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

Measure string does not add any extra space at the end of strings #734

Open
jhergens opened this issue Feb 10, 2022 · 0 comments
Open

Measure string does not add any extra space at the end of strings #734

jhergens opened this issue Feb 10, 2022 · 0 comments

Comments

@jhergens
Copy link

In the documentation of the MeasureString method it says it "includes a small amount of extra space before and after the string". This does not seem to be true for libgdiplus.

The following code:

using var font = new Font("Arial", 12, GraphicsUnit.Pixel);
using var backBuffer = new Bitmap(100, 20);
using (var graphics = Graphics.FromImage(backBuffer))
{
    graphics.Clear(Color.White);
    var size = graphics.MeasureString("Hello World", font);
    var destRect = new RectangleF(0, 0, size.Width, size.Height);
    graphics.FillRectangle(Brushes.Red, destRect);
    graphics.DrawString("Hello World", font, Brushes.Black, destRect);
}

Renders like this when building with Pango from main:
text_linux
There is a small amount of white space before the text, but none after.

On Windows with gdiplus there is white space before and after the text:
text_win

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

1 participant