Class: Fontisan::Audit::Extractors::OpenTypeLayout
- Defined in:
- lib/fontisan/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) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/fontisan/audit/extractors/opentype_layout.rb', line 16 def extract(context) font = context.font return { opentype_layout: nil } unless sfnt?(font) gsub_scripts = scripts_in(font, Constants::GSUB_TAG) gpos_scripts = scripts_in(font, Constants::GPOS_TAG) 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, Constants::GSUB_TAG, tag), gpos_features: features_for(font, Constants::GPOS_TAG, 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?(Constants::GSUB_TAG), has_gpos: font.has_table?(Constants::GPOS_TAG), ) } end |