/// <summary> /// Writes the font subset to the supplied output stream. /// </summary> public void Generate(MemoryStream output) { HeaderTable head = reader.GetHeaderTable(); MaximumProfileTable maxp = reader.GetMaximumProfileTable(); HorizontalHeaderTable hhea = reader.GetHorizontalHeaderTable(); ControlValueTable cvt = reader.GetControlValueTable(); FontProgramTable fpgm = reader.GetFontProgramTable(); GlyfDataTable glyf = reader.GetGlyfDataTable(); ControlValueProgramTable prep = reader.GetControlValueProgramTable(); IndexToLocationTable loca = CreateLocaTable(glyf); HorizontalMetricsTable hmtx = CreateHmtxTable(glyf); // Since we're reusing the hhea and maxp tables, we must update // the numberOfHMetrics and numGlyphs fields to reflect the reduced // number of glyphs. maxp.GlyphCount = glyf.Count; hhea.HMetricCount = glyf.Count; FontFileWriter writer = new FontFileWriter(output); writer.Write(head); writer.Write(maxp); writer.Write(hhea); writer.Write(hmtx); writer.Write(cvt); writer.Write(prep); writer.Write(fpgm); writer.Write(loca); writer.Write(glyf); writer.Close(); }
/// <summary> /// Updates the checkSumAdjustment field in the head table. /// </summary> private void WriteChecksumAdjustment() { HeaderTable head = (HeaderTable)tables[TableNames.Head]; // Move to beginning of head table and skip the version no and // font revision no fields. stream.Position = head.Entry.Offset + 2 * PrimitiveSizes.Fixed; stream.WriteULong(CalculateCheckSumAdjustment()); }
private void EnsureHeadTable() { if (head == null) { head = (HeaderTable) GetTable(TableNames.Head); } }