简体   繁体   中英

ASP.NET C# GetFontFamilies on web

I want to get all supported characters of a font, that font is stored in localhost:53625/fonts/WINGDNG2.TTF . I has try this thread in Stackoverflow

Get supported characters of a font - in C#

but have no luck. When

Fonts.GetFontFamilies(@"C:\\WINDOWS\\Fonts\\Arial.TTF");

return a list contain 1 family,

Fonts.GetFontFamilies(new Uri( http://localhost:53625/fonts/WINGDNG2.TTF ));

return a list contain 0 family.
Thank you for reading my question.

p/s: My project is a website using ASP.NET MVC5, so the function can be in C# (server side) or in Javascript (client site). If there are any codes can give me a list of supported characters of a font (with specific path like above), which side is no problem.

Instead of enumerating the Font Families, you can instantiate GlyphTypeface directly, if you know the font file location:

GlyphTypeface glyphTypeface = new GlyphTypeface(new Uri("file:///C:\\WINDOWS\\Fonts\\Kooten.ttf"));

Then access the GlyphCharacterMap to get all the supported characters:

IDictionary<int, ushort> characterMap = glyph.CharacterToGlyphMap;

https://msdn.microsoft.com/en-us/library/system.windows.media.glyphtypeface(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM