mirror of
https://github.com/Dasemu/NavFrame.git
synced 2026-11-26 15:26:05 +00:00
fix: keep TFT snapshots alive when labels need unbundled glyph ranges
MapLibre's MapSnapshotter aborts the whole still image on any glyph load
error. The offline style only bundled Noto Sans ranges 0-2047, while the
Asturias archive labels use U+1E36/U+1E37 (Asturian Ḷḷ) and typographic
quotes/dashes, so the TFT failed with SDK/STYLE_READY UNKNOWN/UNKNOWN
("Could not read asset") whenever such a label was in view, while the
phone MapView kept working.
Bundle the unmodified demotiles ranges 7680-7935 and 8192-8447, add an
empty placeholder for every other BMP range, report missing assets as
NOT_FOUND, and release 0.13.7.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014YKH4z66ZCe2wK4GvgRg7g
This commit is contained in:
259 files changed
+846
-9
No files matched your search
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Write an empty glyph PBF for every Unicode BMP range missing from a font stack directory.
|
||||
|
||||
MapLibre's MapSnapshotter aborts a whole still image when any glyph range fails to load,
|
||||
whereas an empty range only omits the uncovered characters. Real ranges are never replaced.
|
||||
"""
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
|
||||
def varint(value: int) -> bytes:
|
||||
out = bytearray()
|
||||
while value >= 0x80:
|
||||
out.append(value & 0x7F | 0x80)
|
||||
value >>= 7
|
||||
out.append(value)
|
||||
return bytes(out)
|
||||
|
||||
|
||||
def field(number: int, payload: bytes) -> bytes:
|
||||
return varint(number << 3 | 2) + varint(len(payload)) + payload
|
||||
|
||||
|
||||
def empty_range(font_stack: str, glyph_range: str) -> bytes:
|
||||
return field(1, field(1, font_stack.encode()) + field(2, glyph_range.encode()))
|
||||
|
||||
|
||||
def main(directory: str) -> None:
|
||||
folder = pathlib.Path(directory)
|
||||
if not folder.is_dir():
|
||||
sys.exit(f"Not a font stack directory: {folder}")
|
||||
for start in range(0, 65536, 256):
|
||||
name = f"{start}-{start + 255}"
|
||||
target = folder / f"{name}.pbf"
|
||||
if not target.exists():
|
||||
target.write_bytes(empty_range(folder.name, name))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit("usage: fill-glyph-ranges.py FONT_STACK_DIRECTORY")
|
||||
main(sys.argv[1])
|
||||
Reference in new issue
Block a user