mapbox / node-fontnik

Fonts ⇢ protobuf-encoded SDF glyphs
BSD 3-Clause "New" or "Revised" License
222 stars 65 forks source link

Expose ascender/descender metadata properties in protobuf #160

Open tristen opened 5 years ago

tristen commented 5 years ago

Pull what's applicable from https://github.com/mapbox/node-fontnik/pull/97 into this commit.

springmeyer commented 5 years ago

The branch is passing now on travis since I fixed this minor issue (https://github.com/mapbox/node-fontnik/pull/161) and merged that fix into this branch. The next steps I see for this work are:

zmiao commented 5 years ago

Some experimenting rendering results after applying the ascender value in MBGL for fixing the dis-alignment of mixed fonts:

After fix Before fix
Screen Shot 2019-09-17 at 6 43 29 PM Screen Shot 2019-09-17 at 6 44 50 PM
Screen Shot 2019-09-17 at 6 51 54 PM Screen Shot 2019-09-17 at 6 51 20 PM

Next step for testing would be trying to figure out how to deal with issues in https://github.com/mapbox/mapbox-gl-js/issues/8560

zmiao commented 5 years ago

@tristen @springmeyer in the source code https://github.com/mapbox/node-fontnik/blob/d65c204a3134bfe7b0d4ed020c088861e98744e9/src/glyphs.cpp#L297-L310, each font-face equals to a new fontstack in the pbf. So what does font-face mean? Does it imply a new font type?

I am confused because that I tried to use the executable build-glyphs to generate the pbf data from one .ttc file that containing multiple fonts, but finally the output is still the general ranges pbf, nothing is font related. Did I miss something, how can I generate font-specific pbf data if the *.ttc has multiple fonts inside? For example, the NotoSansCJK.ttc in https://www.google.com/get/noto/help/cjk/ has 36 OTF font files in total.

springmeyer commented 5 years ago

👋 @zmiao thanks for asking. This was also a confusion for me when I first considered .ttc behavior. My understanding is this:

A little bit of this history is evident in https://github.com/mapbox/node-fontnik/issues/125

So, overall, to support ttc would need someone to comprehensively test and perhaps fix issues in the entire dependency chain: node-fontnik -> fontmachine -> core-fonts -> api-styles -> mapbox-gl. Because several of those repos are private, if you have questions about them it would make most sense to discuss more in tickets at those repos.

zmiao commented 5 years ago

@springmeyer Thanks for the explanation, it is really helpful.

So based on your comments, right now we do not support generating pbf from multi-face ttc, but the weird thing is if I upload the ttc file via MapboxStudio, I could get multiple fonts, how did it work? I assume MapboxStudio uses the same node-fontnik engine, right?

springmeyer commented 5 years ago

Interesting @zmiao - I would have assumed you'd get an error due to this line: https://github.com/mapbox/fontmachine/blob/0e5eaab3fd99153083f08278d7a55792d2b6f3ce/index.js#L32

I assume MapboxStudio uses the same node-fontnik engine, right?

Yes, the backend of Mapbox Studio uses node-fontnik@0.5.3

zmiao commented 5 years ago

@springmeyer It was my bad. Actually for my case, I uploaded one otf file, but I got two fonts without any error prompt, I am wondering why it works?

And also if I use bin/build-glyphs to generate pbf from ttc file, I didn't get any errors neither, just have to wait for a very long while.

tmpsantos commented 4 years ago

Hi all, this has been stalled for a while. Do we have plans to merge it?