Mapbox-gl-js: Use font-provided metadata to determine glyph baseline position

Created on 14 Nov 2013  ·  18Comments  ·  Source: mapbox/mapbox-gl-js

@kkaefer, is this something harfbuzz can produce?

Otherwise, the median bottom edge would probably be a good approximation.

feature

Most helpful comment

Re-earthing @mikemorris's initial work in a new pr https://github.com/mapbox/node-fontnik/pull/160. That should address the downstream work to enable this.

All 18 comments

Why did you close this?

Not sure, reopening

Should this move to fontserver?

@ansis Not sure if this ticket is still relevant, but Harfbuzz is not necessary (FreeType is sufficient) for getting ascender (distance from top to baseline) for a font face. I have an open PR at https://github.com/mapbox/node-fontnik/pull/50 for #154 that implements this and adds it to the glyph PBF (note that all glyphs in a face have the same ascender, so the PBF structure could be optimized a bit here)

@mikemorris https://github.com/mapbox/node-fontnik/pull/50/files got merged into master but master doesn't have the ascender version?

@ansis Looks like we never updated the PBF spec in https://github.com/mapbox/node-fontnik/blob/master/proto/glyphs.proto, I started work on this in https://github.com/mapbox/node-fontnik/pull/97 but it never got merged.

@ansis I think there's more detail on our current implementation in https://github.com/mapbox/mapbox-gl-js/issues/154

Inadvertently closed due to some 🌳 history magic — reopening.

Closing as stale. I haven't seen this become a practical concern yet.

Assuming that this will be subsumed by @ChrisLoer's push on fonts + harfbuzz.

Ah! Good point. We can keep this open to track this aspect of our text shaping work.

@ChrisLoer @ansis @kkaefer Is this something we can move on before switching to Harfbuzz? What would it require to accomplish this? It continues to be a visible issue:

  • Text along lines are often not vertically centered (quite noticeable if the line geometry is also visible, like with road labels along roads).
  • Labels using multiple fonts (due to font fallbacks for different unicode ranges) can have vertically misaligned glyphs.
  • Vertically-oriented text along lines using multiple fonts can have awkward spacing or even overlap between glyphs.

Please let me know if there's anything I can do to help resolve this 🙏

@nickidlugash I think this is something we can work on without Harfbuzz. It does unfortunately require server-side changes -- i.e. we need to get node-fontnik to send the metadata down to the client. Hopefully we can add that to the glyph PBF is a backward compatible way, and just use the baseline if it's there, otherwise fall back to our hardwired value.

Unearthing this issue as deriving this from a fonts metadata instead of using a fixed value would greatly improve labels using mixed font families.

Screen Shot 2019-07-10 at 9 44 44 AM

we need to get node-fontnik to send the metadata down to the client.

@springmeyer wanted to put this on your radar. The only related issue I saw in that project was https://github.com/mapbox/node-fontnik/issues/51

@tristen There's an abandoned PR in which I started most of the work for this at https://github.com/mapbox/node-fontnik/pull/97

👋 @tristen - If someone from @mapbox/map-design-team wants to tackle this I'd be happy to help get them up to speed on node-fontnik development. /cc @jseppi @agentpu1011 @ian29 @brsbl @philogb

Re-earthing @mikemorris's initial work in a new pr https://github.com/mapbox/node-fontnik/pull/160. That should address the downstream work to enable this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muesliq picture muesliq  ·  3Comments

rasagy picture rasagy  ·  3Comments

rigoneri picture rigoneri  ·  3Comments

iamdenny picture iamdenny  ·  3Comments

samanpwbb picture samanpwbb  ·  3Comments