Skip to content
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

Underline and StrikeThrough incorrect when given font size is very smaller #75

Open
mzh3511 opened this issue Jun 21, 2023 · 2 comments

Comments

@mzh3511
Copy link

mzh3511 commented Jun 21, 2023

Given a smaller font size, when painting a TextBlock, the underline and strike-through line are very thick

Due to business logic requirements, my calculated font size is very smaller, but needs to zoom in and be displayed by other modules, the following is my demo code and the screenshot

        private void skglControl1_PaintSurface(object sender, SkiaSharp.Views.Desktop.SKPaintGLSurfaceEventArgs e)
        {
            var surface = e.Surface;
            var canvas = surface.Canvas;

            canvas.Clear(SKColors.White);
            canvas.Scale(20, 20);

            var textBlock = new TextBlock();
            textBlock.AddText("Hello, world", new Style()
                                              {
                                                  FontFamily = "Arial",
                                                  TextColor = SKColors.Black,
                                                  FontSize = 3,
                                                  StrikeThrough = StrikeThroughStyle.Solid,
                                                  Underline = UnderlineStyle.Solid
                                              });
            textBlock.Paint(canvas, new SKPoint(1, 5));
        }

image

I found this is because of 3 if statements in FontRun.cs
image

Is this a valid issue? can I create a pull request to remove the 3 if statements? thanks

A real business logic requirement: The user requires to export the diagram to pdf by Skia, the diagram is very very big, they want to draw it on the A4 paper size pdf file, then the user zoom in at a large scale to see the pdf file clearly, and they saw that the underline is very very thick

@toptensoftware
Copy link
Owner

Thanks for reporting. Not sure actually. I know those if statements were added to fix underlines and strike throughs not appearing when too thin. I think the logic needs to be a bit smarter, but not sure what off hand.

@charlenni
Copy link
Contributor

Perhaps a combination with the scale factor when drawing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants