From 332064c92a01296b5dd2d25524d0f8286ccdd107 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Tue, 9 Jan 2018 06:16:46 +0000 Subject: freetype 2.9.0 git-svn-id: svn://tug.org/texlive/trunk@46256 c570f23f-e606-0410-a88d-b1316a301751 --- .../libs/freetype2/freetype-src/src/cff/Jamfile | 11 +- .../libs/freetype2/freetype-src/src/cff/cf2arrst.c | 241 -- .../libs/freetype2/freetype-src/src/cff/cf2arrst.h | 100 - .../libs/freetype2/freetype-src/src/cff/cf2blues.c | 582 ----- .../libs/freetype2/freetype-src/src/cff/cf2blues.h | 185 -- .../libs/freetype2/freetype-src/src/cff/cf2error.c | 52 - .../libs/freetype2/freetype-src/src/cff/cf2error.h | 119 - .../libs/freetype2/freetype-src/src/cff/cf2fixed.h | 95 - .../libs/freetype2/freetype-src/src/cff/cf2font.c | 562 ---- .../libs/freetype2/freetype-src/src/cff/cf2font.h | 130 - .../libs/freetype2/freetype-src/src/cff/cf2ft.c | 755 ------ .../libs/freetype2/freetype-src/src/cff/cf2ft.h | 159 -- .../libs/freetype2/freetype-src/src/cff/cf2glue.h | 144 -- .../libs/freetype2/freetype-src/src/cff/cf2hints.c | 1875 -------------- .../libs/freetype2/freetype-src/src/cff/cf2hints.h | 289 --- .../libs/freetype2/freetype-src/src/cff/cf2intrp.c | 1959 -------------- .../libs/freetype2/freetype-src/src/cff/cf2intrp.h | 83 - .../libs/freetype2/freetype-src/src/cff/cf2read.c | 112 - .../libs/freetype2/freetype-src/src/cff/cf2read.h | 68 - .../libs/freetype2/freetype-src/src/cff/cf2stack.c | 328 --- .../libs/freetype2/freetype-src/src/cff/cf2stack.h | 121 - .../libs/freetype2/freetype-src/src/cff/cf2types.h | 78 - .../libs/freetype2/freetype-src/src/cff/cff.c | 13 +- .../libs/freetype2/freetype-src/src/cff/cffcmap.c | 2 +- .../libs/freetype2/freetype-src/src/cff/cffcmap.h | 4 +- .../libs/freetype2/freetype-src/src/cff/cffdrivr.c | 381 +-- .../libs/freetype2/freetype-src/src/cff/cffdrivr.h | 2 +- .../libs/freetype2/freetype-src/src/cff/cfferrs.h | 2 +- .../libs/freetype2/freetype-src/src/cff/cffgload.c | 2729 +------------------- .../libs/freetype2/freetype-src/src/cff/cffgload.h | 187 +- .../libs/freetype2/freetype-src/src/cff/cffload.c | 66 +- .../libs/freetype2/freetype-src/src/cff/cffload.h | 9 +- .../libs/freetype2/freetype-src/src/cff/cffobjs.c | 120 +- .../libs/freetype2/freetype-src/src/cff/cffobjs.h | 106 +- .../libs/freetype2/freetype-src/src/cff/cffparse.c | 27 +- .../libs/freetype2/freetype-src/src/cff/cffparse.h | 4 +- .../libs/freetype2/freetype-src/src/cff/cffpic.c | 2 +- .../libs/freetype2/freetype-src/src/cff/cffpic.h | 7 +- .../libs/freetype2/freetype-src/src/cff/cfftoken.h | 2 +- .../libs/freetype2/freetype-src/src/cff/cfftypes.h | 405 --- .../libs/freetype2/freetype-src/src/cff/module.mk | 2 +- .../libs/freetype2/freetype-src/src/cff/rules.mk | 19 +- 42 files changed, 365 insertions(+), 11772 deletions(-) delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h delete mode 100644 Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h (limited to 'Build/source/libs/freetype2/freetype-src/src/cff') diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile index e6dd05fc15a..53c904fcfe2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile +++ b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile @@ -1,6 +1,6 @@ # FreeType 2 src/cff Jamfile # -# Copyright 2001-2017 by +# Copyright 2001-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -23,15 +23,6 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ; cffobjs cffparse cffpic - cf2arrst - cf2blues - cf2error - cf2font - cf2ft - cf2hints - cf2intrp - cf2read - cf2stack ; } else diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c deleted file mode 100644 index 6796450fe10..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.c +++ /dev/null @@ -1,241 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2arrst.c */ -/* */ -/* Adobe's code for Array Stacks (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2glue.h" -#include "cf2arrst.h" - -#include "cf2error.h" - - - /* - * CF2_ArrStack uses an error pointer, to enable shared errors. - * Shared errors are necessary when multiple objects allow the program - * to continue after detecting errors. Only the first error should be - * recorded. - */ - - FT_LOCAL_DEF( void ) - cf2_arrstack_init( CF2_ArrStack arrstack, - FT_Memory memory, - FT_Error* error, - size_t sizeItem ) - { - FT_ASSERT( arrstack ); - - /* initialize the structure */ - arrstack->memory = memory; - arrstack->error = error; - arrstack->sizeItem = sizeItem; - arrstack->allocated = 0; - arrstack->chunk = 10; /* chunks of 10 items */ - arrstack->count = 0; - arrstack->totalSize = 0; - arrstack->ptr = NULL; - } - - - FT_LOCAL_DEF( void ) - cf2_arrstack_finalize( CF2_ArrStack arrstack ) - { - FT_Memory memory = arrstack->memory; /* for FT_FREE */ - - - FT_ASSERT( arrstack ); - - arrstack->allocated = 0; - arrstack->count = 0; - arrstack->totalSize = 0; - - /* free the data buffer */ - FT_FREE( arrstack->ptr ); - } - - - /* allocate or reallocate the buffer size; */ - /* return false on memory error */ - static FT_Bool - cf2_arrstack_setNumElements( CF2_ArrStack arrstack, - size_t numElements ) - { - FT_ASSERT( arrstack ); - - { - FT_Error error = FT_Err_Ok; /* for FT_REALLOC */ - FT_Memory memory = arrstack->memory; /* for FT_REALLOC */ - - size_t newSize = numElements * arrstack->sizeItem; - - - if ( numElements > FT_LONG_MAX / arrstack->sizeItem ) - goto exit; - - - FT_ASSERT( newSize > 0 ); /* avoid realloc with zero size */ - - if ( !FT_REALLOC( arrstack->ptr, arrstack->totalSize, newSize ) ) - { - arrstack->allocated = numElements; - arrstack->totalSize = newSize; - - if ( arrstack->count > numElements ) - { - /* we truncated the list! */ - CF2_SET_ERROR( arrstack->error, Stack_Overflow ); - arrstack->count = numElements; - return FALSE; - } - - return TRUE; /* success */ - } - } - - exit: - /* if there's not already an error, store this one */ - CF2_SET_ERROR( arrstack->error, Out_Of_Memory ); - - return FALSE; - } - - - /* set the count, ensuring allocation is sufficient */ - FT_LOCAL_DEF( void ) - cf2_arrstack_setCount( CF2_ArrStack arrstack, - size_t numElements ) - { - FT_ASSERT( arrstack ); - - if ( numElements > arrstack->allocated ) - { - /* expand the allocation first */ - if ( !cf2_arrstack_setNumElements( arrstack, numElements ) ) - return; - } - - arrstack->count = numElements; - } - - - /* clear the count */ - FT_LOCAL_DEF( void ) - cf2_arrstack_clear( CF2_ArrStack arrstack ) - { - FT_ASSERT( arrstack ); - - arrstack->count = 0; - } - - - /* current number of items */ - FT_LOCAL_DEF( size_t ) - cf2_arrstack_size( const CF2_ArrStack arrstack ) - { - FT_ASSERT( arrstack ); - - return arrstack->count; - } - - - FT_LOCAL_DEF( void* ) - cf2_arrstack_getBuffer( const CF2_ArrStack arrstack ) - { - FT_ASSERT( arrstack ); - - return arrstack->ptr; - } - - - /* return pointer to the given element */ - FT_LOCAL_DEF( void* ) - cf2_arrstack_getPointer( const CF2_ArrStack arrstack, - size_t idx ) - { - void* newPtr; - - - FT_ASSERT( arrstack ); - - if ( idx >= arrstack->count ) - { - /* overflow */ - CF2_SET_ERROR( arrstack->error, Stack_Overflow ); - idx = 0; /* choose safe default */ - } - - newPtr = (FT_Byte*)arrstack->ptr + idx * arrstack->sizeItem; - - return newPtr; - } - - - /* push (append) an element at the end of the list; */ - /* return false on memory error */ - /* TODO: should there be a length param for extra checking? */ - FT_LOCAL_DEF( void ) - cf2_arrstack_push( CF2_ArrStack arrstack, - const void* ptr ) - { - FT_ASSERT( arrstack ); - - if ( arrstack->count == arrstack->allocated ) - { - /* grow the buffer by one chunk */ - if ( !cf2_arrstack_setNumElements( - arrstack, arrstack->allocated + arrstack->chunk ) ) - { - /* on error, ignore the push */ - return; - } - } - - FT_ASSERT( ptr ); - - { - size_t offset = arrstack->count * arrstack->sizeItem; - void* newPtr = (FT_Byte*)arrstack->ptr + offset; - - - FT_MEM_COPY( newPtr, ptr, arrstack->sizeItem ); - arrstack->count += 1; - } - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h deleted file mode 100644 index 3c21a3b6727..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2arrst.h +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2arrst.h */ -/* */ -/* Adobe's code for Array Stacks (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2ARRST_H_ -#define CF2ARRST_H_ - - -#include "cf2error.h" - - -FT_BEGIN_HEADER - - - /* need to define the struct here (not opaque) so it can be allocated by */ - /* clients */ - typedef struct CF2_ArrStackRec_ - { - FT_Memory memory; - FT_Error* error; - - size_t sizeItem; /* bytes per element */ - size_t allocated; /* items allocated */ - size_t chunk; /* allocation increment in items */ - size_t count; /* number of elements allocated */ - size_t totalSize; /* total bytes allocated */ - - void* ptr; /* ptr to data */ - - } CF2_ArrStackRec, *CF2_ArrStack; - - - FT_LOCAL( void ) - cf2_arrstack_init( CF2_ArrStack arrstack, - FT_Memory memory, - FT_Error* error, - size_t sizeItem ); - FT_LOCAL( void ) - cf2_arrstack_finalize( CF2_ArrStack arrstack ); - - FT_LOCAL( void ) - cf2_arrstack_setCount( CF2_ArrStack arrstack, - size_t numElements ); - FT_LOCAL( void ) - cf2_arrstack_clear( CF2_ArrStack arrstack ); - FT_LOCAL( size_t ) - cf2_arrstack_size( const CF2_ArrStack arrstack ); - - FT_LOCAL( void* ) - cf2_arrstack_getBuffer( const CF2_ArrStack arrstack ); - FT_LOCAL( void* ) - cf2_arrstack_getPointer( const CF2_ArrStack arrstack, - size_t idx ); - - FT_LOCAL( void ) - cf2_arrstack_push( CF2_ArrStack arrstack, - const void* ptr ); - - -FT_END_HEADER - - -#endif /* CF2ARRST_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c deleted file mode 100644 index c491f2f9e5c..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.c +++ /dev/null @@ -1,582 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2blues.c */ -/* */ -/* Adobe's code for handling Blue Zones (body). */ -/* */ -/* Copyright 2009-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2blues.h" -#include "cf2hints.h" -#include "cf2font.h" - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_cf2blues - - - /* - * For blue values, the FreeType parser produces an array of integers, - * while the Adobe CFF engine produces an array of fixed. - * Define a macro to convert FreeType to fixed. - */ -#define cf2_blueToFixed( x ) cf2_intToFixed( x ) - - - FT_LOCAL_DEF( void ) - cf2_blues_init( CF2_Blues blues, - CF2_Font font ) - { - /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; - - CF2_Fixed zoneHeight; - CF2_Fixed maxZoneHeight = 0; - CF2_Fixed csUnitsPerPixel; - - size_t numBlueValues; - size_t numOtherBlues; - size_t numFamilyBlues; - size_t numFamilyOtherBlues; - - FT_Pos* blueValues; - FT_Pos* otherBlues; - FT_Pos* familyBlues; - FT_Pos* familyOtherBlues; - - size_t i; - CF2_Fixed emBoxBottom, emBoxTop; - -#if 0 - CF2_Int unitsPerEm = font->unitsPerEm; - - - if ( unitsPerEm == 0 ) - unitsPerEm = 1000; -#endif - - FT_ZERO( blues ); - blues->scale = font->innerTransform.d; - - cf2_getBlueMetrics( decoder, - &blues->blueScale, - &blues->blueShift, - &blues->blueFuzz ); - - cf2_getBlueValues( decoder, &numBlueValues, &blueValues ); - cf2_getOtherBlues( decoder, &numOtherBlues, &otherBlues ); - cf2_getFamilyBlues( decoder, &numFamilyBlues, &familyBlues ); - cf2_getFamilyOtherBlues( decoder, &numFamilyOtherBlues, &familyOtherBlues ); - - /* - * synthetic em box hint heuristic - * - * Apply this when ideographic dictionary (LanguageGroup 1) has no - * real alignment zones. Adobe tools generate dummy zones at -250 and - * 1100 for a 1000 unit em. Fonts with ICF-based alignment zones - * should not enable the heuristic. When the heuristic is enabled, - * the font's blue zones are ignored. - * - */ - - /* get em box from OS/2 typoAscender/Descender */ - /* TODO: FreeType does not parse these metrics. Skip them for now. */ -#if 0 - FCM_getHorizontalLineMetrics( &e, - font->font, - &ascender, - &descender, - &linegap ); - if ( ascender - descender == unitsPerEm ) - { - emBoxBottom = cf2_intToFixed( descender ); - emBoxTop = cf2_intToFixed( ascender ); - } - else -#endif - { - emBoxBottom = CF2_ICF_Bottom; - emBoxTop = CF2_ICF_Top; - } - - if ( cf2_getLanguageGroup( decoder ) == 1 && - ( numBlueValues == 0 || - ( numBlueValues == 4 && - cf2_blueToFixed( blueValues[0] ) < emBoxBottom && - cf2_blueToFixed( blueValues[1] ) < emBoxBottom && - cf2_blueToFixed( blueValues[2] ) > emBoxTop && - cf2_blueToFixed( blueValues[3] ) > emBoxTop ) ) ) - { - /* - * Construct hint edges suitable for synthetic ghost hints at top - * and bottom of em box. +-CF2_MIN_COUNTER allows for unhinted - * features above or below the last hinted edge. This also gives a - * net 1 pixel boost to the height of ideographic glyphs. - * - * Note: Adjust synthetic hints outward by epsilon (0x.0001) to - * avoid interference. E.g., some fonts have real hints at - * 880 and -120. - */ - - blues->emBoxBottomEdge.csCoord = emBoxBottom - CF2_FIXED_EPSILON; - blues->emBoxBottomEdge.dsCoord = cf2_fixedRound( - FT_MulFix( - blues->emBoxBottomEdge.csCoord, - blues->scale ) ) - - CF2_MIN_COUNTER; - blues->emBoxBottomEdge.scale = blues->scale; - blues->emBoxBottomEdge.flags = CF2_GhostBottom | - CF2_Locked | - CF2_Synthetic; - - blues->emBoxTopEdge.csCoord = emBoxTop + CF2_FIXED_EPSILON + - 2 * font->darkenY; - blues->emBoxTopEdge.dsCoord = cf2_fixedRound( - FT_MulFix( - blues->emBoxTopEdge.csCoord, - blues->scale ) ) + - CF2_MIN_COUNTER; - blues->emBoxTopEdge.scale = blues->scale; - blues->emBoxTopEdge.flags = CF2_GhostTop | - CF2_Locked | - CF2_Synthetic; - - blues->doEmBoxHints = TRUE; /* enable the heuristic */ - - return; - } - - /* copy `BlueValues' and `OtherBlues' to a combined array of top and */ - /* bottom zones */ - for ( i = 0; i < numBlueValues; i += 2 ) - { - blues->zone[blues->count].csBottomEdge = - cf2_blueToFixed( blueValues[i] ); - blues->zone[blues->count].csTopEdge = - cf2_blueToFixed( blueValues[i + 1] ); - - zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge, - blues->zone[blues->count].csBottomEdge ); - - if ( zoneHeight < 0 ) - { - FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" )); - continue; /* reject this zone */ - } - - if ( zoneHeight > maxZoneHeight ) - { - /* take maximum before darkening adjustment */ - /* so overshoot suppression point doesn't change */ - maxZoneHeight = zoneHeight; - } - - /* adjust both edges of top zone upward by twice darkening amount */ - if ( i != 0 ) - { - blues->zone[blues->count].csTopEdge += 2 * font->darkenY; - blues->zone[blues->count].csBottomEdge += 2 * font->darkenY; - } - - /* first `BlueValue' is bottom zone; others are top */ - if ( i == 0 ) - { - blues->zone[blues->count].bottomZone = - TRUE; - blues->zone[blues->count].csFlatEdge = - blues->zone[blues->count].csTopEdge; - } - else - { - blues->zone[blues->count].bottomZone = - FALSE; - blues->zone[blues->count].csFlatEdge = - blues->zone[blues->count].csBottomEdge; - } - - blues->count += 1; - } - - for ( i = 0; i < numOtherBlues; i += 2 ) - { - blues->zone[blues->count].csBottomEdge = - cf2_blueToFixed( otherBlues[i] ); - blues->zone[blues->count].csTopEdge = - cf2_blueToFixed( otherBlues[i + 1] ); - - zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge, - blues->zone[blues->count].csBottomEdge ); - - if ( zoneHeight < 0 ) - { - FT_TRACE4(( "cf2_blues_init: ignoring negative zone height\n" )); - continue; /* reject this zone */ - } - - if ( zoneHeight > maxZoneHeight ) - { - /* take maximum before darkening adjustment */ - /* so overshoot suppression point doesn't change */ - maxZoneHeight = zoneHeight; - } - - /* Note: bottom zones are not adjusted for darkening amount */ - - /* all OtherBlues are bottom zone */ - blues->zone[blues->count].bottomZone = - TRUE; - blues->zone[blues->count].csFlatEdge = - blues->zone[blues->count].csTopEdge; - - blues->count += 1; - } - - /* Adjust for FamilyBlues */ - - /* Search for the nearest flat edge in `FamilyBlues' or */ - /* `FamilyOtherBlues'. According to the Black Book, any matching edge */ - /* must be within one device pixel */ - - csUnitsPerPixel = FT_DivFix( cf2_intToFixed( 1 ), blues->scale ); - - /* loop on all zones in this font */ - for ( i = 0; i < blues->count; i++ ) - { - size_t j; - CF2_Fixed minDiff; - CF2_Fixed flatFamilyEdge, diff; - /* value for this font */ - CF2_Fixed flatEdge = blues->zone[i].csFlatEdge; - - - if ( blues->zone[i].bottomZone ) - { - /* In a bottom zone, the top edge is the flat edge. */ - /* Search `FamilyOtherBlues' for bottom zones; look for closest */ - /* Family edge that is within the one pixel threshold. */ - - minDiff = CF2_FIXED_MAX; - - for ( j = 0; j < numFamilyOtherBlues; j += 2 ) - { - /* top edge */ - flatFamilyEdge = cf2_blueToFixed( familyOtherBlues[j + 1] ); - - diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); - - if ( diff < minDiff && diff < csUnitsPerPixel ) - { - blues->zone[i].csFlatEdge = flatFamilyEdge; - minDiff = diff; - - if ( diff == 0 ) - break; - } - } - - /* check the first member of FamilyBlues, which is a bottom zone */ - if ( numFamilyBlues >= 2 ) - { - /* top edge */ - flatFamilyEdge = cf2_blueToFixed( familyBlues[1] ); - - diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); - - if ( diff < minDiff && diff < csUnitsPerPixel ) - blues->zone[i].csFlatEdge = flatFamilyEdge; - } - } - else - { - /* In a top zone, the bottom edge is the flat edge. */ - /* Search `FamilyBlues' for top zones; skip first zone, which is a */ - /* bottom zone; look for closest Family edge that is within the */ - /* one pixel threshold */ - - minDiff = CF2_FIXED_MAX; - - for ( j = 2; j < numFamilyBlues; j += 2 ) - { - /* bottom edge */ - flatFamilyEdge = cf2_blueToFixed( familyBlues[j] ); - - /* adjust edges of top zone upward by twice darkening amount */ - flatFamilyEdge += 2 * font->darkenY; /* bottom edge */ - - diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); - - if ( diff < minDiff && diff < csUnitsPerPixel ) - { - blues->zone[i].csFlatEdge = flatFamilyEdge; - minDiff = diff; - - if ( diff == 0 ) - break; - } - } - } - } - - /* TODO: enforce separation of zones, including BlueFuzz */ - - /* Adjust BlueScale; similar to AdjustBlueScale() in coretype */ - /* `bcsetup.c'. */ - - if ( maxZoneHeight > 0 ) - { - if ( blues->blueScale > FT_DivFix( cf2_intToFixed( 1 ), - maxZoneHeight ) ) - { - /* clamp at maximum scale */ - blues->blueScale = FT_DivFix( cf2_intToFixed( 1 ), - maxZoneHeight ); - } - - /* - * TODO: Revisit the bug fix for 613448. The minimum scale - * requirement catches a number of library fonts. For - * example, with default BlueScale (.039625) and 0.4 minimum, - * the test below catches any font with maxZoneHeight < 10.1. - * There are library fonts ranging from 2 to 10 that get - * caught, including e.g., Eurostile LT Std Medium with - * maxZoneHeight of 6. - * - */ -#if 0 - if ( blueScale < .4 / maxZoneHeight ) - { - tetraphilia_assert( 0 ); - /* clamp at minimum scale, per bug 0613448 fix */ - blueScale = .4 / maxZoneHeight; - } -#endif - - } - - /* - * Suppress overshoot and boost blue zones at small sizes. Boost - * amount varies linearly from 0.5 pixel near 0 to 0 pixel at - * blueScale cutoff. - * Note: This boost amount is different from the coretype heuristic. - * - */ - - if ( blues->scale < blues->blueScale ) - { - blues->suppressOvershoot = TRUE; - - /* Change rounding threshold for `dsFlatEdge'. */ - /* Note: constant changed from 0.5 to 0.6 to avoid a problem with */ - /* 10ppem Arial */ - - blues->boost = cf2_doubleToFixed( .6 ) - - FT_MulDiv( cf2_doubleToFixed ( .6 ), - blues->scale, - blues->blueScale ); - if ( blues->boost > 0x7FFF ) - { - /* boost must remain less than 0.5, or baseline could go negative */ - blues->boost = 0x7FFF; - } - } - - /* boost and darkening have similar effects; don't do both */ - if ( font->stemDarkened ) - blues->boost = 0; - - /* set device space alignment for each zone; */ - /* apply boost amount before rounding flat edge */ - - for ( i = 0; i < blues->count; i++ ) - { - if ( blues->zone[i].bottomZone ) - blues->zone[i].dsFlatEdge = cf2_fixedRound( - FT_MulFix( - blues->zone[i].csFlatEdge, - blues->scale ) - - blues->boost ); - else - blues->zone[i].dsFlatEdge = cf2_fixedRound( - FT_MulFix( - blues->zone[i].csFlatEdge, - blues->scale ) + - blues->boost ); - } - } - - - /* - * Check whether `stemHint' is captured by one of the blue zones. - * - * Zero, one or both edges may be valid; only valid edges can be - * captured. For compatibility with CoolType, search top and bottom - * zones in the same pass (see `BlueLock'). If a hint is captured, - * return true and position the edge(s) in one of 3 ways: - * - * 1) If `BlueScale' suppresses overshoot, position the captured edge - * at the flat edge of the zone. - * 2) If overshoot is not suppressed and `BlueShift' requires - * overshoot, position the captured edge a minimum of 1 device pixel - * from the flat edge. - * 3) If overshoot is not suppressed or required, position the captured - * edge at the nearest device pixel. - * - */ - FT_LOCAL_DEF( FT_Bool ) - cf2_blues_capture( const CF2_Blues blues, - CF2_Hint bottomHintEdge, - CF2_Hint topHintEdge ) - { - /* TODO: validate? */ - CF2_Fixed csFuzz = blues->blueFuzz; - - /* new position of captured edge */ - CF2_Fixed dsNew; - - /* amount that hint is moved when positioned */ - CF2_Fixed dsMove = 0; - - FT_Bool captured = FALSE; - CF2_UInt i; - - - /* assert edge flags are consistent */ - FT_ASSERT( !cf2_hint_isTop( bottomHintEdge ) && - !cf2_hint_isBottom( topHintEdge ) ); - - /* TODO: search once without blue fuzz for compatibility with coretype? */ - for ( i = 0; i < blues->count; i++ ) - { - if ( blues->zone[i].bottomZone && - cf2_hint_isBottom( bottomHintEdge ) ) - { - if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <= - bottomHintEdge->csCoord && - bottomHintEdge->csCoord <= - ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) ) - { - /* bottom edge captured by bottom zone */ - - if ( blues->suppressOvershoot ) - dsNew = blues->zone[i].dsFlatEdge; - - else if ( SUB_INT32( blues->zone[i].csTopEdge, - bottomHintEdge->csCoord ) >= - blues->blueShift ) - { - /* guarantee minimum of 1 pixel overshoot */ - dsNew = FT_MIN( - cf2_fixedRound( bottomHintEdge->dsCoord ), - blues->zone[i].dsFlatEdge - cf2_intToFixed( 1 ) ); - } - - else - { - /* simply round captured edge */ - dsNew = cf2_fixedRound( bottomHintEdge->dsCoord ); - } - - dsMove = SUB_INT32( dsNew, bottomHintEdge->dsCoord ); - captured = TRUE; - - break; - } - } - - if ( !blues->zone[i].bottomZone && cf2_hint_isTop( topHintEdge ) ) - { - if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <= - topHintEdge->csCoord && - topHintEdge->csCoord <= - ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) ) - { - /* top edge captured by top zone */ - - if ( blues->suppressOvershoot ) - dsNew = blues->zone[i].dsFlatEdge; - - else if ( SUB_INT32( topHintEdge->csCoord, - blues->zone[i].csBottomEdge ) >= - blues->blueShift ) - { - /* guarantee minimum of 1 pixel overshoot */ - dsNew = FT_MAX( - cf2_fixedRound( topHintEdge->dsCoord ), - blues->zone[i].dsFlatEdge + cf2_intToFixed( 1 ) ); - } - - else - { - /* simply round captured edge */ - dsNew = cf2_fixedRound( topHintEdge->dsCoord ); - } - - dsMove = SUB_INT32( dsNew, topHintEdge->dsCoord ); - captured = TRUE; - - break; - } - } - } - - if ( captured ) - { - /* move both edges and flag them `locked' */ - if ( cf2_hint_isValid( bottomHintEdge ) ) - { - bottomHintEdge->dsCoord = ADD_INT32( bottomHintEdge->dsCoord, - dsMove ); - cf2_hint_lock( bottomHintEdge ); - } - - if ( cf2_hint_isValid( topHintEdge ) ) - { - topHintEdge->dsCoord = ADD_INT32( topHintEdge->dsCoord, dsMove ); - cf2_hint_lock( topHintEdge ); - } - } - - return captured; - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h deleted file mode 100644 index a6bcd9de578..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2blues.h +++ /dev/null @@ -1,185 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2blues.h */ -/* */ -/* Adobe's code for handling Blue Zones (specification). */ -/* */ -/* Copyright 2009-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - - /* - * A `CF2_Blues' object stores the blue zones (horizontal alignment - * zones) of a font. These are specified in the CFF private dictionary - * by `BlueValues', `OtherBlues', `FamilyBlues', and `FamilyOtherBlues'. - * Each zone is defined by a top and bottom edge in character space. - * Further, each zone is either a top zone or a bottom zone, as recorded - * by `bottomZone'. - * - * The maximum number of `BlueValues' and `FamilyBlues' is 7 each. - * However, these are combined to produce a total of 7 zones. - * Similarly, the maximum number of `OtherBlues' and `FamilyOtherBlues' - * is 5 and these are combined to produce an additional 5 zones. - * - * Blue zones are used to `capture' hints and force them to a common - * alignment point. This alignment is recorded in device space in - * `dsFlatEdge'. Except for this value, a `CF2_Blues' object could be - * constructed independently of scaling. Construction may occur once - * the matrix is known. Other features implemented in the Capture - * method are overshoot suppression, overshoot enforcement, and Blue - * Boost. - * - * Capture is determined by `BlueValues' and `OtherBlues', but the - * alignment point may be adjusted to the scaled flat edge of - * `FamilyBlues' or `FamilyOtherBlues'. No alignment is done to the - * curved edge of a zone. - * - */ - - -#ifndef CF2BLUES_H_ -#define CF2BLUES_H_ - - -#include "cf2glue.h" - - -FT_BEGIN_HEADER - - - /* - * `CF2_Hint' is shared by `cf2hints.h' and - * `cf2blues.h', but `cf2blues.h' depends on - * `cf2hints.h', so define it here. Note: The typedef is in - * `cf2glue.h'. - * - */ - enum - { - CF2_GhostBottom = 0x1, /* a single bottom edge */ - CF2_GhostTop = 0x2, /* a single top edge */ - CF2_PairBottom = 0x4, /* the bottom edge of a stem hint */ - CF2_PairTop = 0x8, /* the top edge of a stem hint */ - CF2_Locked = 0x10, /* this edge has been aligned */ - /* by a blue zone */ - CF2_Synthetic = 0x20 /* this edge was synthesized */ - }; - - - /* - * Default value for OS/2 typoAscender/Descender when their difference - * is not equal to `unitsPerEm'. The default is based on -250 and 1100 - * in `CF2_Blues', assuming 1000 units per em here. - * - */ - enum - { - CF2_ICF_Top = cf2_intToFixed( 880 ), - CF2_ICF_Bottom = cf2_intToFixed( -120 ) - }; - - - /* - * Constant used for hint adjustment and for synthetic em box hint - * placement. - */ -#define CF2_MIN_COUNTER cf2_doubleToFixed( 0.5 ) - - - /* shared typedef is in cf2glue.h */ - struct CF2_HintRec_ - { - CF2_UInt flags; /* attributes of the edge */ - size_t index; /* index in original stem hint array */ - /* (if not synthetic) */ - CF2_Fixed csCoord; - CF2_Fixed dsCoord; - CF2_Fixed scale; - }; - - - typedef struct CF2_BlueRec_ - { - CF2_Fixed csBottomEdge; - CF2_Fixed csTopEdge; - CF2_Fixed csFlatEdge; /* may be from either local or Family zones */ - CF2_Fixed dsFlatEdge; /* top edge of bottom zone or bottom edge */ - /* of top zone (rounded) */ - FT_Bool bottomZone; - - } CF2_BlueRec; - - - /* max total blue zones is 12 */ - enum - { - CF2_MAX_BLUES = 7, - CF2_MAX_OTHERBLUES = 5 - }; - - - typedef struct CF2_BluesRec_ - { - CF2_Fixed scale; - CF2_UInt count; - FT_Bool suppressOvershoot; - FT_Bool doEmBoxHints; - - CF2_Fixed blueScale; - CF2_Fixed blueShift; - CF2_Fixed blueFuzz; - - CF2_Fixed boost; - - CF2_HintRec emBoxTopEdge; - CF2_HintRec emBoxBottomEdge; - - CF2_BlueRec zone[CF2_MAX_BLUES + CF2_MAX_OTHERBLUES]; - - } CF2_BluesRec, *CF2_Blues; - - - FT_LOCAL( void ) - cf2_blues_init( CF2_Blues blues, - CF2_Font font ); - FT_LOCAL( FT_Bool ) - cf2_blues_capture( const CF2_Blues blues, - CF2_Hint bottomHintEdge, - CF2_Hint topHintEdge ); - - -FT_END_HEADER - - -#endif /* CF2BLUES_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c deleted file mode 100644 index e3dd69f50d1..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.c +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2error.c */ -/* */ -/* Adobe's code for error handling (body). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include "cf2error.h" - - - FT_LOCAL_DEF( void ) - cf2_setError( FT_Error* error, - FT_Error value ) - { - if ( error && !*error ) - *error = value; - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h deleted file mode 100644 index d2c770d2974..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2error.h */ -/* */ -/* Adobe's code for error handling (specification). */ -/* */ -/* Copyright 2006-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2ERROR_H_ -#define CF2ERROR_H_ - - -#include FT_MODULE_ERRORS_H - -#undef FTERRORS_H_ - -#undef FT_ERR_PREFIX -#define FT_ERR_PREFIX CF2_Err_ -#define FT_ERR_BASE FT_Mod_Err_CF2 - - -#include FT_ERRORS_H -#include "cf2ft.h" - - -FT_BEGIN_HEADER - - - /* - * A poor-man error facility. - * - * This code being written in vanilla C, doesn't have the luxury of a - * language-supported exception mechanism such as the one available in - * Java. Instead, we are stuck with using error codes that must be - * carefully managed and preserved. However, it is convenient for us to - * model our error mechanism on a Java-like exception mechanism. - * When we assign an error code we are thus `throwing' an error. - * - * The preservation of an error code is done by coding convention. - * Upon a function call if the error code is anything other than - * `FT_Err_Ok', which is guaranteed to be zero, we - * will return without altering that error. This will allow the - * error to propagate and be handled at the appropriate location in - * the code. - * - * This allows a style of code where the error code is initialized - * up front and a block of calls are made with the error code only - * being checked after the block. If a new error occurs, the original - * error will be preserved and a functional no-op should result in any - * subsequent function that has an initial error code not equal to - * `FT_Err_Ok'. - * - * Errors are encoded by calling the `FT_THROW' macro. For example, - * - * { - * FT_Error e; - * - * - * ... - * e = FT_THROW( Out_Of_Memory ); - * } - * - */ - - - /* Set error code to a particular value. */ - FT_LOCAL( void ) - cf2_setError( FT_Error* error, - FT_Error value ); - - - /* - * A macro that conditionally sets an error code. - * - * This macro will first check whether `error' is set; - * if not, it will set it to `e'. - * - */ -#define CF2_SET_ERROR( error, e ) \ - cf2_setError( error, FT_THROW( e ) ) - - -FT_END_HEADER - - -#endif /* CF2ERROR_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h deleted file mode 100644 index a041184bda8..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2fixed.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2fixed.h */ -/* */ -/* Adobe's code for Fixed Point Mathematics (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2FIXED_H_ -#define CF2FIXED_H_ - - -FT_BEGIN_HEADER - - - /* rasterizer integer and fixed point arithmetic must be 32-bit */ - -#define CF2_Fixed CF2_F16Dot16 - typedef FT_Int32 CF2_Frac; /* 2.30 fixed point */ - - -#define CF2_FIXED_MAX ( (CF2_Fixed)0x7FFFFFFFL ) -#define CF2_FIXED_MIN ( (CF2_Fixed)0x80000000L ) -#define CF2_FIXED_ONE ( (CF2_Fixed)0x10000L ) -#define CF2_FIXED_EPSILON ( (CF2_Fixed)0x0001 ) - - /* in C 89, left and right shift of negative numbers is */ - /* implementation specific behaviour in the general case */ - -#define cf2_intToFixed( i ) \ - ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) ) -#define cf2_fixedToInt( x ) \ - ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) -#define cf2_fixedRound( x ) \ - ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) ) -#define cf2_doubleToFixed( f ) \ - ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) ) -#define cf2_fixedAbs( x ) \ - ( (x) < 0 ? NEG_INT32( x ) : (x) ) -#define cf2_fixedFloor( x ) \ - ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) ) -#define cf2_fixedFraction( x ) \ - ( (x) - cf2_fixedFloor( x ) ) -#define cf2_fracToFixed( x ) \ - ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 ) \ - : ( ( (x) + 0x2000 ) >> 14 ) ) - - - /* signed numeric types */ - typedef enum CF2_NumberType_ - { - CF2_NumberFixed, /* 16.16 */ - CF2_NumberFrac, /* 2.30 */ - CF2_NumberInt /* 32.0 */ - - } CF2_NumberType; - - -FT_END_HEADER - - -#endif /* CF2FIXED_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c deleted file mode 100644 index 4ac71a8d715..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.c +++ /dev/null @@ -1,562 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2font.c */ -/* */ -/* Adobe's code for font instances (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include -#include FT_INTERNAL_CALC_H - -#include "cf2ft.h" - -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2error.h" -#include "cf2intrp.h" - - - /* Compute a stem darkening amount in character space. */ - static void - cf2_computeDarkening( CF2_Fixed emRatio, - CF2_Fixed ppem, - CF2_Fixed stemWidth, - CF2_Fixed* darkenAmount, - CF2_Fixed boldenAmount, - FT_Bool stemDarkened, - FT_Int* darkenParams ) - { - /* - * Total darkening amount is computed in 1000 unit character space - * using the modified 5 part curve as Adobe's Avalon rasterizer. - * The darkening amount is smaller for thicker stems. - * It becomes zero when the stem is thicker than 2.333 pixels. - * - * By default, we use - * - * darkenAmount = 0.4 pixels if scaledStem <= 0.5 pixels, - * darkenAmount = 0.275 pixels if 1 <= scaledStem <= 1.667 pixels, - * darkenAmount = 0 pixel if scaledStem >= 2.333 pixels, - * - * and piecewise linear in-between: - * - * - * darkening - * ^ - * | - * | (x1,y1) - * |--------+ - * | \ - * | \ - * | \ (x3,y3) - * | +----------+ - * | (x2,y2) \ - * | \ - * | \ - * | +----------------- - * | (x4,y4) - * +---------------------------------------------> stem - * thickness - * - * - * This corresponds to the following values for the - * `darkening-parameters' property: - * - * (x1, y1) = (500, 400) - * (x2, y2) = (1000, 275) - * (x3, y3) = (1667, 275) - * (x4, y4) = (2333, 0) - * - */ - - /* Internal calculations are done in units per thousand for */ - /* convenience. The x axis is scaled stem width in */ - /* thousandths of a pixel. That is, 1000 is 1 pixel. */ - /* The y axis is darkening amount in thousandths of a pixel.*/ - /* In the code, below, dividing by ppem and */ - /* adjusting for emRatio converts darkenAmount to character */ - /* space (font units). */ - CF2_Fixed stemWidthPer1000, scaledStem; - FT_Int logBase2; - - - *darkenAmount = 0; - - if ( boldenAmount == 0 && !stemDarkened ) - return; - - /* protect against range problems and divide by zero */ - if ( emRatio < cf2_doubleToFixed( .01 ) ) - return; - - if ( stemDarkened ) - { - FT_Int x1 = darkenParams[0]; - FT_Int y1 = darkenParams[1]; - FT_Int x2 = darkenParams[2]; - FT_Int y2 = darkenParams[3]; - FT_Int x3 = darkenParams[4]; - FT_Int y3 = darkenParams[5]; - FT_Int x4 = darkenParams[6]; - FT_Int y4 = darkenParams[7]; - - - /* convert from true character space to 1000 unit character space; */ - /* add synthetic emboldening effect */ - - /* `stemWidthPer1000' will not overflow for a legitimate font */ - - stemWidthPer1000 = FT_MulFix( stemWidth + boldenAmount, emRatio ); - - /* `scaledStem' can easily overflow, so we must clamp its maximum */ - /* value; the test doesn't need to be precise, but must be */ - /* conservative. The clamp value (default 2333) where */ - /* `darkenAmount' is zero is well below the overflow value of */ - /* 32767. */ - /* */ - /* FT_MSB computes the integer part of the base 2 logarithm. The */ - /* number of bits for the product is 1 or 2 more than the sum of */ - /* logarithms; remembering that the 16 lowest bits of the fraction */ - /* are dropped this is correct to within a factor of almost 4. */ - /* For example, 0x80.0000 * 0x80.0000 = 0x4000.0000 is 23+23 and */ - /* is flagged as possible overflow because 0xFF.FFFF * 0xFF.FFFF = */ - /* 0xFFFF.FE00 is also 23+23. */ - - logBase2 = FT_MSB( (FT_UInt32)stemWidthPer1000 ) + - FT_MSB( (FT_UInt32)ppem ); - - if ( logBase2 >= 46 ) - /* possible overflow */ - scaledStem = cf2_intToFixed( x4 ); - else - scaledStem = FT_MulFix( stemWidthPer1000, ppem ); - - /* now apply the darkening parameters */ - - if ( scaledStem < cf2_intToFixed( x1 ) ) - *darkenAmount = FT_DivFix( cf2_intToFixed( y1 ), ppem ); - - else if ( scaledStem < cf2_intToFixed( x2 ) ) - { - FT_Int xdelta = x2 - x1; - FT_Int ydelta = y2 - y1; - FT_Int x = stemWidthPer1000 - - FT_DivFix( cf2_intToFixed( x1 ), ppem ); - - - if ( !xdelta ) - goto Try_x3; - - *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) + - FT_DivFix( cf2_intToFixed( y1 ), ppem ); - } - - else if ( scaledStem < cf2_intToFixed( x3 ) ) - { - Try_x3: - { - FT_Int xdelta = x3 - x2; - FT_Int ydelta = y3 - y2; - FT_Int x = stemWidthPer1000 - - FT_DivFix( cf2_intToFixed( x2 ), ppem ); - - - if ( !xdelta ) - goto Try_x4; - - *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) + - FT_DivFix( cf2_intToFixed( y2 ), ppem ); - } - } - - else if ( scaledStem < cf2_intToFixed( x4 ) ) - { - Try_x4: - { - FT_Int xdelta = x4 - x3; - FT_Int ydelta = y4 - y3; - FT_Int x = stemWidthPer1000 - - FT_DivFix( cf2_intToFixed( x3 ), ppem ); - - - if ( !xdelta ) - goto Use_y4; - - *darkenAmount = FT_MulDiv( x, ydelta, xdelta ) + - FT_DivFix( cf2_intToFixed( y3 ), ppem ); - } - } - - else - { - Use_y4: - *darkenAmount = FT_DivFix( cf2_intToFixed( y4 ), ppem ); - } - - /* use half the amount on each side and convert back to true */ - /* character space */ - *darkenAmount = FT_DivFix( *darkenAmount, 2 * emRatio ); - } - - /* add synthetic emboldening effect in character space */ - *darkenAmount += boldenAmount / 2; - } - - - /* set up values for the current FontDict and matrix; */ - /* called for each glyph to be rendered */ - - /* caller's transform is adjusted for subpixel positioning */ - static void - cf2_font_setup( CF2_Font font, - const CF2_Matrix* transform ) - { - /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; - - FT_Bool needExtraSetup = FALSE; - - CFF_VStoreRec* vstore; - FT_Bool hasVariations = FALSE; - - /* character space units */ - CF2_Fixed boldenX = font->syntheticEmboldeningAmountX; - CF2_Fixed boldenY = font->syntheticEmboldeningAmountY; - - CFF_SubFont subFont; - CF2_Fixed ppem; - - CF2_UInt lenNormalizedV = 0; - FT_Fixed* normalizedV = NULL; - - - /* clear previous error */ - font->error = FT_Err_Ok; - - /* if a CID fontDict has changed, we need to recompute some cached */ - /* data */ - subFont = cf2_getSubfont( decoder ); - if ( font->lastSubfont != subFont ) - { - font->lastSubfont = subFont; - needExtraSetup = TRUE; - } - - /* check for variation vectors */ - vstore = cf2_getVStore( decoder ); - hasVariations = ( vstore->dataCount != 0 ); - - if ( hasVariations ) - { -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /* check whether Private DICT in this subfont needs to be reparsed */ - font->error = cf2_getNormalizedVector( decoder, - &lenNormalizedV, - &normalizedV ); - if ( font->error ) - return; - - if ( cff_blend_check_vector( &subFont->blend, - subFont->private_dict.vsindex, - lenNormalizedV, - normalizedV ) ) - { - /* blend has changed, reparse */ - cff_load_private_dict( decoder->cff, - subFont, - lenNormalizedV, - normalizedV ); - needExtraSetup = TRUE; - } -#endif - - /* copy from subfont */ - font->blend.font = subFont->blend.font; - - /* clear state of charstring blend */ - font->blend.usedBV = FALSE; - - /* initialize value for charstring */ - font->vsindex = subFont->private_dict.vsindex; - - /* store vector inputs for blends in charstring */ - font->lenNDV = lenNormalizedV; - font->NDV = normalizedV; - } - - /* if ppem has changed, we need to recompute some cached data */ - /* note: because of CID font matrix concatenation, ppem and transform */ - /* do not necessarily track. */ - ppem = cf2_getPpemY( decoder ); - if ( font->ppem != ppem ) - { - font->ppem = ppem; - needExtraSetup = TRUE; - } - - /* copy hinted flag on each call */ - font->hinted = (FT_Bool)( font->renderingFlags & CF2_FlagsHinted ); - - /* determine if transform has changed; */ - /* include Fontmatrix but ignore translation */ - if ( ft_memcmp( transform, - &font->currentTransform, - 4 * sizeof ( CF2_Fixed ) ) != 0 ) - { - /* save `key' information for `cache of one' matrix data; */ - /* save client transform, without the translation */ - font->currentTransform = *transform; - font->currentTransform.tx = - font->currentTransform.ty = cf2_intToFixed( 0 ); - - /* TODO: FreeType transform is simple scalar; for now, use identity */ - /* for outer */ - font->innerTransform = *transform; - font->outerTransform.a = - font->outerTransform.d = cf2_intToFixed( 1 ); - font->outerTransform.b = - font->outerTransform.c = cf2_intToFixed( 0 ); - - needExtraSetup = TRUE; - } - - /* - * font->darkened is set to true if there is a stem darkening request or - * the font is synthetic emboldened. - * font->darkened controls whether to adjust blue zones, winding order, - * and hinting. - * - */ - if ( font->stemDarkened != ( font->renderingFlags & CF2_FlagsDarkened ) ) - { - font->stemDarkened = - (FT_Bool)( font->renderingFlags & CF2_FlagsDarkened ); - - /* blue zones depend on darkened flag */ - needExtraSetup = TRUE; - } - - /* recompute variables that are dependent on transform or FontDict or */ - /* darken flag */ - if ( needExtraSetup ) - { - /* StdVW is found in the private dictionary; */ - /* recompute darkening amounts whenever private dictionary or */ - /* transform change */ - /* Note: a rendering flag turns darkening on or off, so we want to */ - /* store the `on' amounts; */ - /* darkening amount is computed in character space */ - /* TODO: testing size-dependent darkening here; */ - /* what to do for rotations? */ - - CF2_Fixed emRatio; - CF2_Fixed stdHW; - CF2_Int unitsPerEm = font->unitsPerEm; - - - if ( unitsPerEm == 0 ) - unitsPerEm = 1000; - - ppem = FT_MAX( cf2_intToFixed( 4 ), - font->ppem ); /* use minimum ppem of 4 */ - -#if 0 - /* since vstem is measured in the x-direction, we use the `a' member */ - /* of the fontMatrix */ - emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->a ); -#endif - - /* Freetype does not preserve the fontMatrix when parsing; use */ - /* unitsPerEm instead. */ - /* TODO: check precision of this */ - emRatio = cf2_intToFixed( 1000 ) / unitsPerEm; - font->stdVW = cf2_getStdVW( decoder ); - - if ( font->stdVW <= 0 ) - font->stdVW = FT_DivFix( cf2_intToFixed( 75 ), emRatio ); - - if ( boldenX > 0 ) - { - /* Ensure that boldenX is at least 1 pixel for synthetic bold font */ - /* (similar to what Avalon does) */ - boldenX = FT_MAX( boldenX, - FT_DivFix( cf2_intToFixed( unitsPerEm ), ppem ) ); - - /* Synthetic emboldening adds at least 1 pixel to darkenX, while */ - /* stem darkening adds at most half pixel. Since the purpose of */ - /* stem darkening (readability at small sizes) is met with */ - /* synthetic emboldening, no need to add stem darkening for a */ - /* synthetic bold font. */ - cf2_computeDarkening( emRatio, - ppem, - font->stdVW, - &font->darkenX, - boldenX, - FALSE, - font->darkenParams ); - } - else - cf2_computeDarkening( emRatio, - ppem, - font->stdVW, - &font->darkenX, - 0, - font->stemDarkened, - font->darkenParams ); - -#if 0 - /* since hstem is measured in the y-direction, we use the `d' member */ - /* of the fontMatrix */ - /* TODO: use the same units per em as above; check this */ - emRatio = cf2_fixedFracMul( cf2_intToFixed( 1000 ), fontMatrix->d ); -#endif - - /* set the default stem width, because it must be the same for all */ - /* family members; */ - /* choose a constant for StdHW that depends on font contrast */ - stdHW = cf2_getStdHW( decoder ); - - if ( stdHW > 0 && font->stdVW > MUL_INT32( 2, stdHW ) ) - font->stdHW = FT_DivFix( cf2_intToFixed( 75 ), emRatio ); - else - { - /* low contrast font gets less hstem darkening */ - font->stdHW = FT_DivFix( cf2_intToFixed( 110 ), emRatio ); - } - - cf2_computeDarkening( emRatio, - ppem, - font->stdHW, - &font->darkenY, - boldenY, - font->stemDarkened, - font->darkenParams ); - - if ( font->darkenX != 0 || font->darkenY != 0 ) - font->darkened = TRUE; - else - font->darkened = FALSE; - - font->reverseWinding = FALSE; /* initial expectation is CCW */ - - /* compute blue zones for this instance */ - cf2_blues_init( &font->blues, font ); - - } /* needExtraSetup */ - } - - - /* equivalent to AdobeGetOutline */ - FT_LOCAL_DEF( FT_Error ) - cf2_getGlyphOutline( CF2_Font font, - CF2_Buffer charstring, - const CF2_Matrix* transform, - CF2_F16Dot16* glyphWidth ) - { - FT_Error lastError = FT_Err_Ok; - - FT_Vector translation; - -#if 0 - FT_Vector advancePoint; -#endif - - CF2_Fixed advWidth = 0; - FT_Bool needWinding; - - - /* Note: use both integer and fraction for outlines. This allows bbox */ - /* to come out directly. */ - - translation.x = transform->tx; - translation.y = transform->ty; - - /* set up values based on transform */ - cf2_font_setup( font, transform ); - if ( font->error ) - goto exit; /* setup encountered an error */ - - /* reset darken direction */ - font->reverseWinding = FALSE; - - /* winding order only affects darkening */ - needWinding = font->darkened; - - while ( 1 ) - { - /* reset output buffer */ - cf2_outline_reset( &font->outline ); - - /* build the outline, passing the full translation */ - cf2_interpT2CharString( font, - charstring, - (CF2_OutlineCallbacks)&font->outline, - &translation, - FALSE, - 0, - 0, - &advWidth ); - - if ( font->error ) - goto exit; - - if ( !needWinding ) - break; - - /* check winding order */ - if ( font->outline.root.windingMomentum >= 0 ) /* CFF is CCW */ - break; - - /* invert darkening and render again */ - /* TODO: this should be a parameter to getOutline-computeOffset */ - font->reverseWinding = TRUE; - - needWinding = FALSE; /* exit after next iteration */ - } - - /* finish storing client outline */ - cf2_outline_close( &font->outline ); - - exit: - /* FreeType just wants the advance width; there is no translation */ - *glyphWidth = advWidth; - - /* free resources and collect errors from objects we've used */ - cf2_setError( &font->error, lastError ); - - return font->error; - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h deleted file mode 100644 index 17ecd17bbb6..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2font.h +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2font.h */ -/* */ -/* Adobe's code for font instances (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2FONT_H_ -#define CF2FONT_H_ - - -#include "cf2ft.h" -#include "cf2blues.h" -#include "cffload.h" - - -FT_BEGIN_HEADER - - -#define CF2_OPERAND_STACK_SIZE 48 -#define CF2_MAX_SUBR 16 /* maximum subroutine nesting; */ - /* only 10 are allowed but there exist */ - /* fonts like `HiraKakuProN-W3.ttf' */ - /* (Hiragino Kaku Gothic ProN W3; */ - /* 8.2d6e1; 2014-12-19) that exceed */ - /* this limit */ -#define CF2_STORAGE_SIZE 32 - - - /* typedef is in `cf2glue.h' */ - struct CF2_FontRec_ - { - FT_Memory memory; - FT_Error error; /* shared error for this instance */ - - FT_Bool isCFF2; - CF2_RenderingFlags renderingFlags; - - /* variables that depend on Transform: */ - /* the following have zero translation; */ - /* inner * outer = font * original */ - - CF2_Matrix currentTransform; /* original client matrix */ - CF2_Matrix innerTransform; /* for hinting; erect, scaled */ - CF2_Matrix outerTransform; /* post hinting; includes rotations */ - CF2_Fixed ppem; /* transform-dependent */ - - /* variation data */ - CFF_BlendRec blend; /* cached charstring blend vector */ - CF2_UInt vsindex; /* current vsindex */ - CF2_UInt lenNDV; /* current length NDV or zero */ - FT_Fixed* NDV; /* ptr to current NDV or NULL */ - - CF2_Int unitsPerEm; - - CF2_Fixed syntheticEmboldeningAmountX; /* character space units */ - CF2_Fixed syntheticEmboldeningAmountY; /* character space units */ - - /* FreeType related members */ - CF2_OutlineRec outline; /* freetype glyph outline functions */ - CFF_Decoder* decoder; - CFF_SubFont lastSubfont; /* FreeType parsed data; */ - /* top font or subfont */ - - /* these flags can vary from one call to the next */ - FT_Bool hinted; - FT_Bool darkened; /* true if stemDarkened or synthetic bold */ - /* i.e. darkenX != 0 || darkenY != 0 */ - FT_Bool stemDarkened; - - FT_Int darkenParams[8]; /* 1000 unit character space */ - - /* variables that depend on both FontDict and Transform */ - CF2_Fixed stdVW; /* in character space; depends on dict entry */ - CF2_Fixed stdHW; /* in character space; depends on dict entry */ - CF2_Fixed darkenX; /* character space units */ - CF2_Fixed darkenY; /* depends on transform */ - /* and private dict (StdVW) */ - FT_Bool reverseWinding; /* darken assuming */ - /* counterclockwise winding */ - - CF2_BluesRec blues; /* computed zone data */ - }; - - - FT_LOCAL( FT_Error ) - cf2_getGlyphOutline( CF2_Font font, - CF2_Buffer charstring, - const CF2_Matrix* transform, - CF2_F16Dot16* glyphWidth ); - - -FT_END_HEADER - - -#endif /* CF2FONT_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c deleted file mode 100644 index c6c00d16239..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c +++ /dev/null @@ -1,755 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2ft.c */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (body). */ -/* */ -/* Copyright 2013-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2font.h" -#include "cf2error.h" - - -#define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */ - - - /* - * This check should avoid most internal overflow cases. Clients should - * generally respond to `Glyph_Too_Big' by getting a glyph outline - * at EM size, scaling it and filling it as a graphics operation. - * - */ - static FT_Error - cf2_checkTransform( const CF2_Matrix* transform, - CF2_Int unitsPerEm ) - { - CF2_Fixed maxScale; - - - FT_ASSERT( unitsPerEm > 0 ); - - if ( transform->a <= 0 || transform->d <= 0 ) - return FT_THROW( Invalid_Size_Handle ); - - FT_ASSERT( transform->b == 0 && transform->c == 0 ); - FT_ASSERT( transform->tx == 0 && transform->ty == 0 ); - - if ( unitsPerEm > 0x7FFF ) - return FT_THROW( Glyph_Too_Big ); - - maxScale = FT_DivFix( CF2_MAX_SIZE, cf2_intToFixed( unitsPerEm ) ); - - if ( transform->a > maxScale || transform->d > maxScale ) - return FT_THROW( Glyph_Too_Big ); - - return FT_Err_Ok; - } - - - static void - cf2_setGlyphWidth( CF2_Outline outline, - CF2_Fixed width ) - { - CFF_Decoder* decoder = outline->decoder; - - - FT_ASSERT( decoder ); - - decoder->glyph_width = cf2_fixedToInt( width ); - } - - - /* Clean up font instance. */ - static void - cf2_free_instance( void* ptr ) - { - CF2_Font font = (CF2_Font)ptr; - - - if ( font ) - { - FT_Memory memory = font->memory; - - - FT_FREE( font->blend.lastNDV ); - FT_FREE( font->blend.BV ); - } - } - - - /********************************************/ - /* */ - /* functions for handling client outline; */ - /* FreeType uses coordinates in 26.6 format */ - /* */ - /********************************************/ - - static void - cf2_builder_moveTo( CF2_OutlineCallbacks callbacks, - const CF2_CallbackParams params ) - { - /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; - - (void)params; /* only used in debug mode */ - - - FT_ASSERT( outline && outline->decoder ); - FT_ASSERT( params->op == CF2_PathOpMoveTo ); - - builder = &outline->decoder->builder; - - /* note: two successive moves simply close the contour twice */ - cff_builder_close_contour( builder ); - builder->path_begun = 0; - } - - - static void - cf2_builder_lineTo( CF2_OutlineCallbacks callbacks, - const CF2_CallbackParams params ) - { - FT_Error error; - - /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; - - - FT_ASSERT( outline && outline->decoder ); - FT_ASSERT( params->op == CF2_PathOpLineTo ); - - builder = &outline->decoder->builder; - - if ( !builder->path_begun ) - { - /* record the move before the line; also check points and set */ - /* `path_begun' */ - error = cff_builder_start_point( builder, - params->pt0.x, - params->pt0.y ); - if ( error ) - { - if ( !*callbacks->error ) - *callbacks->error = error; - return; - } - } - - /* `cff_builder_add_point1' includes a check_points call for one point */ - error = cff_builder_add_point1( builder, - params->pt1.x, - params->pt1.y ); - if ( error ) - { - if ( !*callbacks->error ) - *callbacks->error = error; - return; - } - } - - - static void - cf2_builder_cubeTo( CF2_OutlineCallbacks callbacks, - const CF2_CallbackParams params ) - { - FT_Error error; - - /* downcast the object pointer */ - CF2_Outline outline = (CF2_Outline)callbacks; - CFF_Builder* builder; - - - FT_ASSERT( outline && outline->decoder ); - FT_ASSERT( params->op == CF2_PathOpCubeTo ); - - builder = &outline->decoder->builder; - - if ( !builder->path_begun ) - { - /* record the move before the line; also check points and set */ - /* `path_begun' */ - error = cff_builder_start_point( builder, - params->pt0.x, - params->pt0.y ); - if ( error ) - { - if ( !*callbacks->error ) - *callbacks->error = error; - return; - } - } - - /* prepare room for 3 points: 2 off-curve, 1 on-curve */ - error = cff_check_points( builder, 3 ); - if ( error ) - { - if ( !*callbacks->error ) - *callbacks->error = error; - return; - } - - cff_builder_add_point( builder, - params->pt1.x, - params->pt1.y, 0 ); - cff_builder_add_point( builder, - params->pt2.x, - params->pt2.y, 0 ); - cff_builder_add_point( builder, - params->pt3.x, - params->pt3.y, 1 ); - } - - - static void - cf2_outline_init( CF2_Outline outline, - FT_Memory memory, - FT_Error* error ) - { - FT_ZERO( outline ); - - outline->root.memory = memory; - outline->root.error = error; - - outline->root.moveTo = cf2_builder_moveTo; - outline->root.lineTo = cf2_builder_lineTo; - outline->root.cubeTo = cf2_builder_cubeTo; - } - - - /* get scaling and hint flag from GlyphSlot */ - static void - cf2_getScaleAndHintFlag( CFF_Decoder* decoder, - CF2_Fixed* x_scale, - CF2_Fixed* y_scale, - FT_Bool* hinted, - FT_Bool* scaled ) - { - FT_ASSERT( decoder && decoder->builder.glyph ); - - /* note: FreeType scale includes a factor of 64 */ - *hinted = decoder->builder.glyph->hint; - *scaled = decoder->builder.glyph->scaled; - - if ( *hinted ) - { - *x_scale = ADD_INT32( decoder->builder.glyph->x_scale, 32 ) / 64; - *y_scale = ADD_INT32( decoder->builder.glyph->y_scale, 32 ) / 64; - } - else - { - /* for unhinted outlines, `cff_slot_load' does the scaling, */ - /* thus render at `unity' scale */ - - *x_scale = 0x0400; /* 1/64 as 16.16 */ - *y_scale = 0x0400; - } - } - - - /* get units per em from `FT_Face' */ - /* TODO: should handle font matrix concatenation? */ - static FT_UShort - cf2_getUnitsPerEm( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->builder.face ); - FT_ASSERT( decoder->builder.face->root.units_per_EM ); - - return decoder->builder.face->root.units_per_EM; - } - - - /* Main entry point: Render one glyph. */ - FT_LOCAL_DEF( FT_Error ) - cf2_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len ) - { - FT_Memory memory; - FT_Error error = FT_Err_Ok; - CF2_Font font; - - - FT_ASSERT( decoder && decoder->cff ); - - memory = decoder->builder.memory; - - /* CF2 data is saved here across glyphs */ - font = (CF2_Font)decoder->cff->cf2_instance.data; - - /* on first glyph, allocate instance structure */ - if ( !decoder->cff->cf2_instance.data ) - { - decoder->cff->cf2_instance.finalizer = - (FT_Generic_Finalizer)cf2_free_instance; - - if ( FT_ALLOC( decoder->cff->cf2_instance.data, - sizeof ( CF2_FontRec ) ) ) - return FT_THROW( Out_Of_Memory ); - - font = (CF2_Font)decoder->cff->cf2_instance.data; - - font->memory = memory; - - /* initialize a client outline, to be shared by each glyph rendered */ - cf2_outline_init( &font->outline, font->memory, &font->error ); - } - - /* save decoder; it is a stack variable and will be different on each */ - /* call */ - font->decoder = decoder; - font->outline.decoder = decoder; - - { - /* build parameters for Adobe engine */ - - CFF_Builder* builder = &decoder->builder; - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); - - FT_Bool no_stem_darkening_driver = - driver->no_stem_darkening; - FT_Char no_stem_darkening_font = - builder->face->root.internal->no_stem_darkening; - - /* local error */ - FT_Error error2 = FT_Err_Ok; - CF2_BufferRec buf; - CF2_Matrix transform; - CF2_F16Dot16 glyphWidth; - - FT_Bool hinted; - FT_Bool scaled; - - - /* FreeType has already looked up the GID; convert to */ - /* `RegionBuffer', assuming that the input has been validated */ - FT_ASSERT( charstring_base + charstring_len >= charstring_base ); - - FT_ZERO( &buf ); - buf.start = - buf.ptr = charstring_base; - buf.end = charstring_base + charstring_len; - - FT_ZERO( &transform ); - - cf2_getScaleAndHintFlag( decoder, - &transform.a, - &transform.d, - &hinted, - &scaled ); - - /* copy isCFF2 boolean from TT_Face to CF2_Font */ - font->isCFF2 = builder->face->is_cff2; - - font->renderingFlags = 0; - if ( hinted ) - font->renderingFlags |= CF2_FlagsHinted; - if ( scaled && ( !no_stem_darkening_font || - ( no_stem_darkening_font < 0 && - !no_stem_darkening_driver ) ) ) - font->renderingFlags |= CF2_FlagsDarkened; - - font->darkenParams[0] = driver->darken_params[0]; - font->darkenParams[1] = driver->darken_params[1]; - font->darkenParams[2] = driver->darken_params[2]; - font->darkenParams[3] = driver->darken_params[3]; - font->darkenParams[4] = driver->darken_params[4]; - font->darkenParams[5] = driver->darken_params[5]; - font->darkenParams[6] = driver->darken_params[6]; - font->darkenParams[7] = driver->darken_params[7]; - - /* now get an outline for this glyph; */ - /* also get units per em to validate scale */ - font->unitsPerEm = (CF2_Int)cf2_getUnitsPerEm( decoder ); - - if ( scaled ) - { - error2 = cf2_checkTransform( &transform, font->unitsPerEm ); - if ( error2 ) - return error2; - } - - error2 = cf2_getGlyphOutline( font, &buf, &transform, &glyphWidth ); - if ( error2 ) - return FT_ERR( Invalid_File_Format ); - - cf2_setGlyphWidth( &font->outline, glyphWidth ); - - return FT_Err_Ok; - } - } - - - /* get pointer to current FreeType subfont (based on current glyphID) */ - FT_LOCAL_DEF( CFF_SubFont ) - cf2_getSubfont( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return decoder->current_subfont; - } - - - /* get pointer to VStore structure */ - FT_LOCAL_DEF( CFF_VStore ) - cf2_getVStore( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->cff ); - - return &decoder->cff->vstore; - } - - - /* get maxstack value from CFF2 Top DICT */ - FT_LOCAL_DEF( FT_UInt ) - cf2_getMaxstack( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->cff ); - - return decoder->cff->top_font.font_dict.maxstack; - } - - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - /* Get normalized design vector for current render request; */ - /* return pointer and length. */ - /* */ - /* Note: Uses FT_Fixed not CF2_Fixed for the vector. */ - FT_LOCAL_DEF( FT_Error ) - cf2_getNormalizedVector( CFF_Decoder* decoder, - CF2_UInt *len, - FT_Fixed* *vec ) - { - FT_ASSERT( decoder && decoder->builder.face ); - FT_ASSERT( vec && len ); - - return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL ); - } -#endif - - - /* get `y_ppem' from `CFF_Size' */ - FT_LOCAL_DEF( CF2_Fixed ) - cf2_getPpemY( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && - decoder->builder.face && - decoder->builder.face->root.size ); - - /* - * Note that `y_ppem' can be zero if there wasn't a call to - * `FT_Set_Char_Size' or something similar. However, this isn't a - * problem since we come to this place in the code only if - * FT_LOAD_NO_SCALE is set (the other case gets caught by - * `cf2_checkTransform'). The ppem value is needed to compute the stem - * darkening, which is disabled for getting the unscaled outline. - * - */ - return cf2_intToFixed( - decoder->builder.face->root.size->metrics.y_ppem ); - } - - - /* get standard stem widths for the current subfont; */ - /* FreeType stores these as integer font units */ - /* (note: variable names seem swapped) */ - FT_LOCAL_DEF( CF2_Fixed ) - cf2_getStdVW( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return cf2_intToFixed( - decoder->current_subfont->private_dict.standard_height ); - } - - - FT_LOCAL_DEF( CF2_Fixed ) - cf2_getStdHW( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return cf2_intToFixed( - decoder->current_subfont->private_dict.standard_width ); - } - - - /* note: FreeType stores 1000 times the actual value for `BlueScale' */ - FT_LOCAL_DEF( void ) - cf2_getBlueMetrics( CFF_Decoder* decoder, - CF2_Fixed* blueScale, - CF2_Fixed* blueShift, - CF2_Fixed* blueFuzz ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - *blueScale = FT_DivFix( - decoder->current_subfont->private_dict.blue_scale, - cf2_intToFixed( 1000 ) ); - *blueShift = cf2_intToFixed( - decoder->current_subfont->private_dict.blue_shift ); - *blueFuzz = cf2_intToFixed( - decoder->current_subfont->private_dict.blue_fuzz ); - } - - - /* get blue values counts and arrays; the FreeType parser has validated */ - /* the counts and verified that each is an even number */ - FT_LOCAL_DEF( void ) - cf2_getBlueValues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - *count = decoder->current_subfont->private_dict.num_blue_values; - *data = (FT_Pos*) - &decoder->current_subfont->private_dict.blue_values; - } - - - FT_LOCAL_DEF( void ) - cf2_getOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - *count = decoder->current_subfont->private_dict.num_other_blues; - *data = (FT_Pos*) - &decoder->current_subfont->private_dict.other_blues; - } - - - FT_LOCAL_DEF( void ) - cf2_getFamilyBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - *count = decoder->current_subfont->private_dict.num_family_blues; - *data = (FT_Pos*) - &decoder->current_subfont->private_dict.family_blues; - } - - - FT_LOCAL_DEF( void ) - cf2_getFamilyOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - *count = decoder->current_subfont->private_dict.num_family_other_blues; - *data = (FT_Pos*) - &decoder->current_subfont->private_dict.family_other_blues; - } - - - FT_LOCAL_DEF( CF2_Int ) - cf2_getLanguageGroup( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return decoder->current_subfont->private_dict.language_group; - } - - - /* convert unbiased subroutine index to `CF2_Buffer' and */ - /* return 0 on success */ - FT_LOCAL_DEF( CF2_Int ) - cf2_initGlobalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ) - { - CF2_UInt idx; - - - FT_ASSERT( decoder ); - - FT_ZERO( buf ); - - idx = (CF2_UInt)( subrNum + decoder->globals_bias ); - if ( idx >= decoder->num_globals ) - return TRUE; /* error */ - - FT_ASSERT( decoder->globals ); - - buf->start = - buf->ptr = decoder->globals[idx]; - buf->end = decoder->globals[idx + 1]; - - return FALSE; /* success */ - } - - - /* convert AdobeStandardEncoding code to CF2_Buffer; */ - /* used for seac component */ - FT_LOCAL_DEF( FT_Error ) - cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_Int code, - CF2_Buffer buf ) - { - CF2_Int gid; - FT_Byte* charstring; - FT_ULong len; - FT_Error error; - - - FT_ASSERT( decoder ); - - FT_ZERO( buf ); - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* Incremental fonts don't necessarily have valid charsets. */ - /* They use the character code, not the glyph index, in this case. */ - if ( decoder->builder.face->root.internal->incremental_interface ) - gid = code; - else -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - { - gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code ); - if ( gid < 0 ) - return FT_THROW( Invalid_Glyph_Format ); - } - - error = cff_get_glyph_data( decoder->builder.face, - (CF2_UInt)gid, - &charstring, - &len ); - /* TODO: for now, just pass the FreeType error through */ - if ( error ) - return error; - - /* assume input has been validated */ - FT_ASSERT( charstring + len >= charstring ); - - buf->start = charstring; - buf->end = charstring + len; - buf->ptr = buf->start; - - return FT_Err_Ok; - } - - - FT_LOCAL_DEF( void ) - cf2_freeSeacComponent( CFF_Decoder* decoder, - CF2_Buffer buf ) - { - FT_ASSERT( decoder ); - - cff_free_glyph_data( decoder->builder.face, - (FT_Byte**)&buf->start, - (FT_ULong)( buf->end - buf->start ) ); - } - - - FT_LOCAL_DEF( CF2_Int ) - cf2_initLocalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ) - { - CF2_UInt idx; - - - FT_ASSERT( decoder ); - - FT_ZERO( buf ); - - idx = (CF2_UInt)( subrNum + decoder->locals_bias ); - if ( idx >= decoder->num_locals ) - return TRUE; /* error */ - - FT_ASSERT( decoder->locals ); - - buf->start = - buf->ptr = decoder->locals[idx]; - buf->end = decoder->locals[idx + 1]; - - return FALSE; /* success */ - } - - - FT_LOCAL_DEF( CF2_Fixed ) - cf2_getDefaultWidthX( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return cf2_intToFixed( - decoder->current_subfont->private_dict.default_width ); - } - - - FT_LOCAL_DEF( CF2_Fixed ) - cf2_getNominalWidthX( CFF_Decoder* decoder ) - { - FT_ASSERT( decoder && decoder->current_subfont ); - - return cf2_intToFixed( - decoder->current_subfont->private_dict.nominal_width ); - } - - - FT_LOCAL_DEF( void ) - cf2_outline_reset( CF2_Outline outline ) - { - CFF_Decoder* decoder = outline->decoder; - - - FT_ASSERT( decoder ); - - outline->root.windingMomentum = 0; - - FT_GlyphLoader_Rewind( decoder->builder.loader ); - } - - - FT_LOCAL_DEF( void ) - cf2_outline_close( CF2_Outline outline ) - { - CFF_Decoder* decoder = outline->decoder; - - - FT_ASSERT( decoder ); - - cff_builder_close_contour( &decoder->builder ); - - FT_GlyphLoader_Add( decoder->builder.loader ); - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h deleted file mode 100644 index b054a6e950c..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.h +++ /dev/null @@ -1,159 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2ft.h */ -/* */ -/* FreeType Glue Component to Adobe's Interpreter (specification). */ -/* */ -/* Copyright 2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2FT_H_ -#define CF2FT_H_ - - -#include "cf2types.h" - - - /* TODO: disable asserts for now */ -#define CF2_NDEBUG - - -#include FT_SYSTEM_H - -#include "cf2glue.h" -#include "cffgload.h" /* for CFF_Decoder */ - - -FT_BEGIN_HEADER - - - FT_LOCAL( FT_Error ) - cf2_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len ); - - FT_LOCAL( CFF_SubFont ) - cf2_getSubfont( CFF_Decoder* decoder ); - - FT_LOCAL( CFF_VStore ) - cf2_getVStore( CFF_Decoder* decoder ); - - FT_LOCAL( FT_UInt ) - cf2_getMaxstack( CFF_Decoder* decoder ); - -#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_LOCAL( FT_Error ) - cf2_getNormalizedVector( CFF_Decoder* decoder, - CF2_UInt *len, - FT_Fixed* *vec ); -#endif - - FT_LOCAL( CF2_Fixed ) - cf2_getPpemY( CFF_Decoder* decoder ); - FT_LOCAL( CF2_Fixed ) - cf2_getStdVW( CFF_Decoder* decoder ); - FT_LOCAL( CF2_Fixed ) - cf2_getStdHW( CFF_Decoder* decoder ); - - FT_LOCAL( void ) - cf2_getBlueMetrics( CFF_Decoder* decoder, - CF2_Fixed* blueScale, - CF2_Fixed* blueShift, - CF2_Fixed* blueFuzz ); - FT_LOCAL( void ) - cf2_getBlueValues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); - FT_LOCAL( void ) - cf2_getOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); - FT_LOCAL( void ) - cf2_getFamilyBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); - FT_LOCAL( void ) - cf2_getFamilyOtherBlues( CFF_Decoder* decoder, - size_t* count, - FT_Pos* *data ); - - FT_LOCAL( CF2_Int ) - cf2_getLanguageGroup( CFF_Decoder* decoder ); - - FT_LOCAL( CF2_Int ) - cf2_initGlobalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ); - FT_LOCAL( FT_Error ) - cf2_getSeacComponent( CFF_Decoder* decoder, - CF2_Int code, - CF2_Buffer buf ); - FT_LOCAL( void ) - cf2_freeSeacComponent( CFF_Decoder* decoder, - CF2_Buffer buf ); - FT_LOCAL( CF2_Int ) - cf2_initLocalRegionBuffer( CFF_Decoder* decoder, - CF2_Int subrNum, - CF2_Buffer buf ); - - FT_LOCAL( CF2_Fixed ) - cf2_getDefaultWidthX( CFF_Decoder* decoder ); - FT_LOCAL( CF2_Fixed ) - cf2_getNominalWidthX( CFF_Decoder* decoder ); - - - /* - * FreeType client outline - * - * process output from the charstring interpreter - */ - typedef struct CF2_OutlineRec_ - { - CF2_OutlineCallbacksRec root; /* base class must be first */ - CFF_Decoder* decoder; - - } CF2_OutlineRec, *CF2_Outline; - - - FT_LOCAL( void ) - cf2_outline_reset( CF2_Outline outline ); - FT_LOCAL( void ) - cf2_outline_close( CF2_Outline outline ); - - -FT_END_HEADER - - -#endif /* CF2FT_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h deleted file mode 100644 index 56a7c248f4e..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2glue.h +++ /dev/null @@ -1,144 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2glue.h */ -/* */ -/* Adobe's code for shared stuff (specification only). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2GLUE_H_ -#define CF2GLUE_H_ - - -/* common includes for other modules */ -#include "cf2error.h" -#include "cf2fixed.h" -#include "cf2arrst.h" -#include "cf2read.h" - - -FT_BEGIN_HEADER - - - /* rendering parameters */ - - /* apply hints to rendered glyphs */ -#define CF2_FlagsHinted 1 - /* for testing */ -#define CF2_FlagsDarkened 2 - - /* type for holding the flags */ - typedef CF2_Int CF2_RenderingFlags; - - - /* elements of a glyph outline */ - typedef enum CF2_PathOp_ - { - CF2_PathOpMoveTo = 1, /* change the current point */ - CF2_PathOpLineTo = 2, /* line */ - CF2_PathOpQuadTo = 3, /* quadratic curve */ - CF2_PathOpCubeTo = 4 /* cubic curve */ - - } CF2_PathOp; - - - /* a matrix of fixed point values */ - typedef struct CF2_Matrix_ - { - CF2_F16Dot16 a; - CF2_F16Dot16 b; - CF2_F16Dot16 c; - CF2_F16Dot16 d; - CF2_F16Dot16 tx; - CF2_F16Dot16 ty; - - } CF2_Matrix; - - - /* these typedefs are needed by more than one header file */ - /* and gcc compiler doesn't allow redefinition */ - typedef struct CF2_FontRec_ CF2_FontRec, *CF2_Font; - typedef struct CF2_HintRec_ CF2_HintRec, *CF2_Hint; - - - /* A common structure for all callback parameters. */ - /* */ - /* Some members may be unused. For example, `pt0' is not used for */ - /* `moveTo' and `pt3' is not used for `quadTo'. The initial point `pt0' */ - /* is included for each path element for generality; curve conversions */ - /* need it. The `op' parameter allows one function to handle multiple */ - /* element types. */ - - typedef struct CF2_CallbackParamsRec_ - { - FT_Vector pt0; - FT_Vector pt1; - FT_Vector pt2; - FT_Vector pt3; - - CF2_Int op; - - } CF2_CallbackParamsRec, *CF2_CallbackParams; - - - /* forward reference */ - typedef struct CF2_OutlineCallbacksRec_ CF2_OutlineCallbacksRec, - *CF2_OutlineCallbacks; - - /* callback function pointers */ - typedef void - (*CF2_Callback_Type)( CF2_OutlineCallbacks callbacks, - const CF2_CallbackParams params ); - - - struct CF2_OutlineCallbacksRec_ - { - CF2_Callback_Type moveTo; - CF2_Callback_Type lineTo; - CF2_Callback_Type quadTo; - CF2_Callback_Type cubeTo; - - CF2_Int windingMomentum; /* for winding order detection */ - - FT_Memory memory; - FT_Error* error; - }; - - -FT_END_HEADER - - -#endif /* CF2GLUE_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c deleted file mode 100644 index 656eb2cff17..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.c +++ /dev/null @@ -1,1875 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2hints.c */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2hints.h" -#include "cf2intrp.h" - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_cf2hints - - - typedef struct CF2_HintMoveRec_ - { - size_t j; /* index of upper hint map edge */ - CF2_Fixed moveUp; /* adjustment to optimum position */ - - } CF2_HintMoveRec, *CF2_HintMove; - - - /* Compute angular momentum for winding order detection. It is called */ - /* for all lines and curves, but not necessarily in element order. */ - static CF2_Int - cf2_getWindingMomentum( CF2_Fixed x1, - CF2_Fixed y1, - CF2_Fixed x2, - CF2_Fixed y2 ) - { - /* cross product of pt1 position from origin with pt2 position from */ - /* pt1; we reduce the precision so that the result fits into 32 bits */ - - return ( x1 >> 16 ) * ( SUB_INT32( y2, y1 ) >> 16 ) - - ( y1 >> 16 ) * ( SUB_INT32( x2, x1 ) >> 16 ); - } - - - /* - * Construct from a StemHint; this is used as a parameter to - * `cf2_blues_capture'. - * `hintOrigin' is the character space displacement of a seac accent. - * Adjust stem hint for darkening here. - * - */ - static void - cf2_hint_init( CF2_Hint hint, - const CF2_ArrStack stemHintArray, - size_t indexStemHint, - const CF2_Font font, - CF2_Fixed hintOrigin, - CF2_Fixed scale, - FT_Bool bottom ) - { - CF2_Fixed width; - const CF2_StemHintRec* stemHint; - - - FT_ZERO( hint ); - - stemHint = (const CF2_StemHintRec*)cf2_arrstack_getPointer( - stemHintArray, - indexStemHint ); - - width = SUB_INT32( stemHint->max, stemHint->min ); - - if ( width == cf2_intToFixed( -21 ) ) - { - /* ghost bottom */ - - if ( bottom ) - { - hint->csCoord = stemHint->max; - hint->flags = CF2_GhostBottom; - } - else - hint->flags = 0; - } - - else if ( width == cf2_intToFixed( -20 ) ) - { - /* ghost top */ - - if ( bottom ) - hint->flags = 0; - else - { - hint->csCoord = stemHint->min; - hint->flags = CF2_GhostTop; - } - } - - else if ( width < 0 ) - { - /* inverted pair */ - - /* - * Hints with negative widths were produced by an early version of a - * non-Adobe font tool. The Type 2 spec allows edge (ghost) hints - * with negative widths, but says - * - * All other negative widths have undefined meaning. - * - * CoolType has a silent workaround that negates the hint width; for - * permissive mode, we do the same here. - * - * Note: Such fonts cannot use ghost hints, but should otherwise work. - * Note: Some poor hints in our faux fonts can produce negative - * widths at some blends. For example, see a light weight of - * `u' in ASerifMM. - * - */ - if ( bottom ) - { - hint->csCoord = stemHint->max; - hint->flags = CF2_PairBottom; - } - else - { - hint->csCoord = stemHint->min; - hint->flags = CF2_PairTop; - } - } - - else - { - /* normal pair */ - - if ( bottom ) - { - hint->csCoord = stemHint->min; - hint->flags = CF2_PairBottom; - } - else - { - hint->csCoord = stemHint->max; - hint->flags = CF2_PairTop; - } - } - - /* Now that ghost hints have been detected, adjust this edge for */ - /* darkening. Bottoms are not changed; tops are incremented by twice */ - /* `darkenY'. */ - if ( cf2_hint_isTop( hint ) ) - hint->csCoord = ADD_INT32( hint->csCoord, 2 * font->darkenY ); - - hint->csCoord = ADD_INT32( hint->csCoord, hintOrigin ); - hint->scale = scale; - hint->index = indexStemHint; /* index in original stem hint array */ - - /* if original stem hint has been used, use the same position */ - if ( hint->flags != 0 && stemHint->used ) - { - if ( cf2_hint_isTop( hint ) ) - hint->dsCoord = stemHint->maxDS; - else - hint->dsCoord = stemHint->minDS; - - cf2_hint_lock( hint ); - } - else - hint->dsCoord = FT_MulFix( hint->csCoord, scale ); - } - - - /* initialize an invalid hint map element */ - static void - cf2_hint_initZero( CF2_Hint hint ) - { - FT_ZERO( hint ); - } - - - FT_LOCAL_DEF( FT_Bool ) - cf2_hint_isValid( const CF2_Hint hint ) - { - return (FT_Bool)( hint->flags != 0 ); - } - - - static FT_Bool - cf2_hint_isPair( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_PairTop ) ) != 0 ); - } - - - static FT_Bool - cf2_hint_isPairTop( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & CF2_PairTop ) != 0 ); - } - - - FT_LOCAL_DEF( FT_Bool ) - cf2_hint_isTop( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & - ( CF2_PairTop | CF2_GhostTop ) ) != 0 ); - } - - - FT_LOCAL_DEF( FT_Bool ) - cf2_hint_isBottom( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & - ( CF2_PairBottom | CF2_GhostBottom ) ) != 0 ); - } - - - static FT_Bool - cf2_hint_isLocked( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & CF2_Locked ) != 0 ); - } - - - static FT_Bool - cf2_hint_isSynthetic( const CF2_Hint hint ) - { - return (FT_Bool)( ( hint->flags & CF2_Synthetic ) != 0 ); - } - - - FT_LOCAL_DEF( void ) - cf2_hint_lock( CF2_Hint hint ) - { - hint->flags |= CF2_Locked; - } - - - FT_LOCAL_DEF( void ) - cf2_hintmap_init( CF2_HintMap hintmap, - CF2_Font font, - CF2_HintMap initialMap, - CF2_ArrStack hintMoves, - CF2_Fixed scale ) - { - FT_ZERO( hintmap ); - - /* copy parameters from font instance */ - hintmap->hinted = font->hinted; - hintmap->scale = scale; - hintmap->font = font; - hintmap->initialHintMap = initialMap; - /* will clear in `cf2_hintmap_adjustHints' */ - hintmap->hintMoves = hintMoves; - } - - - static FT_Bool - cf2_hintmap_isValid( const CF2_HintMap hintmap ) - { - return hintmap->isValid; - } - - - /* transform character space coordinate to device space using hint map */ - static CF2_Fixed - cf2_hintmap_map( CF2_HintMap hintmap, - CF2_Fixed csCoord ) - { - if ( hintmap->count == 0 || ! hintmap->hinted ) - { - /* there are no hints; use uniform scale and zero offset */ - return FT_MulFix( csCoord, hintmap->scale ); - } - else - { - /* start linear search from last hit */ - CF2_UInt i = hintmap->lastIndex; - - - FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES ); - - /* search up */ - while ( i < hintmap->count - 1 && - csCoord >= hintmap->edge[i + 1].csCoord ) - i += 1; - - /* search down */ - while ( i > 0 && csCoord < hintmap->edge[i].csCoord ) - i -= 1; - - hintmap->lastIndex = i; - - if ( i == 0 && csCoord < hintmap->edge[0].csCoord ) - { - /* special case for points below first edge: use uniform scale */ - return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, - hintmap->edge[0].csCoord ), - hintmap->scale ), - hintmap->edge[0].dsCoord ); - } - else - { - /* - * Note: entries with duplicate csCoord are allowed. - * Use edge[i], the highest entry where csCoord >= entry[i].csCoord - */ - return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, - hintmap->edge[i].csCoord ), - hintmap->edge[i].scale ), - hintmap->edge[i].dsCoord ); - } - } - } - - - /* - * This hinting policy moves a hint pair in device space so that one of - * its two edges is on a device pixel boundary (its fractional part is - * zero). `cf2_hintmap_insertHint' guarantees no overlap in CS - * space. Ensure here that there is no overlap in DS. - * - * In the first pass, edges are adjusted relative to adjacent hints. - * Those that are below have already been adjusted. Those that are - * above have not yet been adjusted. If a hint above blocks an - * adjustment to an optimal position, we will try again in a second - * pass. The second pass is top-down. - * - */ - - static void - cf2_hintmap_adjustHints( CF2_HintMap hintmap ) - { - size_t i, j; - - - cf2_arrstack_clear( hintmap->hintMoves ); /* working storage */ - - /* - * First pass is bottom-up (font hint order) without look-ahead. - * Locked edges are already adjusted. - * Unlocked edges begin with dsCoord from `initialHintMap'. - * Save edges that are not optimally adjusted in `hintMoves' array, - * and process them in second pass. - */ - - for ( i = 0; i < hintmap->count; i++ ) - { - FT_Bool isPair = cf2_hint_isPair( &hintmap->edge[i] ); - - - /* index of upper edge (same value for ghost hint) */ - j = isPair ? i + 1 : i; - - FT_ASSERT( j < hintmap->count ); - FT_ASSERT( cf2_hint_isValid( &hintmap->edge[i] ) ); - FT_ASSERT( cf2_hint_isValid( &hintmap->edge[j] ) ); - FT_ASSERT( cf2_hint_isLocked( &hintmap->edge[i] ) == - cf2_hint_isLocked( &hintmap->edge[j] ) ); - - if ( !cf2_hint_isLocked( &hintmap->edge[i] ) ) - { - /* hint edge is not locked, we can adjust it */ - CF2_Fixed fracDown = cf2_fixedFraction( hintmap->edge[i].dsCoord ); - CF2_Fixed fracUp = cf2_fixedFraction( hintmap->edge[j].dsCoord ); - - /* calculate all four possibilities; moves down are negative */ - CF2_Fixed downMoveDown = 0 - fracDown; - CF2_Fixed upMoveDown = 0 - fracUp; - CF2_Fixed downMoveUp = ( fracDown == 0 ) - ? 0 - : cf2_intToFixed( 1 ) - fracDown; - CF2_Fixed upMoveUp = ( fracUp == 0 ) - ? 0 - : cf2_intToFixed( 1 ) - fracUp; - - /* smallest move up */ - CF2_Fixed moveUp = FT_MIN( downMoveUp, upMoveUp ); - /* smallest move down */ - CF2_Fixed moveDown = FT_MAX( downMoveDown, upMoveDown ); - - /* final amount to move edge or edge pair */ - CF2_Fixed move; - - CF2_Fixed downMinCounter = CF2_MIN_COUNTER; - CF2_Fixed upMinCounter = CF2_MIN_COUNTER; - FT_Bool saveEdge = FALSE; - - - /* minimum counter constraint doesn't apply when adjacent edges */ - /* are synthetic */ - /* TODO: doesn't seem a big effect; for now, reduce the code */ -#if 0 - if ( i == 0 || - cf2_hint_isSynthetic( &hintmap->edge[i - 1] ) ) - downMinCounter = 0; - - if ( j >= hintmap->count - 1 || - cf2_hint_isSynthetic( &hintmap->edge[j + 1] ) ) - upMinCounter = 0; -#endif - - /* is there room to move up? */ - /* there is if we are at top of array or the next edge is at or */ - /* beyond proposed move up? */ - if ( j >= hintmap->count - 1 || - hintmap->edge[j + 1].dsCoord >= - ADD_INT32( hintmap->edge[j].dsCoord, - moveUp + upMinCounter ) ) - { - /* there is room to move up; is there also room to move down? */ - if ( i == 0 || - hintmap->edge[i - 1].dsCoord <= - ADD_INT32( hintmap->edge[i].dsCoord, - moveDown - downMinCounter ) ) - { - /* move smaller absolute amount */ - move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */ - } - else - move = moveUp; - } - else - { - /* is there room to move down? */ - if ( i == 0 || - hintmap->edge[i - 1].dsCoord <= - ADD_INT32( hintmap->edge[i].dsCoord, - moveDown - downMinCounter ) ) - { - move = moveDown; - /* true if non-optimum move */ - saveEdge = (FT_Bool)( moveUp < -moveDown ); - } - else - { - /* no room to move either way without overlapping or reducing */ - /* the counter too much */ - move = 0; - saveEdge = TRUE; - } - } - - /* Identify non-moves and moves down that aren't optimal, and save */ - /* them for second pass. */ - /* Do this only if there is an unlocked edge above (which could */ - /* possibly move). */ - if ( saveEdge && - j < hintmap->count - 1 && - !cf2_hint_isLocked( &hintmap->edge[j + 1] ) ) - { - CF2_HintMoveRec savedMove; - - - savedMove.j = j; - /* desired adjustment in second pass */ - savedMove.moveUp = moveUp - move; - - cf2_arrstack_push( hintmap->hintMoves, &savedMove ); - } - - /* move the edge(s) */ - hintmap->edge[i].dsCoord = ADD_INT32( hintmap->edge[i].dsCoord, - move ); - if ( isPair ) - hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord, - move ); - } - - /* assert there are no overlaps in device space */ - FT_ASSERT( i == 0 || - hintmap->edge[i - 1].dsCoord <= hintmap->edge[i].dsCoord ); - FT_ASSERT( i < j || - hintmap->edge[i].dsCoord <= hintmap->edge[j].dsCoord ); - - /* adjust the scales, avoiding divide by zero */ - if ( i > 0 ) - { - if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord ) - hintmap->edge[i - 1].scale = - FT_DivFix( SUB_INT32( hintmap->edge[i].dsCoord, - hintmap->edge[i - 1].dsCoord ), - SUB_INT32( hintmap->edge[i].csCoord, - hintmap->edge[i - 1].csCoord ) ); - } - - if ( isPair ) - { - if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord ) - hintmap->edge[j - 1].scale = - FT_DivFix( SUB_INT32( hintmap->edge[j].dsCoord, - hintmap->edge[j - 1].dsCoord ), - SUB_INT32( hintmap->edge[j].csCoord, - hintmap->edge[j - 1].csCoord ) ); - - i += 1; /* skip upper edge on next loop */ - } - } - - /* second pass tries to move non-optimal hints up, in case there is */ - /* room now */ - for ( i = cf2_arrstack_size( hintmap->hintMoves ); i > 0; i-- ) - { - CF2_HintMove hintMove = (CF2_HintMove) - cf2_arrstack_getPointer( hintmap->hintMoves, i - 1 ); - - - j = hintMove->j; - - /* this was tested before the push, above */ - FT_ASSERT( j < hintmap->count - 1 ); - - /* is there room to move up? */ - if ( hintmap->edge[j + 1].dsCoord >= - ADD_INT32( hintmap->edge[j].dsCoord, - hintMove->moveUp + CF2_MIN_COUNTER ) ) - { - /* there is more room now, move edge up */ - hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord, - hintMove->moveUp ); - - if ( cf2_hint_isPair( &hintmap->edge[j] ) ) - { - FT_ASSERT( j > 0 ); - hintmap->edge[j - 1].dsCoord = - ADD_INT32( hintmap->edge[j - 1].dsCoord, hintMove->moveUp ); - } - } - } - } - - - /* insert hint edges into map, sorted by csCoord */ - static void - cf2_hintmap_insertHint( CF2_HintMap hintmap, - CF2_Hint bottomHintEdge, - CF2_Hint topHintEdge ) - { - CF2_UInt indexInsert; - - /* set default values, then check for edge hints */ - FT_Bool isPair = TRUE; - CF2_Hint firstHintEdge = bottomHintEdge; - CF2_Hint secondHintEdge = topHintEdge; - - - /* one or none of the input params may be invalid when dealing with */ - /* edge hints; at least one edge must be valid */ - FT_ASSERT( cf2_hint_isValid( bottomHintEdge ) || - cf2_hint_isValid( topHintEdge ) ); - - /* determine how many and which edges to insert */ - if ( !cf2_hint_isValid( bottomHintEdge ) ) - { - /* insert only the top edge */ - firstHintEdge = topHintEdge; - isPair = FALSE; - } - else if ( !cf2_hint_isValid( topHintEdge ) ) - { - /* insert only the bottom edge */ - isPair = FALSE; - } - - /* paired edges must be in proper order */ - if ( isPair && - topHintEdge->csCoord < bottomHintEdge->csCoord ) - return; - - /* linear search to find index value of insertion point */ - indexInsert = 0; - for ( ; indexInsert < hintmap->count; indexInsert++ ) - { - if ( hintmap->edge[indexInsert].csCoord >= firstHintEdge->csCoord ) - break; - } - - /* - * Discard any hints that overlap in character space. Most often, this - * is while building the initial map, where captured hints from all - * zones are combined. Define overlap to include hints that `touch' - * (overlap zero). Hiragino Sans/Gothic fonts have numerous hints that - * touch. Some fonts have non-ideographic glyphs that overlap our - * synthetic hints. - * - * Overlap also occurs when darkening stem hints that are close. - * - */ - if ( indexInsert < hintmap->count ) - { - /* we are inserting before an existing edge: */ - /* verify that an existing edge is not the same */ - if ( hintmap->edge[indexInsert].csCoord == firstHintEdge->csCoord ) - return; /* ignore overlapping stem hint */ - - /* verify that a new pair does not straddle the next edge */ - if ( isPair && - hintmap->edge[indexInsert].csCoord <= secondHintEdge->csCoord ) - return; /* ignore overlapping stem hint */ - - /* verify that we are not inserting between paired edges */ - if ( cf2_hint_isPairTop( &hintmap->edge[indexInsert] ) ) - return; /* ignore overlapping stem hint */ - } - - /* recompute device space locations using initial hint map */ - if ( cf2_hintmap_isValid( hintmap->initialHintMap ) && - !cf2_hint_isLocked( firstHintEdge ) ) - { - if ( isPair ) - { - /* Use hint map to position the center of stem, and nominal scale */ - /* to position the two edges. This preserves the stem width. */ - CF2_Fixed midpoint = - cf2_hintmap_map( - hintmap->initialHintMap, - ADD_INT32( secondHintEdge->csCoord, - firstHintEdge->csCoord ) / 2 ); - CF2_Fixed halfWidth = - FT_MulFix( SUB_INT32( secondHintEdge->csCoord, - firstHintEdge->csCoord ) / 2, - hintmap->scale ); - - - firstHintEdge->dsCoord = SUB_INT32( midpoint, halfWidth ); - secondHintEdge->dsCoord = ADD_INT32( midpoint, halfWidth ); - } - else - firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap, - firstHintEdge->csCoord ); - } - - /* - * Discard any hints that overlap in device space; this can occur - * because locked hints have been moved to align with blue zones. - * - * TODO: Although we might correct this later during adjustment, we - * don't currently have a way to delete a conflicting hint once it has - * been inserted. See v2.030 MinionPro-Regular, 12 ppem darkened, - * initial hint map for second path, glyph 945 (the perispomeni (tilde) - * in U+1F6E, Greek omega with psili and perispomeni). Darkening is - * 25. Pair 667,747 initially conflicts in design space with top edge - * 660. This is because 667 maps to 7.87, and the top edge was - * captured by a zone at 8.0. The pair is later successfully inserted - * in a zone without the top edge. In this zone it is adjusted to 8.0, - * and no longer conflicts with the top edge in design space. This - * means it can be included in yet a later zone which does have the top - * edge hint. This produces a small mismatch between the first and - * last points of this path, even though the hint masks are the same. - * The density map difference is tiny (1/256). - * - */ - - if ( indexInsert > 0 ) - { - /* we are inserting after an existing edge */ - if ( firstHintEdge->dsCoord < hintmap->edge[indexInsert - 1].dsCoord ) - return; - } - - if ( indexInsert < hintmap->count ) - { - /* we are inserting before an existing edge */ - if ( isPair ) - { - if ( secondHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord ) - return; - } - else - { - if ( firstHintEdge->dsCoord > hintmap->edge[indexInsert].dsCoord ) - return; - } - } - - /* make room to insert */ - { - CF2_UInt iSrc = hintmap->count - 1; - CF2_UInt iDst = isPair ? hintmap->count + 1 : hintmap->count; - - CF2_UInt count = hintmap->count - indexInsert; - - - if ( iDst >= CF2_MAX_HINT_EDGES ) - { - FT_TRACE4(( "cf2_hintmap_insertHint: too many hintmaps\n" )); - return; - } - - while ( count-- ) - hintmap->edge[iDst--] = hintmap->edge[iSrc--]; - - /* insert first edge */ - hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */ - hintmap->count += 1; - - if ( isPair ) - { - /* insert second edge */ - hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */ - hintmap->count += 1; - } - } - - return; - } - - - /* - * Build a map from hints and mask. - * - * This function may recur one level if `hintmap->initialHintMap' is not yet - * valid. - * If `initialMap' is true, simply build initial map. - * - * Synthetic hints are used in two ways. A hint at zero is inserted, if - * needed, in the initial hint map, to prevent translations from - * propagating across the origin. If synthetic em box hints are enabled - * for ideographic dictionaries, then they are inserted in all hint - * maps, including the initial one. - * - */ - FT_LOCAL_DEF( void ) - cf2_hintmap_build( CF2_HintMap hintmap, - CF2_ArrStack hStemHintArray, - CF2_ArrStack vStemHintArray, - CF2_HintMask hintMask, - CF2_Fixed hintOrigin, - FT_Bool initialMap ) - { - FT_Byte* maskPtr; - - CF2_Font font = hintmap->font; - CF2_HintMaskRec tempHintMask; - - size_t bitCount, i; - FT_Byte maskByte; - - - /* check whether initial map is constructed */ - if ( !initialMap && !cf2_hintmap_isValid( hintmap->initialHintMap ) ) - { - /* make recursive call with initialHintMap and temporary mask; */ - /* temporary mask will get all bits set, below */ - cf2_hintmask_init( &tempHintMask, hintMask->error ); - cf2_hintmap_build( hintmap->initialHintMap, - hStemHintArray, - vStemHintArray, - &tempHintMask, - hintOrigin, - TRUE ); - } - - if ( !cf2_hintmask_isValid( hintMask ) ) - { - /* without a hint mask, assume all hints are active */ - cf2_hintmask_setAll( hintMask, - cf2_arrstack_size( hStemHintArray ) + - cf2_arrstack_size( vStemHintArray ) ); - if ( !cf2_hintmask_isValid( hintMask ) ) - return; /* too many stem hints */ - } - - /* begin by clearing the map */ - hintmap->count = 0; - hintmap->lastIndex = 0; - - /* make a copy of the hint mask so we can modify it */ - tempHintMask = *hintMask; - maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask ); - - /* use the hStem hints only, which are first in the mask */ - bitCount = cf2_arrstack_size( hStemHintArray ); - - /* Defense-in-depth. Should never return here. */ - if ( bitCount > hintMask->bitCount ) - return; - - /* synthetic embox hints get highest priority */ - if ( font->blues.doEmBoxHints ) - { - CF2_HintRec dummy; - - - cf2_hint_initZero( &dummy ); /* invalid hint map element */ - - /* ghost bottom */ - cf2_hintmap_insertHint( hintmap, - &font->blues.emBoxBottomEdge, - &dummy ); - /* ghost top */ - cf2_hintmap_insertHint( hintmap, - &dummy, - &font->blues.emBoxTopEdge ); - } - - /* insert hints captured by a blue zone or already locked (higher */ - /* priority) */ - for ( i = 0, maskByte = 0x80; i < bitCount; i++ ) - { - if ( maskByte & *maskPtr ) - { - /* expand StemHint into two `CF2_Hint' elements */ - CF2_HintRec bottomHintEdge, topHintEdge; - - - cf2_hint_init( &bottomHintEdge, - hStemHintArray, - i, - font, - hintOrigin, - hintmap->scale, - TRUE /* bottom */ ); - cf2_hint_init( &topHintEdge, - hStemHintArray, - i, - font, - hintOrigin, - hintmap->scale, - FALSE /* top */ ); - - if ( cf2_hint_isLocked( &bottomHintEdge ) || - cf2_hint_isLocked( &topHintEdge ) || - cf2_blues_capture( &font->blues, - &bottomHintEdge, - &topHintEdge ) ) - { - /* insert captured hint into map */ - cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge ); - - *maskPtr &= ~maskByte; /* turn off the bit for this hint */ - } - } - - if ( ( i & 7 ) == 7 ) - { - /* move to next mask byte */ - maskPtr++; - maskByte = 0x80; - } - else - maskByte >>= 1; - } - - /* initial hint map includes only captured hints plus maybe one at 0 */ - - /* - * TODO: There is a problem here because we are trying to build a - * single hint map containing all captured hints. It is - * possible for there to be conflicts between captured hints, - * either because of darkening or because the hints are in - * separate hint zones (we are ignoring hint zones for the - * initial map). An example of the latter is MinionPro-Regular - * v2.030 glyph 883 (Greek Capital Alpha with Psili) at 15ppem. - * A stem hint for the psili conflicts with the top edge hint - * for the base character. The stem hint gets priority because - * of its sort order. In glyph 884 (Greek Capital Alpha with - * Psili and Oxia), the top of the base character gets a stem - * hint, and the psili does not. This creates different initial - * maps for the two glyphs resulting in different renderings of - * the base character. Will probably defer this either as not - * worth the cost or as a font bug. I don't think there is any - * good reason for an accent to be captured by an alignment - * zone. -darnold 2/12/10 - */ - - if ( initialMap ) - { - /* Apply a heuristic that inserts a point for (0,0), unless it's */ - /* already covered by a mapping. This locks the baseline for glyphs */ - /* that have no baseline hints. */ - - if ( hintmap->count == 0 || - hintmap->edge[0].csCoord > 0 || - hintmap->edge[hintmap->count - 1].csCoord < 0 ) - { - /* all edges are above 0 or all edges are below 0; */ - /* construct a locked edge hint at 0 */ - - CF2_HintRec edge, invalid; - - - cf2_hint_initZero( &edge ); - - edge.flags = CF2_GhostBottom | - CF2_Locked | - CF2_Synthetic; - edge.scale = hintmap->scale; - - cf2_hint_initZero( &invalid ); - cf2_hintmap_insertHint( hintmap, &edge, &invalid ); - } - } - else - { - /* insert remaining hints */ - - maskPtr = cf2_hintmask_getMaskPtr( &tempHintMask ); - - for ( i = 0, maskByte = 0x80; i < bitCount; i++ ) - { - if ( maskByte & *maskPtr ) - { - CF2_HintRec bottomHintEdge, topHintEdge; - - - cf2_hint_init( &bottomHintEdge, - hStemHintArray, - i, - font, - hintOrigin, - hintmap->scale, - TRUE /* bottom */ ); - cf2_hint_init( &topHintEdge, - hStemHintArray, - i, - font, - hintOrigin, - hintmap->scale, - FALSE /* top */ ); - - cf2_hintmap_insertHint( hintmap, &bottomHintEdge, &topHintEdge ); - } - - if ( ( i & 7 ) == 7 ) - { - /* move to next mask byte */ - maskPtr++; - maskByte = 0x80; - } - else - maskByte >>= 1; - } - } - - /* - * Note: The following line is a convenient place to break when - * debugging hinting. Examine `hintmap->edge' for the list of - * enabled hints, then step over the call to see the effect of - * adjustment. We stop here first on the recursive call that - * creates the initial map, and then on each counter group and - * hint zone. - */ - - /* adjust positions of hint edges that are not locked to blue zones */ - cf2_hintmap_adjustHints( hintmap ); - - /* save the position of all hints that were used in this hint map; */ - /* if we use them again, we'll locate them in the same position */ - if ( !initialMap ) - { - for ( i = 0; i < hintmap->count; i++ ) - { - if ( !cf2_hint_isSynthetic( &hintmap->edge[i] ) ) - { - /* Note: include both valid and invalid edges */ - /* Note: top and bottom edges are copied back separately */ - CF2_StemHint stemhint = (CF2_StemHint) - cf2_arrstack_getPointer( hStemHintArray, - hintmap->edge[i].index ); - - - if ( cf2_hint_isTop( &hintmap->edge[i] ) ) - stemhint->maxDS = hintmap->edge[i].dsCoord; - else - stemhint->minDS = hintmap->edge[i].dsCoord; - - stemhint->used = TRUE; - } - } - } - - /* hint map is ready to use */ - hintmap->isValid = TRUE; - - /* remember this mask has been used */ - cf2_hintmask_setNew( hintMask, FALSE ); - } - - - FT_LOCAL_DEF( void ) - cf2_glyphpath_init( CF2_GlyphPath glyphpath, - CF2_Font font, - CF2_OutlineCallbacks callbacks, - CF2_Fixed scaleY, - /* CF2_Fixed hShift, */ - CF2_ArrStack hStemHintArray, - CF2_ArrStack vStemHintArray, - CF2_HintMask hintMask, - CF2_Fixed hintOriginY, - const CF2_Blues blues, - const FT_Vector* fractionalTranslation ) - { - FT_ZERO( glyphpath ); - - glyphpath->font = font; - glyphpath->callbacks = callbacks; - - cf2_arrstack_init( &glyphpath->hintMoves, - font->memory, - &font->error, - sizeof ( CF2_HintMoveRec ) ); - - cf2_hintmap_init( &glyphpath->initialHintMap, - font, - &glyphpath->initialHintMap, - &glyphpath->hintMoves, - scaleY ); - cf2_hintmap_init( &glyphpath->firstHintMap, - font, - &glyphpath->initialHintMap, - &glyphpath->hintMoves, - scaleY ); - cf2_hintmap_init( &glyphpath->hintMap, - font, - &glyphpath->initialHintMap, - &glyphpath->hintMoves, - scaleY ); - - glyphpath->scaleX = font->innerTransform.a; - glyphpath->scaleC = font->innerTransform.c; - glyphpath->scaleY = font->innerTransform.d; - - glyphpath->fractionalTranslation = *fractionalTranslation; - -#if 0 - glyphpath->hShift = hShift; /* for fauxing */ -#endif - - glyphpath->hStemHintArray = hStemHintArray; - glyphpath->vStemHintArray = vStemHintArray; - glyphpath->hintMask = hintMask; /* ptr to current mask */ - glyphpath->hintOriginY = hintOriginY; - glyphpath->blues = blues; - glyphpath->darken = font->darkened; /* TODO: should we make copies? */ - glyphpath->xOffset = font->darkenX; - glyphpath->yOffset = font->darkenY; - glyphpath->miterLimit = 2 * FT_MAX( - cf2_fixedAbs( glyphpath->xOffset ), - cf2_fixedAbs( glyphpath->yOffset ) ); - - /* .1 character space unit */ - glyphpath->snapThreshold = cf2_doubleToFixed( 0.1 ); - - glyphpath->moveIsPending = TRUE; - glyphpath->pathIsOpen = FALSE; - glyphpath->pathIsClosing = FALSE; - glyphpath->elemIsQueued = FALSE; - } - - - FT_LOCAL_DEF( void ) - cf2_glyphpath_finalize( CF2_GlyphPath glyphpath ) - { - cf2_arrstack_finalize( &glyphpath->hintMoves ); - } - - - /* - * Hint point in y-direction and apply outerTransform. - * Input `current' hint map (which is actually delayed by one element). - * Input x,y point in Character Space. - * Output x,y point in Device Space, including translation. - */ - static void - cf2_glyphpath_hintPoint( CF2_GlyphPath glyphpath, - CF2_HintMap hintmap, - FT_Vector* ppt, - CF2_Fixed x, - CF2_Fixed y ) - { - FT_Vector pt; /* hinted point in upright DS */ - - - pt.x = ADD_INT32( FT_MulFix( glyphpath->scaleX, x ), - FT_MulFix( glyphpath->scaleC, y ) ); - pt.y = cf2_hintmap_map( hintmap, y ); - - ppt->x = ADD_INT32( - FT_MulFix( glyphpath->font->outerTransform.a, pt.x ), - ADD_INT32( - FT_MulFix( glyphpath->font->outerTransform.c, pt.y ), - glyphpath->fractionalTranslation.x ) ); - ppt->y = ADD_INT32( - FT_MulFix( glyphpath->font->outerTransform.b, pt.x ), - ADD_INT32( - FT_MulFix( glyphpath->font->outerTransform.d, pt.y ), - glyphpath->fractionalTranslation.y ) ); - } - - - /* - * From two line segments, (u1,u2) and (v1,v2), compute a point of - * intersection on the corresponding lines. - * Return false if no intersection is found, or if the intersection is - * too far away from the ends of the line segments, u2 and v1. - * - */ - static FT_Bool - cf2_glyphpath_computeIntersection( CF2_GlyphPath glyphpath, - const FT_Vector* u1, - const FT_Vector* u2, - const FT_Vector* v1, - const FT_Vector* v2, - FT_Vector* intersection ) - { - /* - * Let `u' be a zero-based vector from the first segment, `v' from the - * second segment. - * Let `w 'be the zero-based vector from `u1' to `v1'. - * `perp' is the `perpendicular dot product'; see - * http://mathworld.wolfram.com/PerpDotProduct.html. - * `s' is the parameter for the parametric line for the first segment - * (`u'). - * - * See notation in - * http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm. - * Calculations are done in 16.16, but must handle the squaring of - * line lengths in character space. We scale all vectors by 1/32 to - * avoid overflow. This allows values up to 4095 to be squared. The - * scale factor cancels in the divide. - * - * TODO: the scale factor could be computed from UnitsPerEm. - * - */ - -#define cf2_perp( a, b ) \ - ( FT_MulFix( a.x, b.y ) - FT_MulFix( a.y, b.x ) ) - - /* round and divide by 32 */ -#define CF2_CS_SCALE( x ) \ - ( ( (x) + 0x10 ) >> 5 ) - - FT_Vector u, v, w; /* scaled vectors */ - CF2_Fixed denominator, s; - - - u.x = CF2_CS_SCALE( SUB_INT32( u2->x, u1->x ) ); - u.y = CF2_CS_SCALE( SUB_INT32( u2->y, u1->y ) ); - v.x = CF2_CS_SCALE( SUB_INT32( v2->x, v1->x ) ); - v.y = CF2_CS_SCALE( SUB_INT32( v2->y, v1->y ) ); - w.x = CF2_CS_SCALE( SUB_INT32( v1->x, u1->x ) ); - w.y = CF2_CS_SCALE( SUB_INT32( v1->y, u1->y ) ); - - denominator = cf2_perp( u, v ); - - if ( denominator == 0 ) - return FALSE; /* parallel or coincident lines */ - - s = FT_DivFix( cf2_perp( w, v ), denominator ); - - intersection->x = ADD_INT32( u1->x, - FT_MulFix( s, SUB_INT32( u2->x, u1->x ) ) ); - intersection->y = ADD_INT32( u1->y, - FT_MulFix( s, SUB_INT32( u2->y, u1->y ) ) ); - - - /* - * Special case snapping for horizontal and vertical lines. - * This cleans up intersections and reduces problems with winding - * order detection. - * Sample case is sbc cd KozGoPr6N-Medium.otf 20 16685. - * Note: these calculations are in character space. - * - */ - - if ( u1->x == u2->x && - cf2_fixedAbs( SUB_INT32( intersection->x, - u1->x ) ) < glyphpath->snapThreshold ) - intersection->x = u1->x; - if ( u1->y == u2->y && - cf2_fixedAbs( SUB_INT32( intersection->y, - u1->y ) ) < glyphpath->snapThreshold ) - intersection->y = u1->y; - - if ( v1->x == v2->x && - cf2_fixedAbs( SUB_INT32( intersection->x, - v1->x ) ) < glyphpath->snapThreshold ) - intersection->x = v1->x; - if ( v1->y == v2->y && - cf2_fixedAbs( SUB_INT32( intersection->y, - v1->y ) ) < glyphpath->snapThreshold ) - intersection->y = v1->y; - - /* limit the intersection distance from midpoint of u2 and v1 */ - if ( cf2_fixedAbs( intersection->x - ADD_INT32( u2->x, v1->x ) / 2 ) > - glyphpath->miterLimit || - cf2_fixedAbs( intersection->y - ADD_INT32( u2->y, v1->y ) / 2 ) > - glyphpath->miterLimit ) - return FALSE; - - return TRUE; - } - - - /* - * Push the cached element (glyphpath->prevElem*) to the outline - * consumer. When a darkening offset is used, the end point of the - * cached element may be adjusted to an intersection point or we may - * synthesize a connecting line to the current element. If we are - * closing a subpath, we may also generate a connecting line to the start - * point. - * - * This is where Character Space (CS) is converted to Device Space (DS) - * using a hint map. This calculation must use a HintMap that was valid - * at the time the element was saved. For the first point in a subpath, - * that is a saved HintMap. For most elements, it just means the caller - * has delayed building a HintMap from the current HintMask. - * - * Transform each point with outerTransform and call the outline - * callbacks. This is a general 3x3 transform: - * - * x' = a*x + c*y + tx, y' = b*x + d*y + ty - * - * but it uses 4 elements from CF2_Font and the translation part - * from CF2_GlyphPath. - * - */ - static void - cf2_glyphpath_pushPrevElem( CF2_GlyphPath glyphpath, - CF2_HintMap hintmap, - FT_Vector* nextP0, - FT_Vector nextP1, - FT_Bool close ) - { - CF2_CallbackParamsRec params; - - FT_Vector* prevP0; - FT_Vector* prevP1; - - FT_Vector intersection = { 0, 0 }; - FT_Bool useIntersection = FALSE; - - - FT_ASSERT( glyphpath->prevElemOp == CF2_PathOpLineTo || - glyphpath->prevElemOp == CF2_PathOpCubeTo ); - - if ( glyphpath->prevElemOp == CF2_PathOpLineTo ) - { - prevP0 = &glyphpath->prevElemP0; - prevP1 = &glyphpath->prevElemP1; - } - else - { - prevP0 = &glyphpath->prevElemP2; - prevP1 = &glyphpath->prevElemP3; - } - - /* optimization: if previous and next elements are offset by the same */ - /* amount, then there will be no gap, and no need to compute an */ - /* intersection. */ - if ( prevP1->x != nextP0->x || prevP1->y != nextP0->y ) - { - /* previous element does not join next element: */ - /* adjust end point of previous element to the intersection */ - useIntersection = cf2_glyphpath_computeIntersection( glyphpath, - prevP0, - prevP1, - nextP0, - &nextP1, - &intersection ); - if ( useIntersection ) - { - /* modify the last point of the cached element (either line or */ - /* curve) */ - *prevP1 = intersection; - } - } - - params.pt0 = glyphpath->currentDS; - - switch( glyphpath->prevElemOp ) - { - case CF2_PathOpLineTo: - params.op = CF2_PathOpLineTo; - - /* note: pt2 and pt3 are unused */ - - if ( close ) - { - /* use first hint map if closing */ - cf2_glyphpath_hintPoint( glyphpath, - &glyphpath->firstHintMap, - ¶ms.pt1, - glyphpath->prevElemP1.x, - glyphpath->prevElemP1.y ); - } - else - { - cf2_glyphpath_hintPoint( glyphpath, - hintmap, - ¶ms.pt1, - glyphpath->prevElemP1.x, - glyphpath->prevElemP1.y ); - } - - /* output only non-zero length lines */ - if ( params.pt0.x != params.pt1.x || params.pt0.y != params.pt1.y ) - { - glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms ); - - glyphpath->currentDS = params.pt1; - } - break; - - case CF2_PathOpCubeTo: - params.op = CF2_PathOpCubeTo; - - /* TODO: should we intersect the interior joins (p1-p2 and p2-p3)? */ - cf2_glyphpath_hintPoint( glyphpath, - hintmap, - ¶ms.pt1, - glyphpath->prevElemP1.x, - glyphpath->prevElemP1.y ); - cf2_glyphpath_hintPoint( glyphpath, - hintmap, - ¶ms.pt2, - glyphpath->prevElemP2.x, - glyphpath->prevElemP2.y ); - cf2_glyphpath_hintPoint( glyphpath, - hintmap, - ¶ms.pt3, - glyphpath->prevElemP3.x, - glyphpath->prevElemP3.y ); - - glyphpath->callbacks->cubeTo( glyphpath->callbacks, ¶ms ); - - glyphpath->currentDS = params.pt3; - - break; - } - - if ( !useIntersection || close ) - { - /* insert connecting line between end of previous element and start */ - /* of current one */ - /* note: at the end of a subpath, we might do both, so use `nextP0' */ - /* before we change it, below */ - - if ( close ) - { - /* if we are closing the subpath, then nextP0 is in the first */ - /* hint zone */ - cf2_glyphpath_hintPoint( glyphpath, - &glyphpath->firstHintMap, - ¶ms.pt1, - nextP0->x, - nextP0->y ); - } - else - { - cf2_glyphpath_hintPoint( glyphpath, - hintmap, - ¶ms.pt1, - nextP0->x, - nextP0->y ); - } - - if ( params.pt1.x != glyphpath->currentDS.x || - params.pt1.y != glyphpath->currentDS.y ) - { - /* length is nonzero */ - params.op = CF2_PathOpLineTo; - params.pt0 = glyphpath->currentDS; - - /* note: pt2 and pt3 are unused */ - glyphpath->callbacks->lineTo( glyphpath->callbacks, ¶ms ); - - glyphpath->currentDS = params.pt1; - } - } - - if ( useIntersection ) - { - /* return intersection point to caller */ - *nextP0 = intersection; - } - } - - - /* push a MoveTo element based on current point and offset of current */ - /* element */ - static void - cf2_glyphpath_pushMove( CF2_GlyphPath glyphpath, - FT_Vector start ) - { - CF2_CallbackParamsRec params; - - - params.op = CF2_PathOpMoveTo; - params.pt0 = glyphpath->currentDS; - - /* Test if move has really happened yet; it would have called */ - /* `cf2_hintmap_build' to set `isValid'. */ - if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) ) - { - /* we are here iff first subpath is missing a moveto operator: */ - /* synthesize first moveTo to finish initialization of hintMap */ - cf2_glyphpath_moveTo( glyphpath, - glyphpath->start.x, - glyphpath->start.y ); - } - - cf2_glyphpath_hintPoint( glyphpath, - &glyphpath->hintMap, - ¶ms.pt1, - start.x, - start.y ); - - /* note: pt2 and pt3 are unused */ - glyphpath->callbacks->moveTo( glyphpath->callbacks, ¶ms ); - - glyphpath->currentDS = params.pt1; - glyphpath->offsetStart0 = start; - } - - - /* - * All coordinates are in character space. - * On input, (x1, y1) and (x2, y2) give line segment. - * On output, (x, y) give offset vector. - * We use a piecewise approximation to trig functions. - * - * TODO: Offset true perpendicular and proper length - * supply the y-translation for hinting here, too, - * that adds yOffset unconditionally to *y. - */ - static void - cf2_glyphpath_computeOffset( CF2_GlyphPath glyphpath, - CF2_Fixed x1, - CF2_Fixed y1, - CF2_Fixed x2, - CF2_Fixed y2, - CF2_Fixed* x, - CF2_Fixed* y ) - { - CF2_Fixed dx = SUB_INT32( x2, x1 ); - CF2_Fixed dy = SUB_INT32( y2, y1 ); - - - /* note: negative offsets don't work here; negate deltas to change */ - /* quadrants, below */ - if ( glyphpath->font->reverseWinding ) - { - dx = NEG_INT32( dx ); - dy = NEG_INT32( dy ); - } - - *x = *y = 0; - - if ( !glyphpath->darken ) - return; - - /* add momentum for this path element */ - glyphpath->callbacks->windingMomentum = - ADD_INT32( glyphpath->callbacks->windingMomentum, - cf2_getWindingMomentum( x1, y1, x2, y2 ) ); - - /* note: allow mixed integer and fixed multiplication here */ - if ( dx >= 0 ) - { - if ( dy >= 0 ) - { - /* first quadrant, +x +y */ - - if ( dx > MUL_INT32( 2, dy ) ) - { - /* +x */ - *x = 0; - *y = 0; - } - else if ( dy > MUL_INT32( 2, dx ) ) - { - /* +y */ - *x = glyphpath->xOffset; - *y = glyphpath->yOffset; - } - else - { - /* +x +y */ - *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), - glyphpath->xOffset ); - *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), - glyphpath->yOffset ); - } - } - else - { - /* fourth quadrant, +x -y */ - - if ( dx > MUL_INT32( -2, dy ) ) - { - /* +x */ - *x = 0; - *y = 0; - } - else if ( NEG_INT32( dy ) > MUL_INT32( 2, dx ) ) - { - /* -y */ - *x = NEG_INT32( glyphpath->xOffset ); - *y = glyphpath->yOffset; - } - else - { - /* +x -y */ - *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), - glyphpath->xOffset ); - *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), - glyphpath->yOffset ); - } - } - } - else - { - if ( dy >= 0 ) - { - /* second quadrant, -x +y */ - - if ( NEG_INT32( dx ) > MUL_INT32( 2, dy ) ) - { - /* -x */ - *x = 0; - *y = MUL_INT32( 2, glyphpath->yOffset ); - } - else if ( dy > MUL_INT32( -2, dx ) ) - { - /* +y */ - *x = glyphpath->xOffset; - *y = glyphpath->yOffset; - } - else - { - /* -x +y */ - *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), - glyphpath->xOffset ); - *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), - glyphpath->yOffset ); - } - } - else - { - /* third quadrant, -x -y */ - - if ( NEG_INT32( dx ) > MUL_INT32( -2, dy ) ) - { - /* -x */ - *x = 0; - *y = MUL_INT32( 2, glyphpath->yOffset ); - } - else if ( NEG_INT32( dy ) > MUL_INT32( -2, dx ) ) - { - /* -y */ - *x = NEG_INT32( glyphpath->xOffset ); - *y = glyphpath->yOffset; - } - else - { - /* -x -y */ - *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), - glyphpath->xOffset ); - *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), - glyphpath->yOffset ); - } - } - } - } - - - /* - * The functions cf2_glyphpath_{moveTo,lineTo,curveTo,closeOpenPath} are - * called by the interpreter with Character Space (CS) coordinates. Each - * path element is placed into a queue of length one to await the - * calculation of the following element. At that time, the darkening - * offset of the following element is known and joins can be computed, - * including possible modification of this element, before mapping to - * Device Space (DS) and passing it on to the outline consumer. - * - */ - FT_LOCAL_DEF( void ) - cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath, - CF2_Fixed x, - CF2_Fixed y ) - { - cf2_glyphpath_closeOpenPath( glyphpath ); - - /* save the parameters of the move for later, when we'll know how to */ - /* offset it; */ - /* also save last move point */ - glyphpath->currentCS.x = glyphpath->start.x = x; - glyphpath->currentCS.y = glyphpath->start.y = y; - - glyphpath->moveIsPending = TRUE; - - /* ensure we have a valid map with current mask */ - if ( !cf2_hintmap_isValid( &glyphpath->hintMap ) || - cf2_hintmask_isNew( glyphpath->hintMask ) ) - cf2_hintmap_build( &glyphpath->hintMap, - glyphpath->hStemHintArray, - glyphpath->vStemHintArray, - glyphpath->hintMask, - glyphpath->hintOriginY, - FALSE ); - - /* save a copy of current HintMap to use when drawing initial point */ - glyphpath->firstHintMap = glyphpath->hintMap; /* structure copy */ - } - - - FT_LOCAL_DEF( void ) - cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath, - CF2_Fixed x, - CF2_Fixed y ) - { - CF2_Fixed xOffset, yOffset; - FT_Vector P0, P1; - FT_Bool newHintMap; - - /* - * New hints will be applied after cf2_glyphpath_pushPrevElem has run. - * In case this is a synthesized closing line, any new hints should be - * delayed until this path is closed (`cf2_hintmask_isNew' will be - * called again before the next line or curve). - */ - - /* true if new hint map not on close */ - newHintMap = cf2_hintmask_isNew( glyphpath->hintMask ) && - !glyphpath->pathIsClosing; - - /* - * Zero-length lines may occur in the charstring. Because we cannot - * compute darkening offsets or intersections from zero-length lines, - * it is best to remove them and avoid artifacts. However, zero-length - * lines in CS at the start of a new hint map can generate non-zero - * lines in DS due to hint substitution. We detect a change in hint - * map here and pass those zero-length lines along. - */ - - /* - * Note: Find explicitly closed paths here with a conditional - * breakpoint using - * - * !gp->pathIsClosing && gp->start.x == x && gp->start.y == y - * - */ - - if ( glyphpath->currentCS.x == x && - glyphpath->currentCS.y == y && - !newHintMap ) - /* - * Ignore zero-length lines in CS where the hint map is the same - * because the line in DS will also be zero length. - * - * Ignore zero-length lines when we synthesize a closing line because - * the close will be handled in cf2_glyphPath_pushPrevElem. - */ - return; - - cf2_glyphpath_computeOffset( glyphpath, - glyphpath->currentCS.x, - glyphpath->currentCS.y, - x, - y, - &xOffset, - &yOffset ); - - /* construct offset points */ - P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset ); - P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset ); - P1.x = ADD_INT32( x, xOffset ); - P1.y = ADD_INT32( y, yOffset ); - - if ( glyphpath->moveIsPending ) - { - /* emit offset 1st point as MoveTo */ - cf2_glyphpath_pushMove( glyphpath, P0 ); - - glyphpath->moveIsPending = FALSE; /* adjust state machine */ - glyphpath->pathIsOpen = TRUE; - - glyphpath->offsetStart1 = P1; /* record second point */ - } - - if ( glyphpath->elemIsQueued ) - { - FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) || - glyphpath->hintMap.count == 0 ); - - cf2_glyphpath_pushPrevElem( glyphpath, - &glyphpath->hintMap, - &P0, - P1, - FALSE ); - } - - /* queue the current element with offset points */ - glyphpath->elemIsQueued = TRUE; - glyphpath->prevElemOp = CF2_PathOpLineTo; - glyphpath->prevElemP0 = P0; - glyphpath->prevElemP1 = P1; - - /* update current map */ - if ( newHintMap ) - cf2_hintmap_build( &glyphpath->hintMap, - glyphpath->hStemHintArray, - glyphpath->vStemHintArray, - glyphpath->hintMask, - glyphpath->hintOriginY, - FALSE ); - - glyphpath->currentCS.x = x; /* pre-offset current point */ - glyphpath->currentCS.y = y; - } - - - FT_LOCAL_DEF( void ) - cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath, - CF2_Fixed x1, - CF2_Fixed y1, - CF2_Fixed x2, - CF2_Fixed y2, - CF2_Fixed x3, - CF2_Fixed y3 ) - { - CF2_Fixed xOffset1, yOffset1, xOffset3, yOffset3; - FT_Vector P0, P1, P2, P3; - - - /* TODO: ignore zero length portions of curve?? */ - cf2_glyphpath_computeOffset( glyphpath, - glyphpath->currentCS.x, - glyphpath->currentCS.y, - x1, - y1, - &xOffset1, - &yOffset1 ); - cf2_glyphpath_computeOffset( glyphpath, - x2, - y2, - x3, - y3, - &xOffset3, - &yOffset3 ); - - /* add momentum from the middle segment */ - glyphpath->callbacks->windingMomentum = - ADD_INT32( glyphpath->callbacks->windingMomentum, - cf2_getWindingMomentum( x1, y1, x2, y2 ) ); - - /* construct offset points */ - P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset1 ); - P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset1 ); - P1.x = ADD_INT32( x1, xOffset1 ); - P1.y = ADD_INT32( y1, yOffset1 ); - /* note: preserve angle of final segment by using offset3 at both ends */ - P2.x = ADD_INT32( x2, xOffset3 ); - P2.y = ADD_INT32( y2, yOffset3 ); - P3.x = ADD_INT32( x3, xOffset3 ); - P3.y = ADD_INT32( y3, yOffset3 ); - - if ( glyphpath->moveIsPending ) - { - /* emit offset 1st point as MoveTo */ - cf2_glyphpath_pushMove( glyphpath, P0 ); - - glyphpath->moveIsPending = FALSE; - glyphpath->pathIsOpen = TRUE; - - glyphpath->offsetStart1 = P1; /* record second point */ - } - - if ( glyphpath->elemIsQueued ) - { - FT_ASSERT( cf2_hintmap_isValid( &glyphpath->hintMap ) || - glyphpath->hintMap.count == 0 ); - - cf2_glyphpath_pushPrevElem( glyphpath, - &glyphpath->hintMap, - &P0, - P1, - FALSE ); - } - - /* queue the current element with offset points */ - glyphpath->elemIsQueued = TRUE; - glyphpath->prevElemOp = CF2_PathOpCubeTo; - glyphpath->prevElemP0 = P0; - glyphpath->prevElemP1 = P1; - glyphpath->prevElemP2 = P2; - glyphpath->prevElemP3 = P3; - - /* update current map */ - if ( cf2_hintmask_isNew( glyphpath->hintMask ) ) - cf2_hintmap_build( &glyphpath->hintMap, - glyphpath->hStemHintArray, - glyphpath->vStemHintArray, - glyphpath->hintMask, - glyphpath->hintOriginY, - FALSE ); - - glyphpath->currentCS.x = x3; /* pre-offset current point */ - glyphpath->currentCS.y = y3; - } - - - FT_LOCAL_DEF( void ) - cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath ) - { - if ( glyphpath->pathIsOpen ) - { - /* - * A closing line in Character Space line is always generated below - * with `cf2_glyphPath_lineTo'. It may be ignored later if it turns - * out to be zero length in Device Space. - */ - glyphpath->pathIsClosing = TRUE; - - cf2_glyphpath_lineTo( glyphpath, - glyphpath->start.x, - glyphpath->start.y ); - - /* empty the final element from the queue and close the path */ - if ( glyphpath->elemIsQueued ) - cf2_glyphpath_pushPrevElem( glyphpath, - &glyphpath->hintMap, - &glyphpath->offsetStart0, - glyphpath->offsetStart1, - TRUE ); - - /* reset state machine */ - glyphpath->moveIsPending = TRUE; - glyphpath->pathIsOpen = FALSE; - glyphpath->pathIsClosing = FALSE; - glyphpath->elemIsQueued = FALSE; - } - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h deleted file mode 100644 index a8984542a01..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2hints.h +++ /dev/null @@ -1,289 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2hints.h */ -/* */ -/* Adobe's code for handling CFF hints (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2HINTS_H_ -#define CF2HINTS_H_ - - -FT_BEGIN_HEADER - - - enum - { - CF2_MAX_HINTS = 96 /* maximum # of hints */ - }; - - - /* - * A HintMask object stores a bit mask that specifies which hints in the - * charstring are active at a given time. Hints in CFF must be declared - * at the start, before any drawing operators, with horizontal hints - * preceding vertical hints. The HintMask is ordered the same way, with - * horizontal hints immediately followed by vertical hints. Clients are - * responsible for knowing how many of each type are present. - * - * The maximum total number of hints is 96, as specified by the CFF - * specification. - * - * A HintMask is built 0 or more times while interpreting a charstring, by - * the HintMask operator. There is only one HintMask, but it is built or - * rebuilt each time there is a hint substitution (HintMask operator) in - * the charstring. A default HintMask with all bits set is built if there - * has been no HintMask operator prior to the first drawing operator. - * - */ - - typedef struct CF2_HintMaskRec_ - { - FT_Error* error; - - FT_Bool isValid; - FT_Bool isNew; - - size_t bitCount; - size_t byteCount; - - FT_Byte mask[( CF2_MAX_HINTS + 7 ) / 8]; - - } CF2_HintMaskRec, *CF2_HintMask; - - - typedef struct CF2_StemHintRec_ - { - FT_Bool used; /* DS positions are valid */ - - CF2_Fixed min; /* original character space value */ - CF2_Fixed max; - - CF2_Fixed minDS; /* DS position after first use */ - CF2_Fixed maxDS; - - } CF2_StemHintRec, *CF2_StemHint; - - - /* - * A HintMap object stores a piecewise linear function for mapping - * y-coordinates from character space to device space, providing - * appropriate pixel alignment to stem edges. - * - * The map is implemented as an array of `CF2_Hint' elements, each - * representing an edge. When edges are paired, as from stem hints, the - * bottom edge must immediately precede the top edge in the array. - * Element character space AND device space positions must both increase - * monotonically in the array. `CF2_Hint' elements are also used as - * parameters to `cf2_blues_capture'. - * - * The `cf2_hintmap_build' method must be called before any drawing - * operation (beginning with a Move operator) and at each hint - * substitution (HintMask operator). - * - * The `cf2_hintmap_map' method is called to transform y-coordinates at - * each drawing operation (move, line, curve). - * - */ - - /* TODO: make this a CF2_ArrStack and add a deep copy method */ - enum - { - CF2_MAX_HINT_EDGES = CF2_MAX_HINTS * 2 - }; - - - typedef struct CF2_HintMapRec_ - { - CF2_Font font; - - /* initial map based on blue zones */ - struct CF2_HintMapRec_* initialHintMap; - - /* working storage for 2nd pass adjustHints */ - CF2_ArrStack hintMoves; - - FT_Bool isValid; - FT_Bool hinted; - - CF2_Fixed scale; - CF2_UInt count; - - /* start search from this index */ - CF2_UInt lastIndex; - - CF2_HintRec edge[CF2_MAX_HINT_EDGES]; /* 192 */ - - } CF2_HintMapRec, *CF2_HintMap; - - - FT_LOCAL( FT_Bool ) - cf2_hint_isValid( const CF2_Hint hint ); - FT_LOCAL( FT_Bool ) - cf2_hint_isTop( const CF2_Hint hint ); - FT_LOCAL( FT_Bool ) - cf2_hint_isBottom( const CF2_Hint hint ); - FT_LOCAL( void ) - cf2_hint_lock( CF2_Hint hint ); - - - FT_LOCAL( void ) - cf2_hintmap_init( CF2_HintMap hintmap, - CF2_Font font, - CF2_HintMap initialMap, - CF2_ArrStack hintMoves, - CF2_Fixed scale ); - FT_LOCAL( void ) - cf2_hintmap_build( CF2_HintMap hintmap, - CF2_ArrStack hStemHintArray, - CF2_ArrStack vStemHintArray, - CF2_HintMask hintMask, - CF2_Fixed hintOrigin, - FT_Bool initialMap ); - - - /* - * GlyphPath is a wrapper for drawing operations that scales the - * coordinates according to the render matrix and HintMap. It also tracks - * open paths to control ClosePath and to insert MoveTo for broken fonts. - * - */ - typedef struct CF2_GlyphPathRec_ - { - /* TODO: gather some of these into a hinting context */ - - CF2_Font font; /* font instance */ - CF2_OutlineCallbacks callbacks; /* outline consumer */ - - - CF2_HintMapRec hintMap; /* current hint map */ - CF2_HintMapRec firstHintMap; /* saved copy */ - CF2_HintMapRec initialHintMap; /* based on all captured hints */ - - CF2_ArrStackRec hintMoves; /* list of hint moves for 2nd pass */ - - CF2_Fixed scaleX; /* matrix a */ - CF2_Fixed scaleC; /* matrix c */ - CF2_Fixed scaleY; /* matrix d */ - - FT_Vector fractionalTranslation; /* including deviceXScale */ -#if 0 - CF2_Fixed hShift; /* character space horizontal shift */ - /* (for fauxing) */ -#endif - - FT_Bool pathIsOpen; /* true after MoveTo */ - FT_Bool pathIsClosing; /* true when synthesizing closepath line */ - FT_Bool darken; /* true if stem darkening */ - FT_Bool moveIsPending; /* true between MoveTo and offset MoveTo */ - - /* references used to call `cf2_hintmap_build', if necessary */ - CF2_ArrStack hStemHintArray; - CF2_ArrStack vStemHintArray; - CF2_HintMask hintMask; /* ptr to the current mask */ - CF2_Fixed hintOriginY; /* copy of current origin */ - const CF2_BluesRec* blues; - - CF2_Fixed xOffset; /* character space offsets */ - CF2_Fixed yOffset; - - /* character space miter limit threshold */ - CF2_Fixed miterLimit; - /* vertical/horizontal snap distance in character space */ - CF2_Fixed snapThreshold; - - FT_Vector offsetStart0; /* first and second points of first */ - FT_Vector offsetStart1; /* element with offset applied */ - - /* current point, character space, before offset */ - FT_Vector currentCS; - /* current point, device space */ - FT_Vector currentDS; - /* start point of subpath, character space */ - FT_Vector start; - - /* the following members constitute the `queue' of one element */ - FT_Bool elemIsQueued; - CF2_Int prevElemOp; - - FT_Vector prevElemP0; - FT_Vector prevElemP1; - FT_Vector prevElemP2; - FT_Vector prevElemP3; - - } CF2_GlyphPathRec, *CF2_GlyphPath; - - - FT_LOCAL( void ) - cf2_glyphpath_init( CF2_GlyphPath glyphpath, - CF2_Font font, - CF2_OutlineCallbacks callbacks, - CF2_Fixed scaleY, - /* CF2_Fixed hShift, */ - CF2_ArrStack hStemHintArray, - CF2_ArrStack vStemHintArray, - CF2_HintMask hintMask, - CF2_Fixed hintOrigin, - const CF2_Blues blues, - const FT_Vector* fractionalTranslation ); - FT_LOCAL( void ) - cf2_glyphpath_finalize( CF2_GlyphPath glyphpath ); - - FT_LOCAL( void ) - cf2_glyphpath_moveTo( CF2_GlyphPath glyphpath, - CF2_Fixed x, - CF2_Fixed y ); - FT_LOCAL( void ) - cf2_glyphpath_lineTo( CF2_GlyphPath glyphpath, - CF2_Fixed x, - CF2_Fixed y ); - FT_LOCAL( void ) - cf2_glyphpath_curveTo( CF2_GlyphPath glyphpath, - CF2_Fixed x1, - CF2_Fixed y1, - CF2_Fixed x2, - CF2_Fixed y2, - CF2_Fixed x3, - CF2_Fixed y3 ); - FT_LOCAL( void ) - cf2_glyphpath_closeOpenPath( CF2_GlyphPath glyphpath ); - - -FT_END_HEADER - - -#endif /* CF2HINTS_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c deleted file mode 100644 index a8162807485..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c +++ /dev/null @@ -1,1959 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2intrp.c */ -/* */ -/* Adobe's CFF Interpreter (body). */ -/* */ -/* Copyright 2007-2014 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2stack.h" -#include "cf2hints.h" -#include "cf2intrp.h" - -#include "cf2error.h" - -#include "cffload.h" - - - /*************************************************************************/ - /* */ - /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ - /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ - /* messages during execution. */ - /* */ -#undef FT_COMPONENT -#define FT_COMPONENT trace_cf2interp - - - FT_LOCAL_DEF( void ) - cf2_hintmask_init( CF2_HintMask hintmask, - FT_Error* error ) - { - FT_ZERO( hintmask ); - - hintmask->error = error; - } - - - FT_LOCAL_DEF( FT_Bool ) - cf2_hintmask_isValid( const CF2_HintMask hintmask ) - { - return hintmask->isValid; - } - - - FT_LOCAL_DEF( FT_Bool ) - cf2_hintmask_isNew( const CF2_HintMask hintmask ) - { - return hintmask->isNew; - } - - - FT_LOCAL_DEF( void ) - cf2_hintmask_setNew( CF2_HintMask hintmask, - FT_Bool val ) - { - hintmask->isNew = val; - } - - - /* clients call `getMaskPtr' in order to iterate */ - /* through hint mask */ - - FT_LOCAL_DEF( FT_Byte* ) - cf2_hintmask_getMaskPtr( CF2_HintMask hintmask ) - { - return hintmask->mask; - } - - - static size_t - cf2_hintmask_setCounts( CF2_HintMask hintmask, - size_t bitCount ) - { - if ( bitCount > CF2_MAX_HINTS ) - { - /* total of h and v stems must be <= 96 */ - CF2_SET_ERROR( hintmask->error, Invalid_Glyph_Format ); - return 0; - } - - hintmask->bitCount = bitCount; - hintmask->byteCount = ( hintmask->bitCount + 7 ) / 8; - - hintmask->isValid = TRUE; - hintmask->isNew = TRUE; - - return bitCount; - } - - - /* consume the hintmask bytes from the charstring, advancing the src */ - /* pointer */ - static void - cf2_hintmask_read( CF2_HintMask hintmask, - CF2_Buffer charstring, - size_t bitCount ) - { - size_t i; - -#ifndef CF2_NDEBUG - /* these are the bits in the final mask byte that should be zero */ - /* Note: this variable is only used in an assert expression below */ - /* and then only if CF2_NDEBUG is not defined */ - CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1; -#endif - - - /* initialize counts and isValid */ - if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 ) - return; - - FT_ASSERT( hintmask->byteCount > 0 ); - - FT_TRACE4(( " (maskbytes:" )); - - /* set mask and advance interpreter's charstring pointer */ - for ( i = 0; i < hintmask->byteCount; i++ ) - { - hintmask->mask[i] = (FT_Byte)cf2_buf_readByte( charstring ); - FT_TRACE4(( " 0x%02X", hintmask->mask[i] )); - } - - FT_TRACE4(( ")\n" )); - - /* assert any unused bits in last byte are zero unless there's a prior */ - /* error */ - /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */ -#ifndef CF2_NDEBUG - FT_ASSERT( ( hintmask->mask[hintmask->byteCount - 1] & mask ) == 0 || - *hintmask->error ); -#endif - } - - - FT_LOCAL_DEF( void ) - cf2_hintmask_setAll( CF2_HintMask hintmask, - size_t bitCount ) - { - size_t i; - CF2_UInt mask = ( 1 << ( -(CF2_Int)bitCount & 7 ) ) - 1; - - - /* initialize counts and isValid */ - if ( cf2_hintmask_setCounts( hintmask, bitCount ) == 0 ) - return; - - FT_ASSERT( hintmask->byteCount > 0 ); - FT_ASSERT( hintmask->byteCount <= - sizeof ( hintmask->mask ) / sizeof ( hintmask->mask[0] ) ); - - /* set mask to all ones */ - for ( i = 0; i < hintmask->byteCount; i++ ) - hintmask->mask[i] = 0xFF; - - /* clear unused bits */ - /* bitCount -> mask, 0 -> 0, 1 -> 7f, 2 -> 3f, ... 6 -> 3, 7 -> 1 */ - hintmask->mask[hintmask->byteCount - 1] &= ~mask; - } - - - /* Type2 charstring opcodes */ - enum - { - cf2_cmdRESERVED_0, /* 0 */ - cf2_cmdHSTEM, /* 1 */ - cf2_cmdRESERVED_2, /* 2 */ - cf2_cmdVSTEM, /* 3 */ - cf2_cmdVMOVETO, /* 4 */ - cf2_cmdRLINETO, /* 5 */ - cf2_cmdHLINETO, /* 6 */ - cf2_cmdVLINETO, /* 7 */ - cf2_cmdRRCURVETO, /* 8 */ - cf2_cmdRESERVED_9, /* 9 */ - cf2_cmdCALLSUBR, /* 10 */ - cf2_cmdRETURN, /* 11 */ - cf2_cmdESC, /* 12 */ - cf2_cmdRESERVED_13, /* 13 */ - cf2_cmdENDCHAR, /* 14 */ - cf2_cmdVSINDEX, /* 15 */ - cf2_cmdBLEND, /* 16 */ - cf2_cmdRESERVED_17, /* 17 */ - cf2_cmdHSTEMHM, /* 18 */ - cf2_cmdHINTMASK, /* 19 */ - cf2_cmdCNTRMASK, /* 20 */ - cf2_cmdRMOVETO, /* 21 */ - cf2_cmdHMOVETO, /* 22 */ - cf2_cmdVSTEMHM, /* 23 */ - cf2_cmdRCURVELINE, /* 24 */ - cf2_cmdRLINECURVE, /* 25 */ - cf2_cmdVVCURVETO, /* 26 */ - cf2_cmdHHCURVETO, /* 27 */ - cf2_cmdEXTENDEDNMBR, /* 28 */ - cf2_cmdCALLGSUBR, /* 29 */ - cf2_cmdVHCURVETO, /* 30 */ - cf2_cmdHVCURVETO /* 31 */ - }; - - enum - { - cf2_escDOTSECTION, /* 0 */ - cf2_escRESERVED_1, /* 1 */ - cf2_escRESERVED_2, /* 2 */ - cf2_escAND, /* 3 */ - cf2_escOR, /* 4 */ - cf2_escNOT, /* 5 */ - cf2_escRESERVED_6, /* 6 */ - cf2_escRESERVED_7, /* 7 */ - cf2_escRESERVED_8, /* 8 */ - cf2_escABS, /* 9 */ - cf2_escADD, /* 10 like otherADD */ - cf2_escSUB, /* 11 like otherSUB */ - cf2_escDIV, /* 12 */ - cf2_escRESERVED_13, /* 13 */ - cf2_escNEG, /* 14 */ - cf2_escEQ, /* 15 */ - cf2_escRESERVED_16, /* 16 */ - cf2_escRESERVED_17, /* 17 */ - cf2_escDROP, /* 18 */ - cf2_escRESERVED_19, /* 19 */ - cf2_escPUT, /* 20 like otherPUT */ - cf2_escGET, /* 21 like otherGET */ - cf2_escIFELSE, /* 22 like otherIFELSE */ - cf2_escRANDOM, /* 23 like otherRANDOM */ - cf2_escMUL, /* 24 like otherMUL */ - cf2_escRESERVED_25, /* 25 */ - cf2_escSQRT, /* 26 */ - cf2_escDUP, /* 27 like otherDUP */ - cf2_escEXCH, /* 28 like otherEXCH */ - cf2_escINDEX, /* 29 */ - cf2_escROLL, /* 30 */ - cf2_escRESERVED_31, /* 31 */ - cf2_escRESERVED_32, /* 32 */ - cf2_escRESERVED_33, /* 33 */ - cf2_escHFLEX, /* 34 */ - cf2_escFLEX, /* 35 */ - cf2_escHFLEX1, /* 36 */ - cf2_escFLEX1, /* 37 */ - cf2_escRESERVED_38 /* 38 & all higher */ - }; - - - /* `stemHintArray' does not change once we start drawing the outline. */ - static void - cf2_doStems( const CF2_Font font, - CF2_Stack opStack, - CF2_ArrStack stemHintArray, - CF2_Fixed* width, - FT_Bool* haveWidth, - CF2_Fixed hintOffset ) - { - CF2_UInt i; - CF2_UInt count = cf2_stack_count( opStack ); - FT_Bool hasWidthArg = (FT_Bool)( count & 1 ); - - /* variable accumulates delta values from operand stack */ - CF2_Fixed position = hintOffset; - - - if ( hasWidthArg && !*haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + - cf2_getNominalWidthX( font->decoder ); - - if ( font->decoder->width_only ) - goto exit; - - for ( i = hasWidthArg ? 1 : 0; i < count; i += 2 ) - { - /* construct a CF2_StemHint and push it onto the list */ - CF2_StemHintRec stemhint; - - - stemhint.min = - position = ADD_INT32( position, - cf2_stack_getReal( opStack, i ) ); - stemhint.max = - position = ADD_INT32( position, - cf2_stack_getReal( opStack, i + 1 ) ); - - stemhint.used = FALSE; - stemhint.maxDS = - stemhint.minDS = 0; - - cf2_arrstack_push( stemHintArray, &stemhint ); /* defer error check */ - } - - cf2_stack_clear( opStack ); - - exit: - /* cf2_doStems must define a width (may be default) */ - *haveWidth = TRUE; - } - - - static void - cf2_doFlex( CF2_Stack opStack, - CF2_Fixed* curX, - CF2_Fixed* curY, - CF2_GlyphPath glyphPath, - const FT_Bool* readFromStack, - FT_Bool doConditionalLastRead ) - { - CF2_Fixed vals[14]; - CF2_UInt idx; - FT_Bool isHFlex; - CF2_Int top, i, j; - - - vals[0] = *curX; - vals[1] = *curY; - idx = 0; - isHFlex = FT_BOOL( readFromStack[9] == FALSE ); - top = isHFlex ? 9 : 10; - - for ( i = 0; i < top; i++ ) - { - vals[i + 2] = vals[i]; - if ( readFromStack[i] ) - vals[i + 2] = ADD_INT32( vals[i + 2], cf2_stack_getReal( opStack, - idx++ ) ); - } - - if ( isHFlex ) - vals[9 + 2] = *curY; - - if ( doConditionalLastRead ) - { - FT_Bool lastIsX = (FT_Bool)( - cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) > - cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) ); - CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx ); - - - if ( lastIsX ) - { - vals[12] = ADD_INT32( vals[10], lastVal ); - vals[13] = *curY; - } - else - { - vals[12] = *curX; - vals[13] = ADD_INT32( vals[11], lastVal ); - } - } - else - { - if ( readFromStack[10] ) - vals[12] = ADD_INT32( vals[10], - cf2_stack_getReal( opStack, idx++ ) ); - else - vals[12] = *curX; - - if ( readFromStack[11] ) - vals[13] = ADD_INT32( vals[11], - cf2_stack_getReal( opStack, idx ) ); - else - vals[13] = *curY; - } - - for ( j = 0; j < 2; j++ ) - cf2_glyphpath_curveTo( glyphPath, vals[j * 6 + 2], - vals[j * 6 + 3], - vals[j * 6 + 4], - vals[j * 6 + 5], - vals[j * 6 + 6], - vals[j * 6 + 7] ); - - cf2_stack_clear( opStack ); - - *curX = vals[12]; - *curY = vals[13]; - } - - - /* Blend numOperands on the stack, */ - /* store results into the first numBlends values, */ - /* then pop remaining arguments. */ - static void - cf2_doBlend( const CFF_Blend blend, - CF2_Stack opStack, - CF2_UInt numBlends ) - { - CF2_UInt delta; - CF2_UInt base; - CF2_UInt i, j; - CF2_UInt numOperands = (CF2_UInt)( numBlends * blend->lenBV ); - - - base = cf2_stack_count( opStack ) - numOperands; - delta = base + numBlends; - - for ( i = 0; i < numBlends; i++ ) - { - const CF2_Fixed* weight = &blend->BV[1]; - - /* start with first term */ - CF2_Fixed sum = cf2_stack_getReal( opStack, i + base ); - - - for ( j = 1; j < blend->lenBV; j++ ) - sum = ADD_INT32( sum, - FT_MulFix( *weight++, - cf2_stack_getReal( opStack, - delta++ ) ) ); - - /* store blended result */ - cf2_stack_setReal( opStack, i + base, sum ); - } - - /* leave only `numBlends' results on stack */ - cf2_stack_pop( opStack, numOperands - numBlends ); - } - - - /* - * `error' is a shared error code used by many objects in this - * routine. Before the code continues from an error, it must check and - * record the error in `*error'. The idea is that this shared - * error code will record the first error encountered. If testing - * for an error anyway, the cost of `goto exit' is small, so we do it, - * even if continuing would be safe. In this case, `lastError' is - * set, so the testing and storing can be done in one place, at `exit'. - * - * Continuing after an error is intended for objects which do their own - * testing of `*error', e.g., array stack functions. This allows us to - * avoid an extra test after the call. - * - * Unimplemented opcodes are ignored. - * - */ - FT_LOCAL_DEF( void ) - cf2_interpT2CharString( CF2_Font font, - CF2_Buffer buf, - CF2_OutlineCallbacks callbacks, - const FT_Vector* translation, - FT_Bool doingSeac, - CF2_Fixed curX, - CF2_Fixed curY, - CF2_Fixed* width ) - { - /* lastError is used for errors that are immediately tested */ - FT_Error lastError = FT_Err_Ok; - - /* pointer to parsed font object */ - CFF_Decoder* decoder = font->decoder; - - FT_Error* error = &font->error; - FT_Memory memory = font->memory; - - CF2_Fixed scaleY = font->innerTransform.d; - CF2_Fixed nominalWidthX = cf2_getNominalWidthX( decoder ); - - /* save this for hinting seac accents */ - CF2_Fixed hintOriginY = curY; - - CF2_Stack opStack = NULL; - FT_UInt stackSize; - FT_Byte op1; /* first opcode byte */ - - CF2_F16Dot16 storage[CF2_STORAGE_SIZE]; /* for `put' and `get' */ - - /* instruction limit; 20,000,000 matches Avalon */ - FT_UInt32 instructionLimit = 20000000UL; - - CF2_ArrStackRec subrStack; - - FT_Bool haveWidth; - CF2_Buffer charstring = NULL; - - CF2_Int charstringIndex = -1; /* initialize to empty */ - - /* TODO: placeholders for hint structures */ - - /* objects used for hinting */ - CF2_ArrStackRec hStemHintArray; - CF2_ArrStackRec vStemHintArray; - - CF2_HintMaskRec hintMask; - CF2_GlyphPathRec glyphPath; - - - FT_ZERO( &storage ); - - /* initialize the remaining objects */ - cf2_arrstack_init( &subrStack, - memory, - error, - sizeof ( CF2_BufferRec ) ); - cf2_arrstack_init( &hStemHintArray, - memory, - error, - sizeof ( CF2_StemHintRec ) ); - cf2_arrstack_init( &vStemHintArray, - memory, - error, - sizeof ( CF2_StemHintRec ) ); - - /* initialize CF2_StemHint arrays */ - cf2_hintmask_init( &hintMask, error ); - - /* initialize path map to manage drawing operations */ - - /* Note: last 4 params are used to handle `MoveToPermissive', which */ - /* may need to call `hintMap.Build' */ - /* TODO: MoveToPermissive is gone; are these still needed? */ - cf2_glyphpath_init( &glyphPath, - font, - callbacks, - scaleY, - /* hShift, */ - &hStemHintArray, - &vStemHintArray, - &hintMask, - hintOriginY, - &font->blues, - translation ); - - /* - * Initialize state for width parsing. From the CFF Spec: - * - * The first stack-clearing operator, which must be one of hstem, - * hstemhm, vstem, vstemhm, cntrmask, hintmask, hmoveto, vmoveto, - * rmoveto, or endchar, takes an additional argument - the width (as - * described earlier), which may be expressed as zero or one numeric - * argument. - * - * What we implement here uses the first validly specified width, but - * does not detect errors for specifying more than one width. - * - * If one of the above operators occurs without explicitly specifying - * a width, we assume the default width. - * - * CFF2 charstrings always return the default width (0). - * - */ - haveWidth = font->isCFF2 ? TRUE : FALSE; - *width = cf2_getDefaultWidthX( decoder ); - - /* - * Note: At this point, all pointers to resources must be NULL - * and all local objects must be initialized. - * There must be no branches to `exit:' above this point. - * - */ - - /* allocate an operand stack */ - stackSize = font->isCFF2 ? cf2_getMaxstack( decoder ) - : CF2_OPERAND_STACK_SIZE; - opStack = cf2_stack_init( memory, error, stackSize ); - - if ( !opStack ) - { - lastError = FT_THROW( Out_Of_Memory ); - goto exit; - } - - /* initialize subroutine stack by placing top level charstring as */ - /* first element (max depth plus one for the charstring) */ - /* Note: Caller owns and must finalize the first charstring. */ - /* Our copy of it does not change that requirement. */ - cf2_arrstack_setCount( &subrStack, CF2_MAX_SUBR + 1 ); - - charstring = (CF2_Buffer)cf2_arrstack_getBuffer( &subrStack ); - *charstring = *buf; /* structure copy */ - - charstringIndex = 0; /* entry is valid now */ - - /* catch errors so far */ - if ( *error ) - goto exit; - - /* main interpreter loop */ - while ( 1 ) - { - if ( cf2_buf_isEnd( charstring ) ) - { - /* If we've reached the end of the charstring, simulate a */ - /* cf2_cmdRETURN or cf2_cmdENDCHAR. */ - /* We do this for both CFF and CFF2. */ - if ( charstringIndex ) - op1 = cf2_cmdRETURN; /* end of buffer for subroutine */ - else - op1 = cf2_cmdENDCHAR; /* end of buffer for top level charstring */ - } - else - { - op1 = (FT_Byte)cf2_buf_readByte( charstring ); - - /* Explicit RETURN and ENDCHAR in CFF2 should be ignored. */ - /* Note: Trace message will report 0 instead of 11 or 14. */ - if ( ( op1 == cf2_cmdRETURN || op1 == cf2_cmdENDCHAR ) && - font->isCFF2 ) - op1 = cf2_cmdRESERVED_0; - } - - /* check for errors once per loop */ - if ( *error ) - goto exit; - - instructionLimit--; - if ( instructionLimit == 0 ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; - } - - switch( op1 ) - { - case cf2_cmdRESERVED_0: - case cf2_cmdRESERVED_2: - case cf2_cmdRESERVED_9: - case cf2_cmdRESERVED_13: - case cf2_cmdRESERVED_17: - /* we may get here if we have a prior error */ - FT_TRACE4(( " unknown op (%d)\n", op1 )); - break; - - case cf2_cmdVSINDEX: - FT_TRACE4(( " vsindex\n" )); - - if ( !font->isCFF2 ) - break; /* clear stack & ignore */ - - if ( font->blend.usedBV ) - { - /* vsindex not allowed after blend */ - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; - } - - { - FT_Int temp = cf2_stack_popInt( opStack ); - - - if ( temp >= 0 ) - font->vsindex = (FT_UInt)temp; - } - break; - - case cf2_cmdBLEND: - { - FT_UInt numBlends; - - - FT_TRACE4(( " blend\n" )); - - if ( !font->isCFF2 ) - break; /* clear stack & ignore */ - - /* do we have a `blend' op in a non-variant font? */ - if ( !font->blend.font ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; - } - - /* check cached blend vector */ - if ( cff_blend_check_vector( &font->blend, - font->vsindex, - font->lenNDV, - font->NDV ) ) - { - lastError = cff_blend_build_vector( &font->blend, - font->vsindex, - font->lenNDV, - font->NDV ); - if ( lastError ) - goto exit; - } - - /* do the blend */ - numBlends = (FT_UInt)cf2_stack_popInt( opStack ); - if ( numBlends > stackSize ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; - } - - cf2_doBlend( &font->blend, opStack, numBlends ); - - font->blend.usedBV = TRUE; - } - continue; /* do not clear the stack */ - - case cf2_cmdHSTEMHM: - case cf2_cmdHSTEM: - FT_TRACE4(( op1 == cf2_cmdHSTEMHM ? " hstemhm\n" : " hstem\n" )); - - /* never add hints after the mask is computed */ - if ( cf2_hintmask_isValid( &hintMask ) ) - { - FT_TRACE4(( "cf2_interpT2CharString:" - " invalid horizontal hint mask\n" )); - break; - } - - cf2_doStems( font, - opStack, - &hStemHintArray, - width, - &haveWidth, - 0 ); - - if ( font->decoder->width_only ) - goto exit; - - break; - - case cf2_cmdVSTEMHM: - case cf2_cmdVSTEM: - FT_TRACE4(( op1 == cf2_cmdVSTEMHM ? " vstemhm\n" : " vstem\n" )); - - /* never add hints after the mask is computed */ - if ( cf2_hintmask_isValid( &hintMask ) ) - { - FT_TRACE4(( "cf2_interpT2CharString:" - " invalid vertical hint mask\n" )); - break; - } - - cf2_doStems( font, - opStack, - &vStemHintArray, - width, - &haveWidth, - 0 ); - - if ( font->decoder->width_only ) - goto exit; - - break; - - case cf2_cmdVMOVETO: - FT_TRACE4(( " vmoveto\n" )); - - if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) - *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), - nominalWidthX ); - - /* width is defined or default after this */ - haveWidth = TRUE; - - if ( font->decoder->width_only ) - goto exit; - - curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); - - cf2_glyphpath_moveTo( &glyphPath, curX, curY ); - - break; - - case cf2_cmdRLINETO: - { - CF2_UInt idx; - CF2_UInt count = cf2_stack_count( opStack ); - - - FT_TRACE4(( " rlineto\n" )); - - for ( idx = 0; idx < count; idx += 2 ) - { - curX = ADD_INT32( curX, cf2_stack_getReal( opStack, - idx + 0 ) ); - curY = ADD_INT32( curY, cf2_stack_getReal( opStack, - idx + 1 ) ); - - cf2_glyphpath_lineTo( &glyphPath, curX, curY ); - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdHLINETO: - case cf2_cmdVLINETO: - { - CF2_UInt idx; - CF2_UInt count = cf2_stack_count( opStack ); - - FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO ); - - - FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" )); - - for ( idx = 0; idx < count; idx++ ) - { - CF2_Fixed v = cf2_stack_getReal( opStack, idx ); - - - if ( isX ) - curX = ADD_INT32( curX, v ); - else - curY = ADD_INT32( curY, v ); - - isX = !isX; - - cf2_glyphpath_lineTo( &glyphPath, curX, curY ); - } - - cf2_stack_clear( opStack ); - } - continue; - - case cf2_cmdRCURVELINE: - case cf2_cmdRRCURVETO: - { - CF2_UInt count = cf2_stack_count( opStack ); - CF2_UInt idx = 0; - - - FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n" - : " rrcurveto\n" )); - - while ( idx + 6 <= count ) - { - CF2_Fixed x1, y1, x2, y2, x3, y3; - - - x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); - y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY ); - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 ); - x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); - y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 ); - - cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - - curX = x3; - curY = y3; - idx += 6; - } - - if ( op1 == cf2_cmdRCURVELINE ) - { - curX = ADD_INT32( curX, cf2_stack_getReal( opStack, - idx + 0 ) ); - curY = ADD_INT32( curY, cf2_stack_getReal( opStack, - idx + 1 ) ); - - cf2_glyphpath_lineTo( &glyphPath, curX, curY ); - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdCALLGSUBR: - case cf2_cmdCALLSUBR: - { - CF2_Int subrNum; - - - FT_TRACE4(( op1 == cf2_cmdCALLGSUBR ? " callgsubr" - : " callsubr" )); - - if ( charstringIndex > CF2_MAX_SUBR ) - { - /* max subr plus one for charstring */ - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; /* overflow of stack */ - } - - /* push our current CFF charstring region on subrStack */ - charstring = (CF2_Buffer) - cf2_arrstack_getPointer( - &subrStack, - (size_t)charstringIndex + 1 ); - - /* set up the new CFF region and pointer */ - subrNum = cf2_stack_popInt( opStack ); - - switch ( op1 ) - { - case cf2_cmdCALLGSUBR: - FT_TRACE4(( " (idx %d, entering level %d)\n", - subrNum + decoder->globals_bias, - charstringIndex + 1 )); - - if ( cf2_initGlobalRegionBuffer( decoder, - subrNum, - charstring ) ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; /* subroutine lookup or stream error */ - } - break; - - default: - /* cf2_cmdCALLSUBR */ - FT_TRACE4(( " (idx %d, entering level %d)\n", - subrNum + decoder->locals_bias, - charstringIndex + 1 )); - - if ( cf2_initLocalRegionBuffer( decoder, - subrNum, - charstring ) ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; /* subroutine lookup or stream error */ - } - } - - charstringIndex += 1; /* entry is valid now */ - } - continue; /* do not clear the stack */ - - case cf2_cmdRETURN: - FT_TRACE4(( " return (leaving level %d)\n", charstringIndex )); - - if ( charstringIndex < 1 ) - { - /* Note: cannot return from top charstring */ - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; /* underflow of stack */ - } - - /* restore position in previous charstring */ - charstring = (CF2_Buffer) - cf2_arrstack_getPointer( - &subrStack, - (CF2_UInt)--charstringIndex ); - continue; /* do not clear the stack */ - - case cf2_cmdESC: - { - FT_Byte op2 = (FT_Byte)cf2_buf_readByte( charstring ); - - - /* first switch for 2-byte operators handles CFF2 */ - /* and opcodes that are reserved for both CFF and CFF2 */ - switch ( op2 ) - { - case cf2_escHFLEX: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, FALSE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, FALSE /* dy3 */, - TRUE /* dx4 */, FALSE /* dy4 */, - TRUE /* dx5 */, FALSE /* dy5 */, - TRUE /* dx6 */, FALSE /* dy6 */ - }; - - - FT_TRACE4(( " hflex\n" )); - - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - continue; - - case cf2_escFLEX: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, TRUE /* dy3 */, - TRUE /* dx4 */, TRUE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - TRUE /* dx6 */, TRUE /* dy6 */ - }; - - - FT_TRACE4(( " flex\n" )); - - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - break; /* TODO: why is this not a continue? */ - - case cf2_escHFLEX1: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, FALSE /* dy3 */, - TRUE /* dx4 */, FALSE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - TRUE /* dx6 */, FALSE /* dy6 */ - }; - - - FT_TRACE4(( " hflex1\n" )); - - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - FALSE /* doConditionalLastRead */ ); - } - continue; - - case cf2_escFLEX1: - { - static const FT_Bool readFromStack[12] = - { - TRUE /* dx1 */, TRUE /* dy1 */, - TRUE /* dx2 */, TRUE /* dy2 */, - TRUE /* dx3 */, TRUE /* dy3 */, - TRUE /* dx4 */, TRUE /* dy4 */, - TRUE /* dx5 */, TRUE /* dy5 */, - FALSE /* dx6 */, FALSE /* dy6 */ - }; - - - FT_TRACE4(( " flex1\n" )); - - cf2_doFlex( opStack, - &curX, - &curY, - &glyphPath, - readFromStack, - TRUE /* doConditionalLastRead */ ); - } - continue; - - /* these opcodes are reserved in both CFF & CFF2 */ - case cf2_escRESERVED_1: - case cf2_escRESERVED_2: - case cf2_escRESERVED_6: - case cf2_escRESERVED_7: - case cf2_escRESERVED_8: - case cf2_escRESERVED_13: - case cf2_escRESERVED_16: - case cf2_escRESERVED_17: - case cf2_escRESERVED_19: - case cf2_escRESERVED_25: - case cf2_escRESERVED_31: - case cf2_escRESERVED_32: - case cf2_escRESERVED_33: - FT_TRACE4(( " unknown op (12, %d)\n", op2 )); - break; - - default: - { - if ( font->isCFF2 || op2 >= cf2_escRESERVED_38 ) - FT_TRACE4(( " unknown op (12, %d)\n", op2 )); - else - { - /* second switch for 2-byte operators handles just CFF */ - switch ( op2 ) - { - - case cf2_escDOTSECTION: - /* something about `flip type of locking' -- ignore it */ - FT_TRACE4(( " dotsection\n" )); - - break; - - case cf2_escAND: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - - - FT_TRACE4(( " and\n" )); - - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushInt( opStack, arg1 && arg2 ); - } - continue; /* do not clear the stack */ - - case cf2_escOR: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - - - FT_TRACE4(( " or\n" )); - - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushInt( opStack, arg1 || arg2 ); - } - continue; /* do not clear the stack */ - - case cf2_escNOT: - { - CF2_F16Dot16 arg; - - - FT_TRACE4(( " not\n" )); - - arg = cf2_stack_popFixed( opStack ); - - cf2_stack_pushInt( opStack, !arg ); - } - continue; /* do not clear the stack */ - - case cf2_escABS: - { - CF2_F16Dot16 arg; - - - FT_TRACE4(( " abs\n" )); - - arg = cf2_stack_popFixed( opStack ); - - if ( arg < -CF2_FIXED_MAX ) - cf2_stack_pushFixed( opStack, CF2_FIXED_MAX ); - else - cf2_stack_pushFixed( opStack, FT_ABS( arg ) ); - } - continue; /* do not clear the stack */ - - case cf2_escADD: - { - CF2_F16Dot16 summand1; - CF2_F16Dot16 summand2; - - - FT_TRACE4(( " add\n" )); - - summand2 = cf2_stack_popFixed( opStack ); - summand1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, - ADD_INT32( summand1, - summand2 ) ); - } - continue; /* do not clear the stack */ - - case cf2_escSUB: - { - CF2_F16Dot16 minuend; - CF2_F16Dot16 subtrahend; - - - FT_TRACE4(( " sub\n" )); - - subtrahend = cf2_stack_popFixed( opStack ); - minuend = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, - SUB_INT32( minuend, subtrahend ) ); - } - continue; /* do not clear the stack */ - - case cf2_escDIV: - { - CF2_F16Dot16 dividend; - CF2_F16Dot16 divisor; - - - FT_TRACE4(( " div\n" )); - - divisor = cf2_stack_popFixed( opStack ); - dividend = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, - FT_DivFix( dividend, divisor ) ); - } - continue; /* do not clear the stack */ - - case cf2_escNEG: - { - CF2_F16Dot16 arg; - - - FT_TRACE4(( " neg\n" )); - - arg = cf2_stack_popFixed( opStack ); - - if ( arg < -CF2_FIXED_MAX ) - cf2_stack_pushFixed( opStack, CF2_FIXED_MAX ); - else - cf2_stack_pushFixed( opStack, -arg ); - } - continue; /* do not clear the stack */ - - case cf2_escEQ: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - - - FT_TRACE4(( " eq\n" )); - - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushInt( opStack, arg1 == arg2 ); - } - continue; /* do not clear the stack */ - - case cf2_escDROP: - FT_TRACE4(( " drop\n" )); - - (void)cf2_stack_popFixed( opStack ); - continue; /* do not clear the stack */ - - case cf2_escPUT: - { - CF2_F16Dot16 val; - CF2_Int idx; - - - FT_TRACE4(( " put\n" )); - - idx = cf2_stack_popInt( opStack ); - val = cf2_stack_popFixed( opStack ); - - if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) - storage[idx] = val; - } - continue; /* do not clear the stack */ - - case cf2_escGET: - { - CF2_Int idx; - - - FT_TRACE4(( " get\n" )); - - idx = cf2_stack_popInt( opStack ); - - if ( idx >= 0 && idx < CF2_STORAGE_SIZE ) - cf2_stack_pushFixed( opStack, storage[idx] ); - } - continue; /* do not clear the stack */ - - case cf2_escIFELSE: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - CF2_F16Dot16 cond1; - CF2_F16Dot16 cond2; - - - FT_TRACE4(( " ifelse\n" )); - - cond2 = cf2_stack_popFixed( opStack ); - cond1 = cf2_stack_popFixed( opStack ); - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, - cond1 <= cond2 ? arg1 : arg2 ); - } - continue; /* do not clear the stack */ - - case cf2_escRANDOM: /* in spec */ - { - CF2_F16Dot16 r; - - - FT_TRACE4(( " random\n" )); - - /* only use the lower 16 bits of `random' */ - /* to generate a number in the range (0;1] */ - r = (CF2_F16Dot16) - ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - - decoder->current_subfont->random = - cff_random( decoder->current_subfont->random ); - - cf2_stack_pushFixed( opStack, r ); - } - continue; /* do not clear the stack */ - - case cf2_escMUL: - { - CF2_F16Dot16 factor1; - CF2_F16Dot16 factor2; - - - FT_TRACE4(( " mul\n" )); - - factor2 = cf2_stack_popFixed( opStack ); - factor1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, - FT_MulFix( factor1, factor2 ) ); - } - continue; /* do not clear the stack */ - - case cf2_escSQRT: - { - CF2_F16Dot16 arg; - - - FT_TRACE4(( " sqrt\n" )); - - arg = cf2_stack_popFixed( opStack ); - if ( arg > 0 ) - { - /* use a start value that doesn't make */ - /* the algorithm's addition overflow */ - FT_Fixed root = arg < 10 ? arg : arg >> 1; - FT_Fixed new_root; - - - /* Babylonian method */ - for (;;) - { - new_root = ( root + FT_DivFix( arg, root ) + 1 ) >> 1; - if ( new_root == root ) - break; - root = new_root; - } - arg = new_root; - } - else - arg = 0; - - cf2_stack_pushFixed( opStack, arg ); - } - continue; /* do not clear the stack */ - - case cf2_escDUP: - { - CF2_F16Dot16 arg; - - - FT_TRACE4(( " dup\n" )); - - arg = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, arg ); - cf2_stack_pushFixed( opStack, arg ); - } - continue; /* do not clear the stack */ - - case cf2_escEXCH: - { - CF2_F16Dot16 arg1; - CF2_F16Dot16 arg2; - - - FT_TRACE4(( " exch\n" )); - - arg2 = cf2_stack_popFixed( opStack ); - arg1 = cf2_stack_popFixed( opStack ); - - cf2_stack_pushFixed( opStack, arg2 ); - cf2_stack_pushFixed( opStack, arg1 ); - } - continue; /* do not clear the stack */ - - case cf2_escINDEX: - { - CF2_Int idx; - CF2_UInt size; - - - FT_TRACE4(( " index\n" )); - - idx = cf2_stack_popInt( opStack ); - size = cf2_stack_count( opStack ); - - if ( size > 0 ) - { - /* for `cf2_stack_getReal', */ - /* index 0 is bottom of stack */ - CF2_UInt gr_idx; - - - if ( idx < 0 ) - gr_idx = size - 1; - else if ( (CF2_UInt)idx >= size ) - gr_idx = 0; - else - gr_idx = size - 1 - (CF2_UInt)idx; - - cf2_stack_pushFixed( opStack, - cf2_stack_getReal( opStack, - gr_idx ) ); - } - } - continue; /* do not clear the stack */ - - case cf2_escROLL: - { - CF2_Int idx; - CF2_Int count; - - - FT_TRACE4(( " roll\n" )); - - idx = cf2_stack_popInt( opStack ); - count = cf2_stack_popInt( opStack ); - - cf2_stack_roll( opStack, count, idx ); - } - continue; /* do not clear the stack */ - - } /* end of 2nd switch checking op2 */ - } - } - } /* end of 1st switch checking op2 */ - } /* case cf2_cmdESC */ - - break; - - case cf2_cmdENDCHAR: - FT_TRACE4(( " endchar\n" )); - - if ( cf2_stack_count( opStack ) == 1 || - cf2_stack_count( opStack ) == 5 ) - { - if ( !haveWidth ) - *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), - nominalWidthX ); - } - - /* width is defined or default after this */ - haveWidth = TRUE; - - if ( font->decoder->width_only ) - goto exit; - - /* close path if still open */ - cf2_glyphpath_closeOpenPath( &glyphPath ); - - /* disable seac for CFF2 (charstring ending with args on stack) */ - if ( !font->isCFF2 && cf2_stack_count( opStack ) > 1 ) - { - /* must be either 4 or 5 -- */ - /* this is a (deprecated) implied `seac' operator */ - - CF2_Int achar; - CF2_Int bchar; - CF2_BufferRec component; - CF2_Fixed dummyWidth; /* ignore component width */ - FT_Error error2; - - - if ( doingSeac ) - { - lastError = FT_THROW( Invalid_Glyph_Format ); - goto exit; /* nested seac */ - } - - achar = cf2_stack_popInt( opStack ); - bchar = cf2_stack_popInt( opStack ); - - curY = cf2_stack_popFixed( opStack ); - curX = cf2_stack_popFixed( opStack ); - - error2 = cf2_getSeacComponent( decoder, achar, &component ); - if ( error2 ) - { - lastError = error2; /* pass FreeType error through */ - goto exit; - } - cf2_interpT2CharString( font, - &component, - callbacks, - translation, - TRUE, - curX, - curY, - &dummyWidth ); - cf2_freeSeacComponent( decoder, &component ); - - error2 = cf2_getSeacComponent( decoder, bchar, &component ); - if ( error2 ) - { - lastError = error2; /* pass FreeType error through */ - goto exit; - } - cf2_interpT2CharString( font, - &component, - callbacks, - translation, - TRUE, - 0, - 0, - &dummyWidth ); - cf2_freeSeacComponent( decoder, &component ); - } - goto exit; - - case cf2_cmdCNTRMASK: - case cf2_cmdHINTMASK: - /* the final \n in the tracing message gets added in */ - /* `cf2_hintmask_read' (which also traces the mask bytes) */ - FT_TRACE4(( op1 == cf2_cmdCNTRMASK ? " cntrmask" : " hintmask" )); - - /* never add hints after the mask is computed */ - if ( cf2_stack_count( opStack ) > 1 && - cf2_hintmask_isValid( &hintMask ) ) - { - FT_TRACE4(( "cf2_interpT2CharString: invalid hint mask\n" )); - break; - } - - /* if there are arguments on the stack, there this is an */ - /* implied cf2_cmdVSTEMHM */ - cf2_doStems( font, - opStack, - &vStemHintArray, - width, - &haveWidth, - 0 ); - - if ( font->decoder->width_only ) - goto exit; - - if ( op1 == cf2_cmdHINTMASK ) - { - /* consume the hint mask bytes which follow the operator */ - cf2_hintmask_read( &hintMask, - charstring, - cf2_arrstack_size( &hStemHintArray ) + - cf2_arrstack_size( &vStemHintArray ) ); - } - else - { - /* - * Consume the counter mask bytes which follow the operator: - * Build a temporary hint map, just to place and lock those - * stems participating in the counter mask. These are most - * likely the dominant hstems, and are grouped together in a - * few counter groups, not necessarily in correspondence - * with the hint groups. This reduces the chances of - * conflicts between hstems that are initially placed in - * separate hint groups and then brought together. The - * positions are copied back to `hStemHintArray', so we can - * discard `counterMask' and `counterHintMap'. - * - */ - CF2_HintMapRec counterHintMap; - CF2_HintMaskRec counterMask; - - - cf2_hintmap_init( &counterHintMap, - font, - &glyphPath.initialHintMap, - &glyphPath.hintMoves, - scaleY ); - cf2_hintmask_init( &counterMask, error ); - - cf2_hintmask_read( &counterMask, - charstring, - cf2_arrstack_size( &hStemHintArray ) + - cf2_arrstack_size( &vStemHintArray ) ); - cf2_hintmap_build( &counterHintMap, - &hStemHintArray, - &vStemHintArray, - &counterMask, - 0, - FALSE ); - } - break; - - case cf2_cmdRMOVETO: - FT_TRACE4(( " rmoveto\n" )); - - if ( cf2_stack_count( opStack ) > 2 && !haveWidth ) - *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), - nominalWidthX ); - - /* width is defined or default after this */ - haveWidth = TRUE; - - if ( font->decoder->width_only ) - goto exit; - - curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); - curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); - - cf2_glyphpath_moveTo( &glyphPath, curX, curY ); - - break; - - case cf2_cmdHMOVETO: - FT_TRACE4(( " hmoveto\n" )); - - if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) - *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), - nominalWidthX ); - - /* width is defined or default after this */ - haveWidth = TRUE; - - if ( font->decoder->width_only ) - goto exit; - - curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); - - cf2_glyphpath_moveTo( &glyphPath, curX, curY ); - - break; - - case cf2_cmdRLINECURVE: - { - CF2_UInt count = cf2_stack_count( opStack ); - CF2_UInt idx = 0; - - - FT_TRACE4(( " rlinecurve\n" )); - - while ( idx + 6 < count ) - { - curX = ADD_INT32( curX, cf2_stack_getReal( opStack, - idx + 0 ) ); - curY = ADD_INT32( curY, cf2_stack_getReal( opStack, - idx + 1 ) ); - - cf2_glyphpath_lineTo( &glyphPath, curX, curY ); - idx += 2; - } - - while ( idx < count ) - { - CF2_Fixed x1, y1, x2, y2, x3, y3; - - - x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); - y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY ); - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 ); - x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); - y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 ); - - cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - - curX = x3; - curY = y3; - idx += 6; - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdVVCURVETO: - { - CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt idx = 0; - - - /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - idx += count1 - count; - - FT_TRACE4(( " vvcurveto\n" )); - - while ( idx < count ) - { - CF2_Fixed x1, y1, x2, y2, x3, y3; - - - if ( ( count - idx ) & 1 ) - { - x1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curX ); - - idx++; - } - else - x1 = curX; - - y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY ); - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); - x3 = x2; - y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 ); - - cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - - curX = x3; - curY = y3; - idx += 4; - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdHHCURVETO: - { - CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt idx = 0; - - - /* if `cf2_stack_count' isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - idx += count1 - count; - - FT_TRACE4(( " hhcurveto\n" )); - - while ( idx < count ) - { - CF2_Fixed x1, y1, x2, y2, x3, y3; - - - if ( ( count - idx ) & 1 ) - { - y1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curY ); - - idx++; - } - else - y1 = curY; - - x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); - x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 ); - y3 = y2; - - cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - - curX = x3; - curY = y3; - idx += 4; - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdVHCURVETO: - case cf2_cmdHVCURVETO: - { - CF2_UInt count, count1 = cf2_stack_count( opStack ); - CF2_UInt idx = 0; - - FT_Bool alternate = FT_BOOL( op1 == cf2_cmdHVCURVETO ); - - - /* if `cf2_stack_count' isn't of the form 8n, 8n+1, */ - /* 8n+4, or 8n+5, we enforce it by clearing the */ - /* second bit */ - /* (and sorting the stack indexing to suit) */ - count = count1 & ~2U; - idx += count1 - count; - - FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" )); - - while ( idx < count ) - { - CF2_Fixed x1, x2, x3, y1, y2, y3; - - - if ( alternate ) - { - x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); - y1 = curY; - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); - y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 ); - - if ( count - idx == 5 ) - { - x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); - - idx++; - } - else - x3 = x2; - - alternate = FALSE; - } - else - { - x1 = curX; - y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY ); - x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); - y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); - x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 ); - - if ( count - idx == 5 ) - { - y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), y2 ); - - idx++; - } - else - y3 = y2; - - alternate = TRUE; - } - - cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); - - curX = x3; - curY = y3; - idx += 4; - } - - cf2_stack_clear( opStack ); - } - continue; /* no need to clear stack again */ - - case cf2_cmdEXTENDEDNMBR: - { - CF2_Int v; - - CF2_Int byte1 = cf2_buf_readByte( charstring ); - CF2_Int byte2 = cf2_buf_readByte( charstring ); - - - v = (FT_Short)( ( byte1 << 8 ) | - byte2 ); - - FT_TRACE4(( " %d", v )); - - cf2_stack_pushInt( opStack, v ); - } - continue; - - default: - /* numbers */ - { - if ( /* op1 >= 32 && */ op1 <= 246 ) - { - CF2_Int v; - - - v = op1 - 139; - - FT_TRACE4(( " %d", v )); - - /* -107 .. 107 */ - cf2_stack_pushInt( opStack, v ); - } - - else if ( /* op1 >= 247 && */ op1 <= 250 ) - { - CF2_Int v; - - - v = op1; - v -= 247; - v *= 256; - v += cf2_buf_readByte( charstring ); - v += 108; - - FT_TRACE4(( " %d", v )); - - /* 108 .. 1131 */ - cf2_stack_pushInt( opStack, v ); - } - - else if ( /* op1 >= 251 && */ op1 <= 254 ) - { - CF2_Int v; - - - v = op1; - v -= 251; - v *= 256; - v += cf2_buf_readByte( charstring ); - v = -v - 108; - - FT_TRACE4(( " %d", v )); - - /* -1131 .. -108 */ - cf2_stack_pushInt( opStack, v ); - } - - else /* op1 == 255 */ - { - CF2_Fixed v; - - FT_UInt32 byte1 = (FT_UInt32)cf2_buf_readByte( charstring ); - FT_UInt32 byte2 = (FT_UInt32)cf2_buf_readByte( charstring ); - FT_UInt32 byte3 = (FT_UInt32)cf2_buf_readByte( charstring ); - FT_UInt32 byte4 = (FT_UInt32)cf2_buf_readByte( charstring ); - - - v = (CF2_Fixed)( ( byte1 << 24 ) | - ( byte2 << 16 ) | - ( byte3 << 8 ) | - byte4 ); - - FT_TRACE4(( " %.5f", v / 65536.0 )); - - cf2_stack_pushFixed( opStack, v ); - } - } - continue; /* don't clear stack */ - - } /* end of switch statement checking `op1' */ - - cf2_stack_clear( opStack ); - - } /* end of main interpreter loop */ - - /* we get here if the charstring ends without cf2_cmdENDCHAR */ - FT_TRACE4(( "cf2_interpT2CharString:" - " charstring ends without ENDCHAR\n" )); - - exit: - /* check whether last error seen is also the first one */ - cf2_setError( error, lastError ); - - if ( *error ) - FT_TRACE4(( "charstring error %d\n", *error )); - - /* free resources from objects we've used */ - cf2_glyphpath_finalize( &glyphPath ); - cf2_arrstack_finalize( &vStemHintArray ); - cf2_arrstack_finalize( &hStemHintArray ); - cf2_arrstack_finalize( &subrStack ); - cf2_stack_free( opStack ); - - FT_TRACE4(( "\n" )); - - return; - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h deleted file mode 100644 index ec030e89444..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2font.h */ -/* */ -/* Adobe's CFF Interpreter (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2INTRP_H_ -#define CF2INTRP_H_ - - -#include "cf2ft.h" -#include "cf2hints.h" - - -FT_BEGIN_HEADER - - - FT_LOCAL( void ) - cf2_hintmask_init( CF2_HintMask hintmask, - FT_Error* error ); - FT_LOCAL( FT_Bool ) - cf2_hintmask_isValid( const CF2_HintMask hintmask ); - FT_LOCAL( FT_Bool ) - cf2_hintmask_isNew( const CF2_HintMask hintmask ); - FT_LOCAL( void ) - cf2_hintmask_setNew( CF2_HintMask hintmask, - FT_Bool val ); - FT_LOCAL( FT_Byte* ) - cf2_hintmask_getMaskPtr( CF2_HintMask hintmask ); - FT_LOCAL( void ) - cf2_hintmask_setAll( CF2_HintMask hintmask, - size_t bitCount ); - - FT_LOCAL( void ) - cf2_interpT2CharString( CF2_Font font, - CF2_Buffer charstring, - CF2_OutlineCallbacks callbacks, - const FT_Vector* translation, - FT_Bool doingSeac, - CF2_Fixed curX, - CF2_Fixed curY, - CF2_Fixed* width ); - - -FT_END_HEADER - - -#endif /* CF2INTRP_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c deleted file mode 100644 index 2b429e3eeb0..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.c +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2read.c */ -/* */ -/* Adobe's code for stream handling (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2glue.h" - -#include "cf2error.h" - - - /* Define CF2_IO_FAIL as 1 to enable random errors and random */ - /* value errors in I/O. */ -#define CF2_IO_FAIL 0 - - -#if CF2_IO_FAIL - - /* set the .00 value to a nonzero probability */ - static int - randomError2( void ) - { - /* for region buffer ReadByte (interp) function */ - return (double)rand() / RAND_MAX < .00; - } - - /* set the .00 value to a nonzero probability */ - static CF2_Int - randomValue() - { - return (double)rand() / RAND_MAX < .00 ? rand() : 0; - } - -#endif /* CF2_IO_FAIL */ - - - /* Region Buffer */ - /* */ - /* Can be constructed from a copied buffer managed by */ - /* `FCM_getDatablock'. */ - /* Reads bytes with check for end of buffer. */ - - /* reading past the end of the buffer sets error and returns zero */ - FT_LOCAL_DEF( CF2_Int ) - cf2_buf_readByte( CF2_Buffer buf ) - { - if ( buf->ptr < buf->end ) - { -#if CF2_IO_FAIL - if ( randomError2() ) - { - CF2_SET_ERROR( buf->error, Invalid_Stream_Operation ); - return 0; - } - - return *(buf->ptr)++ + randomValue(); -#else - return *(buf->ptr)++; -#endif - } - else - { - CF2_SET_ERROR( buf->error, Invalid_Stream_Operation ); - return 0; - } - } - - - /* note: end condition can occur without error */ - FT_LOCAL_DEF( FT_Bool ) - cf2_buf_isEnd( CF2_Buffer buf ) - { - return (FT_Bool)( buf->ptr >= buf->end ); - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h deleted file mode 100644 index b0b0db803a5..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2read.h +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2read.h */ -/* */ -/* Adobe's code for stream handling (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2READ_H_ -#define CF2READ_H_ - - -FT_BEGIN_HEADER - - - typedef struct CF2_BufferRec_ - { - FT_Error* error; - const FT_Byte* start; - const FT_Byte* end; - const FT_Byte* ptr; - - } CF2_BufferRec, *CF2_Buffer; - - - FT_LOCAL( CF2_Int ) - cf2_buf_readByte( CF2_Buffer buf ); - FT_LOCAL( FT_Bool ) - cf2_buf_isEnd( CF2_Buffer buf ); - - -FT_END_HEADER - - -#endif /* CF2READ_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c deleted file mode 100644 index 12a026d21d8..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c +++ /dev/null @@ -1,328 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2stack.c */ -/* */ -/* Adobe's code for emulating a CFF stack (body). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#include "cf2ft.h" -#include FT_INTERNAL_DEBUG_H - -#include "cf2glue.h" -#include "cf2font.h" -#include "cf2stack.h" - -#include "cf2error.h" - - - /* Allocate and initialize an instance of CF2_Stack. */ - /* Note: This function returns NULL on error (does not set */ - /* `error'). */ - FT_LOCAL_DEF( CF2_Stack ) - cf2_stack_init( FT_Memory memory, - FT_Error* e, - FT_UInt stackSize ) - { - FT_Error error = FT_Err_Ok; /* for FT_NEW */ - - CF2_Stack stack = NULL; - - - if ( !FT_NEW( stack ) ) - { - /* initialize the structure; FT_NEW zeroes it */ - stack->memory = memory; - stack->error = e; - } - - /* allocate the stack buffer */ - if ( FT_NEW_ARRAY( stack->buffer, stackSize ) ) - { - FT_FREE( stack ); - return NULL; - } - - stack->stackSize = stackSize; - stack->top = stack->buffer; /* empty stack */ - - return stack; - } - - - FT_LOCAL_DEF( void ) - cf2_stack_free( CF2_Stack stack ) - { - if ( stack ) - { - FT_Memory memory = stack->memory; - - /* free the buffer */ - FT_FREE( stack->buffer ); - - /* free the main structure */ - FT_FREE( stack ); - } - } - - - FT_LOCAL_DEF( CF2_UInt ) - cf2_stack_count( CF2_Stack stack ) - { - return (CF2_UInt)( stack->top - stack->buffer ); - } - - - FT_LOCAL_DEF( void ) - cf2_stack_pushInt( CF2_Stack stack, - CF2_Int val ) - { - if ( stack->top == stack->buffer + stack->stackSize ) - { - CF2_SET_ERROR( stack->error, Stack_Overflow ); - return; /* stack overflow */ - } - - stack->top->u.i = val; - stack->top->type = CF2_NumberInt; - stack->top++; - } - - - FT_LOCAL_DEF( void ) - cf2_stack_pushFixed( CF2_Stack stack, - CF2_Fixed val ) - { - if ( stack->top == stack->buffer + stack->stackSize ) - { - CF2_SET_ERROR( stack->error, Stack_Overflow ); - return; /* stack overflow */ - } - - stack->top->u.r = val; - stack->top->type = CF2_NumberFixed; - stack->top++; - } - - - /* this function is only allowed to pop an integer type */ - FT_LOCAL_DEF( CF2_Int ) - cf2_stack_popInt( CF2_Stack stack ) - { - if ( stack->top == stack->buffer ) - { - CF2_SET_ERROR( stack->error, Stack_Underflow ); - return 0; /* underflow */ - } - if ( stack->top[-1].type != CF2_NumberInt ) - { - CF2_SET_ERROR( stack->error, Syntax_Error ); - return 0; /* type mismatch */ - } - - stack->top--; - - return stack->top->u.i; - } - - - /* Note: type mismatch is silently cast */ - /* TODO: check this */ - FT_LOCAL_DEF( CF2_Fixed ) - cf2_stack_popFixed( CF2_Stack stack ) - { - if ( stack->top == stack->buffer ) - { - CF2_SET_ERROR( stack->error, Stack_Underflow ); - return cf2_intToFixed( 0 ); /* underflow */ - } - - stack->top--; - - switch ( stack->top->type ) - { - case CF2_NumberInt: - return cf2_intToFixed( stack->top->u.i ); - case CF2_NumberFrac: - return cf2_fracToFixed( stack->top->u.f ); - default: - return stack->top->u.r; - } - } - - - /* Note: type mismatch is silently cast */ - /* TODO: check this */ - FT_LOCAL_DEF( CF2_Fixed ) - cf2_stack_getReal( CF2_Stack stack, - CF2_UInt idx ) - { - FT_ASSERT( cf2_stack_count( stack ) <= stack->stackSize ); - - if ( idx >= cf2_stack_count( stack ) ) - { - CF2_SET_ERROR( stack->error, Stack_Overflow ); - return cf2_intToFixed( 0 ); /* bounds error */ - } - - switch ( stack->buffer[idx].type ) - { - case CF2_NumberInt: - return cf2_intToFixed( stack->buffer[idx].u.i ); - case CF2_NumberFrac: - return cf2_fracToFixed( stack->buffer[idx].u.f ); - default: - return stack->buffer[idx].u.r; - } - } - - - /* provide random access to stack */ - FT_LOCAL_DEF( void ) - cf2_stack_setReal( CF2_Stack stack, - CF2_UInt idx, - CF2_Fixed val ) - { - if ( idx > cf2_stack_count( stack ) ) - { - CF2_SET_ERROR( stack->error, Stack_Overflow ); - return; - } - - stack->buffer[idx].u.r = val; - stack->buffer[idx].type = CF2_NumberFixed; - } - - - /* discard (pop) num values from stack */ - FT_LOCAL_DEF( void ) - cf2_stack_pop( CF2_Stack stack, - CF2_UInt num ) - { - if ( num > cf2_stack_count( stack ) ) - { - CF2_SET_ERROR( stack->error, Stack_Underflow ); - return; - } - stack->top -= num; - } - - - FT_LOCAL_DEF( void ) - cf2_stack_roll( CF2_Stack stack, - CF2_Int count, - CF2_Int shift ) - { - /* we initialize this variable to avoid compiler warnings */ - CF2_StackNumber last = { { 0 }, CF2_NumberInt }; - - CF2_Int start_idx, idx, i; - - - if ( count < 2 ) - return; /* nothing to do (values 0 and 1), or undefined value */ - - if ( (CF2_UInt)count > cf2_stack_count( stack ) ) - { - CF2_SET_ERROR( stack->error, Stack_Overflow ); - return; - } - - if ( shift < 0 ) - shift = -( ( -shift ) % count ); - else - shift %= count; - - if ( shift == 0 ) - return; /* nothing to do */ - - /* We use the following algorithm to do the rolling, */ - /* which needs two temporary variables only. */ - /* */ - /* Example: */ - /* */ - /* count = 8 */ - /* shift = 2 */ - /* */ - /* stack indices before roll: 7 6 5 4 3 2 1 0 */ - /* stack indices after roll: 1 0 7 6 5 4 3 2 */ - /* */ - /* The value of index 0 gets moved to index 2, while */ - /* the old value of index 2 gets moved to index 4, */ - /* and so on. We thus have the following copying */ - /* chains for shift value 2. */ - /* */ - /* 0 -> 2 -> 4 -> 6 -> 0 */ - /* 1 -> 3 -> 5 -> 7 -> 1 */ - /* */ - /* If `count' and `shift' are incommensurable, we */ - /* have a single chain only. Otherwise, increase */ - /* the start index by 1 after the first chain, then */ - /* do the next chain until all elements in all */ - /* chains are handled. */ - - start_idx = -1; - idx = -1; - for ( i = 0; i < count; i++ ) - { - CF2_StackNumber tmp; - - - if ( start_idx == idx ) - { - start_idx++; - idx = start_idx; - last = stack->buffer[idx]; - } - - idx += shift; - if ( idx >= count ) - idx -= count; - else if ( idx < 0 ) - idx += count; - - tmp = stack->buffer[idx]; - stack->buffer[idx] = last; - last = tmp; - } - } - - - FT_LOCAL_DEF( void ) - cf2_stack_clear( CF2_Stack stack ) - { - stack->top = stack->buffer; - } - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h deleted file mode 100644 index ef08eefe411..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.h +++ /dev/null @@ -1,121 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2stack.h */ -/* */ -/* Adobe's code for emulating a CFF stack (specification). */ -/* */ -/* Copyright 2007-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2STACK_H_ -#define CF2STACK_H_ - - -FT_BEGIN_HEADER - - - /* CFF operand stack; specified maximum of 48 or 192 values */ - typedef struct CF2_StackNumber_ - { - union - { - CF2_Fixed r; /* 16.16 fixed point */ - CF2_Frac f; /* 2.30 fixed point (for font matrix) */ - CF2_Int i; - } u; - - CF2_NumberType type; - - } CF2_StackNumber; - - - typedef struct CF2_StackRec_ - { - FT_Memory memory; - FT_Error* error; - CF2_StackNumber* buffer; - CF2_StackNumber* top; - FT_UInt stackSize; - - } CF2_StackRec, *CF2_Stack; - - - FT_LOCAL( CF2_Stack ) - cf2_stack_init( FT_Memory memory, - FT_Error* error, - FT_UInt stackSize ); - FT_LOCAL( void ) - cf2_stack_free( CF2_Stack stack ); - - FT_LOCAL( CF2_UInt ) - cf2_stack_count( CF2_Stack stack ); - - FT_LOCAL( void ) - cf2_stack_pushInt( CF2_Stack stack, - CF2_Int val ); - FT_LOCAL( void ) - cf2_stack_pushFixed( CF2_Stack stack, - CF2_Fixed val ); - - FT_LOCAL( CF2_Int ) - cf2_stack_popInt( CF2_Stack stack ); - FT_LOCAL( CF2_Fixed ) - cf2_stack_popFixed( CF2_Stack stack ); - - FT_LOCAL( CF2_Fixed ) - cf2_stack_getReal( CF2_Stack stack, - CF2_UInt idx ); - FT_LOCAL( void ) - cf2_stack_setReal( CF2_Stack stack, - CF2_UInt idx, - CF2_Fixed val ); - - FT_LOCAL( void ) - cf2_stack_pop( CF2_Stack stack, - CF2_UInt num ); - - FT_LOCAL( void ) - cf2_stack_roll( CF2_Stack stack, - CF2_Int count, - CF2_Int idx ); - - FT_LOCAL( void ) - cf2_stack_clear( CF2_Stack stack ); - - -FT_END_HEADER - - -#endif /* CF2STACK_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h deleted file mode 100644 index 5b7e1239af3..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2types.h +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************/ -/* */ -/* cf2types.h */ -/* */ -/* Adobe's code for defining data types (specification only). */ -/* */ -/* Copyright 2011-2013 Adobe Systems Incorporated. */ -/* */ -/* This software, and all works of authorship, whether in source or */ -/* object code form as indicated by the copyright notice(s) included */ -/* herein (collectively, the "Work") is made available, and may only be */ -/* used, modified, and distributed under the FreeType Project License, */ -/* LICENSE.TXT. Additionally, subject to the terms and conditions of the */ -/* FreeType Project License, each contributor to the Work hereby grants */ -/* to any individual or legal entity exercising permissions granted by */ -/* the FreeType Project License and this section (hereafter, "You" or */ -/* "Your") a perpetual, worldwide, non-exclusive, no-charge, */ -/* royalty-free, irrevocable (except as stated in this section) patent */ -/* license to make, have made, use, offer to sell, sell, import, and */ -/* otherwise transfer the Work, where such license applies only to those */ -/* patent claims licensable by such contributor that are necessarily */ -/* infringed by their contribution(s) alone or by combination of their */ -/* contribution(s) with the Work to which such contribution(s) was */ -/* submitted. If You institute patent litigation against any entity */ -/* (including a cross-claim or counterclaim in a lawsuit) alleging that */ -/* the Work or a contribution incorporated within the Work constitutes */ -/* direct or contributory patent infringement, then any patent licenses */ -/* granted to You under this License for that Work shall terminate as of */ -/* the date such litigation is filed. */ -/* */ -/* By using, modifying, or distributing the Work you indicate that you */ -/* have read and understood the terms and conditions of the */ -/* FreeType Project License as well as those provided in this section, */ -/* and you accept them fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CF2TYPES_H_ -#define CF2TYPES_H_ - -#include -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - - /* - * The data models that we expect to support are as follows: - * - * name char short int long long-long pointer example - * ----------------------------------------------------- - * ILP32 8 16 32 32 64* 32 32-bit MacOS, x86 - * LLP64 8 16 32 32 64 64 x64 - * LP64 8 16 32 64 64 64 64-bit MacOS - * - * *) type may be supported by emulation on a 32-bit architecture - * - */ - - - /* integers at least 32 bits wide */ -#define CF2_UInt FT_UFast -#define CF2_Int FT_Fast - - - /* fixed-float numbers */ - typedef FT_Int32 CF2_F16Dot16; - - -FT_END_HEADER - - -#endif /* CF2TYPES_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c index 397f6dfafe9..1a755d5dadd 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c @@ -4,7 +4,7 @@ /* */ /* FreeType OpenType driver component (body only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -27,15 +27,4 @@ #include "cffload.c" #include "cffobjs.c" -#include "cf2arrst.c" -#include "cf2blues.c" -#include "cf2error.c" -#include "cf2font.c" -#include "cf2ft.c" -#include "cf2hints.c" -#include "cf2intrp.c" -#include "cf2read.c" -#include "cf2stack.c" - - /* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c index 4adce7a54d9..e45ae1127bf 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (body). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h index 7792e042483..856a43dd1b9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h @@ -4,7 +4,7 @@ /* */ /* CFF character mapping table (cmap) support (specification). */ /* */ -/* Copyright 2002-2017 by */ +/* Copyright 2002-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -19,7 +19,7 @@ #ifndef CFFCMAP_H_ #define CFFCMAP_H_ -#include "cffobjs.h" +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H FT_BEGIN_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c index 38bfc2ca3dd..df896848da4 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,16 +21,20 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include FT_SERVICE_CID_H #include FT_SERVICE_POSTSCRIPT_INFO_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_TT_CMAP_H +#include FT_SERVICE_CFF_TABLE_LOAD_H #include "cffdrivr.h" #include "cffgload.h" #include "cffload.h" #include "cffcmap.h" #include "cffparse.h" +#include "cffobjs.h" #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_SERVICE_MULTIPLE_MASTERS_H @@ -43,7 +47,7 @@ #include FT_SERVICE_FONT_FORMAT_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_PROPERTIES_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H /*************************************************************************/ @@ -214,8 +218,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without VVAR table */ - if ( !ttface->is_default_instance && - !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && + !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -237,8 +241,10 @@ &dummy, &ah ); - FT_TRACE5(( " idx %d: advance height %d font units\n", - start + nn, ah )); + FT_TRACE5(( " idx %d: advance height %d font unit%s\n", + start + nn, + ah, + ah == 1 ? "" : "s" )); advances[nn] = ah; } } @@ -246,8 +252,8 @@ { #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* no fast retrieval for blended MM fonts without HVAR table */ - if ( !ttface->is_default_instance && - !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) + if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && + !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) return FT_THROW( Unimplemented_Feature ); #endif @@ -266,8 +272,10 @@ &dummy, &aw ); - FT_TRACE5(( " idx %d: advance width %d font units\n", - start + nn, aw )); + FT_TRACE5(( " idx %d: advance width %d font unit%s\n", + start + nn, + aw, + aw == 1 ? "" : "s" )); advances[nn] = aw; } } @@ -493,11 +501,89 @@ } + static FT_Error + cff_ps_get_font_extra( CFF_Face face, + PS_FontExtraRec* afont_extra ) + { + CFF_Font cff = (CFF_Font)face->extra.data; + FT_Error error = FT_Err_Ok; + + + if ( cff && cff->font_extra == NULL ) + { + CFF_FontRecDict dict = &cff->top_font.font_dict; + PS_FontExtraRec* font_extra = NULL; + FT_Memory memory = face->root.memory; + FT_String* embedded_postscript; + + + if ( FT_ALLOC( font_extra, sizeof ( *font_extra ) ) ) + goto Fail; + + font_extra->fs_type = 0U; + + embedded_postscript = cff_index_get_sid_string( + cff, + dict->embedded_postscript ); + if ( embedded_postscript ) + { + FT_String* start_fstype; + FT_String* start_def; + + + /* Identify the XYZ integer in `/FSType XYZ def' substring. */ + if ( ( start_fstype = ft_strstr( embedded_postscript, + "/FSType" ) ) != NULL && + ( start_def = ft_strstr( start_fstype + + sizeof ( "/FSType" ) - 1, + "def" ) ) != NULL ) + { + FT_String* s; + + + for ( s = start_fstype + sizeof ( "/FSType" ) - 1; + s != start_def; + s++ ) + { + if ( *s >= '0' && *s <= '9' ) + { + if ( font_extra->fs_type >= ( FT_USHORT_MAX - 9 ) / 10 ) + { + /* Overflow - ignore the FSType value. */ + font_extra->fs_type = 0U; + break; + } + + font_extra->fs_type *= 10; + font_extra->fs_type += (FT_UShort)( *s - '0' ); + } + else if ( *s != ' ' && *s != '\n' && *s != '\r' ) + { + /* Non-whitespace character between `/FSType' and next `def' */ + /* - ignore the FSType value. */ + font_extra->fs_type = 0U; + break; + } + } + } + } + + cff->font_extra = font_extra; + } + + if ( cff ) + *afont_extra = *cff->font_extra; + + Fail: + return error; + } + + FT_DEFINE_SERVICE_PSINFOREC( cff_service_ps_info, (PS_GetFontInfoFunc) cff_ps_get_font_info, /* ps_get_font_info */ - (PS_GetFontExtraFunc) NULL, /* ps_get_font_extra */ + (PS_GetFontExtraFunc) cff_ps_get_font_extra, /* ps_get_font_extra */ (PS_HasGlyphNamesFunc) cff_ps_has_glyph_names, /* ps_has_glyph_names */ /* unsupported with CFF fonts */ (PS_GetFontPrivateFunc)NULL, /* ps_get_font_private */ @@ -735,231 +821,12 @@ * PROPERTY SERVICE * */ - static FT_Error - cff_property_set( FT_Module module, /* CFF_Driver */ - const char* property_name, - const void* value, - FT_Bool value_is_string ) - { - FT_Error error = FT_Err_Ok; - CFF_Driver driver = (CFF_Driver)module; - -#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_UNUSED( value_is_string ); -#endif - - - if ( !ft_strcmp( property_name, "darkening-parameters" ) ) - { - FT_Int* darken_params; - FT_Int x1, y1, x2, y2, x3, y3, x4, y4; - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_Int dp[8]; - - - if ( value_is_string ) - { - const char* s = (const char*)value; - char* ep; - int i; - - - /* eight comma-separated numbers */ - for ( i = 0; i < 7; i++ ) - { - dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( *ep != ',' || s == ep ) - return FT_THROW( Invalid_Argument ); - - s = ep + 1; - } - - dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) - return FT_THROW( Invalid_Argument ); - - darken_params = dp; - } - else -#endif - darken_params = (FT_Int*)value; - - x1 = darken_params[0]; - y1 = darken_params[1]; - x2 = darken_params[2]; - y2 = darken_params[3]; - x3 = darken_params[4]; - y3 = darken_params[5]; - x4 = darken_params[6]; - y4 = darken_params[7]; - - if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || - y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || - x1 > x2 || x2 > x3 || x3 > x4 || - y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 ) - return FT_THROW( Invalid_Argument ); - - driver->darken_params[0] = x1; - driver->darken_params[1] = y1; - driver->darken_params[2] = x2; - driver->darken_params[3] = y2; - driver->darken_params[4] = x3; - driver->darken_params[5] = y3; - driver->darken_params[6] = x4; - driver->darken_params[7] = y4; - - return error; - } - else if ( !ft_strcmp( property_name, "hinting-engine" ) ) - { -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - if ( !ft_strcmp( s, "adobe" ) ) - driver->hinting_engine = FT_CFF_HINTING_ADOBE; -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - else if ( !ft_strcmp( s, "freetype" ) ) - driver->hinting_engine = FT_CFF_HINTING_FREETYPE; -#endif - else - return FT_THROW( Invalid_Argument ); - } - else -#endif - { - FT_UInt* hinting_engine = (FT_UInt*)value; - - - if ( *hinting_engine == FT_CFF_HINTING_ADOBE -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - || *hinting_engine == FT_CFF_HINTING_FREETYPE -#endif - ) - driver->hinting_engine = *hinting_engine; - else - error = FT_ERR( Unimplemented_Feature ); - - return error; - } - } - else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) - { -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - long nsd = ft_strtol( s, NULL, 10 ); - - - if ( !nsd ) - driver->no_stem_darkening = FALSE; - else - driver->no_stem_darkening = TRUE; - } - else -#endif - { - FT_Bool* no_stem_darkening = (FT_Bool*)value; - - - driver->no_stem_darkening = *no_stem_darkening; - } - - return error; - } - else if ( !ft_strcmp( property_name, "random-seed" ) ) - { - FT_Int32 random_seed; - - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - random_seed = (FT_Int32)ft_strtol( s, NULL, 10 ); - } - else -#endif - random_seed = *(FT_Int32*)value; - - if ( random_seed < 0 ) - random_seed = 0; - - driver->random_seed = random_seed; - - return error; - } - - FT_TRACE0(( "cff_property_set: missing property `%s'\n", - property_name )); - return FT_THROW( Missing_Property ); - } - - - static FT_Error - cff_property_get( FT_Module module, /* CFF_Driver */ - const char* property_name, - const void* value ) - { - FT_Error error = FT_Err_Ok; - CFF_Driver driver = (CFF_Driver)module; - - - if ( !ft_strcmp( property_name, "darkening-parameters" ) ) - { - FT_Int* darken_params = driver->darken_params; - FT_Int* val = (FT_Int*)value; - - - val[0] = darken_params[0]; - val[1] = darken_params[1]; - val[2] = darken_params[2]; - val[3] = darken_params[3]; - val[4] = darken_params[4]; - val[5] = darken_params[5]; - val[6] = darken_params[6]; - val[7] = darken_params[7]; - - return error; - } - else if ( !ft_strcmp( property_name, "hinting-engine" ) ) - { - FT_UInt hinting_engine = driver->hinting_engine; - FT_UInt* val = (FT_UInt*)value; - - - *val = hinting_engine; - - return error; - } - else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) - { - FT_Bool no_stem_darkening = driver->no_stem_darkening; - FT_Bool* val = (FT_Bool*)value; - - - *val = no_stem_darkening; - - return error; - } - - FT_TRACE0(( "cff_property_get: missing property `%s'\n", - property_name )); - return FT_THROW( Missing_Property ); - } - FT_DEFINE_SERVICE_PROPERTIESREC( cff_service_properties, - (FT_Properties_SetFunc)cff_property_set, /* set_property */ - (FT_Properties_GetFunc)cff_property_get ) /* get_property */ + (FT_Properties_SetFunc)ps_property_set, /* set_property */ + (FT_Properties_GetFunc)ps_property_get ) /* get_property */ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT @@ -1028,6 +895,17 @@ } + static FT_Error + cff_set_instance( CFF_Face face, + FT_UInt instance_index ) + { + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + + + return mm->set_instance( FT_FACE( face ), instance_index ); + } + + FT_DEFINE_SERVICE_MULTIMASTERSREC( cff_service_multi_masters, @@ -1038,6 +916,7 @@ (FT_Get_MM_Var_Func) cff_get_mm_var, /* get_mm_var */ (FT_Set_Var_Design_Func)cff_set_var_design, /* set_var_design */ (FT_Get_Var_Design_Func)cff_get_var_design, /* get_var_design */ + (FT_Set_Instance_Func) cff_set_instance, /* set_instance */ (FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */ (FT_Done_Blend_Func) cff_done_blend /* done_blend */ @@ -1088,6 +967,22 @@ #endif + /* + * CFFLOAD SERVICE + * + */ + + FT_DEFINE_SERVICE_CFFLOADREC( + cff_service_cff_load, + + (FT_Get_Standard_Encoding_Func)cff_get_standard_encoding, + (FT_Load_Private_Dict_Func) cff_load_private_dict, + (FT_FD_Select_Get_Func) cff_fd_select_get, + (FT_Blend_Check_Vector_Func) cff_blend_check_vector, + (FT_Blend_Build_Vector_Func) cff_blend_build_vector + ) + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -1102,7 +997,7 @@ #if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \ defined TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_DEFINE_SERVICEDESCREC9( + FT_DEFINE_SERVICEDESCREC10( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1113,10 +1008,11 @@ FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES - FT_DEFINE_SERVICEDESCREC7( + FT_DEFINE_SERVICEDESCREC8( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1125,10 +1021,11 @@ FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT - FT_DEFINE_SERVICEDESCREC8( + FT_DEFINE_SERVICEDESCREC9( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1138,10 +1035,11 @@ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #else - FT_DEFINE_SERVICEDESCREC6( + FT_DEFINE_SERVICEDESCREC7( cff_services, FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF, @@ -1149,7 +1047,8 @@ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET, FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET, - FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET + FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET, + FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET ) #endif @@ -1208,7 +1107,7 @@ FT_MODULE_DRIVER_HAS_HINTER | FT_MODULE_DRIVER_HINTS_LIGHTLY, - sizeof ( CFF_DriverRec ), + sizeof ( PS_DriverRec ), "cff", 0x10000L, 0x20000L, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h index 05381e66db9..ad7c3ad70a8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h @@ -4,7 +4,7 @@ /* */ /* High-level OpenType driver interface (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h index 40808c10513..b2e1bfaf9db 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF error codes (specification only). */ /* */ -/* Copyright 2001-2017 by */ +/* Copyright 2001-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c index 20f3a2c28e9..c58471ce861 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,13 +21,12 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_OUTLINE_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H -#include "cffobjs.h" #include "cffload.h" #include "cffgload.h" -#include "cf2ft.h" /* for cf2_decoder_parse_charstrings */ #include "cfferrs.h" @@ -42,2637 +41,76 @@ #define FT_COMPONENT trace_cffgload -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - - typedef enum CFF_Operator_ - { - cff_op_unknown = 0, - - cff_op_rmoveto, - cff_op_hmoveto, - cff_op_vmoveto, - - cff_op_rlineto, - cff_op_hlineto, - cff_op_vlineto, - - cff_op_rrcurveto, - cff_op_hhcurveto, - cff_op_hvcurveto, - cff_op_rcurveline, - cff_op_rlinecurve, - cff_op_vhcurveto, - cff_op_vvcurveto, - - cff_op_flex, - cff_op_hflex, - cff_op_hflex1, - cff_op_flex1, - - cff_op_endchar, - - cff_op_hstem, - cff_op_vstem, - cff_op_hstemhm, - cff_op_vstemhm, - - cff_op_hintmask, - cff_op_cntrmask, - cff_op_dotsection, /* deprecated, acts as no-op */ - - cff_op_abs, - cff_op_add, - cff_op_sub, - cff_op_div, - cff_op_neg, - cff_op_random, - cff_op_mul, - cff_op_sqrt, - - cff_op_blend, - - cff_op_drop, - cff_op_exch, - cff_op_index, - cff_op_roll, - cff_op_dup, - - cff_op_put, - cff_op_get, - cff_op_store, - cff_op_load, - - cff_op_and, - cff_op_or, - cff_op_not, - cff_op_eq, - cff_op_ifelse, - - cff_op_callsubr, - cff_op_callgsubr, - cff_op_return, - - /* Type 1 opcodes: invalid but seen in real life */ - cff_op_hsbw, - cff_op_closepath, - cff_op_callothersubr, - cff_op_pop, - cff_op_seac, - cff_op_sbw, - cff_op_setcurrentpoint, - - /* do not remove */ - cff_op_max - - } CFF_Operator; - - -#define CFF_COUNT_CHECK_WIDTH 0x80 -#define CFF_COUNT_EXACT 0x40 -#define CFF_COUNT_CLEAR_STACK 0x20 - - /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are */ - /* used for checking the width and requested numbers of arguments */ - /* only; they are set to zero afterwards */ - - /* the other two flags are informative only and unused currently */ - - static const FT_Byte cff_argument_counts[] = - { - 0, /* unknown */ - - 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */ - 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, - 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, - - 0 | CFF_COUNT_CLEAR_STACK, /* rlineto */ - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - - 0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */ - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - 0 | CFF_COUNT_CLEAR_STACK, - - 13, /* flex */ - 7, - 9, - 11, - - 0 | CFF_COUNT_CHECK_WIDTH, /* endchar */ - - 2 | CFF_COUNT_CHECK_WIDTH, /* hstem */ - 2 | CFF_COUNT_CHECK_WIDTH, - 2 | CFF_COUNT_CHECK_WIDTH, - 2 | CFF_COUNT_CHECK_WIDTH, - - 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */ - 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */ - 0, /* dotsection */ - - 1, /* abs */ - 2, - 2, - 2, - 1, - 0, - 2, - 1, - - 1, /* blend */ - - 1, /* drop */ - 2, - 1, - 2, - 1, - - 2, /* put */ - 1, - 4, - 3, - - 2, /* and */ - 2, - 1, - 2, - 4, - - 1, /* callsubr */ - 1, - 0, - - 2, /* hsbw */ - 0, - 0, - 0, - 5, /* seac */ - 4, /* sbw */ - 2 /* setcurrentpoint */ - }; - -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********** *********/ - /********** *********/ - /********** GENERIC CHARSTRING PARSING *********/ - /********** *********/ - /********** *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* cff_builder_init */ - /* */ - /* */ - /* Initializes a given glyph builder. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to initialize. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* glyph :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - static void - cff_builder_init( CFF_Builder* builder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot glyph, - FT_Bool hinting ) - { - builder->path_begun = 0; - builder->load_points = 1; - - builder->face = face; - builder->glyph = glyph; - builder->memory = face->root.memory; - - if ( glyph ) - { - FT_GlyphLoader loader = glyph->root.internal->loader; - - - builder->loader = loader; - builder->base = &loader->base.outline; - builder->current = &loader->current.outline; - FT_GlyphLoader_Rewind( loader ); - - builder->hints_globals = NULL; - builder->hints_funcs = NULL; - - if ( hinting && size ) - { - FT_Size ftsize = FT_SIZE( size ); - CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; - - - if ( internal ) - { - builder->hints_globals = (void *)internal->topfont; - builder->hints_funcs = glyph->root.internal->glyph_hints; - } - } - } - - builder->pos_x = 0; - builder->pos_y = 0; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - builder->advance.x = 0; - builder->advance.y = 0; - } - - - /*************************************************************************/ - /* */ - /* */ - /* cff_builder_done */ - /* */ - /* */ - /* Finalizes a given glyph builder. Its contents can still be used */ - /* after the call, but the function saves important information */ - /* within the corresponding glyph slot. */ - /* */ - /* */ - /* builder :: A pointer to the glyph builder to finalize. */ - /* */ - static void - cff_builder_done( CFF_Builder* builder ) - { - CFF_GlyphSlot glyph = builder->glyph; - - - if ( glyph ) - glyph->root.outline = *builder->base; - } - - - /*************************************************************************/ - /* */ - /* */ - /* cff_compute_bias */ - /* */ - /* */ - /* Computes the bias value in dependence of the number of glyph */ - /* subroutines. */ - /* */ - /* */ - /* in_charstring_type :: The `CharstringType' value of the top DICT */ - /* dictionary. */ - /* */ - /* num_subrs :: The number of glyph subroutines. */ - /* */ - /* */ - /* The bias value. */ - static FT_Int - cff_compute_bias( FT_Int in_charstring_type, - FT_UInt num_subrs ) - { - FT_Int result; - - - if ( in_charstring_type == 1 ) - result = 0; - else if ( num_subrs < 1240 ) - result = 107; - else if ( num_subrs < 33900U ) - result = 1131; - else - result = 32768U; - - return result; - } - - - /*************************************************************************/ - /* */ - /* */ - /* cff_decoder_init */ - /* */ - /* */ - /* Initializes a given glyph decoder. */ - /* */ - /* */ - /* decoder :: A pointer to the glyph builder to initialize. */ - /* */ - /* */ - /* face :: The current face object. */ - /* */ - /* size :: The current size object. */ - /* */ - /* slot :: The current glyph object. */ - /* */ - /* hinting :: Whether hinting is active. */ - /* */ - /* hint_mode :: The hinting mode. */ - /* */ - FT_LOCAL_DEF( void ) - cff_decoder_init( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting, - FT_Render_Mode hint_mode ) - { - CFF_Font cff = (CFF_Font)face->extra.data; - - - /* clear everything */ - FT_ZERO( decoder ); - - /* initialize builder */ - cff_builder_init( &decoder->builder, face, size, slot, hinting ); - - /* initialize Type2 decoder */ - decoder->cff = cff; - decoder->num_globals = cff->global_subrs_index.count; - decoder->globals = cff->global_subrs; - decoder->globals_bias = cff_compute_bias( - cff->top_font.font_dict.charstring_type, - decoder->num_globals ); - - decoder->hint_mode = hint_mode; - } - - - /* this function is used to select the subfont */ - /* and the locals subrs array */ - FT_LOCAL_DEF( FT_Error ) - cff_decoder_prepare( CFF_Decoder* decoder, - CFF_Size size, - FT_UInt glyph_index ) - { - CFF_Builder *builder = &decoder->builder; - CFF_Font cff = (CFF_Font)builder->face->extra.data; - CFF_SubFont sub = &cff->top_font; - FT_Error error = FT_Err_Ok; - - - /* manage CID fonts */ - if ( cff->num_subfonts ) - { - FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); - - - if ( fd_index >= cff->num_subfonts ) - { - FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" )); - error = FT_THROW( Invalid_File_Format ); - goto Exit; - } - - FT_TRACE3(( " in subfont %d:\n", fd_index )); - - sub = cff->subfonts[fd_index]; - - if ( builder->hints_funcs && size ) - { - FT_Size ftsize = FT_SIZE( size ); - CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data; - - - /* for CFFs without subfonts, this value has already been set */ - builder->hints_globals = (void *)internal->subfonts[fd_index]; - } - } - - decoder->num_locals = sub->local_subrs_index.count; - decoder->locals = sub->local_subrs; - decoder->locals_bias = cff_compute_bias( - decoder->cff->top_font.font_dict.charstring_type, - decoder->num_locals ); - - decoder->glyph_width = sub->private_dict.default_width; - decoder->nominal_width = sub->private_dict.nominal_width; - - decoder->current_subfont = sub; - - Exit: - return error; - } - - - /* check that there is enough space for `count' more points */ - FT_LOCAL_DEF( FT_Error ) - cff_check_points( CFF_Builder* builder, - FT_Int count ) - { - return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 ); - } - - - /* add a new point, do not check space */ - FT_LOCAL_DEF( void ) - cff_builder_add_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ) - { - FT_Outline* outline = builder->current; - - - if ( builder->load_points ) - { - FT_Vector* point = outline->points + outline->n_points; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points; - -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face ); - - - if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) - { - point->x = x >> 16; - point->y = y >> 16; - } - else -#endif - { - /* cf2_decoder_parse_charstrings uses 16.16 coordinates */ - point->x = x >> 10; - point->y = y >> 10; - } - *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC ); - } - - outline->n_points++; - } - - - /* check space for a new on-curve point, then add it */ - FT_LOCAL_DEF( FT_Error ) - cff_builder_add_point1( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error; - - - error = cff_check_points( builder, 1 ); - if ( !error ) - cff_builder_add_point( builder, x, y, 1 ); - - return error; - } - - - /* check space for a new contour, then add it */ - static FT_Error - cff_builder_add_contour( CFF_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Error error; - - - if ( !builder->load_points ) - { - outline->n_contours++; - return FT_Err_Ok; - } - - error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 ); - if ( !error ) - { - if ( outline->n_contours > 0 ) - outline->contours[outline->n_contours - 1] = - (short)( outline->n_points - 1 ); - - outline->n_contours++; - } - - return error; - } - - - /* if a path was begun, add its first on-curve point */ - FT_LOCAL_DEF( FT_Error ) - cff_builder_start_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ) - { - FT_Error error = FT_Err_Ok; - - - /* test whether we are building a new contour */ - if ( !builder->path_begun ) - { - builder->path_begun = 1; - error = cff_builder_add_contour( builder ); - if ( !error ) - error = cff_builder_add_point1( builder, x, y ); - } - - return error; - } - - - /* close the current contour */ - FT_LOCAL_DEF( void ) - cff_builder_close_contour( CFF_Builder* builder ) - { - FT_Outline* outline = builder->current; - FT_Int first; - - - if ( !outline ) - return; - - first = outline->n_contours <= 1 - ? 0 : outline->contours[outline->n_contours - 2] + 1; - - /* We must not include the last point in the path if it */ - /* is located on the first point. */ - if ( outline->n_points > 1 ) - { - FT_Vector* p1 = outline->points + first; - FT_Vector* p2 = outline->points + outline->n_points - 1; - FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1; - - - /* `delete' last point only if it coincides with the first */ - /* point and if it is not a control point (which can happen). */ - if ( p1->x == p2->x && p1->y == p2->y ) - if ( *control == FT_CURVE_TAG_ON ) - outline->n_points--; - } - - if ( outline->n_contours > 0 ) - { - /* Don't add contours only consisting of one point, i.e., */ - /* check whether begin point and last point are the same. */ - if ( first == outline->n_points - 1 ) - { - outline->n_contours--; - outline->n_points--; - } - else - outline->contours[outline->n_contours - 1] = - (short)( outline->n_points - 1 ); - } - } - - - FT_LOCAL_DEF( FT_Int ) - cff_lookup_glyph_by_stdcharcode( CFF_Font cff, - FT_Int charcode ) - { - FT_UInt n; - FT_UShort glyph_sid; - - - /* CID-keyed fonts don't have glyph names */ - if ( !cff->charset.sids ) - return -1; - - /* check range of standard char code */ - if ( charcode < 0 || charcode > 255 ) - return -1; - - /* Get code to SID mapping from `cff_standard_encoding'. */ - glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode ); - - for ( n = 0; n < cff->num_glyphs; n++ ) - { - if ( cff->charset.sids[n] == glyph_sid ) - return (FT_Int)n; - } - - return -1; - } - - - FT_LOCAL_DEF( FT_Error ) - cff_get_glyph_data( TT_Face face, - FT_UInt glyph_index, - FT_Byte** pointer, - FT_ULong* length ) - { -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* For incremental fonts get the character data using the */ - /* callback function. */ - if ( face->root.internal->incremental_interface ) - { - FT_Data data; - FT_Error error = - face->root.internal->incremental_interface->funcs->get_glyph_data( - face->root.internal->incremental_interface->object, - glyph_index, &data ); - - - *pointer = (FT_Byte*)data.pointer; - *length = (FT_ULong)data.length; - - return error; - } - else -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - - { - CFF_Font cff = (CFF_Font)(face->extra.data); - - - return cff_index_access_element( &cff->charstrings_index, glyph_index, - pointer, length ); - } - } - - - FT_LOCAL_DEF( void ) - cff_free_glyph_data( TT_Face face, - FT_Byte** pointer, - FT_ULong length ) - { -#ifndef FT_CONFIG_OPTION_INCREMENTAL - FT_UNUSED( length ); -#endif - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* For incremental fonts get the character data using the */ - /* callback function. */ - if ( face->root.internal->incremental_interface ) - { - FT_Data data; - - - data.pointer = *pointer; - data.length = (FT_Int)length; - - face->root.internal->incremental_interface->funcs->free_glyph_data( - face->root.internal->incremental_interface->object, &data ); - } - else -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - - { - CFF_Font cff = (CFF_Font)(face->extra.data); - - - cff_index_forget_element( &cff->charstrings_index, pointer ); - } - } - - -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - - static FT_Error - cff_operator_seac( CFF_Decoder* decoder, - FT_Pos asb, - FT_Pos adx, - FT_Pos ady, - FT_Int bchar, - FT_Int achar ) - { - FT_Error error; - CFF_Builder* builder = &decoder->builder; - FT_Int bchar_index, achar_index; - TT_Face face = decoder->builder.face; - FT_Vector left_bearing, advance; - FT_Byte* charstring; - FT_ULong charstring_len; - FT_Pos glyph_width; - - - if ( decoder->seac ) - { - FT_ERROR(( "cff_operator_seac: invalid nested seac\n" )); - return FT_THROW( Syntax_Error ); - } - - adx += decoder->builder.left_bearing.x; - ady += decoder->builder.left_bearing.y; - -#ifdef FT_CONFIG_OPTION_INCREMENTAL - /* Incremental fonts don't necessarily have valid charsets. */ - /* They use the character code, not the glyph index, in this case. */ - if ( face->root.internal->incremental_interface ) - { - bchar_index = bchar; - achar_index = achar; - } - else -#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - { - CFF_Font cff = (CFF_Font)(face->extra.data); - - - bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar ); - achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar ); - } - - if ( bchar_index < 0 || achar_index < 0 ) - { - FT_ERROR(( "cff_operator_seac:" - " invalid seac character code arguments\n" )); - return FT_THROW( Syntax_Error ); - } - - /* If we are trying to load a composite glyph, do not load the */ - /* accent character and return the array of subglyphs. */ - if ( builder->no_recurse ) - { - FT_GlyphSlot glyph = (FT_GlyphSlot)builder->glyph; - FT_GlyphLoader loader = glyph->internal->loader; - FT_SubGlyph subg; - - - /* reallocate subglyph array if necessary */ - error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); - if ( error ) - goto Exit; - - subg = loader->current.subglyphs; - - /* subglyph 0 = base character */ - subg->index = bchar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | - FT_SUBGLYPH_FLAG_USE_MY_METRICS; - subg->arg1 = 0; - subg->arg2 = 0; - subg++; - - /* subglyph 1 = accent character */ - subg->index = achar_index; - subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; - subg->arg1 = (FT_Int)( adx >> 16 ); - subg->arg2 = (FT_Int)( ady >> 16 ); - - /* set up remaining glyph fields */ - glyph->num_subglyphs = 2; - glyph->subglyphs = loader->base.subglyphs; - glyph->format = FT_GLYPH_FORMAT_COMPOSITE; - - loader->current.num_subglyphs = 2; - } - - FT_GlyphLoader_Prepare( builder->loader ); - - /* First load `bchar' in builder */ - error = cff_get_glyph_data( face, (FT_UInt)bchar_index, - &charstring, &charstring_len ); - if ( !error ) - { - /* the seac operator must not be nested */ - decoder->seac = TRUE; - error = cff_decoder_parse_charstrings( decoder, charstring, - charstring_len, 0 ); - decoder->seac = FALSE; - - cff_free_glyph_data( face, &charstring, charstring_len ); - - if ( error ) - goto Exit; - } - - /* Save the left bearing, advance and glyph width of the base */ - /* character as they will be erased by the next load. */ - - left_bearing = builder->left_bearing; - advance = builder->advance; - glyph_width = decoder->glyph_width; - - builder->left_bearing.x = 0; - builder->left_bearing.y = 0; - - builder->pos_x = adx - asb; - builder->pos_y = ady; - - /* Now load `achar' on top of the base outline. */ - error = cff_get_glyph_data( face, (FT_UInt)achar_index, - &charstring, &charstring_len ); - if ( !error ) - { - /* the seac operator must not be nested */ - decoder->seac = TRUE; - error = cff_decoder_parse_charstrings( decoder, charstring, - charstring_len, 0 ); - decoder->seac = FALSE; - - cff_free_glyph_data( face, &charstring, charstring_len ); - - if ( error ) - goto Exit; - } - - /* Restore the left side bearing, advance and glyph width */ - /* of the base character. */ - builder->left_bearing = left_bearing; - builder->advance = advance; - decoder->glyph_width = glyph_width; - - builder->pos_x = 0; - builder->pos_y = 0; - - Exit: - return error; - } - - - /*************************************************************************/ - /* */ - /* */ - /* cff_decoder_parse_charstrings */ - /* */ - /* */ - /* Parses a given Type 2 charstrings program. */ - /* */ - /* */ - /* decoder :: The current Type 1 decoder. */ - /* */ - /* */ - /* charstring_base :: The base of the charstring stream. */ - /* */ - /* charstring_len :: The length in bytes of the charstring stream. */ - /* */ - /* in_dict :: Set to 1 if function is called from top or */ - /* private DICT (needed for Multiple Master CFFs). */ - /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) - cff_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len, - FT_Bool in_dict ) - { - FT_Error error; - CFF_Decoder_Zone* zone; - FT_Byte* ip; - FT_Byte* limit; - CFF_Builder* builder = &decoder->builder; - FT_Pos x, y; - FT_Fixed* stack; - FT_Int charstring_type = - decoder->cff->top_font.font_dict.charstring_type; - FT_UShort num_designs = - decoder->cff->top_font.font_dict.num_designs; - FT_UShort num_axes = - decoder->cff->top_font.font_dict.num_axes; - - T2_Hints_Funcs hinter; - - - /* set default width */ - decoder->num_hints = 0; - decoder->read_width = 1; - - /* initialize the decoder */ - decoder->top = decoder->stack; - decoder->zone = decoder->zones; - zone = decoder->zones; - stack = decoder->top; - - hinter = (T2_Hints_Funcs)builder->hints_funcs; - - builder->path_begun = 0; - - zone->base = charstring_base; - limit = zone->limit = charstring_base + charstring_len; - ip = zone->cursor = zone->base; - - error = FT_Err_Ok; - - x = builder->pos_x; - y = builder->pos_y; - - /* begin hints recording session, if any */ - if ( hinter ) - hinter->open( hinter->hints ); - - /* now execute loop */ - while ( ip < limit ) - { - CFF_Operator op; - FT_Byte v; - - - /********************************************************************/ - /* */ - /* Decode operator or operand */ - /* */ - v = *ip++; - if ( v >= 32 || v == 28 ) - { - FT_Int shift = 16; - FT_Int32 val; - - - /* this is an operand, push it on the stack */ - - /* if we use shifts, all computations are done with unsigned */ - /* values; the conversion to a signed value is the last step */ - if ( v == 28 ) - { - if ( ip + 1 >= limit ) - goto Syntax_Error; - val = (FT_Short)( ( (FT_UShort)ip[0] << 8 ) | ip[1] ); - ip += 2; - } - else if ( v < 247 ) - val = (FT_Int32)v - 139; - else if ( v < 251 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108; - } - else if ( v < 255 ) - { - if ( ip >= limit ) - goto Syntax_Error; - val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108; - } - else - { - if ( ip + 3 >= limit ) - goto Syntax_Error; - val = (FT_Int32)( ( (FT_UInt32)ip[0] << 24 ) | - ( (FT_UInt32)ip[1] << 16 ) | - ( (FT_UInt32)ip[2] << 8 ) | - (FT_UInt32)ip[3] ); - ip += 4; - if ( charstring_type == 2 ) - shift = 0; - } - if ( decoder->top - stack >= CFF_MAX_OPERANDS ) - goto Stack_Overflow; - - val = (FT_Int32)( (FT_UInt32)val << shift ); - *decoder->top++ = val; - -#ifdef FT_DEBUG_LEVEL_TRACE - if ( !( val & 0xFFFFL ) ) - FT_TRACE4(( " %hd", (FT_Short)( (FT_UInt32)val >> 16 ) )); - else - FT_TRACE4(( " %.5f", val / 65536.0 )); -#endif - - } - else - { - /* The specification says that normally arguments are to be taken */ - /* from the bottom of the stack. However, this seems not to be */ - /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */ - /* arguments similar to a PS interpreter. */ - - FT_Fixed* args = decoder->top; - FT_Int num_args = (FT_Int)( args - decoder->stack ); - FT_Int req_args; - - - /* find operator */ - op = cff_op_unknown; - - switch ( v ) - { - case 1: - op = cff_op_hstem; - break; - case 3: - op = cff_op_vstem; - break; - case 4: - op = cff_op_vmoveto; - break; - case 5: - op = cff_op_rlineto; - break; - case 6: - op = cff_op_hlineto; - break; - case 7: - op = cff_op_vlineto; - break; - case 8: - op = cff_op_rrcurveto; - break; - case 9: - op = cff_op_closepath; - break; - case 10: - op = cff_op_callsubr; - break; - case 11: - op = cff_op_return; - break; - case 12: - { - if ( ip >= limit ) - goto Syntax_Error; - v = *ip++; - - switch ( v ) - { - case 0: - op = cff_op_dotsection; - break; - case 1: /* this is actually the Type1 vstem3 operator */ - op = cff_op_vstem; - break; - case 2: /* this is actually the Type1 hstem3 operator */ - op = cff_op_hstem; - break; - case 3: - op = cff_op_and; - break; - case 4: - op = cff_op_or; - break; - case 5: - op = cff_op_not; - break; - case 6: - op = cff_op_seac; - break; - case 7: - op = cff_op_sbw; - break; - case 8: - op = cff_op_store; - break; - case 9: - op = cff_op_abs; - break; - case 10: - op = cff_op_add; - break; - case 11: - op = cff_op_sub; - break; - case 12: - op = cff_op_div; - break; - case 13: - op = cff_op_load; - break; - case 14: - op = cff_op_neg; - break; - case 15: - op = cff_op_eq; - break; - case 16: - op = cff_op_callothersubr; - break; - case 17: - op = cff_op_pop; - break; - case 18: - op = cff_op_drop; - break; - case 20: - op = cff_op_put; - break; - case 21: - op = cff_op_get; - break; - case 22: - op = cff_op_ifelse; - break; - case 23: - op = cff_op_random; - break; - case 24: - op = cff_op_mul; - break; - case 26: - op = cff_op_sqrt; - break; - case 27: - op = cff_op_dup; - break; - case 28: - op = cff_op_exch; - break; - case 29: - op = cff_op_index; - break; - case 30: - op = cff_op_roll; - break; - case 33: - op = cff_op_setcurrentpoint; - break; - case 34: - op = cff_op_hflex; - break; - case 35: - op = cff_op_flex; - break; - case 36: - op = cff_op_hflex1; - break; - case 37: - op = cff_op_flex1; - break; - default: - FT_TRACE4(( " unknown op (12, %d)\n", v )); - break; - } - } - break; - case 13: - op = cff_op_hsbw; - break; - case 14: - op = cff_op_endchar; - break; - case 16: - op = cff_op_blend; - break; - case 18: - op = cff_op_hstemhm; - break; - case 19: - op = cff_op_hintmask; - break; - case 20: - op = cff_op_cntrmask; - break; - case 21: - op = cff_op_rmoveto; - break; - case 22: - op = cff_op_hmoveto; - break; - case 23: - op = cff_op_vstemhm; - break; - case 24: - op = cff_op_rcurveline; - break; - case 25: - op = cff_op_rlinecurve; - break; - case 26: - op = cff_op_vvcurveto; - break; - case 27: - op = cff_op_hhcurveto; - break; - case 29: - op = cff_op_callgsubr; - break; - case 30: - op = cff_op_vhcurveto; - break; - case 31: - op = cff_op_hvcurveto; - break; - default: - FT_TRACE4(( " unknown op (%d)\n", v )); - break; - } - - if ( op == cff_op_unknown ) - continue; - - /* in Multiple Master CFFs, T2 charstrings can appear in */ - /* dictionaries, but some operators are prohibited */ - if ( in_dict ) - { - switch ( op ) - { - case cff_op_hstem: - case cff_op_vstem: - case cff_op_vmoveto: - case cff_op_rlineto: - case cff_op_hlineto: - case cff_op_vlineto: - case cff_op_rrcurveto: - case cff_op_hstemhm: - case cff_op_hintmask: - case cff_op_cntrmask: - case cff_op_rmoveto: - case cff_op_hmoveto: - case cff_op_vstemhm: - case cff_op_rcurveline: - case cff_op_rlinecurve: - case cff_op_vvcurveto: - case cff_op_hhcurveto: - case cff_op_vhcurveto: - case cff_op_hvcurveto: - case cff_op_hflex: - case cff_op_flex: - case cff_op_hflex1: - case cff_op_flex1: - case cff_op_callsubr: - case cff_op_callgsubr: - goto MM_Error; - - default: - break; - } - } - - /* check arguments */ - req_args = cff_argument_counts[op]; - if ( req_args & CFF_COUNT_CHECK_WIDTH ) - { - if ( num_args > 0 && decoder->read_width ) - { - /* If `nominal_width' is non-zero, the number is really a */ - /* difference against `nominal_width'. Else, the number here */ - /* is truly a width, not a difference against `nominal_width'. */ - /* If the font does not set `nominal_width', then */ - /* `nominal_width' defaults to zero, and so we can set */ - /* `glyph_width' to `nominal_width' plus number on the stack */ - /* -- for either case. */ - - FT_Int set_width_ok; - - - switch ( op ) - { - case cff_op_hmoveto: - case cff_op_vmoveto: - set_width_ok = num_args & 2; - break; - - case cff_op_hstem: - case cff_op_vstem: - case cff_op_hstemhm: - case cff_op_vstemhm: - case cff_op_rmoveto: - case cff_op_hintmask: - case cff_op_cntrmask: - set_width_ok = num_args & 1; - break; - - case cff_op_endchar: - /* If there is a width specified for endchar, we either have */ - /* 1 argument or 5 arguments. We like to argue. */ - set_width_ok = in_dict - ? 0 - : ( ( num_args == 5 ) || ( num_args == 1 ) ); - break; - - default: - set_width_ok = 0; - break; - } - - if ( set_width_ok ) - { - decoder->glyph_width = decoder->nominal_width + - ( stack[0] >> 16 ); - - if ( decoder->width_only ) - { - /* we only want the advance width; stop here */ - break; - } - - /* Consumed an argument. */ - num_args--; - } - } - - decoder->read_width = 0; - req_args = 0; - } - - req_args &= 0x000F; - if ( num_args < req_args ) - goto Stack_Underflow; - args -= req_args; - num_args -= req_args; - - /* At this point, `args' points to the first argument of the */ - /* operand in case `req_args' isn't zero. Otherwise, we have */ - /* to adjust `args' manually. */ - - /* Note that we only pop arguments from the stack which we */ - /* really need and can digest so that we can continue in case */ - /* of superfluous stack elements. */ - - switch ( op ) - { - case cff_op_hstem: - case cff_op_vstem: - case cff_op_hstemhm: - case cff_op_vstemhm: - /* the number of arguments is always even here */ - FT_TRACE4(( - op == cff_op_hstem ? " hstem\n" : - ( op == cff_op_vstem ? " vstem\n" : - ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) )); - - if ( hinter ) - hinter->stems( hinter->hints, - ( op == cff_op_hstem || op == cff_op_hstemhm ), - num_args / 2, - args - ( num_args & ~1 ) ); - - decoder->num_hints += num_args / 2; - args = stack; - break; - - case cff_op_hintmask: - case cff_op_cntrmask: - FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); - - /* implement vstem when needed -- */ - /* the specification doesn't say it, but this also works */ - /* with the 'cntrmask' operator */ - /* */ - if ( num_args > 0 ) - { - if ( hinter ) - hinter->stems( hinter->hints, - 0, - num_args / 2, - args - ( num_args & ~1 ) ); - - decoder->num_hints += num_args / 2; - } - - /* In a valid charstring there must be at least one byte */ - /* after `hintmask' or `cntrmask' (e.g., for a `return' */ - /* instruction). Additionally, there must be space for */ - /* `num_hints' bits. */ - - if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit ) - goto Syntax_Error; - - if ( hinter ) - { - if ( op == cff_op_hintmask ) - hinter->hintmask( hinter->hints, - (FT_UInt)builder->current->n_points, - (FT_UInt)decoder->num_hints, - ip ); - else - hinter->counter( hinter->hints, - (FT_UInt)decoder->num_hints, - ip ); - } - -#ifdef FT_DEBUG_LEVEL_TRACE - { - FT_UInt maskbyte; - - - FT_TRACE4(( " (maskbytes:" )); - - for ( maskbyte = 0; - maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 ); - maskbyte++, ip++ ) - FT_TRACE4(( " 0x%02X", *ip )); - - FT_TRACE4(( ")\n" )); - } -#else - ip += ( decoder->num_hints + 7 ) >> 3; -#endif - args = stack; - break; - - case cff_op_rmoveto: - FT_TRACE4(( " rmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - x = ADD_LONG( x, args[-2] ); - y = ADD_LONG( y, args[-1] ); - args = stack; - break; - - case cff_op_vmoveto: - FT_TRACE4(( " vmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - y = ADD_LONG( y, args[-1] ); - args = stack; - break; - - case cff_op_hmoveto: - FT_TRACE4(( " hmoveto\n" )); - - cff_builder_close_contour( builder ); - builder->path_begun = 0; - x = ADD_LONG( x, args[-1] ); - args = stack; - break; - - case cff_op_rlineto: - FT_TRACE4(( " rlineto\n" )); - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_args / 2 ) ) - goto Fail; - - if ( num_args < 2 ) - goto Stack_Underflow; - - args -= num_args & ~1; - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - args += 2; - } - args = stack; - break; - - case cff_op_hlineto: - case cff_op_vlineto: - { - FT_Int phase = ( op == cff_op_hlineto ); - - - FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n" - : " vlineto\n" )); - - if ( num_args < 0 ) - goto Stack_Underflow; - - /* there exist subsetted fonts (found in PDFs) */ - /* which call `hlineto' without arguments */ - if ( num_args == 0 ) - break; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_args ) ) - goto Fail; - - args = stack; - while ( args < decoder->top ) - { - if ( phase ) - x = ADD_LONG( x, args[0] ); - else - y = ADD_LONG( y, args[0] ); - - if ( cff_builder_add_point1( builder, x, y ) ) - goto Fail; - - args++; - phase ^= 1; - } - args = stack; - } - break; - - case cff_op_rrcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " rrcurveto\n" )); - - if ( num_args < 6 ) - goto Stack_Underflow; - - nargs = num_args - num_args % 6; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, nargs / 2 ) ) - goto Fail; - - args -= nargs; - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 6; - } - args = stack; - } - break; - - case cff_op_vvcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " vvcurveto\n" )); - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - args -= nargs; - - if ( nargs & 1 ) - { - x = ADD_LONG( x, args[0] ); - args++; - nargs--; - } - - if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) - goto Fail; - - while ( args < decoder->top ) - { - y = ADD_LONG( y, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 4; - } - args = stack; - } - break; - - case cff_op_hhcurveto: - { - FT_Int nargs; - - - FT_TRACE4(( " hhcurveto\n" )); - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 4n or 4n+1, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - args -= nargs; - if ( nargs & 1 ) - { - y = ADD_LONG( y, args[0] ); - args++; - nargs--; - } - - if ( cff_check_points( builder, 3 * ( nargs / 4 ) ) ) - goto Fail; - - while ( args < decoder->top ) - { - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 4; - } - args = stack; - } - break; - - case cff_op_vhcurveto: - case cff_op_hvcurveto: - { - FT_Int phase; - FT_Int nargs; - - - FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n" - : " hvcurveto\n" )); - - if ( cff_builder_start_point( builder, x, y ) ) - goto Fail; - - if ( num_args < 4 ) - goto Stack_Underflow; - - /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ - /* we enforce it by clearing the second bit */ - - nargs = num_args & ~2; - - args -= nargs; - if ( cff_check_points( builder, ( nargs / 4 ) * 3 ) ) - goto Stack_Underflow; - - phase = ( op == cff_op_hvcurveto ); - - while ( nargs >= 4 ) - { - nargs -= 4; - if ( phase ) - { - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - y = ADD_LONG( y, args[3] ); - if ( nargs == 1 ) - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - } - else - { - y = ADD_LONG( y, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[3] ); - if ( nargs == 1 ) - y = ADD_LONG( y, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - } - args += 4; - phase ^= 1; - } - args = stack; - } - break; - - case cff_op_rlinecurve: - { - FT_Int num_lines; - FT_Int nargs; - - - FT_TRACE4(( " rlinecurve\n" )); - - if ( num_args < 8 ) - goto Stack_Underflow; - - nargs = num_args & ~1; - num_lines = ( nargs - 6 ) / 2; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_lines + 3 ) ) - goto Fail; - - args -= nargs; - - /* first, add the line segments */ - while ( num_lines > 0 ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 2; - num_lines--; - } - - /* then the curve */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - } - break; - - case cff_op_rcurveline: - { - FT_Int num_curves; - FT_Int nargs; - - - FT_TRACE4(( " rcurveline\n" )); - - if ( num_args < 8 ) - goto Stack_Underflow; - - nargs = num_args - 2; - nargs = nargs - nargs % 6 + 2; - num_curves = ( nargs - 2 ) / 6; - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, num_curves * 3 + 2 ) ) - goto Fail; - - args -= nargs; - - /* first, add the curves */ - while ( num_curves > 0 ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - x = ADD_LONG( x, args[4] ); - y = ADD_LONG( y, args[5] ); - cff_builder_add_point( builder, x, y, 1 ); - - args += 6; - num_curves--; - } - - /* then the final line */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - } - break; - - case cff_op_hflex1: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex1\n" )); - - /* adding five more points: 4 control points, 1 on-curve point */ - /* -- make sure we have enough space for the start point if it */ - /* needs to be added */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's y position for later use */ - start_y = y; - - /* first control point */ - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* second control point */ - x = ADD_LONG( x, args[2] ); - y = ADD_LONG( y, args[3] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x = ADD_LONG( x, args[5] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* fourth control point */ - x = ADD_LONG( x, args[6] ); - y = ADD_LONG( y, args[7] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start */ - x = ADD_LONG( x, args[8] ); - y = start_y; - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_hflex: - { - FT_Pos start_y; - - - FT_TRACE4(( " hflex\n" )); - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's y-position for later use */ - start_y = y; - - /* first control point */ - x = ADD_LONG( x, args[0] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* second control point */ - x = ADD_LONG( x, args[1] ); - y = ADD_LONG( y, args[2] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* join point; on curve, with y-value the same as the last */ - /* control point's y-value */ - x = ADD_LONG( x, args[3] ); - cff_builder_add_point( builder, x, y, 1 ); - - /* third control point, with y-value the same as the join */ - /* point's y-value */ - x = ADD_LONG( x, args[4] ); - cff_builder_add_point( builder, x, y, 0 ); - - /* fourth control point */ - x = ADD_LONG( x, args[5] ); - y = start_y; - cff_builder_add_point( builder, x, y, 0 ); - - /* ending point, with y-value the same as the start point's */ - /* y-value -- we don't add this point, though */ - x = ADD_LONG( x, args[6] ); - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_flex1: - { - FT_Pos start_x, start_y; /* record start x, y values for */ - /* alter use */ - FT_Fixed dx = 0, dy = 0; /* used in horizontal/vertical */ - /* algorithm below */ - FT_Int horizontal, count; - FT_Fixed* temp; - - - FT_TRACE4(( " flex1\n" )); - - /* adding six more points; 4 control points, 2 on-curve points */ - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - /* record the starting point's x, y position for later use */ - start_x = x; - start_y = y; - - /* XXX: figure out whether this is supposed to be a horizontal */ - /* or vertical flex; the Type 2 specification is vague... */ - - temp = args; - - /* grab up to the last argument */ - for ( count = 5; count > 0; count-- ) - { - dx = ADD_LONG( dx, temp[0] ); - dy = ADD_LONG( dy, temp[1] ); - temp += 2; - } - - if ( dx < 0 ) - dx = -dx; - if ( dy < 0 ) - dy = -dy; - - /* strange test, but here it is... */ - horizontal = ( dx > dy ); - - for ( count = 5; count > 0; count-- ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 3 ) ); - args += 2; - } - - /* is last operand an x- or y-delta? */ - if ( horizontal ) - { - x = ADD_LONG( x, args[0] ); - y = start_y; - } - else - { - x = start_x; - y = ADD_LONG( y, args[0] ); - } - - cff_builder_add_point( builder, x, y, 1 ); - - args = stack; - break; - } - - case cff_op_flex: - { - FT_UInt count; - - - FT_TRACE4(( " flex\n" )); - - if ( cff_builder_start_point( builder, x, y ) || - cff_check_points( builder, 6 ) ) - goto Fail; - - for ( count = 6; count > 0; count-- ) - { - x = ADD_LONG( x, args[0] ); - y = ADD_LONG( y, args[1] ); - cff_builder_add_point( builder, x, y, - (FT_Bool)( count == 4 || count == 1 ) ); - args += 2; - } - - args = stack; - } - break; - - case cff_op_seac: - FT_TRACE4(( " seac\n" )); - - error = cff_operator_seac( decoder, - args[0], args[1], args[2], - (FT_Int)( args[3] >> 16 ), - (FT_Int)( args[4] >> 16 ) ); - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - - /* return now! */ - FT_TRACE4(( "\n" )); - return error; - - case cff_op_endchar: - /* in dictionaries, `endchar' simply indicates end of data */ - if ( in_dict ) - return error; - - FT_TRACE4(( " endchar\n" )); - - /* We are going to emulate the seac operator. */ - if ( num_args >= 4 ) - { - /* Save glyph width so that the subglyphs don't overwrite it. */ - FT_Pos glyph_width = decoder->glyph_width; - - - error = cff_operator_seac( decoder, - 0L, args[-4], args[-3], - (FT_Int)( args[-2] >> 16 ), - (FT_Int)( args[-1] >> 16 ) ); - - decoder->glyph_width = glyph_width; - } - else - { - cff_builder_close_contour( builder ); - - /* close hints recording session */ - if ( hinter ) - { - if ( hinter->close( hinter->hints, - (FT_UInt)builder->current->n_points ) ) - goto Syntax_Error; - - /* apply hints to the loaded glyph outline now */ - error = hinter->apply( hinter->hints, - builder->current, - (PSH_Globals)builder->hints_globals, - decoder->hint_mode ); - if ( error ) - goto Fail; - } - - /* add current outline to the glyph slot */ - FT_GlyphLoader_Add( builder->loader ); - } - - /* return now! */ - FT_TRACE4(( "\n" )); - return error; - - case cff_op_abs: - FT_TRACE4(( " abs\n" )); - - if ( args[0] < 0 ) - { - if ( args[0] == FT_LONG_MIN ) - args[0] = FT_LONG_MAX; - else - args[0] = -args[0]; - } - args++; - break; - - case cff_op_add: - FT_TRACE4(( " add\n" )); - - args[0] = ADD_LONG( args[0], args[1] ); - args++; - break; - - case cff_op_sub: - FT_TRACE4(( " sub\n" )); - - args[0] = SUB_LONG( args[0], args[1] ); - args++; - break; - - case cff_op_div: - FT_TRACE4(( " div\n" )); - - args[0] = FT_DivFix( args[0], args[1] ); - args++; - break; - - case cff_op_neg: - FT_TRACE4(( " neg\n" )); - - if ( args[0] == FT_LONG_MIN ) - args[0] = FT_LONG_MAX; - args[0] = -args[0]; - args++; - break; - - case cff_op_random: - FT_TRACE4(( " random\n" )); - - /* only use the lower 16 bits of `random' */ - /* to generate a number in the range (0;1] */ - args[0] = (FT_Fixed) - ( ( decoder->current_subfont->random & 0xFFFF ) + 1 ); - args++; - - decoder->current_subfont->random = - cff_random( decoder->current_subfont->random ); - break; - - case cff_op_mul: - FT_TRACE4(( " mul\n" )); - - args[0] = FT_MulFix( args[0], args[1] ); - args++; - break; - - case cff_op_sqrt: - FT_TRACE4(( " sqrt\n" )); - - if ( args[0] > 0 ) - { - FT_Fixed root = args[0]; - FT_Fixed new_root; - - - for (;;) - { - new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1; - if ( new_root == root ) - break; - root = new_root; - } - args[0] = new_root; - } - else - args[0] = 0; - args++; - break; - - case cff_op_drop: - /* nothing */ - FT_TRACE4(( " drop\n" )); - - break; - - case cff_op_exch: - { - FT_Fixed tmp; - - - FT_TRACE4(( " exch\n" )); - - tmp = args[0]; - args[0] = args[1]; - args[1] = tmp; - args += 2; - } - break; - - case cff_op_index: - { - FT_Int idx = (FT_Int)( args[0] >> 16 ); - - - FT_TRACE4(( " index\n" )); - - if ( idx < 0 ) - idx = 0; - else if ( idx > num_args - 2 ) - idx = num_args - 2; - args[0] = args[-( idx + 1 )]; - args++; - } - break; - - case cff_op_roll: - { - FT_Int count = (FT_Int)( args[0] >> 16 ); - FT_Int idx = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " roll\n" )); - - if ( count <= 0 ) - count = 1; - - args -= count; - if ( args < stack ) - goto Stack_Underflow; - - if ( idx >= 0 ) - { - while ( idx > 0 ) - { - FT_Fixed tmp = args[count - 1]; - FT_Int i; - - - for ( i = count - 2; i >= 0; i-- ) - args[i + 1] = args[i]; - args[0] = tmp; - idx--; - } - } - else - { - while ( idx < 0 ) - { - FT_Fixed tmp = args[0]; - FT_Int i; - - - for ( i = 0; i < count - 1; i++ ) - args[i] = args[i + 1]; - args[count - 1] = tmp; - idx++; - } - } - args += count; - } - break; - - case cff_op_dup: - FT_TRACE4(( " dup\n" )); - - args[1] = args[0]; - args += 2; - break; - - case cff_op_put: - { - FT_Fixed val = args[0]; - FT_Int idx = (FT_Int)( args[1] >> 16 ); - - - FT_TRACE4(( " put\n" )); - - /* the Type2 specification before version 16-March-2000 */ - /* didn't give a hard-coded size limit of the temporary */ - /* storage array; instead, an argument of the */ - /* `MultipleMaster' operator set the size */ - if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) - decoder->buildchar[idx] = val; - } - break; - - case cff_op_get: - { - FT_Int idx = (FT_Int)( args[0] >> 16 ); - FT_Fixed val = 0; - - - FT_TRACE4(( " get\n" )); - - if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS ) - val = decoder->buildchar[idx]; - - args[0] = val; - args++; - } - break; - - case cff_op_store: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, this is a no-op */ - FT_TRACE4(( " store\n")); - break; - - case cff_op_load: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - { - FT_Int reg_idx = (FT_Int)args[0]; - FT_Int idx = (FT_Int)args[1]; - FT_Int count = (FT_Int)args[2]; - - - FT_TRACE4(( " load\n" )); - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, we store a vector [1 0 0 ...] in the */ - /* temporary storage array regardless of the Registry index */ - if ( reg_idx >= 0 && reg_idx <= 2 && - idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS && - count >= 0 && count <= num_axes ) - { - FT_Int end, i; - - - end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS ); - - if ( idx < end ) - decoder->buildchar[idx] = 1 << 16; - - for ( i = idx + 1; i < end; i++ ) - decoder->buildchar[i] = 0; - } - } - break; - - case cff_op_blend: - /* this operator was removed from the Type2 specification */ - /* in version 16-March-2000 */ - { - FT_Int num_results = (FT_Int)( args[0] >> 16 ); - - - FT_TRACE4(( " blend\n" )); - - if ( num_results < 0 ) - goto Syntax_Error; - - if ( num_results * (FT_Int)num_designs > num_args ) - goto Stack_Underflow; - - /* since we currently don't handle interpolation of multiple */ - /* master fonts, return the `num_results' values of the */ - /* first master */ - args -= num_results * ( num_designs - 1 ); - num_args -= num_results * ( num_designs - 1 ); - } - break; - - case cff_op_dotsection: - /* this operator is deprecated and ignored by the parser */ - FT_TRACE4(( " dotsection\n" )); - break; - - case cff_op_closepath: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " closepath (invalid op)\n" )); - - args = stack; - break; - - case cff_op_hsbw: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " hsbw (invalid op)\n" )); - - decoder->glyph_width = - ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) ); - - decoder->builder.left_bearing.x = args[0]; - decoder->builder.left_bearing.y = 0; - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = decoder->builder.pos_y; - args = stack; - break; - - case cff_op_sbw: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " sbw (invalid op)\n" )); - - decoder->glyph_width = - ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) ); - - decoder->builder.left_bearing.x = args[0]; - decoder->builder.left_bearing.y = args[1]; - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = ADD_LONG( decoder->builder.pos_y, args[1] ); - args = stack; - break; - - case cff_op_setcurrentpoint: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " setcurrentpoint (invalid op)\n" )); - - x = ADD_LONG( decoder->builder.pos_x, args[0] ); - y = ADD_LONG( decoder->builder.pos_y, args[1] ); - args = stack; - break; - - case cff_op_callothersubr: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " callothersubr (invalid op)\n" )); - - /* subsequent `pop' operands should add the arguments, */ - /* this is the implementation described for `unknown' other */ - /* subroutines in the Type1 spec. */ - /* */ - /* XXX Fix return arguments (see discussion below). */ - args -= 2 + ( args[-2] >> 16 ); - if ( args < stack ) - goto Stack_Underflow; - break; - - case cff_op_pop: - /* this is an invalid Type 2 operator; however, there */ - /* exist fonts which are incorrectly converted from probably */ - /* Type 1 to CFF, and some parsers seem to accept it */ - - FT_TRACE4(( " pop (invalid op)\n" )); - - /* XXX Increasing `args' is wrong: After a certain number of */ - /* `pop's we get a stack overflow. Reason for doing it is */ - /* code like this (actually found in a CFF font): */ - /* */ - /* 17 1 3 callothersubr */ - /* pop */ - /* callsubr */ - /* */ - /* Since we handle `callothersubr' as a no-op, and */ - /* `callsubr' needs at least one argument, `pop' can't be a */ - /* no-op too as it basically should be. */ - /* */ - /* The right solution would be to provide real support for */ - /* `callothersubr' as done in `t1decode.c', however, given */ - /* the fact that CFF fonts with `pop' are invalid, it is */ - /* questionable whether it is worth the time. */ - args++; - break; - - case cff_op_and: - { - FT_Fixed cond = ( args[0] && args[1] ); - - - FT_TRACE4(( " and\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_or: - { - FT_Fixed cond = ( args[0] || args[1] ); - - - FT_TRACE4(( " or\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_not: - { - FT_Fixed cond = !args[0]; - - - FT_TRACE4(( " not\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_eq: - { - FT_Fixed cond = ( args[0] == args[1] ); - - - FT_TRACE4(( " eq\n" )); - - args[0] = cond ? 0x10000L : 0; - args++; - } - break; - - case cff_op_ifelse: - { - FT_Fixed cond = ( args[2] <= args[3] ); - - - FT_TRACE4(( " ifelse\n" )); - - if ( !cond ) - args[0] = args[1]; - args++; - } - break; - - case cff_op_callsubr: - { - FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + - decoder->locals_bias ); - - - FT_TRACE4(( " callsubr (idx %d, entering level %d)\n", - idx, - zone - decoder->zones + 1 )); - - if ( idx >= decoder->num_locals ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invalid local subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->locals[idx]; - zone->limit = decoder->locals[idx + 1]; - zone->cursor = zone->base; - - if ( !zone->base || zone->limit == zone->base ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invoking empty subrs\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case cff_op_callgsubr: - { - FT_UInt idx = (FT_UInt)( ( args[0] >> 16 ) + - decoder->globals_bias ); - - - FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n", - idx, - zone - decoder->zones + 1 )); - - if ( idx >= decoder->num_globals ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invalid global subr index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = decoder->globals[idx]; - zone->limit = decoder->globals[idx + 1]; - zone->cursor = zone->base; - - if ( !zone->base || zone->limit == zone->base ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " invoking empty subrs\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case cff_op_return: - FT_TRACE4(( " return (leaving level %d)\n", - decoder->zone - decoder->zones )); + FT_LOCAL_DEF( FT_Error ) + cff_get_glyph_data( TT_Face face, + FT_UInt glyph_index, + FT_Byte** pointer, + FT_ULong* length ) + { +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( face->root.internal->incremental_interface ) + { + FT_Data data; + FT_Error error = + face->root.internal->incremental_interface->funcs->get_glyph_data( + face->root.internal->incremental_interface->object, + glyph_index, &data ); - if ( decoder->zone <= decoder->zones ) - { - FT_ERROR(( "cff_decoder_parse_charstrings:" - " unexpected return\n" )); - goto Syntax_Error; - } - decoder->zone--; - zone = decoder->zone; - ip = zone->cursor; - limit = zone->limit; - break; + *pointer = (FT_Byte*)data.pointer; + *length = (FT_ULong)data.length; - default: - FT_ERROR(( "Unimplemented opcode: %d", ip[-1] )); + return error; + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - if ( ip[-1] == 12 ) - FT_ERROR(( " %d", ip[0] )); - FT_ERROR(( "\n" )); + { + CFF_Font cff = (CFF_Font)(face->extra.data); - return FT_THROW( Unimplemented_Feature ); - } - decoder->top = args; + return cff_index_access_element( &cff->charstrings_index, glyph_index, + pointer, length ); + } + } - if ( decoder->top - stack >= CFF_MAX_OPERANDS ) - goto Stack_Overflow; - } /* general operator processing */ + FT_LOCAL_DEF( void ) + cff_free_glyph_data( TT_Face face, + FT_Byte** pointer, + FT_ULong length ) + { +#ifndef FT_CONFIG_OPTION_INCREMENTAL + FT_UNUSED( length ); +#endif - } /* while ip < limit */ +#ifdef FT_CONFIG_OPTION_INCREMENTAL + /* For incremental fonts get the character data using the */ + /* callback function. */ + if ( face->root.internal->incremental_interface ) + { + FT_Data data; - FT_TRACE4(( "..end..\n\n" )); - Fail: - return error; + data.pointer = *pointer; + data.length = (FT_Int)length; - MM_Error: - FT_TRACE4(( "cff_decoder_parse_charstrings:" - " invalid opcode found in top DICT charstring\n")); - return FT_THROW( Invalid_File_Format ); + face->root.internal->incremental_interface->funcs->free_glyph_data( + face->root.internal->incremental_interface->object, &data ); + } + else +#endif /* FT_CONFIG_OPTION_INCREMENTAL */ - Syntax_Error: - FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" )); - return FT_THROW( Invalid_File_Format ); + { + CFF_Font cff = (CFF_Font)(face->extra.data); - Stack_Underflow: - FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" )); - return FT_THROW( Too_Few_Arguments ); - Stack_Overflow: - FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" )); - return FT_THROW( Stack_Overflow ); + cff_index_forget_element( &cff->charstrings_index, pointer ); + } } -#endif /* CFF_CONFIG_OPTION_OLD_ENGINE */ - /*************************************************************************/ /*************************************************************************/ @@ -2704,11 +142,14 @@ FT_Int glyph_index; CFF_Font cff = (CFF_Font)face->other; + PSAux_Service psaux = (PSAux_Service)face->psaux; + const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs; + *max_advance = 0; /* Initialize load decoder */ - cff_decoder_init( &decoder, face, 0, 0, 0, 0 ); + decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 ); decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; @@ -2727,12 +168,12 @@ &charstring, &charstring_len ); if ( !error ) { - error = cff_decoder_prepare( &decoder, size, glyph_index ); + error = decoder_funcs->prepare( &decoder, size, glyph_index ); if ( !error ) - error = cff_decoder_parse_charstrings( &decoder, - charstring, - charstring_len, - 0 ); + error = decoder_funcs->parse_charstrings_old( &decoder, + charstring, + charstring_len, + 0 ); cff_free_glyph_data( face, &charstring, &charstring_len ); } @@ -2758,10 +199,14 @@ { FT_Error error; CFF_Decoder decoder; + PS_Decoder psdecoder; TT_Face face = (TT_Face)glyph->root.face; FT_Bool hinting, scaled, force_scaling; CFF_Font cff = (CFF_Font)face->extra.data; + PSAux_Service psaux = (PSAux_Service)face->psaux; + const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs; + FT_Matrix font_matrix; FT_Vector font_offset; @@ -2951,7 +396,7 @@ { #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); #endif @@ -2959,8 +404,10 @@ FT_ULong charstring_len; - cff_decoder_init( &decoder, face, size, glyph, hinting, - FT_LOAD_TARGET_MODE( load_flags ) ); + decoder_funcs->init( &decoder, face, size, glyph, hinting, + FT_LOAD_TARGET_MODE( load_flags ), + cff_get_glyph_data, + cff_free_glyph_data ); /* this is for pure CFFs */ if ( load_flags & FT_LOAD_ADVANCE_ONLY ) @@ -2975,23 +422,25 @@ if ( error ) goto Glyph_Build_Finished; - error = cff_decoder_prepare( &decoder, size, glyph_index ); + error = decoder_funcs->prepare( &decoder, size, glyph_index ); if ( error ) goto Glyph_Build_Finished; #ifdef CFF_CONFIG_OPTION_OLD_ENGINE /* choose which CFF renderer to use */ - if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE ) - error = cff_decoder_parse_charstrings( &decoder, - charstring, - charstring_len, - 0 ); + if ( driver->hinting_engine == FT_HINTING_FREETYPE ) + error = decoder_funcs->parse_charstrings_old( &decoder, + charstring, + charstring_len, + 0 ); else #endif { - error = cf2_decoder_parse_charstrings( &decoder, - charstring, - charstring_len ); + psaux->ps_decoder_init( &psdecoder, &decoder, FALSE ); + + error = decoder_funcs->parse_charstrings( &psdecoder, + charstring, + charstring_len ); /* Adobe's engine uses 16.16 numbers everywhere; */ /* as a consequence, glyphs larger than 2000ppem get rejected */ @@ -3004,9 +453,9 @@ force_scaling = TRUE; glyph->hint = hinting; - error = cf2_decoder_parse_charstrings( &decoder, - charstring, - charstring_len ); + error = decoder_funcs->parse_charstrings( &psdecoder, + charstring, + charstring_len ); } } @@ -3044,7 +493,7 @@ Glyph_Build_Finished: /* save new glyph tables, if no error */ if ( !error ) - cff_builder_done( &decoder.builder ); + decoder.builder.funcs.done( &decoder.builder ); /* XXX: anything to do for broken glyph entry? */ } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h index 0fa93b43985..803f3974fc7 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,119 +22,11 @@ #include #include FT_FREETYPE_H -#include "cffobjs.h" +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H FT_BEGIN_HEADER - -#define CFF_MAX_OPERANDS 48 -#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */ - /* only 10 are allowed but there exist */ - /* fonts like `HiraKakuProN-W3.ttf' */ - /* (Hiragino Kaku Gothic ProN W3; */ - /* 8.2d6e1; 2014-12-19) that exceed */ - /* this limit */ -#define CFF_MAX_TRANS_ELEMENTS 32 - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_Builder */ - /* */ - /* */ - /* A structure used during glyph loading to store its outline. */ - /* */ - /* */ - /* memory :: The current memory object. */ - /* */ - /* face :: The current face object. */ - /* */ - /* glyph :: The current glyph slot. */ - /* */ - /* loader :: The current glyph loader. */ - /* */ - /* base :: The base glyph outline. */ - /* */ - /* current :: The current glyph outline. */ - /* */ - /* pos_x :: The horizontal translation (if composite glyph). */ - /* */ - /* pos_y :: The vertical translation (if composite glyph). */ - /* */ - /* left_bearing :: The left side bearing point. */ - /* */ - /* advance :: The horizontal advance vector. */ - /* */ - /* bbox :: Unused. */ - /* */ - /* path_begun :: A flag which indicates that a new path has begun. */ - /* */ - /* load_points :: If this flag is not set, no points are loaded. */ - /* */ - /* no_recurse :: Set but not used. */ - /* */ - /* metrics_only :: A boolean indicating that we only want to compute */ - /* the metrics of a given glyph, not load all of its */ - /* points. */ - /* */ - /* hints_funcs :: Auxiliary pointer for hinting. */ - /* */ - /* hints_globals :: Auxiliary pointer for hinting. */ - /* */ - typedef struct CFF_Builder_ - { - FT_Memory memory; - TT_Face face; - CFF_GlyphSlot glyph; - FT_GlyphLoader loader; - FT_Outline* base; - FT_Outline* current; - - FT_Pos pos_x; - FT_Pos pos_y; - - FT_Vector left_bearing; - FT_Vector advance; - - FT_BBox bbox; /* bounding box */ - FT_Bool path_begun; - FT_Bool load_points; - FT_Bool no_recurse; - - FT_Bool metrics_only; - - void* hints_funcs; /* hinter-specific */ - void* hints_globals; /* hinter-specific */ - - } CFF_Builder; - - - FT_LOCAL( FT_Error ) - cff_check_points( CFF_Builder* builder, - FT_Int count ); - - FT_LOCAL( void ) - cff_builder_add_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y, - FT_Byte flag ); - FT_LOCAL( FT_Error ) - cff_builder_add_point1( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ); - FT_LOCAL( FT_Error ) - cff_builder_start_point( CFF_Builder* builder, - FT_Pos x, - FT_Pos y ); - FT_LOCAL( void ) - cff_builder_close_contour( CFF_Builder* builder ); - - - FT_LOCAL( FT_Int ) - cff_lookup_glyph_by_stdcharcode( CFF_Font cff, - FT_Int charcode ); FT_LOCAL( FT_Error ) cff_get_glyph_data( TT_Face face, FT_UInt glyph_index, @@ -146,74 +38,6 @@ FT_BEGIN_HEADER FT_ULong length ); - /* execution context charstring zone */ - - typedef struct CFF_Decoder_Zone_ - { - FT_Byte* base; - FT_Byte* limit; - FT_Byte* cursor; - - } CFF_Decoder_Zone; - - - typedef struct CFF_Decoder_ - { - CFF_Builder builder; - CFF_Font cff; - - FT_Fixed stack[CFF_MAX_OPERANDS + 1]; - FT_Fixed* top; - - CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1]; - CFF_Decoder_Zone* zone; - - FT_Int flex_state; - FT_Int num_flex_vectors; - FT_Vector flex_vectors[7]; - - FT_Pos glyph_width; - FT_Pos nominal_width; - - FT_Bool read_width; - FT_Bool width_only; - FT_Int num_hints; - FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS]; - - FT_UInt num_locals; - FT_UInt num_globals; - - FT_Int locals_bias; - FT_Int globals_bias; - - FT_Byte** locals; - FT_Byte** globals; - - FT_Byte** glyph_names; /* for pure CFF fonts only */ - FT_UInt num_glyphs; /* number of glyphs in font */ - - FT_Render_Mode hint_mode; - - FT_Bool seac; - - CFF_SubFont current_subfont; /* for current glyph_index */ - - } CFF_Decoder; - - - FT_LOCAL( void ) - cff_decoder_init( CFF_Decoder* decoder, - TT_Face face, - CFF_Size size, - CFF_GlyphSlot slot, - FT_Bool hinting, - FT_Render_Mode hint_mode ); - - FT_LOCAL( FT_Error ) - cff_decoder_prepare( CFF_Decoder* decoder, - CFF_Size size, - FT_UInt glyph_index ); - #if 0 /* unused until we support pure CFF fonts */ /* Compute the maximum advance width of a font through quick parsing */ @@ -223,13 +47,6 @@ FT_BEGIN_HEADER #endif /* 0 */ -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - FT_LOCAL( FT_Error ) - cff_decoder_parse_charstrings( CFF_Decoder* decoder, - FT_Byte* charstring_base, - FT_ULong charstring_len, - FT_Bool in_dict ); -#endif FT_LOCAL( FT_Error ) cff_slot_load( CFF_GlyphSlot glyph, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c index 12420384af2..ba49793dc8a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c @@ -4,7 +4,7 @@ /* */ /* OpenType and CFF data/program tables loader (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,7 @@ #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include FT_TYPE1_TABLES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H @@ -1297,7 +1298,9 @@ if ( numOperands > count ) { - FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d args\n", count )); + FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n", + count, + count == 1 ? "" : "s" )); error = FT_THROW( Stack_Underflow ); goto Exit; @@ -1345,19 +1348,14 @@ for ( i = 0; i < numBlends; i++ ) { const FT_Int32* weight = &blend->BV[1]; - FT_Int32 sum; + FT_UInt32 sum; /* convert inputs to 16.16 fixed point */ - sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536; + sum = cff_parse_num( parser, &parser->stack[i + base] ) * 0x10000; for ( j = 1; j < blend->lenBV; j++ ) - sum = ADD_INT32( - sum, - FT_MulFix( - *weight++, - cff_parse_num( parser, - &parser->stack[delta++] ) * 65536 ) ); + sum += cff_parse_num( parser, &parser->stack[delta++] ) * *weight++; /* point parser stack to new value on blend_stack */ parser->stack[i + base] = subFont->blend_top; @@ -1367,10 +1365,10 @@ /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */ /* decode of this, which rounds to an integer. */ *subFont->blend_top++ = 255; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0xFF000000U ) >> 24; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0x00FF0000U ) >> 16; - *subFont->blend_top++ = ( (FT_UInt32)sum & 0x0000FF00U ) >> 8; - *subFont->blend_top++ = (FT_UInt32)sum & 0x000000FFU; + *subFont->blend_top++ = (FT_Byte)( sum >> 24 ); + *subFont->blend_top++ = (FT_Byte)( sum >> 16 ); + *subFont->blend_top++ = (FT_Byte)( sum >> 8 ); + *subFont->blend_top++ = (FT_Byte)sum; } /* leave only numBlends results on parser stack */ @@ -1558,13 +1556,13 @@ FT_UInt lenNDV, FT_Fixed* NDV ) { - if ( !blend->builtBV || - blend->lastVsindex != vsindex || - blend->lenNDV != lenNDV || - ( lenNDV && - memcmp( NDV, - blend->lastNDV, - lenNDV * sizeof ( *NDV ) ) != 0 ) ) + if ( !blend->builtBV || + blend->lastVsindex != vsindex || + blend->lenNDV != lenNDV || + ( lenNDV && + ft_memcmp( NDV, + blend->lastNDV, + lenNDV * sizeof ( *NDV ) ) != 0 ) ) { /* need to build blend vector */ return TRUE; @@ -1600,7 +1598,8 @@ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; - mm->done_blend( FT_FACE( face ) ); + if (mm) + mm->done_blend( FT_FACE( face ) ); } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -1945,18 +1944,6 @@ } - FT_LOCAL_DEF( FT_UInt32 ) - cff_random( FT_UInt32 r ) - { - /* a 32bit version of the `xorshift' algorithm */ - r ^= r << 13; - r ^= r >> 17; - r ^= r << 5; - - return r; - } - - /* There are 3 ways to call this function, distinguished by code. */ /* */ /* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */ @@ -1980,6 +1967,8 @@ CFF_FontRecDict top = &subfont->font_dict; CFF_Private priv = &subfont->private_dict; + PSAux_Service psaux = (PSAux_Service)face->psaux; + FT_Bool cff2 = FT_BOOL( code == CFF2_CODE_TOPDICT || code == CFF2_CODE_FONTDICT ); FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK @@ -2085,7 +2074,7 @@ */ if ( face->root.internal->random_seed == -1 ) { - CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face ); + PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face ); subfont->random = (FT_UInt32)driver->random_seed; @@ -2094,7 +2083,7 @@ do { driver->random_seed = - (FT_Int32)cff_random( (FT_UInt32)driver->random_seed ); + (FT_Int32)psaux->cff_random( (FT_UInt32)driver->random_seed ); } while ( driver->random_seed < 0 ); } @@ -2107,7 +2096,8 @@ do { face->root.internal->random_seed = - (FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed ); + (FT_Int32)psaux->cff_random( + (FT_UInt32)face->root.internal->random_seed ); } while ( face->root.internal->random_seed < 0 ); } @@ -2548,6 +2538,8 @@ font->cf2_instance.finalizer( font->cf2_instance.data ); FT_FREE( font->cf2_instance.data ); } + + FT_FREE( font->font_extra ); } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h index c745e8127b3..14d14e21122 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h @@ -4,7 +4,7 @@ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,9 +21,9 @@ #include -#include "cfftypes.h" +#include FT_INTERNAL_CFF_TYPES_H #include "cffparse.h" -#include "cffobjs.h" /* for CFF_Face */ +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H /* for CFF_Face */ FT_BEGIN_HEADER @@ -61,9 +61,6 @@ FT_BEGIN_HEADER FT_UInt cid ); - FT_LOCAL( FT_UInt32 ) - cff_random( FT_UInt32 r ); - FT_LOCAL( FT_Error ) cff_font_load( FT_Library library, FT_Stream stream, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c index 61613933ff7..a2d7aec65ef 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -25,13 +25,15 @@ #include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_SFNT_H -#include FT_CFF_DRIVER_H +#include FT_DRIVER_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT #include FT_MULTIPLE_MASTERS_H #include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_METRICS_VARIATIONS_H #endif +#include FT_INTERNAL_CFF_OBJECTS_TYPES_H #include "cffobjs.h" #include "cffload.h" #include "cffcmap.h" @@ -39,6 +41,9 @@ #include "cfferrs.h" +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_SERVICE_CFF_TABLE_LOAD_H + /*************************************************************************/ /* */ @@ -408,7 +413,7 @@ remove_subset_prefix( FT_String* name ) { FT_Int32 idx = 0; - FT_Int32 length = (FT_Int32)strlen( name ) + 1; + FT_Int32 length = (FT_Int32)ft_strlen( name ) + 1; FT_Bool continue_search = 1; @@ -445,8 +450,8 @@ FT_Int32 family_name_length, style_name_length; - family_name_length = (FT_Int32)strlen( family_name ); - style_name_length = (FT_Int32)strlen( style_name ); + family_name_length = (FT_Int32)ft_strlen( family_name ); + style_name_length = (FT_Int32)ft_strlen( style_name ); if ( family_name_length > style_name_length ) { @@ -493,14 +498,16 @@ SFNT_Service sfnt; FT_Service_PsCMaps psnames; PSHinter_Service pshinter; + PSAux_Service psaux; + FT_Service_CFFLoad cffload; FT_Bool pure_cff = 1; FT_Bool cff2 = 0; FT_Bool sfnt_format = 0; FT_Library library = cffface->driver->root.library; - sfnt = (SFNT_Service)FT_Get_Module_Interface( - library, "sfnt" ); + sfnt = (SFNT_Service)FT_Get_Module_Interface( library, + "sfnt" ); if ( !sfnt ) { FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" )); @@ -510,8 +517,20 @@ FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); - pshinter = (PSHinter_Service)FT_Get_Module_Interface( - library, "pshinter" ); + pshinter = (PSHinter_Service)FT_Get_Module_Interface( library, + "pshinter" ); + + psaux = (PSAux_Service)FT_Get_Module_Interface( library, + "psaux" ); + if ( !psaux ) + { + FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" )); + error = FT_THROW( Missing_Module ); + goto Exit; + } + face->psaux = psaux; + + FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD ); FT_TRACE2(( "CFF driver\n" )); @@ -614,6 +633,7 @@ cff->pshinter = pshinter; cff->psnames = psnames; + cff->cffload = cffload; cffface->face_index = face_index & 0xFFFF; @@ -690,50 +710,22 @@ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { - FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm; + FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var; - FT_Int instance_index = face_index >> 16; + FT_UInt instance_index = (FT_UInt)face_index >> 16; if ( FT_HAS_MULTIPLE_MASTERS( cffface ) && mm && instance_index > 0 ) { - FT_MM_Var* mm_var; - - - error = mm->get_mm_var( cffface, NULL ); + error = mm->set_instance( cffface, instance_index ); if ( error ) goto Exit; - mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var ); - - if ( mm_var->namedstyle ) - { - FT_Var_Named_Style* named_style; - FT_String* style_name; - - - /* in `face_index', the instance index starts with value 1 */ - named_style = mm_var->namedstyle + instance_index - 1; - error = sfnt->get_name( face, - (FT_UShort)named_style->strid, - &style_name ); - if ( error ) - goto Exit; - - /* set style name; if already set, replace it */ - if ( face->root.style_name ) - FT_FREE( face->root.style_name ); - face->root.style_name = style_name; - - /* finally, select the named instance */ - error = mm->set_var_design( cffface, - mm_var->num_axis, - named_style->coords ); - if ( error ) - goto Exit; - } + if ( var ) + var->metrics_adjust( cffface ); } } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ @@ -876,7 +868,8 @@ cffface->height = (FT_Short)( ( cffface->units_per_EM * 12 ) / 10 ); if ( cffface->height < cffface->ascender - cffface->descender ) - cffface->height = (FT_Short)( cffface->ascender - cffface->descender ); + cffface->height = (FT_Short)( cffface->ascender - + cffface->descender ); cffface->underline_position = (FT_Short)( dict->underline_position >> 16 ); @@ -884,27 +877,32 @@ (FT_Short)( dict->underline_thickness >> 16 ); /* retrieve font family & style name */ - cffface->family_name = cff_index_get_name( - cff, - (FT_UInt)( face_index & 0xFFFF ) ); + if ( dict->family_name ) + { + char* family_name; + + + family_name = cff_index_get_sid_string( cff, dict->family_name ); + if ( family_name ) + cffface->family_name = cff_strcpy( memory, family_name ); + } + + if ( !cffface->family_name ) + { + cffface->family_name = cff_index_get_name( + cff, + (FT_UInt)( face_index & 0xFFFF ) ); + if ( cffface->family_name ) + remove_subset_prefix( cffface->family_name ); + } + if ( cffface->family_name ) { char* full = cff_index_get_sid_string( cff, dict->full_name ); char* fullp = full; char* family = cffface->family_name; - char* family_name = NULL; - - remove_subset_prefix( cffface->family_name ); - - if ( dict->family_name ) - { - family_name = cff_index_get_sid_string( cff, - dict->family_name ); - if ( family_name ) - family = family_name; - } /* We try to extract the style name from the full name. */ /* We need to ignore spaces and dashes during the search. */ @@ -1159,16 +1157,16 @@ FT_LOCAL_DEF( FT_Error ) cff_driver_init( FT_Module module ) /* CFF_Driver */ { - CFF_Driver driver = (CFF_Driver)module; + PS_Driver driver = (PS_Driver)module; FT_UInt32 seed; /* set default property values, cf. `ftcffdrv.h' */ #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - driver->hinting_engine = FT_CFF_HINTING_FREETYPE; + driver->hinting_engine = FT_HINTING_FREETYPE; #else - driver->hinting_engine = FT_CFF_HINTING_ADOBE; + driver->hinting_engine = FT_HINTING_ADOBE; #endif driver->no_stem_darkening = TRUE; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h index 1dba694c532..616a25b3b59 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (specification). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,111 +21,11 @@ #include -#include FT_INTERNAL_OBJECTS_H -#include "cfftypes.h" -#include FT_INTERNAL_TRUETYPE_TYPES_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H -#include FT_INTERNAL_POSTSCRIPT_HINTS_H FT_BEGIN_HEADER - /*************************************************************************/ - /* */ - /* */ - /* CFF_Driver */ - /* */ - /* */ - /* A handle to an OpenType driver object. */ - /* */ - typedef struct CFF_DriverRec_* CFF_Driver; - - typedef TT_Face CFF_Face; - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_Size */ - /* */ - /* */ - /* A handle to an OpenType size object. */ - /* */ - typedef struct CFF_SizeRec_ - { - FT_SizeRec root; - FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */ - - } CFF_SizeRec, *CFF_Size; - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_GlyphSlot */ - /* */ - /* */ - /* A handle to an OpenType glyph slot object. */ - /* */ - typedef struct CFF_GlyphSlotRec_ - { - FT_GlyphSlotRec root; - - FT_Bool hint; - FT_Bool scaled; - - FT_Fixed x_scale; - FT_Fixed y_scale; - - } CFF_GlyphSlotRec, *CFF_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_Internal */ - /* */ - /* */ - /* The interface to the `internal' field of `FT_Size'. */ - /* */ - typedef struct CFF_InternalRec_ - { - PSH_Globals topfont; - PSH_Globals subfonts[CFF_MAX_CID_FONTS]; - - } CFF_InternalRec, *CFF_Internal; - - - /*************************************************************************/ - /* */ - /* Subglyph transformation record. */ - /* */ - typedef struct CFF_Transform_ - { - FT_Fixed xx, xy; /* transformation matrix coefficients */ - FT_Fixed yx, yy; - FT_F26Dot6 ox, oy; /* offsets */ - - } CFF_Transform; - - - /***********************************************************************/ - /* */ - /* CFF driver class. */ - /* */ - typedef struct CFF_DriverRec_ - { - FT_DriverRec root; - - FT_UInt hinting_engine; - FT_Bool no_stem_darkening; - FT_Int darken_params[8]; - FT_Int32 random_seed; - - } CFF_DriverRec; - - FT_LOCAL( FT_Error ) cff_size_init( FT_Size size ); /* CFF_Size */ @@ -171,10 +71,10 @@ FT_BEGIN_HEADER /* Driver functions */ /* */ FT_LOCAL( FT_Error ) - cff_driver_init( FT_Module module ); /* CFF_Driver */ + cff_driver_init( FT_Module module ); /* PS_Driver */ FT_LOCAL( void ) - cff_driver_done( FT_Module module ); /* CFF_Driver */ + cff_driver_done( FT_Module module ); /* PS_Driver */ FT_END_HEADER diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c index 9d7bf6d22c8..b9611cf548a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (body) */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,10 +21,10 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_CALC_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include "cfferrs.h" #include "cffpic.h" -#include "cffgload.h" #include "cffload.h" @@ -949,7 +949,9 @@ goto Exit; } - FT_TRACE4(( " %d values blended\n", numBlends )); + FT_TRACE4(( " %d value%s blended\n", + numBlends, + numBlends == 1 ? "" : "s" )); error = cff_blend_doBlend( subFont, parser, numBlends ); @@ -1299,9 +1301,14 @@ FT_Byte* start, FT_Byte* limit ) { +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + PSAux_Service psaux; +#endif + FT_Byte* p = start; FT_Error error = FT_Err_Ok; FT_Library library = parser->library; + FT_UNUSED( library ); @@ -1388,10 +1395,16 @@ cff_rec.top_font.font_dict.num_axes = parser->num_axes; decoder.cff = &cff_rec; - error = cff_decoder_parse_charstrings( &decoder, - charstring_base, - charstring_len, - 1 ); + psaux = (PSAux_Service)FT_Get_Module_Interface( library, "psaux" ); + if ( !psaux ) + { + FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" )); + error = FT_THROW( Missing_Module ); + goto Exit; + } + + error = psaux->cff_decoder_funcs->parse_charstrings_old( + &decoder, charstring_base, charstring_len, 1 ); /* Now copy the stack data in the temporary decoder object, */ /* converting it back to charstring number representations */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h index 83d1bba45f2..8a8caeca446 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h @@ -4,7 +4,7 @@ /* */ /* CFF token stream parser (specification) */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,7 +21,7 @@ #include -#include "cfftypes.h" +#include FT_INTERNAL_CFF_TYPES_H #include FT_INTERNAL_OBJECTS_H diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c index 4e9ba12b3fe..08b74c7cf20 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h index 5db39cd6272..8ba4203a8de 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h @@ -4,7 +4,7 @@ /* */ /* The FreeType position independent code services for cff module. */ /* */ -/* Copyright 2009-2017 by */ +/* Copyright 2009-2018 by */ /* Oran Agra and Mickey Gabel. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,7 +22,6 @@ #include FT_INTERNAL_PIC_H - #ifndef FT_CONFIG_OPTION_PIC #define CFF_SERVICE_PS_INFO_GET cff_service_ps_info @@ -34,6 +33,7 @@ #define CFF_SERVICES_GET cff_services #define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters #define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations +#define CFF_SERVICE_CFF_LOAD_GET cff_service_cff_load #define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec #define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec #define CFF_FIELD_HANDLERS_GET cff_field_handlers @@ -65,6 +65,7 @@ FT_BEGIN_HEADER FT_Service_PropertiesRec cff_service_properties; FT_Service_MultiMastersRec cff_service_multi_masters; FT_Service_MetricsVariationsRec cff_service_metrics_variations; + FT_Service_CFFLoadRec cff_service_cff_load; FT_CMap_ClassRec cff_cmap_encoding_class_rec; FT_CMap_ClassRec cff_cmap_unicode_class_rec; @@ -92,6 +93,8 @@ FT_BEGIN_HEADER ( GET_PIC( library )->cff_service_multi_masters ) #define CFF_SERVICE_METRICS_VAR_GET \ ( GET_PIC( library )->cff_service_metrics_variations ) +#define CFF_SERVICE_CFF_LOAD_GET \ + ( GET_PIC( library )->cff_service_cff_load ) #define CFF_CMAP_ENCODING_CLASS_REC_GET \ ( GET_PIC( library )->cff_cmap_encoding_class_rec ) #define CFF_CMAP_UNICODE_CLASS_REC_GET \ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h index 3222e933f1d..fec1ca20bde 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h @@ -4,7 +4,7 @@ /* */ /* CFF token definitions (specification only). */ /* */ -/* Copyright 1996-2017 by */ +/* Copyright 1996-2018 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h deleted file mode 100644 index 74f569f08b8..00000000000 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h +++ /dev/null @@ -1,405 +0,0 @@ -/***************************************************************************/ -/* */ -/* cfftypes.h */ -/* */ -/* Basic OpenType/CFF type definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2017 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef CFFTYPES_H_ -#define CFFTYPES_H_ - - -#include -#include FT_FREETYPE_H -#include FT_TYPE1_TABLES_H -#include FT_INTERNAL_SERVICE_H -#include FT_SERVICE_POSTSCRIPT_CMAPS_H -#include FT_INTERNAL_POSTSCRIPT_HINTS_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* */ - /* CFF_IndexRec */ - /* */ - /* */ - /* A structure used to model a CFF Index table. */ - /* */ - /* */ - /* stream :: The source input stream. */ - /* */ - /* start :: The position of the first index byte in the */ - /* input stream. */ - /* */ - /* count :: The number of elements in the index. */ - /* */ - /* off_size :: The size in bytes of object offsets in index. */ - /* */ - /* data_offset :: The position of first data byte in the index's */ - /* bytes. */ - /* */ - /* data_size :: The size of the data table in this index. */ - /* */ - /* offsets :: A table of element offsets in the index. Must be */ - /* loaded explicitly. */ - /* */ - /* bytes :: If the index is loaded in memory, its bytes. */ - /* */ - typedef struct CFF_IndexRec_ - { - FT_Stream stream; - FT_ULong start; - FT_UInt hdr_size; - FT_UInt count; - FT_Byte off_size; - FT_ULong data_offset; - FT_ULong data_size; - - FT_ULong* offsets; - FT_Byte* bytes; - - } CFF_IndexRec, *CFF_Index; - - - typedef struct CFF_EncodingRec_ - { - FT_UInt format; - FT_ULong offset; - - FT_UInt count; - FT_UShort sids [256]; /* avoid dynamic allocations */ - FT_UShort codes[256]; - - } CFF_EncodingRec, *CFF_Encoding; - - - typedef struct CFF_CharsetRec_ - { - - FT_UInt format; - FT_ULong offset; - - FT_UShort* sids; - FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ - /* for CID-keyed fonts */ - FT_UInt max_cid; - FT_UInt num_glyphs; - - } CFF_CharsetRec, *CFF_Charset; - - - /* cf. similar fields in file `ttgxvar.h' from the `truetype' module */ - - typedef struct CFF_VarData_ - { -#if 0 - FT_UInt itemCount; /* not used; always zero */ - FT_UInt shortDeltaCount; /* not used; always zero */ -#endif - - FT_UInt regionIdxCount; /* number of region indexes */ - FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */ - /* these index `varRegionList' */ - } CFF_VarData; - - - /* contribution of one axis to a region */ - typedef struct CFF_AxisCoords_ - { - FT_Fixed startCoord; - FT_Fixed peakCoord; /* zero peak means no effect (factor = 1) */ - FT_Fixed endCoord; - - } CFF_AxisCoords; - - - typedef struct CFF_VarRegion_ - { - CFF_AxisCoords* axisList; /* array of axisCount records */ - - } CFF_VarRegion; - - - typedef struct CFF_VStoreRec_ - { - FT_UInt dataCount; - CFF_VarData* varData; /* array of dataCount records */ - /* vsindex indexes this array */ - FT_UShort axisCount; - FT_UInt regionCount; /* total number of regions defined */ - CFF_VarRegion* varRegionList; - - } CFF_VStoreRec, *CFF_VStore; - - - /* forward reference */ - typedef struct CFF_FontRec_* CFF_Font; - - - /* This object manages one cached blend vector. */ - /* */ - /* There is a BlendRec for Private DICT parsing in each subfont */ - /* and a BlendRec for charstrings in CF2_Font instance data. */ - /* A cached BV may be used across DICTs or Charstrings if inputs */ - /* have not changed. */ - /* */ - /* `usedBV' is reset at the start of each parse or charstring. */ - /* vsindex cannot be changed after a BV is used. */ - /* */ - /* Note: NDV is long (32/64 bit), while BV is 16.16 (FT_Int32). */ - typedef struct CFF_BlendRec_ - { - FT_Bool builtBV; /* blendV has been built */ - FT_Bool usedBV; /* blendV has been used */ - CFF_Font font; /* top level font struct */ - FT_UInt lastVsindex; /* last vsindex used */ - FT_UInt lenNDV; /* normDV length (aka numAxes) */ - FT_Fixed* lastNDV; /* last NDV used */ - FT_UInt lenBV; /* BlendV length (aka numMasters) */ - FT_Int32* BV; /* current blendV (per DICT/glyph) */ - - } CFF_BlendRec, *CFF_Blend; - - - typedef struct CFF_FontRecDictRec_ - { - FT_UInt version; - FT_UInt notice; - FT_UInt copyright; - FT_UInt full_name; - FT_UInt family_name; - FT_UInt weight; - FT_Bool is_fixed_pitch; - FT_Fixed italic_angle; - FT_Fixed underline_position; - FT_Fixed underline_thickness; - FT_Int paint_type; - FT_Int charstring_type; - FT_Matrix font_matrix; - FT_Bool has_font_matrix; - FT_ULong units_per_em; /* temporarily used as scaling value also */ - FT_Vector font_offset; - FT_ULong unique_id; - FT_BBox font_bbox; - FT_Pos stroke_width; - FT_ULong charset_offset; - FT_ULong encoding_offset; - FT_ULong charstrings_offset; - FT_ULong private_offset; - FT_ULong private_size; - FT_Long synthetic_base; - FT_UInt embedded_postscript; - - /* these should only be used for the top-level font dictionary */ - FT_UInt cid_registry; - FT_UInt cid_ordering; - FT_Long cid_supplement; - - FT_Long cid_font_version; - FT_Long cid_font_revision; - FT_Long cid_font_type; - FT_ULong cid_count; - FT_ULong cid_uid_base; - FT_ULong cid_fd_array_offset; - FT_ULong cid_fd_select_offset; - FT_UInt cid_font_name; - - /* the next fields come from the data of the deprecated */ - /* `MultipleMaster' operator; they are needed to parse the (also */ - /* deprecated) `blend' operator in Type 2 charstrings */ - FT_UShort num_designs; - FT_UShort num_axes; - - /* fields for CFF2 */ - FT_ULong vstore_offset; - FT_UInt maxstack; - - } CFF_FontRecDictRec, *CFF_FontRecDict; - - - /* forward reference */ - typedef struct CFF_SubFontRec_* CFF_SubFont; - - - typedef struct CFF_PrivateRec_ - { - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Pos blue_values[14]; - FT_Pos other_blues[10]; - FT_Pos family_blues[14]; - FT_Pos family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Pos blue_shift; - FT_Pos blue_fuzz; - FT_Pos standard_width; - FT_Pos standard_height; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Pos snap_widths[13]; - FT_Pos snap_heights[13]; - FT_Bool force_bold; - FT_Fixed force_bold_threshold; - FT_Int lenIV; - FT_Int language_group; - FT_Fixed expansion_factor; - FT_Long initial_random_seed; - FT_ULong local_subrs_offset; - FT_Pos default_width; - FT_Pos nominal_width; - - /* fields for CFF2 */ - FT_UInt vsindex; - CFF_SubFont subfont; - - } CFF_PrivateRec, *CFF_Private; - - - typedef struct CFF_FDSelectRec_ - { - FT_Byte format; - FT_UInt range_count; - - /* that's the table, taken from the file `as is' */ - FT_Byte* data; - FT_UInt data_size; - - /* small cache for format 3 only */ - FT_UInt cache_first; - FT_UInt cache_count; - FT_Byte cache_fd; - - } CFF_FDSelectRec, *CFF_FDSelect; - - - /* A SubFont packs a font dict and a private dict together. They are */ - /* needed to support CID-keyed CFF fonts. */ - typedef struct CFF_SubFontRec_ - { - CFF_FontRecDictRec font_dict; - CFF_PrivateRec private_dict; - - /* fields for CFF2 */ - CFF_BlendRec blend; /* current blend vector */ - FT_UInt lenNDV; /* current length NDV or zero */ - FT_Fixed* NDV; /* ptr to current NDV or NULL */ - - /* `blend_stack' is a writable buffer to hold blend results. */ - /* This buffer is to the side of the normal cff parser stack; */ - /* `cff_parse_blend' and `cff_blend_doBlend' push blend results here. */ - /* The normal stack then points to these values instead of the DICT */ - /* because all other operators in Private DICT clear the stack. */ - /* `blend_stack' could be cleared at each operator other than blend. */ - /* Blended values are stored as 5-byte fixed point values. */ - - FT_Byte* blend_stack; /* base of stack allocation */ - FT_Byte* blend_top; /* first empty slot */ - FT_UInt blend_used; /* number of bytes in use */ - FT_UInt blend_alloc; /* number of bytes allocated */ - - CFF_IndexRec local_subrs_index; - FT_Byte** local_subrs; /* array of pointers */ - /* into Local Subrs INDEX data */ - - FT_UInt32 random; - - } CFF_SubFontRec; - - -#define CFF_MAX_CID_FONTS 256 - - - typedef struct CFF_FontRec_ - { - FT_Library library; - FT_Stream stream; - FT_Memory memory; /* TODO: take this from stream->memory? */ - FT_ULong base_offset; /* offset to start of CFF */ - FT_UInt num_faces; - FT_UInt num_glyphs; - - FT_Byte version_major; - FT_Byte version_minor; - FT_Byte header_size; - - FT_UInt top_dict_length; /* cff2 only */ - - FT_Bool cff2; - - CFF_IndexRec name_index; - CFF_IndexRec top_dict_index; - CFF_IndexRec global_subrs_index; - - CFF_EncodingRec encoding; - CFF_CharsetRec charset; - - CFF_IndexRec charstrings_index; - CFF_IndexRec font_dict_index; - CFF_IndexRec private_index; - CFF_IndexRec local_subrs_index; - - FT_String* font_name; - - /* array of pointers into Global Subrs INDEX data */ - FT_Byte** global_subrs; - - /* array of pointers into String INDEX data stored at string_pool */ - FT_UInt num_strings; - FT_Byte** strings; - FT_Byte* string_pool; - FT_ULong string_pool_size; - - CFF_SubFontRec top_font; - FT_UInt num_subfonts; - CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; - - CFF_FDSelectRec fd_select; - - /* interface to PostScript hinter */ - PSHinter_Service pshinter; - - /* interface to Postscript Names service */ - FT_Service_PsCMaps psnames; - - /* since version 2.3.0 */ - PS_FontInfoRec* font_info; /* font info dictionary */ - - /* since version 2.3.6 */ - FT_String* registry; - FT_String* ordering; - - /* since version 2.4.12 */ - FT_Generic cf2_instance; - - /* since version 2.7.1 */ - CFF_VStoreRec vstore; /* parsed vstore structure */ - - } CFF_FontRec; - - -FT_END_HEADER - -#endif /* CFFTYPES_H_ */ - - -/* END */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk index 2975aeed8c7..8013d5dcab0 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk index 86840bfe3c9..bce672927ec 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk +++ b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk @@ -3,7 +3,7 @@ # -# Copyright 1996-2017 by +# Copyright 1996-2018 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, @@ -32,27 +32,14 @@ CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \ $(CFF_DIR)/cffload.c \ $(CFF_DIR)/cffobjs.c \ $(CFF_DIR)/cffparse.c \ - $(CFF_DIR)/cffpic.c \ - $(CFF_DIR)/cf2arrst.c \ - $(CFF_DIR)/cf2blues.c \ - $(CFF_DIR)/cf2error.c \ - $(CFF_DIR)/cf2font.c \ - $(CFF_DIR)/cf2ft.c \ - $(CFF_DIR)/cf2hints.c \ - $(CFF_DIR)/cf2intrp.c \ - $(CFF_DIR)/cf2read.c \ - $(CFF_DIR)/cf2stack.c + $(CFF_DIR)/cffpic.c # CFF driver headers # CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \ $(CFF_DIR)/cfferrs.h \ - $(CFF_DIR)/cfftoken.h \ - $(CFF_DIR)/cfftypes.h \ - $(CFF_DIR)/cf2fixed.h \ - $(CFF_DIR)/cf2glue.h \ - $(CFF_DIR)/cf2types.h + $(CFF_DIR)/cfftoken.h # CFF driver object(s) -- cgit v1.2.3