Class: PDF::Writer::Object::Font

### Home Classes Methods

### In Files

- lib/pdf/writer/object/font.rb

### Parent

PDF::Writer::Object

### Methods

- ::new
- #to_s

### Files

- ChangeLog

### Class/Module Index

Quicksearch

- PDF
- PDF::Charts
- PDF::Charts::StdDev
- PDF::Charts::StdDev::Label
- PDF::Charts::StdDev::Marker
- PDF::Charts::StdDev::Scale
- PDF::Math
- PDF::QuickRef
- PDF::SimpleTable
- PDF::SimpleTable::Column
- PDF::SimpleTable::Column::Heading
- PDF::TechBook
- PDF::TechBook::TagTocDots
- PDF::TechBook::TagXref
- PDF::Writer
- PDF::Writer::ARC4
- PDF::Writer::Complex
- PDF::Writer::External
- PDF::Writer::FontMetrics
- PDF::Writer::Graphics
- PDF::Writer::Graphics::ImageInfo
- PDF::Writer::Graphics::ImageInfo::Formats
- PDF::Writer::Graphics::ImageInfo::Type
- PDF::Writer::Lang
- PDF::Writer::Lang::EN
- PDF::Writer::OHash
- PDF::Writer::Object
- PDF::Writer::Object::Action
- PDF::Writer::Object::Annotation
- PDF::Writer::Object::Catalog
- PDF::Writer::Object::Contents
- PDF::Writer::Object::Destination
- PDF::Writer::Object::Encryption
- PDF::Writer::Object::Font
- PDF::Writer::Object::FontDescriptor
- PDF::Writer::Object::FontEncoding
- PDF::Writer::Object::Info
- PDF::Writer::Object::Outline
- PDF::Writer::Object::Outlines
- PDF::Writer::Object::Pages
- PDF::Writer::Object::Procset
- PDF::Writer::Object::ViewerPreferences
- PDF::Writer::OffsetReader
- PDF::Writer::PolygonPoint
- PDF::Writer::State
- PDF::Writer::StateStack
- PDF::Writer::StrokeStyle

No matching classes.

# PDF::Writer::Object::Font

An object to hold the font description

### Constants

Details

### Attributes

encoding[R]

Valid values: WinAnsiEncoding, MacRomanEncoding, MacExpertEncoding, none, `nil`, or an instance of PDF::Writer::Object::FontEncoding.

font_id[R]
subtype[R]

The type of the font: Type1 and TrueType are the only values supported by

### Public Class Methods

new(parent, name, encoding = 'WinAnsiEncoding', subtype = 'Type1') click to toggle source

    # File lib/pdf/writer/object/font.rb, line 15
    def initialize(parent, name, encoding = 'WinAnsiEncoding', subtype = 'Type1')
      super(parent)

      @name     = name
      @subtype  = subtype
      @font_id  = @parent.__send__(:generate_font_id)

      if encoding.kind_of?(PDF::Writer::Object::FontEncoding)
        @encoding           = encoding
      elsif encoding == 'none' or encoding.nil?
        @encoding           = nil
      else
        @encoding           = encoding
      end

      @parent.pages << self

      @firstchar      = nil
      @lastchar       = nil
      @widths         = nil
      @fontdescriptor = nil
    end

### Public Instance Methods

to_s() click to toggle source

    # File lib/pdf/writer/object/font.rb, line 58
    def to_s
      res = "\n#{@oid} 0 obj\n<< /Type /Font\n/Subtype /#{@subtype}\n"
      res << "/Name /F#{@font_id}\n/BaseFont /#{@name}\n"
      if @encoding.kind_of?(PDF::Writer::Object::FontEncoding)
        res << "/Encoding #{@encoding.oid} 0 R\n"
      elsif @encoding
        res << "/Encoding /#{@encoding}\n" if @encoding
      end
      res << "/FirstChar #{@firstchar}\n" unless @firstchar.nil?
      res << "/LastChar #{@lastchar}\n" unless @lastchar.nil?
      res << "/Widths #{@widths} 0 R\n" unless @widths.nil?
      res << "/FontDescriptor #{@fontdescriptor} 0 R\n" unless @fontdescriptor.nil?
      res << ">>\nendobj"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.