Class: RGhost::FontMap

Inherits:
PsObject show all
Includes:
RubyToPs
Defined in:
lib/rghost/font_map.rb

Overview

:nodoc:

Constant Summary

Constants included from RubyToPs

RubyToPs::UTF8_ENCODINGS

Instance Method Summary collapse

Methods included from RubyToPs

#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(options = {:font => "Helvetica", :size => 8}, &block) ⇒ FontMap

Returns a new instance of FontMap.



10
11
12
13
14
15
16
# File 'lib/rghost/font_map.rb', line 10

def initialize(options={:font => "Helvetica", :size => 8},&block)
    
  #options[:name]=options[:font]
  @options=options
  @fonts={}
  instance_eval(&block) if block
end

Instance Method Details

#new(name, options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/rghost/font_map.rb', line 18

def new(name,options={})
  #options[:name]=options[:font]
  @fonts[name]=options
  
end

#psObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rghost/font_map.rb', line 28

def ps
  functions=[]
  fonts=""
  @fonts.each do |name,params|
    options=@options
    if params[:from]
      [params[:from]].flatten.each do |font|
        functions << format_custom_font(font)
      end
    
    end
    functions << RGhost::Function.new("_#{name}") do
      raw RGhost::Font.new(options.dup.merge(params)).ps
      raw( RGhost::Color.create(params[:color] || 0) ) 
    end
  end
  functions.join
end

#tag(name, options = {}) ⇒ Object



23
24
25
# File 'lib/rghost/font_map.rb', line 23

def tag(name,options={})
  new(name,options)
end