我在根目录下的此文件夹中有OpenSans-Light.ttf:〜/ fonts / open-sans / OpenSans-Light.ttf
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
privateFontCollection.AddFontFile("~/fonts/open-sans/OpenSans-Light.ttf");
但是我收到“ System.IO.FileNotFoundException:找不到文件”
如何定位该字体文件?
答案 0 :(得分:0)
我找到了使用MapPath的解决方案:
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
privateFontCollection.AddFontFile(HttpContext.Current.Server.MapPath("~/fonts/open-sans/OpenSans-Light.ttf"));