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

Rendering text with ellipsis does not work when StringFormatFlags.NoWrap is specified. #735

Open
jhergens opened this issue Mar 8, 2022 · 0 comments

Comments

@jhergens
Copy link

jhergens commented Mar 8, 2022

Rendering text with StringTrimming.EllipsisCharacter and StringFormatFlags.NoWrap does not render any ellipsis.

The following code:

using var font = new Font("Arial", 11f, GraphicsUnit.Pixel);
using var backBuffer = new Bitmap(100, 35);
using (var graphics = Graphics.FromImage(backBuffer))
using (var stringFormat = new StringFormat())
{
    graphics.Clear(Color.White);
    stringFormat.FormatFlags = StringFormatFlags.NoWrap;
    stringFormat.Trimming = StringTrimming.EllipsisCharacter;
    var bounds = new RectangleF(10, 10, 45, 16);
    graphics.FillRectangle(Brushes.Red, bounds);
    graphics.DrawString("Too long string", font, Brushes.Black, bounds, stringFormat);
}

Renders an image like this on Windows:
text_win

But like this on Linux with Pango backend:
text_linux

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