Class: Fontisan::Type1::SeacExpander
- Inherits:
-
Object
- Object
- Fontisan::Type1::SeacExpander
- Defined in:
- lib/fontisan/type1/seac_expander.rb
Overview
Expands Type 1 seac composite glyphs into base + accent outlines
SeacExpander handles the
decomposition of Type 1 composite glyphs that use the seac operator.
The seac operator combines two glyphs (a base character and an accent)
with a positioning offset, which must be decomposed for CFF conversion.
Supports nested seac: if a base or accent glyph is itself a seac composite, it is recursively expanded. Cycles are detected and raise SeacReferenceError.
The seac operator format is:
seac asb adx ady bchar achar
Where:
asb: Accent side bearing (not used in decomposition)adx: X offset for accent placementady: Y offset for accent placementbchar: Character code of base glyphachar: Character code of accent glyph
Constant Summary collapse
- MAX_DEPTH =
16
Instance Attribute Summary collapse
-
#charstrings ⇒ CharStrings
readonly
Type 1 CharStrings dictionary.
-
#private_dict ⇒ PrivateDict
readonly
Private dictionary for hinting.
Instance Method Summary collapse
-
#composite?(glyph_name) ⇒ Boolean
Check if a glyph is a seac composite.
-
#composite_glyphs ⇒ Array<String>
Get all seac composite glyphs in the font.
-
#decompose(glyph_name) ⇒ String?
Decompose a seac composite glyph into base + accent outlines.
-
#initialize(charstrings, private_dict) ⇒ SeacExpander
constructor
Initialize a new SeacExpander.
Constructor Details
#initialize(charstrings, private_dict) ⇒ SeacExpander
Initialize a new SeacExpander
51 52 53 54 |
# File 'lib/fontisan/type1/seac_expander.rb', line 51 def initialize(charstrings, private_dict) @charstrings = charstrings @private_dict = private_dict end |
Instance Attribute Details
#charstrings ⇒ CharStrings (readonly)
Returns Type 1 CharStrings dictionary.
42 43 44 |
# File 'lib/fontisan/type1/seac_expander.rb', line 42 def charstrings @charstrings end |
#private_dict ⇒ PrivateDict (readonly)
Returns Private dictionary for hinting.
45 46 47 |
# File 'lib/fontisan/type1/seac_expander.rb', line 45 def private_dict @private_dict end |
Instance Method Details
#composite?(glyph_name) ⇒ Boolean
Check if a glyph is a seac composite
71 72 73 |
# File 'lib/fontisan/type1/seac_expander.rb', line 71 def composite?(glyph_name) @charstrings.composite?(glyph_name) end |
#composite_glyphs ⇒ Array<String>
Get all seac composite glyphs in the font
78 79 80 |
# File 'lib/fontisan/type1/seac_expander.rb', line 78 def composite_glyphs @charstrings.glyph_names.select { |name| composite?(name) } end |
#decompose(glyph_name) ⇒ String?
Decompose a seac composite glyph into base + accent outlines. Handles nested seac recursively.
63 64 65 |
# File 'lib/fontisan/type1/seac_expander.rb', line 63 def decompose(glyph_name) decompose_with_visited(glyph_name, Set.new) end |