Fire an event when a request for a glyph range PBF returns a bad response
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
I am trying to render font previews using a mapbox-gl map instance and a small custom style that just shows a single text label.
The way I do this is:
- Create a map instance
- Generate a style that takes a font name and some other parameters like color and preview text
- Call `map.setStyle(generatedStyle);`
- Assign a listener for the `'idle'` event, that when triggered, will get the map canvas and save the canvas as a dataURL
- Move on to rendering the next font
Here's a smallish proof-of-concept: https://jsbin.com/putowir/edit?html,js,console,output
It works well when all the fonts for which I want to generate previews exist. If, however, a font does not exist and the request for its glyph range(s) fails (with a `404` generally), the map never triggers its `idle` event. To get around this, I added a timeout so that if `idle` is not triggered before the timeout, the current font preview render is abandoned. You can simulate a bad font in the proof-of-concept by uncommenting the line `// "BAD FONT",`.
I think it would be nicer if the map instead triggered an event when a glyph request fails. Then, instead of using a timeout, I could listen for that that event, abandon the current font preview, and move on to the next one.
## Design Alternatives
## Design
### Implementation
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how glyph range PBF requests are handled and how the map's `idle` event is triggered. The issue names no files or tests, so identify the relevant request and event-handling entry points first. Done means a failed glyph request emits a usable event instead of leaving the map waiting indefinitely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100