diff --git a/Vocaluxe/Base/CFont.cs b/Vocaluxe/Base/CFont.cs index 1349f672..0c3fa048 100644 --- a/Vocaluxe/Base/CFont.cs +++ b/Vocaluxe/Base/CFont.cs @@ -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) diff --git a/Vocaluxe/Screens/CScreenOptionsTheme.cs b/Vocaluxe/Screens/CScreenOptionsTheme.cs index 8f7369dc..7250b268 100644 --- a/Vocaluxe/Screens/CScreenOptionsTheme.cs +++ b/Vocaluxe/Screens/CScreenOptionsTheme.cs @@ -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;