X Tutup
Skip to content
Prev Previous commit
Use default font as fallback in CanvasRenderContext when determining …
…font metrics
  • Loading branch information
VisualMelon committed Feb 13, 2024
commit 5aea6f4339a8ab4ee4d8b1b51755a9290d32a5e5
8 changes: 7 additions & 1 deletion Source/OxyPlot.Wpf/CanvasRenderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,13 @@ public FontMetrics GetFontMetrics(string fontFamily, double fontSize, double fon

if (!typeface.TryGetGlyphTypeface(out var glyphTypeface))
{
throw new InvalidOperationException("No glyph typeface found");
var defaultTypeface = new Typeface(
new FontFamily(this.DefaultFontFamily), FontStyles.Normal, GetFontWeight(fontWeight), FontStretches.Normal);

if (!defaultTypeface.TryGetGlyphTypeface(out glyphTypeface))
{
throw new InvalidOperationException("No glyph typeface found");
}
}

var lineHeight = Math.Abs(glyphTypeface.Height) * fontSize;
Expand Down
X Tutup