⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t1load.c

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 C
📖 第 1 页 / 共 4 页
字号:
      error      = Next_T1_Token( parser, &token );      top        = parser->top;      dict_index = parser->state_index;      dict_state = parser->state_stack[ dict_index ];      switch ( token.kind )      {        /* A keyword was detected */        case tok_keyword:          switch (token.kind2)          {            case key_dict:              switch (dict_state)              {                case dict_none:                   /* All right, we're beggining the font dictionary    */                   /* check that we only have one number argument, then */                   /* consume the 'begin' and change to 'dict_font'     */                   /* state..                                           */                   error = Expect_Dict_Arguments( parser, 1, tok_error,                                                  dict_font, 0 );                   if (error) goto Exit;                                      /* clear stack from all the previous content. This   */                   /* could be some stupid Postscript code ...          */                   parser->top = parser->stack;                   break;                case dict_font:                   /* This must be the /FontInfo dictionary, so check */                   /* That we have at least two arguments, that they  */                   /* are "/FontInfo" and a number, then change the   */                   /* dictionary state..                              */                   error = Expect_Dict_Arguments( parser, 2, imm_FontInfo,                                                  dict_fontinfo, 0 );                   if (error) goto Exit;                   break;                case dict_none2:                   error = Expect_Dict_Arguments( parser, 2, imm_Private,                                                  dict_private, 0 );                   if (error) goto Exit;                   break;                case dict_private:                  {                    T1_Face  face = parser->face;                    T1_Int   count;                    error = Expect_Dict_Arguments( parser, 2, imm_CharStrings,                                                   dict_charstrings, &count );                    if (error) goto Exit;                    type1->num_glyphs = count;                    error = T1_New_Table( &parser->table, count*2, face->root.memory );                    if (error) goto Exit;                    /* record '.notdef' as the first glyph in the font */                    error = T1_Add_Table( &parser->table, 0, (T1_Byte*)".notdef", 8 );                    parser->cur_name = 1;                    /* XXXXX : DO SOMETHING HERE */                  }                  break;                default:                   /* All other uses are invalid */                   FT_ERROR(( "T1.Parse: invalid use of the 'dict' keyword\n" ));                   goto Syntax_Error;              }              break;            case key_array:              /* Are we in an array yet ? Is so, raise an error */              switch (dict_state)              {                case dict_encoding:   case dict_subrs:                case dict_othersubrs: case dict_charstrings:                case dict_unknown_array:                  FT_ERROR(( "T1.Parse.array: nested array definitions\n" ));                  goto Syntax_Error;                default:                  ;              }              error = Expect_Array_Arguments( parser );              if (error) goto Exit;              break;            case key_ND:            case key_NP:            case key_def:              /* Are we in an array ? If so, finalise it.. */              switch ( dict_state )              {                case dict_encoding:    /* finish encoding array */                  {                    /* copy table names to the face object */                    T1_Done_Table( &parser->table );                    parser->encoding_names   = parser->table.block;                    parser->encoding_lengths = parser->table.lengths;                    parser->encoding_offsets = parser->table.elements;                    parser->state_index--;                  }                  break;                case dict_subrs:                  {                    /* copy recorder sub-routines */                    T1_Done_Table( &parser->table );                    parser->subrs    = parser->table.block;                    type1->subrs     = parser->table.elements;                    type1->subrs_len = parser->table.lengths;                    parser->state_index--;                  }                  break;                case dict_charstrings:                case dict_othersubrs:                case dict_unknown_array:                  FT_ERROR(( "T1.Parser.def: unsupported array\n" ));                  goto Syntax_Error;                  break;                default:   /* normal 'def' processing */                  {                    /* Check that we have sufficient operands in the stack */                    if ( top >= parser->stack+2 )                    {                      /* Now check that the first operand is an immediate */                      /* If so, call the appropriate "def" routine based  */                      /* on the current parser state..                    */                      if ( top[-2].kind == tok_immediate )                      {                        parser->top -= 2;						parser->args = parser->top + 1;                        error = def_funcs[dict_state](parser);                      }                      else                      {                        /* This is an error, but some fonts contain some */                        /* stupid Postscript code. We simply ignore      */                        /* an invalid 'def' by clearing the stack        */#if 0                        FT_ERROR(( "T1.Parse.def: immediate expected\n" ));                        goto Syntax_Error;#else                        parser->top = parser->stack;#endif                      }                    }                    else                    {                      FT_ERROR(( "T1.Parse.def: not enough arguments\n" ));                      goto Stack_Underflow;                    }                  }              }              break;            case key_index:              if ( top <= parser->stack )              {                FT_ERROR(( "T1.Parse.index: not enough arguments\n" ));                goto Stack_Underflow;              }              /* simply ignore ?? */              parser->top --;              break;            case key_put:              /* Check that we have sufficient operands in stack */              if ( top < parser->stack+2 )              {                FT_ERROR(( "T1.Parse.put: not enough arguments\n" ));                goto Stack_Underflow;              }              parser->top -= 2;			  parser->args = parser->top;              switch (dict_state)              {                case dict_encoding:                  error = Do_Put_Encoding( parser );                  if (error) goto Exit;                  break;                case dict_unknown_array:   /* ignore the put */                  break;                default:#if 0                  FT_ERROR(( "T1.Parse.put: invalid context\n" ));                  goto Syntax_Error;#else                  /* invalid context, simply ignore the put and */                  /* clear the stack (stupid Postscript code..) */                  FT_TRACE4(( "T1.Parse.put: invalid context. ignored.\n" ));                  parser->top = parser->stack;#endif              }              break;            case key_RD:              /* Check that we have sufficient operands in stack */              if ( top < parser->stack+2 )              {                FT_ERROR(( "T1.Parse.RD: not enough arguments\n" ));                goto Stack_Underflow;              }              parser->top -= 2;			  parser->args = parser->top;              switch (dict_state)              {                case dict_subrs:                  error = Do_RD_Subrs( parser );                  if (error) goto Exit;                  break;                case dict_charstrings:                  error = Do_RD_Charstrings( parser );                  if (error) goto Exit;                  break;                default:                  FT_ERROR(( "T1.Parse.RD: invalid context\n" ));                  goto Syntax_Error;              }              break;            case key_end:              /* Were we in a dictionary or in an array ? */              if ( dict_index <= 0 )              {                FT_ERROR(( "T1.Parse.end: no dictionary defined\n" ));                goto Syntax_Error;              }              switch (dict_state)              {                /* Jump to the private dictionary if we're closing the */                /* /Font dictionary..                                  */                case dict_font:                  goto Open_Private;                /* Exit the parser when closing the CharStrings dictionary */                case dict_charstrings:                  return Finalise_Parsing( parser );                default:                  /* Pop the current dictionary state and return to previous */                  /* one. Consume the "def"..                                */                  /* Because some buggy fonts (BitStream) have incorrect     */                  /* syntax, we never escape from the private dictionary     */                  if (dict_state != dict_private)                    parser->state_index--;                                 /* many fonts use a NP instead of def or put, so */                  /* we simply ignore the nest token..             */#if 0                  error = Expect_Keyword2( parser, key_def, key_put );                  if (error) goto Exit;#else                  (void)Expect_Keyword2( parser, key_def, key_put );#endif              }              break;            case key_for:              /* check that we have four arguments, and simply */              /* ignore them..                                 */              if ( top - parser->stack < 4 )              {                FT_ERROR(( "T1.Parse.for: not enough arguments\n" ));                goto Stack_Underflow;              }              parser->top -= 4;              break;            case key_currentdict:          Open_Private:               parser->state_index    = 0;               parser->state_stack[0] = dict_none2;               error = Open_PrivateDict( parser->tokenizer );               if (error) goto Exit;               break;            case key_true:            case key_false:			case key_StandardEncoding:			case key_ExpertEncoding:              goto Push_Element;            default:			  FT_ERROR(( "T1.Parser: invalid keyword in context\n" ));              error = T1_Err_Syntax_Error;          }          break;        /* A number was detected */        case tok_string:        case tok_program:        case tok_immediate:        case tok_array:        case tok_hexarray:        case tok_any:        case tok_number:                        /* push number on stack */     Push_Element:          if ( top >= parser->limit )          {            error = T1_Err_Stack_Overflow;            goto Exit;          }          else            *parser->top++ = token;          break;        /* anything else is an error per se the spec, but we     */        /* frequently encountre stupid postscript code in fonts, */        /* so just ignore them..                                 */        default:          error = T1_Err_Ok;  /* ignore token */      }      if (error)        return error;    }  Exit:    return error;  Syntax_Error:    return T1_Err_Syntax_Error;  Stack_Underflow:    return T1_Err_Stack_Underflow;  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -