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.
-
#code_widths ⇒ Object
Returns the value of attribute code_widths.
-
#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.
-
#width_of(text, size) ⇒ Object
Width of
textatsizepoints, in points.
Instance Attribute Details
#ascender ⇒ Object
Returns the value of attribute ascender
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def ascender @ascender end |
#bbox_bottom ⇒ Object
Returns the value of attribute bbox_bottom
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def bbox_bottom @bbox_bottom end |
#bbox_top ⇒ Object
Returns the value of attribute bbox_top
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def bbox_top @bbox_top end |
#code_widths ⇒ Object
Returns the value of attribute code_widths
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def code_widths @code_widths end |
#descender ⇒ Object
Returns the value of attribute descender
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def descender @descender end |
#remap ⇒ Object
Returns the value of attribute remap
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def remap @remap end |
#widths ⇒ Object
Returns the value of attribute widths
202 203 204 |
# File 'lib/acrofill/metrics.rb', line 202 def widths @widths end |
Instance Method Details
#ascent(size) ⇒ Object
217 |
# File 'lib/acrofill/metrics.rb', line 217 def ascent(size) = ascender * size / 1000.0 |
#descent(size) ⇒ Object
219 |
# File 'lib/acrofill/metrics.rb', line 219 def descent(size) = -descender * size / 1000.0 |
#encode(text) ⇒ Object
Windows-1252 text as the byte codes this font draws it with.
205 206 207 208 209 |
# File 'lib/acrofill/metrics.rb', line 205 def encode(text) return text unless remap text.b.each_byte.map { |code| remap[code] }.pack('C*') end |
#line_height(size) ⇒ Object
224 |
# File 'lib/acrofill/metrics.rb', line 224 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.
222 |
# File 'lib/acrofill/metrics.rb', line 222 def top(size) = bbox_top * size / 1000.0 |
#width_of(text, size) ⇒ Object
Width of text at size points, in points. text is in this font's
own codes (the output of #encode), so it is measured in that space.
213 214 215 |
# File 'lib/acrofill/metrics.rb', line 213 def width_of(text, size) Metrics.string_width(text, code_widths, size) end |