How to use font fallback (cascade list ) with Skia ?

1,571 views
Skip to first unread message

breadson xue

unread,
Nov 19, 2015, 12:56:43 PM11/19/15
to skia-discuss
Skia create SkTypeface instance with a font name. but if I try to draw a character which don't have glyph in the font, how to make it fallback to fallback font? For example if I create SkTypeface for Helvetica, when I draw Chinese, how to fallback to a Chinese font?

I tried to use SkCreateTypefaceFromCTFont, pass CTFontRef to it. I create CTFontRef  by CTFontCreateWithFontDescriptor(), which could pass a

kCTFontCascadeListAttribute as attributes, then I can set cascade list attributes. but it seem can not work. Who know if Skia support attributes kCTFontCascadeListAttribute to set font fallback list?

David Lattimore

unread,
Nov 23, 2015, 5:05:11 PM11/23/15
to skia-d...@googlegroups.com
You can call textToGlyphs on the SkPaint to convert your text to glyph IDs. Any glyph IDs that are 0 are missing glyphs. You can split your text accordingly and then use a different font for those parts of the text. I'm not quite sure with textToGlyphs how you can know which characters produced the missing glyphs since characters don't map 1:1 to glyphs. I do something similar to this in my application except that I use FreeType2 directly to map characters to glyph IDs. This gives me information about which characters particular ranges of glyphs came from.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

breadson xue

unread,
Nov 25, 2015, 3:10:00 PM11/25/15
to skia-discuss
Hi David, thanks for response!
Do you know any example to use textToGlyphs to implement font fallback? I tried to see how chromium implement font fallback, but it looks they don't use textToGlyphs. Do you know how chromium implement font fall fallback? or any hint which files ?

Thanks a lot!

在 2015年11月23日星期一 UTC-8下午2:05:11,David Lattimore写道:

Cary Clark

unread,
Nov 25, 2015, 4:19:01 PM11/25/15
to skia-d...@googlegroups.com
Chrome uses Harfbuzz to select the glyphs and fonts corresponding to runs of text, and calls Skia with runs of glyphs and fonts that don't require fallbacks. Unfortunately, no one has written a simple example that shows how to use Skia and Harbuzz in tandem.

You could be the first!

Cary

breadson xue

unread,
Dec 1, 2015, 12:57:32 AM12/1/15
to skia-discuss
Do you know in which file Chrome using Harfbuzz, I'd like to see how they use it. A

在 2015年11月25日星期三 UTC-8下午1:19:01,Cary Clark写道:

Cary Clark

unread,
Dec 1, 2015, 8:25:01 AM12/1/15
to skia-d...@googlegroups.com
Look at the files in

src/third_party/WebKit/Source/platform/fonts/shaping

hongrui chen

unread,
Dec 30, 2015, 1:57:17 AM12/30/15
to skia-discuss
and android use harfbuzz too, and it implment it's own shape engine called minikin to encapsulate harfbuzz lib, it will easily to found how to use in Cnavas.DrawText.
 
在 2015年12月1日星期二 UTC+8下午9:25:01,Cary Clark写道:
Reply all
Reply to author
Forward
0 new messages