Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jonashertzman opened this issue Jan 19, 2018 · 0 comments

Comments

@jonashertzman
Copy link
Owner

jonashertzman commented Jan 19, 2018

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 "";
	}
@jonashertzman jonashertzman added this to the 1.0 Release milestone Feb 1, 2018
@jonashertzman jonashertzman removed this from the 1.0 Release milestone Apr 15, 2018
@jonashertzman jonashertzman changed the title Use a fall back font when files contain characters that does not exist in the chosen font. Use a fall back font when files contain characters that do not exist in the chosen font. Aug 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant