Compare commits
2
Commits
0.4.0.beta2
..
0.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41cf7a5ac2 | ||
|
|
d94868f466 |
No files matched your search
@@ -84,7 +84,7 @@ namespace Vocaluxe.Base
|
|||||||
if (_WidthTrimmed < 0f)
|
if (_WidthTrimmed < 0f)
|
||||||
{
|
{
|
||||||
string text = Text.TrimEnd(null);
|
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;
|
return _WidthTrimmed;
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ namespace Vocaluxe.Base
|
|||||||
public CTextElement(string text, Graphics g, Font font)
|
public CTextElement(string text, Graphics g, Font font)
|
||||||
{
|
{
|
||||||
Text = text;
|
Text = text;
|
||||||
SizeF dimensions = g.MeasureString(text, font, -1, StringFormat.GenericTypographic);
|
SizeF dimensions = g.MeasureString(text, font);
|
||||||
Width = dimensions.Width;
|
Width = dimensions.Width;
|
||||||
Height = (dimensions.Height + font.Height) / 2;
|
Height = (dimensions.Height + font.Height) / 2;
|
||||||
_Graphics = g;
|
_Graphics = g;
|
||||||
|
|||||||
@@ -51,7 +51,13 @@ namespace Vocaluxe.Base.Fonts
|
|||||||
if (chr != ' ')
|
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
|
//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
|
// ReSharper disable CompareOfFloatsByEqualityOperator
|
||||||
if (_BoundingBox.Height == 0)
|
if (_BoundingBox.Height == 0)
|
||||||
// ReSharper restore CompareOfFloatsByEqualityOperator
|
// ReSharper restore CompareOfFloatsByEqualityOperator
|
||||||
|
|||||||
Reference in new issue
Block a user