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.
430 431 432 433 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 430 def initialize @encoding_map = {} @encoding_type = :standard end |
Instance Attribute Details
#encoding_map ⇒ Hash (readonly)
Returns Character code to glyph name mapping.
425 426 427 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 425 def encoding_map @encoding_map end |
#encoding_type ⇒ Symbol (readonly)
Returns Encoding type (:standard, :custom, :identity).
428 429 430 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 428 def encoding_type @encoding_type end |
Instance Method Details
#[](char_code) ⇒ String?
Get glyph name for character code
456 457 458 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 456 def [](char_code) @encoding_map[char_code] end |
#parse(dict_data) ⇒ Object
Parse encoding from dictionary data
438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 438 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
463 464 465 |
# File 'lib/fontisan/type1/font_dictionary.rb', line 463 def standard? @encoding_type == :standard end |