[英]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")]
in AssemblyInfo.cs
. 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
中。 But Syncfusion Pdf Drawing want to access to the TTF file by Stream
.但是 Syncfusion Pdf 绘图想要通过
Stream
访问 TTF 文件。
This is my code:这是我的代码:
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(EmbeddedFont)).Assembly;
Stream stream = assembly.GetManifestResourceStream("MyAppName.ArialUnicodeMS.ttf");
PdfFont font = new PdfTrueTypeFont(stream, 14);
But my string is always null
.但我的字符串总是
null
。 Where i'm getting wrong?我哪里错了?
The resource is missing.资源丢失。
Most likely it is one of these 3 issues:很可能是以下三个问题之一:
"MyAppName.ArialUnicodeMS.ttf"
has a typo."MyAppName.ArialUnicodeMS.ttf"
有错字。typeof(EmbeddedFont)).Assembly
assembly.typeof(EmbeddedFont)).Assembly
程序集中。Build Action
to Embedded Resource
.Build Action
设置为Embedded Resource
。 This is part of the EmbeddedFont
project and acts on the ArialUnicodeMS.ttf
resource.EmbeddedFont
项目的一部分,作用于ArialUnicodeMS.ttf
资源。 To verify which names are available, you can use:要验证哪些名称可用,您可以使用:
string resourceNames = assembly.GetManifestResourceNames();
You could use the code below to get the stream from the Embeded resource.您可以使用下面的代码从嵌入式资源中获取 stream。
var assembly = Assembly.GetExecutingAssembly();
var resourceName = "App28.Trashtalk.ttf";
Stream stream = assembly.GetManifestResourceStream(resourceName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.