Example #1
0
        /// <summary>
        /// Adds the specified table to this font image.
        /// </summary>
        public void AddTable(OpenTypeFontTable fontTable)
        {
            if (!CanWrite)
            {
                throw new InvalidOperationException("Font image cannot be modified.");
            }

            if (fontTable == null)
            {
                throw new ArgumentNullException("fontTable");
            }

            if (fontTable._fontData == null)
            {
                fontTable._fontData = this;
            }
            else
            {
                Debug.Assert(fontTable._fontData.CanRead);
                // Create a reference to this font table
                fontTable = new IRefFontTable(this, fontTable);
            }

            //Debug.Assert(fontTable.FontData == null);
            //fontTable.fontData = this;

            TableDictionary[fontTable.DirectoryEntry.Tag] = fontTable.DirectoryEntry;
            switch (fontTable.DirectoryEntry.Tag)
            {
            case TableTagNames.CMap:
                cmap = fontTable as CMapTable;
                break;

            case TableTagNames.Cvt:
                cvt = fontTable as ControlValueTable;
                break;

            case TableTagNames.Fpgm:
                fpgm = fontTable as FontProgram;
                break;

            case TableTagNames.MaxP:
                maxp = fontTable as MaximumProfileTable;
                break;

            case TableTagNames.Name:
                name = fontTable as NameTable;
                break;

            case TableTagNames.Head:
                head = fontTable as FontHeaderTable;
                break;

            case TableTagNames.HHea:
                hhea = fontTable as HorizontalHeaderTable;
                break;

            case TableTagNames.HMtx:
                hmtx = fontTable as HorizontalMetricsTable;
                break;

            case TableTagNames.OS2:
                os2 = fontTable as OS2Table;
                break;

            case TableTagNames.Post:
                post = fontTable as PostScriptTable;
                break;

            case TableTagNames.Glyf:
                glyf = fontTable as GlyphDataTable;
                break;

            case TableTagNames.Loca:
                loca = fontTable as IndexToLocationTable;
                break;

            case TableTagNames.GSUB:
                gsub = fontTable as GlyphSubstitutionTable;
                break;

            case TableTagNames.Prep:
                prep = fontTable as ControlValueProgram;
                break;
            }
        }
Example #2
0
    /// <summary>
    /// Adds the specified table to this font image.
    /// </summary>
    public void AddTable(OpenTypeFontTable fontTable)
    {
      if (!CanWrite)
        throw new InvalidOperationException("Font image cannot be modified.");

      if (fontTable == null)
        throw new ArgumentNullException("fontTable");

      if (fontTable.fontData == null)
      {
        fontTable.fontData = this;
      }
      else
      {
        Debug.Assert(fontTable.fontData.CanRead);
        // Create a reference to this font table
        fontTable = new IRefFontTable(this, fontTable);
      }

      //Debug.Assert(fontTable.FontData == null);
      //fontTable.fontData = this;

      this.tableDictionary[fontTable.DirectoryEntry.Tag] = fontTable.DirectoryEntry;
      switch (fontTable.DirectoryEntry.Tag)
      {
        case TableTagNames.CMap:
          this.cmap = fontTable as CMapTable;
          break;

        case TableTagNames.Cvt:
          this.cvt = fontTable as ControlValueTable;
          break;

        case TableTagNames.Fpgm:
          this.fpgm = fontTable as FontProgram;
          break;

        case TableTagNames.MaxP:
          this.maxp = fontTable as MaximumProfileTable;
          break;

        case TableTagNames.Name:
          this.name = fontTable as NameTable;
          break;

        case TableTagNames.Head:
          this.head = fontTable as FontHeaderTable;
          break;

        case TableTagNames.HHea:
          this.hhea = fontTable as HorizontalHeaderTable;
          break;

        case TableTagNames.HMtx:
          this.hmtx = fontTable as HorizontalMetricsTable;
          break;

        case TableTagNames.OS2:
          this.os2 = fontTable as OS2Table;
          break;

        case TableTagNames.Post:
          this.post = fontTable as PostScriptTable;
          break;

        case TableTagNames.Glyf:
          this.glyf = fontTable as GlyphDataTable;
          break;

        case TableTagNames.Loca:
          this.loca = fontTable as IndexToLocationTable;
          break;

        case TableTagNames.GSUB:
          this.gsub = fontTable as GlyphSubstitutionTable;
          break;

        case TableTagNames.Prep:
          this.prep = fontTable as ControlValueProgram;
          break;
      }
    }