The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

MaxpTable.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/MaxpTable.vala.
Fix compile time error
1 /* 2 Copyright (C) 2012, 2013 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 15 namespace BirdFont { 16 17 public class MaxpTable : OtfTable { 18 19 GlyfTable glyf_table; 20 21 public uint16 num_glyphs = 0; 22 23 public MaxpTable (GlyfTable g) { 24 glyf_table = g; 25 id = "maxp"; 26 } 27 28 public override void parse (FontData dis) 29 requires (offset > 0 && length > 0) { 30 Fixed format; 31 32 dis.seek (offset); 33 34 format = dis.read_fixed (); 35 printd (@"Maxp version: $(format.get_string ())\n"); 36 37 num_glyphs = dis.read_ushort (); 38 39 if (format == 0x00005000) { 40 return; 41 } 42 43 // Format 1.0 continues here 44 } 45 46 public void process () { 47 FontData fd = new FontData(); 48 49 // Version 0.5 for fonts with cff data and 1.0 for ttf 50 fd.add_u32 (0x00010000); 51 52 if (glyf_table.glyphs.size == 0) { 53 warning ("Zero glyphs in maxp table."); 54 } 55 56 fd.add_u16 ((uint16) glyf_table.glyphs.size); // numGlyphs in the font 57 58 fd.add_u16 (glyf_table.get_max_points ()); // max points 59 fd.add_u16 (glyf_table.get_max_contours ()); // max contours 60 fd.add_u16 (0); // max composite points 61 fd.add_u16 (0); // max composite contours 62 fd.add_u16 (1); // max zones 63 fd.add_u16 (0); // twilight points 64 fd.add_u16 (0); // max storage 65 fd.add_u16 (0); // max function defs 66 fd.add_u16 (0); // max instruction defs 67 fd.add_u16 (0); // max stack elements 68 fd.add_u16 (0); // max size of instructions 69 fd.add_u16 (0); // max component elements 70 fd.add_u16 (0); // component depth 71 72 fd.pad (); 73 74 this.font_data = fd; 75 } 76 } 77 78 } 79