Class: Ucode::Audit::Extractors::OpenTypeLayout
- Defined in:
- lib/ucode/audit/extractors/opentype_layout.rb
Overview
OpenType layout summary: union of GSUB + GPOS scripts and features, plus a per-script breakdown preserving which feature belongs to which script under which table.
Returned fields:
opentype_layout: Models::Audit::OpenTypeLayout, or nil for
Type 1
Owned here (MECE split from Aggregations, which is UCD-only).
Instance Method Summary collapse
Instance Method Details
#extract(context) ⇒ Hash{Symbol=>Object}
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ucode/audit/extractors/opentype_layout.rb', line 20 def extract(context) font = context.font return { opentype_layout: nil } unless sfnt?(font) gsub_scripts = scripts_in(font, "GSUB") gpos_scripts = scripts_in(font, "GPOS") all_scripts = (gsub_scripts + gpos_scripts).uniq.sort by_script = all_scripts.map do |tag| Models::Audit::ScriptFeatures.new( script: tag, gsub_features: features_for(font, "GSUB", tag), gpos_features: features_for(font, "GPOS", tag), ) end { opentype_layout: Models::Audit::OpenTypeLayout.new( scripts: all_scripts, features: aggregate_features(by_script), by_script: by_script, has_gsub: font.has_table?("GSUB"), has_gpos: font.has_table?("GPOS"), ) } end |