Package | org.purepdf.pdf.fonts |
Class | public class FontsResourceFactory |
Inheritance | FontsResourceFactory Object |
Method | Defined By | ||
---|---|---|---|
FontsResourceFactory(lock:Lock)
Do not use constructor to initialize this class but getInstance
should be used
| FontsResourceFactory | ||
fontIsRegistered(name:String):Boolean
Return true if a font is already registered
| FontsResourceFactory | ||
getFontFile(filename:String):ByteArray | FontsResourceFactory | ||
[static]
Return the singleton of FontsResourceFactory
| FontsResourceFactory | ||
registerFont(name:String, file:ByteArray):void
You can register a new font passing the bytearray class
of an embedded resource
Example
[Embed(source="assets/fonts/Helvetica-Bold.afm", mimeType="application/octet-stream")]
private var helveticaB: Class;
public function main()
{
// this will register a custom, user defined font
FontsResourceFactory.getInstance().registerFont( BaseFont.HELVETICA_BOLD, new helveticaB() );
// register a new font, using one of the builtin fonts
FontsResourceFactory.getInstance().registerFont( BaseFont.HELVETICA, new BuiltinFonts.HELVETICA() );
var font: Font = new Font( Font.HELVETICA, 18, Font.BOLD );
document.addElement( new Paragraph("Hello world", font) );
}
You can use the built-in fonts embedded into the separate BuiltinFonts class
| FontsResourceFactory |
FontsResourceFactory | () | Constructor |
public function FontsResourceFactory(lock:Lock)
Do not use constructor to initialize this class but getInstance
should be used
lock:Lock |
See also
fontIsRegistered | () | method |
public function fontIsRegistered(name:String):Boolean
Return true if a font is already registered
Parameters
name:String — the font name. eg. "Helvetica"
|
Boolean |
See also
getFontFile | () | method |
public function getFontFile(filename:String):ByteArray
Parameters
filename:String |
ByteArray |
getInstance | () | method |
public static function getInstance():FontsResourceFactory
Return the singleton of FontsResourceFactory
ReturnsFontsResourceFactory |
See also
registerFont | () | method |
public function registerFont(name:String, file:ByteArray):void
You can register a new font passing the bytearray class of an embedded resource
Example
[Embed(source="assets/fonts/Helvetica-Bold.afm", mimeType="application/octet-stream")] private var helveticaB: Class; public function main() { // this will register a custom, user defined font FontsResourceFactory.getInstance().registerFont( BaseFont.HELVETICA_BOLD, new helveticaB() ); // register a new font, using one of the builtin fonts FontsResourceFactory.getInstance().registerFont( BaseFont.HELVETICA, new BuiltinFonts.HELVETICA() ); var font: Font = new Font( Font.HELVETICA, 18, Font.BOLD ); document.addElement( new Paragraph("Hello world", font) ); }
You can use the built-in fonts embedded into the separate BuiltinFonts class
Parameters
name:String — The font name (eg. "Helvetica")
| |
file:ByteArray |
See also