ALT Linux Bugzilla
– Attachment 19996 Details for
Bug 44767
Метод GdipDrawString считает кириллическую 'Р' пробелом и обрезает её в конце строки.
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
Тестовая программа
drawstring.cs (text/x-csharp), 1.84 KB, created by
Pavel Petrykin
on 2025-11-05 15:04:37 MSK
(
hide
)
Description:
Тестовая программа
Filename:
MIME Type:
Creator:
Pavel Petrykin
Created:
2025-11-05 15:04:37 MSK
Size:
1.84 KB
patch
obsolete
>using System; >using System.Drawing; > >class P { > static void Main() { > Bitmap bmp = new Bitmap(450, 260); > Graphics g = Graphics.FromImage(bmp); > g.Clear(Color.White); > Font f = new Font("Sans", 24); > > string text = " ТÑанÑпондеР"; > float x = 20f; > float y1 = 60f; > float y2 = 170f; > > StringFormat fmtOn = new StringFormat(); > fmtOn.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces; > DrawLabeledString(g, text, f, fmtOn, x, y1, "MeasureTrailingSpaces ON"); > > StringFormat fmtOff = new StringFormat(); > fmtOff.FormatFlags &= ~StringFormatFlags.MeasureTrailingSpaces; > DrawLabeledString(g, text, f, fmtOff, x, y2, "MeasureTrailingSpaces OFF"); > > bmp.Save("out.png"); > g.Dispose(); > bmp.Dispose(); > } > > static void DrawLabeledString(Graphics g, string text, Font f, StringFormat fmt, float x, float y, string label) { > g.DrawString(label, f, Brushes.DarkGreen, new PointF(x, y - 50f)); > > SizeF size = g.MeasureString(text, f, PointF.Empty, fmt); > > using (Brush bg = new SolidBrush(Color.FromArgb(128, 255, 255, 224))) > g.FillRectangle(bg, x, y, size.Width, size.Height); > > g.DrawString(text, f, Brushes.Black, new PointF(x, y), fmt); > > using (Pen p = new Pen(Color.Red, 1f)) > g.DrawRectangle(p, x, y, size.Width, size.Height); > > using (Pen mark = new Pen(Color.Blue, 1f)) { > for (int i = 1; i <= text.Length; i++) { > string prefix = text.Substring(0, i); > SizeF prefSize = g.MeasureString(prefix, f, PointF.Empty, fmt); > float xpos = x + prefSize.Width; > g.DrawLine(mark, xpos, y, xpos, y + size.Height); > } > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 44767
:
19995
| 19996