Class Prawn::Font
In: lib/prawn/font/afm.rb
lib/prawn/font/dfont.rb
lib/prawn/font/ttf.rb
lib/prawn/font.rb
Parent: Object

Provides font information and helper functions.

Methods

Classes and Modules

Class Prawn::Font::AFM
Class Prawn::Font::DFont
Class Prawn::Font::TTF

Attributes

family  [R]  The current font family
name  [R]  The current font name
options  [R]  The options hash used to initialize the font

Public Class methods

Public Instance methods

Registers the given subset of the current font with the current PDF page. This is safe to call multiple times for a given font and subset, as it will only add the font the first time it is called.

Gets height of current font in PDF points at current font size

Normalizes the encoding of the string to an encoding supported by the font. The string is expected to be UTF-8 going in, and will be reencoded in-place (the argument will be modified directly). The return value is not defined.

Returns the width of the given string using the given font. If :size is not specified as one of the options, the string is measured using the current font size. You can also pass :kerning as an option to indicate whether kerning should be used when measuring the width (defaults to false).

Note that the string must be encoded properly for the font being used. For AFM fonts, this is WinAnsi. For TTF, make sure the font is encoded as UTF-8. You can use the normalize_encoding method to make sure strings are in an encoding appropriate for the font.

[Validate]