Bug 28100 - Font option CAIRO_HINT_METRICS_OFF unhonoured on win32 (and a fix)
Summary: Font option CAIRO_HINT_METRICS_OFF unhonoured on win32 (and a fix)
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: win32 backend (show other bugs)
Version: 1.9.7
Hardware: Other Windows (All)
: medium normal
Assignee: cairo-bugs mailing list
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-14 01:41 UTC by Richard Procter
Modified: 2010-05-14 11:49 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Proposed fix (674 bytes, application/octet-stream)
2010-05-14 01:41 UTC, Richard Procter
Details

Description Richard Procter 2010-05-14 01:41:24 UTC
Created attachment 35646 [details]
Proposed fix

Note: This was mistakenly logged as pango bug #615909 - see there for the test program. 

Running the test program gives this output: 

$ ./textsize.exe ON
MINGW32_NT-5.0 LOTUS 1.0.11(0.46/3/2) 2009-07-11 17:46 i686 Msys
Cairo version: 1.8.8
Pango version: 1.26.2
Hint metrics set to: ON
Font: 'arial 12px'
Layout text: 'The origin of thinking is some perplexity, confusion or doubt.'
Ink extents: (0,3) 326x11
Logical extents: (0,0) 327x15

$ ./textsize.exe OFF
MINGW32_NT-5.0 LOTUS 1.0.11(0.46/3/2) 2009-07-11 17:46 i686 Msys
Cairo version: 1.8.8
Pango version: 1.26.2
Hint metrics set to: OFF
Font: 'arial 12px'
Layout text: 'The origin of thinking is some perplexity, confusion or doubt.'
Ink extents: (0,3) 326x11
Logical extents: (0,0) 327x15

The logical extents are unaffected by the cario hint metrics font option
setting on win32.

According to Behdad Esfahbod, this is a known problem on win32, where hint
metrics is stuck at CAIRO_HINT_METRICS_ON (whereas on OS X it is stuck at
CAIRO_HINT_METRICS_OFF).

This is significant because turning off hint metrics is a useful way to ensure
consistent layout sizes cross-platform, which is a requirement for
cross-platform diagramming applications.  

The problem looks to be a typo in cairo-win32-font.c, comparing 
CAIRO_HINT_METRICS_OFF against options.hint_style, 
rather than options.hint_metrics. Once fixed with the attached patch the 
backend looks to do the Right Thing (and is a useful reminder for me 
that C enums are macros in drag!).  

best, 
Richard. 

PS. And I'll take the opportunity here to thank everyone responsible for cairo. I am no expert on such libraries, but I have found it a pleasure to understand and to use due to the clear separation of concerns, the elegant and powerful interface, and the largely impeccable documentation to boot.
Comment 1 Behdad Esfahbod 2010-05-14 11:49:15 UTC
Fixed in master.  Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.