Adapt to changed usage of CFonts
This commit is contained in:
1 parent
eaa709813d
commit
6c7b59ed44
2 files changed
+40
-24
No files matched your search
@@ -138,7 +138,7 @@ namespace Vocaluxe.Base
|
||||
Text = text;
|
||||
SizeF dimensions = g.MeasureString(text, font, -1, StringFormat.GenericTypographic);
|
||||
Width = dimensions.Width;
|
||||
Height = (dimensions.Height + CFonts.Height) / 2;
|
||||
Height = (dimensions.Height + font.Height) / 2;
|
||||
_Graphics = g;
|
||||
_Font = font;
|
||||
}
|
||||
@@ -180,24 +180,22 @@ namespace Vocaluxe.Base
|
||||
if (text != "")
|
||||
{
|
||||
IEnumerable<string> textParts = _SplitText(text);
|
||||
CFonts.SetFont(_Font);
|
||||
CFonts.Style = _Style;
|
||||
CFonts.Height = bmp.Height - _TextMarginTop - _TextMarginBottom;
|
||||
Font fo = CFonts.GetFont();
|
||||
CFont font = new CFont(_Font, _Style, bmp.Height - _TextMarginTop - _TextMarginBottom);
|
||||
Font fo = CFonts.GetSystemFont(font);
|
||||
List<CTextElement> elements = textParts.Select(line => new CTextElement(line, g, fo)).ToList();
|
||||
float factor = _DistributeText(elements, bmp.Width, bmp.Height);
|
||||
foreach (CTextElement element in elements)
|
||||
element.AdjustSize(factor);
|
||||
CFonts.Height *= factor / (1f + CFonts.Outline); //Adjust for outline size
|
||||
fo = CFonts.GetFont();
|
||||
font.Height *= factor / (1f + CFonts.GetOutlineSize(font)); //Adjust for outline size
|
||||
fo = CFonts.GetSystemFont(font);
|
||||
|
||||
float maxHeight = elements.Select(el => el.Height).Max();
|
||||
int lineCount = elements.Last().Line + 1;
|
||||
|
||||
//Have to use size in em not pixels!
|
||||
float emSize = fo.Size * fo.FontFamily.GetCellAscent(fo.Style) / fo.FontFamily.GetEmHeight(fo.Style);
|
||||
float outlineSize = CFonts.Outline * CFonts.Height;
|
||||
SColorF outlineColorF = CFonts.OutlineColor;
|
||||
float outlineSize = CFonts.GetOutlineSize(font) * font.Height;
|
||||
SColorF outlineColorF = CFonts.GetOutlineColor(font);
|
||||
outlineColorF.A = outlineColorF.A * _TextColor.A;
|
||||
|
||||
using (var path = new GraphicsPath())
|
||||
|
||||
@@ -180,22 +180,24 @@ namespace Vocaluxe.Base.Fonts
|
||||
return new RectangleF(text.X, text.Y, GetTextWidth(text.TranslatedText, text.Font), GetTextHeight(text.TranslatedText, text.Font));
|
||||
}
|
||||
|
||||
public static Font GetSystemFont(CFont font)
|
||||
{
|
||||
return _GetFontStyle(font).GetSystemFont(font.Height);
|
||||
}
|
||||
|
||||
public static float GetOutlineSize(CFont font)
|
||||
{
|
||||
return _FontFamilies[_GetFontIndex(font.Name)].Outline;
|
||||
}
|
||||
|
||||
public static SColorF GetOutlineColor(CFont font)
|
||||
{
|
||||
return _FontFamilies[_GetFontIndex(font.Name)].OutlineColor;
|
||||
}
|
||||
|
||||
private static CFontStyle _GetFontStyle(CFont font)
|
||||
{
|
||||
int index = _GetPartyFontIndex(font.Name, PartyModeID);
|
||||
if (index < 0)
|
||||
index = _GetThemeFontIndex(font.Name, CConfig.Theme);
|
||||
if (index < 0)
|
||||
index = _GetFontIndex(font.Name);
|
||||
if (index < 0)
|
||||
{
|
||||
if (!_LoggedMissingFonts.Contains(font.Name))
|
||||
{
|
||||
_LoggedMissingFonts.Add(font.Name);
|
||||
CLog.LogError("Font \"" + font.Name + "\" not found!");
|
||||
}
|
||||
index = 0;
|
||||
}
|
||||
int index = _GetFontIndex(font.Name);
|
||||
|
||||
switch (font.Style)
|
||||
{
|
||||
@@ -225,13 +227,29 @@ namespace Vocaluxe.Base.Fonts
|
||||
|
||||
private static int _GetFontIndex(string fontName)
|
||||
{
|
||||
int index = _GetPartyFontIndex(fontName, PartyModeID);
|
||||
if (index < 0)
|
||||
index = _GetThemeFontIndex(fontName, CConfig.Theme);
|
||||
if (index >= 0)
|
||||
return index;
|
||||
for (int i = 0; i < _FontFamilies.Count; i++)
|
||||
{
|
||||
if (_FontFamilies[i].Name == fontName)
|
||||
return i;
|
||||
}
|
||||
if (index < 0)
|
||||
{
|
||||
if (!_LoggedMissingFonts.Contains(fontName))
|
||||
{
|
||||
_LoggedMissingFonts.Add(fontName);
|
||||
CLog.LogError("Font \"" + fontName + "\" not found!");
|
||||
}
|
||||
if (_FontFamilies.Count == 0)
|
||||
CLog.LogError("No fonts found!", true, true);
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return index;
|
||||
}
|
||||
|
||||
private static int _GetThemeFontIndex(string fontName, string themeName)
|
||||
|
||||
Reference in new issue
Block a user