/// <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(); }
protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; // These two fields are common to versions 0.5 and 1.0 stream.WriteFixed(versionNo); stream.WriteUShort(numGlyphs); // Version 1.0 of this table contains more data if (versionNo == 0x00010000) { stream.WriteUShort(maxPoints); stream.WriteUShort(maxContours); stream.WriteUShort(maxCompositePoints); stream.WriteUShort(maxCompositeContours); stream.WriteUShort(maxZones); stream.WriteUShort(maxTwilightPoints); stream.WriteUShort(maxStorage); stream.WriteUShort(maxFunctionDefs); stream.WriteUShort(maxInstructionDefs); stream.WriteUShort(maxStackElements); stream.WriteUShort(maxSizeOfInstructions); stream.WriteUShort(maxComponentElements); stream.WriteUShort(maxComponentDepth); } }
protected internal override void Write(FontFileWriter writer) { foreach (uint offset in offsets) { writer.Stream.WriteULong(offset); } }
protected internal override void Write(FontFileWriter writer) { // TODO: Determine short/long format foreach (uint offset in offsets) { writer.Stream.WriteULong(offset); } }
protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; for (int i = 0; i < metrics.Count; i++) { HorizontalMetric metric = (HorizontalMetric) metrics[i]; stream.WriteUShort(metric.AdvanceWidth); stream.WriteShort(metric.LeftSideBearing); } }
/// <summary> /// Writes the contents of the glyf table to the supplied stream. /// </summary> /// <param name="writer"></param> protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; foreach (int subsetIndex in glyphDescriptions.Keys) { this[subsetIndex].Write(stream); } }
protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; for (int i = 0; i < metrics.Count; i++) { HorizontalMetric metric = metrics[i]; stream.WriteUShort(metric.AdvanceWidth); stream.WriteShort(metric.LeftSideBearing); } }
protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; stream.WriteFixed(versionNo); stream.WriteFWord(ascender); stream.WriteFWord(decender); stream.WriteFWord(lineGap); stream.WriteUFWord(advanceWidthMax); stream.WriteFWord(minLeftSideBearing); stream.WriteFWord(minRightSideBearing); stream.WriteFWord(xMaxExtent); stream.WriteShort(caretSlopeRise); stream.WriteShort(caretSlopeRun); stream.WriteShort(caretOffset); stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(metricDataFormat); stream.WriteUShort(numberOfHMetrics); }
/// <summary> /// Writes the contents of the head table to the supplied stream. /// </summary> /// <param name="writer"></param> protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; stream.WriteFixed(versionNo); stream.WriteFixed(fontRevision); stream.WriteULong(0); stream.WriteULong(0x5F0F3CF5); stream.WriteUShort(flags); stream.WriteUShort(unitsPermEm); stream.WriteDateTime((long)(createDate - BaseDate).TotalSeconds); stream.WriteDateTime((long)(updateDate - BaseDate).TotalSeconds); stream.WriteShort(xMin); stream.WriteShort(yMin); stream.WriteShort(xMax); stream.WriteShort(yMax); stream.WriteUShort(macStyle); stream.WriteUShort(lowestRecPPEM); stream.WriteShort(fontDirectionHint); stream.WriteShort(1); stream.WriteShort(glyphDataFormat); }
protected internal override void Write(FontFileWriter writer) { throw new NotImplementedException("Write is not implemented."); }
/// <summary> /// No supported. /// </summary> /// <param name="writer"></param> protected internal override void Write(FontFileWriter writer) { throw new InvalidOperationException("Write not supported."); }
protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; stream.WriteFixed(versionNo); stream.WriteFWord(ascender); stream.WriteFWord(decender); stream.WriteFWord(lineGap); stream.WriteUFWord(advanceWidthMax); stream.WriteFWord(minLeftSideBearing); stream.WriteFWord(minRightSideBearing); stream.WriteFWord(xMaxExtent); stream.WriteShort(caretSlopeRise); stream.WriteShort(caretSlopeRun); stream.WriteShort(caretOffset); // TODO: Check these 4 fields are all 0 stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(0); stream.WriteShort(metricDataFormat); stream.WriteUShort(numberOfHMetrics); }
/// <summary> /// Writes the contents of a table to the supplied writer. /// </summary> /// <remarks> /// This method should not be concerned with aligning the /// table output on the 4-byte boundary. /// </remarks> /// <param name="writer"></param> protected internal abstract void Write(FontFileWriter writer);
/// <summary> /// Writes the contents of the head table to the supplied stream. /// </summary> /// <param name="writer"></param> protected internal override void Write(FontFileWriter writer) { FontFileStream stream = writer.Stream; stream.WriteFixed(versionNo); stream.WriteFixed(fontRevision); // TODO: Calculate based on entire font stream.WriteULong(0); stream.WriteULong(0x5F0F3CF5); stream.WriteUShort(flags); stream.WriteUShort(unitsPermEm); stream.WriteDateTime((long) (createDate - BaseDate).TotalSeconds); stream.WriteDateTime((long) (updateDate - BaseDate).TotalSeconds); stream.WriteShort(xMin); stream.WriteShort(yMin); stream.WriteShort(xMax); stream.WriteShort(yMax); stream.WriteUShort(macStyle); stream.WriteUShort(lowestRecPPEM); stream.WriteShort(fontDirectionHint); // TODO: Always write loca offsets as ulongs stream.WriteShort(1); stream.WriteShort(glyphDataFormat); }