Object
Provides font information and helper functions.
Shortcut interface for constructing a font object. Filenames of the form *.ttf will call Font::TTF.new, *.dfont Font::DFont.new, and anything else will be passed through to Font::AFM.new()
# File lib/prawn/font.rb, line 238 238: def self.load(document,name,options={}) 239: case name 240: when /\.ttf$/ then TTF.new(document, name, options) 241: when /\.dfont$/ then DFont.new(document, name, options) 242: when /\.afm$/ then AFM.new(document, name, options) 243: else AFM.new(document, name, options) 244: end 245: end
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.
# File lib/prawn/font.rb, line 310 310: def add_to_current_page(subset) 311: @references[subset] ||= register(subset) 312: @document.page.fonts.merge!(identifier_for(subset) => @references[subset]) 313: end
The size of the font ascender in PDF points
# File lib/prawn/font.rb, line 261 261: def ascender 262: @ascender / 1000.0 * size 263: end
The size of the font descender in PDF points
# File lib/prawn/font.rb, line 267 267: def descender 268: -@descender / 1000.0 * size 269: end
Gets height of current font in PDF points at current font size
# File lib/prawn/font.rb, line 302 302: def height 303: height_at(size) 304: end
Gets height of current font in PDF points at the given font size
# File lib/prawn/font.rb, line 295 295: def height_at(size) 296: @normalized_height ||= (@ascender - @descender + @line_gap) / 1000.0 297: @normalized_height * size 298: end
The size of the recommended gap between lines of text in PDF points
# File lib/prawn/font.rb, line 273 273: def line_gap 274: @line_gap / 1000.0 * size 275: end
Normalizes the encoding of the string to an encoding supported by the font. The string is expected to be UTF-8 going in. It will be re-encoded and the new string will be returned. For an in-place (destructive) version, see normalize_encoding!.
# File lib/prawn/font.rb, line 282 282: def normalize_encoding(string) 283: raise NotImplementedError, "subclasses of Prawn::Font must implement #normalize_encoding" 284: end
Destructive version of normalize_encoding; normalizes the encoding of a string in place.
# File lib/prawn/font.rb, line 289 289: def normalize_encoding!(str) 290: str.replace(normalize_encoding(str)) 291: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.