[cairo] possible bug win32 font metrics

Lynn Neir lynn.neir at skype.net
Mon Mar 26 15:59:50 PDT 2012


Hello, I was debugging into method _cairo_win32_scaled_font_set_metrics (cairo-win32-font.c) and I'm trying to figure out the logic.  It seems when preserve_axes is true (which it is for 0 and 90 rotations) then regardless of hint metrics setting it always follows the first path that does hinting.  In another method _cairo_win32_scaled_font_init_glyph_metrics, it does something different.   It seems like the code in _cairo_win32_scaled_font_set_metrics should match logic in _cairo_win32_scaled_font_init_glyph_metrics.   I guess I also don't understand this 'preserve_axis' logic and why hint metrics setting is basically ignored in current code below.

Current code:
static cairo_status_t
_cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
{
    cairo_status_t status;
    cairo_font_extents_t extents;

    TEXTMETRIC metrics;
    HDC hdc;

    hdc = _get_global_font_dc ();
    assert (hdc != NULL);

    if (scaled_font->preserve_axes || scaled_font->base.options.hint_metrics == CAIRO_HINT_METRICS_OFF) {
      /* For 90-degree rotations (including 0), we get the metrics
      * from the GDI in logical space, then convert back to font space
      */
     status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
    ...

Proposed change???:
static cairo_status_t
_cairo_win32_scaled_font_set_metrics (cairo_win32_scaled_font_t *scaled_font)
{
    cairo_status_t status;
    cairo_font_extents_t extents;

    TEXTMETRIC metrics;
    HDC hdc;

    hdc = _get_global_font_dc ();
    assert (hdc != NULL);

    if (scaled_font->preserve_axes && scaled_font->base.options.hint_metrics != CAIRO_HINT_METRICS_OFF) {
      /* For 90-degree rotations (including 0), we get the metrics
      * from the GDI in logical space, then convert back to font space
      */
      status = cairo_win32_scaled_font_select_font (&scaled_font->base, hdc);
               ....

Thanks for your help,
Lynn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120326/d2a2dc58/attachment.html>


More information about the cairo mailing list