Thread abort when loading pdfsharp font.

Hello. I ran into a problem while generating a pdf document. I am using nuget pdfsharpNetstandart2. In debug mode, everything works fine for me. But in the release version downloaded from google play, the thread creating the document is interrupted without errors. I created the FileFontResolver class to download fonts. I assume that the problem is in downloading fonts. But I don’t understand why it works in debug mode.

packageFontPath = Package.Fonts;

public byte[] GetFont(string faceName) {
using (var ms = new MemoryStream()) {
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(FileFontResolver)).Assembly;
Stream stream = assembly.GetManifestResourceStream(packageFontPath + "." + faceName);
stream.CopyTo(ms);
ms.Position = 0;
return ms.ToArray();
}
}

public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) {
if (familyName.Equals("Helvetica", StringComparison.CurrentCultureIgnoreCase)) {
if (isBold && isItalic) {
return new FontResolverInfo("Helvetica_BoldItalic.ttf");
} else if (isBold) {
return new FontResolverInfo("Helvetica_Bold.ttf");
} else if (isItalic) {
return new FontResolverInfo("Helvetica_Italic.ttf");
} else {
return new FontResolverInfo("Helvetica_Regular.ttf");
}
}
return null;
}

Tagged:
Sign In or Register to comment.