Prepare text pipeline for future Pretext integration#492
Merged
Conversation
This was referenced Apr 20, 2026
This was referenced Apr 28, 2026
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.
PR Summary: Prepare
Svg.SkiaText Pipeline For Future Pretext IntegrationOverview
This change prepares
Svg.Skiafor a futurePretext-backed text preparation layer without introducing any runtime dependency onPretextand without modifying upstreamPretextSharp.The refactor keeps SVG-specific placement and rendering ownership in
SvgSceneTextCompiler, but extracts an internal prepared-text boundary that can eventually host a different preparation and measurement implementation.Why
The current text pipeline in
SvgSceneTextCompilermixes several concerns in the same area:That coupling makes it hard to introduce a future prepared-text engine safely. The goal of this PR is to separate the preparation and measurement boundary first, while preserving the existing SVG behavior.
What Changed
1. Added a prepared-text abstraction
A new internal partial file,
src/Svg.SceneGraph/SvgSceneTextCompiler.PreparedText.cs, introduces:ISvgPreparedTextEnginePreparedFlatTextRunPreparedSequentialTextPreparedSequentialRunCurrentSvgPreparedTextEngineThe default implementation still delegates to the current
Svg.Skiatext-measurement behavior. NoPretextAPIs are referenced.2. Moved flat-run preparation and cache ownership behind that abstraction
The prepared-text engine now owns the boundary for:
The existing top-level helpers in
SvgSceneTextCompilernow delegate to the prepared-text engine instead of owning the measurement policy directly.3. Routed sequential fast paths through prepared sequential text
Sequential measurement and alignment paths now use prepared sequential text when they need aggregate run advances:
This keeps behavior unchanged while reducing duplication around repeated sequential width probes.
4. Preserved existing fast-path behavior
During review, the refactor was tightened to avoid unintended slowdowns or fallback regressions:
MeasureSequentialTextRuns(...)now falls back to summing per-run advances instead of returning0if preparation failsTests Added
tests/Svg.Skia.UnitTests/SvgSceneTextCompilerTests.csnow includes coverage for:tspanbarriersBehavioral Scope
This PR is intentionally limited to preparation and measurement refactoring.
It does not change ownership of:
textPathx/y/dx/dytextLengthplacement rulesThose remain in the existing
Svg.Skiatext engine.Commit Breakdown
0c7a8c4c3Add Pretext feasibility plan5b5200b92Extract prepared text engine924e57639Add prepared text compiler testsValidation
The final state was verified with:
dotnet build Svg.Skia.slnx -c Releasedotnet test tests/Svg.Skia.UnitTests/Svg.Skia.UnitTests.csproj -f net10.0 -c Release --no-restore --filter "FullyQualifiedName~SvgSceneTextCompilerTests"dotnet test Svg.Skia.slnx -c ReleaseObserved final result:
SvgSceneTextCompilerTests:12passedSvg.Skia.UnitTests:1628passed,593skipped,2221totalRisks / Follow-up
This PR improves the integration boundary, but it does not yet provide a drop-in alternative prepared-text engine. The next safe steps would be:
Notes
PretextSharpchanges are required or included here.externals/SVGsubmodule state was left untouched.