Skip to content

Use a fall back font when files contain characters that do not exist in the chosen font. #3

Description

@jonashertzman

Maybe something like this could be used to find a suitable font:

	private static string FindFont(int codePoint)
	{
		foreach (FontFamily family in Fonts.SystemFontFamilies)
		{
			var typefaces = family.GetTypefaces();
			foreach (Typeface typeface in typefaces)
			{
				typeface.TryGetGlyphTypeface(out GlyphTypeface glyph);
				if (glyph != null && glyph.CharacterToGlyphMap.TryGetValue(codePoint, out _))
				{
					if (family.FamilyNames.TryGetValue(XmlLanguage.GetLanguage("en-us"), out string familyName))
					{
						return familyName;
					}
				}
			}
		}
		return "";
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions