Class: RGhost::Font

Inherits:
PsObject show all
Includes:
Constants::Fonts
Defined in:
lib/rghost/font.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_OPTONS =
{ :size=> 8, :name => "Helvetica", :encoding => true }

Constants included from Constants::Fonts

Constants::Fonts::ENCODINGS, Constants::Fonts::STANDARD, Constants::Fonts::SUNS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from PsObject

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

Constructor Details

#initialize(options) ⇒ Font

Returns a new instance of Font.



12
13
14
15
16
17
18
19
# File 'lib/rghost/font.rb', line 12

def initialize(options)

  @options=DEFAULT_OPTONS.dup.merge(options)
  @options.default ""
  @options[:name]=@options[:font] if @options[:font]
  @name=@options[:name].to_s
  @name+="-encoding" if @options[:encoding]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/rghost/font.rb', line 10

def name
  @name
end

Instance Method Details

#psObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rghost/font.rb', line 21

def ps
  o=@options
  str_ret=""
#    if o[:barcode]
#      bc=RGhost::Barcode.new(o[:barcode])
#      @name=bc.font_name  
#      o[:encoding]=false   
#    end
  if o[:encoding] #define enconding 
    str_ret="/#{o[:name]} encoding_font\n"+
      "/#{o[:name]}-encoding exch definefont pop\n"
  end 
   
     
  size= o[:size]
  str_ret+=case size
  when Hash then   "/#{@name} findfont [ #{size[:width]} 0 0 #{size[:height]} 0 0] makefont setfont "
  when Array then  "/#{@name} findfont [ #{size[0]} 0 0 #{size[1]} 0 0] makefont setfont "
  when Numeric then "/#{@name} findfont #{size} scalefont setfont "
  end
  str_ret
end