Choose correct shaper and avoid infinite loop #478
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Fixes #475
This pull request introduces several improvements and bug fixes to the advanced typographic shaping logic and font test infrastructure. The main focus is on more robust script detection and fallback handling in the OpenType GPOS/GSUB tables, as well as enhancements to test coverage and test font management.
Advanced Typographic Shaping Improvements:
ScriptClass.Defaultvalue to represent a fallback/default script, and updated theUnicodeScriptTagMapto include appropriate tags for this default. This allows the shaping engine to gracefully fall back to a default shaper if a script is not present in the font. [1] [2]GetScriptClassmethod in bothGSubTableandGPosTableto determine whether the current script is supported by the font, and to returnDefaultif not. Updated relevant shaping logic to use this method, improving script fallback handling and preventing incorrect shaping when text contains unsupported scripts. [1] [2] [3] [4] Fb617cd5L319R319, [5][]). [1] [2] [3] [4] [5] [6]Bug Fixes and Logic Corrections:
GlyphPositioningCollection.TryUpdatewhere the check for removing fallback glyphs now correctly usesreplacementCount == 0instead ofj == 0.LookupType2Format1SubTablea sealed class and improved variable declarations for clarity and consistency. [1] [2] [3]Test Infrastructure and Coverage:
Issues_475) to verify correct glyph counting and fallback handling for scripts not supported by the provided fonts, ensuring no exceptions are thrown and the correct glyph count is returned.NotoSansSCThinBadtest font where appropriate, and fixed a reference in an issue test to use the correct font. [1] [2] [3]These changes collectively improve the robustness of script detection and fallback in font shaping, clarify test font usage, and expand test coverage for edge cases.