Class: Fontisan::Hints::PostScriptHintApplier

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/hints/postscript_hint_applier.rb

Overview

Applies rendering hints to PostScript/CFF CharString data

This applier converts universal Hint objects into PostScript hint operators and integrates them into CharString data. It ensures proper operator placement and maintains CharString validity.

**PostScript Hint Placement:**

  • Stem hints (hstem/vstem) must appear at the beginning

  • Hintmask operators can appear throughout the CharString

  • Hints affect all subsequent path operations

Examples:

Apply hints to a CharString

applier = PostScriptHintApplier.new
charstring_with_hints = applier.apply(charstring, hints)

Constant Summary collapse

HSTEM =

CFF CharString operators

1
VSTEM =
3
HINTMASK =
19
CNTRMASK =
20
HSTEM3 =
[12, 2]
VSTEM3 =
[12, 1]

Instance Method Summary collapse

Instance Method Details

#apply(charstring, hints) ⇒ String

Apply hints to CharString

Parameters:

  • charstring (String)

    Original CharString bytes

  • hints (Array<Hint>)

    Hints to apply

Returns:

  • (String)

    CharString with applied hints



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fontisan/hints/postscript_hint_applier.rb', line 36

def apply(charstring, hints)
  return charstring if hints.nil? || hints.empty?
  return charstring if charstring.nil? || charstring.empty?

  # Build hint operators
  hint_ops = build_hint_operators(hints)

  # Insert hints at the beginning of CharString
  # (simplified - real implementation would analyze existing structure)
  hint_ops + charstring
end