unload theme fonts on theme change

This commit is contained in:
Alexander Eckart committed 2012-12-09 12:56:40 +01:00
1 parent 1d5201f1ab
commit 06c3ed6cc7
2 files changed
+37

No files matched your search

+35
View File
@@ -123,6 +123,11 @@ namespace Vocaluxe.Base
fo.Dispose();
}
public void UnloadTexture()
{
CDraw.RemoveTexture(ref Texture);
}
private float GetFactor(char chr, TextFormatFlags flags)
{
if (CFonts.Style == EStyle.Normal)
@@ -277,6 +282,15 @@ namespace Vocaluxe.Base
_htGlyphs.Add(chr, _Glyphs.Count - 1);
CFonts.Height = h;
}
public void UnloadAllGlyphs()
{
foreach (CGlyph glyph in _Glyphs)
{
glyph.UnloadTexture();
}
_Glyphs.Clear();
}
}
struct SFont
@@ -854,6 +868,27 @@ namespace Vocaluxe.Base
writer.WriteEndElement();
}
public static void UnloadThemeFonts(string ThemeName)
{
if (_Fonts.Count == 0)
return;
int Index = 0;
while (Index < _Fonts.Count)
{
if (_Fonts[Index].IsThemeFont && _Fonts[Index].ThemeName == ThemeName)
{
_Fonts[Index].Normal.UnloadAllGlyphs();
_Fonts[Index].Italic.UnloadAllGlyphs();
_Fonts[Index].Bold.UnloadAllGlyphs();
_Fonts[Index].BoldItalic.UnloadAllGlyphs();
_Fonts.RemoveAt(Index);
}
else
Index++;
}
}
private static int GetFontIndex(string ThemeName, string FontName)
{
if (ThemeName == String.Empty || FontName == String.Empty)
+2
View File
@@ -183,6 +183,7 @@ namespace Vocaluxe.Screens
_OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection;
CTheme.UnloadSkins();
CFonts.UnloadThemeFonts(CConfig.Theme);
CTheme.ListSkins();
CConfig.Skin = CTheme.SkinNames[0];
_OldSkin = 0;
@@ -205,6 +206,7 @@ namespace Vocaluxe.Screens
_OldTheme = SelectSlides[htSelectSlides(SelectSlideTheme)].Selection;
CTheme.UnloadSkins();
CFonts.UnloadThemeFonts(CConfig.Theme);
CTheme.ListSkins();
CConfig.Skin = CTheme.SkinNames[0];
_OldSkin = 0;