[英]Xamarin.Forms can't convert TTF file in stream
I'm working on Xamarin.Forms app with help of Syncfusion and want to add Cyrillic support in PDF drawing.I download ArialUnicodeMS.tff
added the file in Shared Project in Resources folder and added Build Action Embedded Resource
and also added [assembly: ExportFont("ArialUnicodeMS.ttf", Alias = "ArialUni")]
在AssemblyInfo.cs
中。 但是 Syncfusion Pdf 繪圖想要通過Stream
訪問 TTF 文件。
這是我的代碼:
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(EmbeddedFont)).Assembly;
Stream stream = assembly.GetManifestResourceStream("MyAppName.ArialUnicodeMS.ttf");
PdfFont font = new PdfTrueTypeFont(stream, 14);
但我的字符串總是null
。 我哪里錯了?
資源丟失。
很可能是以下三個問題之一:
"MyAppName.ArialUnicodeMS.ttf"
有錯字。typeof(EmbeddedFont)).Assembly
程序集中。Build Action
設置為Embedded Resource
。 這是EmbeddedFont
項目的一部分,作用於ArialUnicodeMS.ttf
資源。要驗證哪些名稱可用,您可以使用:
string resourceNames = assembly.GetManifestResourceNames();
您可以使用下面的代碼從嵌入式資源中獲取 stream。
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "App28.Trashtalk.ttf";
Stream stream = assembly.GetManifestResourceStream(resourceName);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.