Small Font fixes

This commit is contained in:
Flamefire committed 2013-04-28 14:25:49 +02:00
1 parent 2f3f121f88
commit 3956fa17d1
2 files changed
+25 -48

No files matched your search

+21 -41
View File
@@ -20,15 +20,6 @@ namespace Vocaluxe.Base.Font
public static EStyle Style = EStyle.Normal; 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 public static float Height
{ {
get { return _Height; } get { return _Height; }
@@ -196,35 +187,13 @@ namespace Vocaluxe.Base.Font
public static void SetFont(string fontName) public static void SetFont(string fontName)
{ {
int index; int index = _GetPartyFontIndex(PartyModeID, fontName);
if (index < 0)
if (PartyModeID != -1) index = _GetThemeFontIndex(CConfig.Theme, fontName);
{ if (index < 0)
index = _GetFontIndexParty(PartyModeID, fontName); index = _GetFontIndex(fontName);
if (index >= 0)
if (index >= 0 && index < _Fonts.Count)
{
_CurrentFont = index;
return;
}
}
index = _GetFontIndex(CConfig.Theme, fontName);
if (index >= 0 && index < _Fonts.Count)
{
_CurrentFont = index; _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) 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 == "") if (themeName == "" || fontName == "")
return -1; return -1;
@@ -434,14 +414,14 @@ namespace Vocaluxe.Base.Font
return -1; return -1;
} }
private static int _GetFontIndexParty(int partyModeID, string fontName) private static int _GetPartyFontIndex(int partyModeID, string fontName)
{ {
if (partyModeID == -1 || fontName == "") if (partyModeID == -1 || fontName == "")
return -1; return -1;
for (int i = 0; i < _Fonts.Count; i++) 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; return i;
} }
@@ -454,7 +434,7 @@ namespace Vocaluxe.Base.Font
for (int i = 0; i < _Fonts.Count; i++) for (int i = 0; i < _Fonts.Count; i++)
{ {
CurrentFont = i; _CurrentFont = i;
foreach (char chr in text) foreach (char chr in text)
{ {
+4 -7
View File
@@ -1,6 +1,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text; using System.Drawing.Text;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -9,18 +10,14 @@ namespace Vocaluxe.Base.Font
{ {
class CGlyph class CGlyph
{ {
private readonly float _Sizeh = 50f; public float Sizeh { get; private set; }
public float Sizeh
{
get { return _Sizeh; }
}
public STexture Texture; public STexture Texture;
public readonly int Width; public readonly int Width;
public CGlyph(char chr, float maxHigh) public CGlyph(char chr, float maxHigh)
{ {
_Sizeh = maxHigh; Sizeh = maxHigh;
float outline = CFonts.Outline; float outline = CFonts.Outline;
const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix; const TextFormatFlags flags = TextFormatFlags.NoPadding | TextFormatFlags.NoPrefix;
@@ -85,7 +82,7 @@ namespace Vocaluxe.Base.Font
point); point);
* */ * */
Texture = CDraw.AddTexture(bmp); 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); Width = (int)((1f + outline / 2f) * sizeB.Width * Texture.Width / factor / bmp.Width);
g.Dispose(); g.Dispose();
} }