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 font tables

This applier validates and applies PostScript hint data to CFF fonts by rebuilding the entire CFF table structure with updated Private DICT parameters.

Status: Fully Operational (Phase 10A Complete)

**PostScript Hint Parameters (Private DICT)**:

  • blue_values: Alignment zones for overshoot suppression

  • other_blues: Additional alignment zones

  • std_hw: Standard horizontal stem width

  • std_vw: Standard vertical stem width

  • stem_snap_h: Horizontal stem snap widths

  • stem_snap_v: Vertical stem snap widths

  • blue_scale, blue_shift, blue_fuzz: Overshoot parameters

  • force_bold: Force bold flag

  • language_group: Language group (0=Latin, 1=CJK)

Examples:

Apply PostScript hints

applier = PostScriptHintApplier.new
tables = { "CFF " => cff_table }
hint_set = HintSet.new(format: "postscript", private_dict_hints: hints_json)
result = applier.apply(hint_set, tables)

Instance Method Summary collapse

Instance Method Details

#apply(hint_set, tables) ⇒ Hash

Apply PostScript hints to font tables

Validates hint data and rebuilds CFF table with updated Private DICT. Supports arbitrary Private DICT size changes through full table reconstruction. Also supports per-glyph hints injected directly into CharStrings.

Parameters:

  • hint_set (HintSet)

    Hint data to apply

  • tables (Hash)

    Font tables (must include “CFF ” or “CFF2 ”)

Returns:

  • (Hash)

    Updated font tables with hints applied



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

def apply(hint_set, tables)
  return tables if hint_set.nil? || hint_set.empty?
  return tables unless hint_set.format == "postscript"

  if cff2_table?(tables)
    apply_cff2_hints(hint_set, tables)
  elsif cff_table?(tables)
    apply_cff_hints(hint_set, tables)
  else
    tables
  end
end