Fixed drawing non-latin character not correctly, closes #310
This commit is contained in:
1 parent
72bacca5b8
commit
eb9fad65a9
2 files changed
+9
-3
No files matched your search
@@ -84,7 +84,7 @@ namespace Vocaluxe.Base
|
||||
if (_WidthTrimmed < 0f)
|
||||
{
|
||||
string text = Text.TrimEnd(null);
|
||||
_WidthTrimmed = text.Length == Text.Length ? Width : _Graphics.MeasureString(text, _Font, -1, StringFormat.GenericTypographic).Width;
|
||||
_WidthTrimmed = text.Length == Text.Length ? Width : _Graphics.MeasureString(text, _Font).Width;
|
||||
}
|
||||
return _WidthTrimmed;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ namespace Vocaluxe.Base
|
||||
public CTextElement(string text, Graphics g, Font font)
|
||||
{
|
||||
Text = text;
|
||||
SizeF dimensions = g.MeasureString(text, font, -1, StringFormat.GenericTypographic);
|
||||
SizeF dimensions = g.MeasureString(text, font);
|
||||
Width = dimensions.Width;
|
||||
Height = (dimensions.Height + font.Height) / 2;
|
||||
_Graphics = g;
|
||||
|
||||
@@ -51,7 +51,13 @@ namespace Vocaluxe.Base.Fonts
|
||||
if (chr != ' ')
|
||||
{
|
||||
//Gets exact height and width for drawing more than 1 char. But width is to small to draw char on bitmap as e.g. italic chars will get cropped
|
||||
_BoundingBox = g.MeasureString(chrString, fo, -1, StringFormat.GenericTypographic);
|
||||
//See https://stackoverflow.com/questions/11708621/how-to-measure-width-of-a-string-precisely
|
||||
StringFormat format = StringFormat.GenericTypographic;
|
||||
RectangleF rect = new RectangleF(0, 0, 1000, 1000);
|
||||
CharacterRange[] ranges = { new CharacterRange(0, chrString.Length) };
|
||||
format.SetMeasurableCharacterRanges(ranges);
|
||||
_BoundingBox = g.MeasureCharacterRanges(chrString, fo, rect, format)[0].GetBounds(g).Size;
|
||||
|
||||
// ReSharper disable CompareOfFloatsByEqualityOperator
|
||||
if (_BoundingBox.Height == 0)
|
||||
// ReSharper restore CompareOfFloatsByEqualityOperator
|
||||
|
||||
Reference in new issue
Block a user