cff.cxx (4f60319c) | cff.cxx (25e830b3) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 144 unchanged lines hidden (view full) --- 153#if 0 // TODO: use them 154static const char* pStdEncNames[] = { 155 "ISOAdobe", "Expert", "ExpertSubSet" 156}; 157#endif 158 159// -------------------------------------------------------------------- 160 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 144 unchanged lines hidden (view full) --- 153#if 0 // TODO: use them 154static const char* pStdEncNames[] = { 155 "ISOAdobe", "Expert", "ExpertSubSet" 156}; 157#endif 158 159// -------------------------------------------------------------------- 160 |
161// TOP DICT keywords (also covers PRIV DICT keywords) | 161/** TOP DICT keywords (also covers PRIV DICT keywords) 162 * 163 * Refer to the CFF Specification, tables 9 and 23. 164 * 165 * This array is indexed by operand. 166 * 167 * The first character tells the type of operand ('s': SID, 'b': boolean etc.). 168 */ |
162static const char* pDictOps[] = { 163 "sVersion", "sNotice", "sFullName", "sFamilyName", 164 "sWeight", "aFontBBox", "dBlueValues", "dOtherBlues", 165 "dFamilyBlues", "dFamilyOtherBlues", "nStdHW", "nStdVW", 166 "xESC", "nUniqueID", "aXUID", "nCharset", 167 "nEncoding", "nCharStrings", "PPrivate", "nSubrs", 168 "nDefaultWidthX", "nNominalWidthX", NULL, NULL, 169 NULL, NULL, NULL, NULL, 170 "shortint", "longint", "BCD", NULL 171}; 172 173// -------------------------------------------------------------------- 174 | 169static const char* pDictOps[] = { 170 "sVersion", "sNotice", "sFullName", "sFamilyName", 171 "sWeight", "aFontBBox", "dBlueValues", "dOtherBlues", 172 "dFamilyBlues", "dFamilyOtherBlues", "nStdHW", "nStdVW", 173 "xESC", "nUniqueID", "aXUID", "nCharset", 174 "nEncoding", "nCharStrings", "PPrivate", "nSubrs", 175 "nDefaultWidthX", "nNominalWidthX", NULL, NULL, 176 NULL, NULL, NULL, NULL, 177 "shortint", "longint", "BCD", NULL 178}; 179 180// -------------------------------------------------------------------- 181 |
175// TOP DICT escapes (also covers PRIV DICT escapes) | 182/** TOP DICT escapes (also covers PRIV DICT escapes) 183 * 184 * Refer to the CFF Specification, tables 9 and 23. 185 * 186 * These operators come after the escape operator (no. 12). 187 * 188 * This array is indexed by operand. 189 * 190 * The first character tells the type of operand ('s': SID, 'b': boolean etc.). 191 */ |
176static const char* pDictEscs[] = { 177 "sCopyright", "bIsFixedPitch", "nItalicAngle", "nUnderlinePosition", 178 "nUnderlineThickness", "nPaintType", "tCharstringType", "aFontMatrix", 179 "nStrokeWidth", "nBlueScale", "nBlueShift", "nBlueFuzz", 180 "dStemSnapH", "dStemSnapV", "bForceBold", NULL, 181 NULL, "nLanguageGroup", "nExpansionFactor", "nInitialRandomSeed", 182 "nSyntheticBase", "sPostScript", "sBaseFontName", "dBaseFontBlend", 183 NULL, NULL, NULL, NULL, --- 101 unchanged lines hidden (view full) --- 285 IFELSE=22, RANDOM=23, MUL=24, SQRT=26, 286 DUP=27, EXCH=28, INDEX=29, ROLL=30, 287 HFLEX=34, FLEX=35, HFLEX1=36, FLEX1=37 288 }; 289}; 290 291// ==================================================================== 292 | 192static const char* pDictEscs[] = { 193 "sCopyright", "bIsFixedPitch", "nItalicAngle", "nUnderlinePosition", 194 "nUnderlineThickness", "nPaintType", "tCharstringType", "aFontMatrix", 195 "nStrokeWidth", "nBlueScale", "nBlueShift", "nBlueFuzz", 196 "dStemSnapH", "dStemSnapV", "bForceBold", NULL, 197 NULL, "nLanguageGroup", "nExpansionFactor", "nInitialRandomSeed", 198 "nSyntheticBase", "sPostScript", "sBaseFontName", "dBaseFontBlend", 199 NULL, NULL, NULL, NULL, --- 101 unchanged lines hidden (view full) --- 301 IFELSE=22, RANDOM=23, MUL=24, SQRT=26, 302 DUP=27, EXCH=28, INDEX=29, ROLL=30, 303 HFLEX=34, FLEX=35, HFLEX1=36, FLEX1=37 304 }; 305}; 306 307// ==================================================================== 308 |
309/** Data layout of a CFF FontSet 310 * 311 * Refer to the CFF specification, chapter 2 312 */ |
|
293struct CffGlobal 294{ 295 explicit CffGlobal(); 296 | 313struct CffGlobal 314{ 315 explicit CffGlobal(); 316 |
317 // Offset of the Name INDEX inside the CFF data |
|
297 int mnNameIdxBase; | 318 int mnNameIdxBase; |
319 // Number of objects stored in the Name INDEX |
|
298 int mnNameIdxCount; 299 int mnStringIdxBase; 300 int mnStringIdxCount; 301 bool mbCIDFont; 302 int mnCharStrBase; 303 int mnCharStrCount; 304 int mnEncodingBase; 305 int mnCharsetBase; --- 42 unchanged lines hidden (view full) --- 348 RealType mfBlueFuzz; 349 RealType mfExpFactor; 350 int mnLangGroup; 351 bool mbForceBold; 352}; 353 354// ==================================================================== 355 | 320 int mnNameIdxCount; 321 int mnStringIdxBase; 322 int mnStringIdxCount; 323 bool mbCIDFont; 324 int mnCharStrBase; 325 int mnCharStrCount; 326 int mnEncodingBase; 327 int mnCharsetBase; --- 42 unchanged lines hidden (view full) --- 370 RealType mfBlueFuzz; 371 RealType mfExpFactor; 372 int mnLangGroup; 373 bool mbForceBold; 374}; 375 376// ==================================================================== 377 |
356class SubsetterContext 357{ 358public: 359 virtual ~SubsetterContext( void); 360 virtual bool emitAsType1( class Type1Emitter&, 361 const sal_GlyphId* pGlyphIds, const U8* pEncoding, 362 GlyphWidth* pGlyphWidths, int nGlyphCount, FontSubsetInfo& ) = 0; 363}; 364 365// -------------------------------------------------------------------- 366 367SubsetterContext::~SubsetterContext( void) 368{} 369 370// ==================================================================== 371 | |
372class CffSubsetterContext | 378class CffSubsetterContext |
373: public SubsetterContext 374, private CffGlobal | 379: private CffGlobal |
375{ 376public: | 380{ 381public: |
377 static const int NMAXSTACK = 48; // see CFF.appendixB 378 static const int NMAXHINTS = 2*96; // see CFF.appendixB 379 static const int NMAXTRANS = 32; // see CFF.appendixB | 382 // Refer to Type 2 charstring format appendix B, "Type 2 Charstring Implementation Limits" 383 static const int NMAXSTACK = 48; // argument stack 384 static const int NMAXHINTS = 2*96; // number of stem hints (H/V total) 385 static const int NMAXTRANS = 32; // TransientArray elements |
380public: 381 explicit CffSubsetterContext( const U8* pBasePtr, int nBaseLen); 382 virtual ~CffSubsetterContext( void); 383 | 386public: 387 explicit CffSubsetterContext( const U8* pBasePtr, int nBaseLen); 388 virtual ~CffSubsetterContext( void); 389 |
390 // Begin parsing the CFF data |
|
384 void initialCffRead( void); 385 bool emitAsType1( class Type1Emitter&, 386 const sal_GlyphId* pGlyphIds, const U8* pEncoding, 387 GlyphWidth* pGlyphWidths, int nGlyphCount, FontSubsetInfo& ); 388 389 // used by charstring converter 390 void setCharStringType( int); 391 void fakeLocalSubrCount( int nLocalSubrs ) { maCffLocal[0].mnLocalSubrCount=nLocalSubrs;} 392protected: 393 int convert2Type1Ops( CffLocal*, const U8* pType2Ops, int nType2Len, U8* pType1Ops); 394private: 395 void convertOneTypeOp( void); 396 void convertOneTypeEsc( void); 397 void callType2Subr( bool bGlobal, int nSubrNumber); 398 long getReadOfs( void) const { return (long)(mpReadPtr - mpBasePtr);} 399 | 391 void initialCffRead( void); 392 bool emitAsType1( class Type1Emitter&, 393 const sal_GlyphId* pGlyphIds, const U8* pEncoding, 394 GlyphWidth* pGlyphWidths, int nGlyphCount, FontSubsetInfo& ); 395 396 // used by charstring converter 397 void setCharStringType( int); 398 void fakeLocalSubrCount( int nLocalSubrs ) { maCffLocal[0].mnLocalSubrCount=nLocalSubrs;} 399protected: 400 int convert2Type1Ops( CffLocal*, const U8* pType2Ops, int nType2Len, U8* pType1Ops); 401private: 402 void convertOneTypeOp( void); 403 void convertOneTypeEsc( void); 404 void callType2Subr( bool bGlobal, int nSubrNumber); 405 long getReadOfs( void) const { return (long)(mpReadPtr - mpBasePtr);} 406 |
407 // First byte of CFF font data |
|
400 const U8* mpBasePtr; | 408 const U8* mpBasePtr; |
409 // Last byte of CFF font data |
|
401 const U8* mpBaseEnd; 402 | 410 const U8* mpBaseEnd; 411 |
412 // Moving cursors inside CFF font data |
|
403 const U8* mpReadPtr; 404 const U8* mpReadEnd; 405 406 U8* mpWritePtr; 407 bool mbSawError; 408 bool mbNeedClose; 409 bool mbIgnoreHints; 410 long mnCntrMask; 411 412private: | 413 const U8* mpReadPtr; 414 const U8* mpReadEnd; 415 416 U8* mpWritePtr; 417 bool mbSawError; 418 bool mbNeedClose; 419 bool mbIgnoreHints; 420 long mnCntrMask; 421 422private: |
423 /** Prepare to access an element inside a CFF/CID index table 424 * 425 * nIndexBase: offset of the INDEX structure inside the CFF font data. 426 * nDataIndex: offset of the element inside the INDEX structure. 427 * 428 * Sets mpReadPtr to the beginning of the element and mpReadEnd to the end of the element. 429 * 430 * Returns the size of the element, or -1 if the data is not valid (e.g. indices are too big). 431 */ |
|
413 int seekIndexData( int nIndexBase, int nDataIndex); | 432 int seekIndexData( int nIndexBase, int nDataIndex); |
433 /** Seek to the end of an INDEX structure 434 * 435 * nIndexBase: offset of the INDEX structure inside the CFF font data. 436 * 437 * Sets mpReadPtr to the first byte after the indicated structure. 438 */ |
|
414 void seekIndexEnd( int nIndexBase); 415 416private: 417 const char** mpCharStringOps; 418 const char** mpCharStringEscs; 419 | 439 void seekIndexEnd( int nIndexBase); 440 441private: 442 const char** mpCharStringOps; 443 const char** mpCharStringEscs; 444 |
420 CffLocal maCffLocal[256]; | 445 std::vector<CffLocal> maCffLocal; |
421 CffLocal* mpCffLocal; 422 423 void readDictOp( void); 424 RealType readRealVal( void); 425 const char* getString( int nStringID); 426 int getFDSelect( int nGlyphIndex) const; 427 int getGlyphSID( int nGlyphIndex) const; 428 const char* getGlyphName( int nGlyphIndex); 429 | 446 CffLocal* mpCffLocal; 447 448 void readDictOp( void); 449 RealType readRealVal( void); 450 const char* getString( int nStringID); 451 int getFDSelect( int nGlyphIndex) const; 452 int getGlyphSID( int nGlyphIndex) const; 453 const char* getGlyphName( int nGlyphIndex); 454 |
455 /** Decode an integer DICT Data Operand and push it. 456 * 457 * Refer to the CFF Specification, table 3. 458 * 459 * Advances mpReadPtr. 460 */ |
|
430 void read2push( void); 431 void pop2write( void); 432 void writeType1Val( ValType); 433 void writeTypeOp( int nTypeOp); 434 void writeTypeEsc( int nTypeOp); 435 void writeCurveTo( int nStackPos, int nIX1, int nIY1, int nIX2, int nIY2, int nIX3, int nIY3); 436 void pop2MultiWrite( int nArgsPerTypo, int nTypeOp, int nTypeXor=0); 437 void popAll2Write( int nTypeOp); --- 22 unchanged lines hidden (view full) --- 460 bool hasCharWidth( void) const { return (maCharWidth > 0);} 461 ValType getCharWidth( void) const { return maCharWidth;} 462 void setNominalWidth( ValType aWidth) { mpCffLocal->maNominalWidth = aWidth;} 463 void setDefaultWidth( ValType aWidth) { mpCffLocal->maDefaultWidth = aWidth;} 464 void updateWidth( bool bUseFirstVal); 465 466private: 467 // typeop exceution context | 461 void read2push( void); 462 void pop2write( void); 463 void writeType1Val( ValType); 464 void writeTypeOp( int nTypeOp); 465 void writeTypeEsc( int nTypeOp); 466 void writeCurveTo( int nStackPos, int nIX1, int nIY1, int nIX2, int nIY2, int nIX3, int nIY3); 467 void pop2MultiWrite( int nArgsPerTypo, int nTypeOp, int nTypeXor=0); 468 void popAll2Write( int nTypeOp); --- 22 unchanged lines hidden (view full) --- 491 bool hasCharWidth( void) const { return (maCharWidth > 0);} 492 ValType getCharWidth( void) const { return maCharWidth;} 493 void setNominalWidth( ValType aWidth) { mpCffLocal->maNominalWidth = aWidth;} 494 void setDefaultWidth( ValType aWidth) { mpCffLocal->maDefaultWidth = aWidth;} 495 void updateWidth( bool bUseFirstVal); 496 497private: 498 // typeop exceution context |
499 500 // Count of mnValStack elements |
|
468 int mnStackIdx; | 501 int mnStackIdx; |
502 // Stack for holding CFF DICT operands |
|
469 ValType mnValStack[ NMAXSTACK+4]; | 503 ValType mnValStack[ NMAXSTACK+4]; |
504 // Transient array for Type 2 storage operators (PUT, GET) |
|
470 ValType mnTransVals[ NMAXTRANS]; 471 472 int mnHintSize; 473 int mnHorzHintSize; 474 ValType mnHintStack[ NMAXHINTS]; 475 476 ValType maCharWidth; 477}; --- 4 unchanged lines hidden (view full) --- 482: mpBasePtr( pBasePtr) 483, mpBaseEnd( pBasePtr+nBaseLen) 484, mnStackIdx(0) 485, mnHintSize(0) 486, mnHorzHintSize(0) 487, maCharWidth(-1) 488{ 489// setCharStringType( 1); | 505 ValType mnTransVals[ NMAXTRANS]; 506 507 int mnHintSize; 508 int mnHorzHintSize; 509 ValType mnHintStack[ NMAXHINTS]; 510 511 ValType maCharWidth; 512}; --- 4 unchanged lines hidden (view full) --- 517: mpBasePtr( pBasePtr) 518, mpBaseEnd( pBasePtr+nBaseLen) 519, mnStackIdx(0) 520, mnHintSize(0) 521, mnHorzHintSize(0) 522, maCharWidth(-1) 523{ 524// setCharStringType( 1); |
490 // TODO: new CffLocal[ mnFDAryCount]; | 525 maCffLocal.resize(1); |
491 mpCffLocal = &maCffLocal[0]; 492} 493 494// -------------------------------------------------------------------- 495 496CffSubsetterContext::~CffSubsetterContext( void) 497{ | 526 mpCffLocal = &maCffLocal[0]; 527} 528 529// -------------------------------------------------------------------- 530 531CffSubsetterContext::~CffSubsetterContext( void) 532{ |
498 // TODO: delete[] maCffLocal; | |
499} 500 501// -------------------------------------------------------------------- 502 503inline int CffSubsetterContext::popInt( void) 504{ 505 const ValType aVal = popVal(); 506 const int nInt = static_cast<int>(aVal); --- 94 unchanged lines hidden (view full) --- 601 case 1: mpCharStringOps=pType1Ops; mpCharStringEscs=pT1EscOps; break; 602 case 2: mpCharStringOps=pType2Ops; mpCharStringEscs=pT2EscOps; break; 603 default: fprintf( stderr, "Unknown CharstringType=%d\n",nVal); break; 604 } 605} 606 607// -------------------------------------------------------------------- 608 | 533} 534 535// -------------------------------------------------------------------- 536 537inline int CffSubsetterContext::popInt( void) 538{ 539 const ValType aVal = popVal(); 540 const int nInt = static_cast<int>(aVal); --- 94 unchanged lines hidden (view full) --- 635 case 1: mpCharStringOps=pType1Ops; mpCharStringEscs=pT1EscOps; break; 636 case 2: mpCharStringOps=pType2Ops; mpCharStringEscs=pT2EscOps; break; 637 default: fprintf( stderr, "Unknown CharstringType=%d\n",nVal); break; 638 } 639} 640 641// -------------------------------------------------------------------- 642 |
643/** Read DICT operator at mpReadPtr. 644 * 645 * Sets the attributes of CffSubsetterContext::mpCffLocal 646 */ |
|
609void CffSubsetterContext::readDictOp( void) 610{ 611 ValType nVal = 0; | 647void CffSubsetterContext::readDictOp( void) 648{ 649 ValType nVal = 0; |
612 int nInt = 0; | 650 int nInt = 0; |
613 const U8 c = *mpReadPtr; | 651 const U8 c = *mpReadPtr; |
614 if( c <= 21 ) { | 652 if( c <= 21 ) { // we are looking at an operator |
615 int nOpId = *(mpReadPtr++); 616 const char* pCmdName; 617 if( nOpId != 12) 618 pCmdName = pDictOps[ nOpId]; | 653 int nOpId = *(mpReadPtr++); 654 const char* pCmdName; 655 if( nOpId != 12) 656 pCmdName = pDictOps[ nOpId]; |
619 else { | 657 else { // escape: the operator is indicated in the following byte |
620 const U8 nExtId = *(mpReadPtr++); 621 pCmdName = pDictEscs[ nExtId]; 622 nOpId = 900 + nExtId; 623 } 624 625 //TODO: if( nStackIdx > 0) | 658 const U8 nExtId = *(mpReadPtr++); 659 pCmdName = pDictEscs[ nExtId]; 660 nOpId = 900 + nExtId; 661 } 662 663 //TODO: if( nStackIdx > 0) |
664 // The first byte of pCmdName indicates the type of operand |
|
626 switch( *pCmdName) { 627 default: fprintf( stderr, "unsupported DictOp.type=\'%c\'\n", *pCmdName); break; 628 case 'b': // bool 629 nInt = popInt(); 630 switch( nOpId) { 631 case 915: mpCffLocal->mbForceBold = nInt; break; // "ForceBold" 632 default: break; // TODO: handle more boolean dictops? 633 } --- 75 unchanged lines hidden (view full) --- 709 } break; 710 case 't': // CharstringType 711 nInt = popInt(); 712 setCharStringType( nInt ); 713 break; 714 } 715 716 return; | 665 switch( *pCmdName) { 666 default: fprintf( stderr, "unsupported DictOp.type=\'%c\'\n", *pCmdName); break; 667 case 'b': // bool 668 nInt = popInt(); 669 switch( nOpId) { 670 case 915: mpCffLocal->mbForceBold = nInt; break; // "ForceBold" 671 default: break; // TODO: handle more boolean dictops? 672 } --- 75 unchanged lines hidden (view full) --- 748 } break; 749 case 't': // CharstringType 750 nInt = popInt(); 751 setCharStringType( nInt ); 752 break; 753 } 754 755 return; |
717 } 718 719 if( (c >= 32) || (c == 28) ) { | 756 } else if( (c >= 32) || (c == 28) ) { |
720// --mpReadPtr; 721 read2push(); | 757// --mpReadPtr; 758 read2push(); |
722 } else if( c == 29 ) { // longint | 759 } else if( c == 29 ) { // we are looking at a 32-bit operand |
723 ++mpReadPtr; // skip 29 724 int nS32 = mpReadPtr[0] << 24; 725 nS32 += mpReadPtr[1] << 16; 726 nS32 += mpReadPtr[2] << 8; 727 nS32 += mpReadPtr[3] << 0; 728 if( (sizeof(nS32) != 4) && (nS32 & (1<<31))) 729 nS32 |= (~0U) << 31; // assuming 2s complement 730 mpReadPtr += 4; 731 nVal = static_cast<ValType>(nS32); 732 push( nVal ); | 760 ++mpReadPtr; // skip 29 761 int nS32 = mpReadPtr[0] << 24; 762 nS32 += mpReadPtr[1] << 16; 763 nS32 += mpReadPtr[2] << 8; 764 nS32 += mpReadPtr[3] << 0; 765 if( (sizeof(nS32) != 4) && (nS32 & (1<<31))) 766 nS32 |= (~0U) << 31; // assuming 2s complement 767 mpReadPtr += 4; 768 nVal = static_cast<ValType>(nS32); 769 push( nVal ); |
733 } else if( c == 30) { // real number | 770 } else if( c == 30) { // we are looking at a real number operand |
734 ++mpReadPtr; // skip 30 735 const RealType fReal = readRealVal(); 736 // push value onto stack 737 nVal = fReal; 738 push( nVal); 739 } 740} 741 742// -------------------------------------------------------------------- 743 744void CffSubsetterContext::read2push() 745{ 746 ValType aVal = 0; 747 748 const U8*& p = mpReadPtr; 749 const U8 c = *p; | 771 ++mpReadPtr; // skip 30 772 const RealType fReal = readRealVal(); 773 // push value onto stack 774 nVal = fReal; 775 push( nVal); 776 } 777} 778 779// -------------------------------------------------------------------- 780 781void CffSubsetterContext::read2push() 782{ 783 ValType aVal = 0; 784 785 const U8*& p = mpReadPtr; 786 const U8 c = *p; |
750 if( c == 28 ) { | 787 if( c == 28 ) { // -32767..+32767 |
751 short nS16 = (p[1] << 8) + p[2]; 752 if( (sizeof(nS16) != 2) && (nS16 & (1<<15))) 753 nS16 |= (~0U) << 15; // assuming 2s complement 754 aVal = nS16; 755 p += 3; 756 } else if( c <= 246 ) { // -107..+107 757 aVal = static_cast<ValType>(p[0] - 139); 758 p += 1; --- 549 unchanged lines hidden (view full) --- 1308 1309// -------------------------------------------------------------------- 1310 1311void CffSubsetterContext::callType2Subr( bool bGlobal, int nSubrNumber) 1312{ 1313 const U8* const pOldReadPtr = mpReadPtr; 1314 const U8* const pOldReadEnd = mpReadEnd; 1315 | 788 short nS16 = (p[1] << 8) + p[2]; 789 if( (sizeof(nS16) != 2) && (nS16 & (1<<15))) 790 nS16 |= (~0U) << 15; // assuming 2s complement 791 aVal = nS16; 792 p += 3; 793 } else if( c <= 246 ) { // -107..+107 794 aVal = static_cast<ValType>(p[0] - 139); 795 p += 1; --- 549 unchanged lines hidden (view full) --- 1345 1346// -------------------------------------------------------------------- 1347 1348void CffSubsetterContext::callType2Subr( bool bGlobal, int nSubrNumber) 1349{ 1350 const U8* const pOldReadPtr = mpReadPtr; 1351 const U8* const pOldReadEnd = mpReadEnd; 1352 |
1316 int nLen = 0; | |
1317 if( bGlobal ) { 1318 nSubrNumber += mnGlobalSubrBias; | 1353 if( bGlobal ) { 1354 nSubrNumber += mnGlobalSubrBias; |
1319 nLen = seekIndexData( mnGlobalSubrBase, nSubrNumber); | 1355 seekIndexData( mnGlobalSubrBase, nSubrNumber); |
1320 } else { 1321 nSubrNumber += mpCffLocal->mnLocalSubrBias; | 1356 } else { 1357 nSubrNumber += mpCffLocal->mnLocalSubrBias; |
1322 nLen = seekIndexData( mpCffLocal->mnLocalSubrBase, nSubrNumber); | 1358 seekIndexData( mpCffLocal->mnLocalSubrBase, nSubrNumber); |
1323 } 1324 1325 while( mpReadPtr < mpReadEnd) 1326 convertOneTypeOp(); 1327 1328 mpReadPtr = pOldReadPtr; 1329 mpReadEnd = pOldReadEnd; 1330} --- 150 unchanged lines hidden (view full) --- 1481 if( !nExpVal) { /*nothing to apply*/} 1482 else if( nExpVal > 0) { while( --nExpVal >= 0) fReal *= 10.0;} 1483 else if( nExpVal < 0) { while( ++nExpVal <= 0) fReal /= 10.0;} 1484 return fReal; 1485} 1486 1487// -------------------------------------------------------------------- 1488 | 1359 } 1360 1361 while( mpReadPtr < mpReadEnd) 1362 convertOneTypeOp(); 1363 1364 mpReadPtr = pOldReadPtr; 1365 mpReadEnd = pOldReadEnd; 1366} --- 150 unchanged lines hidden (view full) --- 1517 if( !nExpVal) { /*nothing to apply*/} 1518 else if( nExpVal > 0) { while( --nExpVal >= 0) fReal *= 10.0;} 1519 else if( nExpVal < 0) { while( ++nExpVal <= 0) fReal /= 10.0;} 1520 return fReal; 1521} 1522 1523// -------------------------------------------------------------------- 1524 |
1489// prepare to access an element inside a CFF/CID index table | |
1490int CffSubsetterContext::seekIndexData( int nIndexBase, int nDataIndex) 1491{ 1492 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd)); 1493 if( nDataIndex < 0) 1494 return -1; 1495 mpReadPtr = mpBasePtr + nIndexBase; 1496 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1497 if( nDataIndex >= nDataCount) --- 24 unchanged lines hidden (view full) --- 1522 assert( nOfs2 >= nOfs1); 1523 assert( mpReadPtr <= mpBaseEnd); 1524 assert( mpReadEnd <= mpBaseEnd); 1525 return (nOfs2 - nOfs1); 1526} 1527 1528// -------------------------------------------------------------------- 1529 | 1525int CffSubsetterContext::seekIndexData( int nIndexBase, int nDataIndex) 1526{ 1527 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd)); 1528 if( nDataIndex < 0) 1529 return -1; 1530 mpReadPtr = mpBasePtr + nIndexBase; 1531 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1532 if( nDataIndex >= nDataCount) --- 24 unchanged lines hidden (view full) --- 1557 assert( nOfs2 >= nOfs1); 1558 assert( mpReadPtr <= mpBaseEnd); 1559 assert( mpReadEnd <= mpBaseEnd); 1560 return (nOfs2 - nOfs1); 1561} 1562 1563// -------------------------------------------------------------------- 1564 |
1530// skip over a CFF/CID index table | |
1531void CffSubsetterContext::seekIndexEnd( int nIndexBase) 1532{ 1533 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd)); 1534 mpReadPtr = mpBasePtr + nIndexBase; 1535 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1536 const int nDataOfsSz = mpReadPtr[2]; 1537 mpReadPtr += 3 + nDataOfsSz * nDataCount; 1538 assert( mpReadPtr <= mpBaseEnd); --- 122 unchanged lines hidden (view full) --- 1661 mnCharStrCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1662// seekIndexEnd( mnCharStrBase); 1663 1664 // read the FDArray index (CID only) 1665 if( mbCIDFont) { 1666// assert( mnFontDictBase == tellRel()); 1667 mpReadPtr = mpBasePtr + mnFontDictBase; 1668 mnFDAryCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; | 1565void CffSubsetterContext::seekIndexEnd( int nIndexBase) 1566{ 1567 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd)); 1568 mpReadPtr = mpBasePtr + nIndexBase; 1569 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1570 const int nDataOfsSz = mpReadPtr[2]; 1571 mpReadPtr += 3 + nDataOfsSz * nDataCount; 1572 assert( mpReadPtr <= mpBaseEnd); --- 122 unchanged lines hidden (view full) --- 1695 mnCharStrCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; 1696// seekIndexEnd( mnCharStrBase); 1697 1698 // read the FDArray index (CID only) 1699 if( mbCIDFont) { 1700// assert( mnFontDictBase == tellRel()); 1701 mpReadPtr = mpBasePtr + mnFontDictBase; 1702 mnFDAryCount = (mpReadPtr[0]<<8) + mpReadPtr[1]; |
1669 assert( mnFDAryCount < (int)(sizeof(maCffLocal)/sizeof(*maCffLocal))); | 1703 if (maCffLocal.size() < static_cast<size_t>(mnFDAryCount)) 1704 maCffLocal.resize(mnFDAryCount); |
1670 1671 // read FDArray details to get access to the PRIVDICTs 1672 for( int i = 0; i < mnFDAryCount; ++i) { 1673 mpCffLocal = &maCffLocal[i]; 1674 seekIndexData( mnFontDictBase, i); 1675 while( mpReadPtr < mpReadEnd) 1676 readDictOp(); 1677 assert( mpReadPtr == mpReadEnd); --- 740 unchanged lines hidden --- | 1705 1706 // read FDArray details to get access to the PRIVDICTs 1707 for( int i = 0; i < mnFDAryCount; ++i) { 1708 mpCffLocal = &maCffLocal[i]; 1709 seekIndexData( mnFontDictBase, i); 1710 while( mpReadPtr < mpReadEnd) 1711 readDictOp(); 1712 assert( mpReadPtr == mpReadEnd); --- 740 unchanged lines hidden --- |