Bug 16089

Summary: [GTK] Support custom fonts, CachedFont::platformDataFromCustomData()
Product: WebKit Reporter: Alp Toker <alp>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Minor CC: sylvain.pasche
Priority: P2 Keywords: Cairo, Gtk
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Add support for downloadable fonts hyatt: review+

Description Alp Toker 2007-11-21 19:51:08 PST
CachedFont.cpp currently supports custom fonts for the CG and QT ports. We need to add support for this too.
Comment 1 Alp Toker 2008-01-04 03:11:12 PST
This is easy enough to do with FreeType but I heard Pango doesn't provide appropriate API.
Comment 2 Alp Toker 2008-01-07 16:49:10 PST
The relevant commit adding support to WebCore:

http://trac.webkit.org/projects/webkit/changeset/26484

Some code I wrote about a year ago in another project to load TTFs straight from memory with FreeType:

http://git.ndesk.org/?p=ndesk-xps;a=blob;f=src/FreeType.cs;h=f84f067c466843521b9548aa58496e2fa7ac12e6;hb=HEAD
Comment 3 Alp Toker 2008-01-10 10:36:30 PST
Created attachment 18367 [details]
Add support for downloadable fonts
Comment 4 Sylvain Pasche 2008-01-10 11:54:24 PST
>+    // We force antialiasing and disable hinting to provide consistent
>+    // typographic qualities for custom fonts on all platforms.
>+    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
>+    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);

Is this what other ports do for antialiasing?
I'm wondering if with a lcd screen and subpixel aliasing active, having gray antialiased webfonts side by side with subpixel antialiased ones may look odd.
Comment 5 Alp Toker 2008-01-10 14:38:44 PST
(In reply to comment #4)
> >+    // We force antialiasing and disable hinting to provide consistent
> >+    // typographic qualities for custom fonts on all platforms.
> >+    cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
> >+    cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
> 
> Is this what other ports do for antialiasing?
> I'm wondering if with a lcd screen and subpixel aliasing active, having gray
> antialiased webfonts side by side with subpixel antialiased ones may look odd.
> 

I can't see any easy way to do this with the current font code. It's a good point though and is related to bug #16715, so we can add a TODO here.
Comment 6 Dave Hyatt 2008-01-11 12:14:19 PST
Comment on attachment 18367 [details]
Add support for downloadable fonts

This looks good to me.  Can we just remove those ifdefs now that Mac, Win, CG and GTK all support custom fonts?  I think we can...
Comment 7 Alp Toker 2008-01-11 14:00:36 PST
(In reply to comment #6)
> (From update of attachment 18367 [details] [edit])
> This looks good to me.  Can we just remove those ifdefs now that Mac, Win, CG
> and GTK all support custom fonts?  I think we can...
> 

There's still WX I think. Might be an idea to make the feature opt-out though. Best done separately.

Patch landed in r29418 (with a leak-fix spotted by bdash).