byte[] bytes; // Instructions. n is the number of BYTE items that fit in the size of the table. public FontProgram(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.Fpgm; DirectoryEntry = fontData.tableDictionary[TableTagNames.Fpgm]; Read(); }
public static void Test() { Font font = new Font("Times New Roman", 10); FontData image = new FontData(font); // Font font = new Font("Isabelle", 12); // LOGFONT logFont = new LOGFONT(); // font.ToLogFont(logFont); // // IntPtr hfont = CreateFontIndirect(logFont); //// IntPtr hfont2 = font.ToHfont(); //// System.Windows.Forms.MessageBox.Show(hfont2.ToString()); // // Graphics gfx = Graphics.FromHwnd(IntPtr.Zero); // IntPtr hdc = gfx.GetHdc(); // IntPtr oldFont = SelectObject(hdc, hfont); // int size = GetFontData(hdc, 0, 0, null, 0); // // byte[] fontbits = new byte[size]; // int xx = GetFontData(hdc, 0, 0, fontbits, size); // SelectObject(hdc, oldFont); // DeleteObject(hfont); // gfx.ReleaseHdc(hdc); // // FontData image = new FontData(fontbits); // //image.Read(); // // // //HandleRef // // font.GetType(); }
byte[] bytes; // Set of instructions executed whenever point size or font or transformation change. n is the number of BYTE items that fit in the size of the table. public ControlValueProgram(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.Prep; DirectoryEntry = fontData.tableDictionary[TableTagNames.Prep]; Read(); }
FWord[] array; // List of n values referenceable by instructions. n is the number of FWORD items that fit in the size of the table. public ControlValueTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.Cvt; DirectoryEntry = fontData.tableDictionary[TableTagNames.Cvt]; Read(); }
public GlyphSubstitutionTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.GSUB; DirectoryEntry = fontData.tableDictionary[TableTagNames.GSUB]; Read(); }
///// <summary> ///// Initializes a new instance of the <see cref="TrueTypeFontTable"/> class. ///// </summary> //public TrueTypeFontTable(FontData fontData) //{ // this.fontData = fontData; //} public TrueTypeFontTable(FontData fontData, string tag) { this.fontData = fontData; if (fontData != null && fontData.tableDictionary.ContainsKey(tag)) this.DirectoryEntry = fontData.tableDictionary[tag]; else this.DirectoryEntry = new TableDirectoryEntry(tag); this.DirectoryEntry.FontTable = this; }
/// <summary> /// Creates and reads a TableDirectoryEntry from the font image. /// </summary> public static TableDirectoryEntry ReadFrom(FontData fontData) { TableDirectoryEntry entry = new TableDirectoryEntry(); entry.Tag = fontData.ReadTag(); entry.CheckSum = fontData.ReadULong(); entry.Offset = fontData.ReadLong(); entry.Length = (int)fontData.ReadULong(); return(entry); }
///// <summary> ///// Initializes a new instance of the <see cref="TrueTypeFontTable"/> class. ///// </summary> //public TrueTypeFontTable(FontData fontData) //{ // this.fontData = fontData; //} public TrueTypeFontTable(FontData fontData, string tag) { this.fontData = fontData; if (fontData != null && fontData.tableDictionary.ContainsKey(tag)) { this.DirectoryEntry = fontData.tableDictionary[tag]; } else { this.DirectoryEntry = new TableDirectoryEntry(tag); } this.DirectoryEntry.FontTable = this; }
/// <summary> /// This is an external helper function. /// </summary> public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset) { byte[] data = null; if (subset) { TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null); FontData image = descriptor.fontData; CMapInfo cmapInfo = new CMapInfo(descriptor); cmapInfo.AddAnsiChars(); image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false); data = image.Data; } else { FontData fontData = new FontData(font, options); data = fontData.Data; } return(data); }
/// <summary> /// This is an external helper function. /// </summary> public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset) { byte[] data = null; if (subset) { TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null); FontData image = descriptor.fontData; CMapInfo cmapInfo = new CMapInfo(descriptor); cmapInfo.AddAnsiChars(); image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false); data = image.Data; } else { FontData fontData = new FontData(font, options); data = fontData.Data; } return data; }
public IRefFontTable(FontData fontData, TrueTypeFontTable fontTable) : base(null, fontTable.DirectoryEntry.Tag) { this.fontData = fontData; this.irefDirectoryEntry = fontTable.DirectoryEntry; }
public static void Test() { Font font = new Font("Times New Roman", 10); FontData image = new FontData(font); // Font font = new Font("Isabelle", 12); // LOGFONT logFont = new LOGFONT(); // font.ToLogFont(logFont); // // IntPtr hfont = CreateFontIndirect(logFont); //// IntPtr hfont2 = font.ToHfont(); //// System.Windows.Forms.MessageBox.Show(hfont2.ToString()); // // Graphics gfx = Graphics.FromHwnd(IntPtr.Zero); // IntPtr hdc = gfx.GetHdc(); // IntPtr oldFont = SelectObject(hdc, hfont); // int size = GetFontData(hdc, 0, 0, null, 0); // // byte[] fontbits = new byte[size]; // int xx = GetFontData(hdc, 0, 0, fontbits, size); // SelectObject(hdc, oldFont); // DeleteObject(hfont); // gfx.ReleaseHdc(hdc); // // FontData image = new FontData(fontbits); // //image.Read(); // // // //HandleRef // // font.GetType(); }
public HorizontalHeaderTable(FontData fontData) : base(fontData, Tag) { Read(); }
public OS2Table(FontData fontData) : base(fontData, Tag) { Read(); }
public GlyphDataTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.Glyf; Read(); }
public GenericFontTable(FontData fontData, string tag) : base(fontData, tag) { this.fontData = fontData; }
/// <summary> /// Initializes a new instance of the <see cref="CMapTable"/> class. /// </summary> public CMapTable(FontData fontData) : base(fontData, Tag) { Read(); }
/// <summary> /// Creates a new font image that is a subset of this font image containing only the specified glyphs. /// </summary> public FontData CreateFontSubSet(Dictionary <int, object> glyphs, bool cidFont) { // Create new font image FontData fontData = new FontData(this); // Create new loca and glyf table IndexToLocationTable loca = new IndexToLocationTable(); loca.ShortIndex = this.loca.ShortIndex; GlyphDataTable glyf = new GlyphDataTable(); // Add all required tables //fontData.AddTable(this.os2); if (!cidFont) { fontData.AddTable(this.cmap); } if (this.cvt != null) { fontData.AddTable(this.cvt); } if (this.fpgm != null) { fontData.AddTable(this.fpgm); } fontData.AddTable(glyf); fontData.AddTable(this.head); fontData.AddTable(this.hhea); fontData.AddTable(this.hmtx); fontData.AddTable(loca); if (this.maxp != null) { fontData.AddTable(this.maxp); } //fontData.AddTable(this.name); if (this.prep != null) { fontData.AddTable(this.prep); } // Get closure of used glyphs this.glyf.CompleteGlyphClosure(glyphs); // Create a sorted array of all used glyphs int glyphCount = glyphs.Count; int[] glyphArray = new int[glyphCount]; glyphs.Keys.CopyTo(glyphArray, 0); Array.Sort <int>(glyphArray); // Calculate new size of glyph table. int size = 0; for (int idx = 0; idx < glyphCount; idx++) { size += this.glyf.GetGlyphSize(glyphArray[idx]); } glyf.DirectoryEntry.Length = size; // Create new loca table int numGlyphs = this.maxp.numGlyphs; loca.locaTable = new int[numGlyphs + 1]; // Create new glyf table glyf.glyphTable = new byte[glyf.DirectoryEntry.PaddedLength]; // Fill new glyf and loca table int glyphOffset = 0; int glyphIndex = 0; for (int idx = 0; idx < numGlyphs; idx++) { loca.locaTable[idx] = glyphOffset; if (glyphIndex < glyphCount && glyphArray[glyphIndex] == idx) { glyphIndex++; byte[] bytes = this.glyf.GetGlyphData(idx); int length = bytes.Length; if (length > 0) { Buffer.BlockCopy(bytes, 0, glyf.glyphTable, glyphOffset, length); glyphOffset += length; } } } loca.locaTable[numGlyphs] = glyphOffset; // Compile font tables into byte array fontData.Compile(); return(fontData); }
public GenericFontTable(FontData fontData, string tag) : base(fontData, tag) { this.fontData = fontData; }
public MaximumProfileTable(FontData fontData) : base(fontData, Tag) { Read(); }
public ushort[] glyphIdArray; // Glyph index array (arbitrary length) public CMap4(FontData fontData, WinEncodingId encodingId) : base(fontData, "----") { this.encodingId = encodingId; Read(); }
public NameTable(FontData fontData) : base(fontData, Tag) { Read(); }
public IndexToLocationTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry = this.fontData.tableDictionary[TableTagNames.Loca]; Read(); }
public HorizontalMetricsTable(FontData fontData) : base(fontData, Tag) { Read(); }
public short glyphDataFormat; // 0 for current format public FontHeaderTable(FontData fontData) : base(fontData, Tag) { Read(); }
public IndexToLocationTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry = this.fontData.tableDictionary[TableTagNames.Loca]; Read(); }
public GlyphDataTable(FontData fontData) : base(fontData, Tag) { DirectoryEntry.Tag = TableTagNames.Glyf; Read(); }
public PostScriptTable(FontData fontData) : base(fontData, Tag) { Read(); }
public FontData(FontData fontData) { this.offsetTable = fontData.offsetTable; }
/// <summary> /// Creates a new font image that is a subset of this font image containing only the specified glyphs. /// </summary> public FontData CreateFontSubSet(Dictionary<int, object> glyphs, bool cidFont) { // Create new font image FontData fontData = new FontData(this); // Create new loca and glyf table IndexToLocationTable loca = new IndexToLocationTable(); loca.ShortIndex = this.loca.ShortIndex; GlyphDataTable glyf = new GlyphDataTable(); // Add all required tables //fontData.AddTable(this.os2); if (!cidFont) fontData.AddTable(this.cmap); if (this.cvt != null) fontData.AddTable(this.cvt); if (this.fpgm != null) fontData.AddTable(this.fpgm); fontData.AddTable(glyf); fontData.AddTable(this.head); fontData.AddTable(this.hhea); fontData.AddTable(this.hmtx); fontData.AddTable(loca); if (this.maxp != null) fontData.AddTable(this.maxp); //fontData.AddTable(this.name); if (this.prep != null) fontData.AddTable(this.prep); // Get closure of used glyphs this.glyf.CompleteGlyphClosure(glyphs); // Create a sorted array of all used glyphs int glyphCount = glyphs.Count; int[] glyphArray = new int[glyphCount]; glyphs.Keys.CopyTo(glyphArray, 0); Array.Sort<int>(glyphArray); // Calculate new size of glyph table. int size = 0; for (int idx = 0; idx < glyphCount; idx++) size += this.glyf.GetGlyphSize(glyphArray[idx]); glyf.DirectoryEntry.Length = size; // Create new loca table int numGlyphs = this.maxp.numGlyphs; loca.locaTable = new int[numGlyphs + 1]; // Create new glyf table glyf.glyphTable = new byte[glyf.DirectoryEntry.PaddedLength]; // Fill new glyf and loca table int glyphOffset = 0; int glyphIndex = 0; for (int idx = 0; idx < numGlyphs; idx++) { loca.locaTable[idx] = glyphOffset; if (glyphIndex < glyphCount && glyphArray[glyphIndex] == idx) { glyphIndex++; byte[] bytes = this.glyf.GetGlyphData(idx); int length = bytes.Length; if (length > 0) { Buffer.BlockCopy(bytes, 0, glyf.glyphTable, glyphOffset, length); glyphOffset += length; } } } loca.locaTable[numGlyphs] = glyphOffset; // Compile font tables into byte array fontData.Compile(); return fontData; }
public IRefFontTable(FontData fontData, TrueTypeFontTable fontTable) : base(null, fontTable.DirectoryEntry.Tag) { this.fontData = fontData; this.irefDirectoryEntry = fontTable.DirectoryEntry; }
public FontData(FontData fontData) { this.offsetTable = fontData.offsetTable; }