Class: Fontisan::Hints::TrueTypeHintExtractor

Inherits:
Object
  • Object
show all
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)

Examples:

Extract hints from a glyph

extractor = TrueTypeHintExtractor.new
hints = extractor.extract(glyph)

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]
ALIGNRP =
0x3C
DELTAP1 =
0x5D
DELTAP2 =
0x71
DELTAP3 =
0x72

Instance Method Summary collapse

Instance Method Details

#extract(glyph) ⇒ Array<Hint>

Extract hints from TrueType glyph

Parameters:

  • glyph (Glyph)

    TrueType glyph with instructions

Returns:

  • (Array<Hint>)

    Extracted hints



42
43
44
45
46
47
48
49
50
# File 'lib/fontisan/hints/truetype_hint_extractor.rb', line 42

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