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 }}
This repository was archived by the owner on Mar 7, 2025. It is now read-only.
I'm using the System.Drawing.Common NuGet package.
Main problem: there is a difference in how method MeasureCharacterRanges work on Windows and on Linux.
On Windows this code works correctly: each char -> rectangle, CR/LF -> empty rectangle.
On Linux: CR symbols disappear, the first symbols of each line after LF also disappear.
Code:
var g = Graphics.FromImage(new Bitmap(1, 1));
var font = new Font("Arial", 11f);
var rect = new RectangleF(0, 0, 99999, 99999);
var sf = new StringFormat();
string text = "12\r\n34\r\n56";
var count = text.Length;
CharacterRange[] cr = new CharacterRange[count];
for (int index = 0; index < count; index++)
{
cr[index].First = index;
cr[index].Length = 1;
}
sf.SetMeasurableCharacterRanges(cr);
Region[] ranges = g.MeasureCharacterRanges(text, font, rect, sf);
RectangleF?[] rects = new RectangleF?[count];
for (int index = 0; index < count; index++)
{
rects[index] = ranges[index].GetBounds(g);
}
Results on Windows:
Results on Linux:
I highlighted the symbols and their rectangles in yellow.