Class: Fontisan::Type1::FontDictionary::Encoding

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/type1/font_dictionary.rb

Overview

Encoding vector

Maps character codes to glyph names in the font.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEncoding

Returns a new instance of Encoding.



368
369
370
371
# File 'lib/fontisan/type1/font_dictionary.rb', line 368

def initialize
  @encoding_map = {}
  @encoding_type = :standard
end

Instance Attribute Details

#encoding_mapHash (readonly)

Returns Character code to glyph name mapping.

Returns:

  • (Hash)

    Character code to glyph name mapping



363
364
365
# File 'lib/fontisan/type1/font_dictionary.rb', line 363

def encoding_map
  @encoding_map
end

#encoding_typeSymbol (readonly)

Returns Encoding type (:standard, :custom, :identity).

Returns:

  • (Symbol)

    Encoding type (:standard, :custom, :identity)



366
367
368
# File 'lib/fontisan/type1/font_dictionary.rb', line 366

def encoding_type
  @encoding_type
end

Instance Method Details

#[](char_code) ⇒ String?

Get glyph name for character code

Parameters:

  • char_code (Integer)

    Character code

Returns:

  • (String, nil)

    Glyph name or nil



394
395
396
# File 'lib/fontisan/type1/font_dictionary.rb', line 394

def [](char_code)
  @encoding_map[char_code]
end

#parse(dict_data) ⇒ Object

Parse encoding from dictionary data

Parameters:

  • dict_data (Hash)

    Dictionary data



376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/fontisan/type1/font_dictionary.rb', line 376

def parse(dict_data)
  # Type 1 fonts typically use StandardEncoding by default
  # Custom encodings are specified as an array

  @encoding_type = if dict_data[:encoding]
                     :custom
                   else
                     :standard
                   end

  # Populate with StandardEncoding if standard
  populate_standard_encoding if @encoding_type == :standard
end

#standard?Boolean

Check if encoding is standard

Returns:

  • (Boolean)

    True if using StandardEncoding



401
402
403
# File 'lib/fontisan/type1/font_dictionary.rb', line 401

def standard?
  @encoding_type == :standard
end