Class: Fontisan::Type1::FontDictionary::Encoding
- Inherits:
-
Object
- Object
- Fontisan::Type1::FontDictionary::Encoding
- Defined in:
- lib/fontisan/type1/font_dictionary.rb
Overview
Encoding vector
Maps character codes to glyph names in the font.
Instance Attribute Summary collapse
-
#encoding_map ⇒ Hash
readonly
Character code to glyph name mapping.
-
#encoding_type ⇒ Symbol
readonly
Encoding type (:standard, :custom, :identity).
Instance Method Summary collapse
-
#[](char_code) ⇒ String?
Get glyph name for character code.
-
#initialize ⇒ Encoding
constructor
A new instance of Encoding.
-
#parse(dict_data) ⇒ Object
Parse encoding from dictionary data.
-
#standard? ⇒ Boolean
Check if encoding is standard.
Constructor Details
#initialize ⇒ Encoding
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_map ⇒ Hash (readonly)
Returns 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_type ⇒ Symbol (readonly)
Returns 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
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
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
401 402 403 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 401 def standard? @encoding_type == :standard end |