Class: Pdfrb::Font::TrueType::Head

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#bboxObject (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_hintObject (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_formatObject (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_ppemObject (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_styleObject (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_emObject (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

Returns:

  • (Boolean)


29
# File 'lib/pdfrb/font/true_type/head.rb', line 29

def bold?; (@mac_style || 0) & 0x01 != 0; end

#italic?Boolean

Returns:

  • (Boolean)


30
# File 'lib/pdfrb/font/true_type/head.rb', line 30

def italic?; (@mac_style || 0) & 0x02 != 0; end

#long_loca?Boolean

Returns:

  • (Boolean)


26
# File 'lib/pdfrb/font/true_type/head.rb', line 26

def long_loca?; @index_to_loc_format == 1; end

#short_loca?Boolean

Returns:

  • (Boolean)


27
# File 'lib/pdfrb/font/true_type/head.rb', line 27

def short_loca?; @index_to_loc_format.zero?; end