David PHAM-VAN

Add some asserts on the TtfParser

@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 - Add LayoutWidgetBuilder 6 - Add LayoutWidgetBuilder
7 - Add GridPaper widget 7 - Add GridPaper widget
8 - Improve internal sructure 8 - Improve internal sructure
  9 +- Add some asserts on the TtfParser
9 10
10 ## 1.13.0 11 ## 1.13.0
11 12
@@ -54,6 +54,23 @@ class TtfParser { @@ -54,6 +54,23 @@ class TtfParser {
54 tableSize[name] = size; 54 tableSize[name] = size;
55 } 55 }
56 56
  57 + assert(tableOffsets.containsKey(head_table),
  58 + 'Unable to find the `head` table. This file is not a supported TTF font');
  59 + assert(tableOffsets.containsKey(name_table),
  60 + 'Unable to find the `name` table. This file is not a supported TTF font');
  61 + assert(tableOffsets.containsKey(hmtx_table),
  62 + 'Unable to find the `hmtx` table. This file is not a supported TTF font');
  63 + assert(tableOffsets.containsKey(hhea_table),
  64 + 'Unable to find the `hhea` table. This file is not a supported TTF font');
  65 + assert(tableOffsets.containsKey(cmap_table),
  66 + 'Unable to find the `cmap` table. This file is not a supported TTF font');
  67 + assert(tableOffsets.containsKey(maxp_table),
  68 + 'Unable to find the `maxp` table. This file is not a supported TTF font');
  69 + assert(tableOffsets.containsKey(loca_table),
  70 + 'Unable to find the `loca` table. This file is not a supported TTF font');
  71 + assert(tableOffsets.containsKey(glyf_table),
  72 + 'Unable to find the `glyf` table. This file is not a supported TTF font');
  73 +
57 _parseFontName(); 74 _parseFontName();
58 _parseCMap(); 75 _parseCMap();
59 _parseIndexes(); 76 _parseIndexes();