Skip to content

[glyphs-reader] Add log-once mechanism to avoid repetitive warnings#1681

Merged
anthrotype merged 5 commits into
mainfrom
glyphs-unknown-cp-log-once
Oct 8, 2025
Merged

[glyphs-reader] Add log-once mechanism to avoid repetitive warnings#1681
anthrotype merged 5 commits into
mainfrom
glyphs-unknown-cp-log-once

Conversation

@anthrotype

Copy link
Copy Markdown
Member

Implements log_once_warn! macro to deduplicate warnings like "unknown custom parameter 'xHeight'" that previously could appear multiple times when parsing .glyphs font with several masters/instances.

Fixes #1680

$ cargo run -- /Users/clupo/.fontc_crater_cache/notofonts/bengali/sources/NotoSansBengali.glyphspackage --log warn
   Compiling glyphs-reader v0.2.3 (/Users/clupo/oss/fontc/glyphs-reader)
   Compiling glyphs2fontir v0.3.1 (/Users/clupo/oss/fontc/glyphs2fontir)
   Compiling fontc v0.3.2 (/Users/clupo/oss/fontc/fontc)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.66s
     Running `target/debug/fontc /Users/clupo/.fontc_crater_cache/notofonts/bengali/sources/NotoSansBengali.glyphspackage --log warn`
[2025-10-07T11:05:58.780560Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'openTypeOS2VendorID'
[2025-10-07T11:05:58.780989Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Enforce Compatibility Check'
[2025-10-07T11:05:58.780998Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'DisableAllAutomaticBehaviour'
[2025-10-07T11:05:58.781004Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Write lastChange'
[2025-10-07T11:05:58.781012Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Axis Mappings'
[2025-10-07T11:05:58.781018Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Variable Font Origin'
[2025-10-07T11:05:58.781774Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'xHeight'
[2025-10-07T11:05:58.781942Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Reencode Glyphs'
[2025-10-07T11:05:58.809449Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Master Icon Glyph Name'
[2025-10-07T11:05:58.809562Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Replace Feature'

 Implements log_once_warn! macro to deduplicate warnings like
 "unknown custom parameter 'xHeight'" that previously could
 appear multiple times when parsing .glyphs font with several
 masters/instances.

 Fixes #1680
@anthrotype anthrotype requested a review from rsheeter October 7, 2025 11:06
@anthrotype

Copy link
Copy Markdown
Member Author

I wonder why we see stuff like 'Axis Mappings' or 'Variable Font Origin' in here, I believe we do support these already... 🤔

[2025-10-07T11:05:58.781012Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Axis Mappings'
[2025-10-07T11:05:58.781018Z ThreadId(1) glyphs_reader::font WARN] unknown custom parameter 'Variable Font Origin'

@anthrotype

Copy link
Copy Markdown
Member Author

I wonder why we see stuff like 'Axis Mappings' or 'Variable Font Origin' in here

I filed separate a issue for this #1682

…ams() to avoid 'unknown' warnings

Previously, some special custom parameters like "Axis Mappings", "Axis Location", and "Variable Font Origin" were triggering false "unknown custom parameter" logging warnings because they would fall through the match statement in RawCustomParams::to_custom_params() method.
Here we make so that these special parameters get extracted and parsed ('consumed') before the generic to_custom_params() conversion runs, which prevents them from being flagged as 'unknown'.

Fixes #1682
Replace Vec::remove() with std::mem::take() in custom parameter handling to avoid O(n) element shifting. Parameters are now marked with sentinel values (Default) instead of being removed from the Vec.
…params

[glyphs-reader] handle special custom parameters before to_custom_params() to avoid 'unknown' warnings
@anthrotype

Copy link
Copy Markdown
Member Author

oops I based #1683 onto this PR branch, but forgot I had to merge this one before the other.. Sorry.

This PR is just this commit ffab31d basically

Comment thread glyphs-reader/src/font.rs Outdated
@anthrotype anthrotype force-pushed the glyphs-unknown-cp-log-once branch from 4109da2 to ebb84ed Compare October 8, 2025 10:02
@anthrotype anthrotype added this pull request to the merge queue Oct 8, 2025
Merged via the queue into main with commit ce47d45 Oct 8, 2025
13 checks passed
@anthrotype anthrotype deleted the glyphs-unknown-cp-log-once branch October 8, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

log once

2 participants