///// <summary> ///// Initializes a new instance of the <see cref="TrueTypeFontTable"/> class. ///// </summary> //public TrueTypeFontTable(FontImage fontImage) //{ // this.fontImage = fontImage; //} public TrueTypeFontTable(FontImage fontImage, string tag) { this.fontImage = fontImage; if (fontImage != null && fontImage.tableDictionary.ContainsKey(tag)) this.DirectoryEntry = fontImage.tableDictionary[tag]; else this.DirectoryEntry = new TableDirectoryEntry(tag); this.DirectoryEntry.FontTable = this; }
public static void Test() { Font font = new Font("Times", 10); FontImage image = new FontImage(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); // // FontImage image = new FontImage(fontbits); // //image.Read(); // // // //HandleRef // // font.GetType(); }
public ushort[] glyphIdArray; // Glyph index array (arbitrary length) public CMap4(FontImage fontImage, WinEncodingId encodingId) : base(fontImage, "----") { this.encodingId = encodingId; Read(); }
public GlyphSubstitutionTable(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry.Tag = TableTagNames.GSUB; DirectoryEntry = fontImage.tableDictionary[TableTagNames.GSUB]; Read(); }
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(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry.Tag = TableTagNames.Prep; DirectoryEntry = fontImage.tableDictionary[TableTagNames.Prep]; Read(); }
/// <summary> /// Initializes a new instance of the <see cref="CMapTable"/> class. /// </summary> public CMapTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public GenericFontTable(FontImage fontImage, string tag) : base(fontImage, tag) { this.fontImage = fontImage; }
/// <summary> /// Creates a new font image that is a subset of this font image containing only the specified glyphs. /// </summary> public FontImage CreateFontSubSet(Dictionary<int, object> glyphs, bool cidFont) { // Create new font image FontImage fontImage = new FontImage(this); // Create new loca and glyf table IndexToLocationTable loca = new IndexToLocationTable(); loca.ShortIndex = this.loca.ShortIndex; GlyphDataTable glyf = new GlyphDataTable(); // Add all required tables //fontImage.AddTable(this.os2); if (!cidFont) fontImage.AddTable(this.cmap); if (this.cvt != null) fontImage.AddTable(this.cvt); if (this.fpgm != null) fontImage.AddTable(this.fpgm); fontImage.AddTable(glyf); fontImage.AddTable(this.head); fontImage.AddTable(this.hhea); fontImage.AddTable(this.hmtx); fontImage.AddTable(loca); if (this.maxp != null) fontImage.AddTable(this.maxp); //fontImage.AddTable(this.name); if (this.prep != null) fontImage.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 fontImage.Compile(); return fontImage; }
public OS2Table(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public NameTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public MaximumProfileTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public HorizontalMetricsTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public HorizontalHeaderTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public short glyphDataFormat; // 0 for current format public FontHeaderTable(FontImage fontImage) : base(fontImage, Tag) { Read(); }
public IRefFontTable(FontImage fontImage, TrueTypeFontTable fontTable) : base(null, fontTable.DirectoryEntry.Tag) { this.fontImage = fontImage; this.irefDirectoryEntry = fontTable.DirectoryEntry; }
public PostScriptTable(FontImage fontImage) : base(fontImage, Tag) { 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(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry.Tag = TableTagNames.Cvt; DirectoryEntry = fontImage.tableDictionary[TableTagNames.Cvt]; Read(); }
public FontImage(FontImage fontImage) { this.offsetTable = fontImage.offsetTable; }
byte[] bytes; // Instructions. n is the number of BYTE items that fit in the size of the table. public FontProgram(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry.Tag = TableTagNames.Fpgm; DirectoryEntry = fontImage.tableDictionary[TableTagNames.Fpgm]; Read(); }
public GlyphDataTable(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry.Tag = TableTagNames.Glyf; Read(); }
public IndexToLocationTable(FontImage fontImage) : base(fontImage, Tag) { DirectoryEntry = this.fontImage.tableDictionary[TableTagNames.Loca]; Read(); }