c# - Byte Array to font from my solution resources folder -
i have specific font
in resources
folder want use.
label label; label.fontfamily=mynamespace.properties.resources.
i can see font
name return byte[]
. how can use font
?
try function
private system.drawing.font getfontfromresource() { stream fontstream = this.gettype().assembly.getmanifestresourcestream("yourfont.ttf"); byte[] fontdata = new byte[fontstream.length]; fontstream.read(fontdata,0,(int)fontstream.length); fontstream.close(); unsafe { fixed(byte * pfontdata = fontdata) { return new system.drawing.font((system.intptr)pfontdata, 16, fontstyle.regular); } } }
how load resource assembly:(yournamespace.file.ttf
):
Comments
Post a Comment