Repository navigation
feat(engines): font resolver, HarfBuzz shaper and Unicode tables for the layout engine - #695
Merged
Merged
Conversation
Line_Break, Bidi_Class, Script and East_Asian_Width as range tables, generated by build/generate-unicode-tables.ps1 from the pinned UCD files (SHA-256 checked, not committed). 16.0.0 is the Unicode version .NET 10 uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rules move unchanged to Typesetting/FontSubstitution.cs; RhwpFonts delegates to them and InstalledFont derives from the shared FontCoverage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- FontResolver: installed fonts through SKFontManager, 한글 / English names, style matching, substitutes for missing fonts, per-cluster fallback; variable fonts at their default instance, CFF2 fonts only without another font for the script. - FontSlots: 한글's seven language slots and Word's four run fonts. - Shaper: HarfBuzz shaping with context, cached in font units, glyph IDs, advances, offsets, clusters and unsafe-to-break flags as the page model takes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 of 12 tasks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change?
Implements the Project 4 item "Layout engine: font resolver, HarfBuzz shaper and Unicode tables" (M0, P0). These are the text services that the paragraph layout, CJK typography and bidi items build on. Everything is in
src/Filee.Engines/Typesettingand runs in-process on what Filee already references: SkiaSharp's font manager, HarfBuzzSharp and .NET. No converter uses it yet.UnicodeData.cs+ generatedUnicodeData.Generated.cs): Line_Break, Bidi_Class, Script and East_Asian_Width for every code point, as range tables. Unassigned code points get the UCD's@missingdefaults (ID for CJK blocks, R / AL for the right-to-left blocks, ...).build/generate-unicode-tables.ps1downloads the pinned UCD files from unicode.org intobuild/.cacheand checks their SHA-256, likefetch-engines.ps1. The UCD files are not committed; the generated C# is.CharUnicodeInfo,RuneandStringInfo. A test walks every code point to check that the tables and .NET agree on what is assigned.FontSlots.cs): character → 한글's seven language slots (HLanguage) and Word's ascii / hAnsi / eastAsia / cs fonts, includingw:hint="eastAsia"for ambiguous-width characters. A grapheme cluster takes the slot of its first character, so marks stay with their base.FontResolver.cs,FontNames.cs,SystemFonts.cs,FontCollection.cs):SKFontManager(DirectWrite, CoreText, fontconfig). Nothing is downloaded or shipped.MatchCharacter. Han characters follow the text's language. Punctuation and spaces stay with their neighbours' font.FontSubstitution.cs): the language, coverage and unusable-font rules move out ofHwp/RhwpFonts.csunchanged.RhwpFontsdelegates to them, so rhwp behaves as before, andRhwpFontsTests/RhwpInputTestspass unchanged.InstalledFontnow derives from the sharedFontCoverage.Shaper.cs): HarfBuzz shaping generalised fromVector/GlyphOutlines.cs.PageContenttakes it) and HarfBuzz's unsafe-to-break flags.ShapedRun.ToGlyphRunmakes the page model'sGlyphRun.PdfPageWriterTestsnow builds its page with it instead of its own HarfBuzz code.Shaper.Metricsgives the font's metrics: ascender / descender / line gap, Win metrics, x-height, cap height, underline, strikeout and super / subscript.The namespace is
Typesetting, notLayout:Filee.Engines.Layoutwould hide ACadSharp'sLayouttype in the CAD code and tests.Decisions (open questions from #683)
Shaping acceptance
Arabic, Devanagari, Gujarati, Thai and Hangul jamo strings written in the tests are checked three ways:
build/fetch-fonts.ps1, which CI fetches. There is no pinned Gujarati font, so Gujarati is checked with whichever of Nirmala UI, Shruti, Lohit or Noto is installed.Open questions
GlyphRuncan't draw them yet. Should the paragraph layout item or the output item add emboldening / skew to the page model?w:lang w:eastAsia="zh-*"). Only the hint is used now.Type of change
How was it tested?
dotnet format --verify-no-changesdotnet test:Filee.Engines.Tests2120 passed, 199 skipped.dotnet build Filee.slnx -c Releasegives no new warnings.Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (none)THIRD-PARTY-NOTICES.md(no packages, fonts or programs; the Unicode data notice is added)🤖 Generated with Claude Code