public override void RenderWidthsArrayToPDF(PDFContextBase context, PDFWriter writer) { writer.WriteArrayNumberEntries(this._widths.ToArray()); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "PDFFontWidths", "Rendered " + this._widths.Count.ToString() + " widths written as a simple array"); } }
public PDFObjectRef RenderToPDF(string fullname, PDFContextBase context, PDFWriter writer) { if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Font Descriptor", "Rendering the font descriptor information"); } PDFObjectRef oref = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "FontDescriptor"); writer.WriteDictionaryNameEntry("FontName", fullname); if (this.FontFamily != String.Empty) { writer.WriteDictionaryStringEntry("FontFamily", this.FontFamily); } if (this.BoundingBox != null && this.BoundingBox.Length > 0) { writer.BeginDictionaryEntry("FontBBox"); writer.WriteArrayNumberEntries(this.BoundingBox); writer.EndDictionaryEntry(); } if (this.FontStretch != FontStretch.Normal) { writer.WriteDictionaryStringEntry("FontStretch", this.FontStretch.ToString()); } if (this.Weight != 400) { writer.WriteDictionaryNumberEntry("FontWeight", this.Weight); } writer.WriteDictionaryNumberEntry("FontWeight", 700); writer.WriteDictionaryNumberEntry("Flags", (int)this.Flags); writer.WriteDictionaryNumberEntry("Ascent", (int)(this.Ascent * 0.6)); writer.WriteDictionaryNumberEntry("Descent", this.Descent); //if (this.Leading != 0.0) // writer.WriteDictionaryNumberEntry("Leading", this.Leading); if (this.CapHeight != 0.0) { writer.WriteDictionaryNumberEntry("CapHeight", this.CapHeight); } if (this.XHeight != 0.0) { writer.WriteDictionaryNumberEntry("XHeight", this.XHeight); } writer.WriteDictionaryNumberEntry("StemV", this.StemV); writer.WriteDictionaryNumberEntry("ItalicAngle", this.ItalicAngle); if (this.StemH != 0.0) { writer.WriteDictionaryNumberEntry("StemH", this.StemH); } if (this.AvgWidth != 0.0) { writer.WriteDictionaryNumberEntry("AvgWidth", this.AvgWidth); } if (this.MaxWidth != 0.0) { writer.WriteDictionaryNumberEntry("MaxWidth", this.MaxWidth); } if (this.MissingWidth != 0.0) { writer.WriteDictionaryNumberEntry("MissingWidth", this.MissingWidth); } if (this.FontFile != null) { if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Font Descriptor", "Rendering the font descriptor font file"); } byte[] outputdata = this.FontFile; string filter = null; if (context.Compression == OutputCompressionType.FlateDecode) { if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Font Descriptor", "Ensuring the font data is compressed"); } outputdata = this.FilteredFontFile; filter = this.FilterName; } PDFObjectRef fileref = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNumberEntry("Length", outputdata.Length); if (this.FontType == FontType.TrueType) { writer.WriteDictionaryNumberEntry("Length1", this.FontFile.Length); } else { throw new ArgumentOutOfRangeException("FontType"); } if (!string.IsNullOrEmpty(filter)) { writer.WriteDictionaryNameEntry("Filter", this.FilterName); } writer.EndDictionary(); writer.BeginStream(fileref); writer.WriteRaw(outputdata, 0, outputdata.Length); writer.EndStream(); writer.EndObject(); //We know this is a true type font program from above writer.WriteDictionaryObjectRefEntry("FontFile2", fileref); } writer.EndDictionary(); writer.EndObject(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Font Descriptor", "Completed font descriptor"); } return(oref); }