Class: Fontisan::Models::BitmapStrike

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/fontisan/models/bitmap_strike.rb

Overview

Bitmap strike representation model

Represents a bitmap strike (size) from the CBLC table. Each strike contains bitmap glyphs at a specific ppem (pixels per em) size.

This model uses lutaml-model for structured serialization to YAML/JSON/XML.

Examples:

Creating a bitmap strike

strike = BitmapStrike.new
strike.ppem = 16
strike.start_glyph_id = 10
strike.end_glyph_id = 100
strike.bit_depth = 32

Serializing to JSON

json = strike.to_json
# {
#   "ppem": 16,
#   "start_glyph_id": 10,
#   "end_glyph_id": 100,
#   "bit_depth": 32
# }

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bit_depthInteger

Returns Bit depth (1, 2, 4, 8, or 32).

Returns:

  • (Integer)

    Bit depth (1, 2, 4, 8, or 32)



44
# File 'lib/fontisan/models/bitmap_strike.rb', line 44

attribute :bit_depth, :integer

#end_glyph_idInteger

Returns Last glyph ID in this strike.

Returns:

  • (Integer)

    Last glyph ID in this strike



40
# File 'lib/fontisan/models/bitmap_strike.rb', line 40

attribute :end_glyph_id, :integer

#num_glyphsInteger

Returns Number of glyphs in this strike.

Returns:

  • (Integer)

    Number of glyphs in this strike



48
# File 'lib/fontisan/models/bitmap_strike.rb', line 48

attribute :num_glyphs, :integer

#ppemInteger

Returns Pixels per em (square pixels).

Returns:

  • (Integer)

    Pixels per em (square pixels)



32
# File 'lib/fontisan/models/bitmap_strike.rb', line 32

attribute :ppem, :integer

#start_glyph_idInteger

Returns First glyph ID in this strike.

Returns:

  • (Integer)

    First glyph ID in this strike



36
# File 'lib/fontisan/models/bitmap_strike.rb', line 36

attribute :start_glyph_id, :integer

Instance Method Details

#color?Boolean

Check if this is a color strike (32-bit)

Returns:

  • (Boolean)

    True if 32-bit color



82
83
84
# File 'lib/fontisan/models/bitmap_strike.rb', line 82

def color?
  bit_depth == 32
end

#color_depthString

Get the color depth description

Returns:

  • (String)

    Human-readable color depth



68
69
70
71
72
73
74
75
76
77
# File 'lib/fontisan/models/bitmap_strike.rb', line 68

def color_depth
  case bit_depth
  when 1 then "1-bit (monochrome)"
  when 2 then "2-bit (4 colors)"
  when 4 then "4-bit (16 colors)"
  when 8 then "8-bit (256 colors)"
  when 32 then "32-bit (full color with alpha)"
  else "#{bit_depth}-bit"
  end
end

#glyph_rangeRange

Get glyph IDs covered by this strike

Returns:

  • (Range)

    Range of glyph IDs



53
54
55
# File 'lib/fontisan/models/bitmap_strike.rb', line 53

def glyph_range
  start_glyph_id..end_glyph_id
end

#includes_glyph?(glyph_id) ⇒ Boolean

Check if this strike covers a specific glyph ID

Parameters:

  • glyph_id (Integer)

    Glyph ID to check

Returns:

  • (Boolean)

    True if glyph is in range



61
62
63
# File 'lib/fontisan/models/bitmap_strike.rb', line 61

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

#monochrome?Boolean

Check if this is a monochrome strike (1-bit)

Returns:

  • (Boolean)

    True if 1-bit monochrome



89
90
91
# File 'lib/fontisan/models/bitmap_strike.rb', line 89

def monochrome?
  bit_depth == 1
end