Class: Krill::AFM
- Inherits:
-
Struct
- Object
- Struct
- Krill::AFM
- Defined in:
- lib/krill/afm.rb
Defined Under Namespace
Classes: WinAnsi
Instance Attribute Summary collapse
-
#ascender ⇒ Object
readonly
Returns the value of attribute ascender.
-
#character_widths ⇒ Object
readonly
Returns the value of attribute character_widths.
-
#descender ⇒ Object
readonly
Returns the value of attribute descender.
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#kernings ⇒ Object
readonly
Returns the value of attribute kernings.
-
#line_gap ⇒ Object
readonly
Returns the value of attribute line_gap.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #bold? ⇒ Boolean
-
#initialize(filename) ⇒ AFM
constructor
A new instance of AFM.
- #italic? ⇒ Boolean
- #unicode? ⇒ Boolean
Constructor Details
#initialize(filename) ⇒ AFM
Returns a new instance of AFM.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/krill/afm.rb', line 9 def initialize(filename) super data = parse(filename) @character_widths = data.fetch(:character_widths) @kernings = data.fetch(:kernings) attributes = data.fetch(:attributes) bbox = attributes['fontbbox'].split(/\s+/).map { |e| Integer(e) } line_height = Float(bbox[3] - bbox[1]) / 1000.0 @name = attributes['fontname'] @family = attributes['familyname'] @ascender = attributes['ascender'].to_i / 1000.0 @descender = attributes['descender'].to_i / 1000.0 @line_gap = line_height - (ascender - descender) end |
Instance Attribute Details
#ascender ⇒ Object (readonly)
Returns the value of attribute ascender.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def ascender @ascender end |
#character_widths ⇒ Object (readonly)
Returns the value of attribute character_widths.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def character_widths @character_widths end |
#descender ⇒ Object (readonly)
Returns the value of attribute descender.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def descender @descender end |
#family ⇒ Object (readonly)
Returns the value of attribute family.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def family @family end |
#filename ⇒ Object
Returns the value of attribute filename
2 3 4 |
# File 'lib/krill/afm.rb', line 2 def filename @filename end |
#kernings ⇒ Object (readonly)
Returns the value of attribute kernings.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def kernings @kernings end |
#line_gap ⇒ Object (readonly)
Returns the value of attribute line_gap.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def line_gap @line_gap end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/krill/afm.rb', line 3 def name @name end |
Class Method Details
.open(filename) ⇒ Object
5 6 7 |
# File 'lib/krill/afm.rb', line 5 def self.open(filename) new filename end |
Instance Method Details
#bold? ⇒ Boolean
28 29 30 |
# File 'lib/krill/afm.rb', line 28 def bold? name["Bold"].present? end |
#italic? ⇒ Boolean
32 33 34 |
# File 'lib/krill/afm.rb', line 32 def italic? name["Italic"].present? end |
#unicode? ⇒ Boolean
36 37 38 |
# File 'lib/krill/afm.rb', line 36 def unicode? false end |