You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Font rendering artifacts when calling DrawText() with a long multi-line string #572
Looks like its routed in being a bug in SixLabors.Shapes where particularly large composite shapes start dropping intersection points and as it scans from left to right the errors compound across multiple scans. Raised an issue over on the shapes repo to track any investigation etc we need to do on that side.
I have a feeling that it could related to other issues we have seen around Vector2 being retained as properties. The version of the Shapes package I've pointed to has just had them all removed.
Are you connected to the right Myget feed for the nightlies? (It’s linked from the README) Alpha 9 is a very old version number from the old MyGet feed.
changed the title [-]Why are the font near the bottom and right blurred?[/-][+]Font rendering artifacts when calling DrawText() with a long multi-line string[/+]on May 13, 2018
Notice that the problem appears only for larger x, y coordinates (roughly > 1500), and it gets worse the larger the coordinates are (bottom right of bitmap is worst). This indicates that there's a floating point rounding problem: floating point is relatively precise around zero, but less precise the further from zero you get.
From this stand point a future improvement could be using the center of the bitmap as (0, 0), this will reduce the size of a a multiplication by a factor 4, improving the precision by the same factor.
Here's a quick program to reproduce the issue quicker:
public static void CreateA4300FullPageOutputBlurryTest2() {
var textOptions = new TextGraphicsOptions {
Antialias = false,
ApplyKerning = true,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
//WrapTextWidth = PageSize.Width
};
var fo = SixLabors.Fonts.SystemFonts.Find("Microsoft Sans Serif");
var font = new Font(fo, 36, FontStyle.Regular);
//int size = 2500;
int size = 1500;
using (Image<Rgba32> img = new Image<Rgba32>(size, size)) {
img.MetaData.HorizontalResolution = 300;
img.MetaData.VerticalResolution = 300;
img.Mutate(x =>
x.Fill(Rgba32.White)
.DrawText(textOptions, "O", font, Rgba32.Black, new PointF(img.Width - 80, img.Height - 50))
);
img.Save(@"D:\support\image2.png");
}
}
Problem occurs at y >= 1478.5f, set breakpoint condition start.Y >= 1478.5f at InternalPath.FindIntersections. It will report 1 intersection for the outer polygon of the letter 'O' instead of 2.
Activity
JimBobSquarePants commentedon May 12, 2018
Hi @AtwindYu
Thanks for raising this issue. Would it be possible to add an image demonstrating the blurring?
Cheers
James
FisherMS commentedon May 12, 2018
tocsoft commentedon May 12, 2018
Looks like its routed in being a bug in SixLabors.Shapes where particularly large composite shapes start dropping intersection points and as it scans from left to right the errors compound across multiple scans. Raised an issue over on the shapes repo to track any investigation etc we need to do on that side.
@AtwindYu in the mean time could you please try adding/using this package https://www.myget.org/feed/sixlabors/package/nuget/SixLabors.Shapes/1.0.0-ci0018 from our myget feed and see if that solves it for you.
tocsoft commentedon May 12, 2018
I have a feeling that it could related to other issues we have seen around
Vector2being retained as properties. The version of the Shapes package I've pointed to has just had them all removed.JimBobSquarePants commentedon May 13, 2018
Is that alph9 in the image a version number?
FisherMS commentedon May 13, 2018
@tocsoft
It's blurry still.
JimBobSquarePants commentedon May 13, 2018
Could you answer my question above please? That looks like you’re printing using an alpha.
FisherMS commentedon May 13, 2018
@JimBobSquarePants How to set or change the alph9?
JimBobSquarePants commentedon May 13, 2018
Are you connected to the right Myget feed for the nightlies? (It’s linked from the README) Alpha 9 is a very old version number from the old MyGet feed.
https://github.com/SixLabors/ImageSharp/blob/master/README.md#installation
antonfirsov commentedon May 13, 2018
@JimBobSquarePants the example code suggests that he is not using an alpha.
@AtwindYu the question is the source of the marked information in the sample output image you posted in this thread. Is it an old output?
JimBobSquarePants commentedon May 13, 2018
That’s what I’m finding confusing. I’ll need to try to recreate locally but I want to make sure I have all the relevant info first.
FisherMS commentedon May 13, 2018
@JimBobSquarePants
Hi,There is my test code:
@antonfirsov
Here is my nuget packages
JimBobSquarePants commentedon May 13, 2018
@AtwindYu That all make sense now. Thanks for the updated sample and detail. That’s really really helpful. 👍
JimBobSquarePants commentedon May 13, 2018
Issue confirmed using current latest of all packages from nightlies.
[-]Why are the font near the bottom and right blurred?[/-][+]Font rendering artifacts when calling DrawText() with a long multi-line string[/+]diegogvieira commentedon May 17, 2018
Hi, I am having the same issue, is there any workaround ?
Thanks.
antonfirsov commentedon May 17, 2018
@DiegoGarciaa try rendering smaller parts of the text on manually defined locations.
woutware commentedon May 18, 2018
I've patched the issue: SixLabors/Shapes#43.
Notice that the problem appears only for larger x, y coordinates (roughly > 1500), and it gets worse the larger the coordinates are (bottom right of bitmap is worst). This indicates that there's a floating point rounding problem: floating point is relatively precise around zero, but less precise the further from zero you get.
From this stand point a future improvement could be using the center of the bitmap as (0, 0), this will reduce the size of a a multiplication by a factor 4, improving the precision by the same factor.
Here's a quick program to reproduce the issue quicker:
Problem occurs at
y >= 1478.5f, set breakpoint conditionstart.Y >= 1478.5fatInternalPath.FindIntersections. It will report 1 intersection for the outer polygon of the letter 'O' instead of 2.JimBobSquarePants commentedon May 23, 2018
Closing now as in nightlies
antonfirsov commentedon May 23, 2018
Reopening this for now, see:
https://github.com/SixLabors/ImageSharp/issues/496#issuecomment-391323991
antonfirsov commentedon May 26, 2018
Fixed with #596 in beta4.