简体   繁体   English

Web上的ASP.NET C#GetFontFamilies

[英]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 . 我想获取一种字体的所有受支持的字符,该字体存储在localhost:53625/fonts/WINGDNG2.TTF I has try this thread in Stackoverflow 我已经在Stackoverflow中尝试了这个线程

Get supported characters of a font - in C# 获取支持的字体字符-在C#中

but have no luck. 但没有运气。 When 什么时候

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

return a list contain 1 family, 返回包含1个家庭的列表,

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

return a list contain 0 family. 返回一个包含0个家庭的列表。
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). p / s:我的项目是一个使用ASP.NET MVC5的网站,因此该功能可以在C#(服务器端)或Javascript(客户端站点)中进行。 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 glyphTypeface = new GlyphTypeface(new Uri("file:///C:\\WINDOWS\\Fonts\\Kooten.ttf"));

Then access the GlyphCharacterMap to get all the supported characters: 然后访问GlyphCharacterMap以获取所有受支持的字符:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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