Class: Fontisan::Hints::HintConverter
- Inherits:
-
Object
- Object
- Fontisan::Hints::HintConverter
- Defined in:
- lib/fontisan/hints/hint_converter.rb
Overview
Converts hints between TrueType and PostScript formats
This converter handles bidirectional conversion of rendering hints, translating between TrueType instruction-based hinting and PostScript operator-based hinting while preserving intent where possible.
**Conversion Strategy:**
-
TrueType → PostScript: Extract semantic meaning from instructions and convert to corresponding PostScript operators
-
PostScript → TrueType: Analyze hint operators and generate equivalent TrueType instructions
Instance Method Summary collapse
-
#optimize(hints) ⇒ Array<Hint>
Optimize hint set by removing redundant hints.
-
#to_postscript(hints) ⇒ Array<Hint>
Convert hints to PostScript format.
-
#to_truetype(hints) ⇒ Array<Hint>
Convert hints to TrueType format.
Instance Method Details
#optimize(hints) ⇒ Array<Hint>
Optimize hint set by removing redundant hints
60 61 62 63 64 65 66 67 68 |
# File 'lib/fontisan/hints/hint_converter.rb', line 60 def optimize(hints) return [] if hints.nil? || hints.empty? # Remove duplicate hints unique_hints = hints.uniq { |h| [h.type, h.data] } # Remove conflicting hints (keep first) remove_conflicts(unique_hints) end |
#to_postscript(hints) ⇒ Array<Hint>
Convert hints to PostScript format
32 33 34 35 36 37 38 39 40 |
# File 'lib/fontisan/hints/hint_converter.rb', line 32 def to_postscript(hints) return [] if hints.nil? || hints.empty? hints.map do |hint| next hint if hint.source_format == :postscript convert_hint_to_postscript(hint) end.compact end |
#to_truetype(hints) ⇒ Array<Hint>
Convert hints to TrueType format
46 47 48 49 50 51 52 53 54 |
# File 'lib/fontisan/hints/hint_converter.rb', line 46 def to_truetype(hints) return [] if hints.nil? || hints.empty? hints.map do |hint| next hint if hint.source_format == :truetype convert_hint_to_truetype(hint) end.compact end |