Class: Pdfrb::Font::TrueType::Head
- Inherits:
-
Object
- Object
- Pdfrb::Font::TrueType::Head
- Defined in:
- lib/pdfrb/font/true_type/head.rb
Overview
head table parser. Exposes units_per_em, bbox, index_format
(loca long vs short), mac_style flags.
Spec: OpenType "head" v1.0 — 54 bytes.
Instance Attribute Summary collapse
-
#bbox ⇒ Object
readonly
Returns the value of attribute bbox.
-
#font_direction_hint ⇒ Object
readonly
Returns the value of attribute font_direction_hint.
-
#index_to_loc_format ⇒ Object
readonly
Returns the value of attribute index_to_loc_format.
-
#lowest_rec_ppem ⇒ Object
readonly
Returns the value of attribute lowest_rec_ppem.
-
#mac_style ⇒ Object
readonly
Returns the value of attribute mac_style.
-
#units_per_em ⇒ Object
readonly
Returns the value of attribute units_per_em.
Instance Method Summary collapse
- #bold? ⇒ Boolean
-
#initialize(data) ⇒ Head
constructor
A new instance of Head.
- #italic? ⇒ Boolean
- #long_loca? ⇒ Boolean
- #short_loca? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Head
Returns a new instance of Head.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pdfrb/font/true_type/head.rb', line 14 def initialize(data) @data = data return unless data && data.bytesize >= 54 @units_per_em = u16(18) @bbox = [s16(36), s16(38), s16(40), s16(42)] @index_to_loc_format = s16(50) @mac_style = u16(44) @lowest_rec_ppem = u16(48) @font_direction_hint = s16(52) end |
Instance Attribute Details
#bbox ⇒ Object (readonly)
Returns the value of attribute bbox.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def bbox @bbox end |
#font_direction_hint ⇒ Object (readonly)
Returns the value of attribute font_direction_hint.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def font_direction_hint @font_direction_hint end |
#index_to_loc_format ⇒ Object (readonly)
Returns the value of attribute index_to_loc_format.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def index_to_loc_format @index_to_loc_format end |
#lowest_rec_ppem ⇒ Object (readonly)
Returns the value of attribute lowest_rec_ppem.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def lowest_rec_ppem @lowest_rec_ppem end |
#mac_style ⇒ Object (readonly)
Returns the value of attribute mac_style.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def mac_style @mac_style end |
#units_per_em ⇒ Object (readonly)
Returns the value of attribute units_per_em.
11 12 13 |
# File 'lib/pdfrb/font/true_type/head.rb', line 11 def units_per_em @units_per_em end |
Instance Method Details
#bold? ⇒ Boolean
29 |
# File 'lib/pdfrb/font/true_type/head.rb', line 29 def bold?; (@mac_style || 0) & 0x01 != 0; end |
#italic? ⇒ Boolean
30 |
# File 'lib/pdfrb/font/true_type/head.rb', line 30 def italic?; (@mac_style || 0) & 0x02 != 0; end |
#long_loca? ⇒ Boolean
26 |
# File 'lib/pdfrb/font/true_type/head.rb', line 26 def long_loca?; @index_to_loc_format == 1; end |
#short_loca? ⇒ Boolean
27 |
# File 'lib/pdfrb/font/true_type/head.rb', line 27 def short_loca?; @index_to_loc_format.zero?; end |