foliojs / fontkit

An advanced font engine for Node and the browser
1.46k stars 219 forks source link

Extracting Glyph path for CJK fonts with Italic or bold #217

Closed ningliu19 closed 4 years ago

ningliu19 commented 4 years ago

Hi, I'm trying to use fontkit to extract glyph path from CJK fonts, regular style is OK, but I'm not able to get Italic or bold styled glyph path from CJK fonts. Wondering if this is supported by fontkit? Thanks!

devongovett commented 4 years ago

Italic and bold variants are usually in separate font files.

ningliu19 commented 4 years ago

@devongovett thanks for replying! I want to detail a bit: for example, I want to fetch a Chinese character '我' in Arial font, the glyph turns out to be: image Obviously, id is 0 and the glyph path is a 10 segment array(which looks like a box). So does this mean this Chinese character cannot be loaded by fontkit? thanks!

Pomax commented 4 years ago

the id being 0 means the glyph does not exist in this font and you got the .notdef identifier back. It's not that Fontkit "can't load it", this font does not support 我 at all so there's nothing to load.

ningliu19 commented 4 years ago

@Pomax ah..ok, thanks!

ningliu19 commented 4 years ago

@Pomax however, I tried a font PingFang SC, still it returns undefined path. I'm very sure this font has the glyph, because in Mac osX pages it looks like this: image So I'm confused because for this font, id is not 0, but path is undefined

ningliu19 commented 4 years ago

image I also noticed the hasError is true for the returned glyph.

Pomax commented 4 years ago

Yep, that sure looks like an error in the CFF parsing part of Fontkit.

devongovett commented 4 years ago

Probably fixed by #224?