Class: Acrofill::Metrics::Font
- Inherits:
-
Struct
- Object
- Struct
- Acrofill::Metrics::Font
- Defined in:
- lib/acrofill/metrics.rb
Overview
Everything the appearance code needs about one resolved face. remap
is a 256-entry code translation table, or nil when the font draws
WinAnsi codes as they are.
Instance Attribute Summary collapse
-
#ascender ⇒ Object
Returns the value of attribute ascender.
-
#bbox_bottom ⇒ Object
Returns the value of attribute bbox_bottom.
-
#bbox_top ⇒ Object
Returns the value of attribute bbox_top.
-
#descender ⇒ Object
Returns the value of attribute descender.
-
#remap ⇒ Object
Returns the value of attribute remap.
-
#widths ⇒ Object
Returns the value of attribute widths.
Instance Method Summary collapse
- #ascent(size) ⇒ Object
- #descent(size) ⇒ Object
-
#encode(text) ⇒ Object
Windows-1252 text as the byte codes this font draws it with.
- #line_height(size) ⇒ Object
-
#top(size) ⇒ Object
Distance from the box top to the first baseline, and between rows.
Instance Attribute Details
#ascender ⇒ Object
Returns the value of attribute ascender
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def ascender @ascender end |
#bbox_bottom ⇒ Object
Returns the value of attribute bbox_bottom
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def bbox_bottom @bbox_bottom end |
#bbox_top ⇒ Object
Returns the value of attribute bbox_top
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def bbox_top @bbox_top end |
#descender ⇒ Object
Returns the value of attribute descender
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def descender @descender end |
#remap ⇒ Object
Returns the value of attribute remap
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def remap @remap end |
#widths ⇒ Object
Returns the value of attribute widths
197 198 199 |
# File 'lib/acrofill/metrics.rb', line 197 def widths @widths end |
Instance Method Details
#ascent(size) ⇒ Object
205 |
# File 'lib/acrofill/metrics.rb', line 205 def ascent(size) = ascender * size / 1000.0 |
#descent(size) ⇒ Object
207 |
# File 'lib/acrofill/metrics.rb', line 207 def descent(size) = -descender * size / 1000.0 |
#encode(text) ⇒ Object
Windows-1252 text as the byte codes this font draws it with.
199 200 201 202 203 |
# File 'lib/acrofill/metrics.rb', line 199 def encode(text) return text unless remap text.b.each_byte.map { |code| remap[code] }.pack('C*') end |
#line_height(size) ⇒ Object
212 |
# File 'lib/acrofill/metrics.rb', line 212 def line_height(size) = (bbox_top - bbox_bottom) * size / 1000.0 |
#top(size) ⇒ Object
Distance from the box top to the first baseline, and between rows.
210 |
# File 'lib/acrofill/metrics.rb', line 210 def top(size) = bbox_top * size / 1000.0 |