public GlyphSubstitutionTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry.Tag = TableTagNames.GSUB;
     DirectoryEntry     = fontData.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(OpenTypeFontface fontData)
            : base(fontData, Tag)
        {
            DirectoryEntry.Tag = TableTagNames.Prep;
            DirectoryEntry     = fontData.TableDictionary[TableTagNames.Prep];
            Read();
        }
 public void Read(OpenTypeFontface fontData)
 {
     Tag      = fontData.ReadTag();
     CheckSum = fontData.ReadULong();
     Offset   = fontData.ReadLong();
     Length   = (int)fontData.ReadULong();
 }
        byte[] bytes; // Instructions. n is the number of BYTE items that fit in the size of the table.

        public FontProgram(OpenTypeFontface fontData)
            : base(fontData, Tag)
        {
            DirectoryEntry.Tag = TableTagNames.Fpgm;
            DirectoryEntry     = fontData.TableDictionary[TableTagNames.Fpgm];
            Read();
        }
예제 #5
0
 /// <summary>
 /// Tries to get fontface by its check sum.
 /// </summary>
 public static bool TryGetFontface(ulong checkSum, out OpenTypeFontface fontface)
 {
     try
     {
         Lock.EnterFontFactory();
         bool result = Singleton._fontfacesByCheckSum.TryGetValue(checkSum, out fontface);
         return(result);
     }
     finally { Lock.ExitFontFactory(); }
 }
예제 #6
0
        /// <summary>
        /// Creates and reads a TableDirectoryEntry from the font image.
        /// </summary>
        public static TableDirectoryEntry ReadFrom(OpenTypeFontface fontData)
        {
            TableDirectoryEntry entry = new TableDirectoryEntry();

            entry.Tag      = fontData.ReadTag();
            entry.CheckSum = fontData.ReadULong();
            entry.Offset   = fontData.ReadLong();
            entry.Length   = (int)fontData.ReadULong();
            return(entry);
        }
예제 #7
0
 /// <summary>
 /// Tries to get fontface by its key.
 /// </summary>
 public static bool TryGetFontface(string key, out OpenTypeFontface fontface)
 {
     try
     {
         Lock.EnterFontFactory();
         bool result = Singleton._fontfaceCache.TryGetValue(key, out fontface);
         return(result);
     }
     finally { Lock.ExitFontFactory(); }
 }
 public OpenTypeFontTable(OpenTypeFontface fontData, string tag)
 {
     _fontData = fontData;
     if (fontData != null && fontData.TableDictionary.ContainsKey(tag))
     {
         DirectoryEntry = fontData.TableDictionary[tag];
     }
     else
     {
         DirectoryEntry = new TableDirectoryEntry(tag);
     }
     DirectoryEntry.FontTable = this;
 }
예제 #9
0
 public static OpenTypeFontface AddFontface(OpenTypeFontface fontface)
 {
     try
     {
         Lock.EnterFontFactory();
         OpenTypeFontface fontfaceCheck;
         if (TryGetFontface(fontface.FullFaceName, out fontfaceCheck))
         {
             if (fontfaceCheck.CheckSum != fontface.CheckSum)
             {
                 throw new InvalidOperationException("OpenTypeFontface with same signature but different bytes.");
             }
             return(fontfaceCheck);
         }
         Singleton._fontfaceCache.Add(fontface.FullFaceName, fontface);
         Singleton._fontfacesByCheckSum.Add(fontface.CheckSum, fontface);
         return(fontface);
     }
     finally { Lock.ExitFontFactory(); }
 }
 public VerticalMetricsTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
     throw new NotImplementedException("VerticalMetricsTable");
 }
예제 #11
0
        // Implementation Notes
        // OpenTypeFontface represents a 'decompiled' font file in memory.
        //
        // * An OpenTypeFontface can belong to more than one
        //   XGlyphTypeface because of StyleSimulations.
        //
        // * Currently there is a one to one relationship to XFontSource.
        //
        // * Consider OpenTypeFontface as an decompiled XFontSource.
        //
        // http://www.microsoft.com/typography/otspec/

        /// <summary>
        /// Shallow copy for font subset.
        /// </summary>
        OpenTypeFontface(OpenTypeFontface fontface)
        {
            _offsetTable  = fontface._offsetTable;
            _fullFaceName = fontface._fullFaceName;
        }
예제 #12
0
        /// <summary>
        /// Creates a new font image that is a subset of this font image containing only the specified glyphs.
        /// </summary>
        public OpenTypeFontface CreateFontSubSet(Dictionary <int, object> glyphs, bool cidFont)
        {
            // Create new font image
            OpenTypeFontface fontData = new OpenTypeFontface(this);

            // Create new loca and glyf table
            IndexToLocationTable locaNew = new IndexToLocationTable();

            locaNew.ShortIndex = loca.ShortIndex;
            GlyphDataTable glyfNew = new GlyphDataTable();

            // Add all required tables
            //fontData.AddTable(os2);
            if (!cidFont)
            {
                fontData.AddTable(cmap);
            }
            if (cvt != null)
            {
                fontData.AddTable(cvt);
            }
            if (fpgm != null)
            {
                fontData.AddTable(fpgm);
            }
            fontData.AddTable(glyfNew);
            fontData.AddTable(head);
            fontData.AddTable(hhea);
            fontData.AddTable(hmtx);
            fontData.AddTable(locaNew);
            if (maxp != null)
            {
                fontData.AddTable(maxp);
            }
            //fontData.AddTable(name);
            if (prep != null)
            {
                fontData.AddTable(prep);
            }

            // Get closure of used glyphs.
            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(glyphArray);

            // Calculate new size of glyph table.
            int size = 0;

            for (int idx = 0; idx < glyphCount; idx++)
            {
                size += glyf.GetGlyphSize(glyphArray[idx]);
            }
            glyfNew.DirectoryEntry.Length = size;

            // Create new loca table
            int numGlyphs = maxp.numGlyphs;

            locaNew.LocaTable = new int[numGlyphs + 1];

            // Create new glyf table
            glyfNew.GlyphTable = new byte[glyfNew.DirectoryEntry.PaddedLength];

            // Fill new glyf and loca table
            int glyphOffset = 0;
            int glyphIndex  = 0;

            for (int idx = 0; idx < numGlyphs; idx++)
            {
                locaNew.LocaTable[idx] = glyphOffset;
                if (glyphIndex < glyphCount && glyphArray[glyphIndex] == idx)
                {
                    glyphIndex++;
                    byte[] bytes  = glyf.GetGlyphData(idx);
                    int    length = bytes.Length;
                    if (length > 0)
                    {
                        Buffer.BlockCopy(bytes, 0, glyfNew.GlyphTable, glyphOffset, length);
                        glyphOffset += length;
                    }
                }
            }
            locaNew.LocaTable[numGlyphs] = glyphOffset;

            // Compile font tables into byte array
            fontData.Compile();

            return(fontData);
        }
 public PostScriptTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 public HorizontalHeaderTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 /// <summary>
 /// New...
 /// </summary>
 public OpenTypeDescriptor(string fontDescriptorKey, string name, XFontStyle stlye, OpenTypeFontface fontface, XPdfFontOptions options)
     : base(fontDescriptorKey)
 {
     FontFace = fontface;
     FontName = name;
     Initialize();
 }
 public VerticalMetrics(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 public VerticalHeaderTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 public HorizontalMetricsTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 public GlyphDataTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry.Tag = TableTagNames.Glyf;
     Read();
 }
 public MaximumProfileTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
예제 #21
0
 public IndexToLocationTable(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     DirectoryEntry = _fontData.TableDictionary[TableTagNames.Loca];
     Read();
 }
        public ushort[] glyphIdArray;    // Glyph index array (arbitrary length)

        public CMap4(OpenTypeFontface fontData, WinEncodingId encodingId)
            : base(fontData, "----")
        {
            this.encodingId = encodingId;
            Read();
        }
 public OS2Table(OpenTypeFontface fontData)
     : base(fontData, Tag)
 {
     Read();
 }
 public IRefFontTable(OpenTypeFontface fontData, OpenTypeFontTable fontTable)
     : base(null, fontTable.DirectoryEntry.Tag)
 {
     _fontData           = fontData;
     _irefDirectoryEntry = fontTable.DirectoryEntry;
 }