Class: Text2Path::SvgFont

Inherits:
Object
  • Object
show all
Defined in:
lib/text2path/svg_font.rb

Overview

An SVG font is a font defined using SVG’s ‘font’ element. You may be instested in the specification of svg font: – www.w3.org/TR/SVG/fonts.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font_path) {|_self| ... } ⇒ SvgFont

Returns a new instance of SvgFont.

Yields:

  • (_self)

Yield Parameters:



24
25
26
27
28
# File 'lib/text2path/svg_font.rb', line 24

def initialize( font_path )
  @font_path = font_path
  load_font
  yield self if block_given?
end

Instance Attribute Details

#advance_xObject (readonly)

Returns the value of attribute advance_x.



21
22
23
# File 'lib/text2path/svg_font.rb', line 21

def advance_x
  @advance_x
end

#advance_yObject (readonly)

Returns the value of attribute advance_y.



21
22
23
# File 'lib/text2path/svg_font.rb', line 21

def advance_y
  @advance_y
end

#glyphsObject (readonly)

Returns the value of attribute glyphs.



22
23
24
# File 'lib/text2path/svg_font.rb', line 22

def glyphs
  @glyphs
end

#units_per_emObject (readonly)

Returns the value of attribute units_per_em.



22
23
24
# File 'lib/text2path/svg_font.rb', line 22

def units_per_em
  @units_per_em
end

Instance Method Details

#default_glyph_heightObject



30
31
32
# File 'lib/text2path/svg_font.rb', line 30

def default_glyph_height
  units_per_em
end

#glyph(letter) ⇒ Object



34
35
36
37
# File 'lib/text2path/svg_font.rb', line 34

def glyph( letter )
  key = letter.respond_to?(:ord) ? letter.ord : letter.to_i
  glyphs[key] #|| missing_glyph
end