From 9021a444b561e521629f6308aabadafcde8d43ac Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 2 May 2013 01:17:30 +0200 Subject: [PATCH] Attempt to fix glyph resizing on texture limitation --- Vocaluxe/Base/Fonts/CGlyph.cs | 15 +++++++++------ Vocaluxe/Screens/CScreenTest.cs | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Vocaluxe/Base/Fonts/CGlyph.cs b/Vocaluxe/Base/Fonts/CGlyph.cs index 2feee41a..82f6a46f 100644 --- a/Vocaluxe/Base/Fonts/CGlyph.cs +++ b/Vocaluxe/Base/Fonts/CGlyph.cs @@ -110,13 +110,16 @@ namespace Vocaluxe.Base.Fonts g.FillPath(Brushes.White, path); } } - Rectangle realBounds = _GetRealBounds(bmp); - _DrawBounding = realBounds; - float dx = (fullSize.Width - boundingSize.Width - 1) / 2; - _DrawBounding.X -= dx; - using (Bitmap bmpCropped = bmp.Clone(realBounds, PixelFormat.Format32bppArgb)) + _DrawBounding = _GetRealBounds(bmp); + using (Bitmap bmpCropped = bmp.Clone(_DrawBounding, PixelFormat.Format32bppArgb)) { + float dx = (fullSize.Width - boundingSize.Width - 1) / 2; + _DrawBounding.X -= dx; _Texture = CDraw.AddTexture(bmpCropped); + _DrawBounding.X *= _Texture.Width / _DrawBounding.Width; + _DrawBounding.Y *= _Texture.Width / _DrawBounding.Width; + _DrawBounding.Width = _Texture.Width; + _DrawBounding.Height = _Texture.Height; if (false) { if (outline > 0) @@ -146,8 +149,8 @@ namespace Vocaluxe.Base.Fonts float factor = _GetFactor(); x += _DrawBounding.X * factor; y += _DrawBounding.Y * factor; - float w = _DrawBounding.Width * factor; float h = _DrawBounding.Height * factor; + float w = _DrawBounding.Width * factor; rect = new SRectF(x, y, w, h, z); } diff --git a/Vocaluxe/Screens/CScreenTest.cs b/Vocaluxe/Screens/CScreenTest.cs index d7b3b722..7ab2ef52 100644 --- a/Vocaluxe/Screens/CScreenTest.cs +++ b/Vocaluxe/Screens/CScreenTest.cs @@ -51,7 +51,7 @@ namespace Vocaluxe.Screens _AddText(text); text = new CText(10, 210, 1, 32, 0, EAlignment.Left, EStyle.Bold, "Outline", color, "Bold Text" + test, -1, 26, 0); _AddText(text); - text = new CText(10, 250, 1, 32, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "Italic Text" + test, -1, 26, 0); + text = new CText(10, 250, 1, 400, 0, EAlignment.Left, EStyle.Italic, "Outline", color, "Italic Text" + test, -1, 26, 0); _AddText(text); }