maplibre-gl-js icon indicating copy to clipboard operation
maplibre-gl-js copied to clipboard

Fall back to local glyph rendering if glyph PBF is unavailable

Open 1ec5 opened this issue 1 year ago • 7 comments

If a glyph PBF is unavailable, try to fall back to local glyph rendering, and keep rendering the map without crashing.

A label “ABC” followed by the Object Replacement Character followed by “ABC” against a gray background.

Fixes #3302 and fixes #4563.

Launch Checklist

  • [x] Confirm your changes do not include backports from Mapbox projects (unless with compliant license) - if you are not sure about this, please ask!
  • [x] Briefly describe the changes in this PR.
  • [x] Link to related issues.
  • [x] Include before/after visuals or gifs if this PR includes visual changes.
  • [x] Write tests for all new functionality.
  • [ ] Document any changes to public APIs.
  • [ ] Post benchmark scores.
  • [x] Add an entry to CHANGELOG.md under the ## main section.

1ec5 avatar Aug 15 '24 23:08 1ec5

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 96.29%. Comparing base (897cff1) to head (36c323a). :warning: Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4564      +/-   ##
==========================================
+ Coverage   96.28%   96.29%   +0.01%     
==========================================
  Files         293      293              
  Lines       35437    35475      +38     
  Branches     8684     8688       +4     
==========================================
+ Hits        34119    34160      +41     
+ Misses       1318     1315       -3     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov-commenter avatar Aug 15 '24 23:08 codecov-commenter

Looks good, thanks!

HarelM avatar Aug 18 '24 06:08 HarelM

Ping. Any plans for merging this?

spatialillusions avatar Nov 10 '24 09:11 spatialillusions

I think @1ec5 mentioned there is work that he is planning to do before this can be merged as far as I remember...

HarelM avatar Nov 10 '24 11:11 HarelM

Yes, the to-do list looks like:

  • [x] Relax the requirement for glyphs
  • [x] Go back to only using localIdeographFontFamily for ideographic ranges
  • [x] Try to match text-font to a local font (pass in the property value to TinySDF as the fontFamily)

These changes are straightforward but may require a proposal to change the style spec. I haven’t gotten around to that part yet.

1ec5 avatar Nov 11 '24 03:11 1ec5

@1ec5 any updates on this? I would like to clean up some of the PR that are open for some time...

HarelM avatar Dec 12 '24 10:12 HarelM

There should (also) be an API for this in my opinion.

I don't want people to author styles without a glyphs property (that won't function with Native for the forseeable future, and will be a hassle to use in any case) just to take advantage of local font rendering.

louwers avatar Mar 26 '25 23:03 louwers

@1ec5 where are we with regards to this PR?

HarelM avatar Jul 28 '25 07:07 HarelM

We merged maplibre/maplibre-style-spec#1068, which unblocks this PR, so the rest is pretty straightforward. However, maplibre/maplibre-style-spec#1204 just landed too – would it be necessary to implement that feature within the scope of this PR, or can we stage it one font selection mechanism at a time?

1ec5 avatar Jul 28 '25 08:07 1ec5

I don't think it should be part of this PR. The issue is tracked here: https://github.com/maplibre/maplibre-gl-js/issues/50 And can (and should probably) be solved in a diff PR.

HarelM avatar Jul 28 '25 08:07 HarelM

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​maplibre/​maplibre-gl-style-spec@​24.3.0 ⏵ 24.3.11001009897 +370

View full report

socket-security[bot] avatar Oct 30 '25 16:10 socket-security[bot]

Sorry for the huge number of comments on such a short block of code and not so drastic changes, but it's already hard to understand it, so I want to make it a little bit better from readability aspect. I hope you'll forgive me :-)

HarelM avatar Oct 30 '25 21:10 HarelM

I understand and appreciate it! It was already spaghetti code before I added at least two other variables to the mix. #4550 and 1ec5/maplibre-gl-js#1 will result in even more churn in this area, so I may not be as aggressive in refactoring this code as I normally would be.

1ec5 avatar Oct 30 '25 21:10 1ec5

I've added some last minor comments and this can be merged afterward. Thanks for all the work on this!

HarelM avatar Oct 31 '25 07:10 HarelM