The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

GsubTable.vala in libbirdfont/OpenFontFormat

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libbirdfont/OpenFontFormat/GsubTable.vala.
Create lookups in arbitrary order
1 /* 2 Copyright (C) 2012 2013 2014 2015 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 using Math; 15 16 namespace BirdFont { 17 18 public class GsubTable : OtfTable { 19 20 GlyfTable glyf_table; 21 22 public GsubTable (GlyfTable glyf_table) { 23 this.glyf_table = glyf_table; 24 id = "GSUB"; 25 } 26 27 public override void parse (FontData dis) throws GLib.Error { 28 } 29 30 public void process () throws GLib.Error { 31 FontData fd; 32 33 fd = new FontData (); 34 CligFeature clig_feature = new CligFeature (glyf_table); 35 AlternateFeature alternate_feature = new AlternateFeature (); 36 37 fd.add_ulong (0x00010000); // table version 38 fd.add_ushort (10); // offset to script list 39 fd.add_ushort (30); // offset to feature list 40 fd.add_ushort (clig_feature.contextual.has_ligatures () ? 46 : 44); // offset to lookup list 41 42 // script list 43 fd.add_ushort (1); // number of items in script list 44 fd.add_tag ("DFLT"); // default script 45 fd.add_ushort (8); // offset to script table from script list 46 47 // script table 48 fd.add_ushort (4); // offset to default language system 49 fd.add_ushort (0); // number of languages 50 51 // LangSys table 52 fd.add_ushort (0); // reserved 53 fd.add_ushort (0); // required features (0xFFFF is none) 54 fd.add_ushort (1); // number of features 55 fd.add_ushort (0); // feature index 56 57 // feature table 58 fd.add_ushort (1); // number of features 59 60 fd.add_tag ("clig"); // feature tag 61 fd.add_ushort (8); // offset to feature 62 // FIXME: Should it be liga and clig? 63 64 Lookups lookups = new Lookups (); 65 lookups.append (clig_feature.get_lookups ()); 66 67 // FIXME: refactor clig_feature 68 uint16 feature_lookups = clig_feature.contextual.has_ligatures () ? 2 : 1; 69 70 fd.add_ushort (0); // feature prameters (null) 71 fd.add_ushort (feature_lookups); // number of lookups 72 73 if (clig_feature.contextual.has_ligatures ()) { 74 fd.add_ushort ((uint16) lookups.tables.size - 2); // lookup chained_context (etc.) The chained context tables are listed here but the actual ligature table is only referenced in the context table 75 fd.add_ushort ((uint16) lookups.tables.size - 1); // lookup clig_subtable 76 } else { 77 fd.add_ushort (0); // lookup clig_subtable 78 } 79 80 // lookup list 81 82 fd.append (lookups.genrate_lookup_list ()); 83 84 // subtables 85 foreach (Lookup lookup in lookups.tables) { 86 foreach (FontData subtable in lookup.subtables) { 87 fd.append (subtable); 88 } 89 } 90 91 fd.pad (); 92 93 this.font_data = fd; 94 } 95 } 96 97 } 98 99