ReactOS 0.4.15-dev-8138-g1e75ea8
cffload.h File Reference
#include <ft2build.h>
#include "cffparse.h"
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 1387 of file cffload.c.

1391 {
1392 FT_Error error = FT_Err_Ok; /* for FT_REALLOC */
1393 FT_Memory memory = blend->font->memory; /* for FT_REALLOC */
1394
1395 FT_UInt len;
1396 CFF_VStore vs;
1397 CFF_VarData* varData;
1398 FT_UInt master;
1399
1400
1401 FT_ASSERT( lenNDV == 0 || NDV );
1402
1403 blend->builtBV = FALSE;
1404
1405 vs = &blend->font->vstore;
1406
1407 /* VStore and fvar must be consistent */
1408 if ( lenNDV != 0 && lenNDV != vs->axisCount )
1409 {
1410 FT_TRACE4(( " cff_blend_build_vector: Axis count mismatch\n" ));
1411 error = FT_THROW( Invalid_File_Format );
1412 goto Exit;
1413 }
1414
1415 if ( vsindex >= vs->dataCount )
1416 {
1417 FT_TRACE4(( " cff_blend_build_vector: vsindex out of range\n" ));
1418 error = FT_THROW( Invalid_File_Format );
1419 goto Exit;
1420 }
1421
1422 /* select the item variation data structure */
1423 varData = &vs->varData[vsindex];
1424
1425 /* prepare buffer for the blend vector */
1426 len = varData->regionIdxCount + 1; /* add 1 for default component */
1427 if ( FT_REALLOC( blend->BV,
1428 blend->lenBV * sizeof( *blend->BV ),
1429 len * sizeof( *blend->BV ) ) )
1430 goto Exit;
1431
1432 blend->lenBV = len;
1433
1434 /* outer loop steps through master designs to be blended */
1435 for ( master = 0; master < len; master++ )
1436 {
1437 FT_UInt j;
1438 FT_UInt idx;
1439 CFF_VarRegion* varRegion;
1440
1441
1442 /* default factor is always one */
1443 if ( master == 0 )
1444 {
1445 blend->BV[master] = FT_FIXED_ONE;
1446 FT_TRACE4(( " build blend vector len %d\n"
1447 " [ %f ",
1448 len,
1449 blend->BV[master] / 65536.0 ));
1450 continue;
1451 }
1452
1453 /* VStore array does not include default master, so subtract one */
1454 idx = varData->regionIndices[master - 1];
1455 varRegion = &vs->varRegionList[idx];
1456
1457 if ( idx >= vs->regionCount )
1458 {
1459 FT_TRACE4(( " cff_blend_build_vector:"
1460 " region index out of range\n" ));
1461 error = FT_THROW( Invalid_File_Format );
1462 goto Exit;
1463 }
1464
1465 /* Note: `lenNDV' could be zero. */
1466 /* In that case, build default blend vector (1,0,0...). */
1467 if ( !lenNDV )
1468 {
1469 blend->BV[master] = 0;
1470 continue;
1471 }
1472
1473 /* In the normal case, initialize each component to 1 */
1474 /* before inner loop. */
1475 blend->BV[master] = FT_FIXED_ONE; /* default */
1476
1477 /* inner loop steps through axes in this region */
1478 for ( j = 0; j < lenNDV; j++ )
1479 {
1480 CFF_AxisCoords* axis = &varRegion->axisList[j];
1481 FT_Fixed axisScalar;
1482
1483
1484 /* compute the scalar contribution of this axis; */
1485 /* ignore invalid ranges */
1486 if ( axis->startCoord > axis->peakCoord ||
1487 axis->peakCoord > axis->endCoord )
1488 axisScalar = FT_FIXED_ONE;
1489
1490 else if ( axis->startCoord < 0 &&
1491 axis->endCoord > 0 &&
1492 axis->peakCoord != 0 )
1493 axisScalar = FT_FIXED_ONE;
1494
1495 /* peak of 0 means ignore this axis */
1496 else if ( axis->peakCoord == 0 )
1497 axisScalar = FT_FIXED_ONE;
1498
1499 /* ignore this region if coords are out of range */
1500 else if ( NDV[j] < axis->startCoord ||
1501 NDV[j] > axis->endCoord )
1502 axisScalar = 0;
1503
1504 /* calculate a proportional factor */
1505 else
1506 {
1507 if ( NDV[j] == axis->peakCoord )
1508 axisScalar = FT_FIXED_ONE;
1509 else if ( NDV[j] < axis->peakCoord )
1510 axisScalar = FT_DivFix( NDV[j] - axis->startCoord,
1511 axis->peakCoord - axis->startCoord );
1512 else
1513 axisScalar = FT_DivFix( axis->endCoord - NDV[j],
1514 axis->endCoord - axis->peakCoord );
1515 }
1516
1517 /* take product of all the axis scalars */
1518 blend->BV[master] = FT_MulFix( blend->BV[master], axisScalar );
1519 }
1520
1521 FT_TRACE4(( ", %f ",
1522 blend->BV[master] / 65536.0 ));
1523 }
1524
1525 FT_TRACE4(( "]\n" ));
1526
1527 /* record the parameters used to build the blend vector */
1528 blend->lastVsindex = vsindex;
1529
1530 if ( lenNDV != 0 )
1531 {
1532 /* user has set a normalized vector */
1533 if ( FT_REALLOC( blend->lastNDV,
1534 blend->lenNDV * sizeof ( *NDV ),
1535 lenNDV * sizeof ( *NDV ) ) )
1536 goto Exit;
1537
1538 FT_MEM_COPY( blend->lastNDV,
1539 NDV,
1540 lenNDV * sizeof ( *NDV ) );
1541 }
1542
1543 blend->lenNDV = lenNDV;
1544 blend->builtBV = TRUE;
1545
1546 Exit:
1547 return error;
1548 }
#define FT_FIXED_ONE
Definition: cffload.c:38
#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:608
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
#define FT_REALLOC(ptr, cursz, newsz)
Definition: ftmemory.h:306
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
signed long FT_Fixed
Definition: fttypes.h:288
int FT_Error
Definition: fttypes.h:300
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:116
static vector_t * vs
Definition: server.c:127
static void Exit(void)
Definition: sock.c:1330
FT_Fixed startCoord
Definition: cfftypes.h:125
FT_Fixed peakCoord
Definition: cfftypes.h:126
FT_Fixed endCoord
Definition: cfftypes.h:127
FT_UInt lastVsindex
Definition: cfftypes.h:171
FT_UInt lenNDV
Definition: cfftypes.h:172
FT_Bool builtBV
Definition: cfftypes.h:168
CFF_Font font
Definition: cfftypes.h:170
FT_UInt lenBV
Definition: cfftypes.h:174
FT_Fixed * lastNDV
Definition: cfftypes.h:173
FT_Int32 * BV
Definition: cfftypes.h:175
CFF_VStoreRec vstore
Definition: cfftypes.h:399
FT_Memory memory
Definition: cfftypes.h:337
FT_UInt * regionIndices
Definition: cfftypes.h:117
FT_UInt regionIdxCount
Definition: cfftypes.h:116
CFF_AxisCoords * axisList
Definition: cfftypes.h:134
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 1554 of file cffload.c.

1558 {
1559 if ( !blend->builtBV ||
1560 blend->lastVsindex != vsindex ||
1561 blend->lenNDV != lenNDV ||
1562 ( lenNDV &&
1563 ft_memcmp( NDV,
1564 blend->lastNDV,
1565 lenNDV * sizeof ( *NDV ) ) != 0 ) )
1566 {
1567 /* need to build blend vector */
1568 return TRUE;
1569 }
1570
1571 return FALSE;
1572 }
#define ft_memcmp
Definition: ftstdlib.h:81

Referenced by cff_parse_blend().

◆ cff_blend_clear()

cff_blend_clear ( CFF_SubFont  subFont)

Definition at line 1262 of file cffload.c.

1263 {
1264 subFont->blend_top = subFont->blend_stack;
1265 subFont->blend_used = 0;
1266 }
FT_Byte * blend_top
Definition: cfftypes.h:317
FT_Byte * blend_stack
Definition: cfftypes.h:316
FT_UInt blend_used
Definition: cfftypes.h:318

Referenced by cff_load_private_dict().

◆ cff_blend_doBlend()

cff_blend_doBlend ( CFF_SubFont  subfont,
CFF_Parser  parser,
FT_UInt  numBlends 
)

Definition at line 1280 of file cffload.c.

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

866 {
867 FT_UInt result = 0;
868
869
870 if ( cid <= charset->max_cid )
872
873 return result;
874 }
CFF_Charset charset
Definition: cffcmap.c:138
GLuint64EXT * result
Definition: glext.h:11304
static TfClientId cid
FT_UShort * cids
Definition: cfftypes.h:99

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 750 of file cffload.c.

752 {
753 FT_Byte fd = 0;
754
755
756 /* if there is no FDSelect, return zero */
757 /* Note: CFF2 with just one Font Dict has no FDSelect */
758 if ( !fdselect->data )
759 goto Exit;
760
761 switch ( fdselect->format )
762 {
763 case 0:
764 fd = fdselect->data[glyph_index];
765 break;
766
767 case 3:
768 /* first, compare to the cache */
769 if ( (FT_UInt)( glyph_index - fdselect->cache_first ) <
770 fdselect->cache_count )
771 {
772 fd = fdselect->cache_fd;
773 break;
774 }
775
776 /* then, look up the ranges array */
777 {
778 FT_Byte* p = fdselect->data;
779 FT_Byte* p_limit = p + fdselect->data_size;
780 FT_Byte fd2;
782
783
785 do
786 {
787 if ( glyph_index < first )
788 break;
789
790 fd2 = *p++;
792
793 if ( glyph_index < limit )
794 {
795 fd = fd2;
796
797 /* update cache */
798 fdselect->cache_first = first;
799 fdselect->cache_count = limit - first;
800 fdselect->cache_fd = fd2;
801 break;
802 }
803 first = limit;
804
805 } while ( p < p_limit );
806 }
807 break;
808
809 default:
810 ;
811 }
812
813 Exit:
814 return fd;
815 }
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
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:289
FT_Byte cache_fd
Definition: cfftypes.h:291
FT_UInt cache_count
Definition: cfftypes.h:290
FT_Byte * data
Definition: cfftypes.h:285
FT_Byte format
Definition: cfftypes.h:281
FT_UInt data_size
Definition: cfftypes.h:286

Referenced by cff_slot_load().

◆ cff_font_done()

cff_font_done ( CFF_Font  font)

Definition at line 2499 of file cffload.c.

2500 {
2501 FT_Memory memory = font->memory;
2502 FT_UInt idx;
2503
2504
2505 cff_index_done( &font->global_subrs_index );
2506 cff_index_done( &font->font_dict_index );
2507 cff_index_done( &font->name_index );
2508 cff_index_done( &font->charstrings_index );
2509
2510 /* release font dictionaries, but only if working with */
2511 /* a CID keyed CFF font or a CFF2 font */
2512 if ( font->num_subfonts > 0 )
2513 {
2514 for ( idx = 0; idx < font->num_subfonts; idx++ )
2515 cff_subfont_done( memory, font->subfonts[idx] );
2516
2517 /* the subfonts array has been allocated as a single block */
2518 FT_FREE( font->subfonts[0] );
2519 }
2520
2521 cff_encoding_done( &font->encoding );
2522 cff_charset_done( &font->charset, font->stream );
2523 cff_vstore_done( &font->vstore, memory );
2524
2525 cff_subfont_done( memory, &font->top_font );
2526
2527 CFF_Done_FD_Select( &font->fd_select, font->stream );
2528
2529 FT_FREE( font->font_info );
2530
2531 FT_FREE( font->font_name );
2532 FT_FREE( font->global_subrs );
2533 FT_FREE( font->strings );
2534 FT_FREE( font->string_pool );
2535
2536 if ( font->cf2_instance.finalizer )
2537 {
2538 font->cf2_instance.finalizer( font->cf2_instance.data );
2539 FT_FREE( font->cf2_instance.data );
2540 }
2541
2542 FT_FREE( font->font_extra );
2543 }
static void cff_subfont_done(FT_Memory memory, CFF_SubFont subfont)
Definition: cffload.c:2135
static void cff_index_done(CFF_Index idx)
Definition: cffload.c:324
static void CFF_Done_FD_Select(CFF_FDSelect fdselect, FT_Stream stream)
Definition: cffload.c:686
static void cff_vstore_done(CFF_VStoreRec *vstore, FT_Memory memory)
Definition: cffload.c:1092
static void cff_encoding_done(CFF_Encoding encoding)
Definition: cffload.c:1609
static void cff_charset_done(CFF_Charset charset, FT_Stream stream)
Definition: cffload.c:887
#define FT_FREE(ptr)
Definition: ftmemory.h:329
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 2151 of file cffload.c.

2158 {
2159 static const FT_Frame_Field cff_header_fields[] =
2160 {
2161#undef FT_STRUCTURE
2162#define FT_STRUCTURE CFF_FontRec
2163
2164 FT_FRAME_START( 3 ),
2165 FT_FRAME_BYTE( version_major ),
2166 FT_FRAME_BYTE( version_minor ),
2167 FT_FRAME_BYTE( header_size ),
2169 };
2170
2172 FT_Memory memory = stream->memory;
2173 FT_ULong base_offset;
2174 CFF_FontRecDict dict;
2176 FT_UInt subfont_index;
2177
2178
2179 FT_ZERO( font );
2181
2182 dict = &font->top_font.font_dict;
2183 base_offset = FT_STREAM_POS();
2184
2185 font->library = library;
2186 font->stream = stream;
2187 font->memory = memory;
2188 font->cff2 = cff2;
2189 font->base_offset = base_offset;
2190
2191 /* read CFF font header */
2192 if ( FT_STREAM_READ_FIELDS( cff_header_fields, font ) )
2193 goto Exit;
2194
2195 if ( cff2 )
2196 {
2197 if ( font->version_major != 2 ||
2198 font->header_size < 5 )
2199 {
2200 FT_TRACE2(( " not a CFF2 font header\n" ));
2201 error = FT_THROW( Unknown_File_Format );
2202 goto Exit;
2203 }
2204
2205 if ( FT_READ_USHORT( font->top_dict_length ) )
2206 goto Exit;
2207 }
2208 else
2209 {
2210 FT_Byte absolute_offset;
2211
2212
2213 if ( FT_READ_BYTE( absolute_offset ) )
2214 goto Exit;
2215
2216 if ( font->version_major != 1 ||
2217 font->header_size < 4 ||
2218 absolute_offset > 4 )
2219 {
2220 FT_TRACE2(( " not a CFF font header\n" ));
2221 error = FT_THROW( Unknown_File_Format );
2222 goto Exit;
2223 }
2224 }
2225
2226 /* skip the rest of the header */
2227 if ( FT_STREAM_SEEK( base_offset + font->header_size ) )
2228 {
2229 /* For pure CFFs we have read only four bytes so far. Contrary to */
2230 /* other formats like SFNT those bytes doesn't define a signature; */
2231 /* it is thus possible that the font isn't a CFF at all. */
2232 if ( pure_cff )
2233 {
2234 FT_TRACE2(( " not a CFF file\n" ));
2235 error = FT_THROW( Unknown_File_Format );
2236 }
2237 goto Exit;
2238 }
2239
2240 if ( cff2 )
2241 {
2242 /* For CFF2, the top dict data immediately follow the header */
2243 /* and the length is stored in the header `offSize' field; */
2244 /* there is no index for it. */
2245 /* */
2246 /* Use the `font_dict_index' to save the current position */
2247 /* and length of data, but leave count at zero as an indicator. */
2248 FT_ZERO( &font->font_dict_index );
2249
2250 font->font_dict_index.data_offset = FT_STREAM_POS();
2251 font->font_dict_index.data_size = font->top_dict_length;
2252
2253 /* skip the top dict data for now, we will parse it later */
2254 if ( FT_STREAM_SKIP( font->top_dict_length ) )
2255 goto Exit;
2256
2257 /* next, read the global subrs index */
2258 if ( FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
2259 stream, 1, cff2 ) ) )
2260 goto Exit;
2261 }
2262 else
2263 {
2264 /* for CFF, read the name, top dict, string and global subrs index */
2265 if ( FT_SET_ERROR( cff_index_init( &font->name_index,
2266 stream, 0, cff2 ) ) )
2267 {
2268 if ( pure_cff )
2269 {
2270 FT_TRACE2(( " not a CFF file\n" ));
2271 error = FT_THROW( Unknown_File_Format );
2272 }
2273 goto Exit;
2274 }
2275
2276 /* if we have an empty font name, */
2277 /* it must be the only font in the CFF */
2278 if ( font->name_index.count > 1 &&
2279 font->name_index.data_size < font->name_index.count )
2280 {
2281 /* for pure CFFs, we still haven't checked enough bytes */
2282 /* to be sure that it is a CFF at all */
2283 error = pure_cff ? FT_THROW( Unknown_File_Format )
2284 : FT_THROW( Invalid_File_Format );
2285 goto Exit;
2286 }
2287
2288 if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index,
2289 stream, 0, cff2 ) ) ||
2291 stream, 1, cff2 ) ) ||
2292 FT_SET_ERROR( cff_index_init( &font->global_subrs_index,
2293 stream, 1, cff2 ) ) ||
2295 &font->strings,
2296 &font->string_pool,
2297 &font->string_pool_size ) ) )
2298 goto Exit;
2299
2300 /* there must be a Top DICT index entry for each name index entry */
2301 if ( font->name_index.count > font->font_dict_index.count )
2302 {
2303 FT_ERROR(( "cff_font_load:"
2304 " not enough entries in Top DICT index\n" ));
2305 error = FT_THROW( Invalid_File_Format );
2306 goto Exit;
2307 }
2308 }
2309
2310 font->num_strings = string_index.count;
2311
2312 if ( pure_cff )
2313 {
2314 /* well, we don't really forget the `disabled' fonts... */
2315 subfont_index = (FT_UInt)( face_index & 0xFFFF );
2316
2317 if ( face_index > 0 && subfont_index >= font->name_index.count )
2318 {
2319 FT_ERROR(( "cff_font_load:"
2320 " invalid subfont index for pure CFF font (%d)\n",
2321 subfont_index ));
2322 error = FT_THROW( Invalid_Argument );
2323 goto Exit;
2324 }
2325
2326 font->num_faces = font->name_index.count;
2327 }
2328 else
2329 {
2330 subfont_index = 0;
2331
2332 if ( font->name_index.count > 1 )
2333 {
2334 FT_ERROR(( "cff_font_load:"
2335 " invalid CFF font with multiple subfonts\n"
2336 " "
2337 " in SFNT wrapper\n" ));
2338 error = FT_THROW( Invalid_File_Format );
2339 goto Exit;
2340 }
2341 }
2342
2343 /* in case of a font format check, simply exit now */
2344 if ( face_index < 0 )
2345 goto Exit;
2346
2347 /* now, parse the top-level font dictionary */
2348 FT_TRACE4(( "parsing top-level\n" ));
2349 error = cff_subfont_load( &font->top_font,
2350 &font->font_dict_index,
2351 subfont_index,
2352 stream,
2353 base_offset,
2355 font,
2356 face );
2357 if ( error )
2358 goto Exit;
2359
2360 if ( FT_STREAM_SEEK( base_offset + dict->charstrings_offset ) )
2361 goto Exit;
2362
2363 error = cff_index_init( &font->charstrings_index, stream, 0, cff2 );
2364 if ( error )
2365 goto Exit;
2366
2367 /* now, check for a CID or CFF2 font */
2368 if ( dict->cid_registry != 0xFFFFU ||
2369 cff2 )
2370 {
2371 CFF_IndexRec fd_index;
2372 CFF_SubFont sub = NULL;
2373 FT_UInt idx;
2374
2375
2376 /* for CFF2, read the Variation Store if available; */
2377 /* this must follow the Top DICT parse and precede any Private DICT */
2378 error = cff_vstore_load( &font->vstore,
2379 stream,
2380 base_offset,
2381 dict->vstore_offset );
2382 if ( error )
2383 goto Exit;
2384
2385 /* this is a CID-keyed font, we must now allocate a table of */
2386 /* sub-fonts, then load each of them separately */
2387 if ( FT_STREAM_SEEK( base_offset + dict->cid_fd_array_offset ) )
2388 goto Exit;
2389
2390 error = cff_index_init( &fd_index, stream, 0, cff2 );
2391 if ( error )
2392 goto Exit;
2393
2394 /* Font Dicts are not limited to 256 for CFF2. */
2395 /* TODO: support this for CFF2 */
2396 if ( fd_index.count > CFF_MAX_CID_FONTS )
2397 {
2398 FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
2399 goto Fail_CID;
2400 }
2401
2402 /* allocate & read each font dict independently */
2403 font->num_subfonts = fd_index.count;
2404 if ( FT_NEW_ARRAY( sub, fd_index.count ) )
2405 goto Fail_CID;
2406
2407 /* set up pointer table */
2408 for ( idx = 0; idx < fd_index.count; idx++ )
2409 font->subfonts[idx] = sub + idx;
2410
2411 /* now load each subfont independently */
2412 for ( idx = 0; idx < fd_index.count; idx++ )
2413 {
2414 sub = font->subfonts[idx];
2415 FT_TRACE4(( "parsing subfont %u\n", idx ));
2416 error = cff_subfont_load( sub,
2417 &fd_index,
2418 idx,
2419 stream,
2420 base_offset,
2421 cff2 ? CFF2_CODE_FONTDICT
2423 font,
2424 face );
2425 if ( error )
2426 goto Fail_CID;
2427 }
2428
2429 /* now load the FD Select array; */
2430 /* CFF2 omits FDSelect if there is only one FD */
2431 if ( !cff2 || fd_index.count > 1 )
2432 error = CFF_Load_FD_Select( &font->fd_select,
2433 font->charstrings_index.count,
2434 stream,
2435 base_offset + dict->cid_fd_select_offset );
2436
2437 Fail_CID:
2438 cff_index_done( &fd_index );
2439
2440 if ( error )
2441 goto Exit;
2442 }
2443 else
2444 font->num_subfonts = 0;
2445
2446 /* read the charstrings index now */
2447 if ( dict->charstrings_offset == 0 )
2448 {
2449 FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
2450 error = FT_THROW( Invalid_File_Format );
2451 goto Exit;
2452 }
2453
2454 font->num_glyphs = font->charstrings_index.count;
2455
2456 error = cff_index_get_pointers( &font->global_subrs_index,
2457 &font->global_subrs, NULL, NULL );
2458
2459 if ( error )
2460 goto Exit;
2461
2462 /* read the Charset and Encoding tables if available */
2463 if ( !cff2 && font->num_glyphs > 0 )
2464 {
2465 FT_Bool invert = FT_BOOL( dict->cid_registry != 0xFFFFU && pure_cff );
2466
2467
2468 error = cff_charset_load( &font->charset, font->num_glyphs, stream,
2469 base_offset, dict->charset_offset, invert );
2470 if ( error )
2471 goto Exit;
2472
2473 /* CID-keyed CFFs don't have an encoding */
2474 if ( dict->cid_registry == 0xFFFFU )
2475 {
2476 error = cff_encoding_load( &font->encoding,
2477 &font->charset,
2478 font->num_glyphs,
2479 stream,
2480 base_offset,
2481 dict->encoding_offset );
2482 if ( error )
2483 goto Exit;
2484 }
2485 }
2486
2487 /* get the font name (/CIDFontName for CID-keyed fonts, */
2488 /* /FontName otherwise) */
2489 font->font_name = cff_index_get_name( font, subfont_index );
2490
2491 Exit:
2493
2494 return error;
2495 }
FT_Library library
Definition: cffdrivr.c:654
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:902
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:1618
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:1954
static FT_Error cff_index_init(CFF_Index idx, FT_Stream stream, FT_Bool load, FT_Bool cff2)
Definition: cffload.c:235
static FT_Error CFF_Load_FD_Select(CFF_FDSelect fdselect, FT_UInt num_glyphs, FT_Stream stream, FT_ULong offset)
Definition: cffload.c:699
static FT_Error cff_vstore_load(CFF_VStoreRec *vstore, FT_Stream stream, FT_ULong base_offset, FT_ULong offset)
Definition: cffload.c:1121
cff_index_get_name(CFF_Font font, FT_UInt element)
Definition: cffload.c:611
static FT_Error cff_index_get_pointers(CFF_Index idx, FT_Byte ***table, FT_Byte **pool, FT_ULong *pool_size)
Definition: cffload.c:406
#define CFF_CODE_TOPDICT
Definition: cffparse.h:45
#define CFF2_CODE_FONTDICT
Definition: cffparse.h:48
#define CFF2_CODE_TOPDICT
Definition: cffparse.h:47
FT_BEGIN_HEADER struct CFF_IndexRec_ CFF_IndexRec
#define CFF_MAX_CID_FONTS
Definition: cfftypes.h:330
#define NULL
Definition: types.h:112
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:42
#define FT_ZERO(p)
Definition: ftmemory.h:237
#define FT_READ_USHORT(var)
Definition: ftstream.h:309
#define FT_FRAME_END
Definition: ftstream.h:118
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
#define FT_STREAM_POS()
Definition: ftstream.h:486
#define FT_FRAME_BYTE(f)
Definition: ftstream.h:126
#define FT_READ_BYTE(var)
Definition: ftstream.h:306
#define FT_STREAM_READ_FIELDS(fields, object)
Definition: ftstream.h:508
#define FT_STREAM_SKIP(distance)
Definition: ftstream.h:493
#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:578
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:219
FT_ULong charset_offset
Definition: cfftypes.h:201
FT_ULong cid_fd_select_offset
Definition: cfftypes.h:220
FT_UInt cid_registry
Definition: cfftypes.h:210
FT_ULong charstrings_offset
Definition: cfftypes.h:203
FT_ULong encoding_offset
Definition: cfftypes.h:202
FT_ULong vstore_offset
Definition: cfftypes.h:230
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 192 of file cffload.c.

193 {
194 return (FT_UShort)( charcode < 256 ? cff_standard_encoding[charcode]
195 : 0 );
196 }
static const FT_UShort cff_standard_encoding[256]
Definition: cffload.c:116
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 498 of file cffload.c.

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

598 {
599 if ( idx->bytes == 0 )
600 {
601 FT_Stream stream = idx->stream;
602
603
604 FT_FRAME_RELEASE( *pbytes );
605 }
606 }
#define FT_FRAME_RELEASE(bytes)
Definition: ftstream.h:526

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 611 of file cffload.c.

613 {
614 CFF_Index idx = &font->name_index;
616 FT_Byte* bytes;
617 FT_ULong byte_len;
619 FT_String* name = 0;
620
621
622 if ( !idx->stream ) /* CFF2 does not include a name index */
623 goto Exit;
624
625 memory = idx->stream->memory;
626
628 if ( error )
629 goto Exit;
630
631 if ( !FT_ALLOC( name, byte_len + 1 ) )
632 {
633 if ( byte_len )
634 FT_MEM_COPY( name, bytes, byte_len );
635 name[byte_len] = 0;
636 }
638
639 Exit:
640 return name;
641 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
cff_index_forget_element(CFF_Index idx, FT_Byte **pbytes)
Definition: cffload.c:596
cff_index_access_element(CFF_Index idx, FT_UInt element, FT_Byte **pbytes, FT_ULong *pbyte_len)
Definition: cffload.c:498
FT_BEGIN_HEADER struct CFF_IndexRec_ * CFF_Index
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
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 656 of file cffload.c.

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

◆ cff_index_get_string()

cff_index_get_string ( CFF_Font  font,
FT_UInt  element 
)

Definition at line 646 of file cffload.c.

648 {
649 return ( element < font->num_strings )
650 ? (FT_String*)font->strings[element]
651 : NULL;
652 }

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 1865 of file cffload.c.

1869 {
1872 CFF_FontRecDict top = &subfont->font_dict;
1873 CFF_Private priv = &subfont->private_dict;
1874 FT_Stream stream = font->stream;
1875 FT_UInt stackSize;
1876
1877
1878 /* store handle needed to access memory, vstore for blend; */
1879 /* we need this for clean-up even if there is no private DICT */
1880 subfont->blend.font = font;
1881 subfont->blend.usedBV = FALSE; /* clear state */
1882
1883 if ( !top->private_offset || !top->private_size )
1884 goto Exit2; /* no private DICT, do nothing */
1885
1886 /* set defaults */
1887 FT_ZERO( priv );
1888
1889 priv->blue_shift = 7;
1890 priv->blue_fuzz = 1;
1891 priv->lenIV = -1;
1892 priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
1893 priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
1894
1895 /* provide inputs for blend calculations */
1896 priv->subfont = subfont;
1897 subfont->lenNDV = lenNDV;
1898 subfont->NDV = NDV;
1899
1900 /* add 1 for the operator */
1901 stackSize = font->cff2 ? font->top_font.font_dict.maxstack + 1
1902 : CFF_MAX_STACK_DEPTH + 1;
1903
1904 if ( cff_parser_init( &parser,
1906 priv,
1907 font->library,
1908 stackSize,
1909 top->num_designs,
1910 top->num_axes ) )
1911 goto Exit;
1912
1913 if ( FT_STREAM_SEEK( font->base_offset + top->private_offset ) ||
1914 FT_FRAME_ENTER( top->private_size ) )
1915 goto Exit;
1916
1917 FT_TRACE4(( " private dictionary:\n" ));
1919 (FT_Byte*)stream->cursor,
1920 (FT_Byte*)stream->limit );
1921 FT_FRAME_EXIT();
1922
1923 if ( error )
1924 goto Exit;
1925
1926 /* ensure that `num_blue_values' is even */
1927 priv->num_blue_values &= ~1;
1928
1929 /* sanitize `initialRandomSeed' to be a positive value, if necessary; */
1930 /* this is not mandated by the specification but by our implementation */
1931 if ( priv->initial_random_seed < 0 )
1933 else if ( priv->initial_random_seed == 0 )
1934 priv->initial_random_seed = 987654321;
1935
1936 Exit:
1937 /* clean up */
1938 cff_blend_clear( subfont ); /* clear blend stack */
1939 cff_parser_done( &parser ); /* free parser stack */
1940
1941 Exit2:
1942 /* no clean up (parser not initialized) */
1943 return error;
1944 }
cff_blend_clear(CFF_SubFont subFont)
Definition: cffload.c:1262
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:42
cff_parser_done(CFF_Parser parser)
Definition: cffparse.c:81
cff_parser_run(CFF_Parser parser, FT_Byte *start, FT_Byte *limit)
Definition: cffparse.c:1300
#define CFF2_CODE_PRIVATE
Definition: cffparse.h:49
#define CFF_CODE_PRIVATE
Definition: cffparse.h:46
#define CFF_MAX_STACK_DEPTH
Definition: cffparse.h:33
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
FT_Bool usedBV
Definition: cfftypes.h:169
FT_Byte num_blue_values
Definition: cfftypes.h:242
CFF_SubFont subfont
Definition: cfftypes.h:274
FT_Int lenIV
Definition: cfftypes.h:264
FT_Long initial_random_seed
Definition: cfftypes.h:267
FT_Fixed blue_scale
Definition: cfftypes.h:252
FT_Pos blue_fuzz
Definition: cfftypes.h:254
FT_Fixed expansion_factor
Definition: cfftypes.h:266
FT_Pos blue_shift
Definition: cfftypes.h:253
FT_Fixed * NDV
Definition: cfftypes.h:306
FT_UInt lenNDV
Definition: cfftypes.h:305
CFF_PrivateRec private_dict
Definition: cfftypes.h:301
CFF_BlendRec blend
Definition: cfftypes.h:304
CFF_FontRecDictRec font_dict
Definition: cfftypes.h:300

Referenced by cff_subfont_load().