feat(converter): improve tab rendering with leader character support#83
Merged
feat(converter): improve tab rendering with leader character support#83
Conversation
- Fix CalcWidthOfRunInTwips to use estimation fallback for unknown fonts instead of returning 0 early, enabling proper tab positioning - Add display:inline-block to leader character spans so CSS width property takes effect - Add estimation fallback in MetricsGetter._getTextWidth when SkiaSharp measurement fails or returns 0 - Propagate tab alignment type via PtOpenXml.TabAlignment attribute to enable future alignment-aware rendering - Add Playwright visual tests for tab rendering (HC024-HC027) - Add LibreOffice reference screenshots for comparison - Document field code resolution as known gap (affects TOC page numbers) - Document platform-specific leader character count variation Note: Leader character counts may vary between platforms due to font measurement differences. Desktop .NET uses SkiaSharp measurement, while WASM uses character-based estimation.
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.
Summary
This PR improves tab rendering in the HTML converter, particularly for tab stops with leader characters (dots, underscores, hyphens).
Key Changes
CalcWidthOfRunInTwipsnow uses character-based estimation when fonts are unavailable instead of returning 0, enabling proper tab positioning on Azure, WASM, and other environments without fontsdisplay: inline-blockto leader character spans so the CSSwidthproperty takes effectcharWidth = fontSize * 0.6 / 2)Testing
Documentation
Known Limitations
Leader character counts may vary between platforms due to font measurement differences:
Test plan
dotnet test Docxodus.Tests/Docxodus.Tests.csprojnpx playwright test tabs-visual.spec.ts