Open Bug 432411 Opened 16 years ago Updated 1 year ago

Avoid GetGlyphOutlineW for GDI "vector" fonts in cairo

Categories

(Core :: Graphics: Text, defect, P3)

x86
Windows XP
defect

Tracking

()

People

(Reporter: roc, Unassigned)

Details

Attachments

(1 file)

Attached patch fixSplinter Review
Loading a testcase using old-style Win32 "vector" fonts such as 'Modern' can cause warnings about GetGlyphOutlineW failing. These come when we try to measure glyph extents. The current code takes the non-GetGlyphOutlineW path for bitmap fonts, but GetGlyphOutlineW fails for vector fonts as well.

This patch fixes that, and refactors the information about font format into an enumeration. I think this is easier to follow.

Maybe I should just send this directly upstream to cairo? But who would review it there?
Attachment #319533 - Flags: review?(pavlov)
Adrian Johnson -- I've just Cc'd him to this bug.
Should I just send this patch to the cairo list then?
Comment on attachment 319533 [details] [diff] [review]
fix

this looks OK
Attachment #319533 - Flags: review?(pavlov) → review+
The patch has missed OpenType/CFF fonts. I suggest changing the code for getting the font type to:

+   /* The TMPF_TRUETYPE test is not required (both TrueType and OpenType/CFF
+    * fonts have a CMAP table . However it is a free optimization given that 
+    * TrueType fonts are the most common fonts on Windows.
+    */
+    if (metrics.tmPitchAndFamily & TMPF_TRUETYPE ||
+        GetFontData (hdc, CMAP_TAG, 0, NULL, 0) != GDI_ERROR) {
+        scaled_font->type = CAIRO_WIN32_FONT_TRUETYPE;
+    } else if (!(metrics.tmPitchAndFamily & TMPF_VECTOR)) {
+        scaled_font->type = CAIRO_WIN32_FONT_BITMAP;
+    } else {
+         * Calling GetFontData() with tag = 0 on a Type 1 font will retrieve
+         * the Type 1 font. GetFontData() will fail on a stroke fonts such
+         * as "Script" and "Modern".
+         if (GetFontData (hdc, 0, 0, NULL, 0) != GDI_ERROR) {
+             scaled_font->type = CAIRO_WIN32_FONT_TYPE1;
+         } else {
+             scaled_font->type = CAIRO_WIN32_FONT_VECTOR;
+         }
     }


I've committed some recent changes to cairo-win32-font.c so you will probably need to rebase. There is a new _cairo_win32_font_is_bitmap() function.

I suggest adding a comment to the enum explaining that CAIRO_WIN32_FONT_TRUETYPE also includes OpenType/CFF fonts.

Microsoft calls fonts like Modern and Script "stroke fonts" [1]. A comment explaining that CAIRO_WIN32_FONT_VECTOR means stroke fonts would be good. Or maybe just change VECTOR to STROKE as vector can imply any outline font and the TMPF_VECTOR flag is set to true for any non bitamp font.

[1] http://www.microsoft.com/mspress/books/sampchap/2344.aspx#606
Good idea, I'll change it to stroke.
Adrian, do you want me to send the new patch to the cairo list, or just attach it here, or what?
(In reply to comment #6)
> Adrian, do you want me to send the new patch to the cairo list, or just attach
> it here, or what?
> 

Either is fine. Attaching here is probably easiest.
Assignee: roc → nobody
This never got committed upstream, but I don't know if we care anymore.
QA Contact: thebes → jmuizelaar
We seem to be the only recent browser that supports vector fonts. We could probably drop support for them. Still it probably makes sense to try to land something like this sometime.
QA Contact: jmuizelaar → thebes
Moving to p3 because no activity for at least 1 year(s).
See https://github.com/mozilla/bug-handling/blob/master/policy/triage-bugzilla.md#how-do-you-triage for more information
Priority: P2 → P3
Severity: normal → S3
Component: Graphics → Graphics: Text
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: