Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update glyph placement to verify all glyphs are valid #5118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### 🐞 Bug fixes
- Fixes line flickering problem ([#5094](https://github.com/maplibre/maplibre-gl-js/pull/5094))
- Fix poor performance in Chrome related to passing matrices to WebGL ([#5072](https://github.com/maplibre/maplibre-gl-js/pull/5072))
- Fix handling invalid glyph placement results along lines ([#5118](https://github.com/maplibre/maplibre-gl-js/pull/5118))
- _...Add new stuff here..._

## 5.0.0-pre.7
Expand Down
10 changes: 7 additions & 3 deletions src/symbol/projection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,13 @@

placedGlyphs = [firstAndLastGlyph.first];
for (let glyphIndex = symbol.glyphStartIndex + 1; glyphIndex < glyphEndIndex - 1; glyphIndex++) {
// Since first and last glyph fit on the line, we're sure that the rest of the glyphs can be placed
placedGlyphs.push(placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, symbol.segment,
lineStartIndex, lineEndIndex, projectionContext, rotateToLine));
// Since first and last glyph fit on the line, try placing the rest of the glyphs.
const placedGlyph = placeGlyphAlongLine(fontScale * glyphOffsetArray.getoffsetX(glyphIndex), lineOffsetX, lineOffsetY, flip, symbol.segment,
lineStartIndex, lineEndIndex, projectionContext, rotateToLine);
if (!placedGlyph) {
return {notEnoughRoom: true};

Check warning on line 472 in src/symbol/projection.ts

View check run for this annotation

Codecov / codecov/patch

src/symbol/projection.ts#L472

Added line #L472 was not covered by tests
}
placedGlyphs.push(placedGlyph);
}
placedGlyphs.push(firstAndLastGlyph.last);
} else {
Expand Down
Loading