-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix accuracy of drawing text along a path #178
Conversation
Codecov Report
@@ Coverage Diff @@
## main #178 +/- ##
===================================
Coverage 71% 71%
===================================
Files 87 87
Lines 5307 5349 +42
Branches 1089 1094 +5
===================================
+ Hits 3797 3835 +38
+ Misses 1297 1295 -2
- Partials 213 219 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
OK. So here's the current layout state for both horizontal and vertical text in this PR. I'm rendering multiline text which is wraps at the length of the path. It looks to me like our calculations start off accurate for both text directions but become less so. I'll need help figuring out why. |
I'm actually very happy with this now however there is an issue with |
To be honest I'm not exactly convinced how great a test that is in the first place as they are measuring different things at different points in the processing pipeline of rendering, one don prior to hinting and everything the other is a final vector once all that stuff is applied etc to unblock yourself in this test case however you can do -FontRectangle measuredBounds = TextMeasurer.MeasureBounds(text, options);
+FontRectangle direcectMesured = TextMeasurer.MeasureBounds(text, options);
+var measuredBounds = new FontRectangle(new(0, 0), direcectMesured.Size + direcectMesured.Location); and that test passes again |
|
||
svgPath = FindPoint(svgPath, out PointF point, relative, c); | ||
if (svgPath.Length > 0) | ||
if (TryFindScaler(ref svgPath, out float radiiX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skia was comparing each pointer here whereas we would only draw an arc if the span processing wasn't complete. Wile fixing to allow checking each step I change the order of params for consistency.
|
||
Vector2 targetPoint = point.Point + new PointF(0, rect.Top - this.yOffset); | ||
// Now offset our target point since we're aligning the bottom-left location of our glyph against the path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SVG docs say vertical layout should use the centre point but I found left/bottom still yielded better results.
@@ -17,8 +17,8 @@ | |||
<None Include="..\..\shared-infrastructure\branding\icons\imagesharp.drawing\sixlabors.imagesharp.drawing.128.png" Pack="true" PackagePath="" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta16" /> | |||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1-alpha.0.1" /> | |||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta16.13" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the text drawing reference updates are a result of updating Fonts which contains layout fixes.
Prerequisites
Description
My attempt to fix the accuracy of drawing text along a given path. Fixes #159
Layout rules are different for vertical text. https://svgwg.org/svg2-draft/text.html#TextpathLayoutRules
Merging #177 already improved the output for horizontal layout but more work was required to fix the over rotation of letters.
Old
New
I can't tell whether the glyph offsetting in the outer row is expected.