### Home Classes Methods

### In Files

- lib/prawn/font/afm.rb

### Parent

Prawn::Font

### Methods

- ::metrics_path
- #bbox
- #character_count
- #encode_text
- #glyph_present?
- #has_kerning_data?
- #normalize_encoding
- #unicode?

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Configurable
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::GridBox
- Prawn::Document::Internals
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::FontMetricCache
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Patterns
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::ImageHandler
- Prawn::Images
- Prawn::Images::Image
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Measurements
- Prawn::SoftMask
- Prawn::Stamp
- Prawn::SynchronizedCache
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::Image
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::SpanDummy
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Table::ColumnWidthCalculator
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Prawn::ThreadLocalCache
- PDF
- PDF::Core
- PDF::Core::Reference
- PDF::Core::Stream
- Arcfour
- Numeric

No matching classes.

# Prawn::Font::AFM

@private

### Constants

BUILT_INS

### Public Class Methods

metrics_path() click to toggle source

    # File lib/prawn/font/afm.rb, line 25
    def self.metrics_path
      if m = ENV['METRICS']
        @metrics_path ||= m.split(':')
      else
        @metrics_path ||= [
          ".", "/usr/lib/afm",
          "/usr/local/lib/afm",
          "/usr/openwin/lib/fonts/afm",
           Prawn::DATADIR+'/fonts']
      end
    end

### Public Instance Methods

bbox() click to toggle source

The font bbox, as an array of integers

    # File lib/prawn/font/afm.rb, line 68
    def bbox
      @bbox ||= @attributes['fontbbox'].split(/\s+/).map { |e| Integer(e) }
    end

character_count(str) click to toggle source

Returns the number of characters in `str` (a WinAnsi-encoded string).

    # File lib/prawn/font/afm.rb, line 105
    def character_count(str)
      str.length
    end

encode_text(text, options={}) click to toggle source

Perform any changes to the string that need to happen before it is rendered to the canvas. Returns an array of subset "chunks", where each chunk is an array of two elements. The first element is the font subset number, and the second is either a string or an array (for kerned text).

For Adobe fonts, there is only ever a single subset, so the first element of the array is "0", and the second is the string itself (or an array, if kerning is performed).

The `text` parameter must be in WinAnsi encoding (cp1252).

    # File lib/prawn/font/afm.rb, line 121
    def encode_text(text, options={})
      [[0, options[:kerning] ? kern(text) : text]]
    end

glyph_present?(char) click to toggle source

    # File lib/prawn/font/afm.rb, line 125
    def glyph_present?(char)
      if char == "_"
        true
      else
        normalize_encoding(char) != "_"
      end
    end

has_kerning_data?() click to toggle source

Returns true if the font has kerning data, false otherwise

    # File lib/prawn/font/afm.rb, line 87
    def has_kerning_data?
      @kern_pairs.any?
    end

normalize_encoding(text) click to toggle source

built-in fonts only work with winansi encoding, so translate the string. Changes the encoding in-place, so the argument itself is replaced with a string in WinAnsi encoding.

    # File lib/prawn/font/afm.rb, line 95
    def normalize_encoding(text)
      enc = @@winansi
      text.unpack("U*").collect { |i| enc[i] }.pack("C*")
    rescue ArgumentError
      raise Prawn::Errors::IncompatibleStringEncoding,
        "Arguments to text methods must be UTF-8 encoded"
    end

unicode?() click to toggle source

    # File lib/prawn/font/afm.rb, line 21
    def unicode?
      false
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.