Fixed reflection (Glyph offset)
This commit is contained in:
1 parent
95ff3cd7a3
commit
ac8a53fc55
2 files changed
+17
-18
No files matched your search
@@ -55,7 +55,7 @@ namespace Vocaluxe.Base.Fonts
|
||||
CFonts.Height = maxHeight; // *factor;
|
||||
//float factor = _GetFactor(chr, flags);
|
||||
Font fo = CFonts.GetFont();
|
||||
SizeF fullSize, boundingSize;
|
||||
SizeF fullSize;
|
||||
Size bmpSize;
|
||||
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
|
||||
{
|
||||
@@ -64,20 +64,19 @@ 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
|
||||
boundingSize = g.MeasureString(chrString, fo, -1, new StringFormat(StringFormat.GenericTypographic));
|
||||
boundingSize.Width += outlineSize;
|
||||
if (boundingSize.Height > 0)
|
||||
boundingSize.Height += outlineSize;
|
||||
else
|
||||
boundingSize.Height = fullSize.Height;
|
||||
bmpSize = new Size((int)fullSize.Width, (int)Math.Round(boundingSize.Height));
|
||||
_BoundingBox = g.MeasureString(chrString, fo, -1, new StringFormat(StringFormat.GenericTypographic));
|
||||
_BoundingBox.Width += outlineSize;
|
||||
// ReSharper disable CompareOfFloatsByEqualityOperator
|
||||
if (_BoundingBox.Height == 0)
|
||||
// ReSharper restore CompareOfFloatsByEqualityOperator
|
||||
_BoundingBox.Height = fullSize.Height - outlineSize;
|
||||
bmpSize = new Size((int)fullSize.Width, (int)Math.Round(_BoundingBox.Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
boundingSize = fullSize;
|
||||
_BoundingBox = fullSize;
|
||||
bmpSize = new Size(1, 1);
|
||||
}
|
||||
_BoundingBox = boundingSize;
|
||||
}
|
||||
using (Bitmap bmp = new Bitmap(bmpSize.Width, bmpSize.Height, PixelFormat.Format32bppArgb))
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
@@ -95,7 +94,7 @@ namespace Vocaluxe.Base.Fonts
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
PointF point = new PointF(outlineSize / 2, outlineSize / 2);
|
||||
PointF point = new PointF(outlineSize / 2, outlineSize / 4);
|
||||
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
@@ -113,7 +112,7 @@ namespace Vocaluxe.Base.Fonts
|
||||
_DrawBounding = _GetRealBounds(bmp);
|
||||
using (Bitmap bmpCropped = bmp.Clone(_DrawBounding, PixelFormat.Format32bppArgb))
|
||||
{
|
||||
float dx = (fullSize.Width - boundingSize.Width - 1) / 2;
|
||||
float dx = (fullSize.Width - _BoundingBox.Width - 1) / 2;
|
||||
_DrawBounding.X -= dx;
|
||||
_Texture = CDraw.AddTexture(bmpCropped);
|
||||
/*_DrawBounding.X *= _Texture.Width / _DrawBounding.Width;
|
||||
|
||||
@@ -41,17 +41,17 @@ namespace Vocaluxe.Screens
|
||||
base.Init();
|
||||
const string test = " ÖÄÜabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPGRSTUVWGXZ1234567890";
|
||||
SColorF color = new SColorF(1, 0, 0, 1);
|
||||
CText text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "Normal Text" + test, -1, 26, 0);
|
||||
CText text = new CText(10, 50, 1, 32, 0, EAlignment.Left, EStyle.Normal, "Normal", color, "jÄNormal Text" + test, -1, 26, 0);
|
||||
_AddText(text);
|
||||
text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "Bold Text" + test, -1, 26, 0);
|
||||
text = new CText(10, 90, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Normal", color, "jÄBold Text" + test, -1, 26, 0);
|
||||
_AddText(text);
|
||||
text = new CText(10, 130, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Normal", color, "Italic Text" + test, -1, 26, 0);
|
||||
text = new CText(10, 130, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Normal", color, "jÄItalic Text" + test, -1, 26, 0);
|
||||
_AddText(text);
|
||||
text = new CText(10, 170, 1, 100, 0, EAlignment.Left, EStyle.Normal, "Outline", color, "Normal Text" + test, -1, 26, 0);
|
||||
text = new CText(10, 170, 1, 100, 0, EAlignment.Left, EStyle.Normal, "Outline", color, "jÄNormal Text" + test, -1, 50, 0);
|
||||
_AddText(text);
|
||||
text = new CText(10, 210, 1, 200, 0, EAlignment.Left, EStyle.Bold, "Outline", color, "Bold Text" + test, -1, 26, 0);
|
||||
text = new CText(10, 210, 1, 200, 0, EAlignment.Left, EStyle.Bold, "Outline", color, "jÄBold Text" + test, -1, 100, 0);
|
||||
_AddText(text);
|
||||
text = new CText(10, 250, 1, 300, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "Italic Text" + test, -1, 26, 0);
|
||||
text = new CText(10, 250, 1, 300, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "jÄItalic Text" + test, -1, 150, 0);
|
||||
_AddText(text);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user