From 3956fa17d104d8afc90fc1f8510d913a86240e41 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Sun, 28 Apr 2013 14:25:49 +0200 Subject: [PATCH] Small Font fixes --- Vocaluxe/Base/Font/CFonts.cs | 62 ++++++++++++------------------------ Vocaluxe/Base/Font/CGlyph.cs | 11 +++---- 2 files changed, 25 insertions(+), 48 deletions(-) diff --git a/Vocaluxe/Base/Font/CFonts.cs b/Vocaluxe/Base/Font/CFonts.cs index 8012af02..85d7fde3 100644 --- a/Vocaluxe/Base/Font/CFonts.cs +++ b/Vocaluxe/Base/Font/CFonts.cs @@ -20,15 +20,6 @@ namespace Vocaluxe.Base.Font public static EStyle Style = EStyle.Normal; - public static int CurrentFont - { - get { return _CurrentFont; } - set - { - if ((value >= 0) && (value < _Fonts.Count)) - _CurrentFont = value; - } - } public static float Height { get { return _Height; } @@ -196,35 +187,13 @@ namespace Vocaluxe.Base.Font public static void SetFont(string fontName) { - int index; - - if (PartyModeID != -1) - { - index = _GetFontIndexParty(PartyModeID, fontName); - - if (index >= 0 && index < _Fonts.Count) - { - _CurrentFont = index; - return; - } - } - - index = _GetFontIndex(CConfig.Theme, fontName); - - if (index >= 0 && index < _Fonts.Count) - { + int index = _GetPartyFontIndex(PartyModeID, fontName); + if (index < 0) + index = _GetThemeFontIndex(CConfig.Theme, fontName); + if (index < 0) + index = _GetFontIndex(fontName); + if (index >= 0) _CurrentFont = index; - return; - } - - for (int i = 0; i < _Fonts.Count; i++) - { - if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName) - { - _CurrentFont = i; - return; - } - } } public static RectangleF GetTextBounds(CText text) @@ -420,7 +389,18 @@ namespace Vocaluxe.Base.Font } } - private static int _GetFontIndex(string themeName, string fontName) + private static int _GetFontIndex(string fontName) + { + for (int i = 0; i < _Fonts.Count; i++) + { + if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName) + return i; + } + + return -1; + } + + private static int _GetThemeFontIndex(string themeName, string fontName) { if (themeName == "" || fontName == "") return -1; @@ -434,14 +414,14 @@ namespace Vocaluxe.Base.Font return -1; } - private static int _GetFontIndexParty(int partyModeID, string fontName) + private static int _GetPartyFontIndex(int partyModeID, string fontName) { if (partyModeID == -1 || fontName == "") return -1; for (int i = 0; i < _Fonts.Count; i++) { - if (!_Fonts[i].IsThemeFont && _Fonts[i].Name == fontName && _Fonts[i].PartyModeID == partyModeID) + if (!_Fonts[i].IsThemeFont && _Fonts[i].PartyModeID == partyModeID && _Fonts[i].Name == fontName) return i; } @@ -454,7 +434,7 @@ namespace Vocaluxe.Base.Font for (int i = 0; i < _Fonts.Count; i++) { - CurrentFont = i; + _CurrentFont = i; foreach (char chr in text) { diff --git a/Vocaluxe/Base/Font/CGlyph.cs b/Vocaluxe/Base/Font/CGlyph.cs index 0eb61054..56ac78cd 100644 --- a/Vocaluxe/Base/Font/CGlyph.cs +++ b/Vocaluxe/Base/Font/CGlyph.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Drawing.Text; using System.Windows.Forms; using VocaluxeLib.Menu; @@ -9,18 +10,14 @@ namespace Vocaluxe.Base.Font { class CGlyph { - private readonly float _Sizeh = 50f; - public float Sizeh - { - get { return _Sizeh; } - } + public float Sizeh { get; private set; } public STexture Texture; public readonly int Width; public CGlyph(char chr, float maxHigh) { - _Sizeh = maxHigh; + Sizeh = maxHigh; float outline = CFonts.Outline; const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; @@ -85,7 +82,7 @@ namespace Vocaluxe.Base.Font point); * */ Texture = CDraw.AddTexture(bmp); - //bmp.Save("test.png", ImageFormat.Png); + bmp.Save("font/" + chr + CFonts.Style + ".png", ImageFormat.Png); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width); g.Dispose(); }