Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, currently I have a working, if a bit clunky feeling, solution. I have a static helper class that looks like this:</p> <pre><code>namespace FontFallbackTest { using System.Linq; using System.Windows.Markup; using System.Windows.Media; public static class FontHelper { private static readonly FontFamily testFont; public static FontFamily TestFont { get { return testFont; } } static FontHelper() { testFont = new FontFamily(); testFont.FamilyNames.Add(XmlLanguage.GetLanguage("en-US"), "TestFont"); if (Fonts.SystemFontFamilies.Any(f =&gt; f.FamilyNames.Any(kv =&gt; kv.Value == "Century Gothic"))) { testFont.FamilyMaps.Add(new FontFamilyMap() { Target = "Century Gothic" }); } testFont.FamilyMaps.Add(new FontFamilyMap() { Target = "Comic Sans MS", Scale = 0.5 }); } } } </code></pre> <p>Which I then reference in my XAML like this:</p> <pre><code>&lt;Window x:Class="FontFallbackTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:FontFallbackTest="clr-namespace:FontFallbackTest" Title="MainWindow" Height="550" Width="525"&gt; &lt;Grid&gt; &lt;Label Margin="0,100,0,0" FontSize="48" FontFamily="{x:Static FontFallbackTest:FontHelper.TestFont}"&gt;This is some text&lt;/Label&gt; &lt;Label Margin="0,150,0,0" FontSize="48" FontFamily="{x:Static FontFallbackTest:FontHelper.TestFont}"&gt;This is more text&lt;/Label&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>This seems to work - showing Century Gothic, ignoring Century, and allowing me to control font scaling on the fallbacks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload