Class: Fontisan::Tables::Cblc::BitmapSize

Inherits:
Binary::BaseRecord show all
Defined in:
lib/fontisan/tables/cblc.rb

Overview

BitmapSize record structure (48 bytes)

Describes a bitmap strike at a specific ppem size

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Binary::BaseRecord

#raw_data, #valid?

Instance Attribute Details

#bit_depthObject (readonly)

Returns the value of attribute bit_depth.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def bit_depth
  @bit_depth
end

#color_refObject (readonly)

Returns the value of attribute color_ref.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def color_ref
  @color_ref
end

#end_glyph_indexObject (readonly)

Returns the value of attribute end_glyph_index.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def end_glyph_index
  @end_glyph_index
end

#flagsObject (readonly)

Returns the value of attribute flags.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def flags
  @flags
end

#horiObject (readonly)

Returns the value of attribute hori.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def hori
  @hori
end

#index_subtable_array_offsetObject (readonly)

Returns the value of attribute index_subtable_array_offset.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def index_subtable_array_offset
  @index_subtable_array_offset
end

#index_tables_sizeObject (readonly)

Returns the value of attribute index_tables_size.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def index_tables_size
  @index_tables_size
end

#number_of_index_subtablesObject (readonly)

Returns the value of attribute number_of_index_subtables.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def number_of_index_subtables
  @number_of_index_subtables
end

#ppem_xObject (readonly)

Returns the value of attribute ppem_x.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def ppem_x
  @ppem_x
end

#ppem_yObject (readonly)

Returns the value of attribute ppem_y.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def ppem_y
  @ppem_y
end

#start_glyph_indexObject (readonly)

Returns the value of attribute start_glyph_index.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def start_glyph_index
  @start_glyph_index
end

#vertObject (readonly)

Returns the value of attribute vert.



114
115
116
# File 'lib/fontisan/tables/cblc.rb', line 114

def vert
  @vert
end

Class Method Details

.read(io) ⇒ Object

Read the SbitLineMetrics structures manually



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/fontisan/tables/cblc.rb', line 83

def self.read(io)
  data = io.is_a?(String) ? io : io.read
  size = new

  io = StringIO.new(data)
  size.instance_variable_set(:@index_subtable_array_offset,
                             io.read(4).unpack1("N"))
  size.instance_variable_set(:@index_tables_size,
                             io.read(4).unpack1("N"))
  size.instance_variable_set(:@number_of_index_subtables,
                             io.read(4).unpack1("N"))
  size.instance_variable_set(:@color_ref, io.read(4).unpack1("N"))

  # Parse hori and vert metrics (12 bytes each)
  hori_data = io.read(12)
  vert_data = io.read(12)
  size.instance_variable_set(:@hori, SbitLineMetrics.read(hori_data))
  size.instance_variable_set(:@vert, SbitLineMetrics.read(vert_data))

  # Parse remaining fields
  size.instance_variable_set(:@start_glyph_index,
                             io.read(2).unpack1("n"))
  size.instance_variable_set(:@end_glyph_index, io.read(2).unpack1("n"))
  size.instance_variable_set(:@ppem_x, io.read(1).unpack1("C"))
  size.instance_variable_set(:@ppem_y, io.read(1).unpack1("C"))
  size.instance_variable_set(:@bit_depth, io.read(1).unpack1("C"))
  size.instance_variable_set(:@flags, io.read(1).unpack1("c"))

  size
end

Instance Method Details

#glyph_rangeRange

Get glyph range for this strike

Returns:

  • (Range)

    Range of glyph IDs



129
130
131
# File 'lib/fontisan/tables/cblc.rb', line 129

def glyph_range
  start_glyph_index..end_glyph_index
end

#includes_glyph?(glyph_id) ⇒ Boolean

Check if this strike includes a specific glyph ID

Parameters:

  • glyph_id (Integer)

    Glyph ID to check

Returns:

  • (Boolean)

    True if glyph is in range



137
138
139
# File 'lib/fontisan/tables/cblc.rb', line 137

def includes_glyph?(glyph_id)
  glyph_range.include?(glyph_id)
end

#ppemInteger

Get ppem size (assumes square pixels)

Returns:

  • (Integer)

    Pixels per em



122
123
124
# File 'lib/fontisan/tables/cblc.rb', line 122

def ppem
  ppem_x
end