Class: Fontisan::Hints::TrueTypeHintExtractor
- Inherits:
-
Object
- Object
- Fontisan::Hints::TrueTypeHintExtractor
- Defined in:
- lib/fontisan/hints/truetype_hint_extractor.rb
Overview
Extracts rendering hints from TrueType glyph data
TrueType uses bytecode instructions for hinting. This extractor analyzes glyph instruction sequences and converts them into universal Hint objects for format-agnostic representation.
Supported TrueType Instructions:
- MDAP - Move Direct Absolute Point (stem positioning)
- MDRP - Move Direct Relative Point (stem width)
- IUP - Interpolate Untouched Points (smooth interpolation)
- SHP - Shift Point (point adjustments)
- ALIGNRP - Align to Reference Point (alignment)
- DELTA - Delta instructions (pixel-level adjustments)
Constant Summary collapse
- MDAP_RND =
TrueType instruction opcodes
0x2E- MDAP_NORND =
0x2F- MDRP_MIN_RND_BLACK =
0xC0- IUP_Y =
0x30- IUP_X =
0x31- SHP =
[0x32, 0x33].freeze
- ALIGNRP =
0x3C- DELTAP1 =
0x5D- DELTAP2 =
0x71- DELTAP3 =
0x72
Instance Method Summary collapse
-
#extract(glyph) ⇒ Array<Hint>
Extract hints from TrueType glyph.
-
#extract_from_font(font) ⇒ Models::HintSet
Extract complete hint data from TrueType font.
Instance Method Details
#extract(glyph) ⇒ Array<Hint>
Extract hints from TrueType glyph
64 65 66 67 68 69 70 71 72 |
# File 'lib/fontisan/hints/truetype_hint_extractor.rb', line 64 def extract(glyph) return [] if glyph.nil? || glyph.empty? return [] unless glyph.respond_to?(:instructions) instructions = glyph.instructions || [] return [] if instructions.empty? parse_instructions(instructions) end |
#extract_from_font(font) ⇒ Models::HintSet
Extract complete hint data from TrueType font
This extracts both font-level hints (fpgm, prep, cvt tables) and per-glyph hints from glyph instructions.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fontisan/hints/truetype_hint_extractor.rb', line 43 def extract_from_font(font) hint_set = Models::HintSet.new(format: "truetype") # Extract font-level programs hint_set.font_program = extract_font_program(font) hint_set.control_value_program = extract_control_value_program(font) hint_set.control_values = extract_control_values(font) # Extract per-glyph hints extract_glyph_hints(font, hint_set) # Update metadata hint_set.has_hints = !hint_set.empty? hint_set end |