openpencil/tests/engine/text/fonts/web-fonts.test.ts
Danila Poyarkov 47fe43c3ec feat(text): harden font resolution lifecycle
- Gate ingest rendering until required faces and script fallbacks resolve
- Key CanvasKit artifacts by font registration generation and invalidate affected nodes
- Load character-aware remote subsets with cumulative coverage and exact render aliases
- Use BCP-47 language hints for shaping and CJK fallback order
- Keep baked .fig glyphs as an exhaustion-only fallback
2026-07-17 14:52:35 +03:00

20 lines
865 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { normalizedCoverageText, webFontSubsetsForText } from '@open-pencil/core/text'
describe('web font coverage requests', () => {
test('normalizes coverage without splitting supplementary code points', () => {
expect(normalizedCoverageText('界A界𠀀A')).toBe(normalizedCoverageText('A界𠀀'))
expect(Array.from(normalizedCoverageText('𠀀'))).toEqual(['𠀀'])
})
test('requests script-specific subsets instead of Latin only', () => {
expect(webFontSubsetsForText('مرحبا')).toContain('arabic')
expect(webFontSubsetsForText('한글')).toContain('korean')
expect(webFontSubsetsForText('かな')).toContain('japanese')
expect(webFontSubsetsForText('你好')).toEqual(
expect.arrayContaining(['chinese-simplified', 'chinese-traditional', 'japanese'])
)
})
})