Stores all the specifications for a font style in a font object. Parameters are used with the [PDF_Font] type that define the font face, file, size, color, encoding, and whether to embed it in the PDF. A [PDF_Font] instance stored in a variable is called using the -Font parameter of another [PDF_...] type. The [PDF_Font] must be instantiated before it can be used in another [PDF_...] type.
Parameter | Description |
---|---|
-Face | Specifies the font by its family name (e.g. "Helvetica"). Required if the -File parameter is not used. Allowed font names are Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique, Symbol, Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, and ZapfDingbats. |
-File | Creates a font from a local font file. The file name and path to the font must be specified (e.g., '/Fonts/Courier'). Supported font file types are TrueType Font (.ttf) or OpenType Font (.otf). |
-Size | Sets the font size in points (e.g 14). Required if the -File parameter is not used. |
-Color | Sets the font color to a [PDF_Color] object or a hex color string (e.g., '#EEEE00'). Defaults to '#000000' if not specified. |
-Encoding | Sets the desired font encoding for the font (e.g., 'cp1252'). |
-Embed | Embeds the fonts used within the PDF document as opposed to relying on the client PDF reader for font information. |
local(myfont) = pdf_font(
-file = 'Filepath to TrueType Font or OpenType Font File',
-size = Integer Value,
-color = '#Hexadecimal Value',
-encoding = 'Encoding Value',
-embed)
local(myfont) = pdf_font(
-face = 'Allowed Font Face',
-size = Integer Value,
-color = '#Hexadecimal Value',
-encoding = 'Encoding Value',
-embed)
The example belows shows how to use the [PDF_Font] method to define a 14-point red Helvetica font for use in a PDF document. The local #myfont can be used as the value for the -Font parameter of any [PDF_...] method.
Code
local(myfont) = pdf_font(
-face = 'Helvetica',
-size = 14,
-color = '#990000')
local(mypdf) = pdf_doc(
-file='mypdf.pdf',
-size='Letter')
local(text) = pdf_text(
'My first PDF.',
-paragraph,
-font=#myfont)
#mypdf->add(#text)
#mypdf = bytes(#mypdf)
file_serve(#mypdf, -file='mypdf.pdf', -type='Content-Type: application/pdf')
Result
A PDF file containing 14-point red Helvetica text "My first PDF." is served to the web browser.
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments