I'm using PDFSharpCore to create a pdf, when I came across the problem that there are no fonts on my android device (I'm using a physical android device since emulators are not working on my computer), I googled and found this IFontResolver:
public class GenericFontResolver : IFontResolver
{
public string DefaultFontName => throw new NotImplementedException();
public byte[] GetFont(string faceName)
{
var assembly = this.GetType().GetTypeInfo().Assembly;
var directory = $"CartaoVisitaNFC.Fonts.{faceName}.ttf";
var stream = assembly.GetManifestResourceStream(directory);
using (var reader = new StreamReader(stream))
{
var bytes = default(byte[]);
using (var ms = new MemoryStream())
{
reader.BaseStream.CopyTo(ms);
bytes = ms.ToArray();
}
return bytes;
}
}
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic)
{
return new FontResolverInfo(familyName);
}
}
I already checked the "stream" and it is not getting null and using the breakpoints I identified that the error is in this line of code
using (var ms = new MemoryStream())
{
reader.BaseStream.CopyTo(ms);
bytes = ms.ToArray();
}
and it is returning this error System.ArgumentNullException Message=Buffer cannot be null. Parameter name: buffer
how can i solve this problem? obs: The font I'm trying to use is verdana. .net version is .netstandard2.0