Files
ChiaNing 2c632d6dd6 fix(2d): serialize custom font families and restore native font aliases (#382)
* refactor(2d): share font family and descriptor helpers

Extract the existing TTF and CHAR font family selection and font description
construction into shared helpers. Preserve raw family values, the Arial
fallback, and the existing size and style formatting.

* fix(2d): serialize custom font families at CSS boundaries

Quote and escape raw custom font names before Canvas and DOM consumption,
while preserving system family expressions. Keep Web-loaded aliases raw
and share the serialized expression across registration and loading.

Carry CssFontFamily through Label consumers and cover serialization,
TTF/CHAR selection, EditBox styles, and Web FontFaceSet loading in tests.

* fix(2d): preserve font names during scaling and refresh load metrics

Build CHAR draw descriptors from the scaled size and serialized family,
so unit-like substrings in font names are not rewritten by scaling.

Set the font before baseline measurement and read live Canvas metrics
during Web font polling instead of reusing cached fallback widths.
Add regression tests for the actual CHAR draw path and load completion.

* refactor(native): extract canvas font parsing

Move the existing platform-specific parsing into an internal helper and
return the family, size, and style flags to CanvasRenderingContext2D.
Preserve the existing matching rules, conversions, fallbacks, and update order.

Validated 12,650 comparisons with the original setFont implementation
across five platform macro variants.

* fix(native): restore serialized font aliases within legacy policy

Decode a single quoted CSS family into the descriptor used before TS
serialization. Adopt the result only when the existing platform parser
recognizes the complete registered alias; retain legacy fallbacks otherwise.

Cover existing aliases, escaped encodings, platform name restrictions,
style and size policies, and malformed inputs without expanding font support.

* fix(native): preserve size when a quoted font name falls back

Keep a valid requested px size when a well-formed quoted font family is
rejected on Apple or QNX, while retaining the existing fallback font and
style flags. Leave malformed prefixes, lists, and unsafe sizes unchanged.

Preserve the existing size conversion on other native platforms.

* fix(2d): resolve font family types in bundled declarations

* test(2d): cover explicit native font alias compatibility

* fix(2d): resolve font CI lint diagnostics

Allow implicit move of the native font parsing result and wrap EditBox placeholder CSS without changing its output.

Validation: targeted clang-tidy check, ESLint with zero warnings, 13 native parser tests, and 2062 font policy comparisons.
2026-10-27 10:06:11 +08:00
..