Class: Fontisan::Tables::Gsub
- Inherits:
-
Binary::BaseRecord
- Object
- BinData::Record
- Binary::BaseRecord
- Fontisan::Tables::Gsub
- Defined in:
- lib/fontisan/tables/gsub.rb
Overview
GSUB (Glyph Substitution) table parser Parses OpenType GSUB table to extract scripts and features
Instance Method Summary collapse
-
#features(script_tag: "latn") ⇒ Array<String>
Get all feature tags for a given script.
-
#scripts ⇒ Array<String>
Get all script tags supported by this font.
Methods inherited from Binary::BaseRecord
Instance Method Details
#features(script_tag: "latn") ⇒ Array<String>
Get all feature tags for a given script
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fontisan/tables/gsub.rb', line 34 def features(script_tag: "latn") return [] if script_list_offset.zero? || feature_list_offset.zero? # Get feature indices from the script's LangSys feature_indices = feature_indices_for_script(script_tag) return [] if feature_indices.empty? # Get feature list feature_list_data = table_data[(feature_list_offset - 10)..] return [] if feature_list_data.nil? || feature_list_data.empty? feature_list = LayoutCommon::FeatureList.read(feature_list_data) # Collect features referenced by the script features = [] feature_indices.each do |idx| next if idx >= feature_list.feature_count features << feature_list.feature_records[idx].feature_tag end features.uniq rescue StandardError [] end |
#scripts ⇒ Array<String>
Get all script tags supported by this font
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fontisan/tables/gsub.rb', line 19 def scripts return [] if script_list_offset.zero? script_list_data = table_data[(script_list_offset - 10)..] return [] if script_list_data.nil? || script_list_data.empty? script_list = LayoutCommon::ScriptList.read(script_list_data) script_list. rescue StandardError [] end |