ReactOS 0.4.16-dev-2324-ge2cf0bf
cffload.h File Reference
Include dependency graph for cffload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER cff_get_standard_encoding (FT_UInt charcode)
 
 cff_index_get_string (CFF_Font font, FT_UInt element)
 
 cff_index_get_sid_string (CFF_Font font, FT_UInt sid)
 
 cff_index_access_element (CFF_Index idx, FT_UInt element, FT_Byte **pbytes, FT_ULong *pbyte_len)
 
 cff_index_forget_element (CFF_Index idx, FT_Byte **pbytes)
 
 cff_index_get_name (CFF_Font font, FT_UInt element)
 
 cff_charset_cid_to_gindex (CFF_Charset charset, FT_UInt cid)
 
 cff_font_load (FT_Library library, FT_Stream stream, FT_Int face_index, CFF_Font font, CFF_Face face, FT_Bool pure_cff, FT_Bool cff2)
 
 cff_font_done (CFF_Font font)
 
 cff_load_private_dict (CFF_Font font, CFF_SubFont subfont, FT_UInt lenNDV, FT_Fixed *NDV)
 
 cff_fd_select_get (CFF_FDSelect fdselect, FT_UInt glyph_index)
 
 cff_blend_check_vector (CFF_Blend blend, FT_UInt vsindex, FT_UInt lenNDV, FT_Fixed *NDV)
 
 cff_blend_build_vector (CFF_Blend blend, FT_UInt vsindex, FT_UInt lenNDV, FT_Fixed *NDV)
 
 cff_blend_clear (CFF_SubFont subFont)
 
 cff_blend_doBlend (CFF_SubFont subfont, CFF_Parser parser, FT_UInt numBlends)
 

Function Documentation

◆ cff_blend_build_vector()

cff_blend_build_vector ( CFF_Blend  blend,
FT_UInt  vsindex,
FT_UInt  lenNDV,
FT_Fixed NDV 
)

Definition at line 1393 of file cffload.c.

1397 {
1398 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
1399 FT_Memory memory = blend->font->memory; /* for FT_REALLOC */
1400
1401 FT_UInt len;
1402 CFF_VStore vs;
1403 CFF_VarData* varData;
1404 FT_UInt master;
1405
1406
1407 /* protect against malformed fonts */
1408 if ( !( lenNDV == 0 || NDV ) )
1409 {
1410 FT_TRACE4(( " cff_blend_build_vector:"
1411 " Malformed Normalize Design Vector data\n" ));
1412 error = FT_THROW( Invalid_File_Format );
1413 goto Exit;
1414 }
1415
1416 blend->builtBV = FALSE;
1417
1418 vs = &blend->font->vstore;
1419
1420 /* VStore and fvar must be consistent */
1421 if ( lenNDV != 0 && lenNDV != vs->axisCount )
1422 {
1423 FT_TRACE4(( " cff_blend_build_vector: Axis count mismatch\n" ));
1424 error = FT_THROW( Invalid_File_Format );
1425 goto Exit;
1426 }
1427
1428 if ( vsindex >= vs->dataCount )
1429 {
1430 FT_TRACE4(( " cff_blend_build_vector: vsindex out of range\n" ));
1431 error = FT_THROW( Invalid_File_Format );
1432 goto Exit;
1433 }
1434
1435 /* select the item variation data structure */
1436 varData = &vs->varData[vsindex];
1437
1438 /* prepare buffer for the blend vector */
1439 len = varData->regionIdxCount + 1; /* add 1 for default component */
1440 if ( FT_REALLOC( blend->BV,
1441 blend->lenBV * sizeof( *blend->BV ),
1442 len * sizeof( *blend->BV ) ) )
1443 goto Exit;
1444
1445 blend->lenBV = len;
1446
1447 /* outer loop steps through master designs to be blended */
1448 for ( master = 0; master < len; master++ )
1449 {
1450 FT_UInt j;
1451 FT_UInt idx;
1452 CFF_VarRegion* varRegion;
1453
1454
1455 /* default factor is always one */
1456 if ( master == 0 )
1457 {
1458 blend->BV[master] = FT_FIXED_ONE;
1459 FT_TRACE4(( " build blend vector len %d\n"
1460 " [ %f ",
1461 len,
1462 blend->BV[master] / 65536.0 ));
1463 continue;
1464 }
1465
1466 /* VStore array does not include default master, so subtract one */
1467 idx = varData->regionIndices[master - 1];
1468 varRegion = &vs->varRegionList[idx];
1469
1470 if ( idx >= vs->regionCount )
1471 {
1472 FT_TRACE4(( " cff_blend_build_vector:"
1473 " region index out of range\n" ));
1474 error = FT_THROW( Invalid_File_Format );
1475 goto Exit;
1476 }
1477
1478 /* Note: `lenNDV' could be zero. */
1479 /* In that case, build default blend vector (1,0,0...). */
1480 if ( !lenNDV )
1481 {
1482 blend->BV[master] = 0;
1483 continue;
1484 }
1485
1486 /* In the normal case, initialize each component to 1 */
1487 /* before inner loop. */
1488 blend->BV[master] = FT_FIXED_ONE; /* default */
1489
1490 /* inner loop steps through axes in this region */
1491 for ( j = 0; j < lenNDV; j++ )
1492 {
1493 CFF_AxisCoords* axis = &varRegion->axisList[j];
1494 FT_Fixed axisScalar;
1495
1496
1497 /* compute the scalar contribution of this axis; */
1498 /* ignore invalid ranges */
1499 if ( axis->startCoord > axis->peakCoord ||
1500 axis->peakCoord > axis->endCoord )
1501 axisScalar = FT_FIXED_ONE;
1502
1503 else if ( axis->startCoord < 0 &&
1504 axis->endCoord > 0 &&
1505 axis->peakCoord != 0 )
1506 axisScalar = FT_FIXED_ONE;
1507
1508 /* peak of 0 means ignore this axis */
1509 else if ( axis->peakCoord == 0 )
1510 axisScalar = FT_FIXED_ONE;
1511
1512 /* ignore this region if coords are out of range */
1513 else if ( NDV[j] < axis->startCoord ||
1514 NDV[j] > axis->endCoord )
1515 axisScalar = 0;
1516
1517 /* calculate a proportional factor */
1518 else
1519 {
1520 if ( NDV[j] == axis->peakCoord )
1521 axisScalar = FT_FIXED_ONE;
1522 else if ( NDV[j] < axis->peakCoord )
1523 axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
1524 axis->peakCoord - axis->startCoord );
1525 else
1526 axisScalar = FT_DivFix( axis->endCoord - NDV[j],
1527 axis->endCoord - axis->peakCoord );
1528 }
1529
1530 /* take product of all the axis scalars */
1531 blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
1532 }
1533
1534 FT_TRACE4(( ", %f ",
1535 blend->BV[master] / 65536.0 ));
1536 }
1537
1538 FT_TRACE4(( "]\n" ));
1539
1540 /* record the parameters used to build the blend vector */
1541 blend->lastVsindex = vsindex;
1542
1543 if ( lenNDV != 0 )
1544 {
1545 /* user has set a normalized vector */
1546 if ( FT_REALLOC( blend->lastNDV,
1547 blend->lenNDV * sizeof ( *NDV ),
1548 lenNDV * sizeof ( *NDV ) ) )
1549 goto Exit;
1550
1551 FT_MEM_COPY( blend->lastNDV,
1552 NDV,
1553 lenNDV * sizeof ( *NDV ) );
1554 }
1555
1556 blend->lenNDV = lenNDV;
1557 blend->builtBV = TRUE;
1558
1559 Exit:
1560 return error;
1561 }
#define FT_FIXED_ONE
Definition: cffload.c:37
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int idx
Definition: utils.c:41
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:607
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:508
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE4(varformat)
Definition: ftdebug.h:191
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:314
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:237
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
signed long FT_Fixed
Definition: fttypes.h:287
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:122
static vector_t * vs
Definition: server.c:146
static void Exit(void)
Definition: sock.c:1330
FT_Fixed startCoord
Definition: cfftypes.h:129
FT_Fixed peakCoord
Definition: cfftypes.h:130
FT_Fixed endCoord
Definition: cfftypes.h:131
FT_UInt lastVsindex
Definition: cfftypes.h:175
FT_UInt lenNDV
Definition: cfftypes.h:176
FT_Bool builtBV
Definition: cfftypes.h:172
CFF_Font font
Definition: cfftypes.h:174
FT_UInt lenBV
Definition: cfftypes.h:178
FT_Fixed * lastNDV
Definition: cfftypes.h:177
FT_Int32 * BV
Definition: cfftypes.h:179
CFF_VStoreRec vstore
Definition: cfftypes.h:403
FT_Memory memory
Definition: cfftypes.h:341
FT_UInt * regionIndices
Definition: cfftypes.h:121
FT_UInt regionIdxCount
Definition: cfftypes.h:120
CFF_AxisCoords * axisList
Definition: cfftypes.h:138
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by cff_parse_blend().

◆ cff_blend_check_vector()

cff_blend_check_vector ( CFF_Blend  blend,
FT_UInt  vsindex,
FT_UInt  lenNDV,
FT_Fixed NDV 
)

Definition at line 1567 of file cffload.c.

1571 {
1572 if ( !blend->builtBV ||
1573 blend->lastVsindex != vsindex ||
1574 blend->lenNDV != lenNDV ||
1575 ( lenNDV &&
1576 ft_memcmp( NDV,
1577 blend->lastNDV,
1578 lenNDV * sizeof ( *NDV ) ) != 0 ) )
1579 {
1580 /* need to build blend vector */
1581 return TRUE;
1582 }
1583
1584 return FALSE;
1585 }
#define ft_memcmp
Definition: ftstdlib.h:81

Referenced by cff_parse_blend().

◆ cff_blend_clear()

cff_blend_clear ( CFF_SubFont  subFont)

Definition at line 1268 of file cffload.c.

1269 {
1270 subFont->blend_top = subFont->blend_stack;
1271 subFont->blend_used = 0;
1272 }
FT_Byte * blend_top
Definition: cfftypes.h:321
FT_Byte * blend_stack
Definition: cfftypes.h:320
FT_UInt blend_used
Definition: cfftypes.h:322

Referenced by cff_load_private_dict().

◆ cff_blend_doBlend()

cff_blend_doBlend ( CFF_SubFont  subfont,
CFF_Parser  parser,
FT_UInt  numBlends 
)

Definition at line 1286 of file cffload.c.

1289 {
1290 FT_UInt delta;
1291 FT_UInt base;
1292 FT_UInt i, j;
1293 FT_UInt size;
1294
1295 CFF_Blend blend = &subFont->blend;
1296
1297 FT_Memory memory = subFont->blend.font->memory; /* for FT_REALLOC */
1298 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
1299
1300 /* compute expected number of operands for this blend */
1301 FT_UInt numOperands = (FT_UInt)( numBlends * blend->lenBV );
1302 FT_UInt count = (FT_UInt)( parser->top - 1 - parser->stack );
1303
1304
1305 if ( numOperands > count )
1306 {
1307 FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n",
1308 count,
1309 count == 1 ? "" : "s" ));
1310
1311 error = FT_THROW( Stack_Underflow );
1312 goto Exit;
1313 }
1314
1315 /* check whether we have room for `numBlends' values at `blend_top' */
1316 size = 5 * numBlends; /* add 5 bytes per entry */
1317 if ( subFont->blend_used + size > subFont->blend_alloc )
1318 {
1319 FT_Byte* blend_stack_old = subFont->blend_stack;
1320 FT_Byte* blend_top_old = subFont->blend_top;
1321
1322
1323 /* increase or allocate `blend_stack' and reset `blend_top'; */
1324 /* prepare to append `numBlends' values to the buffer */
1325 if ( FT_REALLOC( subFont->blend_stack,
1326 subFont->blend_alloc,
1327 subFont->blend_alloc + size ) )
1328 goto Exit;
1329
1330 subFont->blend_top = subFont->blend_stack + subFont->blend_used;
1331 subFont->blend_alloc += size;
1332
1333 /* iterate over the parser stack and adjust pointers */
1334 /* if the reallocated buffer has a different address */
1335 if ( blend_stack_old &&
1336 subFont->blend_stack != blend_stack_old )
1337 {
1338 FT_PtrDist offset = subFont->blend_stack - blend_stack_old;
1339 FT_Byte** p;
1340
1341
1342 for ( p = parser->stack; p < parser->top; p++ )
1343 {
1344 if ( *p >= blend_stack_old && *p < blend_top_old )
1345 *p += offset;
1346 }
1347 }
1348 }
1349 subFont->blend_used += size;
1350
1351 base = count - numOperands; /* index of first blend arg */
1352 delta = base + numBlends; /* index of first delta arg */
1353
1354 for ( i = 0; i < numBlends; i++ )
1355 {
1356 const FT_Int32* weight = &blend->BV[1];
1357 FT_UInt32 sum;
1358
1359
1360 /* convert inputs to 16.16 fixed point */
1361 sum = cff_parse_num( parser, &parser->stack[i + base] ) * 0x10000;
1362
1363 for ( j = 1; j < blend->lenBV; j++ )
1364 sum += cff_parse_num( parser, &parser->stack[delta++] ) * *weight++;
1365
1366 /* point parser stack to new value on blend_stack */
1367 parser->stack[i + base] = subFont->blend_top;
1368
1369 /* Push blended result as Type 2 5-byte fixed point number. This */
1370 /* will not conflict with actual DICTs because 255 is a reserved */
1371 /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */
1372 /* decode of this, which rounds to an integer. */
1373 *subFont->blend_top++ = 255;
1374 *subFont->blend_top++ = (FT_Byte)( sum >> 24 );
1375 *subFont->blend_top++ = (FT_Byte)( sum >> 16 );
1376 *subFont->blend_top++ = (FT_Byte)( sum >> 8 );
1377 *subFont->blend_top++ = (FT_Byte)sum;
1378 }
1379
1380 /* leave only numBlends results on parser stack */
1381 parser->top = &parser->stack[base + numBlends];
1382
1383 Exit:
1384 return error;
1385 }
cff_parse_num(CFF_Parser parser, FT_Byte **d)
Definition: cffparse.c:522
ft_ptrdiff_t FT_PtrDist
Definition: fttypes.h:336
unsigned char FT_Byte
Definition: fttypes.h:154
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLfloat GLfloat p
Definition: glext.h:8902
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static int sum(int x_, int y_)
Definition: ptr2_test.cpp:35
weight
Definition: sortkey.c:157
Definition: import.c:81
enum parser_state stack[4]
Definition: inffile.c:91

Referenced by cff_parse_blend().

◆ cff_charset_cid_to_gindex()

cff_charset_cid_to_gindex ( CFF_Charset  charset,
FT_UInt  cid 
)

Definition at line 870 of file cffload.c.

872 {
873 FT_UInt result = 0;
874
875
876 if ( cid <= charset->max_cid )
878
879 return result;
880 }
CFF_Charset charset
Definition: cffcmap.c:137
GLuint64EXT * result
Definition: glext.h:11304
static TfClientId cid
FT_UShort * cids
Definition: cfftypes.h:103

Referenced by cff_encoding_load(), and cff_slot_load().

◆ cff_fd_select_get()

cff_fd_select_get ( CFF_FDSelect  fdselect,
FT_UInt  glyph_index 
)

Definition at line 756 of file cffload.c.

758 {
759 FT_Byte fd = 0;
760
761
762 /* if there is no FDSelect, return zero */
763 /* Note: CFF2 with just one Font Dict has no FDSelect */
764 if ( !fdselect->data )
765 goto Exit;
766
767 switch ( fdselect->format )
768 {
769 case 0:
770 fd = fdselect->data[glyph_index];
771 break;
772
773 case 3:
774 /* first, compare to the cache */
775 if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
776 fdselect->cache_count )
777 {
778 fd = fdselect->cache_fd;
779 break;
780 }
781
782 /* then, look up the ranges array */
783 {
784 FT_Byte* p = fdselect->data;
785 FT_Byte* p_limit = p + fdselect->data_size;
786 FT_Byte fd2;
788
789
791 do
792 {
793 if ( glyph_index < first )
794 break;
795
796 fd2 = *p++;
798
799 if ( glyph_index < limit )
800 {
801 fd = fd2;
802
803 /* update cache */
804 fdselect->cache_first = first;
805 fdselect->cache_count = limit - first;
806 fdselect->cache_fd = fd2;
807 break;
808 }
809 first = limit;
810
811 } while ( p < p_limit );
812 }
813 break;
814
815 default:
816 ;
817 }
818
819 Exit:
820 return fd;
821 }
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:244
GLint limit
Definition: glext.h:10326
const GLint * first
Definition: glext.h:5794
static int fd
Definition: io.c:51
FT_UInt cache_first
Definition: cfftypes.h:293
FT_Byte cache_fd
Definition: cfftypes.h:295
FT_UInt cache_count
Definition: cfftypes.h:294
FT_Byte * data
Definition: cfftypes.h:289
FT_Byte format
Definition: cfftypes.h:285
FT_UInt data_size
Definition: cfftypes.h:290

Referenced by cff_slot_load().

◆ cff_font_done()

cff_font_done ( CFF_Font  font)

Definition at line 2530 of file cffload.c.

2531 {
2532 FT_Memory memory = font->memory;
2533 FT_UInt idx;
2534
2535
2536 cff_index_done( &font->global_subrs_index );
2537 cff_index_done( &font->font_dict_index );
2538 cff_index_done( &font->name_index );
2539 cff_index_done( &font->charstrings_index );
2540
2541 /* release font dictionaries, but only if working with */
2542 /* a CID keyed CFF font or a CFF2 font */
2543 if ( font->num_subfonts > 0 )
2544 {
2545 for ( idx = 0; idx < font->num_subfonts; idx++ )
2546 cff_subfont_done( memory, font->subfonts[idx] );
2547
2548 /* the subfonts array has been allocated as a single block */
2549 FT_FREE( font->subfonts[0] );
2550 }
2551
2552 cff_encoding_done( &font->encoding );
2553 cff_charset_done( &font->charset, font->stream );
2554 cff_vstore_done( &font->vstore, memory );
2555
2556 cff_subfont_done( memory, &font->top_font );
2557
2558 CFF_Done_FD_Select( &font->fd_select, font->stream );
2559
2560 FT_FREE( font->font_info );
2561
2562 FT_FREE( font->font_name );
2563 FT_FREE( font->global_subrs );
2564 FT_FREE( font->strings );
2565 FT_FREE( font->string_pool );
2566
2567 if ( font->cf2_instance.finalizer )
2568 {
2569 font->cf2_instance.finalizer( font->cf2_instance.data );
2570 FT_FREE( font->cf2_instance.data );
2571 }
2572
2573 FT_FREE( font->font_extra );
2574 }
static void cff_subfont_done(FT_Memory memory, CFF_SubFont subfont)
Definition: cffload.c:2166
static void cff_index_done(CFF_Index idx)
Definition: cffload.c:323
static void CFF_Done_FD_Select(CFF_FDSelect fdselect, FT_Stream stream)
Definition: cffload.c:692
static void cff_vstore_done(CFF_VStoreRec *vstore, FT_Memory memory)
Definition: cffload.c:1098
static void cff_encoding_done(CFF_Encoding encoding)
Definition: cffload.c:1622
static void cff_charset_done(CFF_Charset charset, FT_Stream stream)
Definition: cffload.c:893
#define FT_FREE(ptr)
Definition: ftmemory.h:337
Definition: mk_font.cpp:20

Referenced by cff_face_done().

◆ cff_font_load()

cff_font_load ( FT_Library  library,
FT_Stream  stream,
FT_Int  face_index,
CFF_Font  font,
CFF_Face  face,
FT_Bool  pure_cff,
FT_Bool  cff2 
)

Definition at line 2182 of file cffload.c.

2189 {
2190 static const FT_Frame_Field cff_header_fields[] =
2191 {
2192#undef FT_STRUCTURE
2193#define FT_STRUCTURE CFF_FontRec
2194
2195 FT_FRAME_START( 3 ),
2196 FT_FRAME_BYTE( version_major ),
2197 FT_FRAME_BYTE( version_minor ),
2198 FT_FRAME_BYTE( header_size ),
2200 };
2201
2203 FT_Memory memory = stream->memory;
2204 FT_ULong base_offset;
2205 CFF_FontRecDict dict;
2207 FT_UInt subfont_index;
2208
2209
2210 FT_ZERO( font );
2212
2213 dict = &font->top_font.font_dict;
2214 base_offset = FT_STREAM_POS();
2215
2216 font->library = library;
2217 font->stream = stream;
2218 font->memory = memory;
2219 font->cff2 = cff2;
2220 font->base_offset = base_offset;
2221
2222 /* read CFF font header */
2223 if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )
2224 goto Exit;
2225
2226 if ( cff2 )
2227 {
2228 if ( font->version_major != 2 ||
2229 font->header_size < 5 )
2230 {
2231 FT_TRACE2(( " not a CFF2 font header\n" ));
2232 error = FT_THROW( Unknown_File_Format );
2233 goto Exit;
2234 }
2235
2236 if ( FT_READ_USHORT( font->top_dict_length ) )
2237 goto Exit;
2238 }
2239 else
2240 {
2241 FT_Byte absolute_offset;
2242
2243
2244 if ( FT_READ_BYTE( absolute_offset ) )
2245 goto Exit;
2246
2247 if ( font->version_major != 1 ||
2248 font->header_size < 4 ||
2249 absolute_offset > 4 )
2250 {
2251 FT_TRACE2(( " not a CFF font header\n" ));
2252 error = FT_THROW( Unknown_File_Format );
2253 goto Exit;
2254 }
2255 }
2256
2257 /* skip the rest of the header */
2258 if ( FT_STREAM_SEEK( base_offset + font->header_size ) )
2259 {
2260 /* For pure CFFs we have read only four bytes so far. Contrary to */
2261 /* other formats like SFNT those bytes doesn't define a signature; */
2262 /* it is thus possible that the font isn't a CFF at all. */
2263 if ( pure_cff )
2264 {
2265 FT_TRACE2(( " not a CFF file\n" ));
2266 error = FT_THROW( Unknown_File_Format );
2267 }
2268 goto Exit;
2269 }
2270
2271 if ( cff2 )
2272 {
2273 /* For CFF2, the top dict data immediately follow the header */
2274 /* and the length is stored in the header `offSize' field; */
2275 /* there is no index for it. */
2276 /* */
2277 /* Use the `font_dict_index' to save the current position */
2278 /* and length of data, but leave count at zero as an indicator. */
2279 FT_ZERO( &font->font_dict_index );
2280
2281 font->font_dict_index.data_offset = FT_STREAM_POS();
2282 font->font_dict_index.data_size = font->top_dict_length;
2283
2284 /* skip the top dict data for now, we will parse it later */
2285 if ( FT_STREAM_SKIP( font->top_dict_length ) )
2286 goto Exit;
2287
2288 /* next, read the global subrs index */
2289 if ( FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
2290 stream, 1, cff2 ) ) )
2291 goto Exit;
2292 }
2293 else
2294 {
2295 /* for CFF, read the name, top dict, string and global subrs index */
2296 if ( FT_SET_ERROR( cff_index_init( &font->name_index,
2297 stream, 0, cff2 ) ) )
2298 {
2299 if ( pure_cff )
2300 {
2301 FT_TRACE2(( " not a CFF file\n" ));
2302 error = FT_THROW( Unknown_File_Format );
2303 }
2304 goto Exit;
2305 }
2306
2307 /* if we have an empty font name, */
2308 /* it must be the only font in the CFF */
2309 if ( font->name_index.count > 1 &&
2310 font->name_index.data_size < font->name_index.count )
2311 {
2312 /* for pure CFFs, we still haven't checked enough bytes */
2313 /* to be sure that it is a CFF at all */
2314 error = pure_cff ? FT_THROW( Unknown_File_Format )
2315 : FT_THROW( Invalid_File_Format );
2316 goto Exit;
2317 }
2318
2319 if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index,
2320 stream, 0, cff2 ) ) ||
2322 stream, 1, cff2 ) ) ||
2323 FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
2324 stream, 1, cff2 ) ) ||
2326 &font->strings,
2327 &font->string_pool,
2328 &font->string_pool_size ) ) )
2329 goto Exit;
2330
2331 /* there must be a Top DICT index entry for each name index entry */
2332 if ( font->name_index.count > font->font_dict_index.count )
2333 {
2334 FT_ERROR(( "cff_font_load:"
2335 " not enough entries in Top DICT index\n" ));
2336 error = FT_THROW( Invalid_File_Format );
2337 goto Exit;
2338 }
2339 }
2340
2341 font->num_strings = string_index.count;
2342
2343 if ( pure_cff )
2344 {
2345 /* well, we don't really forget the `disabled' fonts... */
2346 subfont_index = (FT_UInt)( face_index & 0xFFFF );
2347
2348 if ( face_index > 0 && subfont_index >= font->name_index.count )
2349 {
2350 FT_ERROR(( "cff_font_load:"
2351 " invalid subfont index for pure CFF font (%d)\n",
2352 subfont_index ));
2353 error = FT_THROW( Invalid_Argument );
2354 goto Exit;
2355 }
2356
2357 font->num_faces = font->name_index.count;
2358 }
2359 else
2360 {
2361 subfont_index = 0;
2362
2363 if ( font->name_index.count > 1 )
2364 {
2365 FT_ERROR(( "cff_font_load:"
2366 " invalid CFF font with multiple subfonts\n"
2367 " "
2368 " in SFNT wrapper\n" ));
2369 error = FT_THROW( Invalid_File_Format );
2370 goto Exit;
2371 }
2372 }
2373
2374 /* in case of a font format check, simply exit now */
2375 if ( face_index < 0 )
2376 goto Exit;
2377
2378 /* now, parse the top-level font dictionary */
2379 FT_TRACE4(( "parsing top-level\n" ));
2380 error = cff_subfont_load( &font->top_font,
2381 &font->font_dict_index,
2382 subfont_index,
2383 stream,
2384 base_offset,
2386 font,
2387 face );
2388 if ( error )
2389 goto Exit;
2390
2391 if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
2392 goto Exit;
2393
2394 error = cff_index_init( &font->charstrings_index, stream, 0, cff2 );
2395 if ( error )
2396 goto Exit;
2397
2398 /* now, check for a CID or CFF2 font */
2399 if ( dict->cid_registry != 0xFFFFU ||
2400 cff2 )
2401 {
2402 CFF_IndexRec fd_index;
2403 CFF_SubFont sub = NULL;
2404 FT_UInt idx;
2405
2406
2407 /* for CFF2, read the Variation Store if available; */
2408 /* this must follow the Top DICT parse and precede any Private DICT */
2409 error = cff_vstore_load( &font->vstore,
2410 stream,
2411 base_offset,
2412 dict->vstore_offset );
2413 if ( error )
2414 goto Exit;
2415
2416 /* this is a CID-keyed font, we must now allocate a table of */
2417 /* sub-fonts, then load each of them separately */
2418 if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )
2419 goto Exit;
2420
2421 error = cff_index_init( &fd_index, stream, 0, cff2 );
2422 if ( error )
2423 goto Exit;
2424
2425 /* Font Dicts are not limited to 256 for CFF2. */
2426 /* TODO: support this for CFF2 */
2427 if ( fd_index.count > CFF_MAX_CID_FONTS )
2428 {
2429 FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
2430 goto Fail_CID;
2431 }
2432
2433 /* allocate & read each font dict independently */
2434 font->num_subfonts = fd_index.count;
2435 if ( FT_NEW_ARRAY( sub, fd_index.count ) )
2436 goto Fail_CID;
2437
2438 /* set up pointer table */
2439 for ( idx = 0; idx < fd_index.count; idx++ )
2440 font->subfonts[idx] = sub + idx;
2441
2442 /* now load each subfont independently */
2443 for ( idx = 0; idx < fd_index.count; idx++ )
2444 {
2445 sub = font->subfonts[idx];
2446 FT_TRACE4(( "parsing subfont %u\n", idx ));
2447 error = cff_subfont_load( sub,
2448 &fd_index,
2449 idx,
2450 stream,
2451 base_offset,
2452 cff2 ? CFF2_CODE_FONTDICT
2454 font,
2455 face );
2456 if ( error )
2457 goto Fail_CID;
2458 }
2459
2460 /* now load the FD Select array; */
2461 /* CFF2 omits FDSelect if there is only one FD */
2462 if ( !cff2 || fd_index.count > 1 )
2463 error = CFF_Load_FD_Select( &font->fd_select,
2464 font->charstrings_index.count,
2465 stream,
2466 base_offset + dict->cid_fd_select_offset );
2467
2468 Fail_CID:
2469 cff_index_done( &fd_index );
2470
2471 if ( error )
2472 goto Exit;
2473 }
2474 else
2475 font->num_subfonts = 0;
2476
2477 /* read the charstrings index now */
2478 if ( dict->charstrings_offset == 0 )
2479 {
2480 FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
2481 error = FT_THROW( Invalid_File_Format );
2482 goto Exit;
2483 }
2484
2485 font->num_glyphs = font->charstrings_index.count;
2486
2487 error = cff_index_get_pointers( &font->global_subrs_index,
2488 &font->global_subrs, NULL, NULL );
2489
2490 if ( error )
2491 goto Exit;
2492
2493 /* read the Charset and Encoding tables if available */
2494 if ( !cff2 && font->num_glyphs > 0 )
2495 {
2496 FT_Bool invert = FT_BOOL( dict->cid_registry != 0xFFFFU && pure_cff );
2497
2498
2499 error = cff_charset_load( &font->charset, font->num_glyphs, stream,
2500 base_offset, dict->charset_offset, invert );
2501 if ( error )
2502 goto Exit;
2503
2504 /* CID-keyed CFFs don't have an encoding */
2505 if ( dict->cid_registry == 0xFFFFU )
2506 {
2507 error = cff_encoding_load( &font->encoding,
2508 &font->charset,
2509 font->num_glyphs,
2510 stream,
2511 base_offset,
2512 dict->encoding_offset );
2513 if ( error )
2514 goto Exit;
2515 }
2516 }
2517
2518 /* get the font name (/CIDFontName for CID-keyed fonts, */
2519 /* /FontName otherwise) */
2520 font->font_name = cff_index_get_name( font, subfont_index );
2521
2522 Exit:
2524
2525 return error;
2526 }
FT_Library library
Definition: cffdrivr.c:660
static FT_Error cff_charset_load(CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, FT_ULong offset, FT_Bool invert)
Definition: cffload.c:908
static FT_Error cff_encoding_load(CFF_Encoding encoding, CFF_Charset charset, FT_UInt num_glyphs, FT_Stream stream, FT_ULong base_offset, FT_ULong offset)
Definition: cffload.c:1631
static FT_Error cff_subfont_load(CFF_SubFont subfont, CFF_Index idx, FT_UInt font_index, FT_Stream stream, FT_ULong base_offset, FT_UInt code, CFF_Font font, CFF_Face face)
Definition: cffload.c:1985
static FT_Error cff_index_init(CFF_Index idx, FT_Stream stream, FT_Bool load, FT_Bool cff2)
Definition: cffload.c:234
static FT_Error CFF_Load_FD_Select(CFF_FDSelect fdselect, FT_UInt num_glyphs, FT_Stream stream, FT_ULong offset)
Definition: cffload.c:705
static FT_Error cff_vstore_load(CFF_VStoreRec *vstore, FT_Stream stream, FT_ULong base_offset, FT_ULong offset)
Definition: cffload.c:1127
cff_index_get_name(CFF_Font font, FT_UInt element)
Definition: cffload.c:617
static FT_Error cff_index_get_pointers(CFF_Index idx, FT_Byte ***table, FT_Byte **pool, FT_ULong *pool_size)
Definition: cffload.c:405
#define CFF_CODE_TOPDICT
Definition: cffparse.h:44
#define CFF2_CODE_FONTDICT
Definition: cffparse.h:47
#define CFF2_CODE_TOPDICT
Definition: cffparse.h:46
FT_BEGIN_HEADER struct CFF_IndexRec_ CFF_IndexRec
#define CFF_MAX_CID_FONTS
Definition: cfftypes.h:334
#define NULL
Definition: types.h:112
#define FT_TRACE0(varformat)
Definition: ftdebug.h:187
#define FT_ERROR(varformat)
Definition: ftdebug.h:211
#define FT_TRACE2(varformat)
Definition: ftdebug.h:189
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:341
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:43
#define FT_ZERO(p)
Definition: ftmemory.h:246
#define FT_READ_USHORT(var)
Definition: ftstream.h:339
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:525
#define FT_STREAM_POS()
Definition: ftstream.h:522
#define FT_FRAME_BYTE(f)
Definition: ftstream.h:126
#define FT_READ_BYTE(var)
Definition: ftstream.h:336
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:544
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:529
#define FT_FRAME_START(size)
Definition: ftstream.h:117
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned long FT_ULong
Definition: fttypes.h:253
#define FT_BOOL(x)
Definition: fttypes.h:591
GLboolean invert
Definition: gl.h:1949
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define for
Definition: utility.h:88
FT_ULong cid_fd_array_offset
Definition: cfftypes.h:223
FT_ULong charset_offset
Definition: cfftypes.h:205
FT_ULong cid_fd_select_offset
Definition: cfftypes.h:224
FT_UInt cid_registry
Definition: cfftypes.h:214
FT_ULong charstrings_offset
Definition: cfftypes.h:207
FT_ULong encoding_offset
Definition: cfftypes.h:206
FT_ULong vstore_offset
Definition: cfftypes.h:234
Definition: parse.h:23

Referenced by cff_face_init().

◆ cff_get_standard_encoding()

FT_BEGIN_HEADER cff_get_standard_encoding ( FT_UInt  charcode)

Definition at line 191 of file cffload.c.

192 {
193 return (FT_UShort)( charcode < 256 ? cff_standard_encoding[charcode]
194 : 0 );
195 }
static const FT_UShort cff_standard_encoding[256]
Definition: cffload.c:115
unsigned short FT_UShort
Definition: fttypes.h:209

◆ cff_index_access_element()

cff_index_access_element ( CFF_Index  idx,
FT_UInt  element,
FT_Byte **  pbytes,
FT_ULong pbyte_len 
)

Definition at line 504 of file cffload.c.

508 {
510
511
512 if ( idx && idx->count > element )
513 {
514 /* compute start and end offsets */
515 FT_Stream stream = idx->stream;
516 FT_ULong off1, off2 = 0;
517
518
519 /* load offsets from file or the offset table */
520 if ( !idx->offsets )
521 {
522 FT_ULong pos = element * idx->off_size;
523
524
525 if ( FT_STREAM_SEEK( idx->start + idx->hdr_size + pos ) )
526 goto Exit;
527
528 off1 = cff_index_read_offset( idx, &error );
529 if ( error )
530 goto Exit;
531
532 if ( off1 != 0 )
533 {
534 do
535 {
536 element++;
537 off2 = cff_index_read_offset( idx, &error );
538
539 } while ( off2 == 0 && element < idx->count );
540 }
541 }
542 else /* use offsets table */
543 {
544 off1 = idx->offsets[element];
545 if ( off1 )
546 {
547 do
548 {
549 element++;
550 off2 = idx->offsets[element];
551
552 } while ( off2 == 0 && element < idx->count );
553 }
554 }
555
556 /* XXX: should check off2 does not exceed the end of this entry; */
557 /* at present, only truncate off2 at the end of this stream */
558 if ( off2 > stream->size + 1 ||
559 idx->data_offset > stream->size - off2 + 1 )
560 {
561 FT_ERROR(( "cff_index_access_element:"
562 " offset to next entry (%ld)"
563 " exceeds the end of stream (%ld)\n",
564 off2, stream->size - idx->data_offset + 1 ));
565 off2 = stream->size - idx->data_offset + 1;
566 }
567
568 /* access element */
569 if ( off1 && off2 > off1 )
570 {
571 *pbyte_len = off2 - off1;
572
573 if ( idx->bytes )
574 {
575 /* this index was completely loaded in memory, that's easy */
576 *pbytes = idx->bytes + off1 - 1;
577 }
578 else
579 {
580 /* this index is still on disk/file, access it through a frame */
581 if ( FT_STREAM_SEEK( idx->data_offset + off1 - 1 ) ||
582 FT_FRAME_EXTRACT( off2 - off1, *pbytes ) )
583 goto Exit;
584 }
585 }
586 else
587 {
588 /* empty index element */
589 *pbytes = 0;
590 *pbyte_len = 0;
591 }
592 }
593 else
594 error = FT_THROW( Invalid_Argument );
595
596 Exit:
597 return error;
598 }
static FT_ULong cff_index_read_offset(CFF_Index idx, FT_Error *errorp)
Definition: cffload.c:210
#define FT_FRAME_EXTRACT(size, bytes)
Definition: ftstream.h:556
unsigned int size
Definition: parse.h:27

Referenced by cff_get_glyph_data(), cff_index_get_name(), and cff_subfont_load().

◆ cff_index_forget_element()

cff_index_forget_element ( CFF_Index  idx,
FT_Byte **  pbytes 
)

Definition at line 602 of file cffload.c.

604 {
605 if ( idx->bytes == 0 )
606 {
607 FT_Stream stream = idx->stream;
608
609
610 FT_FRAME_RELEASE( *pbytes );
611 }
612 }
#define FT_FRAME_RELEASE(bytes)
Definition: ftstream.h:562

Referenced by cff_free_glyph_data(), cff_index_get_name(), and cff_subfont_load().

◆ cff_index_get_name()

cff_index_get_name ( CFF_Font  font,
FT_UInt  element 
)

Definition at line 617 of file cffload.c.

619 {
620 CFF_Index idx = &font->name_index;
622 FT_Byte* bytes;
623 FT_ULong byte_len;
625 FT_String* name = 0;
626
627
628 if ( !idx->stream ) /* CFF2 does not include a name index */
629 goto Exit;
630
631 memory = idx->stream->memory;
632
634 if ( error )
635 goto Exit;
636
637 if ( !FT_ALLOC( name, byte_len + 1 ) )
638 {
639 if ( byte_len )
640 FT_MEM_COPY( name, bytes, byte_len );
641 name[byte_len] = 0;
642 }
644
645 Exit:
646 return name;
647 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
cff_index_forget_element(CFF_Index idx, FT_Byte **pbytes)
Definition: cffload.c:602
cff_index_access_element(CFF_Index idx, FT_UInt element, FT_Byte **pbytes, FT_ULong *pbyte_len)
Definition: cffload.c:504
FT_BEGIN_HEADER struct CFF_IndexRec_ * CFF_Index
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:311
char FT_String
Definition: fttypes.h:187
Definition: name.c:39

Referenced by cff_face_init(), and cff_font_load().

◆ cff_index_get_sid_string()

cff_index_get_sid_string ( CFF_Font  font,
FT_UInt  sid 
)

Definition at line 662 of file cffload.c.

664 {
665 /* value 0xFFFFU indicates a missing dictionary entry */
666 if ( sid == 0xFFFFU )
667 return NULL;
668
669 /* if it is not a standard string, return it */
670 if ( sid > 390 )
671 return cff_index_get_string( font, sid - 391 );
672
673 /* CID-keyed CFF fonts don't have glyph names */
674 if ( !font->psnames )
675 return NULL;
676
677 /* this is a standard string */
678 return (FT_String *)font->psnames->adobe_std_strings( sid );
679 }
FT_UInt sid
Definition: cffcmap.c:138
cff_index_get_string(CFF_Font font, FT_UInt element)
Definition: cffload.c:652

◆ cff_index_get_string()

cff_index_get_string ( CFF_Font  font,
FT_UInt  element 
)

Definition at line 652 of file cffload.c.

654 {
655 return ( element < font->num_strings )
656 ? (FT_String*)font->strings[element]
657 : NULL;
658 }

Referenced by cff_get_name_index(), and cff_index_get_sid_string().

◆ cff_load_private_dict()

cff_load_private_dict ( CFF_Font  font,
CFF_SubFont  subfont,
FT_UInt  lenNDV,
FT_Fixed NDV 
)

Definition at line 1878 of file cffload.c.

1882 {
1885 CFF_FontRecDict top = &subfont->font_dict;
1886 CFF_Private priv = &subfont->private_dict;
1887 FT_Stream stream = font->stream;
1888 FT_UInt stackSize;
1889
1890
1891 /* store handle needed to access memory, vstore for blend; */
1892 /* we need this for clean-up even if there is no private DICT */
1893 subfont->blend.font = font;
1894 subfont->blend.usedBV = FALSE; /* clear state */
1895
1896 if ( !top->private_offset || !top->private_size )
1897 goto Exit2; /* no private DICT, do nothing */
1898
1899 /* set defaults */
1900 FT_ZERO( priv );
1901
1902 priv->blue_shift = 7;
1903 priv->blue_fuzz = 1;
1904 priv->lenIV = -1;
1905 priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
1906 priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
1907
1908 /* provide inputs for blend calculations */
1909 priv->subfont = subfont;
1910 subfont->lenNDV = lenNDV;
1911 subfont->NDV = NDV;
1912
1913 /* add 1 for the operator */
1914 stackSize = font->cff2 ? font->top_font.font_dict.maxstack + 1
1915 : CFF_MAX_STACK_DEPTH + 1;
1916
1917 if ( cff_parser_init( &parser,
1919 priv,
1920 font->library,
1921 stackSize,
1922 top->num_designs,
1923 top->num_axes ) )
1924 goto Exit;
1925
1926 if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) ||
1927 FT_FRAME_ENTER( top->private_size ) )
1928 goto Exit;
1929
1930 FT_TRACE4(( " private dictionary:\n" ));
1932 (FT_Byte*)stream->cursor,
1933 (FT_Byte*)stream->limit );
1934 FT_FRAME_EXIT();
1935
1936 if ( error )
1937 goto Exit;
1938
1939 /* ensure that `num_blue_values' is even */
1940 priv->num_blue_values &= ~1;
1941
1942 /* sanitize `initialRandomSeed' to be a positive value, if necessary; */
1943 /* this is not mandated by the specification but by our implementation */
1944 if ( priv->initial_random_seed < 0 )
1946 else if ( priv->initial_random_seed == 0 )
1947 priv->initial_random_seed = 987654321;
1948
1949 /* some sanitizing to avoid overflows later on; */
1950 /* the upper limits are ad-hoc values */
1951 if ( priv->blue_shift > 1000 || priv->blue_shift < 0 )
1952 {
1953 FT_TRACE2(( "cff_load_private_dict:"
1954 " setting unlikely BlueShift value %ld to default (7)\n",
1955 priv->blue_shift ));
1956 priv->blue_shift = 7;
1957 }
1958
1959 if ( priv->blue_fuzz > 1000 || priv->blue_fuzz < 0 )
1960 {
1961 FT_TRACE2(( "cff_load_private_dict:"
1962 " setting unlikely BlueFuzz value %ld to default (1)\n",
1963 priv->blue_fuzz ));
1964 priv->blue_fuzz = 1;
1965 }
1966
1967 Exit:
1968 /* clean up */
1969 cff_blend_clear( subfont ); /* clear blend stack */
1970 cff_parser_done( &parser ); /* free parser stack */
1971
1972 Exit2:
1973 /* no clean up (parser not initialized) */
1974 return error;
1975 }
cff_blend_clear(CFF_SubFont subFont)
Definition: cffload.c:1268
cff_parser_init(CFF_Parser parser, FT_UInt code, void *object, FT_Library library, FT_UInt stackSize, FT_UShort num_designs, FT_UShort num_axes)
Definition: cffparse.c:41
cff_parser_done(CFF_Parser parser)
Definition: cffparse.c:97
cff_parser_run(CFF_Parser parser, FT_Byte *start, FT_Byte *limit)
Definition: cffparse.c:1194
#define CFF2_CODE_PRIVATE
Definition: cffparse.h:48
#define CFF_CODE_PRIVATE
Definition: cffparse.h:45
#define CFF_MAX_STACK_DEPTH
Definition: cffparse.h:32
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:548
#define FT_FRAME_EXIT()
Definition: ftstream.h:553
FT_Bool usedBV
Definition: cfftypes.h:173
FT_Byte num_blue_values
Definition: cfftypes.h:246
CFF_SubFont subfont
Definition: cfftypes.h:278
FT_Int lenIV
Definition: cfftypes.h:268
FT_Long initial_random_seed
Definition: cfftypes.h:271
FT_Fixed blue_scale
Definition: cfftypes.h:256
FT_Pos blue_fuzz
Definition: cfftypes.h:258
FT_Fixed expansion_factor
Definition: cfftypes.h:270
FT_Pos blue_shift
Definition: cfftypes.h:257
FT_Fixed * NDV
Definition: cfftypes.h:310
FT_UInt lenNDV
Definition: cfftypes.h:309
CFF_PrivateRec private_dict
Definition: cfftypes.h:305
CFF_BlendRec blend
Definition: cfftypes.h:308
CFF_FontRecDictRec font_dict
Definition: cfftypes.h:304

Referenced by cff_subfont_load().