Skip to content

Commit

Permalink
Request non-BMP, non-CJKV glyphs from the server
Browse files Browse the repository at this point in the history
Removed the error that artificially prevented the glyph manager from requesting glyph PBFs for ranges beyond U+FFFF.
  • Loading branch information
1ec5 committed Aug 15, 2024
1 parent a440cb6 commit 249b360
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

- Add constants `MAX_TILE_ZOOM = 25` and `MIN_TILE_ZOOM = 0` as maximum and minimum world tile zoom (Z) values; replace hardcoded instances with those constants.
- Add functions `isInBoundsForTileZoomXY` and `isInBoundsForZoomLngLat` to check whether a tile ZXY or a zoom+LngLat is in the world bounds; use `MAX_TILE_ZOOM` and `MIN_TILE_ZOOM` in those checks; replace existing hardcoded checks with those functions.
- Render uncommon Chinese, Japanese, Korean, and Vietnamese characters. ([#4550](https://github.com/maplibre/maplibre-gl-js/pull/4550))
- Render uncommon Chinese, Japanese, Korean, and Vietnamese characters. Prefer local glyph rendering for all CJKV characters, not just those in the CJK Unified Ideographs, Hiragana, Katakana, and Hangul Syllables blocks. Request other characters beyond U+FFFF from the server instead of throwing an error. ([#4550](https://github.com/maplibre/maplibre-gl-js/pull/4550), [#4560](https://github.com/maplibre/maplibre-gl-js/pull/4560))
- _...Add new stuff here..._

### 🐞 Bug fixes

- Fix right-to-left layout of labels that contain characters in the Arabic Extended-B code block. ([#4536](https://github.com/maplibre/maplibre-gl-js/pull/4536))
- Fix 3D map freezing when camera is adjusted against map bounds. ([#4537](https://github.com/maplibre/maplibre-gl-js/issues/4537))
- Fix `getStyle()` to return a clone so the object cannot be internally changed ([#4488](https://github.com/maplibre/maplibre-gl-js/issues/4488))
- Prefer local glyph rendering for all CJKV characters, not just those in the CJK Unified Ideographs, Hiragana, Katakana, and Hangul Syllables blocks. ([#4560](https://github.com/maplibre/maplibre-gl-js/pull/4560)))
- - _...Add new stuff here..._

## 4.5.2
Expand Down
12 changes: 12 additions & 0 deletions src/render/glyph_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ describe('GlyphManager', () => {
expect(returnedGlyphs['Arial Unicode MS'][0x5e73]).toBeNull(); // The fixture returns a PBF without the glyph we requested
});

test('GlyphManager requests remote non-BMP, non-CJK PBF', async () => {
jest.spyOn(GlyphManager, 'loadGlyphRange').mockImplementation((_stack, _range, _urlTemplate, _transform) => {
return Promise.resolve(GLYPHS);
});

const manager = createGlyphManager();

// Request Egyptian hieroglyph 𓃰
const returnedGlyphs = await manager.getGlyphs({'Arial Unicode MS': [0x1e0f0]});
expect(returnedGlyphs['Arial Unicode MS'][0x1e0f0]).toBeNull(); // The fixture returns a PBF without the glyph we requested
});

test('GlyphManager does not cache CJK chars that should be rendered locally', async () => {
jest.spyOn(GlyphManager, 'loadGlyphRange').mockImplementation((_stack, range, _urlTemplate, _transform) => {
const overlappingGlyphs = {};
Expand Down
10 changes: 3 additions & 7 deletions src/render/glyph_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ export class GlyphManager {

const range = Math.floor(id / 256);
const isInBMP = range * 256 <= 0xFFFF;
if (!isInBMP) {
if (this._doesCharSupportLocalGlyph(+id)) {
entry.ranges[range] = true;
return {stack, id, glyph: null};
} else {
throw new Error('glyphs > 65535 not supported');
}
if (!isInBMP && this._doesCharSupportLocalGlyph(+id)) {
entry.ranges[range] = true;
return {stack, id, glyph: null};
}

if (entry.ranges[range]) {
Expand Down

0 comments on commit 249b360

Please sign in to comment.