code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222
values | license stringclasses 20
values | size int64 1 1.05M |
|---|---|---|---|---|---|
/***************************************************************************/
/* */
/* pshrec.c */
/* */
/* FreeType PostScript hints recorder (body). */
/* */
/* Copyright 2001-2004, 2007, 2009, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include "pshrec.h"
#include "pshalgo.h"
#include "pshnterr.h"
#undef FT_COMPONENT
#define FT_COMPONENT trace_pshrec
#ifdef DEBUG_HINTER
PS_Hints ps_debug_hints = 0;
int ps_debug_no_horz_hints = 0;
int ps_debug_no_vert_hints = 0;
#endif
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS_HINT MANAGEMENT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* destroy hints table */
static void
ps_hint_table_done( PS_Hint_Table table,
FT_Memory memory )
{
FT_FREE( table->hints );
table->num_hints = 0;
table->max_hints = 0;
}
/* ensure that a table can contain "count" elements */
static FT_Error
ps_hint_table_ensure( PS_Hint_Table table,
FT_UInt count,
FT_Memory memory )
{
FT_UInt old_max = table->max_hints;
FT_UInt new_max = count;
FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
{
/* try to grow the table */
new_max = FT_PAD_CEIL( new_max, 8 );
if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) )
table->max_hints = new_max;
}
return error;
}
static FT_Error
ps_hint_table_alloc( PS_Hint_Table table,
FT_Memory memory,
PS_Hint *ahint )
{
FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Hint hint = 0;
count = table->num_hints;
count++;
if ( count >= table->max_hints )
{
error = ps_hint_table_ensure( table, count, memory );
if ( error )
goto Exit;
}
hint = table->hints + count - 1;
hint->pos = 0;
hint->len = 0;
hint->flags = 0;
table->num_hints = count;
Exit:
*ahint = hint;
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS_MASK MANAGEMENT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* destroy mask */
static void
ps_mask_done( PS_Mask mask,
FT_Memory memory )
{
FT_FREE( mask->bytes );
mask->num_bits = 0;
mask->max_bits = 0;
mask->end_point = 0;
}
/* ensure that a mask can contain "count" bits */
static FT_Error
ps_mask_ensure( PS_Mask mask,
FT_UInt count,
FT_Memory memory )
{
FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
FT_UInt new_max = ( count + 7 ) >> 3;
FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 8 );
if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
mask->max_bits = new_max * 8;
}
return error;
}
/* test a bit value in a given mask */
static FT_Int
ps_mask_test_bit( PS_Mask mask,
FT_Int idx )
{
if ( (FT_UInt)idx >= mask->num_bits )
return 0;
return mask->bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
}
/* clear a given bit */
static void
ps_mask_clear_bit( PS_Mask mask,
FT_Int idx )
{
FT_Byte* p;
if ( (FT_UInt)idx >= mask->num_bits )
return;
p = mask->bytes + ( idx >> 3 );
p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
}
/* set a given bit, possibly grow the mask */
static FT_Error
ps_mask_set_bit( PS_Mask mask,
FT_Int idx,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Byte* p;
if ( idx < 0 )
goto Exit;
if ( (FT_UInt)idx >= mask->num_bits )
{
error = ps_mask_ensure( mask, idx + 1, memory );
if ( error )
goto Exit;
mask->num_bits = idx + 1;
}
p = mask->bytes + ( idx >> 3 );
p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( idx & 7 ) ) );
Exit:
return error;
}
/* destroy mask table */
static void
ps_mask_table_done( PS_Mask_Table table,
FT_Memory memory )
{
FT_UInt count = table->max_masks;
PS_Mask mask = table->masks;
for ( ; count > 0; count--, mask++ )
ps_mask_done( mask, memory );
FT_FREE( table->masks );
table->num_masks = 0;
table->max_masks = 0;
}
/* ensure that a mask table can contain "count" masks */
static FT_Error
ps_mask_table_ensure( PS_Mask_Table table,
FT_UInt count,
FT_Memory memory )
{
FT_UInt old_max = table->max_masks;
FT_UInt new_max = count;
FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 8 );
if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) )
table->max_masks = new_max;
}
return error;
}
/* allocate a new mask in a table */
static FT_Error
ps_mask_table_alloc( PS_Mask_Table table,
FT_Memory memory,
PS_Mask *amask )
{
FT_UInt count;
FT_Error error = FT_Err_Ok;
PS_Mask mask = 0;
count = table->num_masks;
count++;
if ( count > table->max_masks )
{
error = ps_mask_table_ensure( table, count, memory );
if ( error )
goto Exit;
}
mask = table->masks + count - 1;
mask->num_bits = 0;
mask->end_point = 0;
table->num_masks = count;
Exit:
*amask = mask;
return error;
}
/* return last hint mask in a table, create one if the table is empty */
static FT_Error
ps_mask_table_last( PS_Mask_Table table,
FT_Memory memory,
PS_Mask *amask )
{
FT_Error error = FT_Err_Ok;
FT_UInt count;
PS_Mask mask;
count = table->num_masks;
if ( count == 0 )
{
error = ps_mask_table_alloc( table, memory, &mask );
if ( error )
goto Exit;
}
else
mask = table->masks + count - 1;
Exit:
*amask = mask;
return error;
}
/* set a new mask to a given bit range */
static FT_Error
ps_mask_table_set_bits( PS_Mask_Table table,
const FT_Byte* source,
FT_UInt bit_pos,
FT_UInt bit_count,
FT_Memory memory )
{
FT_Error error;
PS_Mask mask;
error = ps_mask_table_last( table, memory, &mask );
if ( error )
goto Exit;
error = ps_mask_ensure( mask, bit_count, memory );
if ( error )
goto Exit;
mask->num_bits = bit_count;
/* now, copy bits */
{
FT_Byte* read = (FT_Byte*)source + ( bit_pos >> 3 );
FT_Int rmask = 0x80 >> ( bit_pos & 7 );
FT_Byte* write = mask->bytes;
FT_Int wmask = 0x80;
FT_Int val;
for ( ; bit_count > 0; bit_count-- )
{
val = write[0] & ~wmask;
if ( read[0] & rmask )
val |= wmask;
write[0] = (FT_Byte)val;
rmask >>= 1;
if ( rmask == 0 )
{
read++;
rmask = 0x80;
}
wmask >>= 1;
if ( wmask == 0 )
{
write++;
wmask = 0x80;
}
}
}
Exit:
return error;
}
/* test whether two masks in a table intersect */
static FT_Int
ps_mask_table_test_intersect( PS_Mask_Table table,
FT_Int index1,
FT_Int index2 )
{
PS_Mask mask1 = table->masks + index1;
PS_Mask mask2 = table->masks + index2;
FT_Byte* p1 = mask1->bytes;
FT_Byte* p2 = mask2->bytes;
FT_UInt count1 = mask1->num_bits;
FT_UInt count2 = mask2->num_bits;
FT_UInt count;
count = FT_MIN( count1, count2 );
for ( ; count >= 8; count -= 8 )
{
if ( p1[0] & p2[0] )
return 1;
p1++;
p2++;
}
if ( count == 0 )
return 0;
return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
}
/* merge two masks, used by ps_mask_table_merge_all */
static FT_Error
ps_mask_table_merge( PS_Mask_Table table,
FT_Int index1,
FT_Int index2,
FT_Memory memory )
{
FT_UInt temp;
FT_Error error = FT_Err_Ok;
/* swap index1 and index2 so that index1 < index2 */
if ( index1 > index2 )
{
temp = index1;
index1 = index2;
index2 = temp;
}
if ( index1 < index2 && index1 >= 0 && index2 < (FT_Int)table->num_masks )
{
/* we need to merge the bitsets of index1 and index2 with a */
/* simple union */
PS_Mask mask1 = table->masks + index1;
PS_Mask mask2 = table->masks + index2;
FT_UInt count1 = mask1->num_bits;
FT_UInt count2 = mask2->num_bits;
FT_Int delta;
if ( count2 > 0 )
{
FT_UInt pos;
FT_Byte* read;
FT_Byte* write;
/* if "count2" is greater than "count1", we need to grow the */
/* first bitset, and clear the highest bits */
if ( count2 > count1 )
{
error = ps_mask_ensure( mask1, count2, memory );
if ( error )
goto Exit;
for ( pos = count1; pos < count2; pos++ )
ps_mask_clear_bit( mask1, pos );
}
/* merge (unite) the bitsets */
read = mask2->bytes;
write = mask1->bytes;
pos = (FT_UInt)( ( count2 + 7 ) >> 3 );
for ( ; pos > 0; pos-- )
{
write[0] = (FT_Byte)( write[0] | read[0] );
write++;
read++;
}
}
/* Now, remove "mask2" from the list. We need to keep the masks */
/* sorted in order of importance, so move table elements. */
mask2->num_bits = 0;
mask2->end_point = 0;
delta = table->num_masks - 1 - index2; /* number of masks to move */
if ( delta > 0 )
{
/* move to end of table for reuse */
PS_MaskRec dummy = *mask2;
ft_memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
mask2[delta] = dummy;
}
table->num_masks--;
}
else
FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
index1, index2 ));
Exit:
return error;
}
/* Try to merge all masks in a given table. This is used to merge */
/* all counter masks into independent counter "paths". */
/* */
static FT_Error
ps_mask_table_merge_all( PS_Mask_Table table,
FT_Memory memory )
{
FT_Int index1, index2;
FT_Error error = FT_Err_Ok;
for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
{
for ( index2 = index1 - 1; index2 >= 0; index2-- )
{
if ( ps_mask_table_test_intersect( table, index1, index2 ) )
{
error = ps_mask_table_merge( table, index2, index1, memory );
if ( error )
goto Exit;
break;
}
}
}
Exit:
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS_DIMENSION MANAGEMENT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* finalize a given dimension */
static void
ps_dimension_done( PS_Dimension dimension,
FT_Memory memory )
{
ps_mask_table_done( &dimension->counters, memory );
ps_mask_table_done( &dimension->masks, memory );
ps_hint_table_done( &dimension->hints, memory );
}
/* initialize a given dimension */
static void
ps_dimension_init( PS_Dimension dimension )
{
dimension->hints.num_hints = 0;
dimension->masks.num_masks = 0;
dimension->counters.num_masks = 0;
}
#if 0
/* set a bit at a given index in the current hint mask */
static FT_Error
ps_dimension_set_mask_bit( PS_Dimension dim,
FT_UInt idx,
FT_Memory memory )
{
PS_Mask mask;
FT_Error error = FT_Err_Ok;
/* get last hint mask */
error = ps_mask_table_last( &dim->masks, memory, &mask );
if ( error )
goto Exit;
error = ps_mask_set_bit( mask, idx, memory );
Exit:
return error;
}
#endif
/* set the end point in a mask, called from "End" & "Reset" methods */
static void
ps_dimension_end_mask( PS_Dimension dim,
FT_UInt end_point )
{
FT_UInt count = dim->masks.num_masks;
if ( count > 0 )
{
PS_Mask mask = dim->masks.masks + count - 1;
mask->end_point = end_point;
}
}
/* set the end point in the current mask, then create a new empty one */
/* (called by "Reset" method) */
static FT_Error
ps_dimension_reset_mask( PS_Dimension dim,
FT_UInt end_point,
FT_Memory memory )
{
PS_Mask mask;
/* end current mask */
ps_dimension_end_mask( dim, end_point );
/* allocate new one */
return ps_mask_table_alloc( &dim->masks, memory, &mask );
}
/* set a new mask, called from the "T2Stem" method */
static FT_Error
ps_dimension_set_mask_bits( PS_Dimension dim,
const FT_Byte* source,
FT_UInt source_pos,
FT_UInt source_bits,
FT_UInt end_point,
FT_Memory memory )
{
FT_Error error;
/* reset current mask, if any */
error = ps_dimension_reset_mask( dim, end_point, memory );
if ( error )
goto Exit;
/* set bits in new mask */
error = ps_mask_table_set_bits( &dim->masks, source,
source_pos, source_bits, memory );
Exit:
return error;
}
/* add a new single stem (called from "T1Stem" method) */
static FT_Error
ps_dimension_add_t1stem( PS_Dimension dim,
FT_Int pos,
FT_Int len,
FT_Memory memory,
FT_Int *aindex )
{
FT_Error error = FT_Err_Ok;
FT_UInt flags = 0;
/* detect ghost stem */
if ( len < 0 )
{
flags |= PS_HINT_FLAG_GHOST;
if ( len == -21 )
{
flags |= PS_HINT_FLAG_BOTTOM;
pos += len;
}
len = 0;
}
if ( aindex )
*aindex = -1;
/* now, lookup stem in the current hints table */
{
PS_Mask mask;
FT_UInt idx;
FT_UInt max = dim->hints.num_hints;
PS_Hint hint = dim->hints.hints;
for ( idx = 0; idx < max; idx++, hint++ )
{
if ( hint->pos == pos && hint->len == len )
break;
}
/* we need to create a new hint in the table */
if ( idx >= max )
{
error = ps_hint_table_alloc( &dim->hints, memory, &hint );
if ( error )
goto Exit;
hint->pos = pos;
hint->len = len;
hint->flags = flags;
}
/* now, store the hint in the current mask */
error = ps_mask_table_last( &dim->masks, memory, &mask );
if ( error )
goto Exit;
error = ps_mask_set_bit( mask, idx, memory );
if ( error )
goto Exit;
if ( aindex )
*aindex = (FT_Int)idx;
}
Exit:
return error;
}
/* add a "hstem3/vstem3" counter to our dimension table */
static FT_Error
ps_dimension_add_counter( PS_Dimension dim,
FT_Int hint1,
FT_Int hint2,
FT_Int hint3,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_UInt count = dim->counters.num_masks;
PS_Mask counter = dim->counters.masks;
/* try to find an existing counter mask that already uses */
/* one of these stems here */
for ( ; count > 0; count--, counter++ )
{
if ( ps_mask_test_bit( counter, hint1 ) ||
ps_mask_test_bit( counter, hint2 ) ||
ps_mask_test_bit( counter, hint3 ) )
break;
}
/* create a new counter when needed */
if ( count == 0 )
{
error = ps_mask_table_alloc( &dim->counters, memory, &counter );
if ( error )
goto Exit;
}
/* now, set the bits for our hints in the counter mask */
error = ps_mask_set_bit( counter, hint1, memory );
if ( error )
goto Exit;
error = ps_mask_set_bit( counter, hint2, memory );
if ( error )
goto Exit;
error = ps_mask_set_bit( counter, hint3, memory );
if ( error )
goto Exit;
Exit:
return error;
}
/* end of recording session for a given dimension */
static FT_Error
ps_dimension_end( PS_Dimension dim,
FT_UInt end_point,
FT_Memory memory )
{
/* end hint mask table */
ps_dimension_end_mask( dim, end_point );
/* merge all counter masks into independent "paths" */
return ps_mask_table_merge_all( &dim->counters, memory );
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS_RECORDER MANAGEMENT *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* destroy hints */
FT_LOCAL( void )
ps_hints_done( PS_Hints hints )
{
FT_Memory memory = hints->memory;
ps_dimension_done( &hints->dimension[0], memory );
ps_dimension_done( &hints->dimension[1], memory );
hints->error = FT_Err_Ok;
hints->memory = 0;
}
FT_LOCAL( FT_Error )
ps_hints_init( PS_Hints hints,
FT_Memory memory )
{
FT_MEM_ZERO( hints, sizeof ( *hints ) );
hints->memory = memory;
return FT_Err_Ok;
}
/* initialize a hints for a new session */
static void
ps_hints_open( PS_Hints hints,
PS_Hint_Type hint_type )
{
switch ( hint_type )
{
case PS_HINT_TYPE_1:
case PS_HINT_TYPE_2:
hints->error = FT_Err_Ok;
hints->hint_type = hint_type;
ps_dimension_init( &hints->dimension[0] );
ps_dimension_init( &hints->dimension[1] );
break;
default:
hints->error = FT_THROW( Invalid_Argument );
hints->hint_type = hint_type;
FT_TRACE0(( "ps_hints_open: invalid charstring type\n" ));
break;
}
}
/* add one or more stems to the current hints table */
static void
ps_hints_stem( PS_Hints hints,
FT_Int dimension,
FT_UInt count,
FT_Long* stems )
{
if ( !hints->error )
{
/* limit "dimension" to 0..1 */
if ( dimension < 0 || dimension > 1 )
{
FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
dimension ));
dimension = ( dimension != 0 );
}
/* record the stems in the current hints/masks table */
switch ( hints->hint_type )
{
case PS_HINT_TYPE_1: /* Type 1 "hstem" or "vstem" operator */
case PS_HINT_TYPE_2: /* Type 2 "hstem" or "vstem" operator */
{
PS_Dimension dim = &hints->dimension[dimension];
for ( ; count > 0; count--, stems += 2 )
{
FT_Error error;
FT_Memory memory = hints->memory;
error = ps_dimension_add_t1stem(
dim, (FT_Int)stems[0], (FT_Int)stems[1],
memory, NULL );
if ( error )
{
FT_ERROR(( "ps_hints_stem: could not add stem"
" (%d,%d) to hints table\n", stems[0], stems[1] ));
hints->error = error;
return;
}
}
break;
}
default:
FT_TRACE0(( "ps_hints_stem: called with invalid hint type (%d)\n",
hints->hint_type ));
break;
}
}
}
/* add one Type1 counter stem to the current hints table */
static void
ps_hints_t1stem3( PS_Hints hints,
FT_Int dimension,
FT_Fixed* stems )
{
FT_Error error = FT_Err_Ok;
if ( !hints->error )
{
PS_Dimension dim;
FT_Memory memory = hints->memory;
FT_Int count;
FT_Int idx[3];
/* limit "dimension" to 0..1 */
if ( dimension < 0 || dimension > 1 )
{
FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
dimension ));
dimension = ( dimension != 0 );
}
dim = &hints->dimension[dimension];
/* there must be 6 elements in the 'stem' array */
if ( hints->hint_type == PS_HINT_TYPE_1 )
{
/* add the three stems to our hints/masks table */
for ( count = 0; count < 3; count++, stems += 2 )
{
error = ps_dimension_add_t1stem( dim,
(FT_Int)FIXED_TO_INT( stems[0] ),
(FT_Int)FIXED_TO_INT( stems[1] ),
memory, &idx[count] );
if ( error )
goto Fail;
}
/* now, add the hints to the counters table */
error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
memory );
if ( error )
goto Fail;
}
else
{
FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
error = FT_THROW( Invalid_Argument );
goto Fail;
}
}
return;
Fail:
FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" ));
hints->error = error;
}
/* reset hints (only with Type 1 hints) */
static void
ps_hints_t1reset( PS_Hints hints,
FT_UInt end_point )
{
FT_Error error = FT_Err_Ok;
if ( !hints->error )
{
FT_Memory memory = hints->memory;
if ( hints->hint_type == PS_HINT_TYPE_1 )
{
error = ps_dimension_reset_mask( &hints->dimension[0],
end_point, memory );
if ( error )
goto Fail;
error = ps_dimension_reset_mask( &hints->dimension[1],
end_point, memory );
if ( error )
goto Fail;
}
else
{
/* invalid hint type */
error = FT_THROW( Invalid_Argument );
goto Fail;
}
}
return;
Fail:
hints->error = error;
}
/* Type2 "hintmask" operator, add a new hintmask to each direction */
static void
ps_hints_t2mask( PS_Hints hints,
FT_UInt end_point,
FT_UInt bit_count,
const FT_Byte* bytes )
{
FT_Error error;
if ( !hints->error )
{
PS_Dimension dim = hints->dimension;
FT_Memory memory = hints->memory;
FT_UInt count1 = dim[0].hints.num_hints;
FT_UInt count2 = dim[1].hints.num_hints;
/* check bit count; must be equal to current total hint count */
if ( bit_count != count1 + count2 )
{
FT_TRACE0(( "ps_hints_t2mask:"
" called with invalid bitcount %d (instead of %d)\n",
bit_count, count1 + count2 ));
/* simply ignore the operator */
return;
}
/* set-up new horizontal and vertical hint mask now */
error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
end_point, memory );
if ( error )
goto Fail;
error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
end_point, memory );
if ( error )
goto Fail;
}
return;
Fail:
hints->error = error;
}
static void
ps_hints_t2counter( PS_Hints hints,
FT_UInt bit_count,
const FT_Byte* bytes )
{
FT_Error error;
if ( !hints->error )
{
PS_Dimension dim = hints->dimension;
FT_Memory memory = hints->memory;
FT_UInt count1 = dim[0].hints.num_hints;
FT_UInt count2 = dim[1].hints.num_hints;
/* check bit count, must be equal to current total hint count */
if ( bit_count != count1 + count2 )
{
FT_TRACE0(( "ps_hints_t2counter:"
" called with invalid bitcount %d (instead of %d)\n",
bit_count, count1 + count2 ));
/* simply ignore the operator */
return;
}
/* set-up new horizontal and vertical hint mask now */
error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
0, memory );
if ( error )
goto Fail;
error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
0, memory );
if ( error )
goto Fail;
}
return;
Fail:
hints->error = error;
}
/* end recording session */
static FT_Error
ps_hints_close( PS_Hints hints,
FT_UInt end_point )
{
FT_Error error;
error = hints->error;
if ( !error )
{
FT_Memory memory = hints->memory;
PS_Dimension dim = hints->dimension;
error = ps_dimension_end( &dim[0], end_point, memory );
if ( !error )
{
error = ps_dimension_end( &dim[1], end_point, memory );
}
}
#ifdef DEBUG_HINTER
if ( !error )
ps_debug_hints = hints;
#endif
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** TYPE 1 HINTS RECORDING INTERFACE *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
t1_hints_open( T1_Hints hints )
{
ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_1 );
}
static void
t1_hints_stem( T1_Hints hints,
FT_Int dimension,
FT_Fixed* coords )
{
FT_Pos stems[2];
stems[0] = FIXED_TO_INT( coords[0] );
stems[1] = FIXED_TO_INT( coords[1] );
ps_hints_stem( (PS_Hints)hints, dimension, 1, stems );
}
FT_LOCAL_DEF( void )
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs )
{
FT_MEM_ZERO( (char*)funcs, sizeof ( *funcs ) );
funcs->open = (T1_Hints_OpenFunc) t1_hints_open;
funcs->close = (T1_Hints_CloseFunc) ps_hints_close;
funcs->stem = (T1_Hints_SetStemFunc) t1_hints_stem;
funcs->stem3 = (T1_Hints_SetStem3Func)ps_hints_t1stem3;
funcs->reset = (T1_Hints_ResetFunc) ps_hints_t1reset;
funcs->apply = (T1_Hints_ApplyFunc) ps_hints_apply;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** TYPE 2 HINTS RECORDING INTERFACE *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
static void
t2_hints_open( T2_Hints hints )
{
ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_2 );
}
static void
t2_hints_stems( T2_Hints hints,
FT_Int dimension,
FT_Int count,
FT_Fixed* coords )
{
FT_Pos stems[32], y, n;
FT_Int total = count;
y = 0;
while ( total > 0 )
{
/* determine number of stems to write */
count = total;
if ( count > 16 )
count = 16;
/* compute integer stem positions in font units */
for ( n = 0; n < count * 2; n++ )
{
y += coords[n];
stems[n] = FIXED_TO_INT( y );
}
/* compute lengths */
for ( n = 0; n < count * 2; n += 2 )
stems[n + 1] = stems[n + 1] - stems[n];
/* add them to the current dimension */
ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
total -= count;
}
}
FT_LOCAL_DEF( void )
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs )
{
FT_MEM_ZERO( funcs, sizeof ( *funcs ) );
funcs->open = (T2_Hints_OpenFunc) t2_hints_open;
funcs->close = (T2_Hints_CloseFunc) ps_hints_close;
funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems;
funcs->hintmask= (T2_Hints_MaskFunc) ps_hints_t2mask;
funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter;
funcs->apply = (T2_Hints_ApplyFunc) ps_hints_apply;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/pshinter/pshrec.c | C | apache-2.0 | 32,322 |
/***************************************************************************/
/* */
/* pshrec.h */
/* */
/* Postscript (Type1/Type2) hints recorder (specification). */
/* */
/* Copyright 2001, 2002, 2003, 2006, 2008 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. */
/* */
/***************************************************************************/
/**************************************************************************/
/* */
/* The functions defined here are called from the Type 1, CID and CFF */
/* font drivers to record the hints of a given character/glyph. */
/* */
/* The hints are recorded in a unified format, and are later processed */
/* by the `optimizer' and `fitter' to adjust the outlines to the pixel */
/* grid. */
/* */
/**************************************************************************/
#ifndef __PSHREC_H__
#define __PSHREC_H__
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "pshglob.h"
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** GLYPH HINTS RECORDER INTERNALS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* handle to hint record */
typedef struct PS_HintRec_* PS_Hint;
/* hint types */
typedef enum PS_Hint_Type_
{
PS_HINT_TYPE_1 = 1,
PS_HINT_TYPE_2 = 2
} PS_Hint_Type;
/* hint flags */
typedef enum PS_Hint_Flags_
{
PS_HINT_FLAG_GHOST = 1,
PS_HINT_FLAG_BOTTOM = 2
} PS_Hint_Flags;
/* hint descriptor */
typedef struct PS_HintRec_
{
FT_Int pos;
FT_Int len;
FT_UInt flags;
} PS_HintRec;
#define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE )
#define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST )
#define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM )
/* hints table descriptor */
typedef struct PS_Hint_TableRec_
{
FT_UInt num_hints;
FT_UInt max_hints;
PS_Hint hints;
} PS_Hint_TableRec, *PS_Hint_Table;
/* hint and counter mask descriptor */
typedef struct PS_MaskRec_
{
FT_UInt num_bits;
FT_UInt max_bits;
FT_Byte* bytes;
FT_UInt end_point;
} PS_MaskRec, *PS_Mask;
/* masks and counters table descriptor */
typedef struct PS_Mask_TableRec_
{
FT_UInt num_masks;
FT_UInt max_masks;
PS_Mask masks;
} PS_Mask_TableRec, *PS_Mask_Table;
/* dimension-specific hints descriptor */
typedef struct PS_DimensionRec_
{
PS_Hint_TableRec hints;
PS_Mask_TableRec masks;
PS_Mask_TableRec counters;
} PS_DimensionRec, *PS_Dimension;
/* glyph hints descriptor */
/* dimension 0 => X coordinates + vertical hints/stems */
/* dimension 1 => Y coordinates + horizontal hints/stems */
typedef struct PS_HintsRec_
{
FT_Memory memory;
FT_Error error;
FT_UInt32 magic;
PS_Hint_Type hint_type;
PS_DimensionRec dimension[2];
} PS_HintsRec, *PS_Hints;
/* */
/* initialize hints recorder */
FT_LOCAL( FT_Error )
ps_hints_init( PS_Hints hints,
FT_Memory memory );
/* finalize hints recorder */
FT_LOCAL( void )
ps_hints_done( PS_Hints hints );
/* initialize Type1 hints recorder interface */
FT_LOCAL( void )
t1_hints_funcs_init( T1_Hints_FuncsRec* funcs );
/* initialize Type2 hints recorder interface */
FT_LOCAL( void )
t2_hints_funcs_init( T2_Hints_FuncsRec* funcs );
#ifdef DEBUG_HINTER
extern PS_Hints ps_debug_hints;
extern int ps_debug_no_horz_hints;
extern int ps_debug_no_vert_hints;
#endif
/* */
FT_END_HEADER
#endif /* __PS_HINTER_RECORD_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/pshinter/pshrec.h | C | apache-2.0 | 5,283 |
#
# FreeType 2 PSHinter driver configuration rules
#
# Copyright 2001, 2003, 2011 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.
# PSHINTER driver directory
#
PSHINTER_DIR := $(SRC_DIR)/pshinter
# compilation flags for the driver
#
PSHINTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSHINTER_DIR))
# PSHINTER driver sources (i.e., C files)
#
PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshalgo.c \
$(PSHINTER_DIR)/pshglob.c \
$(PSHINTER_DIR)/pshmod.c \
$(PSHINTER_DIR)/pshpic.c \
$(PSHINTER_DIR)/pshrec.c
# PSHINTER driver headers
#
PSHINTER_DRV_H := $(PSHINTER_DRV_SRC:%c=%h) \
$(PSHINTER_DIR)/pshnterr.h
# PSHINTER driver object(s)
#
# PSHINTER_DRV_OBJ_M is used during `multi' builds.
# PSHINTER_DRV_OBJ_S is used during `single' builds.
#
PSHINTER_DRV_OBJ_M := $(PSHINTER_DRV_SRC:$(PSHINTER_DIR)/%.c=$(OBJ_DIR)/%.$O)
PSHINTER_DRV_OBJ_S := $(OBJ_DIR)/pshinter.$O
# PSHINTER driver source file for single build
#
PSHINTER_DRV_SRC_S := $(PSHINTER_DIR)/pshinter.c
# PSHINTER driver - single object
#
$(PSHINTER_DRV_OBJ_S): $(PSHINTER_DRV_SRC_S) $(PSHINTER_DRV_SRC) \
$(FREETYPE_H) $(PSHINTER_DRV_H)
$(PSHINTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PSHINTER_DRV_SRC_S))
# PSHINTER driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(PSHINTER_DIR)/%.c $(FREETYPE_H) $(PSHINTER_DRV_H)
$(PSHINTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(PSHINTER_DRV_OBJ_S)
DRV_OBJS_M += $(PSHINTER_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/pshinter/rules.mk | Makefile | apache-2.0 | 1,913 |
#
# FreeType 2 PSnames module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += PSNAMES_MODULE
define PSNAMES_MODULE
$(OPEN_DRIVER) FT_Module_Class, psnames_module_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)psnames $(ECHO_DRIVER_DESC)Postscript & Unicode Glyph name handling$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/psnames/module.mk | Makefile | apache-2.0 | 676 |
/***************************************************************************/
/* */
/* psmodule.c */
/* */
/* PSNames module implementation (body). */
/* */
/* Copyright 1996-2003, 2005-2008, 2012, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include "psmodule.h"
#include "pstables.h"
#include "psnamerr.h"
#include "pspic.h"
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
#define VARIANT_BIT 0x80000000UL
#define BASE_GLYPH( code ) ( (FT_UInt32)( (code) & ~VARIANT_BIT ) )
/* Return the Unicode value corresponding to a given glyph. Note that */
/* we do deal with glyph variants by detecting a non-initial dot in */
/* the name, as in `A.swash' or `e.final'; in this case, the */
/* VARIANT_BIT is set in the return value. */
/* */
static FT_UInt32
ps_unicode_value( const char* glyph_name )
{
/* If the name begins with `uni', then the glyph name may be a */
/* hard-coded unicode character code. */
if ( glyph_name[0] == 'u' &&
glyph_name[1] == 'n' &&
glyph_name[2] == 'i' )
{
/* determine whether the next four characters following are */
/* hexadecimal. */
/* XXX: Add code to deal with ligatures, i.e. glyph names like */
/* `uniXXXXYYYYZZZZ'... */
FT_Int count;
FT_UInt32 value = 0;
const char* p = glyph_name + 3;
for ( count = 4; count > 0; count--, p++ )
{
char c = *p;
unsigned int d;
d = (unsigned char)c - '0';
if ( d >= 10 )
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
d = 16;
else
d += 10;
}
/* Exit if a non-uppercase hexadecimal character was found */
/* -- this also catches character codes below `0' since such */
/* negative numbers cast to `unsigned int' are far too big. */
if ( d >= 16 )
break;
value = ( value << 4 ) + d;
}
/* there must be exactly four hex digits */
if ( count == 0 )
{
if ( *p == '\0' )
return value;
if ( *p == '.' )
return (FT_UInt32)( value | VARIANT_BIT );
}
}
/* If the name begins with `u', followed by four to six uppercase */
/* hexadecimal digits, it is a hard-coded unicode character code. */
if ( glyph_name[0] == 'u' )
{
FT_Int count;
FT_UInt32 value = 0;
const char* p = glyph_name + 1;
for ( count = 6; count > 0; count--, p++ )
{
char c = *p;
unsigned int d;
d = (unsigned char)c - '0';
if ( d >= 10 )
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
d = 16;
else
d += 10;
}
if ( d >= 16 )
break;
value = ( value << 4 ) + d;
}
if ( count <= 2 )
{
if ( *p == '\0' )
return value;
if ( *p == '.' )
return (FT_UInt32)( value | VARIANT_BIT );
}
}
/* Look for a non-initial dot in the glyph name in order to */
/* find variants like `A.swash', `e.final', etc. */
{
const char* p = glyph_name;
const char* dot = NULL;
for ( ; *p; p++ )
{
if ( *p == '.' && p > glyph_name )
{
dot = p;
break;
}
}
/* now look up the glyph in the Adobe Glyph List */
if ( !dot )
return (FT_UInt32)ft_get_adobe_glyph_index( glyph_name, p );
else
return (FT_UInt32)( ft_get_adobe_glyph_index( glyph_name, dot ) |
VARIANT_BIT );
}
}
/* ft_qsort callback to sort the unicode map */
FT_CALLBACK_DEF( int )
compare_uni_maps( const void* a,
const void* b )
{
PS_UniMap* map1 = (PS_UniMap*)a;
PS_UniMap* map2 = (PS_UniMap*)b;
FT_UInt32 unicode1 = BASE_GLYPH( map1->unicode );
FT_UInt32 unicode2 = BASE_GLYPH( map2->unicode );
/* sort base glyphs before glyph variants */
if ( unicode1 == unicode2 )
{
if ( map1->unicode > map2->unicode )
return 1;
else if ( map1->unicode < map2->unicode )
return -1;
else
return 0;
}
else
{
if ( unicode1 > unicode2 )
return 1;
else if ( unicode1 < unicode2 )
return -1;
else
return 0;
}
}
/* support for extra glyphs not handled (well) in AGL; */
/* we add extra mappings for them if necessary */
#define EXTRA_GLYPH_LIST_SIZE 10
static const FT_UInt32 ft_extra_glyph_unicodes[EXTRA_GLYPH_LIST_SIZE] =
{
/* WGL 4 */
0x0394,
0x03A9,
0x2215,
0x00AD,
0x02C9,
0x03BC,
0x2219,
0x00A0,
/* Romanian */
0x021A,
0x021B
};
static const char ft_extra_glyph_names[] =
{
'D','e','l','t','a',0,
'O','m','e','g','a',0,
'f','r','a','c','t','i','o','n',0,
'h','y','p','h','e','n',0,
'm','a','c','r','o','n',0,
'm','u',0,
'p','e','r','i','o','d','c','e','n','t','e','r','e','d',0,
's','p','a','c','e',0,
'T','c','o','m','m','a','a','c','c','e','n','t',0,
't','c','o','m','m','a','a','c','c','e','n','t',0
};
static const FT_Int
ft_extra_glyph_name_offsets[EXTRA_GLYPH_LIST_SIZE] =
{
0,
6,
12,
21,
28,
35,
38,
53,
59,
72
};
static void
ps_check_extra_glyph_name( const char* gname,
FT_UInt glyph,
FT_UInt* extra_glyphs,
FT_UInt *states )
{
FT_UInt n;
for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
{
if ( ft_strcmp( ft_extra_glyph_names +
ft_extra_glyph_name_offsets[n], gname ) == 0 )
{
if ( states[n] == 0 )
{
/* mark this extra glyph as a candidate for the cmap */
states[n] = 1;
extra_glyphs[n] = glyph;
}
return;
}
}
}
static void
ps_check_extra_glyph_unicode( FT_UInt32 uni_char,
FT_UInt *states )
{
FT_UInt n;
for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
{
if ( uni_char == ft_extra_glyph_unicodes[n] )
{
/* disable this extra glyph from being added to the cmap */
states[n] = 2;
return;
}
}
}
/* Build a table that maps Unicode values to glyph indices. */
static FT_Error
ps_unicodes_init( FT_Memory memory,
PS_Unicodes table,
FT_UInt num_glyphs,
PS_GetGlyphNameFunc get_glyph_name,
PS_FreeGlyphNameFunc free_glyph_name,
FT_Pointer glyph_data )
{
FT_Error error;
FT_UInt extra_glyph_list_states[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FT_UInt extra_glyphs[EXTRA_GLYPH_LIST_SIZE];
/* we first allocate the table */
table->num_maps = 0;
table->maps = 0;
if ( !FT_NEW_ARRAY( table->maps, num_glyphs + EXTRA_GLYPH_LIST_SIZE ) )
{
FT_UInt n;
FT_UInt count;
PS_UniMap* map;
FT_UInt32 uni_char;
map = table->maps;
for ( n = 0; n < num_glyphs; n++ )
{
const char* gname = get_glyph_name( glyph_data, n );
if ( gname )
{
ps_check_extra_glyph_name( gname, n,
extra_glyphs, extra_glyph_list_states );
uni_char = ps_unicode_value( gname );
if ( BASE_GLYPH( uni_char ) != 0 )
{
ps_check_extra_glyph_unicode( uni_char,
extra_glyph_list_states );
map->unicode = uni_char;
map->glyph_index = n;
map++;
}
if ( free_glyph_name )
free_glyph_name( glyph_data, gname );
}
}
for ( n = 0; n < EXTRA_GLYPH_LIST_SIZE; n++ )
{
if ( extra_glyph_list_states[n] == 1 )
{
/* This glyph name has an additional representation. */
/* Add it to the cmap. */
map->unicode = ft_extra_glyph_unicodes[n];
map->glyph_index = extra_glyphs[n];
map++;
}
}
/* now compress the table a bit */
count = (FT_UInt)( map - table->maps );
if ( count == 0 )
{
/* No unicode chars here! */
FT_FREE( table->maps );
if ( !error )
error = FT_THROW( No_Unicode_Glyph_Name );
}
else
{
/* Reallocate if the number of used entries is much smaller. */
if ( count < num_glyphs / 2 )
{
(void)FT_RENEW_ARRAY( table->maps, num_glyphs, count );
error = FT_Err_Ok;
}
/* Sort the table in increasing order of unicode values, */
/* taking care of glyph variants. */
ft_qsort( table->maps, count, sizeof ( PS_UniMap ),
compare_uni_maps );
}
table->num_maps = count;
}
return error;
}
static FT_UInt
ps_unicodes_char_index( PS_Unicodes table,
FT_UInt32 unicode )
{
PS_UniMap *min, *max, *mid, *result = NULL;
/* Perform a binary search on the table. */
min = table->maps;
max = min + table->num_maps - 1;
while ( min <= max )
{
FT_UInt32 base_glyph;
mid = min + ( ( max - min ) >> 1 );
if ( mid->unicode == unicode )
{
result = mid;
break;
}
base_glyph = BASE_GLYPH( mid->unicode );
if ( base_glyph == unicode )
result = mid; /* remember match but continue search for base glyph */
if ( min == max )
break;
if ( base_glyph < unicode )
min = mid + 1;
else
max = mid - 1;
}
if ( result )
return result->glyph_index;
else
return 0;
}
static FT_UInt32
ps_unicodes_char_next( PS_Unicodes table,
FT_UInt32 *unicode )
{
FT_UInt result = 0;
FT_UInt32 char_code = *unicode + 1;
{
FT_UInt min = 0;
FT_UInt max = table->num_maps;
FT_UInt mid;
PS_UniMap* map;
FT_UInt32 base_glyph;
while ( min < max )
{
mid = min + ( ( max - min ) >> 1 );
map = table->maps + mid;
if ( map->unicode == char_code )
{
result = map->glyph_index;
goto Exit;
}
base_glyph = BASE_GLYPH( map->unicode );
if ( base_glyph == char_code )
result = map->glyph_index;
if ( base_glyph < char_code )
min = mid + 1;
else
max = mid;
}
if ( result )
goto Exit; /* we have a variant glyph */
/* we didn't find it; check whether we have a map just above it */
char_code = 0;
if ( min < table->num_maps )
{
map = table->maps + min;
result = map->glyph_index;
char_code = BASE_GLYPH( map->unicode );
}
}
Exit:
*unicode = char_code;
return result;
}
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
static const char*
ps_get_macintosh_name( FT_UInt name_index )
{
if ( name_index >= FT_NUM_MAC_NAMES )
name_index = 0;
return ft_standard_glyph_names + ft_mac_names[name_index];
}
static const char*
ps_get_standard_strings( FT_UInt sid )
{
if ( sid >= FT_NUM_SID_NAMES )
return 0;
return ft_standard_glyph_names + ft_sid_names[sid];
}
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
(PS_Unicode_ValueFunc) ps_unicode_value,
(PS_Unicodes_InitFunc) ps_unicodes_init,
(PS_Unicodes_CharIndexFunc)ps_unicodes_char_index,
(PS_Unicodes_CharNextFunc) ps_unicodes_char_next,
(PS_Macintosh_NameFunc) ps_get_macintosh_name,
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
t1_standard_encoding,
t1_expert_encoding )
#else
FT_DEFINE_SERVICE_PSCMAPSREC(
pscmaps_interface,
NULL,
NULL,
NULL,
NULL,
(PS_Macintosh_NameFunc) ps_get_macintosh_name,
(PS_Adobe_Std_StringsFunc) ps_get_standard_strings,
t1_standard_encoding,
t1_expert_encoding )
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
FT_DEFINE_SERVICEDESCREC1(
pscmaps_services,
FT_SERVICE_ID_POSTSCRIPT_CMAPS, &PSCMAPS_INTERFACE_GET )
static FT_Pointer
psnames_get_service( FT_Module module,
const char* service_id )
{
/* PSCMAPS_SERVICES_GET derefers `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
FT_Library library;
if ( !module )
return NULL;
library = module->library;
if ( !library )
return NULL;
#else
FT_UNUSED( module );
#endif
return ft_service_list_lookup( PSCMAPS_SERVICES_GET, service_id );
}
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
#ifndef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
#define PUT_PS_NAMES_SERVICE( a ) NULL
#else
#define PUT_PS_NAMES_SERVICE( a ) a
#endif
FT_DEFINE_MODULE(
psnames_module_class,
0, /* this is not a font driver, nor a renderer */
sizeof ( FT_ModuleRec ),
"psnames", /* driver name */
0x10000L, /* driver version */
0x20000L, /* driver requires FreeType 2 or above */
PUT_PS_NAMES_SERVICE(
(void*)&PSCMAPS_INTERFACE_GET ), /* module specific interface */
(FT_Module_Constructor)NULL,
(FT_Module_Destructor) NULL,
(FT_Module_Requester) PUT_PS_NAMES_SERVICE( psnames_get_service ) )
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/psmodule.c | C | apache-2.0 | 15,220 |
/***************************************************************************/
/* */
/* psmodule.h */
/* */
/* High-level PSNames module interface (specification). */
/* */
/* Copyright 1996-2001 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 __PSMODULE_H__
#define __PSMODULE_H__
#include <ft2build.h>
#include FT_MODULE_H
FT_BEGIN_HEADER
FT_DECLARE_MODULE( psnames_module_class )
FT_END_HEADER
#endif /* __PSMODULE_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/psmodule.h | C | apache-2.0 | 1,462 |
/***************************************************************************/
/* */
/* psnamerr.h */
/* */
/* PS names module error codes (specification only). */
/* */
/* Copyright 2001, 2012 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the PS names module error enumeration */
/* constants. */
/* */
/*************************************************************************/
#ifndef __PSNAMERR_H__
#define __PSNAMERR_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX PSnames_Err_
#define FT_ERR_BASE FT_Mod_Err_PSnames
#include FT_ERRORS_H
#endif /* __PSNAMERR_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/psnamerr.h | C | apache-2.0 | 1,981 |
/***************************************************************************/
/* */
/* psnames.c */
/* */
/* FreeType PSNames module component (body only). */
/* */
/* Copyright 1996-2001 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "pspic.c"
#include "psmodule.c"
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/psnames.c | C | apache-2.0 | 1,363 |
/***************************************************************************/
/* */
/* pspic.c */
/* */
/* The FreeType position independent code services for psnames module. */
/* */
/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "pspic.h"
#include "psnamerr.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from psmodule.c */
FT_Error
FT_Create_Class_pscmaps_services( FT_Library library,
FT_ServiceDescRec** output_class );
void
FT_Destroy_Class_pscmaps_services( FT_Library library,
FT_ServiceDescRec* clazz );
void
FT_Init_Class_pscmaps_interface( FT_Library library,
FT_Service_PsCMapsRec* clazz );
void
psnames_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->psnames )
{
PSModulePIC* container = (PSModulePIC*)pic_container->psnames;
if ( container->pscmaps_services )
FT_Destroy_Class_pscmaps_services( library,
container->pscmaps_services );
container->pscmaps_services = NULL;
FT_FREE( container );
pic_container->psnames = NULL;
}
}
FT_Error
psnames_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
PSModulePIC* container = NULL;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->psnames = container;
/* initialize pointer table - */
/* this is how the module usually expects this data */
error = FT_Create_Class_pscmaps_services(
library, &container->pscmaps_services );
if ( error )
goto Exit;
FT_Init_Class_pscmaps_interface( library,
&container->pscmaps_interface );
Exit:
if ( error )
psnames_module_class_pic_free( library );
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/pspic.c | C | apache-2.0 | 3,524 |
/***************************************************************************/
/* */
/* pspic.h */
/* */
/* The FreeType position independent code services for psnames module. */
/* */
/* Copyright 2009, 2012 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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 __PSPIC_H__
#define __PSPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define PSCMAPS_SERVICES_GET pscmaps_services
#define PSCMAPS_INTERFACE_GET pscmaps_interface
#else /* FT_CONFIG_OPTION_PIC */
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
typedef struct PSModulePIC_
{
FT_ServiceDescRec* pscmaps_services;
FT_Service_PsCMapsRec pscmaps_interface;
} PSModulePIC;
#define GET_PIC( lib ) \
( (PSModulePIC*)((lib)->pic_container.psnames) )
#define PSCMAPS_SERVICES_GET ( GET_PIC( library )->pscmaps_services )
#define PSCMAPS_INTERFACE_GET ( GET_PIC( library )->pscmaps_interface )
/* see pspic.c for the implementation */
void
psnames_module_class_pic_free( FT_Library library );
FT_Error
psnames_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __PSPIC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/pspic.h | C | apache-2.0 | 2,222 |
/***************************************************************************/
/* */
/* pstables.h */
/* */
/* PostScript glyph names. */
/* */
/* Copyright 2005, 2008, 2011 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. */
/* */
/***************************************************************************/
/* This file has been generated automatically -- do not edit! */
static const char ft_standard_glyph_names[3696] =
{
'.','n','u','l','l', 0,
'n','o','n','m','a','r','k','i','n','g','r','e','t','u','r','n', 0,
'n','o','t','e','q','u','a','l', 0,
'i','n','f','i','n','i','t','y', 0,
'l','e','s','s','e','q','u','a','l', 0,
'g','r','e','a','t','e','r','e','q','u','a','l', 0,
'p','a','r','t','i','a','l','d','i','f','f', 0,
's','u','m','m','a','t','i','o','n', 0,
'p','r','o','d','u','c','t', 0,
'p','i', 0,
'i','n','t','e','g','r','a','l', 0,
'O','m','e','g','a', 0,
'r','a','d','i','c','a','l', 0,
'a','p','p','r','o','x','e','q','u','a','l', 0,
'D','e','l','t','a', 0,
'n','o','n','b','r','e','a','k','i','n','g','s','p','a','c','e', 0,
'l','o','z','e','n','g','e', 0,
'a','p','p','l','e', 0,
'f','r','a','n','c', 0,
'G','b','r','e','v','e', 0,
'g','b','r','e','v','e', 0,
'I','d','o','t','a','c','c','e','n','t', 0,
'S','c','e','d','i','l','l','a', 0,
's','c','e','d','i','l','l','a', 0,
'C','a','c','u','t','e', 0,
'c','a','c','u','t','e', 0,
'C','c','a','r','o','n', 0,
'c','c','a','r','o','n', 0,
'd','c','r','o','a','t', 0,
'.','n','o','t','d','e','f', 0,
's','p','a','c','e', 0,
'e','x','c','l','a','m', 0,
'q','u','o','t','e','d','b','l', 0,
'n','u','m','b','e','r','s','i','g','n', 0,
'd','o','l','l','a','r', 0,
'p','e','r','c','e','n','t', 0,
'a','m','p','e','r','s','a','n','d', 0,
'q','u','o','t','e','r','i','g','h','t', 0,
'p','a','r','e','n','l','e','f','t', 0,
'p','a','r','e','n','r','i','g','h','t', 0,
'a','s','t','e','r','i','s','k', 0,
'p','l','u','s', 0,
'c','o','m','m','a', 0,
'h','y','p','h','e','n', 0,
'p','e','r','i','o','d', 0,
's','l','a','s','h', 0,
'z','e','r','o', 0,
'o','n','e', 0,
't','w','o', 0,
't','h','r','e','e', 0,
'f','o','u','r', 0,
'f','i','v','e', 0,
's','i','x', 0,
's','e','v','e','n', 0,
'e','i','g','h','t', 0,
'n','i','n','e', 0,
'c','o','l','o','n', 0,
's','e','m','i','c','o','l','o','n', 0,
'l','e','s','s', 0,
'e','q','u','a','l', 0,
'g','r','e','a','t','e','r', 0,
'q','u','e','s','t','i','o','n', 0,
'a','t', 0,
'A', 0,
'B', 0,
'C', 0,
'D', 0,
'E', 0,
'F', 0,
'G', 0,
'H', 0,
'I', 0,
'J', 0,
'K', 0,
'L', 0,
'M', 0,
'N', 0,
'O', 0,
'P', 0,
'Q', 0,
'R', 0,
'S', 0,
'T', 0,
'U', 0,
'V', 0,
'W', 0,
'X', 0,
'Y', 0,
'Z', 0,
'b','r','a','c','k','e','t','l','e','f','t', 0,
'b','a','c','k','s','l','a','s','h', 0,
'b','r','a','c','k','e','t','r','i','g','h','t', 0,
'a','s','c','i','i','c','i','r','c','u','m', 0,
'u','n','d','e','r','s','c','o','r','e', 0,
'q','u','o','t','e','l','e','f','t', 0,
'a', 0,
'b', 0,
'c', 0,
'd', 0,
'e', 0,
'f', 0,
'g', 0,
'h', 0,
'i', 0,
'j', 0,
'k', 0,
'l', 0,
'm', 0,
'n', 0,
'o', 0,
'p', 0,
'q', 0,
'r', 0,
's', 0,
't', 0,
'u', 0,
'v', 0,
'w', 0,
'x', 0,
'y', 0,
'z', 0,
'b','r','a','c','e','l','e','f','t', 0,
'b','a','r', 0,
'b','r','a','c','e','r','i','g','h','t', 0,
'a','s','c','i','i','t','i','l','d','e', 0,
'e','x','c','l','a','m','d','o','w','n', 0,
'c','e','n','t', 0,
's','t','e','r','l','i','n','g', 0,
'f','r','a','c','t','i','o','n', 0,
'y','e','n', 0,
'f','l','o','r','i','n', 0,
's','e','c','t','i','o','n', 0,
'c','u','r','r','e','n','c','y', 0,
'q','u','o','t','e','s','i','n','g','l','e', 0,
'q','u','o','t','e','d','b','l','l','e','f','t', 0,
'g','u','i','l','l','e','m','o','t','l','e','f','t', 0,
'g','u','i','l','s','i','n','g','l','l','e','f','t', 0,
'g','u','i','l','s','i','n','g','l','r','i','g','h','t', 0,
'f','i', 0,
'f','l', 0,
'e','n','d','a','s','h', 0,
'd','a','g','g','e','r', 0,
'd','a','g','g','e','r','d','b','l', 0,
'p','e','r','i','o','d','c','e','n','t','e','r','e','d', 0,
'p','a','r','a','g','r','a','p','h', 0,
'b','u','l','l','e','t', 0,
'q','u','o','t','e','s','i','n','g','l','b','a','s','e', 0,
'q','u','o','t','e','d','b','l','b','a','s','e', 0,
'q','u','o','t','e','d','b','l','r','i','g','h','t', 0,
'g','u','i','l','l','e','m','o','t','r','i','g','h','t', 0,
'e','l','l','i','p','s','i','s', 0,
'p','e','r','t','h','o','u','s','a','n','d', 0,
'q','u','e','s','t','i','o','n','d','o','w','n', 0,
'g','r','a','v','e', 0,
'a','c','u','t','e', 0,
'c','i','r','c','u','m','f','l','e','x', 0,
't','i','l','d','e', 0,
'm','a','c','r','o','n', 0,
'b','r','e','v','e', 0,
'd','o','t','a','c','c','e','n','t', 0,
'd','i','e','r','e','s','i','s', 0,
'r','i','n','g', 0,
'c','e','d','i','l','l','a', 0,
'h','u','n','g','a','r','u','m','l','a','u','t', 0,
'o','g','o','n','e','k', 0,
'c','a','r','o','n', 0,
'e','m','d','a','s','h', 0,
'A','E', 0,
'o','r','d','f','e','m','i','n','i','n','e', 0,
'L','s','l','a','s','h', 0,
'O','s','l','a','s','h', 0,
'O','E', 0,
'o','r','d','m','a','s','c','u','l','i','n','e', 0,
'a','e', 0,
'd','o','t','l','e','s','s','i', 0,
'l','s','l','a','s','h', 0,
'o','s','l','a','s','h', 0,
'o','e', 0,
'g','e','r','m','a','n','d','b','l','s', 0,
'o','n','e','s','u','p','e','r','i','o','r', 0,
'l','o','g','i','c','a','l','n','o','t', 0,
'm','u', 0,
't','r','a','d','e','m','a','r','k', 0,
'E','t','h', 0,
'o','n','e','h','a','l','f', 0,
'p','l','u','s','m','i','n','u','s', 0,
'T','h','o','r','n', 0,
'o','n','e','q','u','a','r','t','e','r', 0,
'd','i','v','i','d','e', 0,
'b','r','o','k','e','n','b','a','r', 0,
'd','e','g','r','e','e', 0,
't','h','o','r','n', 0,
't','h','r','e','e','q','u','a','r','t','e','r','s', 0,
't','w','o','s','u','p','e','r','i','o','r', 0,
'r','e','g','i','s','t','e','r','e','d', 0,
'm','i','n','u','s', 0,
'e','t','h', 0,
'm','u','l','t','i','p','l','y', 0,
't','h','r','e','e','s','u','p','e','r','i','o','r', 0,
'c','o','p','y','r','i','g','h','t', 0,
'A','a','c','u','t','e', 0,
'A','c','i','r','c','u','m','f','l','e','x', 0,
'A','d','i','e','r','e','s','i','s', 0,
'A','g','r','a','v','e', 0,
'A','r','i','n','g', 0,
'A','t','i','l','d','e', 0,
'C','c','e','d','i','l','l','a', 0,
'E','a','c','u','t','e', 0,
'E','c','i','r','c','u','m','f','l','e','x', 0,
'E','d','i','e','r','e','s','i','s', 0,
'E','g','r','a','v','e', 0,
'I','a','c','u','t','e', 0,
'I','c','i','r','c','u','m','f','l','e','x', 0,
'I','d','i','e','r','e','s','i','s', 0,
'I','g','r','a','v','e', 0,
'N','t','i','l','d','e', 0,
'O','a','c','u','t','e', 0,
'O','c','i','r','c','u','m','f','l','e','x', 0,
'O','d','i','e','r','e','s','i','s', 0,
'O','g','r','a','v','e', 0,
'O','t','i','l','d','e', 0,
'S','c','a','r','o','n', 0,
'U','a','c','u','t','e', 0,
'U','c','i','r','c','u','m','f','l','e','x', 0,
'U','d','i','e','r','e','s','i','s', 0,
'U','g','r','a','v','e', 0,
'Y','a','c','u','t','e', 0,
'Y','d','i','e','r','e','s','i','s', 0,
'Z','c','a','r','o','n', 0,
'a','a','c','u','t','e', 0,
'a','c','i','r','c','u','m','f','l','e','x', 0,
'a','d','i','e','r','e','s','i','s', 0,
'a','g','r','a','v','e', 0,
'a','r','i','n','g', 0,
'a','t','i','l','d','e', 0,
'c','c','e','d','i','l','l','a', 0,
'e','a','c','u','t','e', 0,
'e','c','i','r','c','u','m','f','l','e','x', 0,
'e','d','i','e','r','e','s','i','s', 0,
'e','g','r','a','v','e', 0,
'i','a','c','u','t','e', 0,
'i','c','i','r','c','u','m','f','l','e','x', 0,
'i','d','i','e','r','e','s','i','s', 0,
'i','g','r','a','v','e', 0,
'n','t','i','l','d','e', 0,
'o','a','c','u','t','e', 0,
'o','c','i','r','c','u','m','f','l','e','x', 0,
'o','d','i','e','r','e','s','i','s', 0,
'o','g','r','a','v','e', 0,
'o','t','i','l','d','e', 0,
's','c','a','r','o','n', 0,
'u','a','c','u','t','e', 0,
'u','c','i','r','c','u','m','f','l','e','x', 0,
'u','d','i','e','r','e','s','i','s', 0,
'u','g','r','a','v','e', 0,
'y','a','c','u','t','e', 0,
'y','d','i','e','r','e','s','i','s', 0,
'z','c','a','r','o','n', 0,
'e','x','c','l','a','m','s','m','a','l','l', 0,
'H','u','n','g','a','r','u','m','l','a','u','t','s','m','a','l','l', 0,
'd','o','l','l','a','r','o','l','d','s','t','y','l','e', 0,
'd','o','l','l','a','r','s','u','p','e','r','i','o','r', 0,
'a','m','p','e','r','s','a','n','d','s','m','a','l','l', 0,
'A','c','u','t','e','s','m','a','l','l', 0,
'p','a','r','e','n','l','e','f','t','s','u','p','e','r','i','o','r', 0,
'p','a','r','e','n','r','i','g','h','t','s','u','p','e','r','i','o','r', 0,
't','w','o','d','o','t','e','n','l','e','a','d','e','r', 0,
'o','n','e','d','o','t','e','n','l','e','a','d','e','r', 0,
'z','e','r','o','o','l','d','s','t','y','l','e', 0,
'o','n','e','o','l','d','s','t','y','l','e', 0,
't','w','o','o','l','d','s','t','y','l','e', 0,
't','h','r','e','e','o','l','d','s','t','y','l','e', 0,
'f','o','u','r','o','l','d','s','t','y','l','e', 0,
'f','i','v','e','o','l','d','s','t','y','l','e', 0,
's','i','x','o','l','d','s','t','y','l','e', 0,
's','e','v','e','n','o','l','d','s','t','y','l','e', 0,
'e','i','g','h','t','o','l','d','s','t','y','l','e', 0,
'n','i','n','e','o','l','d','s','t','y','l','e', 0,
'c','o','m','m','a','s','u','p','e','r','i','o','r', 0,
't','h','r','e','e','q','u','a','r','t','e','r','s','e','m','d','a','s','h', 0,
'p','e','r','i','o','d','s','u','p','e','r','i','o','r', 0,
'q','u','e','s','t','i','o','n','s','m','a','l','l', 0,
'a','s','u','p','e','r','i','o','r', 0,
'b','s','u','p','e','r','i','o','r', 0,
'c','e','n','t','s','u','p','e','r','i','o','r', 0,
'd','s','u','p','e','r','i','o','r', 0,
'e','s','u','p','e','r','i','o','r', 0,
'i','s','u','p','e','r','i','o','r', 0,
'l','s','u','p','e','r','i','o','r', 0,
'm','s','u','p','e','r','i','o','r', 0,
'n','s','u','p','e','r','i','o','r', 0,
'o','s','u','p','e','r','i','o','r', 0,
'r','s','u','p','e','r','i','o','r', 0,
's','s','u','p','e','r','i','o','r', 0,
't','s','u','p','e','r','i','o','r', 0,
'f','f', 0,
'f','f','i', 0,
'f','f','l', 0,
'p','a','r','e','n','l','e','f','t','i','n','f','e','r','i','o','r', 0,
'p','a','r','e','n','r','i','g','h','t','i','n','f','e','r','i','o','r', 0,
'C','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'h','y','p','h','e','n','s','u','p','e','r','i','o','r', 0,
'G','r','a','v','e','s','m','a','l','l', 0,
'A','s','m','a','l','l', 0,
'B','s','m','a','l','l', 0,
'C','s','m','a','l','l', 0,
'D','s','m','a','l','l', 0,
'E','s','m','a','l','l', 0,
'F','s','m','a','l','l', 0,
'G','s','m','a','l','l', 0,
'H','s','m','a','l','l', 0,
'I','s','m','a','l','l', 0,
'J','s','m','a','l','l', 0,
'K','s','m','a','l','l', 0,
'L','s','m','a','l','l', 0,
'M','s','m','a','l','l', 0,
'N','s','m','a','l','l', 0,
'O','s','m','a','l','l', 0,
'P','s','m','a','l','l', 0,
'Q','s','m','a','l','l', 0,
'R','s','m','a','l','l', 0,
'S','s','m','a','l','l', 0,
'T','s','m','a','l','l', 0,
'U','s','m','a','l','l', 0,
'V','s','m','a','l','l', 0,
'W','s','m','a','l','l', 0,
'X','s','m','a','l','l', 0,
'Y','s','m','a','l','l', 0,
'Z','s','m','a','l','l', 0,
'c','o','l','o','n','m','o','n','e','t','a','r','y', 0,
'o','n','e','f','i','t','t','e','d', 0,
'r','u','p','i','a','h', 0,
'T','i','l','d','e','s','m','a','l','l', 0,
'e','x','c','l','a','m','d','o','w','n','s','m','a','l','l', 0,
'c','e','n','t','o','l','d','s','t','y','l','e', 0,
'L','s','l','a','s','h','s','m','a','l','l', 0,
'S','c','a','r','o','n','s','m','a','l','l', 0,
'Z','c','a','r','o','n','s','m','a','l','l', 0,
'D','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'B','r','e','v','e','s','m','a','l','l', 0,
'C','a','r','o','n','s','m','a','l','l', 0,
'D','o','t','a','c','c','e','n','t','s','m','a','l','l', 0,
'M','a','c','r','o','n','s','m','a','l','l', 0,
'f','i','g','u','r','e','d','a','s','h', 0,
'h','y','p','h','e','n','i','n','f','e','r','i','o','r', 0,
'O','g','o','n','e','k','s','m','a','l','l', 0,
'R','i','n','g','s','m','a','l','l', 0,
'C','e','d','i','l','l','a','s','m','a','l','l', 0,
'q','u','e','s','t','i','o','n','d','o','w','n','s','m','a','l','l', 0,
'o','n','e','e','i','g','h','t','h', 0,
't','h','r','e','e','e','i','g','h','t','h','s', 0,
'f','i','v','e','e','i','g','h','t','h','s', 0,
's','e','v','e','n','e','i','g','h','t','h','s', 0,
'o','n','e','t','h','i','r','d', 0,
't','w','o','t','h','i','r','d','s', 0,
'z','e','r','o','s','u','p','e','r','i','o','r', 0,
'f','o','u','r','s','u','p','e','r','i','o','r', 0,
'f','i','v','e','s','u','p','e','r','i','o','r', 0,
's','i','x','s','u','p','e','r','i','o','r', 0,
's','e','v','e','n','s','u','p','e','r','i','o','r', 0,
'e','i','g','h','t','s','u','p','e','r','i','o','r', 0,
'n','i','n','e','s','u','p','e','r','i','o','r', 0,
'z','e','r','o','i','n','f','e','r','i','o','r', 0,
'o','n','e','i','n','f','e','r','i','o','r', 0,
't','w','o','i','n','f','e','r','i','o','r', 0,
't','h','r','e','e','i','n','f','e','r','i','o','r', 0,
'f','o','u','r','i','n','f','e','r','i','o','r', 0,
'f','i','v','e','i','n','f','e','r','i','o','r', 0,
's','i','x','i','n','f','e','r','i','o','r', 0,
's','e','v','e','n','i','n','f','e','r','i','o','r', 0,
'e','i','g','h','t','i','n','f','e','r','i','o','r', 0,
'n','i','n','e','i','n','f','e','r','i','o','r', 0,
'c','e','n','t','i','n','f','e','r','i','o','r', 0,
'd','o','l','l','a','r','i','n','f','e','r','i','o','r', 0,
'p','e','r','i','o','d','i','n','f','e','r','i','o','r', 0,
'c','o','m','m','a','i','n','f','e','r','i','o','r', 0,
'A','g','r','a','v','e','s','m','a','l','l', 0,
'A','a','c','u','t','e','s','m','a','l','l', 0,
'A','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'A','t','i','l','d','e','s','m','a','l','l', 0,
'A','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'A','r','i','n','g','s','m','a','l','l', 0,
'A','E','s','m','a','l','l', 0,
'C','c','e','d','i','l','l','a','s','m','a','l','l', 0,
'E','g','r','a','v','e','s','m','a','l','l', 0,
'E','a','c','u','t','e','s','m','a','l','l', 0,
'E','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'E','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'I','g','r','a','v','e','s','m','a','l','l', 0,
'I','a','c','u','t','e','s','m','a','l','l', 0,
'I','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'I','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'E','t','h','s','m','a','l','l', 0,
'N','t','i','l','d','e','s','m','a','l','l', 0,
'O','g','r','a','v','e','s','m','a','l','l', 0,
'O','a','c','u','t','e','s','m','a','l','l', 0,
'O','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'O','t','i','l','d','e','s','m','a','l','l', 0,
'O','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'O','E','s','m','a','l','l', 0,
'O','s','l','a','s','h','s','m','a','l','l', 0,
'U','g','r','a','v','e','s','m','a','l','l', 0,
'U','a','c','u','t','e','s','m','a','l','l', 0,
'U','c','i','r','c','u','m','f','l','e','x','s','m','a','l','l', 0,
'U','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'Y','a','c','u','t','e','s','m','a','l','l', 0,
'T','h','o','r','n','s','m','a','l','l', 0,
'Y','d','i','e','r','e','s','i','s','s','m','a','l','l', 0,
'0','0','1','.','0','0','0', 0,
'0','0','1','.','0','0','1', 0,
'0','0','1','.','0','0','2', 0,
'0','0','1','.','0','0','3', 0,
'B','l','a','c','k', 0,
'B','o','l','d', 0,
'B','o','o','k', 0,
'L','i','g','h','t', 0,
'M','e','d','i','u','m', 0,
'R','e','g','u','l','a','r', 0,
'R','o','m','a','n', 0,
'S','e','m','i','b','o','l','d', 0,
};
#define FT_NUM_MAC_NAMES 258
/* Values are offsets into the `ft_standard_glyph_names' table */
static const short ft_mac_names[FT_NUM_MAC_NAMES] =
{
253, 0, 6, 261, 267, 274, 283, 294, 301, 309, 758, 330, 340, 351,
360, 365, 371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430,
436, 441, 447, 457, 462, 468, 476, 485, 488, 490, 492, 494, 496, 498,
500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526,
528, 530, 532, 534, 536, 538, 540, 552, 562, 575, 587, 979, 608, 610,
612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638,
640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 670, 674, 685,
1375,1392,1405,1414,1486,1512,1562,1603,1632,1610,1622,1645,1639,1652,
1661,1690,1668,1680,1697,1726,1704,1716,1733,1740,1769,1747,1759,1776,
1790,1819,1797,1809, 839,1263, 707, 712, 741, 881, 871,1160,1302,1346,
1197, 985,1031, 23,1086,1108, 32,1219, 41, 51, 730,1194, 64, 76,
86, 94, 97,1089,1118, 106,1131,1150, 966, 696,1183, 112, 734, 120,
132, 783, 930, 945, 138,1385,1398,1529,1115,1157, 832,1079, 770, 916,
598, 319,1246, 155,1833,1586, 721, 749, 797, 811, 826, 829, 846, 856,
888, 903, 954,1363,1421,1356,1433,1443,1450,1457,1469,1479,1493,1500,
163,1522,1543,1550,1572,1134, 991,1002,1008,1015,1021,1040,1045,1053,
1066,1073,1101,1143,1536,1783,1596,1843,1253,1207,1319,1579,1826,1229,
1270,1313,1323,1171,1290,1332,1211,1235,1276, 169, 175, 182, 189, 200,
209, 218, 225, 232, 239, 246
};
#define FT_NUM_SID_NAMES 391
/* Values are offsets into the `ft_standard_glyph_names' table */
static const short ft_sid_names[FT_NUM_SID_NAMES] =
{
253, 261, 267, 274, 283, 294, 301, 309, 319, 330, 340, 351, 360, 365,
371, 378, 385, 391, 396, 400, 404, 410, 415, 420, 424, 430, 436, 441,
447, 457, 462, 468, 476, 485, 488, 490, 492, 494, 496, 498, 500, 502,
504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530,
532, 534, 536, 538, 540, 552, 562, 575, 587, 598, 608, 610, 612, 614,
616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642,
644, 646, 648, 650, 652, 654, 656, 658, 660, 670, 674, 685, 696, 707,
712, 721, 730, 734, 741, 749, 758, 770, 783, 797, 811, 826, 829, 832,
839, 846, 856, 871, 881, 888, 903, 916, 930, 945, 954, 966, 979, 985,
991,1002,1008,1015,1021,1031,1040,1045,1053,1066,1073,1079,1086,1089,
1101,1108,1115,1118,1131,1134,1143,1150,1157,1160,1171,1183,1194,1197,
1207,1211,1219,1229,1235,1246,1253,1263,1270,1276,1290,1302,1313,1319,
1323,1332,1346,1356,1363,1375,1385,1392,1398,1405,1414,1421,1433,1443,
1450,1457,1469,1479,1486,1493,1500,1512,1522,1529,1536,1543,1550,1562,
1572,1579,1586,1596,1603,1610,1622,1632,1639,1645,1652,1661,1668,1680,
1690,1697,1704,1716,1726,1733,1740,1747,1759,1769,1776,1783,1790,1797,
1809,1819,1826,1833,1843,1850,1862,1880,1895,1910,1925,1936,1954,1973,
1988,2003,2016,2028,2040,2054,2067,2080,2092,2106,2120,2133,2147,2167,
2182,2196,2206,2216,2229,2239,2249,2259,2269,2279,2289,2299,2309,2319,
2329,2332,2336,2340,2358,2377,2393,2408,2419,2426,2433,2440,2447,2454,
2461,2468,2475,2482,2489,2496,2503,2510,2517,2524,2531,2538,2545,2552,
2559,2566,2573,2580,2587,2594,2601,2615,2625,2632,2643,2659,2672,2684,
2696,2708,2722,2733,2744,2759,2771,2782,2797,2809,2819,2832,2850,2860,
2873,2885,2898,2907,2917,2930,2943,2956,2968,2982,2996,3009,3022,3034,
3046,3060,3073,3086,3098,3112,3126,3139,3152,3167,3182,3196,3208,3220,
3237,3249,3264,3275,3283,3297,3309,3321,3338,3353,3365,3377,3394,3409,
3418,3430,3442,3454,3471,3483,3498,3506,3518,3530,3542,3559,3574,3586,
3597,3612,3620,3628,3636,3644,3650,3655,3660,3666,3673,3681,3687
};
/* the following are indices into the SID name table */
static const unsigned short t1_standard_encoding[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,
0,111,112,113,114, 0,115,116,117,118,119,120,121,122, 0,123,
0,124,125,126,127,128,129,130,131, 0,132,133, 0,134,135,136,
137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,138, 0,139, 0, 0, 0, 0,140,141,142,143, 0, 0, 0, 0,
0,144, 0, 0, 0,145, 0, 0,146,147,148,149, 0, 0, 0, 0
};
/* the following are indices into the SID name table */
static const unsigned short t1_expert_encoding[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1,229,230, 0,231,232,233,234,235,236,237,238, 13, 14, 15, 99,
239,240,241,242,243,244,245,246,247,248, 27, 28,249,250,251,252,
0,253,254,255,256,257, 0, 0, 0,258, 0, 0,259,260,261,262,
0, 0,263,264,265, 0,266,109,110,267,268,269, 0,270,271,272,
273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,
289,290,291,292,293,294,295,296,297,298,299,300,301,302,303, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,304,305,306, 0, 0,307,308,309,310,311, 0,312, 0, 0,313,
0, 0,314,315, 0, 0,316,317,318, 0, 0, 0,158,155,163,319,
320,321,322,323,324,325, 0, 0,326,150,164,169,327,328,329,330,
331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,
347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,
363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378
};
/*
* This table is a compressed version of the Adobe Glyph List (AGL),
* optimized for efficient searching. It has been generated by the
* `glnames.py' python script located in the `src/tools' directory.
*
* The lookup function to get the Unicode value for a given string
* is defined below the table.
*/
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
static const unsigned char ft_adobe_glyph_list[55997L] =
{
0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23,
11,137, 12,199, 14,246, 15, 87, 16,233, 17,219, 18,104, 19, 88,
22,110, 23, 32, 23, 71, 24, 77, 27,156, 29, 73, 31,247, 32,107,
32,222, 33, 55, 34,154, 35,218, 58, 10, 64,122, 72,188, 80,109,
88,104, 93, 61, 98,168,106, 91,114,111,115,237,122,180,127,255,
135,164,143,132,149,213,158,108,161,115,168,175,183,147,197,199,
202, 25,204,166,208,209,209, 81,215, 26, 65,143, 0, 65, 0,140,
0,175, 0,193, 1, 15, 1,147, 1,233, 1,251, 2, 7, 2, 40,
2, 57, 2, 82, 2, 91, 2,128, 2,136, 2,154, 69,131, 0,198,
0,150, 0,158, 0,167,225,227,245,244,101,128, 1,252,237,225,
227,242,239,110,128, 1,226,243,237,225,236,108,128,247,230,225,
227,245,244,101,129, 0,193, 0,185,243,237,225,236,108,128,247,
225,226,242,229,246,101,134, 1, 2, 0,213, 0,221, 0,232, 0,
243, 0,251, 1, 7,225,227,245,244,101,128, 30,174,227,249,242,
233,236,236,233, 99,128, 4,208,228,239,244,226,229,236,239,119,
128, 30,182,231,242,225,246,101,128, 30,176,232,239,239,235,225,
226,239,246,101,128, 30,178,244,233,236,228,101,128, 30,180, 99,
4, 1, 25, 1, 32, 1,121, 1,137,225,242,239,110,128, 1,205,
233,242, 99, 2, 1, 40, 1, 45,236,101,128, 36,182,245,237,230,
236,229,120,134, 0,194, 1, 66, 1, 74, 1, 85, 1, 93, 1,105,
1,113,225,227,245,244,101,128, 30,164,228,239,244,226,229,236,
239,119,128, 30,172,231,242,225,246,101,128, 30,166,232,239,239,
235,225,226,239,246,101,128, 30,168,243,237,225,236,108,128,247,
226,244,233,236,228,101,128, 30,170,245,244,101,129,246,201, 1,
129,243,237,225,236,108,128,247,180,249,242,233,236,236,233, 99,
128, 4, 16,100, 3, 1,155, 1,165, 1,209,226,236,231,242,225,
246,101,128, 2, 0,233,229,242,229,243,233,115,131, 0,196, 1,
181, 1,192, 1,201,227,249,242,233,236,236,233, 99,128, 4,210,
237,225,227,242,239,110,128, 1,222,243,237,225,236,108,128,247,
228,239,116, 2, 1,216, 1,224,226,229,236,239,119,128, 30,160,
237,225,227,242,239,110,128, 1,224,231,242,225,246,101,129, 0,
192, 1,243,243,237,225,236,108,128,247,224,232,239,239,235,225,
226,239,246,101,128, 30,162,105, 2, 2, 13, 2, 25,229,227,249,
242,233,236,236,233, 99,128, 4,212,238,246,229,242,244,229,228,
226,242,229,246,101,128, 2, 2,236,240,232, 97,129, 3,145, 2,
49,244,239,238,239,115,128, 3,134,109, 2, 2, 63, 2, 71,225,
227,242,239,110,128, 1, 0,239,238,239,243,240,225,227,101,128,
255, 33,239,231,239,238,229,107,128, 1, 4,242,233,238,103,131,
0,197, 2,104, 2,112, 2,120,225,227,245,244,101,128, 1,250,
226,229,236,239,119,128, 30, 0,243,237,225,236,108,128,247,229,
243,237,225,236,108,128,247, 97,244,233,236,228,101,129, 0,195,
2,146,243,237,225,236,108,128,247,227,249,226,225,242,237,229,
238,233,225,110,128, 5, 49, 66,137, 0, 66, 2,189, 2,198, 2,
223, 3, 3, 3, 10, 3, 22, 3, 34, 3, 46, 3, 54,227,233,242,
227,236,101,128, 36,183,228,239,116, 2, 2,206, 2,215,225,227,
227,229,238,116,128, 30, 2,226,229,236,239,119,128, 30, 4,101,
3, 2,231, 2,242, 2,254,227,249,242,233,236,236,233, 99,128,
4, 17,238,225,242,237,229,238,233,225,110,128, 5, 50,244, 97,
128, 3,146,232,239,239,107,128, 1,129,236,233,238,229,226,229,
236,239,119,128, 30, 6,237,239,238,239,243,240,225,227,101,128,
255, 34,242,229,246,229,243,237,225,236,108,128,246,244,243,237,
225,236,108,128,247, 98,244,239,240,226,225,114,128, 1,130, 67,
137, 0, 67, 3, 85, 3,127, 3,193, 3,210, 3,224, 4,171, 4,
188, 4,200, 4,212, 97, 3, 3, 93, 3,104, 3,111,225,242,237,
229,238,233,225,110,128, 5, 62,227,245,244,101,128, 1, 6,242,
239,110,129,246,202, 3,119,243,237,225,236,108,128,246,245, 99,
3, 3,135, 3,142, 3,171,225,242,239,110,128, 1, 12,229,228,
233,236,236, 97,130, 0,199, 3,155, 3,163,225,227,245,244,101,
128, 30, 8,243,237,225,236,108,128,247,231,233,242, 99, 2, 3,
179, 3,184,236,101,128, 36,184,245,237,230,236,229,120,128, 1,
8,228,239,116,129, 1, 10, 3,201,225,227,227,229,238,116,128,
1, 10,229,228,233,236,236,225,243,237,225,236,108,128,247,184,
104, 4, 3,234, 3,246, 4,161, 4,165,225,225,242,237,229,238,
233,225,110,128, 5, 73,101, 6, 4, 4, 4, 24, 4, 35, 4,103,
4,115, 4,136,225,226,235,232,225,243,233,225,238,227,249,242,
233,236,236,233, 99,128, 4,188,227,249,242,233,236,236,233, 99,
128, 4, 39,100, 2, 4, 41, 4, 85,229,243,227,229,238,228,229,
114, 2, 4, 54, 4, 74,225,226,235,232,225,243,233,225,238,227,
249,242,233,236,236,233, 99,128, 4,190,227,249,242,233,236,236,
233, 99,128, 4,182,233,229,242,229,243,233,243,227,249,242,233,
236,236,233, 99,128, 4,244,232,225,242,237,229,238,233,225,110,
128, 5, 67,235,232,225,235,225,243,243,233,225,238,227,249,242,
233,236,236,233, 99,128, 4,203,246,229,242,244,233,227,225,236,
243,244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,
184,105,128, 3,167,239,239,107,128, 1,135,233,242,227,245,237,
230,236,229,248,243,237,225,236,108,128,246,246,237,239,238,239,
243,240,225,227,101,128,255, 35,239,225,242,237,229,238,233,225,
110,128, 5, 81,243,237,225,236,108,128,247, 99, 68,142, 0, 68,
4,252, 5, 10, 5, 36, 5, 96, 5,121, 5,166, 5,173, 5,231,
5,244, 6, 0, 6, 12, 6, 28, 6, 48, 6, 57, 90,129, 1,241,
5, 2,227,225,242,239,110,128, 1,196, 97, 2, 5, 16, 5, 27,
225,242,237,229,238,233,225,110,128, 5, 52,230,242,233,227,225,
110,128, 1,137, 99, 4, 5, 46, 5, 53, 5, 62, 5, 89,225,242,
239,110,128, 1, 14,229,228,233,236,236, 97,128, 30, 16,233,242,
99, 2, 5, 70, 5, 75,236,101,128, 36,185,245,237,230,236,229,
248,226,229,236,239,119,128, 30, 18,242,239,225,116,128, 1, 16,
228,239,116, 2, 5,104, 5,113,225,227,227,229,238,116,128, 30,
10,226,229,236,239,119,128, 30, 12,101, 3, 5,129, 5,140, 5,
150,227,249,242,233,236,236,233, 99,128, 4, 20,233,227,239,240,
244,233, 99,128, 3,238,236,244, 97,129, 34, 6, 5,158,231,242,
229,229,107,128, 3,148,232,239,239,107,128, 1,138,105, 2, 5,
179, 5,218,229,242,229,243,233,115,131,246,203, 5,194, 5,202,
5,210,193,227,245,244,101,128,246,204,199,242,225,246,101,128,
246,205,243,237,225,236,108,128,247,168,231,225,237,237,225,231,
242,229,229,107,128, 3,220,234,229,227,249,242,233,236,236,233,
99,128, 4, 2,236,233,238,229,226,229,236,239,119,128, 30, 14,
237,239,238,239,243,240,225,227,101,128,255, 36,239,244,225,227,
227,229,238,244,243,237,225,236,108,128,246,247,115, 2, 6, 34,
6, 41,236,225,243,104,128, 1, 16,237,225,236,108,128,247,100,
244,239,240,226,225,114,128, 1,139,122,131, 1,242, 6, 67, 6,
75, 6,112,227,225,242,239,110,128, 1,197,101, 2, 6, 81, 6,
101,225,226,235,232,225,243,233,225,238,227,249,242,233,236,236,
233, 99,128, 4,224,227,249,242,233,236,236,233, 99,128, 4, 5,
232,229,227,249,242,233,236,236,233, 99,128, 4, 15, 69,146, 0,
69, 6,165, 6,183, 6,191, 7, 89, 7,153, 7,165, 7,183, 7,
211, 8, 7, 8, 36, 8, 94, 8,169, 8,189, 8,208, 8,248, 9,
44, 9,109, 9,115,225,227,245,244,101,129, 0,201, 6,175,243,
237,225,236,108,128,247,233,226,242,229,246,101,128, 1, 20, 99,
5, 6,203, 6,210, 6,224, 6,236, 7, 79,225,242,239,110,128,
1, 26,229,228,233,236,236,225,226,242,229,246,101,128, 30, 28,
232,225,242,237,229,238,233,225,110,128, 5, 53,233,242, 99, 2,
6,244, 6,249,236,101,128, 36,186,245,237,230,236,229,120,135,
0,202, 7, 16, 7, 24, 7, 32, 7, 43, 7, 51, 7, 63, 7, 71,
225,227,245,244,101,128, 30,190,226,229,236,239,119,128, 30, 24,
228,239,244,226,229,236,239,119,128, 30,198,231,242,225,246,101,
128, 30,192,232,239,239,235,225,226,239,246,101,128, 30,194,243,
237,225,236,108,128,247,234,244,233,236,228,101,128, 30,196,249,
242,233,236,236,233, 99,128, 4, 4,100, 3, 7, 97, 7,107, 7,
127,226,236,231,242,225,246,101,128, 2, 4,233,229,242,229,243,
233,115,129, 0,203, 7,119,243,237,225,236,108,128,247,235,239,
116,130, 1, 22, 7,136, 7,145,225,227,227,229,238,116,128, 1,
22,226,229,236,239,119,128, 30,184,230,227,249,242,233,236,236,
233, 99,128, 4, 36,231,242,225,246,101,129, 0,200, 7,175,243,
237,225,236,108,128,247,232,104, 2, 7,189, 7,200,225,242,237,
229,238,233,225,110,128, 5, 55,239,239,235,225,226,239,246,101,
128, 30,186,105, 3, 7,219, 7,230, 7,245,231,232,244,242,239,
237,225,110,128, 33,103,238,246,229,242,244,229,228,226,242,229,
246,101,128, 2, 6,239,244,233,230,233,229,228,227,249,242,233,
236,236,233, 99,128, 4,100,108, 2, 8, 13, 8, 24,227,249,242,
233,236,236,233, 99,128, 4, 27,229,246,229,238,242,239,237,225,
110,128, 33,106,109, 3, 8, 44, 8, 72, 8, 83,225,227,242,239,
110,130, 1, 18, 8, 56, 8, 64,225,227,245,244,101,128, 30, 22,
231,242,225,246,101,128, 30, 20,227,249,242,233,236,236,233, 99,
128, 4, 28,239,238,239,243,240,225,227,101,128,255, 37,110, 4,
8,104, 8,115, 8,135, 8,154,227,249,242,233,236,236,233, 99,
128, 4, 29,228,229,243,227,229,238,228,229,242,227,249,242,233,
236,236,233, 99,128, 4,162,103,129, 1, 74, 8,141,232,229,227,
249,242,233,236,236,233, 99,128, 4,164,232,239,239,235,227,249,
242,233,236,236,233, 99,128, 4,199,111, 2, 8,175, 8,183,231,
239,238,229,107,128, 1, 24,240,229,110,128, 1,144,240,243,233,
236,239,110,129, 3,149, 8,200,244,239,238,239,115,128, 3,136,
114, 2, 8,214, 8,225,227,249,242,233,236,236,233, 99,128, 4,
32,229,246,229,242,243,229,100,129, 1,142, 8,237,227,249,242,
233,236,236,233, 99,128, 4, 45,115, 4, 9, 2, 9, 13, 9, 33,
9, 37,227,249,242,233,236,236,233, 99,128, 4, 33,228,229,243,
227,229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,
170,104,128, 1,169,237,225,236,108,128,247,101,116, 3, 9, 52,
9, 78, 9, 92, 97,130, 3,151, 9, 60, 9, 70,242,237,229,238,
233,225,110,128, 5, 56,244,239,238,239,115,128, 3,137,104,129,
0,208, 9, 84,243,237,225,236,108,128,247,240,233,236,228,101,
129, 30,188, 9,101,226,229,236,239,119,128, 30, 26,245,242,111,
128, 32,172,250,104,130, 1,183, 9,124, 9,132,227,225,242,239,
110,128, 1,238,242,229,246,229,242,243,229,100,128, 1,184, 70,
136, 0, 70, 9,163, 9,172, 9,184, 9,212, 9,219, 9,248, 10,
4, 10, 15,227,233,242,227,236,101,128, 36,187,228,239,244,225,
227,227,229,238,116,128, 30, 30,101, 2, 9,190, 9,202,232,225,
242,237,229,238,233,225,110,128, 5, 86,233,227,239,240,244,233,
99,128, 3,228,232,239,239,107,128, 1,145,105, 2, 9,225, 9,
238,244,225,227,249,242,233,236,236,233, 99,128, 4,114,246,229,
242,239,237,225,110,128, 33,100,237,239,238,239,243,240,225,227,
101,128,255, 38,239,245,242,242,239,237,225,110,128, 33, 99,243,
237,225,236,108,128,247,102, 71,140, 0, 71, 10, 51, 10, 61, 10,
107, 10,115, 10,176, 10,193, 10,205, 11, 39, 11, 52, 11, 65, 11,
90, 11,107,194,243,241,245,225,242,101,128, 51,135, 97, 3, 10,
69, 10, 76, 10, 94,227,245,244,101,128, 1,244,237,237, 97,129,
3,147, 10, 84,225,230,242,233,227,225,110,128, 1,148,238,231,
233,225,227,239,240,244,233, 99,128, 3,234,226,242,229,246,101,
128, 1, 30, 99, 4, 10,125, 10,132, 10,141, 10,163,225,242,239,
110,128, 1,230,229,228,233,236,236, 97,128, 1, 34,233,242, 99,
2, 10,149, 10,154,236,101,128, 36,188,245,237,230,236,229,120,
128, 1, 28,239,237,237,225,225,227,227,229,238,116,128, 1, 34,
228,239,116,129, 1, 32, 10,184,225,227,227,229,238,116,128, 1,
32,229,227,249,242,233,236,236,233, 99,128, 4, 19,104, 3, 10,
213, 10,226, 11, 33,225,228,225,242,237,229,238,233,225,110,128,
5, 66,101, 3, 10,234, 10,255, 11, 16,237,233,228,228,236,229,
232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,148,243,
244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,146,
245,240,244,245,242,238,227,249,242,233,236,236,233, 99,128, 4,
144,239,239,107,128, 1,147,233,237,225,242,237,229,238,233,225,
110,128, 5, 51,234,229,227,249,242,233,236,236,233, 99,128, 4,
3,109, 2, 11, 71, 11, 79,225,227,242,239,110,128, 30, 32,239,
238,239,243,240,225,227,101,128,255, 39,242,225,246,101,129,246,
206, 11, 99,243,237,225,236,108,128,247, 96,115, 2, 11,113, 11,
129,237,225,236,108,129,247,103, 11,122,232,239,239,107,128, 2,
155,244,242,239,235,101,128, 1,228, 72,140, 0, 72, 11,165, 11,
190, 11,198, 11,208, 12, 17, 12, 40, 12, 77, 12,117, 12,129, 12,
157, 12,165, 12,189,177,184, 53, 3, 11,175, 11,180, 11,185,179,
51,128, 37,207,180, 51,128, 37,170,181, 49,128, 37,171,178,178,
176,183, 51,128, 37,161,208,243,241,245,225,242,101,128, 51,203,
97, 3, 11,216, 11,236, 12, 0,225,226,235,232,225,243,233,225,
238,227,249,242,233,236,236,233, 99,128, 4,168,228,229,243,227,
229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,178,
242,228,243,233,231,238,227,249,242,233,236,236,233, 99,128, 4,
42, 98, 2, 12, 23, 12, 28,225,114,128, 1, 38,242,229,246,229,
226,229,236,239,119,128, 30, 42, 99, 2, 12, 46, 12, 55,229,228,
233,236,236, 97,128, 30, 40,233,242, 99, 2, 12, 63, 12, 68,236,
101,128, 36,189,245,237,230,236,229,120,128, 1, 36,100, 2, 12,
83, 12, 93,233,229,242,229,243,233,115,128, 30, 38,239,116, 2,
12,100, 12,109,225,227,227,229,238,116,128, 30, 34,226,229,236,
239,119,128, 30, 36,237,239,238,239,243,240,225,227,101,128,255,
40,111, 2, 12,135, 12,146,225,242,237,229,238,233,225,110,128,
5, 64,242,233,227,239,240,244,233, 99,128, 3,232,243,237,225,
236,108,128,247,104,245,238,231,225,242,245,237,236,225,245,116,
129,246,207, 12,181,243,237,225,236,108,128,246,248,250,243,241,
245,225,242,101,128, 51,144, 73,146, 0, 73, 12,239, 12,251, 12,
255, 13, 11, 13, 29, 13, 37, 13, 94, 13,181, 13,214, 13,224, 13,
242, 13,254, 14, 48, 14, 86, 14, 99, 14,166, 14,187, 14,205,193,
227,249,242,233,236,236,233, 99,128, 4, 47, 74,128, 1, 50,213,
227,249,242,233,236,236,233, 99,128, 4, 46,225,227,245,244,101,
129, 0,205, 13, 21,243,237,225,236,108,128,247,237,226,242,229,
246,101,128, 1, 44, 99, 3, 13, 45, 13, 52, 13, 84,225,242,239,
110,128, 1,207,233,242, 99, 2, 13, 60, 13, 65,236,101,128, 36,
190,245,237,230,236,229,120,129, 0,206, 13, 76,243,237,225,236,
108,128,247,238,249,242,233,236,236,233, 99,128, 4, 6,100, 3,
13,102, 13,112, 13,155,226,236,231,242,225,246,101,128, 2, 8,
233,229,242,229,243,233,115,131, 0,207, 13,128, 13,136, 13,147,
225,227,245,244,101,128, 30, 46,227,249,242,233,236,236,233, 99,
128, 4,228,243,237,225,236,108,128,247,239,239,116,130, 1, 48,
13,164, 13,173,225,227,227,229,238,116,128, 1, 48,226,229,236,
239,119,128, 30,202,101, 2, 13,187, 13,203,226,242,229,246,229,
227,249,242,233,236,236,233, 99,128, 4,214,227,249,242,233,236,
236,233, 99,128, 4, 21,230,242,225,235,244,245,114,128, 33, 17,
231,242,225,246,101,129, 0,204, 13,234,243,237,225,236,108,128,
247,236,232,239,239,235,225,226,239,246,101,128, 30,200,105, 3,
14, 6, 14, 17, 14, 32,227,249,242,233,236,236,233, 99,128, 4,
24,238,246,229,242,244,229,228,226,242,229,246,101,128, 2, 10,
243,232,239,242,244,227,249,242,233,236,236,233, 99,128, 4, 25,
109, 2, 14, 54, 14, 75,225,227,242,239,110,129, 1, 42, 14, 64,
227,249,242,233,236,236,233, 99,128, 4,226,239,238,239,243,240,
225,227,101,128,255, 41,238,233,225,242,237,229,238,233,225,110,
128, 5, 59,111, 3, 14,107, 14,118, 14,126,227,249,242,233,236,
236,233, 99,128, 4, 1,231,239,238,229,107,128, 1, 46,244, 97,
131, 3,153, 14,137, 14,147, 14,158,225,230,242,233,227,225,110,
128, 1,150,228,233,229,242,229,243,233,115,128, 3,170,244,239,
238,239,115,128, 3,138,115, 2, 14,172, 14,179,237,225,236,108,
128,247,105,244,242,239,235,101,128, 1,151,244,233,236,228,101,
129, 1, 40, 14,197,226,229,236,239,119,128, 30, 44,250,232,233,
244,243, 97, 2, 14,216, 14,227,227,249,242,233,236,236,233, 99,
128, 4,116,228,226,236,231,242,225,246,229,227,249,242,233,236,
236,233, 99,128, 4,118, 74,134, 0, 74, 15, 6, 15, 18, 15, 41,
15, 53, 15, 67, 15, 79,225,225,242,237,229,238,233,225,110,128,
5, 65,227,233,242, 99, 2, 15, 27, 15, 32,236,101,128, 36,191,
245,237,230,236,229,120,128, 1, 52,229,227,249,242,233,236,236,
233, 99,128, 4, 8,232,229,232,225,242,237,229,238,233,225,110,
128, 5, 75,237,239,238,239,243,240,225,227,101,128,255, 42,243,
237,225,236,108,128,247,106, 75,140, 0, 75, 15,115, 15,125, 15,
135, 16, 18, 16, 65, 16, 76, 16,106, 16,143, 16,156, 16,168, 16,
180, 16,208,194,243,241,245,225,242,101,128, 51,133,203,243,241,
245,225,242,101,128, 51,205, 97, 7, 15,151, 15,169, 15,191, 15,
211, 15,226, 15,232, 15,249,226,225,243,232,235,233,242,227,249,
242,233,236,236,233, 99,128, 4,160, 99, 2, 15,175, 15,181,245,
244,101,128, 30, 48,249,242,233,236,236,233, 99,128, 4, 26,228,
229,243,227,229,238,228,229,242,227,249,242,233,236,236,233, 99,
128, 4,154,232,239,239,235,227,249,242,233,236,236,233, 99,128,
4,195,240,240, 97,128, 3,154,243,244,242,239,235,229,227,249,
242,233,236,236,233, 99,128, 4,158,246,229,242,244,233,227,225,
236,243,244,242,239,235,229,227,249,242,233,236,236,233, 99,128,
4,156, 99, 4, 16, 28, 16, 35, 16, 44, 16, 52,225,242,239,110,
128, 1,232,229,228,233,236,236, 97,128, 1, 54,233,242,227,236,
101,128, 36,192,239,237,237,225,225,227,227,229,238,116,128, 1,
54,228,239,244,226,229,236,239,119,128, 30, 50,101, 2, 16, 82,
16, 94,232,225,242,237,229,238,233,225,110,128, 5, 84,238,225,
242,237,229,238,233,225,110,128, 5, 63,104, 3, 16,114, 16,126,
16,137,225,227,249,242,233,236,236,233, 99,128, 4, 37,229,233,
227,239,240,244,233, 99,128, 3,230,239,239,107,128, 1,152,234,
229,227,249,242,233,236,236,233, 99,128, 4, 12,236,233,238,229,
226,229,236,239,119,128, 30, 52,237,239,238,239,243,240,225,227,
101,128,255, 43,239,240,240, 97, 2, 16,189, 16,200,227,249,242,
233,236,236,233, 99,128, 4,128,231,242,229,229,107,128, 3,222,
115, 2, 16,214, 16,226,233,227,249,242,233,236,236,233, 99,128,
4,110,237,225,236,108,128,247,107, 76,138, 0, 76, 17, 1, 17,
5, 17, 9, 17, 29, 17, 95, 17,133, 17,147, 17,165, 17,177, 17,
189, 74,128, 1,199, 76,128,246,191, 97, 2, 17, 15, 17, 22,227,
245,244,101,128, 1, 57,237,226,228, 97,128, 3,155, 99, 4, 17,
39, 17, 46, 17, 55, 17, 82,225,242,239,110,128, 1, 61,229,228,
233,236,236, 97,128, 1, 59,233,242, 99, 2, 17, 63, 17, 68,236,
101,128, 36,193,245,237,230,236,229,248,226,229,236,239,119,128,
30, 60,239,237,237,225,225,227,227,229,238,116,128, 1, 59,228,
239,116,130, 1, 63, 17,105, 17,114,225,227,227,229,238,116,128,
1, 63,226,229,236,239,119,129, 30, 54, 17,124,237,225,227,242,
239,110,128, 30, 56,233,247,238,225,242,237,229,238,233,225,110,
128, 5, 60,106,129, 1,200, 17,153,229,227,249,242,233,236,236,
233, 99,128, 4, 9,236,233,238,229,226,229,236,239,119,128, 30,
58,237,239,238,239,243,240,225,227,101,128,255, 44,115, 2, 17,
195, 17,212,236,225,243,104,129, 1, 65, 17,204,243,237,225,236,
108,128,246,249,237,225,236,108,128,247,108, 77,137, 0, 77, 17,
241, 17,251, 18, 24, 18, 33, 18, 58, 18, 71, 18, 83, 18, 91, 18,
100,194,243,241,245,225,242,101,128, 51,134,225, 99, 2, 18, 2,
18, 18,242,239,110,129,246,208, 18, 10,243,237,225,236,108,128,
247,175,245,244,101,128, 30, 62,227,233,242,227,236,101,128, 36,
194,228,239,116, 2, 18, 41, 18, 50,225,227,227,229,238,116,128,
30, 64,226,229,236,239,119,128, 30, 66,229,238,225,242,237,229,
238,233,225,110,128, 5, 68,237,239,238,239,243,240,225,227,101,
128,255, 45,243,237,225,236,108,128,247,109,244,245,242,238,229,
100,128, 1,156,117,128, 3,156, 78,141, 0, 78, 18,134, 18,138,
18,146, 18,212, 18,237, 18,248, 19, 3, 19, 21, 19, 33, 19, 45,
19, 58, 19, 66, 19, 84, 74,128, 1,202,225,227,245,244,101,128,
1, 67, 99, 4, 18,156, 18,163, 18,172, 18,199,225,242,239,110,
128, 1, 71,229,228,233,236,236, 97,128, 1, 69,233,242, 99, 2,
18,180, 18,185,236,101,128, 36,195,245,237,230,236,229,248,226,
229,236,239,119,128, 30, 74,239,237,237,225,225,227,227,229,238,
116,128, 1, 69,228,239,116, 2, 18,220, 18,229,225,227,227,229,
238,116,128, 30, 68,226,229,236,239,119,128, 30, 70,232,239,239,
235,236,229,230,116,128, 1,157,233,238,229,242,239,237,225,110,
128, 33,104,106,129, 1,203, 19, 9,229,227,249,242,233,236,236,
233, 99,128, 4, 10,236,233,238,229,226,229,236,239,119,128, 30,
72,237,239,238,239,243,240,225,227,101,128,255, 46,239,247,225,
242,237,229,238,233,225,110,128, 5, 70,243,237,225,236,108,128,
247,110,244,233,236,228,101,129, 0,209, 19, 76,243,237,225,236,
108,128,247,241,117,128, 3,157, 79,141, 0, 79, 19,118, 19,132,
19,150, 19,203, 20, 78, 20,152, 20,187, 21, 48, 21, 69, 21,213,
21,223, 21,254, 22, 53, 69,129, 1, 82, 19,124,243,237,225,236,
108,128,246,250,225,227,245,244,101,129, 0,211, 19,142,243,237,
225,236,108,128,247,243, 98, 2, 19,156, 19,196,225,242,242,229,
100, 2, 19,166, 19,177,227,249,242,233,236,236,233, 99,128, 4,
232,228,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
99,128, 4,234,242,229,246,101,128, 1, 78, 99, 4, 19,213, 19,
220, 19,235, 20, 68,225,242,239,110,128, 1,209,229,238,244,229,
242,229,228,244,233,236,228,101,128, 1,159,233,242, 99, 2, 19,
243, 19,248,236,101,128, 36,196,245,237,230,236,229,120,134, 0,
212, 20, 13, 20, 21, 20, 32, 20, 40, 20, 52, 20, 60,225,227,245,
244,101,128, 30,208,228,239,244,226,229,236,239,119,128, 30,216,
231,242,225,246,101,128, 30,210,232,239,239,235,225,226,239,246,
101,128, 30,212,243,237,225,236,108,128,247,244,244,233,236,228,
101,128, 30,214,249,242,233,236,236,233, 99,128, 4, 30,100, 3,
20, 86, 20,109, 20,142,226,108, 2, 20, 93, 20,101,225,227,245,
244,101,128, 1, 80,231,242,225,246,101,128, 2, 12,233,229,242,
229,243,233,115,130, 0,214, 20,123, 20,134,227,249,242,233,236,
236,233, 99,128, 4,230,243,237,225,236,108,128,247,246,239,244,
226,229,236,239,119,128, 30,204,103, 2, 20,158, 20,170,239,238,
229,235,243,237,225,236,108,128,246,251,242,225,246,101,129, 0,
210, 20,179,243,237,225,236,108,128,247,242,104, 4, 20,197, 20,
208, 20,212, 21, 34,225,242,237,229,238,233,225,110,128, 5, 85,
109,128, 33, 38,111, 2, 20,218, 20,228,239,235,225,226,239,246,
101,128, 30,206,242,110,133, 1,160, 20,243, 20,251, 21, 6, 21,
14, 21, 26,225,227,245,244,101,128, 30,218,228,239,244,226,229,
236,239,119,128, 30,226,231,242,225,246,101,128, 30,220,232,239,
239,235,225,226,239,246,101,128, 30,222,244,233,236,228,101,128,
30,224,245,238,231,225,242,245,237,236,225,245,116,128, 1, 80,
105,129, 1,162, 21, 54,238,246,229,242,244,229,228,226,242,229,
246,101,128, 2, 14,109, 4, 21, 79, 21,107, 21,184, 21,202,225,
227,242,239,110,130, 1, 76, 21, 91, 21, 99,225,227,245,244,101,
128, 30, 82,231,242,225,246,101,128, 30, 80,229,231, 97,132, 33,
38, 21,121, 21,132, 21,140, 21,156,227,249,242,233,236,236,233,
99,128, 4, 96,231,242,229,229,107,128, 3,169,242,239,245,238,
228,227,249,242,233,236,236,233, 99,128, 4,122,116, 2, 21,162,
21,177,233,244,236,239,227,249,242,233,236,236,233, 99,128, 4,
124,239,238,239,115,128, 3,143,233,227,242,239,110,129, 3,159,
21,194,244,239,238,239,115,128, 3,140,239,238,239,243,240,225,
227,101,128,255, 47,238,229,242,239,237,225,110,128, 33, 96,111,
2, 21,229, 21,248,231,239,238,229,107,129, 1,234, 21,239,237,
225,227,242,239,110,128, 1,236,240,229,110,128, 1,134,115, 3,
22, 6, 22, 33, 22, 40,236,225,243,104,130, 0,216, 22, 17, 22,
25,225,227,245,244,101,128, 1,254,243,237,225,236,108,128,247,
248,237,225,236,108,128,247,111,244,242,239,235,229,225,227,245,
244,101,128, 1,254,116, 2, 22, 59, 22, 70,227,249,242,233,236,
236,233, 99,128, 4,126,233,236,228,101,131, 0,213, 22, 83, 22,
91, 22,102,225,227,245,244,101,128, 30, 76,228,233,229,242,229,
243,233,115,128, 30, 78,243,237,225,236,108,128,247,245, 80,136,
0, 80, 22,130, 22,138, 22,147, 22,159, 22,211, 22,227, 22,246,
23, 2,225,227,245,244,101,128, 30, 84,227,233,242,227,236,101,
128, 36,197,228,239,244,225,227,227,229,238,116,128, 30, 86,101,
3, 22,167, 22,178, 22,190,227,249,242,233,236,236,233, 99,128,
4, 31,232,225,242,237,229,238,233,225,110,128, 5, 74,237,233,
228,228,236,229,232,239,239,235,227,249,242,233,236,236,233, 99,
128, 4,166,104, 2, 22,217, 22,221,105,128, 3,166,239,239,107,
128, 1,164,105,129, 3,160, 22,233,247,242,225,242,237,229,238,
233,225,110,128, 5, 83,237,239,238,239,243,240,225,227,101,128,
255, 48,115, 2, 23, 8, 23, 25,105,129, 3,168, 23, 14,227,249,
242,233,236,236,233, 99,128, 4,112,237,225,236,108,128,247,112,
81,131, 0, 81, 23, 42, 23, 51, 23, 63,227,233,242,227,236,101,
128, 36,198,237,239,238,239,243,240,225,227,101,128,255, 49,243,
237,225,236,108,128,247,113, 82,138, 0, 82, 23, 95, 23,119, 23,
166, 23,217, 23,230, 23,240, 23,245, 24, 19, 24, 31, 24, 43, 97,
2, 23,101, 23,112,225,242,237,229,238,233,225,110,128, 5, 76,
227,245,244,101,128, 1, 84, 99, 4, 23,129, 23,136, 23,145, 23,
153,225,242,239,110,128, 1, 88,229,228,233,236,236, 97,128, 1,
86,233,242,227,236,101,128, 36,199,239,237,237,225,225,227,227,
229,238,116,128, 1, 86,100, 2, 23,172, 23,182,226,236,231,242,
225,246,101,128, 2, 16,239,116, 2, 23,189, 23,198,225,227,227,
229,238,116,128, 30, 88,226,229,236,239,119,129, 30, 90, 23,208,
237,225,227,242,239,110,128, 30, 92,229,232,225,242,237,229,238,
233,225,110,128, 5, 80,230,242,225,235,244,245,114,128, 33, 28,
232,111,128, 3,161,233,110, 2, 23,252, 24, 5,231,243,237,225,
236,108,128,246,252,246,229,242,244,229,228,226,242,229,246,101,
128, 2, 18,236,233,238,229,226,229,236,239,119,128, 30, 94,237,
239,238,239,243,240,225,227,101,128,255, 50,243,237,225,236,108,
129,247,114, 24, 53,233,238,246,229,242,244,229,100,129, 2,129,
24, 66,243,245,240,229,242,233,239,114,128, 2,182, 83,139, 0,
83, 24,103, 26, 17, 26, 55, 26,182, 26,221, 26,250, 27, 84, 27,
105, 27,117, 27,135, 27,143, 70, 6, 24,117, 24,209, 24,241, 25,
77, 25,119, 25,221, 48, 9, 24,137, 24,145, 24,153, 24,161, 24,
169, 24,177, 24,185, 24,193, 24,201,177,176,176,176, 48,128, 37,
12,178,176,176,176, 48,128, 37, 20,179,176,176,176, 48,128, 37,
16,180,176,176,176, 48,128, 37, 24,181,176,176,176, 48,128, 37,
60,182,176,176,176, 48,128, 37, 44,183,176,176,176, 48,128, 37,
52,184,176,176,176, 48,128, 37, 28,185,176,176,176, 48,128, 37,
36, 49, 3, 24,217, 24,225, 24,233,176,176,176,176, 48,128, 37,
0,177,176,176,176, 48,128, 37, 2,185,176,176,176, 48,128, 37,
97, 50, 9, 25, 5, 25, 13, 25, 21, 25, 29, 25, 37, 25, 45, 25,
53, 25, 61, 25, 69,176,176,176,176, 48,128, 37, 98,177,176,176,
176, 48,128, 37, 86,178,176,176,176, 48,128, 37, 85,179,176,176,
176, 48,128, 37, 99,180,176,176,176, 48,128, 37, 81,181,176,176,
176, 48,128, 37, 87,182,176,176,176, 48,128, 37, 93,183,176,176,
176, 48,128, 37, 92,184,176,176,176, 48,128, 37, 91, 51, 4, 25,
87, 25, 95, 25,103, 25,111,182,176,176,176, 48,128, 37, 94,183,
176,176,176, 48,128, 37, 95,184,176,176,176, 48,128, 37, 90,185,
176,176,176, 48,128, 37, 84, 52, 10, 25,141, 25,149, 25,157, 25,
165, 25,173, 25,181, 25,189, 25,197, 25,205, 25,213,176,176,176,
176, 48,128, 37,105,177,176,176,176, 48,128, 37,102,178,176,176,
176, 48,128, 37, 96,179,176,176,176, 48,128, 37, 80,180,176,176,
176, 48,128, 37,108,181,176,176,176, 48,128, 37,103,182,176,176,
176, 48,128, 37,104,183,176,176,176, 48,128, 37,100,184,176,176,
176, 48,128, 37,101,185,176,176,176, 48,128, 37, 89, 53, 5, 25,
233, 25,241, 25,249, 26, 1, 26, 9,176,176,176,176, 48,128, 37,
88,177,176,176,176, 48,128, 37, 82,178,176,176,176, 48,128, 37,
83,179,176,176,176, 48,128, 37,107,180,176,176,176, 48,128, 37,
106, 97, 2, 26, 23, 26, 44,227,245,244,101,129, 1, 90, 26, 32,
228,239,244,225,227,227,229,238,116,128, 30,100,237,240,233,231,
242,229,229,107,128, 3,224, 99, 5, 26, 67, 26, 98, 26,107, 26,
147, 26,169,225,242,239,110,130, 1, 96, 26, 78, 26, 90,228,239,
244,225,227,227,229,238,116,128, 30,102,243,237,225,236,108,128,
246,253,229,228,233,236,236, 97,128, 1, 94,232,247, 97,130, 1,
143, 26,117, 26,128,227,249,242,233,236,236,233, 99,128, 4,216,
228,233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,
128, 4,218,233,242, 99, 2, 26,155, 26,160,236,101,128, 36,200,
245,237,230,236,229,120,128, 1, 92,239,237,237,225,225,227,227,
229,238,116,128, 2, 24,228,239,116, 2, 26,190, 26,199,225,227,
227,229,238,116,128, 30, 96,226,229,236,239,119,129, 30, 98, 26,
209,228,239,244,225,227,227,229,238,116,128, 30,104,101, 2, 26,
227, 26,239,232,225,242,237,229,238,233,225,110,128, 5, 77,246,
229,238,242,239,237,225,110,128, 33,102,104, 5, 27, 6, 27, 34,
27, 48, 27, 59, 27, 72, 97, 2, 27, 12, 27, 23,225,242,237,229,
238,233,225,110,128, 5, 71,227,249,242,233,236,236,233, 99,128,
4, 40,227,232,225,227,249,242,233,236,236,233, 99,128, 4, 41,
229,233,227,239,240,244,233, 99,128, 3,226,232,225,227,249,242,
233,236,236,233, 99,128, 4,186,233,237,225,227,239,240,244,233,
99,128, 3,236,105, 2, 27, 90, 27, 96,231,237, 97,128, 3,163,
248,242,239,237,225,110,128, 33,101,237,239,238,239,243,240,225,
227,101,128,255, 51,239,230,244,243,233,231,238,227,249,242,233,
236,236,233, 99,128, 4, 44,243,237,225,236,108,128,247,115,244,
233,231,237,225,231,242,229,229,107,128, 3,218, 84,141, 0, 84,
27,186, 27,191, 27,197, 28, 7, 28, 32, 28, 96, 28,147, 28,177,
28,189, 28,201, 28,246, 29, 6, 29, 46,225,117,128, 3,164,226,
225,114,128, 1,102, 99, 4, 27,207, 27,214, 27,223, 27,250,225,
242,239,110,128, 1,100,229,228,233,236,236, 97,128, 1, 98,233,
242, 99, 2, 27,231, 27,236,236,101,128, 36,201,245,237,230,236,
229,248,226,229,236,239,119,128, 30,112,239,237,237,225,225,227,
227,229,238,116,128, 1, 98,228,239,116, 2, 28, 15, 28, 24,225,
227,227,229,238,116,128, 30,106,226,229,236,239,119,128, 30,108,
101, 4, 28, 42, 28, 53, 28, 73, 28, 82,227,249,242,233,236,236,
233, 99,128, 4, 34,228,229,243,227,229,238,228,229,242,227,249,
242,233,236,236,233, 99,128, 4,172,238,242,239,237,225,110,128,
33,105,244,243,229,227,249,242,233,236,236,233, 99,128, 4,180,
104, 3, 28,104, 28,110, 28,136,229,244, 97,128, 3,152,111, 2,
28,116, 28,121,239,107,128, 1,172,242,110,129, 0,222, 28,128,
243,237,225,236,108,128,247,254,242,229,229,242,239,237,225,110,
128, 33, 98,105, 2, 28,153, 28,164,236,228,229,243,237,225,236,
108,128,246,254,247,238,225,242,237,229,238,233,225,110,128, 5,
79,236,233,238,229,226,229,236,239,119,128, 30,110,237,239,238,
239,243,240,225,227,101,128,255, 52,111, 2, 28,207, 28,218,225,
242,237,229,238,233,225,110,128, 5, 57,238,101, 3, 28,227, 28,
234, 28,240,230,233,246,101,128, 1,188,243,233,120,128, 1,132,
244,247,111,128, 1,167,242,229,244,242,239,230,236,229,248,232,
239,239,107,128, 1,174,115, 3, 29, 14, 29, 26, 29, 39,229,227,
249,242,233,236,236,233, 99,128, 4, 38,232,229,227,249,242,233,
236,236,233, 99,128, 4, 11,237,225,236,108,128,247,116,119, 2,
29, 52, 29, 64,229,236,246,229,242,239,237,225,110,128, 33,107,
239,242,239,237,225,110,128, 33, 97, 85,142, 0, 85, 29,105, 29,
123, 29,131, 29,198, 30, 69, 30, 87, 30,198, 30,214, 30,226, 31,
21, 31, 30, 31,142, 31,149, 31,219,225,227,245,244,101,129, 0,
218, 29,115,243,237,225,236,108,128,247,250,226,242,229,246,101,
128, 1,108, 99, 3, 29,139, 29,146, 29,188,225,242,239,110,128,
1,211,233,242, 99, 2, 29,154, 29,159,236,101,128, 36,202,245,
237,230,236,229,120,130, 0,219, 29,172, 29,180,226,229,236,239,
119,128, 30,118,243,237,225,236,108,128,247,251,249,242,233,236,
236,233, 99,128, 4, 35,100, 3, 29,206, 29,229, 30, 59,226,108,
2, 29,213, 29,221,225,227,245,244,101,128, 1,112,231,242,225,
246,101,128, 2, 20,233,229,242,229,243,233,115,134, 0,220, 29,
251, 30, 3, 30, 11, 30, 34, 30, 42, 30, 51,225,227,245,244,101,
128, 1,215,226,229,236,239,119,128, 30,114, 99, 2, 30, 17, 30,
24,225,242,239,110,128, 1,217,249,242,233,236,236,233, 99,128,
4,240,231,242,225,246,101,128, 1,219,237,225,227,242,239,110,
128, 1,213,243,237,225,236,108,128,247,252,239,244,226,229,236,
239,119,128, 30,228,231,242,225,246,101,129, 0,217, 30, 79,243,
237,225,236,108,128,247,249,104, 2, 30, 93, 30,171,111, 2, 30,
99, 30,109,239,235,225,226,239,246,101,128, 30,230,242,110,133,
1,175, 30,124, 30,132, 30,143, 30,151, 30,163,225,227,245,244,
101,128, 30,232,228,239,244,226,229,236,239,119,128, 30,240,231,
242,225,246,101,128, 30,234,232,239,239,235,225,226,239,246,101,
128, 30,236,244,233,236,228,101,128, 30,238,245,238,231,225,242,
245,237,236,225,245,116,129, 1,112, 30,187,227,249,242,233,236,
236,233, 99,128, 4,242,233,238,246,229,242,244,229,228,226,242,
229,246,101,128, 2, 22,235,227,249,242,233,236,236,233, 99,128,
4,120,109, 2, 30,232, 31, 10,225,227,242,239,110,130, 1,106,
30,244, 30,255,227,249,242,233,236,236,233, 99,128, 4,238,228,
233,229,242,229,243,233,115,128, 30,122,239,238,239,243,240,225,
227,101,128,255, 53,239,231,239,238,229,107,128, 1,114,240,243,
233,236,239,110,133, 3,165, 31, 49, 31, 53, 31, 90, 31,121, 31,
134, 49,128, 3,210, 97, 2, 31, 59, 31, 81,227,245,244,229,232,
239,239,235,243,249,237,226,239,236,231,242,229,229,107,128, 3,
211,230,242,233,227,225,110,128, 1,177,228,233,229,242,229,243,
233,115,129, 3,171, 31,103,232,239,239,235,243,249,237,226,239,
236,231,242,229,229,107,128, 3,212,232,239,239,235,243,249,237,
226,239,108,128, 3,210,244,239,238,239,115,128, 3,142,242,233,
238,103,128, 1,110,115, 3, 31,157, 31,172, 31,179,232,239,242,
244,227,249,242,233,236,236,233, 99,128, 4, 14,237,225,236,108,
128,247,117,244,242,225,233,231,232,116, 2, 31,191, 31,202,227,
249,242,233,236,236,233, 99,128, 4,174,243,244,242,239,235,229,
227,249,242,233,236,236,233, 99,128, 4,176,244,233,236,228,101,
130, 1,104, 31,231, 31,239,225,227,245,244,101,128, 30,120,226,
229,236,239,119,128, 30,116, 86,136, 0, 86, 32, 11, 32, 20, 32,
31, 32, 60, 32, 67, 32, 79, 32, 91, 32, 99,227,233,242,227,236,
101,128, 36,203,228,239,244,226,229,236,239,119,128, 30,126,101,
2, 32, 37, 32, 48,227,249,242,233,236,236,233, 99,128, 4, 18,
247,225,242,237,229,238,233,225,110,128, 5, 78,232,239,239,107,
128, 1,178,237,239,238,239,243,240,225,227,101,128,255, 54,239,
225,242,237,229,238,233,225,110,128, 5, 72,243,237,225,236,108,
128,247,118,244,233,236,228,101,128, 30,124, 87,134, 0, 87, 32,
123, 32,131, 32,154, 32,194, 32,202, 32,214,225,227,245,244,101,
128, 30,130,227,233,242, 99, 2, 32,140, 32,145,236,101,128, 36,
204,245,237,230,236,229,120,128, 1,116,100, 2, 32,160, 32,170,
233,229,242,229,243,233,115,128, 30,132,239,116, 2, 32,177, 32,
186,225,227,227,229,238,116,128, 30,134,226,229,236,239,119,128,
30,136,231,242,225,246,101,128, 30,128,237,239,238,239,243,240,
225,227,101,128,255, 55,243,237,225,236,108,128,247,119, 88,134,
0, 88, 32,238, 32,247, 33, 18, 33, 31, 33, 35, 33, 47,227,233,
242,227,236,101,128, 36,205,100, 2, 32,253, 33, 7,233,229,242,
229,243,233,115,128, 30,140,239,244,225,227,227,229,238,116,128,
30,138,229,232,225,242,237,229,238,233,225,110,128, 5, 61,105,
128, 3,158,237,239,238,239,243,240,225,227,101,128,255, 56,243,
237,225,236,108,128,247,120, 89,139, 0, 89, 33, 81, 33,116, 33,
139, 33,189, 33,228, 33,236, 33,253, 34, 40, 34, 52, 34, 60, 34,
68, 97, 2, 33, 87, 33,104,227,245,244,101,129, 0,221, 33, 96,
243,237,225,236,108,128,247,253,244,227,249,242,233,236,236,233,
99,128, 4, 98,227,233,242, 99, 2, 33,125, 33,130,236,101,128,
36,206,245,237,230,236,229,120,128, 1,118,100, 2, 33,145, 33,
165,233,229,242,229,243,233,115,129, 1,120, 33,157,243,237,225,
236,108,128,247,255,239,116, 2, 33,172, 33,181,225,227,227,229,
238,116,128, 30,142,226,229,236,239,119,128, 30,244,229,114, 2,
33,196, 33,208,233,227,249,242,233,236,236,233, 99,128, 4, 43,
245,228,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
99,128, 4,248,231,242,225,246,101,128, 30,242,232,239,239,107,
129, 1,179, 33,245,225,226,239,246,101,128, 30,246,105, 3, 34,
5, 34, 16, 34, 27,225,242,237,229,238,233,225,110,128, 5, 69,
227,249,242,233,236,236,233, 99,128, 4, 7,247,238,225,242,237,
229,238,233,225,110,128, 5, 82,237,239,238,239,243,240,225,227,
101,128,255, 57,243,237,225,236,108,128,247,121,244,233,236,228,
101,128, 30,248,245,115, 2, 34, 75, 34,113,226,233,103, 2, 34,
83, 34, 94,227,249,242,233,236,236,233, 99,128, 4,106,233,239,
244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128, 4,
108,236,233,244,244,236,101, 2, 34,124, 34,135,227,249,242,233,
236,236,233, 99,128, 4,102,233,239,244,233,230,233,229,228,227,
249,242,233,236,236,233, 99,128, 4,104, 90,136, 0, 90, 34,174,
34,198, 34,243, 35, 14, 35, 81, 35,173, 35,185, 35,197, 97, 2,
34,180, 34,191,225,242,237,229,238,233,225,110,128, 5, 54,227,
245,244,101,128, 1,121, 99, 2, 34,204, 34,221,225,242,239,110,
129, 1,125, 34,213,243,237,225,236,108,128,246,255,233,242, 99,
2, 34,229, 34,234,236,101,128, 36,207,245,237,230,236,229,120,
128, 30,144,228,239,116,130, 1,123, 34,253, 35, 6,225,227,227,
229,238,116,128, 1,123,226,229,236,239,119,128, 30,146,101, 3,
35, 22, 35, 33, 35, 76,227,249,242,233,236,236,233, 99,128, 4,
23,100, 2, 35, 39, 35, 58,229,243,227,229,238,228,229,242,227,
249,242,233,236,236,233, 99,128, 4,152,233,229,242,229,243,233,
243,227,249,242,233,236,236,233, 99,128, 4,222,244, 97,128, 3,
150,232,101, 4, 35, 92, 35,103, 35,119, 35,130,225,242,237,229,
238,233,225,110,128, 5, 58,226,242,229,246,229,227,249,242,233,
236,236,233, 99,128, 4,193,227,249,242,233,236,236,233, 99,128,
4, 22,100, 2, 35,136, 35,155,229,243,227,229,238,228,229,242,
227,249,242,233,236,236,233, 99,128, 4,150,233,229,242,229,243,
233,243,227,249,242,233,236,236,233, 99,128, 4,220,236,233,238,
229,226,229,236,239,119,128, 30,148,237,239,238,239,243,240,225,
227,101,128,255, 58,115, 2, 35,203, 35,210,237,225,236,108,128,
247,122,244,242,239,235,101,128, 1,181, 97,158, 0, 97, 36, 26,
38,154, 39, 4, 39, 68, 39,132, 39,196, 40, 4, 40, 68, 40,126,
40,190, 41, 70, 41,217, 42,137, 42,237, 43, 17, 49,192, 49,229,
50, 0, 50,225, 51, 7, 52, 96, 52,168, 53,123, 53,132, 54, 5,
56, 13, 57, 3, 57, 50, 57,201, 57,215, 49,138, 39, 1, 36, 50,
36,114, 36,154, 36,218, 37, 26, 37, 90, 37,154, 37,218, 38, 26,
38, 90, 48,138, 39, 33, 36, 74, 36, 78, 36, 82, 36, 86, 36, 90,
36, 94, 36, 98, 36,102, 36,106, 36,110, 48,128, 39, 94, 49,128,
39, 97, 50,128, 39, 98, 51,128, 39, 99, 52,128, 39,100, 53,128,
39, 16, 54,128, 39,101, 55,128, 39,102, 56,128, 39,103, 57,128,
38, 96, 49,134, 38, 27, 36,130, 36,134, 36,138, 36,142, 36,146,
36,150, 48,128, 38,101, 49,128, 38,102, 50,128, 38, 99, 55,128,
39, 9, 56,128, 39, 8, 57,128, 39, 7, 50,138, 38, 30, 36,178,
36,182, 36,186, 36,190, 36,194, 36,198, 36,202, 36,206, 36,210,
36,214, 48,128, 36, 96, 49,128, 36, 97, 50,128, 36, 98, 51,128,
36, 99, 52,128, 36,100, 53,128, 36,101, 54,128, 36,102, 55,128,
36,103, 56,128, 36,104, 57,128, 36,105, 51,138, 39, 12, 36,242,
36,246, 36,250, 36,254, 37, 2, 37, 6, 37, 10, 37, 14, 37, 18,
37, 22, 48,128, 39,118, 49,128, 39,119, 50,128, 39,120, 51,128,
39,121, 52,128, 39,122, 53,128, 39,123, 54,128, 39,124, 55,128,
39,125, 56,128, 39,126, 57,128, 39,127, 52,138, 39, 13, 37, 50,
37, 54, 37, 58, 37, 62, 37, 66, 37, 70, 37, 74, 37, 78, 37, 82,
37, 86, 48,128, 39,128, 49,128, 39,129, 50,128, 39,130, 51,128,
39,131, 52,128, 39,132, 53,128, 39,133, 54,128, 39,134, 55,128,
39,135, 56,128, 39,136, 57,128, 39,137, 53,138, 39, 14, 37,114,
37,118, 37,122, 37,126, 37,130, 37,134, 37,138, 37,142, 37,146,
37,150, 48,128, 39,138, 49,128, 39,139, 50,128, 39,140, 51,128,
39,141, 52,128, 39,142, 53,128, 39,143, 54,128, 39,144, 55,128,
39,145, 56,128, 39,146, 57,128, 39,147, 54,138, 39, 15, 37,178,
37,182, 37,186, 37,190, 37,194, 37,198, 37,202, 37,206, 37,210,
37,214, 48,128, 39,148, 49,128, 33,146, 50,128, 39,163, 51,128,
33,148, 52,128, 33,149, 53,128, 39,153, 54,128, 39,155, 55,128,
39,156, 56,128, 39,157, 57,128, 39,158, 55,138, 39, 17, 37,242,
37,246, 37,250, 37,254, 38, 2, 38, 6, 38, 10, 38, 14, 38, 18,
38, 22, 48,128, 39,159, 49,128, 39,160, 50,128, 39,161, 51,128,
39,162, 52,128, 39,164, 53,128, 39,165, 54,128, 39,166, 55,128,
39,167, 56,128, 39,168, 57,128, 39,169, 56,138, 39, 18, 38, 50,
38, 54, 38, 58, 38, 62, 38, 66, 38, 70, 38, 74, 38, 78, 38, 82,
38, 86, 48,128, 39,171, 49,128, 39,173, 50,128, 39,175, 51,128,
39,178, 52,128, 39,179, 53,128, 39,181, 54,128, 39,184, 55,128,
39,186, 56,128, 39,187, 57,128, 39,188, 57,138, 39, 19, 38,114,
38,118, 38,122, 38,126, 38,130, 38,134, 38,138, 38,142, 38,146,
38,150, 48,128, 39,189, 49,128, 39,190, 50,128, 39,154, 51,128,
39,170, 52,128, 39,182, 53,128, 39,185, 54,128, 39,152, 55,128,
39,180, 56,128, 39,183, 57,128, 39,172, 50,138, 39, 2, 38,178,
38,224, 38,228, 38,232, 38,236, 38,240, 38,244, 38,248, 38,252,
39, 0, 48,135, 39, 20, 38,196, 38,200, 38,204, 38,208, 38,212,
38,216, 38,220, 48,128, 39,174, 49,128, 39,177, 50,128, 39, 3,
51,128, 39, 80, 52,128, 39, 82, 53,128, 39,110, 54,128, 39,112,
49,128, 39, 21, 50,128, 39, 22, 51,128, 39, 23, 52,128, 39, 24,
53,128, 39, 25, 54,128, 39, 26, 55,128, 39, 27, 56,128, 39, 28,
57,128, 39, 34, 51,138, 39, 4, 39, 28, 39, 32, 39, 36, 39, 40,
39, 44, 39, 48, 39, 52, 39, 56, 39, 60, 39, 64, 48,128, 39, 35,
49,128, 39, 36, 50,128, 39, 37, 51,128, 39, 38, 52,128, 39, 39,
53,128, 38, 5, 54,128, 39, 41, 55,128, 39, 42, 56,128, 39, 43,
57,128, 39, 44, 52,138, 38, 14, 39, 92, 39, 96, 39,100, 39,104,
39,108, 39,112, 39,116, 39,120, 39,124, 39,128, 48,128, 39, 45,
49,128, 39, 46, 50,128, 39, 47, 51,128, 39, 48, 52,128, 39, 49,
53,128, 39, 50, 54,128, 39, 51, 55,128, 39, 52, 56,128, 39, 53,
57,128, 39, 54, 53,138, 39, 6, 39,156, 39,160, 39,164, 39,168,
39,172, 39,176, 39,180, 39,184, 39,188, 39,192, 48,128, 39, 55,
49,128, 39, 56, 50,128, 39, 57, 51,128, 39, 58, 52,128, 39, 59,
53,128, 39, 60, 54,128, 39, 61, 55,128, 39, 62, 56,128, 39, 63,
57,128, 39, 64, 54,138, 39, 29, 39,220, 39,224, 39,228, 39,232,
39,236, 39,240, 39,244, 39,248, 39,252, 40, 0, 48,128, 39, 65,
49,128, 39, 66, 50,128, 39, 67, 51,128, 39, 68, 52,128, 39, 69,
53,128, 39, 70, 54,128, 39, 71, 55,128, 39, 72, 56,128, 39, 73,
57,128, 39, 74, 55,138, 39, 30, 40, 28, 40, 32, 40, 36, 40, 40,
40, 44, 40, 48, 40, 52, 40, 56, 40, 60, 40, 64, 48,128, 39, 75,
49,128, 37,207, 50,128, 39, 77, 51,128, 37,160, 52,128, 39, 79,
53,128, 39, 81, 54,128, 37,178, 55,128, 37,188, 56,128, 37,198,
57,128, 39, 86, 56,137, 39, 31, 40, 90, 40, 94, 40, 98, 40,102,
40,106, 40,110, 40,114, 40,118, 40,122, 49,128, 37,215, 50,128,
39, 88, 51,128, 39, 89, 52,128, 39, 90, 53,128, 39,111, 54,128,
39,113, 55,128, 39,114, 56,128, 39,115, 57,128, 39,104, 57,138,
39, 32, 40,150, 40,154, 40,158, 40,162, 40,166, 40,170, 40,174,
40,178, 40,182, 40,186, 48,128, 39,105, 49,128, 39,108, 50,128,
39,109, 51,128, 39,106, 52,128, 39,107, 53,128, 39,116, 54,128,
39,117, 55,128, 39, 91, 56,128, 39, 92, 57,128, 39, 93, 97, 7,
40,206, 40,216, 40,223, 40,230, 40,255, 41, 15, 41, 26,226,229,
238,231,225,236,105,128, 9,134,227,245,244,101,128, 0,225,228,
229,246, 97,128, 9, 6,231,117, 2, 40,237, 40,246,234,225,242,
225,244,105,128, 10,134,242,237,245,235,232,105,128, 10, 6,237,
225,244,242,225,231,245,242,237,245,235,232,105,128, 10, 62,242,
245,243,241,245,225,242,101,128, 51, 3,246,239,247,229,236,243,
233,231,110, 3, 41, 42, 41, 52, 41, 59,226,229,238,231,225,236,
105,128, 9,190,228,229,246, 97,128, 9, 62,231,245,234,225,242,
225,244,105,128, 10,190, 98, 4, 41, 80, 41,121, 41,130, 41,140,
226,242,229,246,233,225,244,233,239,110, 2, 41, 95, 41,110,237,
225,242,235,225,242,237,229,238,233,225,110,128, 5, 95,243,233,
231,238,228,229,246, 97,128, 9,112,229,238,231,225,236,105,128,
9,133,239,240,239,237,239,230,111,128, 49, 26,242,229,246,101,
134, 1, 3, 41,159, 41,167, 41,178, 41,189, 41,197, 41,209,225,
227,245,244,101,128, 30,175,227,249,242,233,236,236,233, 99,128,
4,209,228,239,244,226,229,236,239,119,128, 30,183,231,242,225,
246,101,128, 30,177,232,239,239,235,225,226,239,246,101,128, 30,
179,244,233,236,228,101,128, 30,181, 99, 4, 41,227, 41,234, 42,
57, 42,127,225,242,239,110,128, 1,206,233,242, 99, 2, 41,242,
41,247,236,101,128, 36,208,245,237,230,236,229,120,133, 0,226,
42, 10, 42, 18, 42, 29, 42, 37, 42, 49,225,227,245,244,101,128,
30,165,228,239,244,226,229,236,239,119,128, 30,173,231,242,225,
246,101,128, 30,167,232,239,239,235,225,226,239,246,101,128, 30,
169,244,233,236,228,101,128, 30,171,245,244,101,133, 0,180, 42,
73, 42, 84, 42,101, 42,108, 42,117,226,229,236,239,247,227,237,
98,128, 3, 23, 99, 2, 42, 90, 42, 95,237, 98,128, 3, 1,239,
237, 98,128, 3, 1,228,229,246, 97,128, 9, 84,236,239,247,237,
239,100,128, 2,207,244,239,238,229,227,237, 98,128, 3, 65,249,
242,233,236,236,233, 99,128, 4, 48,100, 5, 42,149, 42,159, 42,
173, 42,179, 42,213,226,236,231,242,225,246,101,128, 2, 1,228,
225,235,231,245,242,237,245,235,232,105,128, 10,113,229,246, 97,
128, 9, 5,233,229,242,229,243,233,115,130, 0,228, 42,193, 42,
204,227,249,242,233,236,236,233, 99,128, 4,211,237,225,227,242,
239,110,128, 1,223,239,116, 2, 42,220, 42,228,226,229,236,239,
119,128, 30,161,237,225,227,242,239,110,128, 1,225,101,131, 0,
230, 42,247, 42,255, 43, 8,225,227,245,244,101,128, 1,253,235,
239,242,229,225,110,128, 49, 80,237,225,227,242,239,110,128, 1,
227,230,233,105, 6, 43, 33, 43, 53, 45,246, 45,252, 46, 11, 49,
111, 48, 2, 43, 39, 43, 46,176,178,176, 56,128, 32, 21,184,185,
180, 49,128, 32,164,177, 48, 3, 43, 62, 45, 86, 45,221, 48, 9,
43, 82, 43,102, 43,164, 43,226, 44, 32, 44, 94, 44,156, 44,218,
45, 24, 49, 3, 43, 90, 43, 94, 43, 98, 55,128, 4, 16, 56,128,
4, 17, 57,128, 4, 18, 50, 10, 43,124, 43,128, 43,132, 43,136,
43,140, 43,144, 43,148, 43,152, 43,156, 43,160, 48,128, 4, 19,
49,128, 4, 20, 50,128, 4, 21, 51,128, 4, 1, 52,128, 4, 22,
53,128, 4, 23, 54,128, 4, 24, 55,128, 4, 25, 56,128, 4, 26,
57,128, 4, 27, 51, 10, 43,186, 43,190, 43,194, 43,198, 43,202,
43,206, 43,210, 43,214, 43,218, 43,222, 48,128, 4, 28, 49,128,
4, 29, 50,128, 4, 30, 51,128, 4, 31, 52,128, 4, 32, 53,128,
4, 33, 54,128, 4, 34, 55,128, 4, 35, 56,128, 4, 36, 57,128,
4, 37, 52, 10, 43,248, 43,252, 44, 0, 44, 4, 44, 8, 44, 12,
44, 16, 44, 20, 44, 24, 44, 28, 48,128, 4, 38, 49,128, 4, 39,
50,128, 4, 40, 51,128, 4, 41, 52,128, 4, 42, 53,128, 4, 43,
54,128, 4, 44, 55,128, 4, 45, 56,128, 4, 46, 57,128, 4, 47,
53, 10, 44, 54, 44, 58, 44, 62, 44, 66, 44, 70, 44, 74, 44, 78,
44, 82, 44, 86, 44, 90, 48,128, 4,144, 49,128, 4, 2, 50,128,
4, 3, 51,128, 4, 4, 52,128, 4, 5, 53,128, 4, 6, 54,128,
4, 7, 55,128, 4, 8, 56,128, 4, 9, 57,128, 4, 10, 54, 10,
44,116, 44,120, 44,124, 44,128, 44,132, 44,136, 44,140, 44,144,
44,148, 44,152, 48,128, 4, 11, 49,128, 4, 12, 50,128, 4, 14,
51,128,246,196, 52,128,246,197, 53,128, 4, 48, 54,128, 4, 49,
55,128, 4, 50, 56,128, 4, 51, 57,128, 4, 52, 55, 10, 44,178,
44,182, 44,186, 44,190, 44,194, 44,198, 44,202, 44,206, 44,210,
44,214, 48,128, 4, 53, 49,128, 4, 81, 50,128, 4, 54, 51,128,
4, 55, 52,128, 4, 56, 53,128, 4, 57, 54,128, 4, 58, 55,128,
4, 59, 56,128, 4, 60, 57,128, 4, 61, 56, 10, 44,240, 44,244,
44,248, 44,252, 45, 0, 45, 4, 45, 8, 45, 12, 45, 16, 45, 20,
48,128, 4, 62, 49,128, 4, 63, 50,128, 4, 64, 51,128, 4, 65,
52,128, 4, 66, 53,128, 4, 67, 54,128, 4, 68, 55,128, 4, 69,
56,128, 4, 70, 57,128, 4, 71, 57, 10, 45, 46, 45, 50, 45, 54,
45, 58, 45, 62, 45, 66, 45, 70, 45, 74, 45, 78, 45, 82, 48,128,
4, 72, 49,128, 4, 73, 50,128, 4, 74, 51,128, 4, 75, 52,128,
4, 76, 53,128, 4, 77, 54,128, 4, 78, 55,128, 4, 79, 56,128,
4,145, 57,128, 4, 82, 49, 4, 45, 96, 45,158, 45,163, 45,189,
48, 10, 45,118, 45,122, 45,126, 45,130, 45,134, 45,138, 45,142,
45,146, 45,150, 45,154, 48,128, 4, 83, 49,128, 4, 84, 50,128,
4, 85, 51,128, 4, 86, 52,128, 4, 87, 53,128, 4, 88, 54,128,
4, 89, 55,128, 4, 90, 56,128, 4, 91, 57,128, 4, 92,177, 48,
128, 4, 94, 52, 4, 45,173, 45,177, 45,181, 45,185, 53,128, 4,
15, 54,128, 4, 98, 55,128, 4,114, 56,128, 4,116, 57, 5, 45,
201, 45,205, 45,209, 45,213, 45,217, 50,128,246,198, 51,128, 4,
95, 52,128, 4, 99, 53,128, 4,115, 54,128, 4,117, 56, 2, 45,
227, 45,241, 51, 2, 45,233, 45,237, 49,128,246,199, 50,128,246,
200,180, 54,128, 4,217,178,185, 57,128, 32, 14,179, 48, 2, 46,
3, 46, 7, 48,128, 32, 15, 49,128, 32, 13,181, 55, 7, 46, 28,
46, 98, 47,163, 47,240, 48,197, 49, 34, 49,105, 51, 2, 46, 34,
46, 48, 56, 2, 46, 40, 46, 44, 49,128, 6,106, 56,128, 6, 12,
57, 8, 46, 66, 46, 70, 46, 74, 46, 78, 46, 82, 46, 86, 46, 90,
46, 94, 50,128, 6, 96, 51,128, 6, 97, 52,128, 6, 98, 53,128,
6, 99, 54,128, 6,100, 55,128, 6,101, 56,128, 6,102, 57,128,
6,103, 52, 7, 46,114, 46,146, 46,208, 47, 14, 47, 46, 47,102,
47,158, 48, 5, 46,126, 46,130, 46,134, 46,138, 46,142, 48,128,
6,104, 49,128, 6,105, 51,128, 6, 27, 55,128, 6, 31, 57,128,
6, 33, 49, 10, 46,168, 46,172, 46,176, 46,180, 46,184, 46,188,
46,192, 46,196, 46,200, 46,204, 48,128, 6, 34, 49,128, 6, 35,
50,128, 6, 36, 51,128, 6, 37, 52,128, 6, 38, 53,128, 6, 39,
54,128, 6, 40, 55,128, 6, 41, 56,128, 6, 42, 57,128, 6, 43,
50, 10, 46,230, 46,234, 46,238, 46,242, 46,246, 46,250, 46,254,
47, 2, 47, 6, 47, 10, 48,128, 6, 44, 49,128, 6, 45, 50,128,
6, 46, 51,128, 6, 47, 52,128, 6, 48, 53,128, 6, 49, 54,128,
6, 50, 55,128, 6, 51, 56,128, 6, 52, 57,128, 6, 53, 51, 5,
47, 26, 47, 30, 47, 34, 47, 38, 47, 42, 48,128, 6, 54, 49,128,
6, 55, 50,128, 6, 56, 51,128, 6, 57, 52,128, 6, 58, 52, 9,
47, 66, 47, 70, 47, 74, 47, 78, 47, 82, 47, 86, 47, 90, 47, 94,
47, 98, 48,128, 6, 64, 49,128, 6, 65, 50,128, 6, 66, 51,128,
6, 67, 52,128, 6, 68, 53,128, 6, 69, 54,128, 6, 70, 56,128,
6, 72, 57,128, 6, 73, 53, 9, 47,122, 47,126, 47,130, 47,134,
47,138, 47,142, 47,146, 47,150, 47,154, 48,128, 6, 74, 49,128,
6, 75, 50,128, 6, 76, 51,128, 6, 77, 52,128, 6, 78, 53,128,
6, 79, 54,128, 6, 80, 55,128, 6, 81, 56,128, 6, 82,183, 48,
128, 6, 71, 53, 3, 47,171, 47,203, 47,235, 48, 5, 47,183, 47,
187, 47,191, 47,195, 47,199, 53,128, 6,164, 54,128, 6,126, 55,
128, 6,134, 56,128, 6,152, 57,128, 6,175, 49, 5, 47,215, 47,
219, 47,223, 47,227, 47,231, 49,128, 6,121, 50,128, 6,136, 51,
128, 6,145, 52,128, 6,186, 57,128, 6,210,179, 52,128, 6,213,
54, 7, 48, 0, 48, 5, 48, 10, 48, 15, 48, 53, 48,115, 48,177,
179, 54,128, 32,170,180, 53,128, 5,190,181, 56,128, 5,195, 54,
6, 48, 29, 48, 33, 48, 37, 48, 41, 48, 45, 48, 49, 52,128, 5,
208, 53,128, 5,209, 54,128, 5,210, 55,128, 5,211, 56,128, 5,
212, 57,128, 5,213, 55, 10, 48, 75, 48, 79, 48, 83, 48, 87, 48,
91, 48, 95, 48, 99, 48,103, 48,107, 48,111, 48,128, 5,214, 49,
128, 5,215, 50,128, 5,216, 51,128, 5,217, 52,128, 5,218, 53,
128, 5,219, 54,128, 5,220, 55,128, 5,221, 56,128, 5,222, 57,
128, 5,223, 56, 10, 48,137, 48,141, 48,145, 48,149, 48,153, 48,
157, 48,161, 48,165, 48,169, 48,173, 48,128, 5,224, 49,128, 5,
225, 50,128, 5,226, 51,128, 5,227, 52,128, 5,228, 53,128, 5,
229, 54,128, 5,230, 55,128, 5,231, 56,128, 5,232, 57,128, 5,
233, 57, 3, 48,185, 48,189, 48,193, 48,128, 5,234, 52,128,251,
42, 53,128,251, 43, 55, 4, 48,207, 48,221, 48,241, 48,246, 48,
2, 48,213, 48,217, 48,128,251, 75, 53,128,251, 31, 49, 3, 48,
229, 48,233, 48,237, 54,128, 5,240, 55,128, 5,241, 56,128, 5,
242,178, 51,128,251, 53, 57, 7, 49, 6, 49, 10, 49, 14, 49, 18,
49, 22, 49, 26, 49, 30, 51,128, 5,180, 52,128, 5,181, 53,128,
5,182, 54,128, 5,187, 55,128, 5,184, 56,128, 5,183, 57,128,
5,176, 56, 3, 49, 42, 49, 86, 49, 91, 48, 7, 49, 58, 49, 62,
49, 66, 49, 70, 49, 74, 49, 78, 49, 82, 48,128, 5,178, 49,128,
5,177, 50,128, 5,179, 51,128, 5,194, 52,128, 5,193, 54,128,
5,185, 55,128, 5,188,179, 57,128, 5,189, 52, 2, 49, 97, 49,
101, 49,128, 5,191, 50,128, 5,192,185,178, 57,128, 2,188, 54,
3, 49,119, 49,178, 49,185, 49, 4, 49,129, 49,145, 49,151, 49,
172, 50, 2, 49,135, 49,140,180, 56,128, 33, 5,184, 57,128, 33,
19,179,181, 50,128, 33, 22,181, 55, 3, 49,160, 49,164, 49,168,
51,128, 32, 44, 52,128, 32, 45, 53,128, 32, 46,182,182, 52,128,
32, 12,179,177,182, 55,128, 6,109,180,185,179, 55,128, 2,189,
103, 2, 49,198, 49,205,242,225,246,101,128, 0,224,117, 2, 49,
211, 49,220,234,225,242,225,244,105,128, 10,133,242,237,245,235,
232,105,128, 10, 5,104, 2, 49,235, 49,245,233,242,225,231,225,
238, 97,128, 48, 66,239,239,235,225,226,239,246,101,128, 30,163,
105, 7, 50, 16, 50, 41, 50, 48, 50, 60, 50, 85, 50,101, 50,181,
98, 2, 50, 22, 50, 31,229,238,231,225,236,105,128, 9,144,239,
240,239,237,239,230,111,128, 49, 30,228,229,246, 97,128, 9, 16,
229,227,249,242,233,236,236,233, 99,128, 4,213,231,117, 2, 50,
67, 50, 76,234,225,242,225,244,105,128, 10,144,242,237,245,235,
232,105,128, 10, 16,237,225,244,242,225,231,245,242,237,245,235,
232,105,128, 10, 72,110, 5, 50,113, 50,122, 50,136, 50,152, 50,
167,225,242,225,226,233, 99,128, 6, 57,230,233,238,225,236,225,
242,225,226,233, 99,128,254,202,233,238,233,244,233,225,236,225,
242,225,226,233, 99,128,254,203,237,229,228,233,225,236,225,242,
225,226,233, 99,128,254,204,246,229,242,244,229,228,226,242,229,
246,101,128, 2, 3,246,239,247,229,236,243,233,231,110, 3, 50,
197, 50,207, 50,214,226,229,238,231,225,236,105,128, 9,200,228,
229,246, 97,128, 9, 72,231,245,234,225,242,225,244,105,128, 10,
200,107, 2, 50,231, 50,255,225,244,225,235,225,238, 97,129, 48,
162, 50,243,232,225,236,230,247,233,228,244,104,128,255,113,239,
242,229,225,110,128, 49, 79,108, 3, 51, 15, 52, 71, 52, 80,101,
2, 51, 21, 52, 66,102,136, 5,208, 51, 41, 51, 50, 51, 65, 51,
79, 51,168, 51,182, 52, 37, 52, 51,225,242,225,226,233, 99,128,
6, 39,228,225,231,229,243,232,232,229,226,242,229,119,128,251,
48,230,233,238,225,236,225,242,225,226,233, 99,128,254,142,104,
2, 51, 85, 51,160,225,237,250, 97, 2, 51, 94, 51,127,225,226,
239,246,101, 2, 51,104, 51,113,225,242,225,226,233, 99,128, 6,
35,230,233,238,225,236,225,242,225,226,233, 99,128,254,132,226,
229,236,239,119, 2, 51,137, 51,146,225,242,225,226,233, 99,128,
6, 37,230,233,238,225,236,225,242,225,226,233, 99,128,254,136,
229,226,242,229,119,128, 5,208,236,225,237,229,228,232,229,226,
242,229,119,128,251, 79,237, 97, 2, 51,189, 51,225,228,228,225,
225,226,239,246,101, 2, 51,202, 51,211,225,242,225,226,233, 99,
128, 6, 34,230,233,238,225,236,225,242,225,226,233, 99,128,254,
130,235,243,245,242, 97, 4, 51,239, 51,248, 52, 6, 52, 22,225,
242,225,226,233, 99,128, 6, 73,230,233,238,225,236,225,242,225,
226,233, 99,128,254,240,233,238,233,244,233,225,236,225,242,225,
226,233, 99,128,254,243,237,229,228,233,225,236,225,242,225,226,
233, 99,128,254,244,240,225,244,225,232,232,229,226,242,229,119,
128,251, 46,241,225,237,225,244,243,232,229,226,242,229,119,128,
251, 47,240,104,128, 33, 53,236,229,241,245,225,108,128, 34, 76,
240,232, 97,129, 3,177, 52, 88,244,239,238,239,115,128, 3,172,
109, 4, 52,106, 52,114, 52,125, 52,159,225,227,242,239,110,128,
1, 1,239,238,239,243,240,225,227,101,128,255, 65,240,229,242,
243,225,238,100,130, 0, 38, 52,139, 52,151,237,239,238,239,243,
240,225,227,101,128,255, 6,243,237,225,236,108,128,247, 38,243,
241,245,225,242,101,128, 51,194,110, 4, 52,178, 52,189, 53, 55,
53, 65,226,239,240,239,237,239,230,111,128, 49, 34,103, 4, 52,
199, 52,210, 52,224, 53, 47,226,239,240,239,237,239,230,111,128,
49, 36,235,232,225,238,235,232,245,244,232,225,105,128, 14, 90,
236,101,131, 34, 32, 52,235, 53, 32, 53, 39,226,242,225,227,235,
229,116, 2, 52,247, 53, 11,236,229,230,116,129, 48, 8, 53, 0,
246,229,242,244,233,227,225,108,128,254, 63,242,233,231,232,116,
129, 48, 9, 53, 21,246,229,242,244,233,227,225,108,128,254, 64,
236,229,230,116,128, 35, 41,242,233,231,232,116,128, 35, 42,243,
244,242,239,109,128, 33, 43,239,244,229,236,229,233, 97,128, 3,
135,117, 2, 53, 71, 53, 83,228,225,244,244,225,228,229,246, 97,
128, 9, 82,243,246,225,242, 97, 3, 53, 95, 53,105, 53,112,226,
229,238,231,225,236,105,128, 9,130,228,229,246, 97,128, 9, 2,
231,245,234,225,242,225,244,105,128, 10,130,239,231,239,238,229,
107,128, 1, 5,112, 3, 53,140, 53,164, 53,194, 97, 2, 53,146,
53,158,225,244,239,243,241,245,225,242,101,128, 51, 0,242,229,
110,128, 36,156,239,243,244,242,239,240,232,101, 2, 53,177, 53,
188,225,242,237,229,238,233,225,110,128, 5, 90,237,239,100,128,
2,188,112, 2, 53,200, 53,205,236,101,128,248,255,242,111, 2,
53,212, 53,220,225,227,232,229,115,128, 34, 80,120, 2, 53,226,
53,246,229,241,245,225,108,129, 34, 72, 53,236,239,242,233,237,
225,231,101,128, 34, 82,233,237,225,244,229,236,249,229,241,245,
225,108,128, 34, 69,114, 4, 54, 15, 54, 42, 54, 46, 54, 91,225,
229, 97, 2, 54, 23, 54, 33,229,235,239,242,229,225,110,128, 49,
142,235,239,242,229,225,110,128, 49,141, 99,128, 35, 18,105, 2,
54, 52, 54, 66,231,232,244,232,225,236,230,242,233,238,103,128,
30,154,238,103,130, 0,229, 54, 75, 54, 83,225,227,245,244,101,
128, 1,251,226,229,236,239,119,128, 30, 1,242,239,119, 8, 54,
111, 54,118, 54,247, 55, 57, 55,107, 55,162, 55,185, 56, 4,226,
239,244,104,128, 33,148,100, 3, 54,126, 54,165, 54,212,225,243,
104, 4, 54,138, 54,145, 54,152, 54,160,228,239,247,110,128, 33,
227,236,229,230,116,128, 33,224,242,233,231,232,116,128, 33,226,
245,112,128, 33,225,226,108, 5, 54,178, 54,185, 54,192, 54,199,
54,207,226,239,244,104,128, 33,212,228,239,247,110,128, 33,211,
236,229,230,116,128, 33,208,242,233,231,232,116,128, 33,210,245,
112,128, 33,209,239,247,110,131, 33,147, 54,224, 54,231, 54,239,
236,229,230,116,128, 33,153,242,233,231,232,116,128, 33,152,247,
232,233,244,101,128, 33,233,104, 2, 54,253, 55, 48,229,225,100,
4, 55, 9, 55, 19, 55, 29, 55, 40,228,239,247,238,237,239,100,
128, 2,197,236,229,230,244,237,239,100,128, 2,194,242,233,231,
232,244,237,239,100,128, 2,195,245,240,237,239,100,128, 2,196,
239,242,233,250,229,120,128,248,231,236,229,230,116,131, 33,144,
55, 70, 55, 87, 55, 99,228,226,108,129, 33,208, 55, 78,243,244,
242,239,235,101,128, 33,205,239,246,229,242,242,233,231,232,116,
128, 33,198,247,232,233,244,101,128, 33,230,242,233,231,232,116,
132, 33,146, 55,123, 55,135, 55,143, 55,154,228,226,236,243,244,
242,239,235,101,128, 33,207,232,229,225,246,121,128, 39,158,239,
246,229,242,236,229,230,116,128, 33,196,247,232,233,244,101,128,
33,232,244,225, 98, 2, 55,170, 55,177,236,229,230,116,128, 33,
228,242,233,231,232,116,128, 33,229,245,112,132, 33,145, 55,198,
55,226, 55,244, 55,252,100, 2, 55,204, 55,216,110,129, 33,149,
55,210,226,243,101,128, 33,168,239,247,238,226,225,243,101,128,
33,168,236,229,230,116,129, 33,150, 55,235,239,230,228,239,247,
110,128, 33,197,242,233,231,232,116,128, 33,151,247,232,233,244,
101,128, 33,231,246,229,242,244,229,120,128,248,230,115, 5, 56,
25, 56,101, 56,146, 56,229, 56,239, 99, 2, 56, 31, 56, 83,233,
105, 2, 56, 38, 56, 61,227,233,242,227,245,109,129, 0, 94, 56,
49,237,239,238,239,243,240,225,227,101,128,255, 62,244,233,236,
228,101,129, 0,126, 56, 71,237,239,238,239,243,240,225,227,101,
128,255, 94,242,233,240,116,129, 2, 81, 56, 92,244,245,242,238,
229,100,128, 2, 82,237,225,236,108, 2, 56,110, 56,121,232,233,
242,225,231,225,238, 97,128, 48, 65,235,225,244,225,235,225,238,
97,129, 48,161, 56,134,232,225,236,230,247,233,228,244,104,128,
255,103,244,229,242,233,115, 2, 56,156, 56,225,107,131, 0, 42,
56,166, 56,194, 56,217, 97, 2, 56,172, 56,186,236,244,239,238,
229,225,242,225,226,233, 99,128, 6,109,242,225,226,233, 99,128,
6,109,109, 2, 56,200, 56,206,225,244,104,128, 34, 23,239,238,
239,243,240,225,227,101,128,255, 10,243,237,225,236,108,128,254,
97,109,128, 32, 66,245,240,229,242,233,239,114,128,246,233,249,
237,240,244,239,244,233,227,225,236,236,249,229,241,245,225,108,
128, 34, 67,116,132, 0, 64, 57, 15, 57, 22, 57, 34, 57, 42,233,
236,228,101,128, 0,227,237,239,238,239,243,240,225,227,101,128,
255, 32,243,237,225,236,108,128,254,107,245,242,238,229,100,128,
2, 80,117, 6, 57, 64, 57, 89, 57, 96, 57,121, 57,141, 57,157,
98, 2, 57, 70, 57, 79,229,238,231,225,236,105,128, 9,148,239,
240,239,237,239,230,111,128, 49, 32,228,229,246, 97,128, 9, 20,
231,117, 2, 57,103, 57,112,234,225,242,225,244,105,128, 10,148,
242,237,245,235,232,105,128, 10, 20,236,229,238,231,244,232,237,
225,242,235,226,229,238,231,225,236,105,128, 9,215,237,225,244,
242,225,231,245,242,237,245,235,232,105,128, 10, 76,246,239,247,
229,236,243,233,231,110, 3, 57,173, 57,183, 57,190,226,229,238,
231,225,236,105,128, 9,204,228,229,246, 97,128, 9, 76,231,245,
234,225,242,225,244,105,128, 10,204,246,225,231,242,225,232,225,
228,229,246, 97,128, 9, 61,121, 2, 57,221, 57,233,226,225,242,
237,229,238,233,225,110,128, 5, 97,233,110,130, 5,226, 57,242,
58, 1,225,236,244,239,238,229,232,229,226,242,229,119,128,251,
32,232,229,226,242,229,119,128, 5,226, 98,144, 0, 98, 58, 46,
58,181, 58,192, 58,201, 58,226, 60, 11, 60, 73, 60,146, 62, 72,
62, 84, 62,127, 62,135, 62,145, 64, 15, 64, 39, 64, 48, 97, 7,
58, 62, 58, 72, 58, 96, 58,103, 58,128, 58,152, 58,163,226,229,
238,231,225,236,105,128, 9,172,227,235,243,236,225,243,104,129,
0, 92, 58, 84,237,239,238,239,243,240,225,227,101,128,255, 60,
228,229,246, 97,128, 9, 44,231,117, 2, 58,110, 58,119,234,225,
242,225,244,105,128, 10,172,242,237,245,235,232,105,128, 10, 44,
104, 2, 58,134, 58,144,233,242,225,231,225,238, 97,128, 48,112,
244,244,232,225,105,128, 14, 63,235,225,244,225,235,225,238, 97,
128, 48,208,114,129, 0,124, 58,169,237,239,238,239,243,240,225,
227,101,128,255, 92,226,239,240,239,237,239,230,111,128, 49, 5,
227,233,242,227,236,101,128, 36,209,228,239,116, 2, 58,209, 58,
218,225,227,227,229,238,116,128, 30, 3,226,229,236,239,119,128,
30, 5,101, 6, 58,240, 59, 5, 59, 28, 59,170, 59,181, 59,193,
225,237,229,228,243,233,248,244,229,229,238,244,232,238,239,244,
229,115,128, 38,108, 99, 2, 59, 11, 59, 18,225,245,243,101,128,
34, 53,249,242,233,236,236,233, 99,128, 4, 49,104, 5, 59, 40,
59, 49, 59, 63, 59, 93, 59,152,225,242,225,226,233, 99,128, 6,
40,230,233,238,225,236,225,242,225,226,233, 99,128,254,144,105,
2, 59, 69, 59, 84,238,233,244,233,225,236,225,242,225,226,233,
99,128,254,145,242,225,231,225,238, 97,128, 48,121,237,101, 2,
59,100, 59,113,228,233,225,236,225,242,225,226,233, 99,128,254,
146,229,237,105, 2, 59,121, 59,136,238,233,244,233,225,236,225,
242,225,226,233, 99,128,252,159,243,239,236,225,244,229,228,225,
242,225,226,233, 99,128,252, 8,238,239,239,238,230,233,238,225,
236,225,242,225,226,233, 99,128,252,109,235,225,244,225,235,225,
238, 97,128, 48,217,238,225,242,237,229,238,233,225,110,128, 5,
98,116,132, 5,209, 59,205, 59,225, 59,245, 59,254, 97,129, 3,
178, 59,211,243,249,237,226,239,236,231,242,229,229,107,128, 3,
208,228,225,231,229,243,104,129,251, 49, 59,236,232,229,226,242,
229,119,128,251, 49,232,229,226,242,229,119,128, 5,209,242,225,
230,229,232,229,226,242,229,119,128,251, 76,104, 2, 60, 17, 60,
67, 97, 3, 60, 25, 60, 35, 60, 42,226,229,238,231,225,236,105,
128, 9,173,228,229,246, 97,128, 9, 45,231,117, 2, 60, 49, 60,
58,234,225,242,225,244,105,128, 10,173,242,237,245,235,232,105,
128, 10, 45,239,239,107,128, 2, 83,105, 5, 60, 85, 60, 96, 60,
107, 60,121, 60,135,232,233,242,225,231,225,238, 97,128, 48,115,
235,225,244,225,235,225,238, 97,128, 48,211,236,225,226,233,225,
236,227,236,233,227,107,128, 2,152,238,228,233,231,245,242,237,
245,235,232,105,128, 10, 2,242,245,243,241,245,225,242,101,128,
51, 49,108, 3, 60,154, 62, 55, 62, 66, 97, 2, 60,160, 62, 50,
227,107, 6, 60,175, 60,184, 60,221, 61,114, 61,169, 61,221,227,
233,242,227,236,101,128, 37,207,100, 2, 60,190, 60,199,233,225,
237,239,238,100,128, 37,198,239,247,238,240,239,233,238,244,233,
238,231,244,242,233,225,238,231,236,101,128, 37,188,108, 2, 60,
227, 61, 74,101, 2, 60,233, 61, 13,230,244,240,239,233,238,244,
233,238,103, 2, 60,248, 61, 2,240,239,233,238,244,229,114,128,
37,196,244,242,233,225,238,231,236,101,128, 37,192,238,244,233,
227,245,236,225,242,226,242,225,227,235,229,116, 2, 61, 33, 61,
53,236,229,230,116,129, 48, 16, 61, 42,246,229,242,244,233,227,
225,108,128,254, 59,242,233,231,232,116,129, 48, 17, 61, 63,246,
229,242,244,233,227,225,108,128,254, 60,239,247,229,114, 2, 61,
83, 61, 98,236,229,230,244,244,242,233,225,238,231,236,101,128,
37,227,242,233,231,232,244,244,242,233,225,238,231,236,101,128,
37,226,114, 2, 61,120, 61,131,229,227,244,225,238,231,236,101,
128, 37,172,233,231,232,244,240,239,233,238,244,233,238,103, 2,
61,148, 61,158,240,239,233,238,244,229,114,128, 37,186,244,242,
233,225,238,231,236,101,128, 37,182,115, 3, 61,177, 61,207, 61,
215,109, 2, 61,183, 61,195,225,236,236,243,241,245,225,242,101,
128, 37,170,233,236,233,238,231,230,225,227,101,128, 38, 59,241,
245,225,242,101,128, 37,160,244,225,114,128, 38, 5,245,240,112,
2, 61,229, 62, 11,229,114, 2, 61,236, 61,251,236,229,230,244,
244,242,233,225,238,231,236,101,128, 37,228,242,233,231,232,244,
244,242,233,225,238,231,236,101,128, 37,229,239,233,238,244,233,
238,103, 2, 62, 23, 62, 39,243,237,225,236,236,244,242,233,225,
238,231,236,101,128, 37,180,244,242,233,225,238,231,236,101,128,
37,178,238,107,128, 36, 35,233,238,229,226,229,236,239,119,128,
30, 7,239,227,107,128, 37,136,237,239,238,239,243,240,225,227,
101,128,255, 66,111, 3, 62, 92, 62,105, 62,116,226,225,233,237,
225,233,244,232,225,105,128, 14, 26,232,233,242,225,231,225,238,
97,128, 48,124,235,225,244,225,235,225,238, 97,128, 48,220,240,
225,242,229,110,128, 36,157,241,243,241,245,225,242,101,128, 51,
195,114, 4, 62,155, 63,149, 63,222, 64, 5,225, 99, 2, 62,162,
63, 56,101, 3, 62,170, 62,175, 62,243,229,120,128,248,244,236,
229,230,116,133, 0,123, 62,192, 62,197, 62,219, 62,227, 62,232,
226,116,128,248,243,109, 2, 62,203, 62,208,233,100,128,248,242,
239,238,239,243,240,225,227,101,128,255, 91,243,237,225,236,108,
128,254, 91,244,112,128,248,241,246,229,242,244,233,227,225,108,
128,254, 55,242,233,231,232,116,133, 0,125, 63, 5, 63, 10, 63,
32, 63, 40, 63, 45,226,116,128,248,254,109, 2, 63, 16, 63, 21,
233,100,128,248,253,239,238,239,243,240,225,227,101,128,255, 93,
243,237,225,236,108,128,254, 92,244,112,128,248,252,246,229,242,
244,233,227,225,108,128,254, 56,235,229,116, 2, 63, 64, 63,106,
236,229,230,116,132, 0, 91, 63, 79, 63, 84, 63, 89, 63,101,226,
116,128,248,240,229,120,128,248,239,237,239,238,239,243,240,225,
227,101,128,255, 59,244,112,128,248,238,242,233,231,232,116,132,
0, 93, 63,122, 63,127, 63,132, 63,144,226,116,128,248,251,229,
120,128,248,250,237,239,238,239,243,240,225,227,101,128,255, 61,
244,112,128,248,249,229,246,101,131, 2,216, 63,161, 63,172, 63,
178,226,229,236,239,247,227,237, 98,128, 3, 46,227,237, 98,128,
3, 6,233,238,246,229,242,244,229,100, 3, 63,193, 63,204, 63,
210,226,229,236,239,247,227,237, 98,128, 3, 47,227,237, 98,128,
3, 17,228,239,245,226,236,229,227,237, 98,128, 3, 97,233,228,
231,101, 2, 63,231, 63,242,226,229,236,239,247,227,237, 98,128,
3, 42,233,238,246,229,242,244,229,228,226,229,236,239,247,227,
237, 98,128, 3, 58,239,235,229,238,226,225,114,128, 0,166,115,
2, 64, 21, 64, 29,244,242,239,235,101,128, 1,128,245,240,229,
242,233,239,114,128,246,234,244,239,240,226,225,114,128, 1,131,
117, 3, 64, 56, 64, 67, 64, 78,232,233,242,225,231,225,238, 97,
128, 48,118,235,225,244,225,235,225,238, 97,128, 48,214,236,108,
2, 64, 85, 64,115,229,116,130, 32, 34, 64, 94, 64,104,233,238,
246,229,242,243,101,128, 37,216,239,240,229,242,225,244,239,114,
128, 34, 25,243,229,249,101,128, 37,206, 99,143, 0, 99, 64,156,
65,105, 65,116, 65,180, 65,211, 66, 48, 67,215, 68,199, 69, 43,
69, 92, 72, 84, 72, 92, 72,102, 72,114, 72,147, 97, 9, 64,176,
64,187, 64,197, 64,204, 64,211, 64,236, 64,246, 65, 42, 65, 51,
225,242,237,229,238,233,225,110,128, 5,110,226,229,238,231,225,
236,105,128, 9,154,227,245,244,101,128, 1, 7,228,229,246, 97,
128, 9, 26,231,117, 2, 64,218, 64,227,234,225,242,225,244,105,
128, 10,154,242,237,245,235,232,105,128, 10, 26,236,243,241,245,
225,242,101,128, 51,136,238,228,242,225,226,233,238,228,117, 4,
65, 8, 65, 18, 65, 24, 65, 31,226,229,238,231,225,236,105,128,
9,129,227,237, 98,128, 3, 16,228,229,246, 97,128, 9, 1,231,
245,234,225,242,225,244,105,128, 10,129,240,243,236,239,227,107,
128, 33,234,114, 3, 65, 59, 65, 65, 65, 91,229,239,102,128, 33,
5,239,110,130, 2,199, 65, 74, 65, 85,226,229,236,239,247,227,
237, 98,128, 3, 44,227,237, 98,128, 3, 12,242,233,225,231,229,
242,229,244,245,242,110,128, 33,181,226,239,240,239,237,239,230,
111,128, 49, 24, 99, 4, 65,126, 65,133, 65,152, 65,174,225,242,
239,110,128, 1, 13,229,228,233,236,236, 97,129, 0,231, 65,144,
225,227,245,244,101,128, 30, 9,233,242, 99, 2, 65,160, 65,165,
236,101,128, 36,210,245,237,230,236,229,120,128, 1, 9,245,242,
108,128, 2, 85,100, 2, 65,186, 65,202,239,116,129, 1, 11, 65,
193,225,227,227,229,238,116,128, 1, 11,243,241,245,225,242,101,
128, 51,197,101, 2, 65,217, 65,233,228,233,236,236, 97,129, 0,
184, 65,227,227,237, 98,128, 3, 39,238,116,132, 0,162, 65,246,
66, 14, 66, 26, 66, 37,105, 2, 65,252, 66, 4,231,242,225,228,
101,128, 33, 3,238,230,229,242,233,239,114,128,246,223,237,239,
238,239,243,240,225,227,101,128,255,224,239,236,228,243,244,249,
236,101,128,247,162,243,245,240,229,242,233,239,114,128,246,224,
104, 5, 66, 60, 66,123, 66,134, 67, 62, 67,154, 97, 4, 66, 70,
66, 81, 66, 91, 66, 98,225,242,237,229,238,233,225,110,128, 5,
121,226,229,238,231,225,236,105,128, 9,155,228,229,246, 97,128,
9, 27,231,117, 2, 66,105, 66,114,234,225,242,225,244,105,128,
10,155,242,237,245,235,232,105,128, 10, 27,226,239,240,239,237,
239,230,111,128, 49, 20,101, 6, 66,148, 66,168, 66,192, 67, 4,
67, 16, 67, 37,225,226,235,232,225,243,233,225,238,227,249,242,
233,236,236,233, 99,128, 4,189, 99, 2, 66,174, 66,182,235,237,
225,242,107,128, 39, 19,249,242,233,236,236,233, 99,128, 4, 71,
100, 2, 66,198, 66,242,229,243,227,229,238,228,229,114, 2, 66,
211, 66,231,225,226,235,232,225,243,233,225,238,227,249,242,233,
236,236,233, 99,128, 4,191,227,249,242,233,236,236,233, 99,128,
4,183,233,229,242,229,243,233,243,227,249,242,233,236,236,233,
99,128, 4,245,232,225,242,237,229,238,233,225,110,128, 5,115,
235,232,225,235,225,243,243,233,225,238,227,249,242,233,236,236,
233, 99,128, 4,204,246,229,242,244,233,227,225,236,243,244,242,
239,235,229,227,249,242,233,236,236,233, 99,128, 4,185,105,129,
3,199, 67, 68,229,245,227,104, 4, 67, 81, 67,116, 67,131, 67,
140, 97, 2, 67, 87, 67,102,227,233,242,227,236,229,235,239,242,
229,225,110,128, 50,119,240,225,242,229,238,235,239,242,229,225,
110,128, 50, 23,227,233,242,227,236,229,235,239,242,229,225,110,
128, 50,105,235,239,242,229,225,110,128, 49, 74,240,225,242,229,
238,235,239,242,229,225,110,128, 50, 9,111, 2, 67,160, 67,210,
227,104, 3, 67,169, 67,191, 67,201,225,110, 2, 67,176, 67,184,
231,244,232,225,105,128, 14, 10,244,232,225,105,128, 14, 8,233,
238,231,244,232,225,105,128, 14, 9,239,229,244,232,225,105,128,
14, 12,239,107,128, 1,136,105, 2, 67,221, 68, 67,229,245, 99,
5, 67,235, 68, 14, 68, 29, 68, 38, 68, 52, 97, 2, 67,241, 68,
0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,118,
240,225,242,229,238,235,239,242,229,225,110,128, 50, 22,227,233,
242,227,236,229,235,239,242,229,225,110,128, 50,104,235,239,242,
229,225,110,128, 49, 72,240,225,242,229,238,235,239,242,229,225,
110,128, 50, 8,245,240,225,242,229,238,235,239,242,229,225,110,
128, 50, 28,242, 99, 2, 68, 74, 68,169,236,101,132, 37,203, 68,
87, 68, 98, 68,103, 68,127,237,245,236,244,233,240,236,121,128,
34,151,239,116,128, 34,153,112, 2, 68,109, 68,115,236,245,115,
128, 34,149,239,243,244,225,236,237,225,242,107,128, 48, 54,247,
233,244,104, 2, 68,136, 68,152,236,229,230,244,232,225,236,230,
226,236,225,227,107,128, 37,208,242,233,231,232,244,232,225,236,
230,226,236,225,227,107,128, 37,209,245,237,230,236,229,120,130,
2,198, 68,182, 68,193,226,229,236,239,247,227,237, 98,128, 3,
45,227,237, 98,128, 3, 2,108, 3, 68,207, 68,213, 69, 11,229,
225,114,128, 35, 39,233,227,107, 4, 68,225, 68,236, 68,245, 68,
255,225,236,246,229,239,236,225,114,128, 1,194,228,229,238,244,
225,108,128, 1,192,236,225,244,229,242,225,108,128, 1,193,242,
229,244,242,239,230,236,229,120,128, 1,195,245, 98,129, 38, 99,
69, 18,243,245,233,116, 2, 69, 27, 69, 35,226,236,225,227,107,
128, 38, 99,247,232,233,244,101,128, 38,103,109, 3, 69, 51, 69,
65, 69, 76,227,245,226,229,228,243,241,245,225,242,101,128, 51,
164,239,238,239,243,240,225,227,101,128,255, 67,243,241,245,225,
242,229,228,243,241,245,225,242,101,128, 51,160,111, 8, 69,110,
69,121, 69,208, 70,150, 71,179, 71,210, 72, 61, 72, 70,225,242,
237,229,238,233,225,110,128, 5,129,236,239,110,131, 0, 58, 69,
133, 69,158, 69,177,237,239,110, 2, 69,141, 69,149,229,244,225,
242,121,128, 32,161,239,243,240,225,227,101,128,255, 26,115, 2,
69,164, 69,170,233,231,110,128, 32,161,237,225,236,108,128,254,
85,244,242,233,225,238,231,245,236,225,114, 2, 69,192, 69,202,
232,225,236,230,237,239,100,128, 2,209,237,239,100,128, 2,208,
109, 2, 69,214, 70,143,237, 97,134, 0, 44, 69,231, 70, 39, 70,
50, 70, 62, 70, 92, 70,115, 97, 3, 69,239, 70, 9, 70, 17,226,
239,246,101, 2, 69,248, 69,254,227,237, 98,128, 3, 19,242,233,
231,232,244,227,237, 98,128, 3, 21,227,227,229,238,116,128,246,
195,114, 2, 70, 23, 70, 30,225,226,233, 99,128, 6, 12,237,229,
238,233,225,110,128, 5, 93,233,238,230,229,242,233,239,114,128,
246,225,237,239,238,239,243,240,225,227,101,128,255, 12,242,229,
246,229,242,243,229,100, 2, 70, 75, 70, 86,225,226,239,246,229,
227,237, 98,128, 3, 20,237,239,100,128, 2,189,115, 2, 70, 98,
70,105,237,225,236,108,128,254, 80,245,240,229,242,233,239,114,
128,246,226,244,245,242,238,229,100, 2, 70,126, 70,137,225,226,
239,246,229,227,237, 98,128, 3, 18,237,239,100,128, 2,187,240,
225,243,115,128, 38, 60,110, 2, 70,156, 70,165,231,242,245,229,
238,116,128, 34, 69,116, 2, 70,171, 70,185,239,245,242,233,238,
244,229,231,242,225,108,128, 34, 46,242,239,108,142, 35, 3, 70,
219, 70,225, 70,240, 70,255, 71, 43, 71, 88, 71,102, 71,107, 71,
112, 71,117, 71,123, 71,128, 71,169, 71,174,193,195, 75,128, 0,
6, 66, 2, 70,231, 70,236,197, 76,128, 0, 7, 83,128, 0, 8,
67, 2, 70,246, 70,251,193, 78,128, 0, 24, 82,128, 0, 13, 68,
3, 71, 7, 71, 33, 71, 38, 67, 4, 71, 17, 71, 21, 71, 25, 71,
29, 49,128, 0, 17, 50,128, 0, 18, 51,128, 0, 19, 52,128, 0,
20,197, 76,128, 0,127,204, 69,128, 0, 16, 69, 5, 71, 55, 71,
59, 71, 64, 71, 69, 71, 74, 77,128, 0, 25,206, 81,128, 0, 5,
207, 84,128, 0, 4,211, 67,128, 0, 27, 84, 2, 71, 80, 71, 84,
66,128, 0, 23, 88,128, 0, 3, 70, 2, 71, 94, 71, 98, 70,128,
0, 12, 83,128, 0, 28,199, 83,128, 0, 29,200, 84,128, 0, 9,
204, 70,128, 0, 10,206,193, 75,128, 0, 21,210, 83,128, 0, 30,
83, 5, 71,140, 71,144, 71,154, 71,159, 71,164, 73,128, 0, 15,
79,129, 0, 14, 71,150, 84,128, 0, 2,212, 88,128, 0, 1,213,
66,128, 0, 26,217, 78,128, 0, 22,213, 83,128, 0, 31,214, 84,
128, 0, 11,240,249,242,233,231,232,116,129, 0,169, 71,191,115,
2, 71,197, 71,203,225,238,115,128,248,233,229,242,233,102,128,
246,217,114, 2, 71,216, 72, 44,238,229,242,226,242,225,227,235,
229,116, 2, 71,231, 72, 9,236,229,230,116,130, 48, 12, 71,242,
71,254,232,225,236,230,247,233,228,244,104,128,255, 98,246,229,
242,244,233,227,225,108,128,254, 65,242,233,231,232,116,130, 48,
13, 72, 21, 72, 33,232,225,236,230,247,233,228,244,104,128,255,
99,246,229,242,244,233,227,225,108,128,254, 66,240,239,242,225,
244,233,239,238,243,241,245,225,242,101,128, 51,127,243,241,245,
225,242,101,128, 51,199,246,229,242,235,231,243,241,245,225,242,
101,128, 51,198,240,225,242,229,110,128, 36,158,242,245,250,229,
233,242,111,128, 32,162,243,244,242,229,244,227,232,229,100,128,
2,151,245,114, 2, 72,121, 72,139,236,121, 2, 72,128, 72,134,
225,238,100,128, 34,207,239,114,128, 34,206,242,229,238,227,121,
128, 0,164,249,114, 4, 72,158, 72,166, 72,173, 72,181,194,242,
229,246,101,128,246,209,198,236,229,120,128,246,210,226,242,229,
246,101,128,246,212,230,236,229,120,128,246,213,100,146, 0,100,
72,228, 74,110, 75,134, 75,194, 76,114, 77, 68, 77,130, 78, 59,
78, 72, 78, 81, 78,107, 78,132, 78,141, 79,208, 79,216, 79,227,
79,247, 80, 19, 97, 11, 72,252, 73, 7, 73, 17, 73, 89, 73,152,
73,163, 73,174, 73,243, 74, 49, 74, 55, 74, 85,225,242,237,229,
238,233,225,110,128, 5,100,226,229,238,231,225,236,105,128, 9,
166,100, 5, 73, 29, 73, 38, 73, 44, 73, 58, 73, 74,225,242,225,
226,233, 99,128, 6, 54,229,246, 97,128, 9, 38,230,233,238,225,
236,225,242,225,226,233, 99,128,254,190,233,238,233,244,233,225,
236,225,242,225,226,233, 99,128,254,191,237,229,228,233,225,236,
225,242,225,226,233, 99,128,254,192,103, 3, 73, 97, 73,114, 73,
128,229,243,104,129, 5,188, 73,105,232,229,226,242,229,119,128,
5,188,231,229,114,129, 32, 32, 73,122,228,226,108,128, 32, 33,
117, 2, 73,134, 73,143,234,225,242,225,244,105,128, 10,166,242,
237,245,235,232,105,128, 10, 38,232,233,242,225,231,225,238, 97,
128, 48, 96,235,225,244,225,235,225,238, 97,128, 48,192,108, 3,
73,182, 73,191, 73,229,225,242,225,226,233, 99,128, 6, 47,229,
116,130, 5,211, 73,200, 73,220,228,225,231,229,243,104,129,251,
51, 73,211,232,229,226,242,229,119,128,251, 51,232,229,226,242,
229,119,128, 5,211,230,233,238,225,236,225,242,225,226,233, 99,
128,254,170,237,237, 97, 3, 73,253, 74, 6, 74, 18,225,242,225,
226,233, 99,128, 6, 79,236,239,247,225,242,225,226,233, 99,128,
6, 79,244,225,238, 97, 2, 74, 27, 74, 41,236,244,239,238,229,
225,242,225,226,233, 99,128, 6, 76,242,225,226,233, 99,128, 6,
76,238,228, 97,128, 9,100,242,231, 97, 2, 74, 63, 74, 72,232,
229,226,242,229,119,128, 5,167,236,229,230,244,232,229,226,242,
229,119,128, 5,167,243,233,225,240,238,229,245,237,225,244,225,
227,249,242,233,236,236,233,227,227,237, 98,128, 4,133, 98, 3,
74,118, 75,115, 75,125,108, 9, 74,138, 74,146, 75, 3, 75, 11,
75, 27, 75, 38, 75, 56, 75, 70, 75, 81,199,242,225,246,101,128,
246,211, 97, 2, 74,152, 74,209,238,231,236,229,226,242,225,227,
235,229,116, 2, 74,168, 74,188,236,229,230,116,129, 48, 10, 74,
177,246,229,242,244,233,227,225,108,128,254, 61,242,233,231,232,
116,129, 48, 11, 74,198,246,229,242,244,233,227,225,108,128,254,
62,114, 2, 74,215, 74,236,227,232,233,238,246,229,242,244,229,
228,226,229,236,239,247,227,237, 98,128, 3, 43,242,239,119, 2,
74,244, 74,251,236,229,230,116,128, 33,212,242,233,231,232,116,
128, 33,210,228,225,238,228, 97,128, 9,101,231,242,225,246,101,
129,246,214, 75, 21,227,237, 98,128, 3, 15,233,238,244,229,231,
242,225,108,128, 34, 44,236,239,247,236,233,238,101,129, 32, 23,
75, 50,227,237, 98,128, 3, 51,239,246,229,242,236,233,238,229,
227,237, 98,128, 3, 63,240,242,233,237,229,237,239,100,128, 2,
186,246,229,242,244,233,227,225,108, 2, 75, 94, 75,100,226,225,
114,128, 32, 22,236,233,238,229,225,226,239,246,229,227,237, 98,
128, 3, 14,239,240,239,237,239,230,111,128, 49, 9,243,241,245,
225,242,101,128, 51,200, 99, 4, 75,144, 75,151, 75,160, 75,187,
225,242,239,110,128, 1, 15,229,228,233,236,236, 97,128, 30, 17,
233,242, 99, 2, 75,168, 75,173,236,101,128, 36,211,245,237,230,
236,229,248,226,229,236,239,119,128, 30, 19,242,239,225,116,128,
1, 17,100, 4, 75,204, 76, 29, 76, 39, 76, 90, 97, 4, 75,214,
75,224, 75,231, 76, 0,226,229,238,231,225,236,105,128, 9,161,
228,229,246, 97,128, 9, 33,231,117, 2, 75,238, 75,247,234,225,
242,225,244,105,128, 10,161,242,237,245,235,232,105,128, 10, 33,
108, 2, 76, 6, 76, 15,225,242,225,226,233, 99,128, 6,136,230,
233,238,225,236,225,242,225,226,233, 99,128,251,137,228,232,225,
228,229,246, 97,128, 9, 92,232, 97, 3, 76, 48, 76, 58, 76, 65,
226,229,238,231,225,236,105,128, 9,162,228,229,246, 97,128, 9,
34,231,117, 2, 76, 72, 76, 81,234,225,242,225,244,105,128, 10,
162,242,237,245,235,232,105,128, 10, 34,239,116, 2, 76, 97, 76,
106,225,227,227,229,238,116,128, 30, 11,226,229,236,239,119,128,
30, 13,101, 8, 76,132, 76,185, 76,192, 76,217, 76,227, 76,238,
77, 27, 77, 63, 99, 2, 76,138, 76,175,233,237,225,236,243,229,
240,225,242,225,244,239,114, 2, 76,156, 76,165,225,242,225,226,
233, 99,128, 6,107,240,229,242,243,233,225,110,128, 6,107,249,
242,233,236,236,233, 99,128, 4, 52,231,242,229,101,128, 0,176,
232,105, 2, 76,199, 76,208,232,229,226,242,229,119,128, 5,173,
242,225,231,225,238, 97,128, 48,103,233,227,239,240,244,233, 99,
128, 3,239,235,225,244,225,235,225,238, 97,128, 48,199,108, 2,
76,244, 77, 11,229,244,101, 2, 76,252, 77, 3,236,229,230,116,
128, 35, 43,242,233,231,232,116,128, 35, 38,244, 97,129, 3,180,
77, 18,244,245,242,238,229,100,128, 1,141,238,239,237,233,238,
225,244,239,242,237,233,238,245,243,239,238,229,238,245,237,229,
242,225,244,239,242,226,229,238,231,225,236,105,128, 9,248,250,
104,128, 2,164,104, 2, 77, 74, 77,124, 97, 3, 77, 82, 77, 92,
77, 99,226,229,238,231,225,236,105,128, 9,167,228,229,246, 97,
128, 9, 39,231,117, 2, 77,106, 77,115,234,225,242,225,244,105,
128, 10,167,242,237,245,235,232,105,128, 10, 39,239,239,107,128,
2, 87,105, 6, 77,144, 77,193, 77,253, 78, 8, 78, 19, 78, 29,
97, 2, 77,150, 77,172,236,249,244,233,235,225,244,239,238,239,
115,129, 3,133, 77,166,227,237, 98,128, 3, 68,237,239,238,100,
129, 38,102, 77,181,243,245,233,244,247,232,233,244,101,128, 38,
98,229,242,229,243,233,115,133, 0,168, 77,212, 77,220, 77,231,
77,237, 77,245,225,227,245,244,101,128,246,215,226,229,236,239,
247,227,237, 98,128, 3, 36,227,237, 98,128, 3, 8,231,242,225,
246,101,128,246,216,244,239,238,239,115,128, 3,133,232,233,242,
225,231,225,238, 97,128, 48, 98,235,225,244,225,235,225,238, 97,
128, 48,194,244,244,239,237,225,242,107,128, 48, 3,246,105, 2,
78, 36, 78, 47,228,101,129, 0,247, 78, 43,115,128, 34, 35,243,
233,239,238,243,236,225,243,104,128, 34, 21,234,229,227,249,242,
233,236,236,233, 99,128, 4, 82,235,243,232,225,228,101,128, 37,
147,108, 2, 78, 87, 78, 98,233,238,229,226,229,236,239,119,128,
30, 15,243,241,245,225,242,101,128, 51,151,109, 2, 78,113, 78,
121,225,227,242,239,110,128, 1, 17,239,238,239,243,240,225,227,
101,128,255, 68,238,226,236,239,227,107,128, 37,132,111, 10, 78,
163, 78,175, 78,185, 78,196, 78,207, 79, 23, 79, 28, 79, 39, 79,
154, 79,180,227,232,225,228,225,244,232,225,105,128, 14, 14,228,
229,235,244,232,225,105,128, 14, 20,232,233,242,225,231,225,238,
97,128, 48,105,235,225,244,225,235,225,238, 97,128, 48,201,236,
236,225,114,132, 0, 36, 78,222, 78,233, 78,245, 79, 0,233,238,
230,229,242,233,239,114,128,246,227,237,239,238,239,243,240,225,
227,101,128,255, 4,239,236,228,243,244,249,236,101,128,247, 36,
115, 2, 79, 6, 79, 13,237,225,236,108,128,254,105,245,240,229,
242,233,239,114,128,246,228,238,103,128, 32,171,242,245,243,241,
245,225,242,101,128, 51, 38,116, 6, 79, 53, 79, 70, 79, 92, 79,
103, 79,135, 79,142,225,227,227,229,238,116,129, 2,217, 79, 64,
227,237, 98,128, 3, 7,226,229,236,239,247, 99, 2, 79, 81, 79,
86,237, 98,128, 3, 35,239,237, 98,128, 3, 35,235,225,244,225,
235,225,238, 97,128, 48,251,236,229,243,115, 2, 79,112, 79,116,
105,128, 1, 49,106,129,246,190, 79,122,243,244,242,239,235,229,
232,239,239,107,128, 2,132,237,225,244,104,128, 34,197,244,229,
228,227,233,242,227,236,101,128, 37,204,245,226,236,229,249,239,
228,240,225,244,225,104,129,251, 31, 79,171,232,229,226,242,229,
119,128,251, 31,247,238,244,225,227,107, 2, 79,191, 79,202,226,
229,236,239,247,227,237, 98,128, 3, 30,237,239,100,128, 2,213,
240,225,242,229,110,128, 36,159,243,245,240,229,242,233,239,114,
128,246,235,116, 2, 79,233, 79,239,225,233,108,128, 2, 86,239,
240,226,225,114,128, 1,140,117, 2, 79,253, 80, 8,232,233,242,
225,231,225,238, 97,128, 48,101,235,225,244,225,235,225,238, 97,
128, 48,197,122,132, 1,243, 80, 31, 80, 40, 80, 59, 80, 96,225,
236,244,239,238,101,128, 2,163, 99, 2, 80, 46, 80, 53,225,242,
239,110,128, 1,198,245,242,108,128, 2,165,101, 2, 80, 65, 80,
85,225,226,235,232,225,243,233,225,238,227,249,242,233,236,236,
233, 99,128, 4,225,227,249,242,233,236,236,233, 99,128, 4, 85,
232,229,227,249,242,233,236,236,233, 99,128, 4, 95,101,151, 0,
101, 80,159, 80,178, 80,212, 81,186, 81,248, 82, 25, 82, 37, 82,
60, 82,113, 83,225, 84, 27, 84,129, 84,245, 85,124, 85,199, 85,
230, 86, 36, 86, 89, 87, 24, 87,157, 87,177, 87,221, 88, 56, 97,
2, 80,165, 80,172,227,245,244,101,128, 0,233,242,244,104,128,
38, 65, 98, 3, 80,186, 80,195, 80,205,229,238,231,225,236,105,
128, 9,143,239,240,239,237,239,230,111,128, 49, 28,242,229,246,
101,128, 1, 21, 99, 5, 80,224, 81, 41, 81, 55, 81, 87, 81,176,
97, 2, 80,230, 81, 35,238,228,242, 97, 3, 80,241, 80,248, 81,
3,228,229,246, 97,128, 9, 13,231,245,234,225,242,225,244,105,
128, 10,141,246,239,247,229,236,243,233,231,110, 2, 81, 17, 81,
24,228,229,246, 97,128, 9, 69,231,245,234,225,242,225,244,105,
128, 10,197,242,239,110,128, 1, 27,229,228,233,236,236,225,226,
242,229,246,101,128, 30, 29,104, 2, 81, 61, 81, 72,225,242,237,
229,238,233,225,110,128, 5,101,249,233,247,238,225,242,237,229,
238,233,225,110,128, 5,135,233,242, 99, 2, 81, 95, 81,100,236,
101,128, 36,212,245,237,230,236,229,120,134, 0,234, 81,121, 81,
129, 81,137, 81,148, 81,156, 81,168,225,227,245,244,101,128, 30,
191,226,229,236,239,119,128, 30, 25,228,239,244,226,229,236,239,
119,128, 30,199,231,242,225,246,101,128, 30,193,232,239,239,235,
225,226,239,246,101,128, 30,195,244,233,236,228,101,128, 30,197,
249,242,233,236,236,233, 99,128, 4, 84,100, 4, 81,196, 81,206,
81,212, 81,222,226,236,231,242,225,246,101,128, 2, 5,229,246,
97,128, 9, 15,233,229,242,229,243,233,115,128, 0,235,239,116,
130, 1, 23, 81,231, 81,240,225,227,227,229,238,116,128, 1, 23,
226,229,236,239,119,128, 30,185,101, 2, 81,254, 82, 9,231,245,
242,237,245,235,232,105,128, 10, 15,237,225,244,242,225,231,245,
242,237,245,235,232,105,128, 10, 71,230,227,249,242,233,236,236,
233, 99,128, 4, 68,103, 2, 82, 43, 82, 50,242,225,246,101,128,
0,232,245,234,225,242,225,244,105,128, 10,143,104, 4, 82, 70,
82, 81, 82, 92, 82,102,225,242,237,229,238,233,225,110,128, 5,
103,226,239,240,239,237,239,230,111,128, 49, 29,233,242,225,231,
225,238, 97,128, 48, 72,239,239,235,225,226,239,246,101,128, 30,
187,105, 4, 82,123, 82,134, 83,192, 83,207,226,239,240,239,237,
239,230,111,128, 49, 31,231,232,116,142, 0, 56, 82,168, 82,177,
82,187, 82,217, 82,224, 83, 6, 83, 31, 83, 76, 83,110, 83,122,
83,133, 83,166, 83,174, 83,185,225,242,225,226,233, 99,128, 6,
104,226,229,238,231,225,236,105,128, 9,238,227,233,242,227,236,
101,129, 36,103, 82,198,233,238,246,229,242,243,229,243,225,238,
243,243,229,242,233,102,128, 39,145,228,229,246, 97,128, 9,110,
229,229,110, 2, 82,232, 82,241,227,233,242,227,236,101,128, 36,
113,112, 2, 82,247, 82,254,225,242,229,110,128, 36,133,229,242,
233,239,100,128, 36,153,231,117, 2, 83, 13, 83, 22,234,225,242,
225,244,105,128, 10,238,242,237,245,235,232,105,128, 10,110,104,
2, 83, 37, 83, 63, 97, 2, 83, 43, 83, 54,227,235,225,242,225,
226,233, 99,128, 6,104,238,231,250,232,239,117,128, 48, 40,238,
239,244,229,226,229,225,237,229,100,128, 38,107,105, 2, 83, 82,
83,100,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
110,128, 50, 39,238,230,229,242,233,239,114,128, 32,136,237,239,
238,239,243,240,225,227,101,128,255, 24,239,236,228,243,244,249,
236,101,128,247, 56,112, 2, 83,139, 83,146,225,242,229,110,128,
36,123,229,114, 2, 83,153, 83,159,233,239,100,128, 36,143,243,
233,225,110,128, 6,248,242,239,237,225,110,128, 33,119,243,245,
240,229,242,233,239,114,128, 32,120,244,232,225,105,128, 14, 88,
238,246,229,242,244,229,228,226,242,229,246,101,128, 2, 7,239,
244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128, 4,
101,107, 2, 83,231, 83,255,225,244,225,235,225,238, 97,129, 48,
168, 83,243,232,225,236,230,247,233,228,244,104,128,255,116,111,
2, 84, 5, 84, 20,238,235,225,242,231,245,242,237,245,235,232,
105,128, 10,116,242,229,225,110,128, 49, 84,108, 3, 84, 35, 84,
46, 84,107,227,249,242,233,236,236,233, 99,128, 4, 59,101, 2,
84, 52, 84, 59,237,229,238,116,128, 34, 8,246,229,110, 3, 84,
69, 84, 78, 84, 99,227,233,242,227,236,101,128, 36,106,112, 2,
84, 84, 84, 91,225,242,229,110,128, 36,126,229,242,233,239,100,
128, 36,146,242,239,237,225,110,128, 33,122,236,233,240,243,233,
115,129, 32, 38, 84,118,246,229,242,244,233,227,225,108,128, 34,
238,109, 5, 84,141, 84,169, 84,180, 84,200, 84,211,225,227,242,
239,110,130, 1, 19, 84,153, 84,161,225,227,245,244,101,128, 30,
23,231,242,225,246,101,128, 30, 21,227,249,242,233,236,236,233,
99,128, 4, 60,228,225,243,104,129, 32, 20, 84,189,246,229,242,
244,233,227,225,108,128,254, 49,239,238,239,243,240,225,227,101,
128,255, 69,112, 2, 84,217, 84,237,232,225,243,233,243,237,225,
242,235,225,242,237,229,238,233,225,110,128, 5, 91,244,249,243,
229,116,128, 34, 5,110, 6, 85, 3, 85, 14, 85, 25, 85, 69, 85,
101, 85,116,226,239,240,239,237,239,230,111,128, 49, 35,227,249,
242,233,236,236,233, 99,128, 4, 61,100, 2, 85, 31, 85, 50,225,
243,104,129, 32, 19, 85, 39,246,229,242,244,233,227,225,108,128,
254, 50,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
233, 99,128, 4,163,103,130, 1, 75, 85, 77, 85, 88,226,239,240,
239,237,239,230,111,128, 49, 37,232,229,227,249,242,233,236,236,
233, 99,128, 4,165,232,239,239,235,227,249,242,233,236,236,233,
99,128, 4,200,243,240,225,227,101,128, 32, 2,111, 3, 85,132,
85,140, 85,149,231,239,238,229,107,128, 1, 25,235,239,242,229,
225,110,128, 49, 83,240,229,110,130, 2, 91, 85,159, 85,168,227,
236,239,243,229,100,128, 2,154,242,229,246,229,242,243,229,100,
130, 2, 92, 85,183, 85,192,227,236,239,243,229,100,128, 2, 94,
232,239,239,107,128, 2, 93,112, 2, 85,205, 85,212,225,242,229,
110,128, 36,160,243,233,236,239,110,129, 3,181, 85,222,244,239,
238,239,115,128, 3,173,241,117, 2, 85,237, 86, 25,225,108,130,
0, 61, 85,246, 86, 2,237,239,238,239,243,240,225,227,101,128,
255, 29,115, 2, 86, 8, 86, 15,237,225,236,108,128,254,102,245,
240,229,242,233,239,114,128, 32,124,233,246,225,236,229,238,227,
101,128, 34, 97,114, 3, 86, 44, 86, 55, 86, 66,226,239,240,239,
237,239,230,111,128, 49, 38,227,249,242,233,236,236,233, 99,128,
4, 64,229,246,229,242,243,229,100,129, 2, 88, 86, 78,227,249,
242,233,236,236,233, 99,128, 4, 77,115, 6, 86,103, 86,114, 86,
134, 86,215, 87, 4, 87, 14,227,249,242,233,236,236,233, 99,128,
4, 65,228,229,243,227,229,238,228,229,242,227,249,242,233,236,
236,233, 99,128, 4,171,104,132, 2,131, 86,146, 86,153, 86,184,
86,199,227,245,242,108,128, 2,134,239,242,116, 2, 86,161, 86,
168,228,229,246, 97,128, 9, 14,246,239,247,229,236,243,233,231,
238,228,229,246, 97,128, 9, 70,242,229,246,229,242,243,229,228,
236,239,239,112,128, 1,170,243,241,245,225,244,242,229,246,229,
242,243,229,100,128, 2,133,237,225,236,108, 2, 86,224, 86,235,
232,233,242,225,231,225,238, 97,128, 48, 71,235,225,244,225,235,
225,238, 97,129, 48,167, 86,248,232,225,236,230,247,233,228,244,
104,128,255,106,244,233,237,225,244,229,100,128, 33, 46,245,240,
229,242,233,239,114,128,246,236,116, 5, 87, 36, 87, 62, 87, 66,
87, 83, 87,149, 97,130, 3,183, 87, 44, 87, 54,242,237,229,238,
233,225,110,128, 5,104,244,239,238,239,115,128, 3,174,104,128,
0,240,233,236,228,101,129, 30,189, 87, 75,226,229,236,239,119,
128, 30, 27,238,225,232,244, 97, 3, 87, 95, 87,127, 87,136,230,
239,245,235,104, 2, 87,105, 87,114,232,229,226,242,229,119,128,
5,145,236,229,230,244,232,229,226,242,229,119,128, 5,145,232,
229,226,242,229,119,128, 5,145,236,229,230,244,232,229,226,242,
229,119,128, 5,145,245,242,238,229,100,128, 1,221,117, 2, 87,
163, 87,172,235,239,242,229,225,110,128, 49, 97,242,111,128, 32,
172,246,239,247,229,236,243,233,231,110, 3, 87,193, 87,203, 87,
210,226,229,238,231,225,236,105,128, 9,199,228,229,246, 97,128,
9, 71,231,245,234,225,242,225,244,105,128, 10,199,120, 2, 87,
227, 88, 44,227,236,225,109,132, 0, 33, 87,242, 87,253, 88, 24,
88, 36,225,242,237,229,238,233,225,110,128, 5, 92,100, 2, 88,
3, 88, 8,226,108,128, 32, 60,239,247,110,129, 0,161, 88, 16,
243,237,225,236,108,128,247,161,237,239,238,239,243,240,225,227,
101,128,255, 1,243,237,225,236,108,128,247, 33,233,243,244,229,
238,244,233,225,108,128, 34, 3,250,104,131, 2,146, 88, 67, 88,
86, 88, 97, 99, 2, 88, 73, 88, 80,225,242,239,110,128, 1,239,
245,242,108,128, 2,147,242,229,246,229,242,243,229,100,128, 1,
185,244,225,233,108,128, 1,186,102,140, 0,102, 88,132, 88,214,
88,225, 88,234, 88,246, 89, 93, 89,109, 91,117, 91,130, 91,156,
93, 33, 93, 41, 97, 4, 88,142, 88,149, 88,160, 88,171,228,229,
246, 97,128, 9, 94,231,245,242,237,245,235,232,105,128, 10, 94,
232,242,229,238,232,229,233,116,128, 33, 9,244,232, 97, 3, 88,
181, 88,190, 88,202,225,242,225,226,233, 99,128, 6, 78,236,239,
247,225,242,225,226,233, 99,128, 6, 78,244,225,238,225,242,225,
226,233, 99,128, 6, 75,226,239,240,239,237,239,230,111,128, 49,
8,227,233,242,227,236,101,128, 36,213,228,239,244,225,227,227,
229,238,116,128, 30, 31,101, 3, 88,254, 89, 76, 89, 86,104, 4,
89, 8, 89, 31, 89, 45, 89, 61,225,114, 2, 89, 15, 89, 22,225,
226,233, 99,128, 6, 65,237,229,238,233,225,110,128, 5,134,230,
233,238,225,236,225,242,225,226,233, 99,128,254,210,233,238,233,
244,233,225,236,225,242,225,226,233, 99,128,254,211,237,229,228,
233,225,236,225,242,225,226,233, 99,128,254,212,233,227,239,240,
244,233, 99,128, 3,229,237,225,236,101,128, 38, 64,102,130,251,
0, 89,101, 89,105,105,128,251, 3,108,128,251, 4,105,136,251,
1, 89,129, 89,169, 89,180, 89,202, 90, 68, 90, 85, 90, 93, 90,
106,230,244,229,229,110, 2, 89,139, 89,148,227,233,242,227,236,
101,128, 36,110,112, 2, 89,154, 89,161,225,242,229,110,128, 36,
130,229,242,233,239,100,128, 36,150,231,245,242,229,228,225,243,
104,128, 32, 18,236,236,229,100, 2, 89,189, 89,195,226,239,120,
128, 37,160,242,229,227,116,128, 37,172,238,225,108, 5, 89,216,
89,255, 90, 16, 90, 33, 90, 49,235,225,102,130, 5,218, 89,226,
89,246,228,225,231,229,243,104,129,251, 58, 89,237,232,229,226,
242,229,119,128,251, 58,232,229,226,242,229,119,128, 5,218,237,
229,109,129, 5,221, 90, 7,232,229,226,242,229,119,128, 5,221,
238,245,110,129, 5,223, 90, 24,232,229,226,242,229,119,128, 5,
223,240,101,129, 5,227, 90, 40,232,229,226,242,229,119,128, 5,
227,244,243,225,228,105,129, 5,229, 90, 59,232,229,226,242,229,
119,128, 5,229,242,243,244,244,239,238,229,227,232,233,238,229,
243,101,128, 2,201,243,232,229,249,101,128, 37,201,244,225,227,
249,242,233,236,236,233, 99,128, 4,115,246,101,142, 0, 53, 90,
139, 90,148, 90,158, 90,188, 90,195, 90,205, 90,230, 91, 1, 91,
35, 91, 47, 91, 58, 91, 91, 91, 99, 91,110,225,242,225,226,233,
99,128, 6,101,226,229,238,231,225,236,105,128, 9,235,227,233,
242,227,236,101,129, 36,100, 90,169,233,238,246,229,242,243,229,
243,225,238,243,243,229,242,233,102,128, 39,142,228,229,246, 97,
128, 9,107,229,233,231,232,244,232,115,128, 33, 93,231,117, 2,
90,212, 90,221,234,225,242,225,244,105,128, 10,235,242,237,245,
235,232,105,128, 10,107,232, 97, 2, 90,237, 90,248,227,235,225,
242,225,226,233, 99,128, 6,101,238,231,250,232,239,117,128, 48,
37,105, 2, 91, 7, 91, 25,228,229,239,231,242,225,240,232,233,
227,240,225,242,229,110,128, 50, 36,238,230,229,242,233,239,114,
128, 32,133,237,239,238,239,243,240,225,227,101,128,255, 21,239,
236,228,243,244,249,236,101,128,247, 53,112, 2, 91, 64, 91, 71,
225,242,229,110,128, 36,120,229,114, 2, 91, 78, 91, 84,233,239,
100,128, 36,140,243,233,225,110,128, 6,245,242,239,237,225,110,
128, 33,116,243,245,240,229,242,233,239,114,128, 32,117,244,232,
225,105,128, 14, 85,108,129,251, 2, 91,123,239,242,233,110,128,
1,146,109, 2, 91,136, 91,147,239,238,239,243,240,225,227,101,
128,255, 70,243,241,245,225,242,101,128, 51,153,111, 4, 91,166,
91,188, 91,200, 91,207,230, 97, 2, 91,173, 91,181,238,244,232,
225,105,128, 14, 31,244,232,225,105,128, 14, 29,238,231,237,225,
238,244,232,225,105,128, 14, 79,242,225,236,108,128, 34, 0,245,
114,142, 0, 52, 91,240, 91,249, 92, 3, 92, 33, 92, 40, 92, 65,
92, 92, 92,126, 92,138, 92,157, 92,168, 92,201, 92,209, 92,220,
225,242,225,226,233, 99,128, 6,100,226,229,238,231,225,236,105,
128, 9,234,227,233,242,227,236,101,129, 36, 99, 92, 14,233,238,
246,229,242,243,229,243,225,238,243,243,229,242,233,102,128, 39,
141,228,229,246, 97,128, 9,106,231,117, 2, 92, 47, 92, 56,234,
225,242,225,244,105,128, 10,234,242,237,245,235,232,105,128, 10,
106,232, 97, 2, 92, 72, 92, 83,227,235,225,242,225,226,233, 99,
128, 6,100,238,231,250,232,239,117,128, 48, 36,105, 2, 92, 98,
92,116,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
110,128, 50, 35,238,230,229,242,233,239,114,128, 32,132,237,239,
238,239,243,240,225,227,101,128,255, 20,238,245,237,229,242,225,
244,239,242,226,229,238,231,225,236,105,128, 9,247,239,236,228,
243,244,249,236,101,128,247, 52,112, 2, 92,174, 92,181,225,242,
229,110,128, 36,119,229,114, 2, 92,188, 92,194,233,239,100,128,
36,139,243,233,225,110,128, 6,244,242,239,237,225,110,128, 33,
115,243,245,240,229,242,233,239,114,128, 32,116,116, 2, 92,226,
93, 8,229,229,110, 2, 92,234, 92,243,227,233,242,227,236,101,
128, 36,109,112, 2, 92,249, 93, 0,225,242,229,110,128, 36,129,
229,242,233,239,100,128, 36,149,104, 2, 93, 14, 93, 19,225,105,
128, 14, 84,244,239,238,229,227,232,233,238,229,243,101,128, 2,
203,240,225,242,229,110,128, 36,161,242, 97, 2, 93, 48, 93, 56,
227,244,233,239,110,128, 32, 68,238, 99,128, 32,163,103,144, 0,
103, 93, 97, 94, 43, 94, 66, 94,127, 94,144, 95, 65, 96, 58, 96,
143, 96,156, 97, 14, 97, 39, 97, 67, 97, 89, 98, 34, 98, 56, 98,
158, 97, 9, 93,117, 93,127, 93,134, 93,141, 93,205, 93,230, 93,
241, 93,252, 94, 30,226,229,238,231,225,236,105,128, 9,151,227,
245,244,101,128, 1,245,228,229,246, 97,128, 9, 23,102, 4, 93,
151, 93,160, 93,174, 93,190,225,242,225,226,233, 99,128, 6,175,
230,233,238,225,236,225,242,225,226,233, 99,128,251,147,233,238,
233,244,233,225,236,225,242,225,226,233, 99,128,251,148,237,229,
228,233,225,236,225,242,225,226,233, 99,128,251,149,231,117, 2,
93,212, 93,221,234,225,242,225,244,105,128, 10,151,242,237,245,
235,232,105,128, 10, 23,232,233,242,225,231,225,238, 97,128, 48,
76,235,225,244,225,235,225,238, 97,128, 48,172,237,237, 97,130,
3,179, 94, 6, 94, 19,236,225,244,233,238,243,237,225,236,108,
128, 2, 99,243,245,240,229,242,233,239,114,128, 2,224,238,231,
233,225,227,239,240,244,233, 99,128, 3,235, 98, 2, 94, 49, 94,
59,239,240,239,237,239,230,111,128, 49, 13,242,229,246,101,128,
1, 31, 99, 4, 94, 76, 94, 83, 94, 92, 94,114,225,242,239,110,
128, 1,231,229,228,233,236,236, 97,128, 1, 35,233,242, 99, 2,
94,100, 94,105,236,101,128, 36,214,245,237,230,236,229,120,128,
1, 29,239,237,237,225,225,227,227,229,238,116,128, 1, 35,228,
239,116,129, 1, 33, 94,135,225,227,227,229,238,116,128, 1, 33,
101, 6, 94,158, 94,169, 94,180, 94,191, 94,210, 95, 56,227,249,
242,233,236,236,233, 99,128, 4, 51,232,233,242,225,231,225,238,
97,128, 48, 82,235,225,244,225,235,225,238, 97,128, 48,178,239,
237,229,244,242,233,227,225,236,236,249,229,241,245,225,108,128,
34, 81,114, 3, 94,218, 95, 11, 95, 21,229,243,104, 3, 94,228,
94,243, 94,252,225,227,227,229,238,244,232,229,226,242,229,119,
128, 5,156,232,229,226,242,229,119,128, 5,243,237,245,241,228,
225,237,232,229,226,242,229,119,128, 5,157,237,225,238,228,226,
236,115,128, 0,223,243,232,225,249,233,109, 2, 95, 32, 95, 47,
225,227,227,229,238,244,232,229,226,242,229,119,128, 5,158,232,
229,226,242,229,119,128, 5,244,244,225,237,225,242,107,128, 48,
19,104, 5, 95, 77, 95,210, 96, 17, 96, 42, 96, 48, 97, 4, 95,
87, 95, 97, 95,120, 95,145,226,229,238,231,225,236,105,128, 9,
152,100, 2, 95,103, 95,114,225,242,237,229,238,233,225,110,128,
5,114,229,246, 97,128, 9, 24,231,117, 2, 95,127, 95,136,234,
225,242,225,244,105,128, 10,152,242,237,245,235,232,105,128, 10,
24,233,110, 4, 95,156, 95,165, 95,179, 95,195,225,242,225,226,
233, 99,128, 6, 58,230,233,238,225,236,225,242,225,226,233, 99,
128,254,206,233,238,233,244,233,225,236,225,242,225,226,233, 99,
128,254,207,237,229,228,233,225,236,225,242,225,226,233, 99,128,
254,208,101, 3, 95,218, 95,239, 96, 0,237,233,228,228,236,229,
232,239,239,235,227,249,242,233,236,236,233, 99,128, 4,149,243,
244,242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,147,
245,240,244,245,242,238,227,249,242,233,236,236,233, 99,128, 4,
145,232, 97, 2, 96, 24, 96, 31,228,229,246, 97,128, 9, 90,231,
245,242,237,245,235,232,105,128, 10, 90,239,239,107,128, 2, 96,
250,243,241,245,225,242,101,128, 51,147,105, 3, 96, 66, 96, 77,
96, 88,232,233,242,225,231,225,238, 97,128, 48, 78,235,225,244,
225,235,225,238, 97,128, 48,174,109, 2, 96, 94, 96,105,225,242,
237,229,238,233,225,110,128, 5, 99,229,108,130, 5,210, 96,114,
96,134,228,225,231,229,243,104,129,251, 50, 96,125,232,229,226,
242,229,119,128,251, 50,232,229,226,242,229,119,128, 5,210,234,
229,227,249,242,233,236,236,233, 99,128, 4, 83,236,239,244,244,
225,108, 2, 96,167, 96,184,233,238,246,229,242,244,229,228,243,
244,242,239,235,101,128, 1,190,243,244,239,112,132, 2,148, 96,
199, 96,210, 96,216, 96,248,233,238,246,229,242,244,229,100,128,
2,150,237,239,100,128, 2,192,242,229,246,229,242,243,229,100,
130, 2,149, 96,231, 96,237,237,239,100,128, 2,193,243,245,240,
229,242,233,239,114,128, 2,228,243,244,242,239,235,101,129, 2,
161, 97, 3,242,229,246,229,242,243,229,100,128, 2,162,109, 2,
97, 20, 97, 28,225,227,242,239,110,128, 30, 33,239,238,239,243,
240,225,227,101,128,255, 71,111, 2, 97, 45, 97, 56,232,233,242,
225,231,225,238, 97,128, 48, 84,235,225,244,225,235,225,238, 97,
128, 48,180,240, 97, 2, 97, 74, 97, 80,242,229,110,128, 36,162,
243,241,245,225,242,101,128, 51,172,114, 2, 97, 95, 97,192, 97,
2, 97,101, 97,109,228,233,229,238,116,128, 34, 7,246,101,134,
0, 96, 97,126, 97,137, 97,154, 97,161, 97,170, 97,182,226,229,
236,239,247,227,237, 98,128, 3, 22, 99, 2, 97,143, 97,148,237,
98,128, 3, 0,239,237, 98,128, 3, 0,228,229,246, 97,128, 9,
83,236,239,247,237,239,100,128, 2,206,237,239,238,239,243,240,
225,227,101,128,255, 64,244,239,238,229,227,237, 98,128, 3, 64,
229,225,244,229,114,132, 0, 62, 97,208, 97,227, 97,239, 98, 26,
229,241,245,225,108,129, 34,101, 97,218,239,242,236,229,243,115,
128, 34,219,237,239,238,239,243,240,225,227,101,128,255, 30,111,
2, 97,245, 98, 15,114, 2, 97,251, 98, 8,229,241,245,233,246,
225,236,229,238,116,128, 34,115,236,229,243,115,128, 34,119,246,
229,242,229,241,245,225,108,128, 34,103,243,237,225,236,108,128,
254,101,115, 2, 98, 40, 98, 48,227,242,233,240,116,128, 2, 97,
244,242,239,235,101,128, 1,229,117, 4, 98, 66, 98, 77, 98,134,
98,145,232,233,242,225,231,225,238, 97,128, 48, 80,233,108, 2,
98, 84, 98,109,236,229,237,239,116, 2, 98, 94, 98,101,236,229,
230,116,128, 0,171,242,233,231,232,116,128, 0,187,243,233,238,
231,108, 2, 98,119, 98,126,236,229,230,116,128, 32, 57,242,233,
231,232,116,128, 32, 58,235,225,244,225,235,225,238, 97,128, 48,
176,242,225,237,245,243,241,245,225,242,101,128, 51, 24,249,243,
241,245,225,242,101,128, 51,201,104,144, 0,104, 98,204,101, 90,
101,125,101,162,101,202,103, 90,103,110,104, 75,104, 87,104, 99,
105,167,105,175,105,186,105,195,106, 19,106, 23, 97, 13, 98,232,
99, 15, 99, 25, 99, 55, 99, 80, 99,158, 99,170, 99,195, 99,210,
99,239, 99,252,100, 54,100, 63, 97, 2, 98,238, 99, 1,226,235,
232,225,243,233,225,238,227,249,242,233,236,236,233, 99,128, 4,
169,236,244,239,238,229,225,242,225,226,233, 99,128, 6,193,226,
229,238,231,225,236,105,128, 9,185,228,101, 2, 99, 32, 99, 50,
243,227,229,238,228,229,242,227,249,242,233,236,236,233, 99,128,
4,179,246, 97,128, 9, 57,231,117, 2, 99, 62, 99, 71,234,225,
242,225,244,105,128, 10,185,242,237,245,235,232,105,128, 10, 57,
104, 4, 99, 90, 99, 99, 99,113, 99,143,225,242,225,226,233, 99,
128, 6, 45,230,233,238,225,236,225,242,225,226,233, 99,128,254,
162,105, 2, 99,119, 99,134,238,233,244,233,225,236,225,242,225,
226,233, 99,128,254,163,242,225,231,225,238, 97,128, 48,111,237,
229,228,233,225,236,225,242,225,226,233, 99,128,254,164,233,244,
245,243,241,245,225,242,101,128, 51, 42,235,225,244,225,235,225,
238, 97,129, 48,207, 99,183,232,225,236,230,247,233,228,244,104,
128,255,138,236,225,238,244,231,245,242,237,245,235,232,105,128,
10, 77,237,250, 97, 2, 99,218, 99,227,225,242,225,226,233, 99,
128, 6, 33,236,239,247,225,242,225,226,233, 99,128, 6, 33,238,
231,245,236,230,233,236,236,229,114,128, 49,100,114, 2,100, 2,
100, 18,228,243,233,231,238,227,249,242,233,236,236,233, 99,128,
4, 74,240,239,239,110, 2,100, 27,100, 40,236,229,230,244,226,
225,242,226,245,112,128, 33,188,242,233,231,232,244,226,225,242,
226,245,112,128, 33,192,243,241,245,225,242,101,128, 51,202,244,
225,102, 3,100, 73,100,165,101, 0,240,225,244,225,104,134, 5,
178,100, 93,100, 98,100,112,100,121,100,136,100,152,177, 54,128,
5,178, 50, 2,100,104,100,108, 51,128, 5,178,102,128, 5,178,
232,229,226,242,229,119,128, 5,178,238,225,242,242,239,247,232,
229,226,242,229,119,128, 5,178,241,245,225,242,244,229,242,232,
229,226,242,229,119,128, 5,178,247,233,228,229,232,229,226,242,
229,119,128, 5,178,241,225,237,225,244,115,135, 5,179,100,188,
100,193,100,198,100,203,100,212,100,227,100,243,177, 98,128, 5,
179,178, 56,128, 5,179,179, 52,128, 5,179,232,229,226,242,229,
119,128, 5,179,238,225,242,242,239,247,232,229,226,242,229,119,
128, 5,179,241,245,225,242,244,229,242,232,229,226,242,229,119,
128, 5,179,247,233,228,229,232,229,226,242,229,119,128, 5,179,
243,229,231,239,108,135, 5,177,101, 22,101, 27,101, 32,101, 37,
101, 46,101, 61,101, 77,177, 55,128, 5,177,178, 52,128, 5,177,
179, 48,128, 5,177,232,229,226,242,229,119,128, 5,177,238,225,
242,242,239,247,232,229,226,242,229,119,128, 5,177,241,245,225,
242,244,229,242,232,229,226,242,229,119,128, 5,177,247,233,228,
229,232,229,226,242,229,119,128, 5,177, 98, 3,101, 98,101,103,
101,113,225,114,128, 1, 39,239,240,239,237,239,230,111,128, 49,
15,242,229,246,229,226,229,236,239,119,128, 30, 43, 99, 2,101,
131,101,140,229,228,233,236,236, 97,128, 30, 41,233,242, 99, 2,
101,148,101,153,236,101,128, 36,215,245,237,230,236,229,120,128,
1, 37,100, 2,101,168,101,178,233,229,242,229,243,233,115,128,
30, 39,239,116, 2,101,185,101,194,225,227,227,229,238,116,128,
30, 35,226,229,236,239,119,128, 30, 37,101,136, 5,212,101,222,
101,255,102, 19,102,248,103, 8,103, 53,103, 62,103, 75,225,242,
116,129, 38,101,101,230,243,245,233,116, 2,101,239,101,247,226,
236,225,227,107,128, 38,101,247,232,233,244,101,128, 38, 97,228,
225,231,229,243,104,129,251, 52,102, 10,232,229,226,242,229,119,
128,251, 52,104, 6,102, 33,102, 61,102, 69,102,119,102,165,102,
214, 97, 2,102, 39,102, 53,236,244,239,238,229,225,242,225,226,
233, 99,128, 6,193,242,225,226,233, 99,128, 6, 71,229,226,242,
229,119,128, 5,212,230,233,238,225,236, 97, 2,102, 80,102,111,
236,116, 2,102, 87,102, 99,239,238,229,225,242,225,226,233, 99,
128,251,167,244,247,239,225,242,225,226,233, 99,128,254,234,242,
225,226,233, 99,128,254,234,232,225,237,250,225,225,226,239,246,
101, 2,102,134,102,148,230,233,238,225,236,225,242,225,226,233,
99,128,251,165,233,243,239,236,225,244,229,228,225,242,225,226,
233, 99,128,251,164,105, 2,102,171,102,205,238,233,244,233,225,
236, 97, 2,102,183,102,197,236,244,239,238,229,225,242,225,226,
233, 99,128,251,168,242,225,226,233, 99,128,254,235,242,225,231,
225,238, 97,128, 48,120,237,229,228,233,225,236, 97, 2,102,226,
102,240,236,244,239,238,229,225,242,225,226,233, 99,128,251,169,
242,225,226,233, 99,128,254,236,233,243,229,233,229,242,225,243,
241,245,225,242,101,128, 51,123,107, 2,103, 14,103, 38,225,244,
225,235,225,238, 97,129, 48,216,103, 26,232,225,236,230,247,233,
228,244,104,128,255,141,245,244,225,225,242,245,243,241,245,225,
242,101,128, 51, 54,238,231,232,239,239,107,128, 2,103,242,245,
244,245,243,241,245,225,242,101,128, 51, 57,116,129, 5,215,103,
81,232,229,226,242,229,119,128, 5,215,232,239,239,107,129, 2,
102,103, 99,243,245,240,229,242,233,239,114,128, 2,177,105, 4,
103,120,103,205,103,216,103,241,229,245,104, 4,103,132,103,167,
103,182,103,191, 97, 2,103,138,103,153,227,233,242,227,236,229,
235,239,242,229,225,110,128, 50,123,240,225,242,229,238,235,239,
242,229,225,110,128, 50, 27,227,233,242,227,236,229,235,239,242,
229,225,110,128, 50,109,235,239,242,229,225,110,128, 49, 78,240,
225,242,229,238,235,239,242,229,225,110,128, 50, 13,232,233,242,
225,231,225,238, 97,128, 48,114,235,225,244,225,235,225,238, 97,
129, 48,210,103,229,232,225,236,230,247,233,228,244,104,128,255,
139,242,233,113,134, 5,180,104, 3,104, 8,104, 22,104, 31,104,
46,104, 62,177, 52,128, 5,180, 50, 2,104, 14,104, 18, 49,128,
5,180,100,128, 5,180,232,229,226,242,229,119,128, 5,180,238,
225,242,242,239,247,232,229,226,242,229,119,128, 5,180,241,245,
225,242,244,229,242,232,229,226,242,229,119,128, 5,180,247,233,
228,229,232,229,226,242,229,119,128, 5,180,236,233,238,229,226,
229,236,239,119,128, 30,150,237,239,238,239,243,240,225,227,101,
128,255, 72,111, 9,104,119,104,130,104,154,104,179,105, 11,105,
24,105,110,105,150,105,161,225,242,237,229,238,233,225,110,128,
5,112,232,105, 2,104,137,104,145,240,244,232,225,105,128, 14,
43,242,225,231,225,238, 97,128, 48,123,235,225,244,225,235,225,
238, 97,129, 48,219,104,167,232,225,236,230,247,233,228,244,104,
128,255,142,236,225,109,135, 5,185,104,199,104,204,104,209,104,
214,104,223,104,238,104,254,177, 57,128, 5,185,178, 54,128, 5,
185,179, 50,128, 5,185,232,229,226,242,229,119,128, 5,185,238,
225,242,242,239,247,232,229,226,242,229,119,128, 5,185,241,245,
225,242,244,229,242,232,229,226,242,229,119,128, 5,185,247,233,
228,229,232,229,226,242,229,119,128, 5,185,238,239,235,232,245,
235,244,232,225,105,128, 14, 46,111, 2,105, 30,105,100,107, 4,
105, 40,105, 52,105, 58,105, 80,225,226,239,246,229,227,239,237,
98,128, 3, 9,227,237, 98,128, 3, 9,240,225,236,225,244,225,
236,233,250,229,228,226,229,236,239,247,227,237, 98,128, 3, 33,
242,229,244,242,239,230,236,229,248,226,229,236,239,247,227,237,
98,128, 3, 34,238,243,241,245,225,242,101,128, 51, 66,114, 2,
105,116,105,143,105, 2,105,122,105,131,227,239,240,244,233, 99,
128, 3,233,250,239,238,244,225,236,226,225,114,128, 32, 21,238,
227,237, 98,128, 3, 27,244,243,240,242,233,238,231,115,128, 38,
104,245,243,101,128, 35, 2,240,225,242,229,110,128, 36,163,243,
245,240,229,242,233,239,114,128, 2,176,244,245,242,238,229,100,
128, 2,101,117, 4,105,205,105,216,105,229,105,254,232,233,242,
225,231,225,238, 97,128, 48,117,233,233,244,239,243,241,245,225,
242,101,128, 51, 51,235,225,244,225,235,225,238, 97,129, 48,213,
105,242,232,225,236,230,247,233,228,244,104,128,255,140,238,231,
225,242,245,237,236,225,245,116,129, 2,221,106, 13,227,237, 98,
128, 3, 11,118,128, 1,149,249,240,232,229,110,132, 0, 45,106,
39,106, 50,106, 62,106, 85,233,238,230,229,242,233,239,114,128,
246,229,237,239,238,239,243,240,225,227,101,128,255, 13,115, 2,
106, 68,106, 75,237,225,236,108,128,254, 99,245,240,229,242,233,
239,114,128,246,230,244,247,111,128, 32, 16,105,149, 0,105,106,
137,106,160,106,194,106,241,110,123,110,243,111, 24,111, 51,111,
213,111,217,111,255,112, 21,112,105,113, 14,113, 89,113, 97,113,
110,113,197,113,254,114, 26,114, 70,225, 99, 2,106,144,106,150,
245,244,101,128, 0,237,249,242,233,236,236,233, 99,128, 4, 79,
98, 3,106,168,106,177,106,187,229,238,231,225,236,105,128, 9,
135,239,240,239,237,239,230,111,128, 49, 39,242,229,246,101,128,
1, 45, 99, 3,106,202,106,209,106,231,225,242,239,110,128, 1,
208,233,242, 99, 2,106,217,106,222,236,101,128, 36,216,245,237,
230,236,229,120,128, 0,238,249,242,233,236,236,233, 99,128, 4,
86,100, 4,106,251,107, 5,110, 80,110,113,226,236,231,242,225,
246,101,128, 2, 9,101, 2,107, 11,110, 75,239,231,242,225,240,
104, 7,107, 32,107, 46,107, 59,109,244,110, 19,110, 32,110, 44,
229,225,242,244,232,227,233,242,227,236,101,128, 50,143,230,233,
242,229,227,233,242,227,236,101,128, 50,139,233, 99, 14,107, 90,
107,106,107,205,108, 3,108, 69,108, 98,108,114,108,171,108,220,
108,232,109, 3,109, 70,109,208,109,237,225,236,236,233,225,238,
227,229,240,225,242,229,110,128, 50, 63, 99, 4,107,116,107,127,
107,141,107,148,225,236,236,240,225,242,229,110,128, 50, 58,229,
238,244,242,229,227,233,242,227,236,101,128, 50,165,236,239,243,
101,128, 48, 6,111, 3,107,156,107,171,107,191,237,237, 97,129,
48, 1,107,164,236,229,230,116,128,255,100,238,231,242,225,244,
245,236,225,244,233,239,238,240,225,242,229,110,128, 50, 55,242,
242,229,227,244,227,233,242,227,236,101,128, 50,163,101, 3,107,
213,107,225,107,242,225,242,244,232,240,225,242,229,110,128, 50,
47,238,244,229,242,240,242,233,243,229,240,225,242,229,110,128,
50, 61,248,227,229,236,236,229,238,244,227,233,242,227,236,101,
128, 50,157,102, 2,108, 9,108, 24,229,243,244,233,246,225,236,
240,225,242,229,110,128, 50, 64,105, 2,108, 30,108, 59,238,225,
238,227,233,225,108, 2,108, 42,108, 51,227,233,242,227,236,101,
128, 50,150,240,225,242,229,110,128, 50, 54,242,229,240,225,242,
229,110,128, 50, 43,104, 2,108, 75,108, 86,225,246,229,240,225,
242,229,110,128, 50, 50,233,231,232,227,233,242,227,236,101,128,
50,164,233,244,229,242,225,244,233,239,238,237,225,242,107,128,
48, 5,108, 3,108,122,108,148,108,160,225,226,239,114, 2,108,
131,108,140,227,233,242,227,236,101,128, 50,152,240,225,242,229,
110,128, 50, 56,229,230,244,227,233,242,227,236,101,128, 50,167,
239,247,227,233,242,227,236,101,128, 50,166,109, 2,108,177,108,
209,101, 2,108,183,108,198,228,233,227,233,238,229,227,233,242,
227,236,101,128, 50,169,244,225,236,240,225,242,229,110,128, 50,
46,239,239,238,240,225,242,229,110,128, 50, 42,238,225,237,229,
240,225,242,229,110,128, 50, 52,112, 2,108,238,108,246,229,242,
233,239,100,128, 48, 2,242,233,238,244,227,233,242,227,236,101,
128, 50,158,114, 2,109, 9,109, 57,101, 3,109, 17,109, 28,109,
43,225,227,232,240,225,242,229,110,128, 50, 67,240,242,229,243,
229,238,244,240,225,242,229,110,128, 50, 57,243,239,245,242,227,
229,240,225,242,229,110,128, 50, 62,233,231,232,244,227,233,242,
227,236,101,128, 50,168,115, 5,109, 82,109,111,109,125,109,150,
109,178,101, 2,109, 88,109,101,227,242,229,244,227,233,242,227,
236,101,128, 50,153,236,230,240,225,242,229,110,128, 50, 66,239,
227,233,229,244,249,240,225,242,229,110,128, 50, 51,112, 2,109,
131,109,137,225,227,101,128, 48, 0,229,227,233,225,236,240,225,
242,229,110,128, 50, 53,116, 2,109,156,109,167,239,227,235,240,
225,242,229,110,128, 50, 49,245,228,249,240,225,242,229,110,128,
50, 59,117, 2,109,184,109,193,238,240,225,242,229,110,128, 50,
48,240,229,242,246,233,243,229,240,225,242,229,110,128, 50, 60,
119, 2,109,214,109,226,225,244,229,242,240,225,242,229,110,128,
50, 44,239,239,228,240,225,242,229,110,128, 50, 45,250,229,242,
111,128, 48, 7,109, 2,109,250,110, 7,229,244,225,236,227,233,
242,227,236,101,128, 50,142,239,239,238,227,233,242,227,236,101,
128, 50,138,238,225,237,229,227,233,242,227,236,101,128, 50,148,
243,245,238,227,233,242,227,236,101,128, 50,144,119, 2,110, 50,
110, 63,225,244,229,242,227,233,242,227,236,101,128, 50,140,239,
239,228,227,233,242,227,236,101,128, 50,141,246, 97,128, 9, 7,
233,229,242,229,243,233,115,130, 0,239,110, 94,110,102,225,227,
245,244,101,128, 30, 47,227,249,242,233,236,236,233, 99,128, 4,
229,239,244,226,229,236,239,119,128, 30,203,101, 3,110,131,110,
147,110,158,226,242,229,246,229,227,249,242,233,236,236,233, 99,
128, 4,215,227,249,242,233,236,236,233, 99,128, 4, 53,245,238,
103, 4,110,170,110,205,110,220,110,229, 97, 2,110,176,110,191,
227,233,242,227,236,229,235,239,242,229,225,110,128, 50,117,240,
225,242,229,238,235,239,242,229,225,110,128, 50, 21,227,233,242,
227,236,229,235,239,242,229,225,110,128, 50,103,235,239,242,229,
225,110,128, 49, 71,240,225,242,229,238,235,239,242,229,225,110,
128, 50, 7,103, 2,110,249,111, 0,242,225,246,101,128, 0,236,
117, 2,111, 6,111, 15,234,225,242,225,244,105,128, 10,135,242,
237,245,235,232,105,128, 10, 7,104, 2,111, 30,111, 40,233,242,
225,231,225,238, 97,128, 48, 68,239,239,235,225,226,239,246,101,
128, 30,201,105, 8,111, 69,111, 79,111, 90,111, 97,111,122,111,
138,111,153,111,169,226,229,238,231,225,236,105,128, 9,136,227,
249,242,233,236,236,233, 99,128, 4, 56,228,229,246, 97,128, 9,
8,231,117, 2,111,104,111,113,234,225,242,225,244,105,128, 10,
136,242,237,245,235,232,105,128, 10, 8,237,225,244,242,225,231,
245,242,237,245,235,232,105,128, 10, 64,238,246,229,242,244,229,
228,226,242,229,246,101,128, 2, 11,243,232,239,242,244,227,249,
242,233,236,236,233, 99,128, 4, 57,246,239,247,229,236,243,233,
231,110, 3,111,185,111,195,111,202,226,229,238,231,225,236,105,
128, 9,192,228,229,246, 97,128, 9, 64,231,245,234,225,242,225,
244,105,128, 10,192,106,128, 1, 51,107, 2,111,223,111,247,225,
244,225,235,225,238, 97,129, 48,164,111,235,232,225,236,230,247,
233,228,244,104,128,255,114,239,242,229,225,110,128, 49, 99,108,
2,112, 5,112, 10,228,101,128, 2,220,245,249,232,229,226,242,
229,119,128, 5,172,109, 2,112, 27,112, 94, 97, 3,112, 35,112,
55,112, 80,227,242,239,110,129, 1, 43,112, 44,227,249,242,233,
236,236,233, 99,128, 4,227,231,229,239,242,225,240,240,242,239,
248,233,237,225,244,229,236,249,229,241,245,225,108,128, 34, 83,
244,242,225,231,245,242,237,245,235,232,105,128, 10, 63,239,238,
239,243,240,225,227,101,128,255, 73,110, 5,112,117,112,127,112,
136,112,148,112,232,227,242,229,237,229,238,116,128, 34, 6,230,
233,238,233,244,121,128, 34, 30,233,225,242,237,229,238,233,225,
110,128, 5,107,116, 2,112,154,112,222,101, 2,112,160,112,211,
231,242,225,108,131, 34, 43,112,173,112,191,112,196, 98, 2,112,
179,112,187,239,244,244,239,109,128, 35, 33,116,128, 35, 33,229,
120,128,248,245,116, 2,112,202,112,207,239,112,128, 35, 32,112,
128, 35, 32,242,243,229,227,244,233,239,110,128, 34, 41,233,243,
241,245,225,242,101,128, 51, 5,118, 3,112,240,112,249,113, 2,
226,245,236,236,229,116,128, 37,216,227,233,242,227,236,101,128,
37,217,243,237,233,236,229,230,225,227,101,128, 38, 59,111, 3,
113, 22,113, 33,113, 41,227,249,242,233,236,236,233, 99,128, 4,
81,231,239,238,229,107,128, 1, 47,244, 97,131, 3,185,113, 52,
113, 73,113, 81,228,233,229,242,229,243,233,115,129, 3,202,113,
65,244,239,238,239,115,128, 3,144,236,225,244,233,110,128, 2,
105,244,239,238,239,115,128, 3,175,240,225,242,229,110,128, 36,
164,242,233,231,245,242,237,245,235,232,105,128, 10,114,115, 4,
113,120,113,165,113,179,113,187,237,225,236,108, 2,113,129,113,
140,232,233,242,225,231,225,238, 97,128, 48, 67,235,225,244,225,
235,225,238, 97,129, 48,163,113,153,232,225,236,230,247,233,228,
244,104,128,255,104,243,232,225,242,226,229,238,231,225,236,105,
128, 9,250,244,242,239,235,101,128, 2,104,245,240,229,242,233,
239,114,128,246,237,116, 2,113,203,113,237,229,242,225,244,233,
239,110, 2,113,215,113,226,232,233,242,225,231,225,238, 97,128,
48,157,235,225,244,225,235,225,238, 97,128, 48,253,233,236,228,
101,129, 1, 41,113,246,226,229,236,239,119,128, 30, 45,117, 2,
114, 4,114, 15,226,239,240,239,237,239,230,111,128, 49, 41,227,
249,242,233,236,236,233, 99,128, 4, 78,246,239,247,229,236,243,
233,231,110, 3,114, 42,114, 52,114, 59,226,229,238,231,225,236,
105,128, 9,191,228,229,246, 97,128, 9, 63,231,245,234,225,242,
225,244,105,128, 10,191,250,232,233,244,243, 97, 2,114, 81,114,
92,227,249,242,233,236,236,233, 99,128, 4,117,228,226,236,231,
242,225,246,229,227,249,242,233,236,236,233, 99,128, 4,119,106,
138, 0,106,114,135,114,198,114,209,115, 3,115, 19,115,132,115,
201,115,206,115,218,115,226, 97, 4,114,145,114,156,114,166,114,
173,225,242,237,229,238,233,225,110,128, 5,113,226,229,238,231,
225,236,105,128, 9,156,228,229,246, 97,128, 9, 28,231,117, 2,
114,180,114,189,234,225,242,225,244,105,128, 10,156,242,237,245,
235,232,105,128, 10, 28,226,239,240,239,237,239,230,111,128, 49,
16, 99, 3,114,217,114,224,114,246,225,242,239,110,128, 1,240,
233,242, 99, 2,114,232,114,237,236,101,128, 36,217,245,237,230,
236,229,120,128, 1, 53,242,239,243,243,229,228,244,225,233,108,
128, 2,157,228,239,244,236,229,243,243,243,244,242,239,235,101,
128, 2, 95,101, 3,115, 27,115, 38,115,103,227,249,242,233,236,
236,233, 99,128, 4, 88,229,109, 4,115, 49,115, 58,115, 72,115,
88,225,242,225,226,233, 99,128, 6, 44,230,233,238,225,236,225,
242,225,226,233, 99,128,254,158,233,238,233,244,233,225,236,225,
242,225,226,233, 99,128,254,159,237,229,228,233,225,236,225,242,
225,226,233, 99,128,254,160,104, 2,115,109,115,118,225,242,225,
226,233, 99,128, 6,152,230,233,238,225,236,225,242,225,226,233,
99,128,251,139,104, 2,115,138,115,188, 97, 3,115,146,115,156,
115,163,226,229,238,231,225,236,105,128, 9,157,228,229,246, 97,
128, 9, 29,231,117, 2,115,170,115,179,234,225,242,225,244,105,
128, 10,157,242,237,245,235,232,105,128, 10, 29,229,232,225,242,
237,229,238,233,225,110,128, 5,123,233,115,128, 48, 4,237,239,
238,239,243,240,225,227,101,128,255, 74,240,225,242,229,110,128,
36,165,243,245,240,229,242,233,239,114,128, 2,178,107,146, 0,
107,116, 21,118,110,118,121,118,183,118,194,119, 28,119, 42,120,
150,121, 90,121,103,121,129,121,178,122, 60,122, 82,122, 95,122,
118,122,160,122,170, 97, 12,116, 47,116, 79,116,101,116,131,116,
245,117, 14,117, 44,117, 69,117,175,117,189,118, 56,118, 85, 98,
2,116, 53,116, 70,225,243,232,235,233,242,227,249,242,233,236,
236,233, 99,128, 4,161,229,238,231,225,236,105,128, 9,149, 99,
2,116, 85,116, 91,245,244,101,128, 30, 49,249,242,233,236,236,
233, 99,128, 4, 58,228,101, 2,116,108,116,126,243,227,229,238,
228,229,242,227,249,242,233,236,236,233, 99,128, 4,155,246, 97,
128, 9, 21,102,135, 5,219,116,149,116,158,116,178,116,192,116,
201,116,217,116,232,225,242,225,226,233, 99,128, 6, 67,228,225,
231,229,243,104,129,251, 59,116,169,232,229,226,242,229,119,128,
251, 59,230,233,238,225,236,225,242,225,226,233, 99,128,254,218,
232,229,226,242,229,119,128, 5,219,233,238,233,244,233,225,236,
225,242,225,226,233, 99,128,254,219,237,229,228,233,225,236,225,
242,225,226,233, 99,128,254,220,242,225,230,229,232,229,226,242,
229,119,128,251, 77,231,117, 2,116,252,117, 5,234,225,242,225,
244,105,128, 10,149,242,237,245,235,232,105,128, 10, 21,104, 2,
117, 20,117, 30,233,242,225,231,225,238, 97,128, 48, 75,239,239,
235,227,249,242,233,236,236,233, 99,128, 4,196,235,225,244,225,
235,225,238, 97,129, 48,171,117, 57,232,225,236,230,247,233,228,
244,104,128,255,118,112, 2,117, 75,117, 96,240, 97,129, 3,186,
117, 82,243,249,237,226,239,236,231,242,229,229,107,128, 3,240,
249,229,239,245,110, 3,117,108,117,122,117,156,237,233,229,245,
237,235,239,242,229,225,110,128, 49,113,112, 2,117,128,117,143,
232,233,229,245,240,232,235,239,242,229,225,110,128, 49,132,233,
229,245,240,235,239,242,229,225,110,128, 49,120,243,243,225,238,
231,240,233,229,245,240,235,239,242,229,225,110,128, 49,121,242,
239,242,233,233,243,241,245,225,242,101,128, 51, 13,115, 5,117,
201,117,245,118, 4,118, 12,118, 40,232,233,228,225,225,245,244,
111, 2,117,214,117,223,225,242,225,226,233, 99,128, 6, 64,238,
239,243,233,228,229,226,229,225,242,233,238,231,225,242,225,226,
233, 99,128, 6, 64,237,225,236,236,235,225,244,225,235,225,238,
97,128, 48,245,241,245,225,242,101,128, 51,132,242, 97, 2,118,
19,118, 28,225,242,225,226,233, 99,128, 6, 80,244,225,238,225,
242,225,226,233, 99,128, 6, 77,244,242,239,235,229,227,249,242,
233,236,236,233, 99,128, 4,159,244,225,232,233,242,225,240,242,
239,236,239,238,231,237,225,242,235,232,225,236,230,247,233,228,
244,104,128,255,112,246,229,242,244,233,227,225,236,243,244,242,
239,235,229,227,249,242,233,236,236,233, 99,128, 4,157,226,239,
240,239,237,239,230,111,128, 49, 14, 99, 4,118,131,118,153,118,
162,118,170, 97, 2,118,137,118,147,236,243,241,245,225,242,101,
128, 51,137,242,239,110,128, 1,233,229,228,233,236,236, 97,128,
1, 55,233,242,227,236,101,128, 36,218,239,237,237,225,225,227,
227,229,238,116,128, 1, 55,228,239,244,226,229,236,239,119,128,
30, 51,101, 4,118,204,118,231,119, 0,119, 12,104, 2,118,210,
118,221,225,242,237,229,238,233,225,110,128, 5,132,233,242,225,
231,225,238, 97,128, 48, 81,235,225,244,225,235,225,238, 97,129,
48,177,118,244,232,225,236,230,247,233,228,244,104,128,255,121,
238,225,242,237,229,238,233,225,110,128, 5,111,243,237,225,236,
236,235,225,244,225,235,225,238, 97,128, 48,246,231,242,229,229,
238,236,225,238,228,233, 99,128, 1, 56,104, 6,119, 56,119,185,
119,196,119,221,120, 52,120,140, 97, 5,119, 68,119, 78,119, 89,
119, 96,119,121,226,229,238,231,225,236,105,128, 9,150,227,249,
242,233,236,236,233, 99,128, 4, 69,228,229,246, 97,128, 9, 22,
231,117, 2,119,103,119,112,234,225,242,225,244,105,128, 10,150,
242,237,245,235,232,105,128, 10, 22,104, 4,119,131,119,140,119,
154,119,170,225,242,225,226,233, 99,128, 6, 46,230,233,238,225,
236,225,242,225,226,233, 99,128,254,166,233,238,233,244,233,225,
236,225,242,225,226,233, 99,128,254,167,237,229,228,233,225,236,
225,242,225,226,233, 99,128,254,168,229,233,227,239,240,244,233,
99,128, 3,231,232, 97, 2,119,203,119,210,228,229,246, 97,128,
9, 89,231,245,242,237,245,235,232,105,128, 10, 89,233,229,245,
235,104, 4,119,235,120, 14,120, 29,120, 38, 97, 2,119,241,120,
0,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,120,
240,225,242,229,238,235,239,242,229,225,110,128, 50, 24,227,233,
242,227,236,229,235,239,242,229,225,110,128, 50,106,235,239,242,
229,225,110,128, 49, 75,240,225,242,229,238,235,239,242,229,225,
110,128, 50, 10,111, 4,120, 62,120,111,120,121,120,126,235,104,
4,120, 73,120, 82,120, 91,120,101,225,233,244,232,225,105,128,
14, 2,239,238,244,232,225,105,128, 14, 5,245,225,244,244,232,
225,105,128, 14, 3,247,225,233,244,232,225,105,128, 14, 4,237,
245,244,244,232,225,105,128, 14, 91,239,107,128, 1,153,242,225,
235,232,225,238,231,244,232,225,105,128, 14, 6,250,243,241,245,
225,242,101,128, 51,145,105, 4,120,160,120,171,120,196,120,245,
232,233,242,225,231,225,238, 97,128, 48, 77,235,225,244,225,235,
225,238, 97,129, 48,173,120,184,232,225,236,230,247,233,228,244,
104,128,255,119,242,111, 3,120,205,120,220,120,236,231,245,242,
225,237,245,243,241,245,225,242,101,128, 51, 21,237,229,229,244,
239,242,245,243,241,245,225,242,101,128, 51, 22,243,241,245,225,
242,101,128, 51, 20,249,229,239,107, 5,121, 4,121, 39,121, 54,
121, 63,121, 77, 97, 2,121, 10,121, 25,227,233,242,227,236,229,
235,239,242,229,225,110,128, 50,110,240,225,242,229,238,235,239,
242,229,225,110,128, 50, 14,227,233,242,227,236,229,235,239,242,
229,225,110,128, 50, 96,235,239,242,229,225,110,128, 49, 49,240,
225,242,229,238,235,239,242,229,225,110,128, 50, 0,243,233,239,
243,235,239,242,229,225,110,128, 49, 51,234,229,227,249,242,233,
236,236,233, 99,128, 4, 92,108, 2,121,109,121,120,233,238,229,
226,229,236,239,119,128, 30, 53,243,241,245,225,242,101,128, 51,
152,109, 3,121,137,121,151,121,162,227,245,226,229,228,243,241,
245,225,242,101,128, 51,166,239,238,239,243,240,225,227,101,128,
255, 75,243,241,245,225,242,229,228,243,241,245,225,242,101,128,
51,162,111, 5,121,190,121,216,121,254,122, 10,122, 24,104, 2,
121,196,121,206,233,242,225,231,225,238, 97,128, 48, 83,237,243,
241,245,225,242,101,128, 51,192,235, 97, 2,121,223,121,231,233,
244,232,225,105,128, 14, 1,244,225,235,225,238, 97,129, 48,179,
121,242,232,225,236,230,247,233,228,244,104,128,255,122,239,240,
239,243,241,245,225,242,101,128, 51, 30,240,240,225,227,249,242,
233,236,236,233, 99,128, 4,129,114, 2,122, 30,122, 50,229,225,
238,243,244,225,238,228,225,242,228,243,249,237,226,239,108,128,
50,127,239,238,233,243,227,237, 98,128, 3, 67,240, 97, 2,122,
67,122, 73,242,229,110,128, 36,166,243,241,245,225,242,101,128,
51,170,243,233,227,249,242,233,236,236,233, 99,128, 4,111,116,
2,122,101,122,110,243,241,245,225,242,101,128, 51,207,245,242,
238,229,100,128, 2,158,117, 2,122,124,122,135,232,233,242,225,
231,225,238, 97,128, 48, 79,235,225,244,225,235,225,238, 97,129,
48,175,122,148,232,225,236,230,247,233,228,244,104,128,255,120,
246,243,241,245,225,242,101,128, 51,184,247,243,241,245,225,242,
101,128, 51,190,108,146, 0,108,122,220,124,247,125, 20,125, 86,
125,124,126, 20,126, 29,126, 45,126, 69,126, 87,126,205,126,246,
127,125,127,133,127,166,127,175,127,183,127,245, 97, 7,122,236,
122,246,122,253,123, 4,123, 29,123, 45,124,235,226,229,238,231,
225,236,105,128, 9,178,227,245,244,101,128, 1, 58,228,229,246,
97,128, 9, 50,231,117, 2,123, 11,123, 20,234,225,242,225,244,
105,128, 10,178,242,237,245,235,232,105,128, 10, 50,235,235,232,
225,238,231,249,225,239,244,232,225,105,128, 14, 69,109, 10,123,
67,124, 6,124, 23,124, 61,124, 75,124, 94,124,110,124,130,124,
150,124,173, 97, 2,123, 73,123,254,236,229,102, 4,123, 85,123,
99,123,191,123,208,230,233,238,225,236,225,242,225,226,233, 99,
128,254,252,232,225,237,250, 97, 2,123,109,123,150,225,226,239,
246,101, 2,123,119,123,133,230,233,238,225,236,225,242,225,226,
233, 99,128,254,248,233,243,239,236,225,244,229,228,225,242,225,
226,233, 99,128,254,247,226,229,236,239,119, 2,123,160,123,174,
230,233,238,225,236,225,242,225,226,233, 99,128,254,250,233,243,
239,236,225,244,229,228,225,242,225,226,233, 99,128,254,249,233,
243,239,236,225,244,229,228,225,242,225,226,233, 99,128,254,251,
237,225,228,228,225,225,226,239,246,101, 2,123,223,123,237,230,
233,238,225,236,225,242,225,226,233, 99,128,254,246,233,243,239,
236,225,244,229,228,225,242,225,226,233, 99,128,254,245,242,225,
226,233, 99,128, 6, 68,226,228, 97,129, 3,187,124, 14,243,244,
242,239,235,101,128, 1,155,229,100,130, 5,220,124, 32,124, 52,
228,225,231,229,243,104,129,251, 60,124, 43,232,229,226,242,229,
119,128,251, 60,232,229,226,242,229,119,128, 5,220,230,233,238,
225,236,225,242,225,226,233, 99,128,254,222,232,225,232,233,238,
233,244,233,225,236,225,242,225,226,233, 99,128,252,202,233,238,
233,244,233,225,236,225,242,225,226,233, 99,128,254,223,234,229,
229,237,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
252,201,235,232,225,232,233,238,233,244,233,225,236,225,242,225,
226,233, 99,128,252,203,236,225,237,232,229,232,233,243,239,236,
225,244,229,228,225,242,225,226,233, 99,128,253,242,237,101, 2,
124,180,124,193,228,233,225,236,225,242,225,226,233, 99,128,254,
224,229,109, 2,124,200,124,219,232,225,232,233,238,233,244,233,
225,236,225,242,225,226,233, 99,128,253,136,233,238,233,244,233,
225,236,225,242,225,226,233, 99,128,252,204,242,231,229,227,233,
242,227,236,101,128, 37,239, 98, 3,124,255,125, 4,125, 10,225,
114,128, 1,154,229,236,116,128, 2,108,239,240,239,237,239,230,
111,128, 49, 12, 99, 4,125, 30,125, 37,125, 46,125, 73,225,242,
239,110,128, 1, 62,229,228,233,236,236, 97,128, 1, 60,233,242,
99, 2,125, 54,125, 59,236,101,128, 36,219,245,237,230,236,229,
248,226,229,236,239,119,128, 30, 61,239,237,237,225,225,227,227,
229,238,116,128, 1, 60,228,239,116,130, 1, 64,125, 96,125,105,
225,227,227,229,238,116,128, 1, 64,226,229,236,239,119,129, 30,
55,125,115,237,225,227,242,239,110,128, 30, 57,101, 3,125,132,
125,170,126, 15,230,116, 2,125,139,125,155,225,238,231,236,229,
225,226,239,246,229,227,237, 98,128, 3, 26,244,225,227,235,226,
229,236,239,247,227,237, 98,128, 3, 24,243,115,132, 0, 60,125,
183,125,205,125,217,126, 7,229,241,245,225,108,129, 34,100,125,
193,239,242,231,242,229,225,244,229,114,128, 34,218,237,239,238,
239,243,240,225,227,101,128,255, 28,111, 2,125,223,125,252,114,
2,125,229,125,242,229,241,245,233,246,225,236,229,238,116,128,
34,114,231,242,229,225,244,229,114,128, 34,118,246,229,242,229,
241,245,225,108,128, 34,102,243,237,225,236,108,128,254,100,250,
104,128, 2,110,230,226,236,239,227,107,128, 37,140,232,239,239,
235,242,229,244,242,239,230,236,229,120,128, 2,109,105, 2,126,
51,126, 56,242, 97,128, 32,164,247,238,225,242,237,229,238,233,
225,110,128, 5,108,106,129, 1,201,126, 75,229,227,249,242,233,
236,236,233, 99,128, 4, 89,108,132,246,192,126, 99,126,123,126,
134,126,143, 97, 2,126,105,126,112,228,229,246, 97,128, 9, 51,
231,245,234,225,242,225,244,105,128, 10,179,233,238,229,226,229,
236,239,119,128, 30, 59,236,225,228,229,246, 97,128, 9, 52,246,
239,227,225,236,233, 99, 3,126,157,126,167,126,174,226,229,238,
231,225,236,105,128, 9,225,228,229,246, 97,128, 9, 97,246,239,
247,229,236,243,233,231,110, 2,126,188,126,198,226,229,238,231,
225,236,105,128, 9,227,228,229,246, 97,128, 9, 99,109, 3,126,
213,126,226,126,237,233,228,228,236,229,244,233,236,228,101,128,
2,107,239,238,239,243,240,225,227,101,128,255, 76,243,241,245,
225,242,101,128, 51,208,111, 6,127, 4,127, 16,127, 58,127, 69,
127, 75,127,117,227,232,245,236,225,244,232,225,105,128, 14, 44,
231,233,227,225,108, 3,127, 28,127, 34,127, 53,225,238,100,128,
34, 39,238,239,116,129, 0,172,127, 42,242,229,246,229,242,243,
229,100,128, 35, 16,239,114,128, 34, 40,236,233,238,231,244,232,
225,105,128, 14, 37,238,231,115,128, 1,127,247,236,233,238,101,
2,127, 85,127,108, 99, 2,127, 91,127,103,229,238,244,229,242,
236,233,238,101,128,254, 78,237, 98,128, 3, 50,228,225,243,232,
229,100,128,254, 77,250,229,238,231,101,128, 37,202,240,225,242,
229,110,128, 36,167,115, 3,127,141,127,148,127,156,236,225,243,
104,128, 1, 66,241,245,225,242,101,128, 33, 19,245,240,229,242,
233,239,114,128,246,238,244,243,232,225,228,101,128, 37,145,245,
244,232,225,105,128, 14, 38,246,239,227,225,236,233, 99, 3,127,
197,127,207,127,214,226,229,238,231,225,236,105,128, 9,140,228,
229,246, 97,128, 9, 12,246,239,247,229,236,243,233,231,110, 2,
127,228,127,238,226,229,238,231,225,236,105,128, 9,226,228,229,
246, 97,128, 9, 98,248,243,241,245,225,242,101,128, 51,211,109,
144, 0,109,128, 35,130,144,130,169,130,196,130,221,132, 18,132,
40,133, 95,133,125,133,174,134, 25,134, 47,134, 72,134, 81,135,
108,135,136, 97, 12,128, 61,128, 71,128,135,128,142,128,167,128,
215,130, 51,130, 76,130, 81,130, 95,130,107,130,112,226,229,238,
231,225,236,105,128, 9,174, 99, 2,128, 77,128,129,242,239,110,
132, 0,175,128, 91,128,102,128,108,128,117,226,229,236,239,247,
227,237, 98,128, 3, 49,227,237, 98,128, 3, 4,236,239,247,237,
239,100,128, 2,205,237,239,238,239,243,240,225,227,101,128,255,
227,245,244,101,128, 30, 63,228,229,246, 97,128, 9, 46,231,117,
2,128,149,128,158,234,225,242,225,244,105,128, 10,174,242,237,
245,235,232,105,128, 10, 46,104, 2,128,173,128,205,225,240,225,
235,104, 2,128,183,128,192,232,229,226,242,229,119,128, 5,164,
236,229,230,244,232,229,226,242,229,119,128, 5,164,233,242,225,
231,225,238, 97,128, 48,126,105, 5,128,227,129, 40,129,103,129,
133,130, 39,227,232,225,244,244,225,247, 97, 3,128,242,129, 17,
129, 24,236,239,119, 2,128,250,129, 5,236,229,230,244,244,232,
225,105,128,248,149,242,233,231,232,244,244,232,225,105,128,248,
148,244,232,225,105,128, 14, 75,245,240,240,229,242,236,229,230,
244,244,232,225,105,128,248,147,229,107, 3,129, 49,129, 80,129,
87,236,239,119, 2,129, 57,129, 68,236,229,230,244,244,232,225,
105,128,248,140,242,233,231,232,244,244,232,225,105,128,248,139,
244,232,225,105,128, 14, 72,245,240,240,229,242,236,229,230,244,
244,232,225,105,128,248,138,232,225,238,225,235,225,116, 2,129,
115,129,126,236,229,230,244,244,232,225,105,128,248,132,244,232,
225,105,128, 14, 49,116, 3,129,141,129,169,129,232,225,233,235,
232,117, 2,129,151,129,162,236,229,230,244,244,232,225,105,128,
248,137,244,232,225,105,128, 14, 71,232,111, 3,129,178,129,209,
129,216,236,239,119, 2,129,186,129,197,236,229,230,244,244,232,
225,105,128,248,143,242,233,231,232,244,244,232,225,105,128,248,
142,244,232,225,105,128, 14, 73,245,240,240,229,242,236,229,230,
244,244,232,225,105,128,248,141,242,105, 3,129,241,130, 16,130,
23,236,239,119, 2,129,249,130, 4,236,229,230,244,244,232,225,
105,128,248,146,242,233,231,232,244,244,232,225,105,128,248,145,
244,232,225,105,128, 14, 74,245,240,240,229,242,236,229,230,244,
244,232,225,105,128,248,144,249,225,237,239,235,244,232,225,105,
128, 14, 70,235,225,244,225,235,225,238, 97,129, 48,222,130, 64,
232,225,236,230,247,233,228,244,104,128,255,143,236,101,128, 38,
66,238,243,249,239,238,243,241,245,225,242,101,128, 51, 71,241,
225,230,232,229,226,242,229,119,128, 5,190,242,115,128, 38, 66,
115, 2,130,118,130,136,239,242,225,227,233,242,227,236,229,232,
229,226,242,229,119,128, 5,175,241,245,225,242,101,128, 51,131,
98, 2,130,150,130,160,239,240,239,237,239,230,111,128, 49, 7,
243,241,245,225,242,101,128, 51,212, 99, 2,130,175,130,183,233,
242,227,236,101,128, 36,220,245,226,229,228,243,241,245,225,242,
101,128, 51,165,228,239,116, 2,130,204,130,213,225,227,227,229,
238,116,128, 30, 65,226,229,236,239,119,128, 30, 67,101, 7,130,
237,131,108,131,119,131,134,131,159,131,196,131,208,101, 2,130,
243,131, 95,109, 4,130,253,131, 6,131, 20,131, 36,225,242,225,
226,233, 99,128, 6, 69,230,233,238,225,236,225,242,225,226,233,
99,128,254,226,233,238,233,244,233,225,236,225,242,225,226,233,
99,128,254,227,237,101, 2,131, 43,131, 56,228,233,225,236,225,
242,225,226,233, 99,128,254,228,229,237,105, 2,131, 64,131, 79,
238,233,244,233,225,236,225,242,225,226,233, 99,128,252,209,243,
239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 72,244,
239,242,245,243,241,245,225,242,101,128, 51, 77,232,233,242,225,
231,225,238, 97,128, 48,129,233,250,233,229,242,225,243,241,245,
225,242,101,128, 51,126,235,225,244,225,235,225,238, 97,129, 48,
225,131,147,232,225,236,230,247,233,228,244,104,128,255,146,109,
130, 5,222,131,167,131,187,228,225,231,229,243,104,129,251, 62,
131,178,232,229,226,242,229,119,128,251, 62,232,229,226,242,229,
119,128, 5,222,238,225,242,237,229,238,233,225,110,128, 5,116,
242,235,232, 97, 3,131,219,131,228,132, 5,232,229,226,242,229,
119,128, 5,165,235,229,230,245,236, 97, 2,131,239,131,248,232,
229,226,242,229,119,128, 5,166,236,229,230,244,232,229,226,242,
229,119,128, 5,166,236,229,230,244,232,229,226,242,229,119,128,
5,165,104, 2,132, 24,132, 30,239,239,107,128, 2,113,250,243,
241,245,225,242,101,128, 51,146,105, 6,132, 54,132, 91,132,228,
132,239,133, 8,133, 65,228,100, 2,132, 61,132, 86,236,229,228,
239,244,235,225,244,225,235,225,238,225,232,225,236,230,247,233,
228,244,104,128,255,101,239,116,128, 0,183,229,245,109, 5,132,
105,132,140,132,155,132,164,132,215, 97, 2,132,111,132,126,227,
233,242,227,236,229,235,239,242,229,225,110,128, 50,114,240,225,
242,229,238,235,239,242,229,225,110,128, 50, 18,227,233,242,227,
236,229,235,239,242,229,225,110,128, 50,100,235,239,242,229,225,
110,128, 49, 65,112, 2,132,170,132,202, 97, 2,132,176,132,190,
238,243,233,239,243,235,239,242,229,225,110,128, 49,112,242,229,
238,235,239,242,229,225,110,128, 50, 4,233,229,245,240,235,239,
242,229,225,110,128, 49,110,243,233,239,243,235,239,242,229,225,
110,128, 49,111,232,233,242,225,231,225,238, 97,128, 48,127,235,
225,244,225,235,225,238, 97,129, 48,223,132,252,232,225,236,230,
247,233,228,244,104,128,255,144,238,117, 2,133, 15,133, 60,115,
132, 34, 18,133, 27,133, 38,133, 47,133, 53,226,229,236,239,247,
227,237, 98,128, 3, 32,227,233,242,227,236,101,128, 34,150,237,
239,100,128, 2,215,240,236,245,115,128, 34, 19,244,101,128, 32,
50,242,105, 2,133, 72,133, 86,226,225,225,242,245,243,241,245,
225,242,101,128, 51, 74,243,241,245,225,242,101,128, 51, 73,108,
2,133,101,133,116,239,238,231,236,229,231,244,245,242,238,229,
100,128, 2,112,243,241,245,225,242,101,128, 51,150,109, 3,133,
133,133,147,133,158,227,245,226,229,228,243,241,245,225,242,101,
128, 51,163,239,238,239,243,240,225,227,101,128,255, 77,243,241,
245,225,242,229,228,243,241,245,225,242,101,128, 51,159,111, 5,
133,186,133,212,133,237,133,247,134, 0,104, 2,133,192,133,202,
233,242,225,231,225,238, 97,128, 48,130,237,243,241,245,225,242,
101,128, 51,193,235,225,244,225,235,225,238, 97,129, 48,226,133,
225,232,225,236,230,247,233,228,244,104,128,255,147,236,243,241,
245,225,242,101,128, 51,214,237,225,244,232,225,105,128, 14, 33,
246,229,242,243,243,241,245,225,242,101,129, 51,167,134, 15,228,
243,241,245,225,242,101,128, 51,168,240, 97, 2,134, 32,134, 38,
242,229,110,128, 36,168,243,241,245,225,242,101,128, 51,171,115,
2,134, 53,134, 62,243,241,245,225,242,101,128, 51,179,245,240,
229,242,233,239,114,128,246,239,244,245,242,238,229,100,128, 2,
111,117,141, 0,181,134,111,134,115,134,125,134,149,134,159,134,
181,134,192,134,217,134,240,134,250,135, 24,135, 88,135, 98, 49,
128, 0,181,225,243,241,245,225,242,101,128, 51,130,227,104, 2,
134,132,134,142,231,242,229,225,244,229,114,128, 34,107,236,229,
243,115,128, 34,106,230,243,241,245,225,242,101,128, 51,140,103,
2,134,165,134,172,242,229,229,107,128, 3,188,243,241,245,225,
242,101,128, 51,141,232,233,242,225,231,225,238, 97,128, 48,128,
235,225,244,225,235,225,238, 97,129, 48,224,134,205,232,225,236,
230,247,233,228,244,104,128,255,145,108, 2,134,223,134,232,243,
241,245,225,242,101,128, 51,149,244,233,240,236,121,128, 0,215,
237,243,241,245,225,242,101,128, 51,155,238,225,104, 2,135, 2,
135, 11,232,229,226,242,229,119,128, 5,163,236,229,230,244,232,
229,226,242,229,119,128, 5,163,115, 2,135, 30,135, 79,233, 99,
3,135, 39,135, 56,135, 67,225,236,238,239,244,101,129, 38,106,
135, 50,228,226,108,128, 38,107,230,236,225,244,243,233,231,110,
128, 38,109,243,232,225,242,240,243,233,231,110,128, 38,111,243,
241,245,225,242,101,128, 51,178,246,243,241,245,225,242,101,128,
51,182,247,243,241,245,225,242,101,128, 51,188,118, 2,135,114,
135,127,237,229,231,225,243,241,245,225,242,101,128, 51,185,243,
241,245,225,242,101,128, 51,183,119, 2,135,142,135,155,237,229,
231,225,243,241,245,225,242,101,128, 51,191,243,241,245,225,242,
101,128, 51,189,110,150, 0,110,135,212,136, 90,136,114,136,180,
136,205,137, 7,137, 17,137, 84,137,127,139,161,139,179,139,204,
139,235,140, 5,140, 70,142, 52,142, 60,142, 85,142, 93,143, 61,
143, 71,143, 81, 97, 8,135,230,135,250,136, 1,136, 8,136, 33,
136, 44,136, 69,136, 81, 98, 2,135,236,135,245,229,238,231,225,
236,105,128, 9,168,236, 97,128, 34, 7,227,245,244,101,128, 1,
68,228,229,246, 97,128, 9, 40,231,117, 2,136, 15,136, 24,234,
225,242,225,244,105,128, 10,168,242,237,245,235,232,105,128, 10,
40,232,233,242,225,231,225,238, 97,128, 48,106,235,225,244,225,
235,225,238, 97,129, 48,202,136, 57,232,225,236,230,247,233,228,
244,104,128,255,133,240,239,243,244,242,239,240,232,101,128, 1,
73,243,241,245,225,242,101,128, 51,129, 98, 2,136, 96,136,106,
239,240,239,237,239,230,111,128, 49, 11,243,240,225,227,101,128,
0,160, 99, 4,136,124,136,131,136,140,136,167,225,242,239,110,
128, 1, 72,229,228,233,236,236, 97,128, 1, 70,233,242, 99, 2,
136,148,136,153,236,101,128, 36,221,245,237,230,236,229,248,226,
229,236,239,119,128, 30, 75,239,237,237,225,225,227,227,229,238,
116,128, 1, 70,228,239,116, 2,136,188,136,197,225,227,227,229,
238,116,128, 30, 69,226,229,236,239,119,128, 30, 71,101, 3,136,
213,136,224,136,249,232,233,242,225,231,225,238, 97,128, 48,109,
235,225,244,225,235,225,238, 97,129, 48,205,136,237,232,225,236,
230,247,233,228,244,104,128,255,136,247,243,232,229,241,229,236,
243,233,231,110,128, 32,170,230,243,241,245,225,242,101,128, 51,
139,103, 2,137, 23,137, 73, 97, 3,137, 31,137, 41,137, 48,226,
229,238,231,225,236,105,128, 9,153,228,229,246, 97,128, 9, 25,
231,117, 2,137, 55,137, 64,234,225,242,225,244,105,128, 10,153,
242,237,245,235,232,105,128, 10, 25,239,238,231,245,244,232,225,
105,128, 14, 7,104, 2,137, 90,137,100,233,242,225,231,225,238,
97,128, 48,147,239,239,107, 2,137,108,137,115,236,229,230,116,
128, 2,114,242,229,244,242,239,230,236,229,120,128, 2,115,105,
4,137,137,138, 50,138, 61,138,119,229,245,110, 7,137,155,137,
190,137,222,137,236,137,245,138, 22,138, 35, 97, 2,137,161,137,
176,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,111,
240,225,242,229,238,235,239,242,229,225,110,128, 50, 15,227,105,
2,137,197,137,209,229,245,227,235,239,242,229,225,110,128, 49,
53,242,227,236,229,235,239,242,229,225,110,128, 50, 97,232,233,
229,245,232,235,239,242,229,225,110,128, 49, 54,235,239,242,229,
225,110,128, 49, 52,240, 97, 2,137,252,138, 10,238,243,233,239,
243,235,239,242,229,225,110,128, 49,104,242,229,238,235,239,242,
229,225,110,128, 50, 1,243,233,239,243,235,239,242,229,225,110,
128, 49,103,244,233,235,229,245,244,235,239,242,229,225,110,128,
49,102,232,233,242,225,231,225,238, 97,128, 48,107,107, 2,138,
67,138, 91,225,244,225,235,225,238, 97,129, 48,203,138, 79,232,
225,236,230,247,233,228,244,104,128,255,134,232,225,232,233,116,
2,138,101,138,112,236,229,230,244,244,232,225,105,128,248,153,
244,232,225,105,128, 14, 77,238,101,141, 0, 57,138,150,138,159,
138,169,138,199,138,206,138,231,139, 2,139, 36,139, 48,139, 59,
139, 92,139,100,139,111,225,242,225,226,233, 99,128, 6,105,226,
229,238,231,225,236,105,128, 9,239,227,233,242,227,236,101,129,
36,104,138,180,233,238,246,229,242,243,229,243,225,238,243,243,
229,242,233,102,128, 39,146,228,229,246, 97,128, 9,111,231,117,
2,138,213,138,222,234,225,242,225,244,105,128, 10,239,242,237,
245,235,232,105,128, 10,111,232, 97, 2,138,238,138,249,227,235,
225,242,225,226,233, 99,128, 6,105,238,231,250,232,239,117,128,
48, 41,105, 2,139, 8,139, 26,228,229,239,231,242,225,240,232,
233,227,240,225,242,229,110,128, 50, 40,238,230,229,242,233,239,
114,128, 32,137,237,239,238,239,243,240,225,227,101,128,255, 25,
239,236,228,243,244,249,236,101,128,247, 57,112, 2,139, 65,139,
72,225,242,229,110,128, 36,124,229,114, 2,139, 79,139, 85,233,
239,100,128, 36,144,243,233,225,110,128, 6,249,242,239,237,225,
110,128, 33,120,243,245,240,229,242,233,239,114,128, 32,121,116,
2,139,117,139,155,229,229,110, 2,139,125,139,134,227,233,242,
227,236,101,128, 36,114,112, 2,139,140,139,147,225,242,229,110,
128, 36,134,229,242,233,239,100,128, 36,154,232,225,105,128, 14,
89,106,129, 1,204,139,167,229,227,249,242,233,236,236,233, 99,
128, 4, 90,235,225,244,225,235,225,238, 97,129, 48,243,139,192,
232,225,236,230,247,233,228,244,104,128,255,157,108, 2,139,210,
139,224,229,231,242,233,231,232,244,236,239,238,103,128, 1,158,
233,238,229,226,229,236,239,119,128, 30, 73,109, 2,139,241,139,
252,239,238,239,243,240,225,227,101,128,255, 78,243,241,245,225,
242,101,128, 51,154,110, 2,140, 11,140, 61, 97, 3,140, 19,140,
29,140, 36,226,229,238,231,225,236,105,128, 9,163,228,229,246,
97,128, 9, 35,231,117, 2,140, 43,140, 52,234,225,242,225,244,
105,128, 10,163,242,237,245,235,232,105,128, 10, 35,238,225,228,
229,246, 97,128, 9, 41,111, 6,140, 84,140, 95,140,120,140,161,
141,113,142, 40,232,233,242,225,231,225,238, 97,128, 48,110,235,
225,244,225,235,225,238, 97,129, 48,206,140,108,232,225,236,230,
247,233,228,244,104,128,255,137,110, 3,140,128,140,144,140,153,
226,242,229,225,235,233,238,231,243,240,225,227,101,128, 0,160,
229,238,244,232,225,105,128, 14, 19,245,244,232,225,105,128, 14,
25,239,110, 7,140,178,140,187,140,201,140,235,140,251,141, 36,
141, 95,225,242,225,226,233, 99,128, 6, 70,230,233,238,225,236,
225,242,225,226,233, 99,128,254,230,231,232,245,238,238, 97, 2,
140,212,140,221,225,242,225,226,233, 99,128, 6,186,230,233,238,
225,236,225,242,225,226,233, 99,128,251,159,233,238,233,244,233,
225,236,225,242,225,226,233, 99,128,254,231,234,229,229,237,105,
2,141, 5,141, 20,238,233,244,233,225,236,225,242,225,226,233,
99,128,252,210,243,239,236,225,244,229,228,225,242,225,226,233,
99,128,252, 75,237,101, 2,141, 43,141, 56,228,233,225,236,225,
242,225,226,233, 99,128,254,232,229,237,105, 2,141, 64,141, 79,
238,233,244,233,225,236,225,242,225,226,233, 99,128,252,213,243,
239,236,225,244,229,228,225,242,225,226,233, 99,128,252, 78,238,
239,239,238,230,233,238,225,236,225,242,225,226,233, 99,128,252,
141,116, 7,141,129,141,140,141,169,141,204,141,216,141,236,142,
6,227,239,238,244,225,233,238,115,128, 34, 12,101, 2,141,146,
141,162,236,229,237,229,238,116,129, 34, 9,141,157,239,102,128,
34, 9,241,245,225,108,128, 34, 96,231,242,229,225,244,229,114,
129, 34,111,141,181,238,239,114, 2,141,189,141,197,229,241,245,
225,108,128, 34,113,236,229,243,115,128, 34,121,233,228,229,238,
244,233,227,225,108,128, 34, 98,236,229,243,115,129, 34,110,141,
225,238,239,242,229,241,245,225,108,128, 34,112,112, 2,141,242,
141,252,225,242,225,236,236,229,108,128, 34, 38,242,229,227,229,
228,229,115,128, 34,128,243,117, 3,142, 15,142, 22,142, 31,226,
243,229,116,128, 34,132,227,227,229,229,228,115,128, 34,129,240,
229,242,243,229,116,128, 34,133,247,225,242,237,229,238,233,225,
110,128, 5,118,240,225,242,229,110,128, 36,169,115, 2,142, 66,
142, 75,243,241,245,225,242,101,128, 51,177,245,240,229,242,233,
239,114,128, 32,127,244,233,236,228,101,128, 0,241,117,132, 3,
189,142,105,142,116,142,197,143, 24,232,233,242,225,231,225,238,
97,128, 48,108,107, 2,142,122,142,146,225,244,225,235,225,238,
97,129, 48,204,142,134,232,225,236,230,247,233,228,244,104,128,
255,135,244, 97, 3,142,155,142,165,142,172,226,229,238,231,225,
236,105,128, 9,188,228,229,246, 97,128, 9, 60,231,117, 2,142,
179,142,188,234,225,242,225,244,105,128, 10,188,242,237,245,235,
232,105,128, 10, 60,109, 2,142,203,142,237,226,229,242,243,233,
231,110,130, 0, 35,142,217,142,229,237,239,238,239,243,240,225,
227,101,128,255, 3,243,237,225,236,108,128,254, 95,229,114, 2,
142,244,143, 20,225,236,243,233,231,110, 2,142,255,143, 7,231,
242,229,229,107,128, 3,116,236,239,247,229,242,231,242,229,229,
107,128, 3,117,111,128, 33, 22,110,130, 5,224,143, 32,143, 52,
228,225,231,229,243,104,129,251, 64,143, 43,232,229,226,242,229,
119,128,251, 64,232,229,226,242,229,119,128, 5,224,246,243,241,
245,225,242,101,128, 51,181,247,243,241,245,225,242,101,128, 51,
187,249, 97, 3,143, 90,143,100,143,107,226,229,238,231,225,236,
105,128, 9,158,228,229,246, 97,128, 9, 30,231,117, 2,143,114,
143,123,234,225,242,225,244,105,128, 10,158,242,237,245,235,232,
105,128, 10, 30,111,147, 0,111,143,174,143,196,144, 18,144,188,
145, 4,145, 19,145, 59,145,182,145,203,145,241,145,252,146,174,
148, 8,148, 72,148,105,148,151,149, 24,149, 71,149, 83, 97, 2,
143,180,143,187,227,245,244,101,128, 0,243,238,231,244,232,225,
105,128, 14, 45, 98, 4,143,206,143,248,144, 1,144, 11,225,242,
242,229,100,130, 2,117,143,218,143,229,227,249,242,233,236,236,
233, 99,128, 4,233,228,233,229,242,229,243,233,243,227,249,242,
233,236,236,233, 99,128, 4,235,229,238,231,225,236,105,128, 9,
147,239,240,239,237,239,230,111,128, 49, 27,242,229,246,101,128,
1, 79, 99, 3,144, 26,144, 99,144,178, 97, 2,144, 32,144, 93,
238,228,242, 97, 3,144, 43,144, 50,144, 61,228,229,246, 97,128,
9, 17,231,245,234,225,242,225,244,105,128, 10,145,246,239,247,
229,236,243,233,231,110, 2,144, 75,144, 82,228,229,246, 97,128,
9, 73,231,245,234,225,242,225,244,105,128, 10,201,242,239,110,
128, 1,210,233,242, 99, 2,144,107,144,112,236,101,128, 36,222,
245,237,230,236,229,120,133, 0,244,144,131,144,139,144,150,144,
158,144,170,225,227,245,244,101,128, 30,209,228,239,244,226,229,
236,239,119,128, 30,217,231,242,225,246,101,128, 30,211,232,239,
239,235,225,226,239,246,101,128, 30,213,244,233,236,228,101,128,
30,215,249,242,233,236,236,233, 99,128, 4, 62,100, 4,144,198,
144,221,144,227,144,250,226,108, 2,144,205,144,213,225,227,245,
244,101,128, 1, 81,231,242,225,246,101,128, 2, 13,229,246, 97,
128, 9, 19,233,229,242,229,243,233,115,129, 0,246,144,239,227,
249,242,233,236,236,233, 99,128, 4,231,239,244,226,229,236,239,
119,128, 30,205,101,129, 1, 83,145, 10,235,239,242,229,225,110,
128, 49, 90,103, 3,145, 27,145, 42,145, 49,239,238,229,107,129,
2,219,145, 36,227,237, 98,128, 3, 40,242,225,246,101,128, 0,
242,245,234,225,242,225,244,105,128, 10,147,104, 4,145, 69,145,
80,145, 90,145,168,225,242,237,229,238,233,225,110,128, 5,133,
233,242,225,231,225,238, 97,128, 48, 74,111, 2,145, 96,145,106,
239,235,225,226,239,246,101,128, 30,207,242,110,133, 1,161,145,
121,145,129,145,140,145,148,145,160,225,227,245,244,101,128, 30,
219,228,239,244,226,229,236,239,119,128, 30,227,231,242,225,246,
101,128, 30,221,232,239,239,235,225,226,239,246,101,128, 30,223,
244,233,236,228,101,128, 30,225,245,238,231,225,242,245,237,236,
225,245,116,128, 1, 81,105,129, 1,163,145,188,238,246,229,242,
244,229,228,226,242,229,246,101,128, 2, 15,107, 2,145,209,145,
233,225,244,225,235,225,238, 97,129, 48,170,145,221,232,225,236,
230,247,233,228,244,104,128,255,117,239,242,229,225,110,128, 49,
87,236,229,232,229,226,242,229,119,128, 5,171,109, 6,146, 10,
146, 38,146, 45,146,134,146,145,146,163,225,227,242,239,110,130,
1, 77,146, 22,146, 30,225,227,245,244,101,128, 30, 83,231,242,
225,246,101,128, 30, 81,228,229,246, 97,128, 9, 80,229,231, 97,
133, 3,201,146, 61,146, 65,146, 76,146, 90,146,106, 49,128, 3,
214,227,249,242,233,236,236,233, 99,128, 4, 97,236,225,244,233,
238,227,236,239,243,229,100,128, 2,119,242,239,245,238,228,227,
249,242,233,236,236,233, 99,128, 4,123,116, 2,146,112,146,127,
233,244,236,239,227,249,242,233,236,236,233, 99,128, 4,125,239,
238,239,115,128, 3,206,231,245,234,225,242,225,244,105,128, 10,
208,233,227,242,239,110,129, 3,191,146,155,244,239,238,239,115,
128, 3,204,239,238,239,243,240,225,227,101,128,255, 79,238,101,
145, 0, 49,146,213,146,222,146,232,147, 6,147, 31,147, 40,147,
49,147, 74,147,108,147,142,147,154,147,173,147,184,147,217,147,
227,147,235,147,246,225,242,225,226,233, 99,128, 6, 97,226,229,
238,231,225,236,105,128, 9,231,227,233,242,227,236,101,129, 36,
96,146,243,233,238,246,229,242,243,229,243,225,238,243,243,229,
242,233,102,128, 39,138,100, 2,147, 12,147, 18,229,246, 97,128,
9,103,239,244,229,238,236,229,225,228,229,114,128, 32, 36,229,
233,231,232,244,104,128, 33, 91,230,233,244,244,229,100,128,246,
220,231,117, 2,147, 56,147, 65,234,225,242,225,244,105,128, 10,
231,242,237,245,235,232,105,128, 10,103,232, 97, 3,147, 83,147,
94,147, 99,227,235,225,242,225,226,233, 99,128, 6, 97,236,102,
128, 0,189,238,231,250,232,239,117,128, 48, 33,105, 2,147,114,
147,132,228,229,239,231,242,225,240,232,233,227,240,225,242,229,
110,128, 50, 32,238,230,229,242,233,239,114,128, 32,129,237,239,
238,239,243,240,225,227,101,128,255, 17,238,245,237,229,242,225,
244,239,242,226,229,238,231,225,236,105,128, 9,244,239,236,228,
243,244,249,236,101,128,247, 49,112, 2,147,190,147,197,225,242,
229,110,128, 36,116,229,114, 2,147,204,147,210,233,239,100,128,
36,136,243,233,225,110,128, 6,241,241,245,225,242,244,229,114,
128, 0,188,242,239,237,225,110,128, 33,112,243,245,240,229,242,
233,239,114,128, 0,185,244,104, 2,147,253,148, 2,225,105,128,
14, 81,233,242,100,128, 33, 83,111, 3,148, 16,148, 50,148, 66,
103, 2,148, 22,148, 40,239,238,229,107,129, 1,235,148, 31,237,
225,227,242,239,110,128, 1,237,245,242,237,245,235,232,105,128,
10, 19,237,225,244,242,225,231,245,242,237,245,235,232,105,128,
10, 75,240,229,110,128, 2, 84,112, 3,148, 80,148, 87,148, 98,
225,242,229,110,128, 36,170,229,238,226,245,236,236,229,116,128,
37,230,244,233,239,110,128, 35, 37,114, 2,148,111,148,140,100,
2,148,117,148,128,230,229,237,233,238,233,238,101,128, 0,170,
237,225,243,227,245,236,233,238,101,128, 0,186,244,232,239,231,
239,238,225,108,128, 34, 31,115, 5,148,163,148,195,148,212,149,
1,149, 14,232,239,242,116, 2,148,172,148,179,228,229,246, 97,
128, 9, 18,246,239,247,229,236,243,233,231,238,228,229,246, 97,
128, 9, 74,236,225,243,104,129, 0,248,148,204,225,227,245,244,
101,128, 1,255,237,225,236,108, 2,148,221,148,232,232,233,242,
225,231,225,238, 97,128, 48, 73,235,225,244,225,235,225,238, 97,
129, 48,169,148,245,232,225,236,230,247,233,228,244,104,128,255,
107,244,242,239,235,229,225,227,245,244,101,128, 1,255,245,240,
229,242,233,239,114,128,246,240,116, 2,149, 30,149, 41,227,249,
242,233,236,236,233, 99,128, 4,127,233,236,228,101,130, 0,245,
149, 52,149, 60,225,227,245,244,101,128, 30, 77,228,233,229,242,
229,243,233,115,128, 30, 79,245,226,239,240,239,237,239,230,111,
128, 49, 33,118, 2,149, 89,149,170,229,114, 2,149, 96,149,162,
236,233,238,101,131, 32, 62,149,109,149,132,149,155, 99, 2,149,
115,149,127,229,238,244,229,242,236,233,238,101,128,254, 74,237,
98,128, 3, 5,100, 2,149,138,149,146,225,243,232,229,100,128,
254, 73,226,236,247,225,246,121,128,254, 76,247,225,246,121,128,
254, 75,243,227,239,242,101,128, 0,175,239,247,229,236,243,233,
231,110, 3,149,185,149,195,149,202,226,229,238,231,225,236,105,
128, 9,203,228,229,246, 97,128, 9, 75,231,245,234,225,242,225,
244,105,128, 10,203,112,145, 0,112,149,251,152,123,152,134,152,
143,152,155,154, 80,154, 90,155, 82,156,101,156,191,156,217,157,
92,157,100,158, 2,158, 60,158, 88,158, 98, 97, 14,150, 25,150,
57,150, 67,150, 74,150, 81,150,129,150,140,150,154,150,165,150,
212,150,226,151,238,152, 21,152,111, 97, 2,150, 31,150, 43,237,
240,243,243,241,245,225,242,101,128, 51,128,243,229,238,244,239,
243,241,245,225,242,101,128, 51, 43,226,229,238,231,225,236,105,
128, 9,170,227,245,244,101,128, 30, 85,228,229,246, 97,128, 9,
42,103, 2,150, 87,150,105,101, 2,150, 93,150,100,228,239,247,
110,128, 33,223,245,112,128, 33,222,117, 2,150,111,150,120,234,
225,242,225,244,105,128, 10,170,242,237,245,235,232,105,128, 10,
42,232,233,242,225,231,225,238, 97,128, 48,113,233,249,225,238,
238,239,233,244,232,225,105,128, 14, 47,235,225,244,225,235,225,
238, 97,128, 48,209,108, 2,150,171,150,196,225,244,225,236,233,
250,225,244,233,239,238,227,249,242,233,236,236,233,227,227,237,
98,128, 4,132,239,227,232,235,225,227,249,242,233,236,236,233,
99,128, 4,192,238,243,233,239,243,235,239,242,229,225,110,128,
49,127,114, 3,150,234,150,255,151,227, 97, 2,150,240,150,248,
231,242,225,240,104,128, 0,182,236,236,229,108,128, 34, 37,229,
110, 2,151, 6,151,116,236,229,230,116,136, 0, 40,151, 29,151,
44,151, 49,151, 54,151, 65,151, 77,151,100,151,105,225,236,244,
239,238,229,225,242,225,226,233, 99,128,253, 62,226,116,128,248,
237,229,120,128,248,236,233,238,230,229,242,233,239,114,128, 32,
141,237,239,238,239,243,240,225,227,101,128,255, 8,115, 2,151,
83,151, 90,237,225,236,108,128,254, 89,245,240,229,242,233,239,
114,128, 32,125,244,112,128,248,235,246,229,242,244,233,227,225,
108,128,254, 53,242,233,231,232,116,136, 0, 41,151,140,151,155,
151,160,151,165,151,176,151,188,151,211,151,216,225,236,244,239,
238,229,225,242,225,226,233, 99,128,253, 63,226,116,128,248,248,
229,120,128,248,247,233,238,230,229,242,233,239,114,128, 32,142,
237,239,238,239,243,240,225,227,101,128,255, 9,115, 2,151,194,
151,201,237,225,236,108,128,254, 90,245,240,229,242,233,239,114,
128, 32,126,244,112,128,248,246,246,229,242,244,233,227,225,108,
128,254, 54,244,233,225,236,228,233,230,102,128, 34, 2,115, 3,
151,246,152, 1,152, 13,229,241,232,229,226,242,229,119,128, 5,
192,232,244,225,232,229,226,242,229,119,128, 5,153,241,245,225,
242,101,128, 51,169,244,225,104,134, 5,183,152, 39,152, 53,152,
58,152, 67,152, 82,152, 98, 49, 2,152, 45,152, 49, 49,128, 5,
183,100,128, 5,183,178, 97,128, 5,183,232,229,226,242,229,119,
128, 5,183,238,225,242,242,239,247,232,229,226,242,229,119,128,
5,183,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
5,183,247,233,228,229,232,229,226,242,229,119,128, 5,183,250,
229,242,232,229,226,242,229,119,128, 5,161,226,239,240,239,237,
239,230,111,128, 49, 6,227,233,242,227,236,101,128, 36,223,228,
239,244,225,227,227,229,238,116,128, 30, 87,101,137, 5,228,152,
177,152,188,152,208,152,220,152,240,153, 86,153, 97,153,118,154,
73,227,249,242,233,236,236,233, 99,128, 4, 63,228,225,231,229,
243,104,129,251, 68,152,199,232,229,226,242,229,119,128,251, 68,
229,250,233,243,241,245,225,242,101,128, 51, 59,230,233,238,225,
236,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 67,
104, 5,152,252,153, 19,153, 27,153, 41,153, 71,225,114, 2,153,
3,153, 10,225,226,233, 99,128, 6,126,237,229,238,233,225,110,
128, 5,122,229,226,242,229,119,128, 5,228,230,233,238,225,236,
225,242,225,226,233, 99,128,251, 87,105, 2,153, 47,153, 62,238,
233,244,233,225,236,225,242,225,226,233, 99,128,251, 88,242,225,
231,225,238, 97,128, 48,122,237,229,228,233,225,236,225,242,225,
226,233, 99,128,251, 89,235,225,244,225,235,225,238, 97,128, 48,
218,237,233,228,228,236,229,232,239,239,235,227,249,242,233,236,
236,233, 99,128, 4,167,114, 5,153,130,153,142,153,184,154, 49,
154, 62,225,230,229,232,229,226,242,229,119,128,251, 78,227,229,
238,116,131, 0, 37,153,155,153,164,153,176,225,242,225,226,233,
99,128, 6,106,237,239,238,239,243,240,225,227,101,128,255, 5,
243,237,225,236,108,128,254,106,105, 2,153,190,154, 31,239,100,
134, 0, 46,153,207,153,218,153,229,153,241,153,252,154, 8,225,
242,237,229,238,233,225,110,128, 5,137,227,229,238,244,229,242,
229,100,128, 0,183,232,225,236,230,247,233,228,244,104,128,255,
97,233,238,230,229,242,233,239,114,128,246,231,237,239,238,239,
243,240,225,227,101,128,255, 14,115, 2,154, 14,154, 21,237,225,
236,108,128,254, 82,245,240,229,242,233,239,114,128,246,232,243,
240,239,237,229,238,233,231,242,229,229,235,227,237, 98,128, 3,
66,240,229,238,228,233,227,245,236,225,114,128, 34,165,244,232,
239,245,243,225,238,100,128, 32, 48,243,229,244, 97,128, 32,167,
230,243,241,245,225,242,101,128, 51,138,104, 3,154, 98,154,148,
155, 29, 97, 3,154,106,154,116,154,123,226,229,238,231,225,236,
105,128, 9,171,228,229,246, 97,128, 9, 43,231,117, 2,154,130,
154,139,234,225,242,225,244,105,128, 10,171,242,237,245,235,232,
105,128, 10, 43,105,133, 3,198,154,162,154,166,154,252,155, 4,
155, 15, 49,128, 3,213,229,245,240,104, 4,154,179,154,214,154,
229,154,238, 97, 2,154,185,154,200,227,233,242,227,236,229,235,
239,242,229,225,110,128, 50,122,240,225,242,229,238,235,239,242,
229,225,110,128, 50, 26,227,233,242,227,236,229,235,239,242,229,
225,110,128, 50,108,235,239,242,229,225,110,128, 49, 77,240,225,
242,229,238,235,239,242,229,225,110,128, 50, 12,236,225,244,233,
110,128, 2,120,238,244,232,245,244,232,225,105,128, 14, 58,243,
249,237,226,239,236,231,242,229,229,107,128, 3,213,111, 3,155,
37,155, 42,155, 68,239,107,128, 1,165,240,104, 2,155, 49,155,
58,225,238,244,232,225,105,128, 14, 30,245,238,231,244,232,225,
105,128, 14, 28,243,225,237,240,232,225,239,244,232,225,105,128,
14, 32,105,133, 3,192,155, 96,156, 52,156, 63,156, 74,156, 88,
229,245,112, 6,155,112,155,147,155,179,155,207,155,221,156, 17,
97, 2,155,118,155,133,227,233,242,227,236,229,235,239,242,229,
225,110,128, 50,115,240,225,242,229,238,235,239,242,229,225,110,
128, 50, 19,227,105, 2,155,154,155,166,229,245,227,235,239,242,
229,225,110,128, 49,118,242,227,236,229,235,239,242,229,225,110,
128, 50,101,107, 2,155,185,155,199,233,249,229,239,235,235,239,
242,229,225,110,128, 49,114,239,242,229,225,110,128, 49, 66,240,
225,242,229,238,235,239,242,229,225,110,128, 50, 5,243,233,239,
115, 2,155,230,156, 2,107, 2,155,236,155,250,233,249,229,239,
235,235,239,242,229,225,110,128, 49,116,239,242,229,225,110,128,
49, 68,244,233,235,229,245,244,235,239,242,229,225,110,128, 49,
117,116, 2,156, 23,156, 38,232,233,229,245,244,232,235,239,242,
229,225,110,128, 49,119,233,235,229,245,244,235,239,242,229,225,
110,128, 49,115,232,233,242,225,231,225,238, 97,128, 48,116,235,
225,244,225,235,225,238, 97,128, 48,212,243,249,237,226,239,236,
231,242,229,229,107,128, 3,214,247,242,225,242,237,229,238,233,
225,110,128, 5,131,236,245,115,132, 0, 43,156,115,156,126,156,
135,156,168,226,229,236,239,247,227,237, 98,128, 3, 31,227,233,
242,227,236,101,128, 34,149,109, 2,156,141,156,148,233,238,245,
115,128, 0,177,111, 2,156,154,156,158,100,128, 2,214,238,239,
243,240,225,227,101,128,255, 11,115, 2,156,174,156,181,237,225,
236,108,128,254, 98,245,240,229,242,233,239,114,128, 32,122,109,
2,156,197,156,208,239,238,239,243,240,225,227,101,128,255, 80,
243,241,245,225,242,101,128, 51,216,111, 5,156,229,156,240,157,
51,157, 62,157, 72,232,233,242,225,231,225,238, 97,128, 48,125,
233,238,244,233,238,231,233,238,228,229,120, 4,157, 4,157, 16,
157, 28,157, 41,228,239,247,238,247,232,233,244,101,128, 38, 31,
236,229,230,244,247,232,233,244,101,128, 38, 28,242,233,231,232,
244,247,232,233,244,101,128, 38, 30,245,240,247,232,233,244,101,
128, 38, 29,235,225,244,225,235,225,238, 97,128, 48,221,240,236,
225,244,232,225,105,128, 14, 27,243,244,225,236,237,225,242,107,
129, 48, 18,157, 85,230,225,227,101,128, 48, 32,240,225,242,229,
110,128, 36,171,114, 3,157,108,157,134,157,159,101, 2,157,114,
157,122,227,229,228,229,115,128, 34,122,243,227,242,233,240,244,
233,239,110,128, 33, 30,233,237,101, 2,157,142,157,148,237,239,
100,128, 2,185,242,229,246,229,242,243,229,100,128, 32, 53,111,
4,157,169,157,176,157,186,157,199,228,245,227,116,128, 34, 15,
234,229,227,244,233,246,101,128, 35, 5,236,239,238,231,229,228,
235,225,238, 97,128, 48,252,112, 2,157,205,157,242,101, 2,157,
211,157,218,236,236,239,114,128, 35, 24,242,243,117, 2,157,226,
157,233,226,243,229,116,128, 34,130,240,229,242,243,229,116,128,
34,131,239,242,244,233,239,110,129, 34, 55,157,253,225,108,128,
34, 29,115, 2,158, 8,158, 51,105,130, 3,200,158, 16,158, 27,
227,249,242,233,236,236,233, 99,128, 4,113,236,233,240,238,229,
245,237,225,244,225,227,249,242,233,236,236,233,227,227,237, 98,
128, 4,134,243,241,245,225,242,101,128, 51,176,117, 2,158, 66,
158, 77,232,233,242,225,231,225,238, 97,128, 48,119,235,225,244,
225,235,225,238, 97,128, 48,215,246,243,241,245,225,242,101,128,
51,180,247,243,241,245,225,242,101,128, 51,186,113,136, 0,113,
158,128,159,177,159,188,159,197,159,204,159,216,159,254,160, 6,
97, 4,158,138,158,161,158,225,159,160,100, 2,158,144,158,150,
229,246, 97,128, 9, 88,237,225,232,229,226,242,229,119,128, 5,
168,102, 4,158,171,158,180,158,194,158,210,225,242,225,226,233,
99,128, 6, 66,230,233,238,225,236,225,242,225,226,233, 99,128,
254,214,233,238,233,244,233,225,236,225,242,225,226,233, 99,128,
254,215,237,229,228,233,225,236,225,242,225,226,233, 99,128,254,
216,237,225,244,115,136, 5,184,158,248,159, 12,159, 26,159, 31,
159, 36,159, 45,159, 60,159,147, 49, 3,159, 0,159, 4,159, 8,
48,128, 5,184, 97,128, 5,184, 99,128, 5,184, 50, 2,159, 18,
159, 22, 55,128, 5,184, 57,128, 5,184,179, 51,128, 5,184,228,
101,128, 5,184,232,229,226,242,229,119,128, 5,184,238,225,242,
242,239,247,232,229,226,242,229,119,128, 5,184,113, 2,159, 66,
159,132,225,244,225,110, 4,159, 79,159, 88,159,103,159,119,232,
229,226,242,229,119,128, 5,184,238,225,242,242,239,247,232,229,
226,242,229,119,128, 5,184,241,245,225,242,244,229,242,232,229,
226,242,229,119,128, 5,184,247,233,228,229,232,229,226,242,229,
119,128, 5,184,245,225,242,244,229,242,232,229,226,242,229,119,
128, 5,184,247,233,228,229,232,229,226,242,229,119,128, 5,184,
242,238,229,249,240,225,242,225,232,229,226,242,229,119,128, 5,
159,226,239,240,239,237,239,230,111,128, 49, 17,227,233,242,227,
236,101,128, 36,224,232,239,239,107,128, 2,160,237,239,238,239,
243,240,225,227,101,128,255, 81,239,102,130, 5,231,159,225,159,
245,228,225,231,229,243,104,129,251, 71,159,236,232,229,226,242,
229,119,128,251, 71,232,229,226,242,229,119,128, 5,231,240,225,
242,229,110,128, 36,172,117, 4,160, 16,160, 28,160,117,160,204,
225,242,244,229,242,238,239,244,101,128, 38,105,226,245,244,115,
135, 5,187,160, 49,160, 54,160, 59,160, 64,160, 73,160, 88,160,
104,177, 56,128, 5,187,178, 53,128, 5,187,179, 49,128, 5,187,
232,229,226,242,229,119,128, 5,187,238,225,242,242,239,247,232,
229,226,242,229,119,128, 5,187,241,245,225,242,244,229,242,232,
229,226,242,229,119,128, 5,187,247,233,228,229,232,229,226,242,
229,119,128, 5,187,229,243,244,233,239,110,133, 0, 63,160,136,
160,159,160,176,160,184,160,196,225,114, 2,160,143,160,150,225,
226,233, 99,128, 6, 31,237,229,238,233,225,110,128, 5, 94,228,
239,247,110,129, 0,191,160,168,243,237,225,236,108,128,247,191,
231,242,229,229,107,128, 3,126,237,239,238,239,243,240,225,227,
101,128,255, 31,243,237,225,236,108,128,247, 63,239,244,101, 4,
160,216,161, 31,161, 51,161, 80,228,226,108,133, 0, 34,160,232,
160,239,160,246,161, 2,161, 23,226,225,243,101,128, 32, 30,236,
229,230,116,128, 32, 28,237,239,238,239,243,240,225,227,101,128,
255, 2,240,242,233,237,101,129, 48, 30,161, 12,242,229,246,229,
242,243,229,100,128, 48, 29,242,233,231,232,116,128, 32, 29,236,
229,230,116,129, 32, 24,161, 40,242,229,246,229,242,243,229,100,
128, 32, 27,114, 2,161, 57,161, 67,229,246,229,242,243,229,100,
128, 32, 27,233,231,232,116,129, 32, 25,161, 76,110,128, 1, 73,
243,233,238,231,108, 2,161, 90,161, 97,226,225,243,101,128, 32,
26,101,129, 0, 39,161,103,237,239,238,239,243,240,225,227,101,
128,255, 7,114,145, 0,114,161,153,162,157,162,168,162,215,163,
10,164, 27,164, 51,164,146,166,180,166,217,166,229,167, 27,167,
35,167,197,167,208,167,243,168, 87, 97, 11,161,177,161,188,161,
198,161,205,162, 14,162, 30,162, 55,162, 66,162, 91,162,114,162,
151,225,242,237,229,238,233,225,110,128, 5,124,226,229,238,231,
225,236,105,128, 9,176,227,245,244,101,128, 1, 85,100, 4,161,
215,161,221,161,235,162, 5,229,246, 97,128, 9, 48,233,227,225,
108,129, 34, 26,161,230,229,120,128,248,229,239,246,229,242,243,
243,241,245,225,242,101,129, 51,174,161,251,228,243,241,245,225,
242,101,128, 51,175,243,241,245,225,242,101,128, 51,173,230,101,
129, 5,191,162, 21,232,229,226,242,229,119,128, 5,191,231,117,
2,162, 37,162, 46,234,225,242,225,244,105,128, 10,176,242,237,
245,235,232,105,128, 10, 48,232,233,242,225,231,225,238, 97,128,
48,137,235,225,244,225,235,225,238, 97,129, 48,233,162, 79,232,
225,236,230,247,233,228,244,104,128,255,151,236,239,247,229,242,
228,233,225,231,239,238,225,236,226,229,238,231,225,236,105,128,
9,241,109, 2,162,120,162,143,233,228,228,236,229,228,233,225,
231,239,238,225,236,226,229,238,231,225,236,105,128, 9,240,243,
232,239,242,110,128, 2,100,244,233,111,128, 34, 54,226,239,240,
239,237,239,230,111,128, 49, 22, 99, 4,162,178,162,185,162,194,
162,202,225,242,239,110,128, 1, 89,229,228,233,236,236, 97,128,
1, 87,233,242,227,236,101,128, 36,225,239,237,237,225,225,227,
227,229,238,116,128, 1, 87,100, 2,162,221,162,231,226,236,231,
242,225,246,101,128, 2, 17,239,116, 2,162,238,162,247,225,227,
227,229,238,116,128, 30, 89,226,229,236,239,119,129, 30, 91,163,
1,237,225,227,242,239,110,128, 30, 93,101, 6,163, 24,163, 69,
163,104,163,159,163,184,163,217,102, 2,163, 30,163, 43,229,242,
229,238,227,229,237,225,242,107,128, 32, 59,236,229,248,243,117,
2,163, 53,163, 60,226,243,229,116,128, 34,134,240,229,242,243,
229,116,128, 34,135,231,233,243,244,229,114, 2,163, 80,163, 85,
229,100,128, 0,174,115, 2,163, 91,163, 97,225,238,115,128,248,
232,229,242,233,102,128,246,218,104, 3,163,112,163,135,163,149,
225,114, 2,163,119,163,126,225,226,233, 99,128, 6, 49,237,229,
238,233,225,110,128, 5,128,230,233,238,225,236,225,242,225,226,
233, 99,128,254,174,233,242,225,231,225,238, 97,128, 48,140,235,
225,244,225,235,225,238, 97,129, 48,236,163,172,232,225,236,230,
247,233,228,244,104,128,255,154,243,104,130, 5,232,163,193,163,
208,228,225,231,229,243,232,232,229,226,242,229,119,128,251, 72,
232,229,226,242,229,119,128, 5,232,118, 3,163,225,163,238,164,
14,229,242,243,229,228,244,233,236,228,101,128, 34, 61,233, 97,
2,163,245,163,254,232,229,226,242,229,119,128, 5,151,237,245,
231,242,225,243,232,232,229,226,242,229,119,128, 5,151,236,239,
231,233,227,225,236,238,239,116,128, 35, 16,230,233,243,232,232,
239,239,107,129, 2,126,164, 40,242,229,246,229,242,243,229,100,
128, 2,127,104, 2,164, 57,164, 80, 97, 2,164, 63,164, 73,226,
229,238,231,225,236,105,128, 9,221,228,229,246, 97,128, 9, 93,
111,131, 3,193,164, 90,164,119,164,133,239,107,129, 2,125,164,
97,244,245,242,238,229,100,129, 2,123,164,108,243,245,240,229,
242,233,239,114,128, 2,181,243,249,237,226,239,236,231,242,229,
229,107,128, 3,241,244,233,227,232,239,239,235,237,239,100,128,
2,222,105, 6,164,160,165,204,165,250,166, 5,166, 30,166,166,
229,245,108, 9,164,182,164,217,164,232,164,246,165, 36,165, 50,
165,136,165,149,165,184, 97, 2,164,188,164,203,227,233,242,227,
236,229,235,239,242,229,225,110,128, 50,113,240,225,242,229,238,
235,239,242,229,225,110,128, 50, 17,227,233,242,227,236,229,235,
239,242,229,225,110,128, 50, 99,232,233,229,245,232,235,239,242,
229,225,110,128, 49, 64,107, 2,164,252,165, 28,233,249,229,239,
107, 2,165, 6,165, 15,235,239,242,229,225,110,128, 49, 58,243,
233,239,243,235,239,242,229,225,110,128, 49,105,239,242,229,225,
110,128, 49, 57,237,233,229,245,237,235,239,242,229,225,110,128,
49, 59,112, 3,165, 58,165, 90,165,105, 97, 2,165, 64,165, 78,
238,243,233,239,243,235,239,242,229,225,110,128, 49,108,242,229,
238,235,239,242,229,225,110,128, 50, 3,232,233,229,245,240,232,
235,239,242,229,225,110,128, 49, 63,233,229,245,112, 2,165,114,
165,123,235,239,242,229,225,110,128, 49, 60,243,233,239,243,235,
239,242,229,225,110,128, 49,107,243,233,239,243,235,239,242,229,
225,110,128, 49, 61,116, 2,165,155,165,170,232,233,229,245,244,
232,235,239,242,229,225,110,128, 49, 62,233,235,229,245,244,235,
239,242,229,225,110,128, 49,106,249,229,239,242,233,238,232,233,
229,245,232,235,239,242,229,225,110,128, 49,109,231,232,116, 2,
165,212,165,220,225,238,231,236,101,128, 34, 31,116, 2,165,226,
165,240,225,227,235,226,229,236,239,247,227,237, 98,128, 3, 25,
242,233,225,238,231,236,101,128, 34,191,232,233,242,225,231,225,
238, 97,128, 48,138,235,225,244,225,235,225,238, 97,129, 48,234,
166, 18,232,225,236,230,247,233,228,244,104,128,255,152,110, 2,
166, 36,166,152,103,131, 2,218,166, 46,166, 57,166, 63,226,229,
236,239,247,227,237, 98,128, 3, 37,227,237, 98,128, 3, 10,232,
225,236,102, 2,166, 72,166,118,236,229,230,116,131, 2,191,166,
85,166, 96,166,107,225,242,237,229,238,233,225,110,128, 5, 89,
226,229,236,239,247,227,237, 98,128, 3, 28,227,229,238,244,229,
242,229,100,128, 2,211,242,233,231,232,116,130, 2,190,166,130,
166,141,226,229,236,239,247,227,237, 98,128, 3, 57,227,229,238,
244,229,242,229,100,128, 2,210,246,229,242,244,229,228,226,242,
229,246,101,128, 2, 19,244,244,239,242,245,243,241,245,225,242,
101,128, 51, 81,108, 2,166,186,166,197,233,238,229,226,229,236,
239,119,128, 30, 95,239,238,231,236,229,103,129, 2,124,166,208,
244,245,242,238,229,100,128, 2,122,237,239,238,239,243,240,225,
227,101,128,255, 82,111, 3,166,237,166,248,167, 17,232,233,242,
225,231,225,238, 97,128, 48,141,235,225,244,225,235,225,238, 97,
129, 48,237,167, 5,232,225,236,230,247,233,228,244,104,128,255,
155,242,245,225,244,232,225,105,128, 14, 35,240,225,242,229,110,
128, 36,173,114, 3,167, 43,167, 79,167,109, 97, 3,167, 51,167,
61,167, 68,226,229,238,231,225,236,105,128, 9,220,228,229,246,
97,128, 9, 49,231,245,242,237,245,235,232,105,128, 10, 92,229,
104, 2,167, 86,167, 95,225,242,225,226,233, 99,128, 6,145,230,
233,238,225,236,225,242,225,226,233, 99,128,251,141,246,239,227,
225,236,233, 99, 4,167,125,167,135,167,142,167,153,226,229,238,
231,225,236,105,128, 9,224,228,229,246, 97,128, 9, 96,231,245,
234,225,242,225,244,105,128, 10,224,246,239,247,229,236,243,233,
231,110, 3,167,169,167,179,167,186,226,229,238,231,225,236,105,
128, 9,196,228,229,246, 97,128, 9, 68,231,245,234,225,242,225,
244,105,128, 10,196,243,245,240,229,242,233,239,114,128,246,241,
116, 2,167,214,167,222,226,236,239,227,107,128, 37,144,245,242,
238,229,100,129, 2,121,167,232,243,245,240,229,242,233,239,114,
128, 2,180,117, 4,167,253,168, 8,168, 33,168, 80,232,233,242,
225,231,225,238, 97,128, 48,139,235,225,244,225,235,225,238, 97,
129, 48,235,168, 21,232,225,236,230,247,233,228,244,104,128,255,
153,112, 2,168, 39,168, 74,229,101, 2,168, 46,168, 60,237,225,
242,235,226,229,238,231,225,236,105,128, 9,242,243,233,231,238,
226,229,238,231,225,236,105,128, 9,243,233,225,104,128,246,221,
244,232,225,105,128, 14, 36,246,239,227,225,236,233, 99, 4,168,
103,168,113,168,120,168,131,226,229,238,231,225,236,105,128, 9,
139,228,229,246, 97,128, 9, 11,231,245,234,225,242,225,244,105,
128, 10,139,246,239,247,229,236,243,233,231,110, 3,168,147,168,
157,168,164,226,229,238,231,225,236,105,128, 9,195,228,229,246,
97,128, 9, 67,231,245,234,225,242,225,244,105,128, 10,195,115,
147, 0,115,168,217,170,187,170,198,171, 68,171,107,174, 49,174,
60,176,203,179, 85,179,131,179,158,180, 93,180,160,181,193,181,
203,182,133,182,206,183,120,183,130, 97, 9,168,237,168,247,169,
12,169, 84,169,109,169,120,169,145,169,177,169,217,226,229,238,
231,225,236,105,128, 9,184,227,245,244,101,129, 1, 91,169, 0,
228,239,244,225,227,227,229,238,116,128, 30,101,100, 5,169, 24,
169, 33,169, 39,169, 53,169, 69,225,242,225,226,233, 99,128, 6,
53,229,246, 97,128, 9, 56,230,233,238,225,236,225,242,225,226,
233, 99,128,254,186,233,238,233,244,233,225,236,225,242,225,226,
233, 99,128,254,187,237,229,228,233,225,236,225,242,225,226,233,
99,128,254,188,231,117, 2,169, 91,169,100,234,225,242,225,244,
105,128, 10,184,242,237,245,235,232,105,128, 10, 56,232,233,242,
225,231,225,238, 97,128, 48, 85,235,225,244,225,235,225,238, 97,
129, 48,181,169,133,232,225,236,230,247,233,228,244,104,128,255,
123,236,236,225,236,236,225,232,239,245,225,236,225,249,232,229,
247,225,243,225,236,236,225,237,225,242,225,226,233, 99,128,253,
250,237,229,235,104,130, 5,225,169,188,169,208,228,225,231,229,
243,104,129,251, 65,169,199,232,229,226,242,229,119,128,251, 65,
232,229,226,242,229,119,128, 5,225,242, 97, 5,169,230,170, 48,
170, 56,170,106,170,114, 97, 5,169,242,169,250,170, 2,170, 33,
170, 41,225,244,232,225,105,128, 14, 50,229,244,232,225,105,128,
14, 65,233,237,225,233,109, 2,170, 12,170, 23,225,236,225,233,
244,232,225,105,128, 14, 68,245,225,238,244,232,225,105,128, 14,
67,237,244,232,225,105,128, 14, 51,244,232,225,105,128, 14, 48,
229,244,232,225,105,128, 14, 64,105, 3,170, 64,170, 88,170, 99,
105, 2,170, 70,170, 81,236,229,230,244,244,232,225,105,128,248,
134,244,232,225,105,128, 14, 53,236,229,230,244,244,232,225,105,
128,248,133,244,232,225,105,128, 14, 52,239,244,232,225,105,128,
14, 66,117, 3,170,122,170,172,170,179,101, 3,170,130,170,154,
170,165,101, 2,170,136,170,147,236,229,230,244,244,232,225,105,
128,248,136,244,232,225,105,128, 14, 55,236,229,230,244,244,232,
225,105,128,248,135,244,232,225,105,128, 14, 54,244,232,225,105,
128, 14, 56,245,244,232,225,105,128, 14, 57,226,239,240,239,237,
239,230,111,128, 49, 25, 99, 5,170,210,170,231,170,240,171, 33,
171, 55,225,242,239,110,129, 1, 97,170,219,228,239,244,225,227,
227,229,238,116,128, 30,103,229,228,233,236,236, 97,128, 1, 95,
232,247, 97,131, 2, 89,170,252,171, 7,171, 26,227,249,242,233,
236,236,233, 99,128, 4,217,228,233,229,242,229,243,233,243,227,
249,242,233,236,236,233, 99,128, 4,219,232,239,239,107,128, 2,
90,233,242, 99, 2,171, 41,171, 46,236,101,128, 36,226,245,237,
230,236,229,120,128, 1, 93,239,237,237,225,225,227,227,229,238,
116,128, 2, 25,228,239,116, 2,171, 76,171, 85,225,227,227,229,
238,116,128, 30, 97,226,229,236,239,119,129, 30, 99,171, 95,228,
239,244,225,227,227,229,238,116,128, 30,105,101, 9,171,127,171,
143,171,178,171,243,172, 90,172,117,172,142,172,223,172,250,225,
231,245,236,236,226,229,236,239,247,227,237, 98,128, 3, 60, 99,
2,171,149,171,171,239,238,100,129, 32, 51,171,157,244,239,238,
229,227,232,233,238,229,243,101,128, 2,202,244,233,239,110,128,
0,167,229,110, 4,171,189,171,198,171,212,171,228,225,242,225,
226,233, 99,128, 6, 51,230,233,238,225,236,225,242,225,226,233,
99,128,254,178,233,238,233,244,233,225,236,225,242,225,226,233,
99,128,254,179,237,229,228,233,225,236,225,242,225,226,233, 99,
128,254,180,231,239,108,135, 5,182,172, 7,172, 21,172, 26,172,
35,172, 50,172, 66,172, 77, 49, 2,172, 13,172, 17, 51,128, 5,
182,102,128, 5,182,178, 99,128, 5,182,232,229,226,242,229,119,
128, 5,182,238,225,242,242,239,247,232,229,226,242,229,119,128,
5,182,241,245,225,242,244,229,242,232,229,226,242,229,119,128,
5,182,244,225,232,229,226,242,229,119,128, 5,146,247,233,228,
229,232,229,226,242,229,119,128, 5,182,104, 2,172, 96,172,107,
225,242,237,229,238,233,225,110,128, 5,125,233,242,225,231,225,
238, 97,128, 48, 91,235,225,244,225,235,225,238, 97,129, 48,187,
172,130,232,225,236,230,247,233,228,244,104,128,255,126,237,105,
2,172,149,172,192,227,239,236,239,110,131, 0, 59,172,163,172,
172,172,184,225,242,225,226,233, 99,128, 6, 27,237,239,238,239,
243,240,225,227,101,128,255, 27,243,237,225,236,108,128,254, 84,
246,239,233,227,229,228,237,225,242,235,235,225,238, 97,129, 48,
156,172,211,232,225,236,230,247,233,228,244,104,128,255,159,238,
116, 2,172,230,172,240,233,243,241,245,225,242,101,128, 51, 34,
239,243,241,245,225,242,101,128, 51, 35,246,229,110,142, 0, 55,
173, 28,173, 37,173, 47,173, 77,173, 84,173, 94,173,119,173,146,
173,180,173,192,173,203,173,236,173,244,173,255,225,242,225,226,
233, 99,128, 6,103,226,229,238,231,225,236,105,128, 9,237,227,
233,242,227,236,101,129, 36,102,173, 58,233,238,246,229,242,243,
229,243,225,238,243,243,229,242,233,102,128, 39,144,228,229,246,
97,128, 9,109,229,233,231,232,244,232,115,128, 33, 94,231,117,
2,173,101,173,110,234,225,242,225,244,105,128, 10,237,242,237,
245,235,232,105,128, 10,109,232, 97, 2,173,126,173,137,227,235,
225,242,225,226,233, 99,128, 6,103,238,231,250,232,239,117,128,
48, 39,105, 2,173,152,173,170,228,229,239,231,242,225,240,232,
233,227,240,225,242,229,110,128, 50, 38,238,230,229,242,233,239,
114,128, 32,135,237,239,238,239,243,240,225,227,101,128,255, 23,
239,236,228,243,244,249,236,101,128,247, 55,112, 2,173,209,173,
216,225,242,229,110,128, 36,122,229,114, 2,173,223,173,229,233,
239,100,128, 36,142,243,233,225,110,128, 6,247,242,239,237,225,
110,128, 33,118,243,245,240,229,242,233,239,114,128, 32,119,116,
2,174, 5,174, 43,229,229,110, 2,174, 13,174, 22,227,233,242,
227,236,101,128, 36,112,112, 2,174, 28,174, 35,225,242,229,110,
128, 36,132,229,242,233,239,100,128, 36,152,232,225,105,128, 14,
87,230,244,232,249,240,232,229,110,128, 0,173,104, 7,174, 76,
175, 50,175, 61,175, 75,176, 20,176, 33,176,197, 97, 6,174, 90,
174,101,174,111,174,122,175, 9,175, 34,225,242,237,229,238,233,
225,110,128, 5,119,226,229,238,231,225,236,105,128, 9,182,227,
249,242,233,236,236,233, 99,128, 4, 72,100, 2,174,128,174,224,
228, 97, 4,174,139,174,148,174,179,174,193,225,242,225,226,233,
99,128, 6, 81,228,225,237,237, 97, 2,174,158,174,167,225,242,
225,226,233, 99,128,252, 97,244,225,238,225,242,225,226,233, 99,
128,252, 94,230,225,244,232,225,225,242,225,226,233, 99,128,252,
96,235,225,243,242, 97, 2,174,203,174,212,225,242,225,226,233,
99,128,252, 98,244,225,238,225,242,225,226,233, 99,128,252, 95,
101,132, 37,146,174,236,174,243,174,251,175, 4,228,225,242,107,
128, 37,147,236,233,231,232,116,128, 37,145,237,229,228,233,245,
109,128, 37,146,246, 97,128, 9, 54,231,117, 2,175, 16,175, 25,
234,225,242,225,244,105,128, 10,182,242,237,245,235,232,105,128,
10, 54,236,243,232,229,236,229,244,232,229,226,242,229,119,128,
5,147,226,239,240,239,237,239,230,111,128, 49, 21,227,232,225,
227,249,242,233,236,236,233, 99,128, 4, 73,101, 4,175, 85,175,
150,175,160,175,177,229,110, 4,175, 96,175,105,175,119,175,135,
225,242,225,226,233, 99,128, 6, 52,230,233,238,225,236,225,242,
225,226,233, 99,128,254,182,233,238,233,244,233,225,236,225,242,
225,226,233, 99,128,254,183,237,229,228,233,225,236,225,242,225,
226,233, 99,128,254,184,233,227,239,240,244,233, 99,128, 3,227,
241,229,108,129, 32,170,175,168,232,229,226,242,229,119,128, 32,
170,246, 97,134, 5,176,175,194,175,209,175,223,175,232,175,247,
176, 7, 49, 2,175,200,175,205,177, 53,128, 5,176, 53,128, 5,
176, 50, 2,175,215,175,219, 50,128, 5,176,101,128, 5,176,232,
229,226,242,229,119,128, 5,176,238,225,242,242,239,247,232,229,
226,242,229,119,128, 5,176,241,245,225,242,244,229,242,232,229,
226,242,229,119,128, 5,176,247,233,228,229,232,229,226,242,229,
119,128, 5,176,232,225,227,249,242,233,236,236,233, 99,128, 4,
187,105, 2,176, 39,176, 50,237,225,227,239,240,244,233, 99,128,
3,237,110,131, 5,233,176, 60,176,143,176,152,100, 2,176, 66,
176,132,225,231,229,243,104,130,251, 73,176, 78,176, 87,232,229,
226,242,229,119,128,251, 73,115, 2,176, 93,176,113,232,233,238,
228,239,116,129,251, 44,176,104,232,229,226,242,229,119,128,251,
44,233,238,228,239,116,129,251, 45,176,123,232,229,226,242,229,
119,128,251, 45,239,244,232,229,226,242,229,119,128, 5,193,232,
229,226,242,229,119,128, 5,233,115, 2,176,158,176,178,232,233,
238,228,239,116,129,251, 42,176,169,232,229,226,242,229,119,128,
251, 42,233,238,228,239,116,129,251, 43,176,188,232,229,226,242,
229,119,128,251, 43,239,239,107,128, 2,130,105, 8,176,221,177,
9,177, 20,177, 45,177, 75,177, 83,177, 96,178, 11,231,237, 97,
131, 3,195,176,233,176,237,176,245, 49,128, 3,194,230,233,238,
225,108,128, 3,194,236,245,238,225,244,229,243,249,237,226,239,
236,231,242,229,229,107,128, 3,242,232,233,242,225,231,225,238,
97,128, 48, 87,235,225,244,225,235,225,238, 97,129, 48,183,177,
33,232,225,236,230,247,233,228,244,104,128,255,124,236,245,113,
2,177, 53,177, 62,232,229,226,242,229,119,128, 5,189,236,229,
230,244,232,229,226,242,229,119,128, 5,189,237,233,236,225,114,
128, 34, 60,238,228,239,244,232,229,226,242,229,119,128, 5,194,
239,115, 6,177,111,177,146,177,178,177,206,177,220,177,252, 97,
2,177,117,177,132,227,233,242,227,236,229,235,239,242,229,225,
110,128, 50,116,240,225,242,229,238,235,239,242,229,225,110,128,
50, 20,227,105, 2,177,153,177,165,229,245,227,235,239,242,229,
225,110,128, 49,126,242,227,236,229,235,239,242,229,225,110,128,
50,102,107, 2,177,184,177,198,233,249,229,239,235,235,239,242,
229,225,110,128, 49,122,239,242,229,225,110,128, 49, 69,238,233,
229,245,238,235,239,242,229,225,110,128, 49,123,112, 2,177,226,
177,239,225,242,229,238,235,239,242,229,225,110,128, 50, 6,233,
229,245,240,235,239,242,229,225,110,128, 49,125,244,233,235,229,
245,244,235,239,242,229,225,110,128, 49,124,120,141, 0, 54,178,
41,178, 50,178, 60,178, 90,178, 97,178,122,178,149,178,183,178,
195,178,206,178,239,178,247,179, 2,225,242,225,226,233, 99,128,
6,102,226,229,238,231,225,236,105,128, 9,236,227,233,242,227,
236,101,129, 36,101,178, 71,233,238,246,229,242,243,229,243,225,
238,243,243,229,242,233,102,128, 39,143,228,229,246, 97,128, 9,
108,231,117, 2,178,104,178,113,234,225,242,225,244,105,128, 10,
236,242,237,245,235,232,105,128, 10,108,232, 97, 2,178,129,178,
140,227,235,225,242,225,226,233, 99,128, 6,102,238,231,250,232,
239,117,128, 48, 38,105, 2,178,155,178,173,228,229,239,231,242,
225,240,232,233,227,240,225,242,229,110,128, 50, 37,238,230,229,
242,233,239,114,128, 32,134,237,239,238,239,243,240,225,227,101,
128,255, 22,239,236,228,243,244,249,236,101,128,247, 54,112, 2,
178,212,178,219,225,242,229,110,128, 36,121,229,114, 2,178,226,
178,232,233,239,100,128, 36,141,243,233,225,110,128, 6,246,242,
239,237,225,110,128, 33,117,243,245,240,229,242,233,239,114,128,
32,118,116, 2,179, 8,179, 79,229,229,110, 2,179, 16,179, 58,
99, 2,179, 22,179, 30,233,242,227,236,101,128, 36,111,245,242,
242,229,238,227,249,228,229,238,239,237,233,238,225,244,239,242,
226,229,238,231,225,236,105,128, 9,249,112, 2,179, 64,179, 71,
225,242,229,110,128, 36,131,229,242,233,239,100,128, 36,151,232,
225,105,128, 14, 86,108, 2,179, 91,179,111,225,243,104,129, 0,
47,179, 99,237,239,238,239,243,240,225,227,101,128,255, 15,239,
238,103,129, 1,127,179,119,228,239,244,225,227,227,229,238,116,
128, 30,155,109, 2,179,137,179,147,233,236,229,230,225,227,101,
128, 38, 58,239,238,239,243,240,225,227,101,128,255, 83,111, 6,
179,172,179,222,179,233,180, 2,180, 47,180, 58,102, 2,179,178,
179,192,240,225,243,245,241,232,229,226,242,229,119,128, 5,195,
116, 2,179,198,179,207,232,249,240,232,229,110,128, 0,173,243,
233,231,238,227,249,242,233,236,236,233, 99,128, 4, 76,232,233,
242,225,231,225,238, 97,128, 48, 93,235,225,244,225,235,225,238,
97,129, 48,189,179,246,232,225,236,230,247,233,228,244,104,128,
255,127,236,233,228,245,115, 2,180, 12,180, 29,236,239,238,231,
239,246,229,242,236,225,249,227,237, 98,128, 3, 56,243,232,239,
242,244,239,246,229,242,236,225,249,227,237, 98,128, 3, 55,242,
245,243,233,244,232,225,105,128, 14, 41,115, 3,180, 66,180, 76,
180, 84,225,236,225,244,232,225,105,128, 14, 40,239,244,232,225,
105,128, 14, 11,245,225,244,232,225,105,128, 14, 42,240, 97, 3,
180,102,180,122,180,154,227,101,129, 0, 32,180,109,232,225,227,
235,225,242,225,226,233, 99,128, 0, 32,228,101,129, 38, 96,180,
129,243,245,233,116, 2,180,138,180,146,226,236,225,227,107,128,
38, 96,247,232,233,244,101,128, 38,100,242,229,110,128, 36,174,
241,245,225,242,101, 11,180,188,180,199,180,213,180,238,180,255,
181, 25,181, 40,181, 73,181,100,181,156,181,171,226,229,236,239,
247,227,237, 98,128, 3, 59, 99, 2,180,205,180,209, 99,128, 51,
196,109,128, 51,157,228,233,225,231,239,238,225,236,227,242,239,
243,243,232,225,244,227,232,230,233,236,108,128, 37,169,232,239,
242,233,250,239,238,244,225,236,230,233,236,108,128, 37,164,107,
2,181, 5,181, 9,103,128, 51,143,109,129, 51,158,181, 15,227,
225,240,233,244,225,108,128, 51,206,108, 2,181, 31,181, 35,110,
128, 51,209,239,103,128, 51,210,109, 4,181, 50,181, 54,181, 59,
181, 63,103,128, 51,142,233,108,128, 51,213,109,128, 51,156,243,
241,245,225,242,229,100,128, 51,161,239,242,244,232,239,231,239,
238,225,236,227,242,239,243,243,232,225,244,227,232,230,233,236,
108,128, 37,166,245,240,240,229,114, 2,181,110,181,133,236,229,
230,244,244,239,236,239,247,229,242,242,233,231,232,244,230,233,
236,108,128, 37,167,242,233,231,232,244,244,239,236,239,247,229,
242,236,229,230,244,230,233,236,108,128, 37,168,246,229,242,244,
233,227,225,236,230,233,236,108,128, 37,165,247,232,233,244,229,
247,233,244,232,243,237,225,236,236,226,236,225,227,107,128, 37,
163,242,243,241,245,225,242,101,128, 51,219,115, 2,181,209,182,
123, 97, 4,181,219,181,229,181,236,181,247,226,229,238,231,225,
236,105,128, 9,183,228,229,246, 97,128, 9, 55,231,245,234,225,
242,225,244,105,128, 10,183,238,103, 8,182, 10,182, 24,182, 38,
182, 52,182, 67,182, 81,182, 95,182,108,227,233,229,245,227,235,
239,242,229,225,110,128, 49, 73,232,233,229,245,232,235,239,242,
229,225,110,128, 49,133,233,229,245,238,231,235,239,242,229,225,
110,128, 49,128,235,233,249,229,239,235,235,239,242,229,225,110,
128, 49, 50,238,233,229,245,238,235,239,242,229,225,110,128, 49,
101,240,233,229,245,240,235,239,242,229,225,110,128, 49, 67,243,
233,239,243,235,239,242,229,225,110,128, 49, 70,244,233,235,229,
245,244,235,239,242,229,225,110,128, 49, 56,245,240,229,242,233,
239,114,128,246,242,116, 2,182,139,182,162,229,242,236,233,238,
103,129, 0,163,182,150,237,239,238,239,243,240,225,227,101,128,
255,225,242,239,235,101, 2,182,171,182,188,236,239,238,231,239,
246,229,242,236,225,249,227,237, 98,128, 3, 54,243,232,239,242,
244,239,246,229,242,236,225,249,227,237, 98,128, 3, 53,117, 7,
182,222,182,254,183, 20,183, 31,183, 72,183, 82,183, 86,226,243,
229,116,130, 34,130,182,233,182,244,238,239,244,229,241,245,225,
108,128, 34,138,239,242,229,241,245,225,108,128, 34,134, 99, 2,
183, 4,183, 12,227,229,229,228,115,128, 34,123,232,244,232,225,
116,128, 34, 11,232,233,242,225,231,225,238, 97,128, 48, 89,107,
2,183, 37,183, 61,225,244,225,235,225,238, 97,129, 48,185,183,
49,232,225,236,230,247,233,228,244,104,128,255,125,245,238,225,
242,225,226,233, 99,128, 6, 82,237,237,225,244,233,239,110,128,
34, 17,110,128, 38, 60,240,229,242,243,229,116,130, 34,131,183,
99,183,110,238,239,244,229,241,245,225,108,128, 34,139,239,242,
229,241,245,225,108,128, 34,135,246,243,241,245,225,242,101,128,
51,220,249,239,245,247,225,229,242,225,243,241,245,225,242,101,
128, 51,124,116,144, 0,116,183,183,184,192,184,213,185,100,185,
140,187,188,191, 70,192,145,192,157,192,169,193,202,193,227,194,
57,194,237,195,165,195,255, 97, 10,183,205,183,215,183,236,183,
243,184, 12,184, 90,184,107,184,132,184,146,184,150,226,229,238,
231,225,236,105,128, 9,164,227,107, 2,183,222,183,229,228,239,
247,110,128, 34,164,236,229,230,116,128, 34,163,228,229,246, 97,
128, 9, 36,231,117, 2,183,250,184, 3,234,225,242,225,244,105,
128, 10,164,242,237,245,235,232,105,128, 10, 36,104, 4,184, 22,
184, 31,184, 45,184, 75,225,242,225,226,233, 99,128, 6, 55,230,
233,238,225,236,225,242,225,226,233, 99,128,254,194,105, 2,184,
51,184, 66,238,233,244,233,225,236,225,242,225,226,233, 99,128,
254,195,242,225,231,225,238, 97,128, 48, 95,237,229,228,233,225,
236,225,242,225,226,233, 99,128,254,196,233,243,249,239,245,229,
242,225,243,241,245,225,242,101,128, 51,125,235,225,244,225,235,
225,238, 97,129, 48,191,184,120,232,225,236,230,247,233,228,244,
104,128,255,128,244,247,229,229,236,225,242,225,226,233, 99,128,
6, 64,117,128, 3,196,118,130, 5,234,184,158,184,183,228,225,
231,229,115,129,251, 74,184,168,104,129,251, 74,184,174,232,229,
226,242,229,119,128,251, 74,232,229,226,242,229,119,128, 5,234,
98, 2,184,198,184,203,225,114,128, 1,103,239,240,239,237,239,
230,111,128, 49, 10, 99, 6,184,227,184,234,184,241,184,250,185,
60,185, 87,225,242,239,110,128, 1,101,227,245,242,108,128, 2,
168,229,228,233,236,236, 97,128, 1, 99,232,229,104, 4,185, 6,
185, 15,185, 29,185, 45,225,242,225,226,233, 99,128, 6,134,230,
233,238,225,236,225,242,225,226,233, 99,128,251,123,233,238,233,
244,233,225,236,225,242,225,226,233, 99,128,251,124,237,229,228,
233,225,236,225,242,225,226,233, 99,128,251,125,233,242, 99, 2,
185, 68,185, 73,236,101,128, 36,227,245,237,230,236,229,248,226,
229,236,239,119,128, 30,113,239,237,237,225,225,227,227,229,238,
116,128, 1, 99,100, 2,185,106,185,116,233,229,242,229,243,233,
115,128, 30,151,239,116, 2,185,123,185,132,225,227,227,229,238,
116,128, 30,107,226,229,236,239,119,128, 30,109,101, 9,185,160,
185,171,185,191,186,201,186,226,187, 34,187,101,187,106,187,158,
227,249,242,233,236,236,233, 99,128, 4, 66,228,229,243,227,229,
238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,173,104,
7,185,207,185,216,185,230,186, 14,186, 44,186, 85,186,183,225,
242,225,226,233, 99,128, 6, 42,230,233,238,225,236,225,242,225,
226,233, 99,128,254,150,232,225,232,105, 2,185,239,185,254,238,
233,244,233,225,236,225,242,225,226,233, 99,128,252,162,243,239,
236,225,244,229,228,225,242,225,226,233, 99,128,252, 12,105, 2,
186, 20,186, 35,238,233,244,233,225,236,225,242,225,226,233, 99,
128,254,151,242,225,231,225,238, 97,128, 48,102,234,229,229,237,
105, 2,186, 54,186, 69,238,233,244,233,225,236,225,242,225,226,
233, 99,128,252,161,243,239,236,225,244,229,228,225,242,225,226,
233, 99,128,252, 11,109, 2,186, 91,186,125,225,242,226,245,244,
97, 2,186,102,186,111,225,242,225,226,233, 99,128, 6, 41,230,
233,238,225,236,225,242,225,226,233, 99,128,254,148,101, 2,186,
131,186,144,228,233,225,236,225,242,225,226,233, 99,128,254,152,
229,237,105, 2,186,152,186,167,238,233,244,233,225,236,225,242,
225,226,233, 99,128,252,164,243,239,236,225,244,229,228,225,242,
225,226,233, 99,128,252, 14,238,239,239,238,230,233,238,225,236,
225,242,225,226,233, 99,128,252,115,235,225,244,225,235,225,238,
97,129, 48,198,186,214,232,225,236,230,247,233,228,244,104,128,
255,131,108, 2,186,232,186,251,229,240,232,239,238,101,129, 33,
33,186,243,226,236,225,227,107,128, 38, 14,233,243,232, 97, 2,
187, 4,187, 19,231,229,228,239,236,225,232,229,226,242,229,119,
128, 5,160,241,229,244,225,238,225,232,229,226,242,229,119,128,
5,169,110, 4,187, 44,187, 53,187, 72,187, 93,227,233,242,227,
236,101,128, 36,105,233,228,229,239,231,242,225,240,232,233,227,
240,225,242,229,110,128, 50, 41,112, 2,187, 78,187, 85,225,242,
229,110,128, 36,125,229,242,233,239,100,128, 36,145,242,239,237,
225,110,128, 33,121,243,104,128, 2,167,116,131, 5,216,187,116,
187,136,187,145,228,225,231,229,243,104,129,251, 56,187,127,232,
229,226,242,229,119,128,251, 56,232,229,226,242,229,119,128, 5,
216,243,229,227,249,242,233,236,236,233, 99,128, 4,181,246,233,
114, 2,187,166,187,175,232,229,226,242,229,119,128, 5,155,236,
229,230,244,232,229,226,242,229,119,128, 5,155,104, 6,187,202,
188, 98,188,220,189, 96,190, 3,191, 60, 97, 5,187,214,187,224,
187,231,188, 0,188, 29,226,229,238,231,225,236,105,128, 9,165,
228,229,246, 97,128, 9, 37,231,117, 2,187,238,187,247,234,225,
242,225,244,105,128, 10,165,242,237,245,235,232,105,128, 10, 37,
108, 2,188, 6,188, 15,225,242,225,226,233, 99,128, 6, 48,230,
233,238,225,236,225,242,225,226,233, 99,128,254,172,238,244,232,
225,235,232,225,116, 3,188, 44,188, 75,188, 82,236,239,119, 2,
188, 52,188, 63,236,229,230,244,244,232,225,105,128,248,152,242,
233,231,232,244,244,232,225,105,128,248,151,244,232,225,105,128,
14, 76,245,240,240,229,242,236,229,230,244,244,232,225,105,128,
248,150,101, 3,188,106,188,170,188,193,104, 4,188,116,188,125,
188,139,188,155,225,242,225,226,233, 99,128, 6, 43,230,233,238,
225,236,225,242,225,226,233, 99,128,254,154,233,238,233,244,233,
225,236,225,242,225,226,233, 99,128,254,155,237,229,228,233,225,
236,225,242,225,226,233, 99,128,254,156,242,101, 2,188,177,188,
186,229,248,233,243,244,115,128, 34, 3,230,239,242,101,128, 34,
52,244, 97,130, 3,184,188,202,188,206, 49,128, 3,209,243,249,
237,226,239,236,231,242,229,229,107,128, 3,209,105, 2,188,226,
189, 56,229,245,244,104, 4,188,239,189, 18,189, 33,189, 42, 97,
2,188,245,189, 4,227,233,242,227,236,229,235,239,242,229,225,
110,128, 50,121,240,225,242,229,238,235,239,242,229,225,110,128,
50, 25,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,
107,235,239,242,229,225,110,128, 49, 76,240,225,242,229,238,235,
239,242,229,225,110,128, 50, 11,242,244,229,229,110, 2,189, 66,
189, 75,227,233,242,227,236,101,128, 36,108,112, 2,189, 81,189,
88,225,242,229,110,128, 36,128,229,242,233,239,100,128, 36,148,
111, 6,189,110,189,127,189,132,189,146,189,151,189,204,238,225,
238,231,237,239,238,244,232,239,244,232,225,105,128, 14, 17,239,
107,128, 1,173,240,232,245,244,232,225,239,244,232,225,105,128,
14, 18,242,110,128, 0,254,244,104, 3,189,160,189,184,189,194,
97, 2,189,166,189,176,232,225,238,244,232,225,105,128, 14, 23,
238,244,232,225,105,128, 14, 16,239,238,231,244,232,225,105,128,
14, 24,245,238,231,244,232,225,105,128, 14, 22,245,243,225,238,
100, 2,189,214,189,225,227,249,242,233,236,236,233, 99,128, 4,
130,243,243,229,240,225,242,225,244,239,114, 2,189,240,189,249,
225,242,225,226,233, 99,128, 6,108,240,229,242,243,233,225,110,
128, 6,108,242,229,101,144, 0, 51,190, 41,190, 50,190, 60,190,
90,190, 97,190,107,190,132,190,159,190,193,190,205,190,224,190,
235,191, 12,191, 34,191, 42,191, 53,225,242,225,226,233, 99,128,
6, 99,226,229,238,231,225,236,105,128, 9,233,227,233,242,227,
236,101,129, 36, 98,190, 71,233,238,246,229,242,243,229,243,225,
238,243,243,229,242,233,102,128, 39,140,228,229,246, 97,128, 9,
105,229,233,231,232,244,232,115,128, 33, 92,231,117, 2,190,114,
190,123,234,225,242,225,244,105,128, 10,233,242,237,245,235,232,
105,128, 10,105,232, 97, 2,190,139,190,150,227,235,225,242,225,
226,233, 99,128, 6, 99,238,231,250,232,239,117,128, 48, 35,105,
2,190,165,190,183,228,229,239,231,242,225,240,232,233,227,240,
225,242,229,110,128, 50, 34,238,230,229,242,233,239,114,128, 32,
131,237,239,238,239,243,240,225,227,101,128,255, 19,238,245,237,
229,242,225,244,239,242,226,229,238,231,225,236,105,128, 9,246,
239,236,228,243,244,249,236,101,128,247, 51,112, 2,190,241,190,
248,225,242,229,110,128, 36,118,229,114, 2,190,255,191, 5,233,
239,100,128, 36,138,243,233,225,110,128, 6,243,241,245,225,242,
244,229,242,115,129, 0,190,191, 25,229,237,228,225,243,104,128,
246,222,242,239,237,225,110,128, 33,114,243,245,240,229,242,233,
239,114,128, 0,179,244,232,225,105,128, 14, 83,250,243,241,245,
225,242,101,128, 51,148,105, 7,191, 86,191, 97,191,212,192, 54,
192, 66,192,115,192,132,232,233,242,225,231,225,238, 97,128, 48,
97,107, 2,191,103,191,127,225,244,225,235,225,238, 97,129, 48,
193,191,115,232,225,236,230,247,233,228,244,104,128,255,129,229,
245,116, 4,191,139,191,174,191,189,191,198, 97, 2,191,145,191,
160,227,233,242,227,236,229,235,239,242,229,225,110,128, 50,112,
240,225,242,229,238,235,239,242,229,225,110,128, 50, 16,227,233,
242,227,236,229,235,239,242,229,225,110,128, 50, 98,235,239,242,
229,225,110,128, 49, 55,240,225,242,229,238,235,239,242,229,225,
110,128, 50, 2,236,228,101,133, 2,220,191,228,191,239,192, 0,
192, 12,192, 40,226,229,236,239,247,227,237, 98,128, 3, 48, 99,
2,191,245,191,250,237, 98,128, 3, 3,239,237, 98,128, 3, 3,
228,239,245,226,236,229,227,237, 98,128, 3, 96,111, 2,192, 18,
192, 28,240,229,242,225,244,239,114,128, 34, 60,246,229,242,236,
225,249,227,237, 98,128, 3, 52,246,229,242,244,233,227,225,236,
227,237, 98,128, 3, 62,237,229,243,227,233,242,227,236,101,128,
34,151,112, 2,192, 72,192,102,229,232, 97, 2,192, 80,192, 89,
232,229,226,242,229,119,128, 5,150,236,229,230,244,232,229,226,
242,229,119,128, 5,150,240,233,231,245,242,237,245,235,232,105,
128, 10,112,244,236,239,227,249,242,233,236,236,233,227,227,237,
98,128, 4,131,247,238,225,242,237,229,238,233,225,110,128, 5,
127,236,233,238,229,226,229,236,239,119,128, 30,111,237,239,238,
239,243,240,225,227,101,128,255, 84,111, 7,192,185,192,196,192,
207,192,232,193, 96,193,108,193,192,225,242,237,229,238,233,225,
110,128, 5,105,232,233,242,225,231,225,238, 97,128, 48,104,235,
225,244,225,235,225,238, 97,129, 48,200,192,220,232,225,236,230,
247,233,228,244,104,128,255,132,110, 3,192,240,193, 82,193, 87,
101, 4,192,250,193, 63,193, 70,193, 76,226,225,114, 4,193, 6,
193, 35,193, 45,193, 54,229,248,244,242, 97, 2,193, 16,193, 26,
232,233,231,232,237,239,100,128, 2,229,236,239,247,237,239,100,
128, 2,233,232,233,231,232,237,239,100,128, 2,230,236,239,247,
237,239,100,128, 2,232,237,233,228,237,239,100,128, 2,231,230,
233,246,101,128, 1,189,243,233,120,128, 1,133,244,247,111,128,
1,168,239,115,128, 3,132,243,241,245,225,242,101,128, 51, 39,
240,225,244,225,235,244,232,225,105,128, 14, 15,242,244,239,233,
243,229,243,232,229,236,236,226,242,225,227,235,229,116, 2,193,
131,193,161,236,229,230,116,130, 48, 20,193,142,193,150,243,237,
225,236,108,128,254, 93,246,229,242,244,233,227,225,108,128,254,
57,242,233,231,232,116,130, 48, 21,193,173,193,181,243,237,225,
236,108,128,254, 94,246,229,242,244,233,227,225,108,128,254, 58,
244,225,239,244,232,225,105,128, 14, 21,240, 97, 2,193,209,193,
221,236,225,244,225,236,232,239,239,107,128, 1,171,242,229,110,
128, 36,175,114, 3,193,235,194, 10,194, 25,225,228,229,237,225,
242,107,129, 33, 34,193,247,115, 2,193,253,194, 3,225,238,115,
128,248,234,229,242,233,102,128,246,219,229,244,242,239,230,236,
229,248,232,239,239,107,128, 2,136,233,225,103, 4,194, 37,194,
42,194, 47,194, 52,228,110,128, 37,188,236,102,128, 37,196,242,
116,128, 37,186,245,112,128, 37,178,115,132, 2,166,194, 69,194,
108,194,214,194,227,225,228,105,130, 5,230,194, 79,194, 99,228,
225,231,229,243,104,129,251, 70,194, 90,232,229,226,242,229,119,
128,251, 70,232,229,226,242,229,119,128, 5,230,101, 2,194,114,
194,125,227,249,242,233,236,236,233, 99,128, 4, 70,242,101,134,
5,181,194,142,194,156,194,161,194,170,194,185,194,201, 49, 2,
194,148,194,152, 50,128, 5,181,101,128, 5,181,178, 98,128, 5,
181,232,229,226,242,229,119,128, 5,181,238,225,242,242,239,247,
232,229,226,242,229,119,128, 5,181,241,245,225,242,244,229,242,
232,229,226,242,229,119,128, 5,181,247,233,228,229,232,229,226,
242,229,119,128, 5,181,232,229,227,249,242,233,236,236,233, 99,
128, 4, 91,245,240,229,242,233,239,114,128,246,243,116, 4,194,
247,195, 41,195,106,195,157, 97, 3,194,255,195, 9,195, 16,226,
229,238,231,225,236,105,128, 9,159,228,229,246, 97,128, 9, 31,
231,117, 2,195, 23,195, 32,234,225,242,225,244,105,128, 10,159,
242,237,245,235,232,105,128, 10, 31,229,104, 4,195, 52,195, 61,
195, 75,195, 91,225,242,225,226,233, 99,128, 6,121,230,233,238,
225,236,225,242,225,226,233, 99,128,251,103,233,238,233,244,233,
225,236,225,242,225,226,233, 99,128,251,104,237,229,228,233,225,
236,225,242,225,226,233, 99,128,251,105,232, 97, 3,195,115,195,
125,195,132,226,229,238,231,225,236,105,128, 9,160,228,229,246,
97,128, 9, 32,231,117, 2,195,139,195,148,234,225,242,225,244,
105,128, 10,160,242,237,245,235,232,105,128, 10, 32,245,242,238,
229,100,128, 2,135,117, 3,195,173,195,184,195,209,232,233,242,
225,231,225,238, 97,128, 48,100,235,225,244,225,235,225,238, 97,
129, 48,196,195,197,232,225,236,230,247,233,228,244,104,128,255,
130,243,237,225,236,108, 2,195,219,195,230,232,233,242,225,231,
225,238, 97,128, 48, 99,235,225,244,225,235,225,238, 97,129, 48,
195,195,243,232,225,236,230,247,233,228,244,104,128,255,111,119,
2,196, 5,196,110,101, 2,196, 11,196, 59,236,246,101, 3,196,
21,196, 30,196, 51,227,233,242,227,236,101,128, 36,107,112, 2,
196, 36,196, 43,225,242,229,110,128, 36,127,229,242,233,239,100,
128, 36,147,242,239,237,225,110,128, 33,123,238,244,121, 3,196,
69,196, 78,196, 89,227,233,242,227,236,101,128, 36,115,232,225,
238,231,250,232,239,117,128, 83, 68,112, 2,196, 95,196,102,225,
242,229,110,128, 36,135,229,242,233,239,100,128, 36,155,111,142,
0, 50,196,142,196,151,196,161,196,191,196,243,197, 12,197, 39,
197, 73,197, 85,197,104,197,115,197,148,197,156,197,180,225,242,
225,226,233, 99,128, 6, 98,226,229,238,231,225,236,105,128, 9,
232,227,233,242,227,236,101,129, 36, 97,196,172,233,238,246,229,
242,243,229,243,225,238,243,243,229,242,233,102,128, 39,139,100,
2,196,197,196,203,229,246, 97,128, 9,104,239,116, 2,196,210,
196,221,229,238,236,229,225,228,229,114,128, 32, 37,236,229,225,
228,229,114,129, 32, 37,196,232,246,229,242,244,233,227,225,108,
128,254, 48,231,117, 2,196,250,197, 3,234,225,242,225,244,105,
128, 10,232,242,237,245,235,232,105,128, 10,104,232, 97, 2,197,
19,197, 30,227,235,225,242,225,226,233, 99,128, 6, 98,238,231,
250,232,239,117,128, 48, 34,105, 2,197, 45,197, 63,228,229,239,
231,242,225,240,232,233,227,240,225,242,229,110,128, 50, 33,238,
230,229,242,233,239,114,128, 32,130,237,239,238,239,243,240,225,
227,101,128,255, 18,238,245,237,229,242,225,244,239,242,226,229,
238,231,225,236,105,128, 9,245,239,236,228,243,244,249,236,101,
128,247, 50,112, 2,197,121,197,128,225,242,229,110,128, 36,117,
229,114, 2,197,135,197,141,233,239,100,128, 36,137,243,233,225,
110,128, 6,242,242,239,237,225,110,128, 33,113,115, 2,197,162,
197,170,244,242,239,235,101,128, 1,187,245,240,229,242,233,239,
114,128, 0,178,244,104, 2,197,187,197,192,225,105,128, 14, 82,
233,242,228,115,128, 33, 84,117,145, 0,117,197,237,197,245,198,
30,198, 87,198,225,199, 6,199,129,199,145,199,196,200, 10,200,
91,200,100,200,219,200,243,201, 95,201,123,201,237,225,227,245,
244,101,128, 0,250, 98, 4,197,255,198, 4,198, 13,198, 23,225,
114,128, 2,137,229,238,231,225,236,105,128, 9,137,239,240,239,
237,239,230,111,128, 49, 40,242,229,246,101,128, 1,109, 99, 3,
198, 38,198, 45,198, 77,225,242,239,110,128, 1,212,233,242, 99,
2,198, 53,198, 58,236,101,128, 36,228,245,237,230,236,229,120,
129, 0,251,198, 69,226,229,236,239,119,128, 30,119,249,242,233,
236,236,233, 99,128, 4, 67,100, 5,198, 99,198,110,198,133,198,
139,198,215,225,244,244,225,228,229,246, 97,128, 9, 81,226,108,
2,198,117,198,125,225,227,245,244,101,128, 1,113,231,242,225,
246,101,128, 2, 21,229,246, 97,128, 9, 9,233,229,242,229,243,
233,115,133, 0,252,198,159,198,167,198,175,198,198,198,206,225,
227,245,244,101,128, 1,216,226,229,236,239,119,128, 30,115, 99,
2,198,181,198,188,225,242,239,110,128, 1,218,249,242,233,236,
236,233, 99,128, 4,241,231,242,225,246,101,128, 1,220,237,225,
227,242,239,110,128, 1,214,239,244,226,229,236,239,119,128, 30,
229,103, 2,198,231,198,238,242,225,246,101,128, 0,249,117, 2,
198,244,198,253,234,225,242,225,244,105,128, 10,137,242,237,245,
235,232,105,128, 10, 9,104, 3,199, 14,199, 24,199,102,233,242,
225,231,225,238, 97,128, 48, 70,111, 2,199, 30,199, 40,239,235,
225,226,239,246,101,128, 30,231,242,110,133, 1,176,199, 55,199,
63,199, 74,199, 82,199, 94,225,227,245,244,101,128, 30,233,228,
239,244,226,229,236,239,119,128, 30,241,231,242,225,246,101,128,
30,235,232,239,239,235,225,226,239,246,101,128, 30,237,244,233,
236,228,101,128, 30,239,245,238,231,225,242,245,237,236,225,245,
116,129, 1,113,199,118,227,249,242,233,236,236,233, 99,128, 4,
243,233,238,246,229,242,244,229,228,226,242,229,246,101,128, 2,
23,107, 3,199,153,199,177,199,188,225,244,225,235,225,238, 97,
129, 48,166,199,165,232,225,236,230,247,233,228,244,104,128,255,
115,227,249,242,233,236,236,233, 99,128, 4,121,239,242,229,225,
110,128, 49, 92,109, 2,199,202,199,255, 97, 2,199,208,199,241,
227,242,239,110,130, 1,107,199,219,199,230,227,249,242,233,236,
236,233, 99,128, 4,239,228,233,229,242,229,243,233,115,128, 30,
123,244,242,225,231,245,242,237,245,235,232,105,128, 10, 65,239,
238,239,243,240,225,227,101,128,255, 85,110, 2,200, 16,200, 71,
228,229,242,243,227,239,242,101,132, 0, 95,200, 35,200, 41,200,
53,200, 64,228,226,108,128, 32, 23,237,239,238,239,243,240,225,
227,101,128,255, 63,246,229,242,244,233,227,225,108,128,254, 51,
247,225,246,121,128,254, 79,105, 2,200, 77,200, 82,239,110,128,
34, 42,246,229,242,243,225,108,128, 34, 0,239,231,239,238,229,
107,128, 1,115,112, 5,200,112,200,119,200,127,200,142,200,193,
225,242,229,110,128, 36,176,226,236,239,227,107,128, 37,128,240,
229,242,228,239,244,232,229,226,242,229,119,128, 5,196,243,233,
236,239,110,131, 3,197,200,156,200,177,200,185,228,233,229,242,
229,243,233,115,129, 3,203,200,169,244,239,238,239,115,128, 3,
176,236,225,244,233,110,128, 2,138,244,239,238,239,115,128, 3,
205,244,225,227,107, 2,200,202,200,213,226,229,236,239,247,227,
237, 98,128, 3, 29,237,239,100,128, 2,212,114, 2,200,225,200,
237,225,231,245,242,237,245,235,232,105,128, 10,115,233,238,103,
128, 1,111,115, 3,200,251,201, 10,201, 55,232,239,242,244,227,
249,242,233,236,236,233, 99,128, 4, 94,237,225,236,108, 2,201,
19,201, 30,232,233,242,225,231,225,238, 97,128, 48, 69,235,225,
244,225,235,225,238, 97,129, 48,165,201, 43,232,225,236,230,247,
233,228,244,104,128,255,105,244,242,225,233,231,232,116, 2,201,
67,201, 78,227,249,242,233,236,236,233, 99,128, 4,175,243,244,
242,239,235,229,227,249,242,233,236,236,233, 99,128, 4,177,244,
233,236,228,101,130, 1,105,201,107,201,115,225,227,245,244,101,
128, 30,121,226,229,236,239,119,128, 30,117,117, 5,201,135,201,
145,201,152,201,177,201,193,226,229,238,231,225,236,105,128, 9,
138,228,229,246, 97,128, 9, 10,231,117, 2,201,159,201,168,234,
225,242,225,244,105,128, 10,138,242,237,245,235,232,105,128, 10,
10,237,225,244,242,225,231,245,242,237,245,235,232,105,128, 10,
66,246,239,247,229,236,243,233,231,110, 3,201,209,201,219,201,
226,226,229,238,231,225,236,105,128, 9,194,228,229,246, 97,128,
9, 66,231,245,234,225,242,225,244,105,128, 10,194,246,239,247,
229,236,243,233,231,110, 3,201,253,202, 7,202, 14,226,229,238,
231,225,236,105,128, 9,193,228,229,246, 97,128, 9, 65,231,245,
234,225,242,225,244,105,128, 10,193,118,139, 0,118,202, 51,202,
199,202,208,202,219,203,148,203,155,203,253,204, 9,204,109,204,
117,204,138, 97, 4,202, 61,202, 68,202, 93,202,104,228,229,246,
97,128, 9, 53,231,117, 2,202, 75,202, 84,234,225,242,225,244,
105,128, 10,181,242,237,245,235,232,105,128, 10, 53,235,225,244,
225,235,225,238, 97,128, 48,247,118,132, 5,213,202,116,202,143,
202,175,202,187,228,225,231,229,243,104,130,251, 53,202,129,202,
134,182, 53,128,251, 53,232,229,226,242,229,119,128,251, 53,104,
2,202,149,202,157,229,226,242,229,119,128, 5,213,239,236,225,
109,129,251, 75,202,166,232,229,226,242,229,119,128,251, 75,246,
225,246,232,229,226,242,229,119,128, 5,240,249,239,228,232,229,
226,242,229,119,128, 5,241,227,233,242,227,236,101,128, 36,229,
228,239,244,226,229,236,239,119,128, 30,127,101, 6,202,233,202,
244,203, 52,203, 63,203, 69,203,136,227,249,242,233,236,236,233,
99,128, 4, 50,104, 4,202,254,203, 7,203, 21,203, 37,225,242,
225,226,233, 99,128, 6,164,230,233,238,225,236,225,242,225,226,
233, 99,128,251,107,233,238,233,244,233,225,236,225,242,225,226,
233, 99,128,251,108,237,229,228,233,225,236,225,242,225,226,233,
99,128,251,109,235,225,244,225,235,225,238, 97,128, 48,249,238,
245,115,128, 38, 64,242,244,233,227,225,108, 2,203, 80,203, 86,
226,225,114,128, 0,124,236,233,238,101, 4,203, 99,203,110,203,
121,203,130,225,226,239,246,229,227,237, 98,128, 3, 13,226,229,
236,239,247,227,237, 98,128, 3, 41,236,239,247,237,239,100,128,
2,204,237,239,100,128, 2,200,247,225,242,237,229,238,233,225,
110,128, 5,126,232,239,239,107,128, 2,139,105, 3,203,163,203,
174,203,213,235,225,244,225,235,225,238, 97,128, 48,248,242,225,
237, 97, 3,203,185,203,195,203,202,226,229,238,231,225,236,105,
128, 9,205,228,229,246, 97,128, 9, 77,231,245,234,225,242,225,
244,105,128, 10,205,243,225,242,231, 97, 3,203,225,203,235,203,
242,226,229,238,231,225,236,105,128, 9,131,228,229,246, 97,128,
9, 3,231,245,234,225,242,225,244,105,128, 10,131,237,239,238,
239,243,240,225,227,101,128,255, 86,111, 3,204, 17,204, 28,204,
98,225,242,237,229,238,233,225,110,128, 5,120,233,227,229,100,
2,204, 37,204, 73,233,244,229,242,225,244,233,239,110, 2,204,
51,204, 62,232,233,242,225,231,225,238, 97,128, 48,158,235,225,
244,225,235,225,238, 97,128, 48,254,237,225,242,235,235,225,238,
97,129, 48,155,204, 86,232,225,236,230,247,233,228,244,104,128,
255,158,235,225,244,225,235,225,238, 97,128, 48,250,240,225,242,
229,110,128, 36,177,116, 2,204,123,204,130,233,236,228,101,128,
30,125,245,242,238,229,100,128, 2,140,117, 2,204,144,204,155,
232,233,242,225,231,225,238, 97,128, 48,148,235,225,244,225,235,
225,238, 97,128, 48,244,119,143, 0,119,204,200,205,177,205,187,
205,210,205,250,206, 61,206, 69,208, 40,208, 81,208, 93,208,168,
208,176,208,183,208,194,208,203, 97, 8,204,218,204,225,204,235,
204,246,205, 28,205, 60,205, 72,205,108,227,245,244,101,128, 30,
131,229,235,239,242,229,225,110,128, 49, 89,232,233,242,225,231,
225,238, 97,128, 48,143,107, 2,204,252,205, 20,225,244,225,235,
225,238, 97,129, 48,239,205, 8,232,225,236,230,247,233,228,244,
104,128,255,156,239,242,229,225,110,128, 49, 88,243,237,225,236,
108, 2,205, 38,205, 49,232,233,242,225,231,225,238, 97,128, 48,
142,235,225,244,225,235,225,238, 97,128, 48,238,244,244,239,243,
241,245,225,242,101,128, 51, 87,118, 2,205, 78,205, 86,229,228,
225,243,104,128, 48, 28,249,245,238,228,229,242,243,227,239,242,
229,246,229,242,244,233,227,225,108,128,254, 52,119, 3,205,116,
205,125,205,139,225,242,225,226,233, 99,128, 6, 72,230,233,238,
225,236,225,242,225,226,233, 99,128,254,238,232,225,237,250,225,
225,226,239,246,101, 2,205,154,205,163,225,242,225,226,233, 99,
128, 6, 36,230,233,238,225,236,225,242,225,226,233, 99,128,254,
134,226,243,241,245,225,242,101,128, 51,221,227,233,242, 99, 2,
205,196,205,201,236,101,128, 36,230,245,237,230,236,229,120,128,
1,117,100, 2,205,216,205,226,233,229,242,229,243,233,115,128,
30,133,239,116, 2,205,233,205,242,225,227,227,229,238,116,128,
30,135,226,229,236,239,119,128, 30,137,101, 4,206, 4,206, 15,
206, 27,206, 51,232,233,242,225,231,225,238, 97,128, 48,145,233,
229,242,243,244,242,225,243,115,128, 33, 24,107, 2,206, 33,206,
43,225,244,225,235,225,238, 97,128, 48,241,239,242,229,225,110,
128, 49, 94,239,235,239,242,229,225,110,128, 49, 93,231,242,225,
246,101,128, 30,129,232,233,244,101, 8,206, 90,206, 99,206,183,
207, 17,207,101,207,146,207,198,207,254,226,245,236,236,229,116,
128, 37,230, 99, 2,206,105,206,125,233,242,227,236,101,129, 37,
203,206,115,233,238,246,229,242,243,101,128, 37,217,239,242,238,
229,242,226,242,225,227,235,229,116, 2,206,142,206,162,236,229,
230,116,129, 48, 14,206,151,246,229,242,244,233,227,225,108,128,
254, 67,242,233,231,232,116,129, 48, 15,206,172,246,229,242,244,
233,227,225,108,128,254, 68,100, 2,206,189,206,230,233,225,237,
239,238,100,129, 37,199,206,200,227,239,238,244,225,233,238,233,
238,231,226,236,225,227,235,243,237,225,236,236,228,233,225,237,
239,238,100,128, 37,200,239,247,238,240,239,233,238,244,233,238,
103, 2,206,246,207, 6,243,237,225,236,236,244,242,233,225,238,
231,236,101,128, 37,191,244,242,233,225,238,231,236,101,128, 37,
189,236,101, 2,207, 24,207, 66,230,244,240,239,233,238,244,233,
238,103, 2,207, 39,207, 55,243,237,225,236,236,244,242,233,225,
238,231,236,101,128, 37,195,244,242,233,225,238,231,236,101,128,
37,193,238,244,233,227,245,236,225,242,226,242,225,227,235,229,
116, 2,207, 86,207, 93,236,229,230,116,128, 48, 22,242,233,231,
232,116,128, 48, 23,242,233,231,232,244,240,239,233,238,244,233,
238,103, 2,207,119,207,135,243,237,225,236,236,244,242,233,225,
238,231,236,101,128, 37,185,244,242,233,225,238,231,236,101,128,
37,183,115, 3,207,154,207,184,207,192,109, 2,207,160,207,172,
225,236,236,243,241,245,225,242,101,128, 37,171,233,236,233,238,
231,230,225,227,101,128, 38, 58,241,245,225,242,101,128, 37,161,
244,225,114,128, 38, 6,116, 2,207,204,207,215,229,236,229,240,
232,239,238,101,128, 38, 15,239,242,244,239,233,243,229,243,232,
229,236,236,226,242,225,227,235,229,116, 2,207,239,207,246,236,
229,230,116,128, 48, 24,242,233,231,232,116,128, 48, 25,245,240,
240,239,233,238,244,233,238,103, 2,208, 13,208, 29,243,237,225,
236,236,244,242,233,225,238,231,236,101,128, 37,181,244,242,233,
225,238,231,236,101,128, 37,179,105, 2,208, 46,208, 57,232,233,
242,225,231,225,238, 97,128, 48,144,107, 2,208, 63,208, 73,225,
244,225,235,225,238, 97,128, 48,240,239,242,229,225,110,128, 49,
95,237,239,238,239,243,240,225,227,101,128,255, 87,111, 4,208,
103,208,114,208,139,208,157,232,233,242,225,231,225,238, 97,128,
48,146,235,225,244,225,235,225,238, 97,129, 48,242,208,127,232,
225,236,230,247,233,228,244,104,128,255,102,110,129, 32,169,208,
145,237,239,238,239,243,240,225,227,101,128,255,230,247,225,229,
238,244,232,225,105,128, 14, 39,240,225,242,229,110,128, 36,178,
242,233,238,103,128, 30,152,243,245,240,229,242,233,239,114,128,
2,183,244,245,242,238,229,100,128, 2,141,249,238,110,128, 1,
191,120,137, 0,120,208,231,208,242,208,253,209, 6,209, 33,209,
46,209, 50,209, 62,209, 70,225,226,239,246,229,227,237, 98,128,
3, 61,226,239,240,239,237,239,230,111,128, 49, 18,227,233,242,
227,236,101,128, 36,231,100, 2,209, 12,209, 22,233,229,242,229,
243,233,115,128, 30,141,239,244,225,227,227,229,238,116,128, 30,
139,229,232,225,242,237,229,238,233,225,110,128, 5,109,105,128,
3,190,237,239,238,239,243,240,225,227,101,128,255, 88,240,225,
242,229,110,128, 36,179,243,245,240,229,242,233,239,114,128, 2,
227,121,143, 0,121,209,115,210, 74,210, 97,210,137,212,103,212,
111,212,128,212,192,212,204,213,201,213,241,213,253,214, 8,214,
29,215, 2, 97, 11,209,139,209,151,209,161,209,168,209,175,209,
185,209,210,209,221,210, 3,210, 16,210, 62,225,228,239,243,241,
245,225,242,101,128, 51, 78,226,229,238,231,225,236,105,128, 9,
175,227,245,244,101,128, 0,253,228,229,246, 97,128, 9, 47,229,
235,239,242,229,225,110,128, 49, 82,231,117, 2,209,192,209,201,
234,225,242,225,244,105,128, 10,175,242,237,245,235,232,105,128,
10, 47,232,233,242,225,231,225,238, 97,128, 48,132,107, 2,209,
227,209,251,225,244,225,235,225,238, 97,129, 48,228,209,239,232,
225,236,230,247,233,228,244,104,128,255,148,239,242,229,225,110,
128, 49, 81,237,225,235,235,225,238,244,232,225,105,128, 14, 78,
243,237,225,236,108, 2,210, 26,210, 37,232,233,242,225,231,225,
238, 97,128, 48,131,235,225,244,225,235,225,238, 97,129, 48,227,
210, 50,232,225,236,230,247,233,228,244,104,128,255,108,244,227,
249,242,233,236,236,233, 99,128, 4, 99,227,233,242, 99, 2,210,
83,210, 88,236,101,128, 36,232,245,237,230,236,229,120,128, 1,
119,100, 2,210,103,210,113,233,229,242,229,243,233,115,128, 0,
255,239,116, 2,210,120,210,129,225,227,227,229,238,116,128, 30,
143,226,229,236,239,119,128, 30,245,101, 7,210,153,211,161,211,
170,211,188,211,220,212, 40,212, 91,104, 8,210,171,210,180,210,
214,210,228,211, 45,211, 61,211,120,211,138,225,242,225,226,233,
99,128, 6, 74,226,225,242,242,229,101, 2,210,191,210,200,225,
242,225,226,233, 99,128, 6,210,230,233,238,225,236,225,242,225,
226,233, 99,128,251,175,230,233,238,225,236,225,242,225,226,233,
99,128,254,242,232,225,237,250,225,225,226,239,246,101, 4,210,
247,211, 0,211, 14,211, 30,225,242,225,226,233, 99,128, 6, 38,
230,233,238,225,236,225,242,225,226,233, 99,128,254,138,233,238,
233,244,233,225,236,225,242,225,226,233, 99,128,254,139,237,229,
228,233,225,236,225,242,225,226,233, 99,128,254,140,233,238,233,
244,233,225,236,225,242,225,226,233, 99,128,254,243,237,101, 2,
211, 68,211, 81,228,233,225,236,225,242,225,226,233, 99,128,254,
244,229,237,105, 2,211, 89,211,104,238,233,244,233,225,236,225,
242,225,226,233, 99,128,252,221,243,239,236,225,244,229,228,225,
242,225,226,233, 99,128,252, 88,238,239,239,238,230,233,238,225,
236,225,242,225,226,233, 99,128,252,148,244,232,242,229,229,228,
239,244,243,226,229,236,239,247,225,242,225,226,233, 99,128, 6,
209,235,239,242,229,225,110,128, 49, 86,110,129, 0,165,211,176,
237,239,238,239,243,240,225,227,101,128,255,229,111, 2,211,194,
211,203,235,239,242,229,225,110,128, 49, 85,242,233,238,232,233,
229,245,232,235,239,242,229,225,110,128, 49,134,114, 3,211,228,
212, 8,212, 20,225,232,226,229,238,249,239,237,111, 2,211,242,
211,251,232,229,226,242,229,119,128, 5,170,236,229,230,244,232,
229,226,242,229,119,128, 5,170,233,227,249,242,233,236,236,233,
99,128, 4, 75,245,228,233,229,242,229,243,233,243,227,249,242,
233,236,236,233, 99,128, 4,249,243,233,229,245,238,103, 3,212,
53,212, 62,212, 78,235,239,242,229,225,110,128, 49,129,240,225,
238,243,233,239,243,235,239,242,229,225,110,128, 49,131,243,233,
239,243,235,239,242,229,225,110,128, 49,130,244,233,246,232,229,
226,242,229,119,128, 5,154,231,242,225,246,101,128, 30,243,232,
239,239,107,129, 1,180,212,120,225,226,239,246,101,128, 30,247,
105, 5,212,140,212,151,212,162,212,171,212,179,225,242,237,229,
238,233,225,110,128, 5,117,227,249,242,233,236,236,233, 99,128,
4, 87,235,239,242,229,225,110,128, 49, 98,238,249,225,238,103,
128, 38, 47,247,238,225,242,237,229,238,233,225,110,128, 5,130,
237,239,238,239,243,240,225,227,101,128,255, 89,111, 7,212,220,
213, 34,213, 45,213, 55,213, 93,213,139,213,148,100,131, 5,217,
212,230,212,250,213, 3,228,225,231,229,243,104,129,251, 57,212,
241,232,229,226,242,229,119,128,251, 57,232,229,226,242,229,119,
128, 5,217,249,239,100, 2,213, 11,213, 20,232,229,226,242,229,
119,128, 5,242,240,225,244,225,232,232,229,226,242,229,119,128,
251, 31,232,233,242,225,231,225,238, 97,128, 48,136,233,235,239,
242,229,225,110,128, 49,137,107, 2,213, 61,213, 85,225,244,225,
235,225,238, 97,129, 48,232,213, 73,232,225,236,230,247,233,228,
244,104,128,255,150,239,242,229,225,110,128, 49, 91,243,237,225,
236,108, 2,213,103,213,114,232,233,242,225,231,225,238, 97,128,
48,135,235,225,244,225,235,225,238, 97,129, 48,231,213,127,232,
225,236,230,247,233,228,244,104,128,255,110,244,231,242,229,229,
107,128, 3,243,121, 2,213,154,213,191, 97, 2,213,160,213,170,
229,235,239,242,229,225,110,128, 49,136,107, 2,213,176,213,184,
239,242,229,225,110,128, 49,135,244,232,225,105,128, 14, 34,233,
238,231,244,232,225,105,128, 14, 13,112, 2,213,207,213,214,225,
242,229,110,128, 36,180,239,231,229,231,242,225,237,237,229,238,
105,129, 3,122,213,230,231,242,229,229,235,227,237, 98,128, 3,
69,114,129, 1,166,213,247,233,238,103,128, 30,153,243,245,240,
229,242,233,239,114,128, 2,184,116, 2,214, 14,214, 21,233,236,
228,101,128, 30,249,245,242,238,229,100,128, 2,142,117, 5,214,
41,214, 52,214, 62,214,100,214,232,232,233,242,225,231,225,238,
97,128, 48,134,233,235,239,242,229,225,110,128, 49,140,107, 2,
214, 68,214, 92,225,244,225,235,225,238, 97,129, 48,230,214, 80,
232,225,236,230,247,233,228,244,104,128,255,149,239,242,229,225,
110,128, 49, 96,115, 3,214,108,214,146,214,187,226,233,103, 2,
214,116,214,127,227,249,242,233,236,236,233, 99,128, 4,107,233,
239,244,233,230,233,229,228,227,249,242,233,236,236,233, 99,128,
4,109,236,233,244,244,236,101, 2,214,157,214,168,227,249,242,
233,236,236,233, 99,128, 4,103,233,239,244,233,230,233,229,228,
227,249,242,233,236,236,233, 99,128, 4,105,237,225,236,108, 2,
214,196,214,207,232,233,242,225,231,225,238, 97,128, 48,133,235,
225,244,225,235,225,238, 97,129, 48,229,214,220,232,225,236,230,
247,233,228,244,104,128,255,109,249,101, 2,214,239,214,248,235,
239,242,229,225,110,128, 49,139,239,235,239,242,229,225,110,128,
49,138,249, 97, 2,215, 9,215, 19,226,229,238,231,225,236,105,
128, 9,223,228,229,246, 97,128, 9, 95,122,142, 0,122,215, 58,
216, 66,216, 77,216,120,216,147,217,182,218, 34,218, 76,218, 88,
218,100,218,128,218,136,218,152,218,161, 97, 10,215, 80,215, 91,
215, 98,215,105,215,116,215,194,215,224,215,235,216, 15,216, 27,
225,242,237,229,238,233,225,110,128, 5,102,227,245,244,101,128,
1,122,228,229,246, 97,128, 9, 91,231,245,242,237,245,235,232,
105,128, 10, 91,104, 4,215,126,215,135,215,149,215,179,225,242,
225,226,233, 99,128, 6, 56,230,233,238,225,236,225,242,225,226,
233, 99,128,254,198,105, 2,215,155,215,170,238,233,244,233,225,
236,225,242,225,226,233, 99,128,254,199,242,225,231,225,238, 97,
128, 48, 86,237,229,228,233,225,236,225,242,225,226,233, 99,128,
254,200,233,110, 2,215,201,215,210,225,242,225,226,233, 99,128,
6, 50,230,233,238,225,236,225,242,225,226,233, 99,128,254,176,
235,225,244,225,235,225,238, 97,128, 48,182,241,229,102, 2,215,
243,216, 1,231,225,228,239,236,232,229,226,242,229,119,128, 5,
149,241,225,244,225,238,232,229,226,242,229,119,128, 5,148,242,
241,225,232,229,226,242,229,119,128, 5,152,249,233,110,130, 5,
214,216, 37,216, 57,228,225,231,229,243,104,129,251, 54,216, 48,
232,229,226,242,229,119,128,251, 54,232,229,226,242,229,119,128,
5,214,226,239,240,239,237,239,230,111,128, 49, 23, 99, 3,216,
85,216, 92,216,114,225,242,239,110,128, 1,126,233,242, 99, 2,
216,100,216,105,236,101,128, 36,233,245,237,230,236,229,120,128,
30,145,245,242,108,128, 2,145,228,239,116,130, 1,124,216,130,
216,139,225,227,227,229,238,116,128, 1,124,226,229,236,239,119,
128, 30,147,101, 6,216,161,216,172,216,215,216,226,216,237,217,
177,227,249,242,233,236,236,233, 99,128, 4, 55,100, 2,216,178,
216,197,229,243,227,229,238,228,229,242,227,249,242,233,236,236,
233, 99,128, 4,153,233,229,242,229,243,233,243,227,249,242,233,
236,236,233, 99,128, 4,223,232,233,242,225,231,225,238, 97,128,
48, 92,235,225,244,225,235,225,238, 97,128, 48,188,242,111,140,
0, 48,217, 10,217, 19,217, 29,217, 36,217, 61,217, 74,217, 85,
217, 97,217,108,217,118,217,129,217,136,225,242,225,226,233, 99,
128, 6, 96,226,229,238,231,225,236,105,128, 9,230,228,229,246,
97,128, 9,102,231,117, 2,217, 43,217, 52,234,225,242,225,244,
105,128, 10,230,242,237,245,235,232,105,128, 10,102,232,225,227,
235,225,242,225,226,233, 99,128, 6, 96,233,238,230,229,242,233,
239,114,128, 32,128,237,239,238,239,243,240,225,227,101,128,255,
16,239,236,228,243,244,249,236,101,128,247, 48,240,229,242,243,
233,225,110,128, 6,240,243,245,240,229,242,233,239,114,128, 32,
112,244,232,225,105,128, 14, 80,247,233,228,244,104, 3,217,148,
217,157,217,169,234,239,233,238,229,114,128,254,255,238,239,238,
234,239,233,238,229,114,128, 32, 12,243,240,225,227,101,128, 32,
11,244, 97,128, 3,182,104, 2,217,188,217,199,226,239,240,239,
237,239,230,111,128, 49, 19,101, 4,217,209,217,220,217,236,217,
247,225,242,237,229,238,233,225,110,128, 5,106,226,242,229,246,
229,227,249,242,233,236,236,233, 99,128, 4,194,227,249,242,233,
236,236,233, 99,128, 4, 54,100, 2,217,253,218, 16,229,243,227,
229,238,228,229,242,227,249,242,233,236,236,233, 99,128, 4,151,
233,229,242,229,243,233,243,227,249,242,233,236,236,233, 99,128,
4,221,105, 3,218, 42,218, 53,218, 64,232,233,242,225,231,225,
238, 97,128, 48, 88,235,225,244,225,235,225,238, 97,128, 48,184,
238,239,242,232,229,226,242,229,119,128, 5,174,236,233,238,229,
226,229,236,239,119,128, 30,149,237,239,238,239,243,240,225,227,
101,128,255, 90,111, 2,218,106,218,117,232,233,242,225,231,225,
238, 97,128, 48, 94,235,225,244,225,235,225,238, 97,128, 48,190,
240,225,242,229,110,128, 36,181,242,229,244,242,239,230,236,229,
248,232,239,239,107,128, 2,144,243,244,242,239,235,101,128, 1,
182,117, 2,218,167,218,178,232,233,242,225,231,225,238, 97,128,
48, 90,235,225,244,225,235,225,238, 97,128, 48,186
};
/*
* This function searches the compressed table efficiently.
*/
static unsigned long
ft_get_adobe_glyph_index( const char* name,
const char* limit )
{
int c = 0;
int count, min, max;
const unsigned char* p = ft_adobe_glyph_list;
if ( name == 0 || name >= limit )
goto NotFound;
c = *name++;
count = p[1];
p += 2;
min = 0;
max = count;
while ( min < max )
{
int mid = ( min + max ) >> 1;
const unsigned char* q = p + mid * 2;
int c2;
q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] );
c2 = q[0] & 127;
if ( c2 == c )
{
p = q;
goto Found;
}
if ( c2 < c )
min = mid + 1;
else
max = mid;
}
goto NotFound;
Found:
for (;;)
{
/* assert (*p & 127) == c */
if ( name >= limit )
{
if ( (p[0] & 128) == 0 &&
(p[1] & 128) != 0 )
return (unsigned long)( ( (int)p[2] << 8 ) | p[3] );
goto NotFound;
}
c = *name++;
if ( p[0] & 128 )
{
p++;
if ( c != (p[0] & 127) )
goto NotFound;
continue;
}
p++;
count = p[0] & 127;
if ( p[0] & 128 )
p += 2;
p++;
for ( ; count > 0; count--, p += 2 )
{
int offset = ( (int)p[0] << 8 ) | p[1];
const unsigned char* q = ft_adobe_glyph_list + offset;
if ( c == ( q[0] & 127 ) )
{
p = q;
goto NextIter;
}
}
goto NotFound;
NextIter:
;
}
NotFound:
return 0;
}
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/psnames/pstables.h | C | apache-2.0 | 267,881 |
#
# FreeType 2 PSNames driver configuration rules
#
# Copyright 1996-2001, 2003, 2011, 2013 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.
# PSNames driver directory
#
PSNAMES_DIR := $(SRC_DIR)/psnames
# compilation flags for the driver
#
PSNAMES_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSNAMES_DIR))
# PSNames driver sources (i.e., C files)
#
PSNAMES_DRV_SRC := $(PSNAMES_DIR)/psmodule.c \
$(PSNAMES_DIR)/pspic.c
# PSNames driver headers
#
PSNAMES_DRV_H := $(PSNAMES_DRV_SRC:%.c=%.h) \
$(PSNAMES_DIR)/psnamerr.h \
$(PSNAMES_DIR)/pstables.h
# PSNames driver object(s)
#
# PSNAMES_DRV_OBJ_M is used during `multi' builds
# PSNAMES_DRV_OBJ_S is used during `single' builds
#
PSNAMES_DRV_OBJ_M := $(PSNAMES_DRV_SRC:$(PSNAMES_DIR)/%.c=$(OBJ_DIR)/%.$O)
PSNAMES_DRV_OBJ_S := $(OBJ_DIR)/psnames.$O
# PSNames driver source file for single build
#
PSNAMES_DRV_SRC_S := $(PSNAMES_DIR)/psnames.c
# PSNames driver - single object
#
$(PSNAMES_DRV_OBJ_S): $(PSNAMES_DRV_SRC_S) $(PSNAMES_DRV_SRC) \
$(FREETYPE_H) $(PSNAMES_DRV_H)
$(PSNAMES_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PSNAMES_DRV_SRC_S))
# PSNames driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(PSNAMES_DIR)/%.c $(FREETYPE_H) $(PSNAMES_DRV_H)
$(PSNAMES_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(PSNAMES_DRV_OBJ_S)
DRV_OBJS_M += $(PSNAMES_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/psnames/rules.mk | Makefile | apache-2.0 | 1,784 |
/***************************************************************************/
/* */
/* ftmisc.h */
/* */
/* Miscellaneous macros for stand-alone rasterizer (specification */
/* only). */
/* */
/* Copyright 2005, 2009, 2010 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. */
/* */
/***************************************************************************/
/***************************************************/
/* */
/* This file is *not* portable! You have to adapt */
/* its definitions to your platform. */
/* */
/***************************************************/
#ifndef __FTMISC_H__
#define __FTMISC_H__
/* memset */
#include FT_CONFIG_STANDARD_LIBRARY_H
#define FT_BEGIN_HEADER
#define FT_END_HEADER
#define FT_LOCAL_DEF( x ) static x
/* from include/freetype2/fttypes.h */
typedef unsigned char FT_Byte;
typedef signed int FT_Int;
typedef unsigned int FT_UInt;
typedef signed long FT_Long;
typedef unsigned long FT_ULong;
typedef signed long FT_F26Dot6;
typedef int FT_Error;
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
( ( (FT_ULong)_x1 << 24 ) | \
( (FT_ULong)_x2 << 16 ) | \
( (FT_ULong)_x3 << 8 ) | \
(FT_ULong)_x4 )
/* from include/freetype2/ftsystem.h */
typedef struct FT_MemoryRec_* FT_Memory;
typedef void* (*FT_Alloc_Func)( FT_Memory memory,
long size );
typedef void (*FT_Free_Func)( FT_Memory memory,
void* block );
typedef void* (*FT_Realloc_Func)( FT_Memory memory,
long cur_size,
long new_size,
void* block );
typedef struct FT_MemoryRec_
{
void* user;
FT_Alloc_Func alloc;
FT_Free_Func free;
FT_Realloc_Func realloc;
} FT_MemoryRec;
/* from src/ftcalc.c */
#if ( defined _WIN32 || defined _WIN64 )
typedef __int64 FT_Int64;
#else
#include "inttypes.h"
typedef int64_t FT_Int64;
#endif
static FT_Long
FT_MulDiv( FT_Long a,
FT_Long b,
FT_Long c )
{
FT_Int s;
FT_Long d;
s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if ( c < 0 ) { c = -c; s = -s; }
d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFL );
return ( s > 0 ) ? d : -d;
}
static FT_Long
FT_MulDiv_No_Round( FT_Long a,
FT_Long b,
FT_Long c )
{
FT_Int s;
FT_Long d;
s = 1;
if ( a < 0 ) { a = -a; s = -1; }
if ( b < 0 ) { b = -b; s = -s; }
if ( c < 0 ) { c = -c; s = -s; }
d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
: 0x7FFFFFFFL );
return ( s > 0 ) ? d : -d;
}
#endif /* __FTMISC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/ftmisc.h | C | apache-2.0 | 4,055 |
/***************************************************************************/
/* */
/* ftraster.c */
/* */
/* The FreeType glyph rasterizer (body). */
/* */
/* Copyright 1996-2003, 2005, 2007-2014 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file can be compiled without the rest of the FreeType engine, by */
/* defining the _STANDALONE_ macro when compiling it. You also need to */
/* put the files `ftimage.h' and `ftmisc.h' into the $(incdir) */
/* directory. Typically, you should do something like */
/* */
/* - copy `src/raster/ftraster.c' (this file) to your current directory */
/* */
/* - copy `include/ftimage.h' and `src/raster/ftmisc.h' to your current */
/* directory */
/* */
/* - compile `ftraster' with the _STANDALONE_ macro defined, as in */
/* */
/* cc -c -D_STANDALONE_ ftraster.c */
/* */
/* The renderer can be initialized with a call to */
/* `ft_standard_raster.raster_new'; a bitmap can be generated */
/* with a call to `ft_standard_raster.raster_render'. */
/* */
/* See the comments and documentation in the file `ftimage.h' for more */
/* details on how the raster works. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* This is a rewrite of the FreeType 1.x scan-line converter */
/* */
/*************************************************************************/
#ifdef _STANDALONE_
#define FT_CONFIG_STANDARD_LIBRARY_H <stdlib.h>
#include <string.h> /* for memset */
#include "ftmisc.h"
#include "ftimage.h"
#else /* !_STANDALONE_ */
#include <ft2build.h>
#include "ftraster.h"
#include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */
#include "rastpic.h"
#endif /* !_STANDALONE_ */
/*************************************************************************/
/* */
/* A simple technical note on how the raster works */
/* ----------------------------------------------- */
/* */
/* Converting an outline into a bitmap is achieved in several steps: */
/* */
/* 1 - Decomposing the outline into successive `profiles'. Each */
/* profile is simply an array of scanline intersections on a given */
/* dimension. A profile's main attributes are */
/* */
/* o its scanline position boundaries, i.e. `Ymin' and `Ymax' */
/* */
/* o an array of intersection coordinates for each scanline */
/* between `Ymin' and `Ymax' */
/* */
/* o a direction, indicating whether it was built going `up' or */
/* `down', as this is very important for filling rules */
/* */
/* o its drop-out mode */
/* */
/* 2 - Sweeping the target map's scanlines in order to compute segment */
/* `spans' which are then filled. Additionally, this pass */
/* performs drop-out control. */
/* */
/* The outline data is parsed during step 1 only. The profiles are */
/* built from the bottom of the render pool, used as a stack. The */
/* following graphics shows the profile list under construction: */
/* */
/* __________________________________________________________ _ _ */
/* | | | | | */
/* | profile | coordinates for | profile | coordinates for |--> */
/* | 1 | profile 1 | 2 | profile 2 |--> */
/* |_________|_________________|_________|_________________|__ _ _ */
/* */
/* ^ ^ */
/* | | */
/* start of render pool top */
/* */
/* The top of the profile stack is kept in the `top' variable. */
/* */
/* As you can see, a profile record is pushed on top of the render */
/* pool, which is then followed by its coordinates/intersections. If */
/* a change of direction is detected in the outline, a new profile is */
/* generated until the end of the outline. */
/* */
/* Note that when all profiles have been generated, the function */
/* Finalize_Profile_Table() is used to record, for each profile, its */
/* bottom-most scanline as well as the scanline above its upmost */
/* boundary. These positions are called `y-turns' because they (sort */
/* of) correspond to local extrema. They are stored in a sorted list */
/* built from the top of the render pool as a downwards stack: */
/* */
/* _ _ _______________________________________ */
/* | | */
/* <--| sorted list of | */
/* <--| extrema scanlines | */
/* _ _ __________________|____________________| */
/* */
/* ^ ^ */
/* | | */
/* maxBuff sizeBuff = end of pool */
/* */
/* This list is later used during the sweep phase in order to */
/* optimize performance (see technical note on the sweep below). */
/* */
/* Of course, the raster detects whether the two stacks collide and */
/* handles the situation properly. */
/* */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/** **/
/** CONFIGURATION MACROS **/
/** **/
/*************************************************************************/
/*************************************************************************/
/* define DEBUG_RASTER if you want to compile a debugging version */
/* #define DEBUG_RASTER */
/* define FT_RASTER_OPTION_ANTI_ALIASING if you want to support */
/* 5-levels anti-aliasing */
/* #define FT_RASTER_OPTION_ANTI_ALIASING */
/* The size of the two-lines intermediate bitmap used */
/* for anti-aliasing, in bytes. */
#define RASTER_GRAY_LINES 2048
/*************************************************************************/
/*************************************************************************/
/** **/
/** OTHER MACROS (do not change) **/
/** **/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* 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_raster
#ifdef _STANDALONE_
/* Auxiliary macros for token concatenation. */
#define FT_ERR_XCAT( x, y ) x ## y
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
/* ANSI compilers (e.g. LCC). */
#define FT_UNUSED( x ) (x) = (x)
/* Disable the tracing mechanism for simplicity -- developers can */
/* activate it easily by redefining these macros. */
#ifndef FT_ERROR
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
#endif
#ifndef FT_TRACE
#define FT_TRACE( x ) do { } while ( 0 ) /* nothing */
#define FT_TRACE1( x ) do { } while ( 0 ) /* nothing */
#define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */
#endif
#ifndef FT_THROW
#define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e )
#endif
#define Raster_Err_None 0
#define Raster_Err_Not_Ini -1
#define Raster_Err_Overflow -2
#define Raster_Err_Neg_Height -3
#define Raster_Err_Invalid -4
#define Raster_Err_Unsupported -5
#define ft_memset memset
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \
raster_reset_, raster_set_mode_, \
raster_render_, raster_done_ ) \
const FT_Raster_Funcs class_ = \
{ \
glyph_format_, \
raster_new_, \
raster_reset_, \
raster_set_mode_, \
raster_render_, \
raster_done_ \
};
#else /* !_STANDALONE_ */
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */
#include "rasterrs.h"
#define Raster_Err_None FT_Err_Ok
#define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized
#define Raster_Err_Overflow Raster_Err_Raster_Overflow
#define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height
#define Raster_Err_Invalid Raster_Err_Invalid_Outline
#define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph
#endif /* !_STANDALONE_ */
#ifndef FT_MEM_SET
#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
#endif
#ifndef FT_MEM_ZERO
#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
#endif
/* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */
/* typically a small value and the result of a*b is known to fit into */
/* 32 bits. */
#define FMulDiv( a, b, c ) ( (a) * (b) / (c) )
/* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */
/* for clipping computations. It simply uses the FT_MulDiv() function */
/* defined in `ftcalc.h'. */
#define SMulDiv FT_MulDiv
#define SMulDiv_No_Round FT_MulDiv_No_Round
/* The rasterizer is a very general purpose component; please leave */
/* the following redefinitions there (you never know your target */
/* environment). */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL (void*)0
#endif
#ifndef SUCCESS
#define SUCCESS 0
#endif
#ifndef FAILURE
#define FAILURE 1
#endif
#define MaxBezier 32 /* The maximum number of stacked Bezier curves. */
/* Setting this constant to more than 32 is a */
/* pure waste of space. */
#define Pixel_Bits 6 /* fractional bits of *input* coordinates */
/*************************************************************************/
/*************************************************************************/
/** **/
/** SIMPLE TYPE DECLARATIONS **/
/** **/
/*************************************************************************/
/*************************************************************************/
typedef int Int;
typedef unsigned int UInt;
typedef short Short;
typedef unsigned short UShort, *PUShort;
typedef long Long, *PLong;
typedef unsigned long ULong;
typedef unsigned char Byte, *PByte;
typedef char Bool;
typedef union Alignment_
{
long l;
void* p;
void (*f)(void);
} Alignment, *PAlignment;
typedef struct TPoint_
{
Long x;
Long y;
} TPoint;
/* values for the `flags' bit field */
#define Flow_Up 0x8
#define Overshoot_Top 0x10
#define Overshoot_Bottom 0x20
/* States of each line, arc, and profile */
typedef enum TStates_
{
Unknown_State,
Ascending_State,
Descending_State,
Flat_State
} TStates;
typedef struct TProfile_ TProfile;
typedef TProfile* PProfile;
struct TProfile_
{
FT_F26Dot6 X; /* current coordinate during sweep */
PProfile link; /* link to next profile (various purposes) */
PLong offset; /* start of profile's data in render pool */
unsigned flags; /* Bit 0-2: drop-out mode */
/* Bit 3: profile orientation (up/down) */
/* Bit 4: is top profile? */
/* Bit 5: is bottom profile? */
long height; /* profile's height in scanlines */
long start; /* profile's starting scanline */
unsigned countL; /* number of lines to step before this */
/* profile becomes drawable */
PProfile next; /* next profile in same contour, used */
/* during drop-out control */
};
typedef PProfile TProfileList;
typedef PProfile* PProfileList;
/* Simple record used to implement a stack of bands, required */
/* by the sub-banding mechanism */
typedef struct black_TBand_
{
Short y_min; /* band's minimum */
Short y_max; /* band's maximum */
} black_TBand;
#define AlignProfileSize \
( ( sizeof ( TProfile ) + sizeof ( Alignment ) - 1 ) / sizeof ( long ) )
#undef RAS_ARG
#undef RAS_ARGS
#undef RAS_VAR
#undef RAS_VARS
#ifdef FT_STATIC_RASTER
#define RAS_ARGS /* void */
#define RAS_ARG /* void */
#define RAS_VARS /* void */
#define RAS_VAR /* void */
#define FT_UNUSED_RASTER do { } while ( 0 )
#else /* !FT_STATIC_RASTER */
#define RAS_ARGS black_PWorker worker,
#define RAS_ARG black_PWorker worker
#define RAS_VARS worker,
#define RAS_VAR worker
#define FT_UNUSED_RASTER FT_UNUSED( worker )
#endif /* !FT_STATIC_RASTER */
typedef struct black_TWorker_ black_TWorker, *black_PWorker;
/* prototypes used for sweep function dispatch */
typedef void
Function_Sweep_Init( RAS_ARGS Short* min,
Short* max );
typedef void
Function_Sweep_Span( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right );
typedef void
Function_Sweep_Step( RAS_ARG );
/* NOTE: These operations are only valid on 2's complement processors */
#undef FLOOR
#undef CEILING
#undef TRUNC
#undef SCALED
#define FLOOR( x ) ( (x) & -ras.precision )
#define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision )
#define TRUNC( x ) ( (Long)(x) >> ras.precision_bits )
#define FRAC( x ) ( (x) & ( ras.precision - 1 ) )
#define SCALED( x ) ( ( (ULong)(x) << ras.scale_shift ) - ras.precision_half )
#define IS_BOTTOM_OVERSHOOT( x ) \
(Bool)( CEILING( x ) - x >= ras.precision_half )
#define IS_TOP_OVERSHOOT( x ) \
(Bool)( x - FLOOR( x ) >= ras.precision_half )
/* The most used variables are positioned at the top of the structure. */
/* Thus, their offset can be coded with less opcodes, resulting in a */
/* smaller executable. */
struct black_TWorker_
{
Int precision_bits; /* precision related variables */
Int precision;
Int precision_half;
Int precision_shift;
Int precision_step;
Int precision_jitter;
Int scale_shift; /* == precision_shift for bitmaps */
/* == precision_shift+1 for pixmaps */
PLong buff; /* The profiles buffer */
PLong sizeBuff; /* Render pool size */
PLong maxBuff; /* Profiles buffer size */
PLong top; /* Current cursor in buffer */
FT_Error error;
Int numTurns; /* number of Y-turns in outline */
TPoint* arc; /* current Bezier arc pointer */
UShort bWidth; /* target bitmap width */
PByte bTarget; /* target bitmap buffer */
PByte gTarget; /* target pixmap buffer */
Long lastX, lastY;
Long minY, maxY;
UShort num_Profs; /* current number of profiles */
Bool fresh; /* signals a fresh new profile which */
/* `start' field must be completed */
Bool joint; /* signals that the last arc ended */
/* exactly on a scanline. Allows */
/* removal of doublets */
PProfile cProfile; /* current profile */
PProfile fProfile; /* head of linked list of profiles */
PProfile gProfile; /* contour's first profile in case */
/* of impact */
TStates state; /* rendering state */
FT_Bitmap target; /* description of target bit/pixmap */
FT_Outline outline;
Long traceOfs; /* current offset in target bitmap */
Long traceG; /* current offset in target pixmap */
Short traceIncr; /* sweep's increment in target bitmap */
Short gray_min_x; /* current min x during gray rendering */
Short gray_max_x; /* current max x during gray rendering */
/* dispatch variables */
Function_Sweep_Init* Proc_Sweep_Init;
Function_Sweep_Span* Proc_Sweep_Span;
Function_Sweep_Span* Proc_Sweep_Drop;
Function_Sweep_Step* Proc_Sweep_Step;
Byte dropOutControl; /* current drop_out control method */
Bool second_pass; /* indicates whether a horizontal pass */
/* should be performed to control */
/* drop-out accurately when calling */
/* Render_Glyph. Note that there is */
/* no horizontal pass during gray */
/* rendering. */
TPoint arcs[3 * MaxBezier + 1]; /* The Bezier stack */
black_TBand band_stack[16]; /* band stack used for sub-banding */
Int band_top; /* band stack top */
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
Byte* grays;
Byte gray_lines[RASTER_GRAY_LINES];
/* Intermediate table used to render the */
/* graylevels pixmaps. */
/* gray_lines is a buffer holding two */
/* monochrome scanlines */
Short gray_width; /* width in bytes of one monochrome */
/* intermediate scanline of gray_lines. */
/* Each gray pixel takes 2 bits long there */
/* The gray_lines must hold 2 lines, thus with size */
/* in bytes of at least `gray_width*2'. */
#endif /* FT_RASTER_ANTI_ALIASING */
};
typedef struct black_TRaster_
{
char* buffer;
long buffer_size;
void* memory;
black_PWorker worker;
Byte grays[5];
Short gray_width;
} black_TRaster, *black_PRaster;
#ifdef FT_STATIC_RASTER
static black_TWorker cur_ras;
#define ras cur_ras
#else /* !FT_STATIC_RASTER */
#define ras (*worker)
#endif /* !FT_STATIC_RASTER */
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
/* A lookup table used to quickly count set bits in four gray 2x2 */
/* cells. The values of the table have been produced with the */
/* following code: */
/* */
/* for ( i = 0; i < 256; i++ ) */
/* { */
/* l = 0; */
/* j = i; */
/* */
/* for ( c = 0; c < 4; c++ ) */
/* { */
/* l <<= 4; */
/* */
/* if ( j & 0x80 ) l++; */
/* if ( j & 0x40 ) l++; */
/* */
/* j = ( j << 2 ) & 0xFF; */
/* } */
/* printf( "0x%04X", l ); */
/* } */
/* */
static const short count_table[256] =
{
0x0000, 0x0001, 0x0001, 0x0002, 0x0010, 0x0011, 0x0011, 0x0012,
0x0010, 0x0011, 0x0011, 0x0012, 0x0020, 0x0021, 0x0021, 0x0022,
0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
0x0100, 0x0101, 0x0101, 0x0102, 0x0110, 0x0111, 0x0111, 0x0112,
0x0110, 0x0111, 0x0111, 0x0112, 0x0120, 0x0121, 0x0121, 0x0122,
0x0200, 0x0201, 0x0201, 0x0202, 0x0210, 0x0211, 0x0211, 0x0212,
0x0210, 0x0211, 0x0211, 0x0212, 0x0220, 0x0221, 0x0221, 0x0222,
0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
0x1000, 0x1001, 0x1001, 0x1002, 0x1010, 0x1011, 0x1011, 0x1012,
0x1010, 0x1011, 0x1011, 0x1012, 0x1020, 0x1021, 0x1021, 0x1022,
0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
0x1100, 0x1101, 0x1101, 0x1102, 0x1110, 0x1111, 0x1111, 0x1112,
0x1110, 0x1111, 0x1111, 0x1112, 0x1120, 0x1121, 0x1121, 0x1122,
0x1200, 0x1201, 0x1201, 0x1202, 0x1210, 0x1211, 0x1211, 0x1212,
0x1210, 0x1211, 0x1211, 0x1212, 0x1220, 0x1221, 0x1221, 0x1222,
0x2000, 0x2001, 0x2001, 0x2002, 0x2010, 0x2011, 0x2011, 0x2012,
0x2010, 0x2011, 0x2011, 0x2012, 0x2020, 0x2021, 0x2021, 0x2022,
0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
0x2100, 0x2101, 0x2101, 0x2102, 0x2110, 0x2111, 0x2111, 0x2112,
0x2110, 0x2111, 0x2111, 0x2112, 0x2120, 0x2121, 0x2121, 0x2122,
0x2200, 0x2201, 0x2201, 0x2202, 0x2210, 0x2211, 0x2211, 0x2212,
0x2210, 0x2211, 0x2211, 0x2212, 0x2220, 0x2221, 0x2221, 0x2222
};
#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
/*************************************************************************/
/*************************************************************************/
/** **/
/** PROFILES COMPUTATION **/
/** **/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* Set_High_Precision */
/* */
/* <Description> */
/* Set precision variables according to param flag. */
/* */
/* <Input> */
/* High :: Set to True for high precision (typically for ppem < 24), */
/* false otherwise. */
/* */
static void
Set_High_Precision( RAS_ARGS Int High )
{
/*
* `precision_step' is used in `Bezier_Up' to decide when to split a
* given y-monotonous Bezier arc that crosses a scanline before
* approximating it as a straight segment. The default value of 32 (for
* low accuracy) corresponds to
*
* 32 / 64 == 0.5 pixels ,
*
* while for the high accuracy case we have
*
* 256/ (1 << 12) = 0.0625 pixels .
*
* `precision_jitter' is an epsilon threshold used in
* `Vertical_Sweep_Span' to deal with small imperfections in the Bezier
* decomposition (after all, we are working with approximations only);
* it avoids switching on additional pixels which would cause artifacts
* otherwise.
*
* The value of `precision_jitter' has been determined heuristically.
*
*/
if ( High )
{
ras.precision_bits = 12;
ras.precision_step = 256;
ras.precision_jitter = 30;
}
else
{
ras.precision_bits = 6;
ras.precision_step = 32;
ras.precision_jitter = 2;
}
FT_TRACE6(( "Set_High_Precision(%s)\n", High ? "true" : "false" ));
ras.precision = 1 << ras.precision_bits;
ras.precision_half = ras.precision / 2;
ras.precision_shift = ras.precision_bits - Pixel_Bits;
}
/*************************************************************************/
/* */
/* <Function> */
/* New_Profile */
/* */
/* <Description> */
/* Create a new profile in the render pool. */
/* */
/* <Input> */
/* aState :: The state/orientation of the new profile. */
/* */
/* overshoot :: Whether the profile's unrounded start position */
/* differs by at least a half pixel. */
/* */
/* <Return> */
/* SUCCESS on success. FAILURE in case of overflow or of incoherent */
/* profile. */
/* */
static Bool
New_Profile( RAS_ARGS TStates aState,
Bool overshoot )
{
if ( !ras.fProfile )
{
ras.cProfile = (PProfile)ras.top;
ras.fProfile = ras.cProfile;
ras.top += AlignProfileSize;
}
if ( ras.top >= ras.maxBuff )
{
ras.error = FT_THROW( Overflow );
return FAILURE;
}
ras.cProfile->flags = 0;
ras.cProfile->start = 0;
ras.cProfile->height = 0;
ras.cProfile->offset = ras.top;
ras.cProfile->link = (PProfile)0;
ras.cProfile->next = (PProfile)0;
ras.cProfile->flags = ras.dropOutControl;
switch ( aState )
{
case Ascending_State:
ras.cProfile->flags |= Flow_Up;
if ( overshoot )
ras.cProfile->flags |= Overshoot_Bottom;
FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile ));
break;
case Descending_State:
if ( overshoot )
ras.cProfile->flags |= Overshoot_Top;
FT_TRACE6(( "New descending profile = %p\n", ras.cProfile ));
break;
default:
FT_ERROR(( "New_Profile: invalid profile direction\n" ));
ras.error = FT_THROW( Invalid );
return FAILURE;
}
if ( !ras.gProfile )
ras.gProfile = ras.cProfile;
ras.state = aState;
ras.fresh = TRUE;
ras.joint = FALSE;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* End_Profile */
/* */
/* <Description> */
/* Finalize the current profile. */
/* */
/* <Input> */
/* overshoot :: Whether the profile's unrounded end position differs */
/* by at least a half pixel. */
/* */
/* <Return> */
/* SUCCESS on success. FAILURE in case of overflow or incoherency. */
/* */
static Bool
End_Profile( RAS_ARGS Bool overshoot )
{
Long h;
h = (Long)( ras.top - ras.cProfile->offset );
if ( h < 0 )
{
FT_ERROR(( "End_Profile: negative height encountered\n" ));
ras.error = FT_THROW( Neg_Height );
return FAILURE;
}
if ( h > 0 )
{
PProfile oldProfile;
FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
ras.cProfile, ras.cProfile->start, h ));
ras.cProfile->height = h;
if ( overshoot )
{
if ( ras.cProfile->flags & Flow_Up )
ras.cProfile->flags |= Overshoot_Top;
else
ras.cProfile->flags |= Overshoot_Bottom;
}
oldProfile = ras.cProfile;
ras.cProfile = (PProfile)ras.top;
ras.top += AlignProfileSize;
ras.cProfile->height = 0;
ras.cProfile->offset = ras.top;
oldProfile->next = ras.cProfile;
ras.num_Profs++;
}
if ( ras.top >= ras.maxBuff )
{
FT_TRACE1(( "overflow in End_Profile\n" ));
ras.error = FT_THROW( Overflow );
return FAILURE;
}
ras.joint = FALSE;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Insert_Y_Turn */
/* */
/* <Description> */
/* Insert a salient into the sorted list placed on top of the render */
/* pool. */
/* */
/* <Input> */
/* New y scanline position. */
/* */
/* <Return> */
/* SUCCESS on success. FAILURE in case of overflow. */
/* */
static Bool
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
Int n;
n = ras.numTurns - 1;
y_turns = ras.sizeBuff - ras.numTurns;
/* look for first y value that is <= */
while ( n >= 0 && y < y_turns[n] )
n--;
/* if it is <, simply insert it, ignore if == */
if ( n >= 0 && y > y_turns[n] )
while ( n >= 0 )
{
Int y2 = (Int)y_turns[n];
y_turns[n] = y;
y = y2;
n--;
}
if ( n < 0 )
{
ras.maxBuff--;
if ( ras.maxBuff <= ras.top )
{
ras.error = FT_THROW( Overflow );
return FAILURE;
}
ras.numTurns++;
ras.sizeBuff[-ras.numTurns] = y;
}
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Finalize_Profile_Table */
/* */
/* <Description> */
/* Adjust all links in the profiles list. */
/* */
/* <Return> */
/* SUCCESS on success. FAILURE in case of overflow. */
/* */
static Bool
Finalize_Profile_Table( RAS_ARG )
{
UShort n;
PProfile p;
n = ras.num_Profs;
p = ras.fProfile;
if ( n > 1 && p )
{
while ( n > 0 )
{
Int bottom, top;
if ( n > 1 )
p->link = (PProfile)( p->offset + p->height );
else
p->link = NULL;
if ( p->flags & Flow_Up )
{
bottom = (Int)p->start;
top = (Int)( p->start + p->height - 1 );
}
else
{
bottom = (Int)( p->start - p->height + 1 );
top = (Int)p->start;
p->start = bottom;
p->offset += p->height - 1;
}
if ( Insert_Y_Turn( RAS_VARS bottom ) ||
Insert_Y_Turn( RAS_VARS top + 1 ) )
return FAILURE;
p = p->link;
n--;
}
}
else
ras.fProfile = NULL;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Split_Conic */
/* */
/* <Description> */
/* Subdivide one conic Bezier into two joint sub-arcs in the Bezier */
/* stack. */
/* */
/* <Input> */
/* None (subdivided Bezier is taken from the top of the stack). */
/* */
/* <Note> */
/* This routine is the `beef' of this component. It is _the_ inner */
/* loop that should be optimized to hell to get the best performance. */
/* */
static void
Split_Conic( TPoint* base )
{
Long a, b;
base[4].x = base[2].x;
b = base[1].x;
a = base[3].x = ( base[2].x + b ) / 2;
b = base[1].x = ( base[0].x + b ) / 2;
base[2].x = ( a + b ) / 2;
base[4].y = base[2].y;
b = base[1].y;
a = base[3].y = ( base[2].y + b ) / 2;
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
/* hand optimized. gcc doesn't seem to be too good at common */
/* expression substitution and instruction scheduling ;-) */
}
/*************************************************************************/
/* */
/* <Function> */
/* Split_Cubic */
/* */
/* <Description> */
/* Subdivide a third-order Bezier arc into two joint sub-arcs in the */
/* Bezier stack. */
/* */
/* <Note> */
/* This routine is the `beef' of the component. It is one of _the_ */
/* inner loops that should be optimized like hell to get the best */
/* performance. */
/* */
static void
Split_Cubic( TPoint* base )
{
Long a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
d = base[2].x;
base[1].x = a = ( base[0].x + c + 1 ) >> 1;
base[5].x = b = ( base[3].x + d + 1 ) >> 1;
c = ( c + d + 1 ) >> 1;
base[2].x = a = ( a + c + 1 ) >> 1;
base[4].x = b = ( b + c + 1 ) >> 1;
base[3].x = ( a + b + 1 ) >> 1;
base[6].y = base[3].y;
c = base[1].y;
d = base[2].y;
base[1].y = a = ( base[0].y + c + 1 ) >> 1;
base[5].y = b = ( base[3].y + d + 1 ) >> 1;
c = ( c + d + 1 ) >> 1;
base[2].y = a = ( a + c + 1 ) >> 1;
base[4].y = b = ( b + c + 1 ) >> 1;
base[3].y = ( a + b + 1 ) >> 1;
}
/*************************************************************************/
/* */
/* <Function> */
/* Line_Up */
/* */
/* <Description> */
/* Compute the x-coordinates of an ascending line segment and store */
/* them in the render pool. */
/* */
/* <Input> */
/* x1 :: The x-coordinate of the segment's start point. */
/* */
/* y1 :: The y-coordinate of the segment's start point. */
/* */
/* x2 :: The x-coordinate of the segment's end point. */
/* */
/* y2 :: The y-coordinate of the segment's end point. */
/* */
/* miny :: A lower vertical clipping bound value. */
/* */
/* maxy :: An upper vertical clipping bound value. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static Bool
Line_Up( RAS_ARGS Long x1,
Long y1,
Long x2,
Long y2,
Long miny,
Long maxy )
{
Long Dx, Dy;
Int e1, e2, f1, f2, size; /* XXX: is `Short' sufficient? */
Long Ix, Rx, Ax;
PLong top;
Dx = x2 - x1;
Dy = y2 - y1;
if ( Dy <= 0 || y2 < miny || y1 > maxy )
return SUCCESS;
if ( y1 < miny )
{
/* Take care: miny-y1 can be a very large value; we use */
/* a slow MulDiv function to avoid clipping bugs */
x1 += SMulDiv( Dx, miny - y1, Dy );
e1 = (Int)TRUNC( miny );
f1 = 0;
}
else
{
e1 = (Int)TRUNC( y1 );
f1 = (Int)FRAC( y1 );
}
if ( y2 > maxy )
{
/* x2 += FMulDiv( Dx, maxy - y2, Dy ); UNNECESSARY */
e2 = (Int)TRUNC( maxy );
f2 = 0;
}
else
{
e2 = (Int)TRUNC( y2 );
f2 = (Int)FRAC( y2 );
}
if ( f1 > 0 )
{
if ( e1 == e2 )
return SUCCESS;
else
{
x1 += SMulDiv( Dx, ras.precision - f1, Dy );
e1 += 1;
}
}
else
if ( ras.joint )
{
ras.top--;
ras.joint = FALSE;
}
ras.joint = (char)( f2 == 0 );
if ( ras.fresh )
{
ras.cProfile->start = e1;
ras.fresh = FALSE;
}
size = e2 - e1 + 1;
if ( ras.top + size >= ras.maxBuff )
{
ras.error = FT_THROW( Overflow );
return FAILURE;
}
if ( Dx > 0 )
{
Ix = SMulDiv_No_Round( ras.precision, Dx, Dy );
Rx = ( ras.precision * Dx ) % Dy;
Dx = 1;
}
else
{
Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy );
Rx = ( ras.precision * -Dx ) % Dy;
Dx = -1;
}
Ax = -Dy;
top = ras.top;
while ( size > 0 )
{
*top++ = x1;
x1 += Ix;
Ax += Rx;
if ( Ax >= 0 )
{
Ax -= Dy;
x1 += Dx;
}
size--;
}
ras.top = top;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Line_Down */
/* */
/* <Description> */
/* Compute the x-coordinates of an descending line segment and store */
/* them in the render pool. */
/* */
/* <Input> */
/* x1 :: The x-coordinate of the segment's start point. */
/* */
/* y1 :: The y-coordinate of the segment's start point. */
/* */
/* x2 :: The x-coordinate of the segment's end point. */
/* */
/* y2 :: The y-coordinate of the segment's end point. */
/* */
/* miny :: A lower vertical clipping bound value. */
/* */
/* maxy :: An upper vertical clipping bound value. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static Bool
Line_Down( RAS_ARGS Long x1,
Long y1,
Long x2,
Long y2,
Long miny,
Long maxy )
{
Bool result, fresh;
fresh = ras.fresh;
result = Line_Up( RAS_VARS x1, -y1, x2, -y2, -maxy, -miny );
if ( fresh && !ras.fresh )
ras.cProfile->start = -ras.cProfile->start;
return result;
}
/* A function type describing the functions used to split Bezier arcs */
typedef void (*TSplitter)( TPoint* base );
/*************************************************************************/
/* */
/* <Function> */
/* Bezier_Up */
/* */
/* <Description> */
/* Compute the x-coordinates of an ascending Bezier arc and store */
/* them in the render pool. */
/* */
/* <Input> */
/* degree :: The degree of the Bezier arc (either 2 or 3). */
/* */
/* splitter :: The function to split Bezier arcs. */
/* */
/* miny :: A lower vertical clipping bound value. */
/* */
/* maxy :: An upper vertical clipping bound value. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static Bool
Bezier_Up( RAS_ARGS Int degree,
TSplitter splitter,
Long miny,
Long maxy )
{
Long y1, y2, e, e2, e0;
Short f1;
TPoint* arc;
TPoint* start_arc;
PLong top;
arc = ras.arc;
y1 = arc[degree].y;
y2 = arc[0].y;
top = ras.top;
if ( y2 < miny || y1 > maxy )
goto Fin;
e2 = FLOOR( y2 );
if ( e2 > maxy )
e2 = maxy;
e0 = miny;
if ( y1 < miny )
e = miny;
else
{
e = CEILING( y1 );
f1 = (Short)( FRAC( y1 ) );
e0 = e;
if ( f1 == 0 )
{
if ( ras.joint )
{
top--;
ras.joint = FALSE;
}
*top++ = arc[degree].x;
e += ras.precision;
}
}
if ( ras.fresh )
{
ras.cProfile->start = TRUNC( e0 );
ras.fresh = FALSE;
}
if ( e2 < e )
goto Fin;
if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff )
{
ras.top = top;
ras.error = FT_THROW( Overflow );
return FAILURE;
}
start_arc = arc;
while ( arc >= start_arc && e <= e2 )
{
ras.joint = FALSE;
y2 = arc[0].y;
if ( y2 > e )
{
y1 = arc[degree].y;
if ( y2 - y1 >= ras.precision_step )
{
splitter( arc );
arc += degree;
}
else
{
*top++ = arc[degree].x + FMulDiv( arc[0].x - arc[degree].x,
e - y1, y2 - y1 );
arc -= degree;
e += ras.precision;
}
}
else
{
if ( y2 == e )
{
ras.joint = TRUE;
*top++ = arc[0].x;
e += ras.precision;
}
arc -= degree;
}
}
Fin:
ras.top = top;
ras.arc -= degree;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Bezier_Down */
/* */
/* <Description> */
/* Compute the x-coordinates of an descending Bezier arc and store */
/* them in the render pool. */
/* */
/* <Input> */
/* degree :: The degree of the Bezier arc (either 2 or 3). */
/* */
/* splitter :: The function to split Bezier arcs. */
/* */
/* miny :: A lower vertical clipping bound value. */
/* */
/* maxy :: An upper vertical clipping bound value. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow. */
/* */
static Bool
Bezier_Down( RAS_ARGS Int degree,
TSplitter splitter,
Long miny,
Long maxy )
{
TPoint* arc = ras.arc;
Bool result, fresh;
arc[0].y = -arc[0].y;
arc[1].y = -arc[1].y;
arc[2].y = -arc[2].y;
if ( degree > 2 )
arc[3].y = -arc[3].y;
fresh = ras.fresh;
result = Bezier_Up( RAS_VARS degree, splitter, -maxy, -miny );
if ( fresh && !ras.fresh )
ras.cProfile->start = -ras.cProfile->start;
arc[0].y = -arc[0].y;
return result;
}
/*************************************************************************/
/* */
/* <Function> */
/* Line_To */
/* */
/* <Description> */
/* Inject a new line segment and adjust the Profiles list. */
/* */
/* <Input> */
/* x :: The x-coordinate of the segment's end point (its start point */
/* is stored in `lastX'). */
/* */
/* y :: The y-coordinate of the segment's end point (its start point */
/* is stored in `lastY'). */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow or incorrect */
/* profile. */
/* */
static Bool
Line_To( RAS_ARGS Long x,
Long y )
{
/* First, detect a change of direction */
switch ( ras.state )
{
case Unknown_State:
if ( y > ras.lastY )
{
if ( New_Profile( RAS_VARS Ascending_State,
IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
return FAILURE;
}
else
{
if ( y < ras.lastY )
if ( New_Profile( RAS_VARS Descending_State,
IS_TOP_OVERSHOOT( ras.lastY ) ) )
return FAILURE;
}
break;
case Ascending_State:
if ( y < ras.lastY )
{
if ( End_Profile( RAS_VARS IS_TOP_OVERSHOOT( ras.lastY ) ) ||
New_Profile( RAS_VARS Descending_State,
IS_TOP_OVERSHOOT( ras.lastY ) ) )
return FAILURE;
}
break;
case Descending_State:
if ( y > ras.lastY )
{
if ( End_Profile( RAS_VARS IS_BOTTOM_OVERSHOOT( ras.lastY ) ) ||
New_Profile( RAS_VARS Ascending_State,
IS_BOTTOM_OVERSHOOT( ras.lastY ) ) )
return FAILURE;
}
break;
default:
;
}
/* Then compute the lines */
switch ( ras.state )
{
case Ascending_State:
if ( Line_Up( RAS_VARS ras.lastX, ras.lastY,
x, y, ras.minY, ras.maxY ) )
return FAILURE;
break;
case Descending_State:
if ( Line_Down( RAS_VARS ras.lastX, ras.lastY,
x, y, ras.minY, ras.maxY ) )
return FAILURE;
break;
default:
;
}
ras.lastX = x;
ras.lastY = y;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Conic_To */
/* */
/* <Description> */
/* Inject a new conic arc and adjust the profile list. */
/* */
/* <Input> */
/* cx :: The x-coordinate of the arc's new control point. */
/* */
/* cy :: The y-coordinate of the arc's new control point. */
/* */
/* x :: The x-coordinate of the arc's end point (its start point is */
/* stored in `lastX'). */
/* */
/* y :: The y-coordinate of the arc's end point (its start point is */
/* stored in `lastY'). */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow or incorrect */
/* profile. */
/* */
static Bool
Conic_To( RAS_ARGS Long cx,
Long cy,
Long x,
Long y )
{
Long y1, y2, y3, x3, ymin, ymax;
TStates state_bez;
ras.arc = ras.arcs;
ras.arc[2].x = ras.lastX;
ras.arc[2].y = ras.lastY;
ras.arc[1].x = cx;
ras.arc[1].y = cy;
ras.arc[0].x = x;
ras.arc[0].y = y;
do
{
y1 = ras.arc[2].y;
y2 = ras.arc[1].y;
y3 = ras.arc[0].y;
x3 = ras.arc[0].x;
/* first, categorize the Bezier arc */
if ( y1 <= y3 )
{
ymin = y1;
ymax = y3;
}
else
{
ymin = y3;
ymax = y1;
}
if ( y2 < ymin || y2 > ymax )
{
/* this arc has no given direction, split it! */
Split_Conic( ras.arc );
ras.arc += 2;
}
else if ( y1 == y3 )
{
/* this arc is flat, ignore it and pop it from the Bezier stack */
ras.arc -= 2;
}
else
{
/* the arc is y-monotonous, either ascending or descending */
/* detect a change of direction */
state_bez = y1 < y3 ? Ascending_State : Descending_State;
if ( ras.state != state_bez )
{
Bool o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
: IS_TOP_OVERSHOOT( y1 );
/* finalize current profile if any */
if ( ras.state != Unknown_State &&
End_Profile( RAS_VARS o ) )
goto Fail;
/* create a new profile */
if ( New_Profile( RAS_VARS state_bez, o ) )
goto Fail;
}
/* now call the appropriate routine */
if ( state_bez == Ascending_State )
{
if ( Bezier_Up( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
goto Fail;
}
else
if ( Bezier_Down( RAS_VARS 2, Split_Conic, ras.minY, ras.maxY ) )
goto Fail;
}
} while ( ras.arc >= ras.arcs );
ras.lastX = x3;
ras.lastY = y3;
return SUCCESS;
Fail:
return FAILURE;
}
/*************************************************************************/
/* */
/* <Function> */
/* Cubic_To */
/* */
/* <Description> */
/* Inject a new cubic arc and adjust the profile list. */
/* */
/* <Input> */
/* cx1 :: The x-coordinate of the arc's first new control point. */
/* */
/* cy1 :: The y-coordinate of the arc's first new control point. */
/* */
/* cx2 :: The x-coordinate of the arc's second new control point. */
/* */
/* cy2 :: The y-coordinate of the arc's second new control point. */
/* */
/* x :: The x-coordinate of the arc's end point (its start point is */
/* stored in `lastX'). */
/* */
/* y :: The y-coordinate of the arc's end point (its start point is */
/* stored in `lastY'). */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on render pool overflow or incorrect */
/* profile. */
/* */
static Bool
Cubic_To( RAS_ARGS Long cx1,
Long cy1,
Long cx2,
Long cy2,
Long x,
Long y )
{
Long y1, y2, y3, y4, x4, ymin1, ymax1, ymin2, ymax2;
TStates state_bez;
ras.arc = ras.arcs;
ras.arc[3].x = ras.lastX;
ras.arc[3].y = ras.lastY;
ras.arc[2].x = cx1;
ras.arc[2].y = cy1;
ras.arc[1].x = cx2;
ras.arc[1].y = cy2;
ras.arc[0].x = x;
ras.arc[0].y = y;
do
{
y1 = ras.arc[3].y;
y2 = ras.arc[2].y;
y3 = ras.arc[1].y;
y4 = ras.arc[0].y;
x4 = ras.arc[0].x;
/* first, categorize the Bezier arc */
if ( y1 <= y4 )
{
ymin1 = y1;
ymax1 = y4;
}
else
{
ymin1 = y4;
ymax1 = y1;
}
if ( y2 <= y3 )
{
ymin2 = y2;
ymax2 = y3;
}
else
{
ymin2 = y3;
ymax2 = y2;
}
if ( ymin2 < ymin1 || ymax2 > ymax1 )
{
/* this arc has no given direction, split it! */
Split_Cubic( ras.arc );
ras.arc += 3;
}
else if ( y1 == y4 )
{
/* this arc is flat, ignore it and pop it from the Bezier stack */
ras.arc -= 3;
}
else
{
state_bez = ( y1 <= y4 ) ? Ascending_State : Descending_State;
/* detect a change of direction */
if ( ras.state != state_bez )
{
Bool o = state_bez == Ascending_State ? IS_BOTTOM_OVERSHOOT( y1 )
: IS_TOP_OVERSHOOT( y1 );
/* finalize current profile if any */
if ( ras.state != Unknown_State &&
End_Profile( RAS_VARS o ) )
goto Fail;
if ( New_Profile( RAS_VARS state_bez, o ) )
goto Fail;
}
/* compute intersections */
if ( state_bez == Ascending_State )
{
if ( Bezier_Up( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
goto Fail;
}
else
if ( Bezier_Down( RAS_VARS 3, Split_Cubic, ras.minY, ras.maxY ) )
goto Fail;
}
} while ( ras.arc >= ras.arcs );
ras.lastX = x4;
ras.lastY = y4;
return SUCCESS;
Fail:
return FAILURE;
}
#undef SWAP_
#define SWAP_( x, y ) do \
{ \
Long swap = x; \
\
\
x = y; \
y = swap; \
} while ( 0 )
/*************************************************************************/
/* */
/* <Function> */
/* Decompose_Curve */
/* */
/* <Description> */
/* Scan the outline arrays in order to emit individual segments and */
/* Beziers by calling Line_To() and Bezier_To(). It handles all */
/* weird cases, like when the first point is off the curve, or when */
/* there are simply no `on' points in the contour! */
/* */
/* <Input> */
/* first :: The index of the first point in the contour. */
/* */
/* last :: The index of the last point in the contour. */
/* */
/* flipped :: If set, flip the direction of the curve. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE on error. */
/* */
static Bool
Decompose_Curve( RAS_ARGS UShort first,
UShort last,
int flipped )
{
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
FT_Vector* points;
FT_Vector* point;
FT_Vector* limit;
char* tags;
unsigned tag; /* current point's state */
points = ras.outline.points;
limit = points + last;
v_start.x = SCALED( points[first].x );
v_start.y = SCALED( points[first].y );
v_last.x = SCALED( points[last].x );
v_last.y = SCALED( points[last].y );
if ( flipped )
{
SWAP_( v_start.x, v_start.y );
SWAP_( v_last.x, v_last.y );
}
v_control = v_start;
point = points + first;
tags = ras.outline.tags + first;
/* set scan mode if necessary */
if ( tags[0] & FT_CURVE_TAG_HAS_SCANMODE )
ras.dropOutControl = (Byte)tags[0] >> 5;
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( ras.outline.tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle and record its position */
/* for closure */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
/* v_last = v_start; */
}
point--;
tags--;
}
ras.lastX = v_start.x;
ras.lastY = v_start.y;
while ( point < limit )
{
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
Long x, y;
x = SCALED( point->x );
y = SCALED( point->y );
if ( flipped )
SWAP_( x, y );
if ( Line_To( RAS_VARS x, y ) )
goto Fail;
continue;
}
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = SCALED( point[0].x );
v_control.y = SCALED( point[0].y );
if ( flipped )
SWAP_( v_control.x, v_control.y );
Do_Conic:
if ( point < limit )
{
FT_Vector v_middle;
Long x, y;
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
x = SCALED( point[0].x );
y = SCALED( point[0].y );
if ( flipped )
SWAP_( x, y );
if ( tag == FT_CURVE_TAG_ON )
{
if ( Conic_To( RAS_VARS v_control.x, v_control.y, x, y ) )
goto Fail;
continue;
}
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + x ) / 2;
v_middle.y = ( v_control.y + y ) / 2;
if ( Conic_To( RAS_VARS v_control.x, v_control.y,
v_middle.x, v_middle.y ) )
goto Fail;
v_control.x = x;
v_control.y = y;
goto Do_Conic;
}
if ( Conic_To( RAS_VARS v_control.x, v_control.y,
v_start.x, v_start.y ) )
goto Fail;
goto Close;
default: /* FT_CURVE_TAG_CUBIC */
{
Long x1, y1, x2, y2, x3, y3;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
tags += 2;
x1 = SCALED( point[-2].x );
y1 = SCALED( point[-2].y );
x2 = SCALED( point[-1].x );
y2 = SCALED( point[-1].y );
if ( flipped )
{
SWAP_( x1, y1 );
SWAP_( x2, y2 );
}
if ( point <= limit )
{
x3 = SCALED( point[0].x );
y3 = SCALED( point[0].y );
if ( flipped )
SWAP_( x3, y3 );
if ( Cubic_To( RAS_VARS x1, y1, x2, y2, x3, y3 ) )
goto Fail;
continue;
}
if ( Cubic_To( RAS_VARS x1, y1, x2, y2, v_start.x, v_start.y ) )
goto Fail;
goto Close;
}
}
}
/* close the contour with a line segment */
if ( Line_To( RAS_VARS v_start.x, v_start.y ) )
goto Fail;
Close:
return SUCCESS;
Invalid_Outline:
ras.error = FT_THROW( Invalid );
Fail:
return FAILURE;
}
/*************************************************************************/
/* */
/* <Function> */
/* Convert_Glyph */
/* */
/* <Description> */
/* Convert a glyph into a series of segments and arcs and make a */
/* profiles list with them. */
/* */
/* <Input> */
/* flipped :: If set, flip the direction of curve. */
/* */
/* <Return> */
/* SUCCESS on success, FAILURE if any error was encountered during */
/* rendering. */
/* */
static Bool
Convert_Glyph( RAS_ARGS int flipped )
{
int i;
unsigned start;
ras.fProfile = NULL;
ras.joint = FALSE;
ras.fresh = FALSE;
ras.maxBuff = ras.sizeBuff - AlignProfileSize;
ras.numTurns = 0;
ras.cProfile = (PProfile)ras.top;
ras.cProfile->offset = ras.top;
ras.num_Profs = 0;
start = 0;
for ( i = 0; i < ras.outline.n_contours; i++ )
{
PProfile lastProfile;
Bool o;
ras.state = Unknown_State;
ras.gProfile = NULL;
if ( Decompose_Curve( RAS_VARS (unsigned short)start,
ras.outline.contours[i],
flipped ) )
return FAILURE;
start = ras.outline.contours[i] + 1;
/* we must now check whether the extreme arcs join or not */
if ( FRAC( ras.lastY ) == 0 &&
ras.lastY >= ras.minY &&
ras.lastY <= ras.maxY )
if ( ras.gProfile &&
( ras.gProfile->flags & Flow_Up ) ==
( ras.cProfile->flags & Flow_Up ) )
ras.top--;
/* Note that ras.gProfile can be nil if the contour was too small */
/* to be drawn. */
lastProfile = ras.cProfile;
if ( ras.cProfile->flags & Flow_Up )
o = IS_TOP_OVERSHOOT( ras.lastY );
else
o = IS_BOTTOM_OVERSHOOT( ras.lastY );
if ( End_Profile( RAS_VARS o ) )
return FAILURE;
/* close the `next profile in contour' linked list */
if ( ras.gProfile )
lastProfile->next = ras.gProfile;
}
if ( Finalize_Profile_Table( RAS_VAR ) )
return FAILURE;
return (Bool)( ras.top < ras.maxBuff ? SUCCESS : FAILURE );
}
/*************************************************************************/
/*************************************************************************/
/** **/
/** SCAN-LINE SWEEPS AND DRAWING **/
/** **/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* Init_Linked */
/* */
/* Initializes an empty linked list. */
/* */
static void
Init_Linked( TProfileList* l )
{
*l = NULL;
}
/*************************************************************************/
/* */
/* InsNew */
/* */
/* Inserts a new profile in a linked list. */
/* */
static void
InsNew( PProfileList list,
PProfile profile )
{
PProfile *old, current;
Long x;
old = list;
current = *old;
x = profile->X;
while ( current )
{
if ( x < current->X )
break;
old = ¤t->link;
current = *old;
}
profile->link = current;
*old = profile;
}
/*************************************************************************/
/* */
/* DelOld */
/* */
/* Removes an old profile from a linked list. */
/* */
static void
DelOld( PProfileList list,
PProfile profile )
{
PProfile *old, current;
old = list;
current = *old;
while ( current )
{
if ( current == profile )
{
*old = current->link;
return;
}
old = ¤t->link;
current = *old;
}
/* we should never get there, unless the profile was not part of */
/* the list. */
}
/*************************************************************************/
/* */
/* Sort */
/* */
/* Sorts a trace list. In 95%, the list is already sorted. We need */
/* an algorithm which is fast in this case. Bubble sort is enough */
/* and simple. */
/* */
static void
Sort( PProfileList list )
{
PProfile *old, current, next;
/* First, set the new X coordinate of each profile */
current = *list;
while ( current )
{
current->X = *current->offset;
current->offset += current->flags & Flow_Up ? 1 : -1;
current->height--;
current = current->link;
}
/* Then sort them */
old = list;
current = *old;
if ( !current )
return;
next = current->link;
while ( next )
{
if ( current->X <= next->X )
{
old = ¤t->link;
current = *old;
if ( !current )
return;
}
else
{
*old = next;
current->link = next->link;
next->link = current;
old = list;
current = *old;
}
next = current->link;
}
}
/*************************************************************************/
/* */
/* Vertical Sweep Procedure Set */
/* */
/* These four routines are used during the vertical black/white sweep */
/* phase by the generic Draw_Sweep() function. */
/* */
/*************************************************************************/
static void
Vertical_Sweep_Init( RAS_ARGS Short* min,
Short* max )
{
Long pitch = ras.target.pitch;
FT_UNUSED( max );
ras.traceIncr = (Short)-pitch;
ras.traceOfs = -*min * pitch;
if ( pitch > 0 )
ras.traceOfs += ( ras.target.rows - 1 ) * pitch;
ras.gray_min_x = 0;
ras.gray_max_x = 0;
}
static void
Vertical_Sweep_Span( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
Long e1, e2;
Byte* target;
FT_UNUSED( y );
FT_UNUSED( left );
FT_UNUSED( right );
/* Drop-out control */
e1 = TRUNC( CEILING( x1 ) );
if ( x2 - x1 - ras.precision <= ras.precision_jitter )
e2 = e1;
else
e2 = TRUNC( FLOOR( x2 ) );
if ( e2 >= 0 && e1 < ras.bWidth )
{
int c1, c2;
Byte f1, f2;
if ( e1 < 0 )
e1 = 0;
if ( e2 >= ras.bWidth )
e2 = ras.bWidth - 1;
c1 = (Short)( e1 >> 3 );
c2 = (Short)( e2 >> 3 );
f1 = (Byte) ( 0xFF >> ( e1 & 7 ) );
f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) );
if ( ras.gray_min_x > c1 )
ras.gray_min_x = (short)c1;
if ( ras.gray_max_x < c2 )
ras.gray_max_x = (short)c2;
target = ras.bTarget + ras.traceOfs + c1;
c2 -= c1;
if ( c2 > 0 )
{
target[0] |= f1;
/* memset() is slower than the following code on many platforms. */
/* This is due to the fact that, in the vast majority of cases, */
/* the span length in bytes is relatively small. */
c2--;
while ( c2 > 0 )
{
*(++target) = 0xFF;
c2--;
}
target[1] |= f2;
}
else
*target |= ( f1 & f2 );
}
}
static void
Vertical_Sweep_Drop( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
Long e1, e2, pxl;
Short c1, f1;
/* Drop-out control */
/* e2 x2 x1 e1 */
/* */
/* ^ | */
/* | | */
/* +-------------+---------------------+------------+ */
/* | | */
/* | v */
/* */
/* pixel contour contour pixel */
/* center center */
/* drop-out mode scan conversion rules (as defined in OpenType) */
/* --------------------------------------------------------------- */
/* 0 1, 2, 3 */
/* 1 1, 2, 4 */
/* 2 1, 2 */
/* 3 same as mode 2 */
/* 4 1, 2, 5 */
/* 5 1, 2, 6 */
/* 6, 7 same as mode 2 */
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
pxl = e1;
if ( e1 > e2 )
{
Int dropOutControl = left->flags & 7;
if ( e1 == e2 + ras.precision )
{
switch ( dropOutControl )
{
case 0: /* simple drop-outs including stubs */
pxl = e2;
break;
case 4: /* smart drop-outs including stubs */
pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
case 1: /* simple drop-outs excluding stubs */
case 5: /* smart drop-outs excluding stubs */
/* Drop-out Control Rules #4 and #6 */
/* The specification neither provides an exact definition */
/* of a `stub' nor gives exact rules to exclude them. */
/* */
/* Here the constraints we use to recognize a stub. */
/* */
/* upper stub: */
/* */
/* - P_Left and P_Right are in the same contour */
/* - P_Right is the successor of P_Left in that contour */
/* - y is the top of P_Left and P_Right */
/* */
/* lower stub: */
/* */
/* - P_Left and P_Right are in the same contour */
/* - P_Left is the successor of P_Right in that contour */
/* - y is the bottom of P_Left */
/* */
/* We draw a stub if the following constraints are met. */
/* */
/* - for an upper or lower stub, there is top or bottom */
/* overshoot, respectively */
/* - the covered interval is greater or equal to a half */
/* pixel */
/* upper stub test */
if ( left->next == right &&
left->height <= 0 &&
!( left->flags & Overshoot_Top &&
x2 - x1 >= ras.precision_half ) )
return;
/* lower stub test */
if ( right->next == left &&
left->start == y &&
!( left->flags & Overshoot_Bottom &&
x2 - x1 >= ras.precision_half ) )
return;
if ( dropOutControl == 1 )
pxl = e2;
else
pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
default: /* modes 2, 3, 6, 7 */
return; /* no drop-out control */
}
/* undocumented but confirmed: If the drop-out would result in a */
/* pixel outside of the bounding box, use the pixel inside of the */
/* bounding box instead */
if ( pxl < 0 )
pxl = e1;
else if ( TRUNC( pxl ) >= ras.bWidth )
pxl = e2;
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
e1 = TRUNC( e1 );
c1 = (Short)( e1 >> 3 );
f1 = (Short)( e1 & 7 );
if ( e1 >= 0 && e1 < ras.bWidth &&
ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) )
return;
}
else
return;
}
e1 = TRUNC( pxl );
if ( e1 >= 0 && e1 < ras.bWidth )
{
c1 = (Short)( e1 >> 3 );
f1 = (Short)( e1 & 7 );
if ( ras.gray_min_x > c1 )
ras.gray_min_x = c1;
if ( ras.gray_max_x < c1 )
ras.gray_max_x = c1;
ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 );
}
}
static void
Vertical_Sweep_Step( RAS_ARG )
{
ras.traceOfs += ras.traceIncr;
}
/***********************************************************************/
/* */
/* Horizontal Sweep Procedure Set */
/* */
/* These four routines are used during the horizontal black/white */
/* sweep phase by the generic Draw_Sweep() function. */
/* */
/***********************************************************************/
static void
Horizontal_Sweep_Init( RAS_ARGS Short* min,
Short* max )
{
/* nothing, really */
FT_UNUSED_RASTER;
FT_UNUSED( min );
FT_UNUSED( max );
}
static void
Horizontal_Sweep_Span( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
{
Long e1, e2;
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 == e2 )
{
Byte f1;
PByte bits;
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
e1 = TRUNC( e1 );
if ( e1 >= 0 && e1 < ras.target.rows )
{
PByte p;
p = bits - e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
p += ( ras.target.rows - 1 ) * ras.target.pitch;
p[0] |= f1;
}
}
}
}
static void
Horizontal_Sweep_Drop( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
Long e1, e2, pxl;
PByte bits;
Byte f1;
/* During the horizontal sweep, we only take care of drop-outs */
/* e1 + <-- pixel center */
/* | */
/* x1 ---+--> <-- contour */
/* | */
/* | */
/* x2 <--+--- <-- contour */
/* | */
/* | */
/* e2 + <-- pixel center */
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
pxl = e1;
if ( e1 > e2 )
{
Int dropOutControl = left->flags & 7;
if ( e1 == e2 + ras.precision )
{
switch ( dropOutControl )
{
case 0: /* simple drop-outs including stubs */
pxl = e2;
break;
case 4: /* smart drop-outs including stubs */
pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
case 1: /* simple drop-outs excluding stubs */
case 5: /* smart drop-outs excluding stubs */
/* see Vertical_Sweep_Drop for details */
/* rightmost stub test */
if ( left->next == right &&
left->height <= 0 &&
!( left->flags & Overshoot_Top &&
x2 - x1 >= ras.precision_half ) )
return;
/* leftmost stub test */
if ( right->next == left &&
left->start == y &&
!( left->flags & Overshoot_Bottom &&
x2 - x1 >= ras.precision_half ) )
return;
if ( dropOutControl == 1 )
pxl = e2;
else
pxl = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
default: /* modes 2, 3, 6, 7 */
return; /* no drop-out control */
}
/* undocumented but confirmed: If the drop-out would result in a */
/* pixel outside of the bounding box, use the pixel inside of the */
/* bounding box instead */
if ( pxl < 0 )
pxl = e1;
else if ( TRUNC( pxl ) >= ras.target.rows )
pxl = e2;
/* check that the other pixel isn't set */
e1 = pxl == e1 ? e2 : e1;
e1 = TRUNC( e1 );
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
if ( e1 >= 0 &&
e1 < ras.target.rows &&
*bits & f1 )
return;
}
else
return;
}
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
e1 = TRUNC( pxl );
if ( e1 >= 0 && e1 < ras.target.rows )
{
bits -= e1 * ras.target.pitch;
if ( ras.target.pitch > 0 )
bits += ( ras.target.rows - 1 ) * ras.target.pitch;
bits[0] |= f1;
}
}
static void
Horizontal_Sweep_Step( RAS_ARG )
{
/* Nothing, really */
FT_UNUSED_RASTER;
}
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
/*************************************************************************/
/* */
/* Vertical Gray Sweep Procedure Set */
/* */
/* These two routines are used during the vertical gray-levels sweep */
/* phase by the generic Draw_Sweep() function. */
/* */
/* NOTES */
/* */
/* - The target pixmap's width *must* be a multiple of 4. */
/* */
/* - You have to use the function Vertical_Sweep_Span() for the gray */
/* span call. */
/* */
/*************************************************************************/
static void
Vertical_Gray_Sweep_Init( RAS_ARGS Short* min,
Short* max )
{
Long pitch, byte_len;
*min = *min & -2;
*max = ( *max + 3 ) & -2;
ras.traceOfs = 0;
pitch = ras.target.pitch;
byte_len = -pitch;
ras.traceIncr = (Short)byte_len;
ras.traceG = ( *min / 2 ) * byte_len;
if ( pitch > 0 )
{
ras.traceG += ( ras.target.rows - 1 ) * pitch;
byte_len = -byte_len;
}
ras.gray_min_x = (Short)byte_len;
ras.gray_max_x = -(Short)byte_len;
}
static void
Vertical_Gray_Sweep_Step( RAS_ARG )
{
short* count = (short*)count_table;
Byte* grays;
ras.traceOfs += ras.gray_width;
if ( ras.traceOfs > ras.gray_width )
{
PByte pix;
pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
grays = ras.grays;
if ( ras.gray_max_x >= 0 )
{
Long last_pixel = ras.target.width - 1;
Int last_cell = last_pixel >> 2;
Int last_bit = last_pixel & 3;
Bool over = 0;
Int c1, c2;
PByte bit, bit2;
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
ras.gray_max_x = last_cell - 1;
over = 1;
}
if ( ras.gray_min_x < 0 )
ras.gray_min_x = 0;
bit = ras.bTarget + ras.gray_min_x;
bit2 = bit + ras.gray_width;
c1 = ras.gray_max_x - ras.gray_min_x;
while ( c1 >= 0 )
{
c2 = count[*bit] + count[*bit2];
if ( c2 )
{
pix[0] = grays[(c2 >> 12) & 0x000F];
pix[1] = grays[(c2 >> 8 ) & 0x000F];
pix[2] = grays[(c2 >> 4 ) & 0x000F];
pix[3] = grays[ c2 & 0x000F];
*bit = 0;
*bit2 = 0;
}
bit++;
bit2++;
pix += 4;
c1--;
}
if ( over )
{
c2 = count[*bit] + count[*bit2];
if ( c2 )
{
switch ( last_bit )
{
case 2:
pix[2] = grays[(c2 >> 4 ) & 0x000F];
case 1:
pix[1] = grays[(c2 >> 8 ) & 0x000F];
default:
pix[0] = grays[(c2 >> 12) & 0x000F];
}
*bit = 0;
*bit2 = 0;
}
}
}
ras.traceOfs = 0;
ras.traceG += ras.traceIncr;
ras.gray_min_x = 32000;
ras.gray_max_x = -32000;
}
}
static void
Horizontal_Gray_Sweep_Span( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
/* nothing, really */
FT_UNUSED_RASTER;
FT_UNUSED( y );
FT_UNUSED( x1 );
FT_UNUSED( x2 );
FT_UNUSED( left );
FT_UNUSED( right );
}
static void
Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y,
FT_F26Dot6 x1,
FT_F26Dot6 x2,
PProfile left,
PProfile right )
{
Long e1, e2;
PByte pixel;
/* During the horizontal sweep, we only take care of drop-outs */
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 > e2 )
{
Int dropOutControl = left->flags & 7;
if ( e1 == e2 + ras.precision )
{
switch ( dropOutControl )
{
case 0: /* simple drop-outs including stubs */
e1 = e2;
break;
case 4: /* smart drop-outs including stubs */
e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
case 1: /* simple drop-outs excluding stubs */
case 5: /* smart drop-outs excluding stubs */
/* see Vertical_Sweep_Drop for details */
/* rightmost stub test */
if ( left->next == right && left->height <= 0 )
return;
/* leftmost stub test */
if ( right->next == left && left->start == y )
return;
if ( dropOutControl == 1 )
e1 = e2;
else
e1 = FLOOR( ( x1 + x2 - 1 ) / 2 + ras.precision_half );
break;
default: /* modes 2, 3, 6, 7 */
return; /* no drop-out control */
}
}
else
return;
}
if ( e1 >= 0 )
{
Byte color;
if ( x2 - x1 >= ras.precision_half )
color = ras.grays[2];
else
color = ras.grays[1];
e1 = TRUNC( e1 ) / 2;
if ( e1 < ras.target.rows )
{
pixel = ras.gTarget - e1 * ras.target.pitch + y / 2;
if ( ras.target.pitch > 0 )
pixel += ( ras.target.rows - 1 ) * ras.target.pitch;
if ( pixel[0] == ras.grays[0] )
pixel[0] = color;
}
}
}
#endif /* FT_RASTER_OPTION_ANTI_ALIASING */
/*************************************************************************/
/* */
/* Generic Sweep Drawing routine */
/* */
/*************************************************************************/
static Bool
Draw_Sweep( RAS_ARG )
{
Short y, y_change, y_height;
PProfile P, Q, P_Left, P_Right;
Short min_Y, max_Y, top, bottom, dropouts;
Long x1, x2, xs, e1, e2;
TProfileList waiting;
TProfileList draw_left, draw_right;
/* initialize empty linked lists */
Init_Linked( &waiting );
Init_Linked( &draw_left );
Init_Linked( &draw_right );
/* first, compute min and max Y */
P = ras.fProfile;
max_Y = (Short)TRUNC( ras.minY );
min_Y = (Short)TRUNC( ras.maxY );
while ( P )
{
Q = P->link;
bottom = (Short)P->start;
top = (Short)( P->start + P->height - 1 );
if ( min_Y > bottom )
min_Y = bottom;
if ( max_Y < top )
max_Y = top;
P->X = 0;
InsNew( &waiting, P );
P = Q;
}
/* check the Y-turns */
if ( ras.numTurns == 0 )
{
ras.error = FT_THROW( Invalid );
return FAILURE;
}
/* now initialize the sweep */
ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y );
/* then compute the distance of each profile from min_Y */
P = waiting;
while ( P )
{
P->countL = (UShort)( P->start - min_Y );
P = P->link;
}
/* let's go */
y = min_Y;
y_height = 0;
if ( ras.numTurns > 0 &&
ras.sizeBuff[-ras.numTurns] == min_Y )
ras.numTurns--;
while ( ras.numTurns > 0 )
{
/* check waiting list for new activations */
P = waiting;
while ( P )
{
Q = P->link;
P->countL -= y_height;
if ( P->countL == 0 )
{
DelOld( &waiting, P );
if ( P->flags & Flow_Up )
InsNew( &draw_left, P );
else
InsNew( &draw_right, P );
}
P = Q;
}
/* sort the drawing lists */
Sort( &draw_left );
Sort( &draw_right );
y_change = (Short)ras.sizeBuff[-ras.numTurns--];
y_height = (Short)( y_change - y );
while ( y < y_change )
{
/* let's trace */
dropouts = 0;
P_Left = draw_left;
P_Right = draw_right;
while ( P_Left )
{
x1 = P_Left ->X;
x2 = P_Right->X;
if ( x1 > x2 )
{
xs = x1;
x1 = x2;
x2 = xs;
}
e1 = FLOOR( x1 );
e2 = CEILING( x2 );
if ( x2 - x1 <= ras.precision &&
e1 != x1 && e2 != x2 )
{
if ( e1 > e2 || e2 == e1 + ras.precision )
{
Int dropOutControl = P_Left->flags & 7;
if ( dropOutControl != 2 )
{
/* a drop-out was detected */
P_Left ->X = x1;
P_Right->X = x2;
/* mark profile for drop-out processing */
P_Left->countL = 1;
dropouts++;
}
goto Skip_To_Next;
}
}
ras.Proc_Sweep_Span( RAS_VARS y, x1, x2, P_Left, P_Right );
Skip_To_Next:
P_Left = P_Left->link;
P_Right = P_Right->link;
}
/* handle drop-outs _after_ the span drawing -- */
/* drop-out processing has been moved out of the loop */
/* for performance tuning */
if ( dropouts > 0 )
goto Scan_DropOuts;
Next_Line:
ras.Proc_Sweep_Step( RAS_VAR );
y++;
if ( y < y_change )
{
Sort( &draw_left );
Sort( &draw_right );
}
}
/* now finalize the profiles that need it */
P = draw_left;
while ( P )
{
Q = P->link;
if ( P->height == 0 )
DelOld( &draw_left, P );
P = Q;
}
P = draw_right;
while ( P )
{
Q = P->link;
if ( P->height == 0 )
DelOld( &draw_right, P );
P = Q;
}
}
/* for gray-scaling, flush the bitmap scanline cache */
while ( y <= max_Y )
{
ras.Proc_Sweep_Step( RAS_VAR );
y++;
}
return SUCCESS;
Scan_DropOuts:
P_Left = draw_left;
P_Right = draw_right;
while ( P_Left )
{
if ( P_Left->countL )
{
P_Left->countL = 0;
#if 0
dropouts--; /* -- this is useful when debugging only */
#endif
ras.Proc_Sweep_Drop( RAS_VARS y,
P_Left->X,
P_Right->X,
P_Left,
P_Right );
}
P_Left = P_Left->link;
P_Right = P_Right->link;
}
goto Next_Line;
}
/*************************************************************************/
/* */
/* <Function> */
/* Render_Single_Pass */
/* */
/* <Description> */
/* Perform one sweep with sub-banding. */
/* */
/* <Input> */
/* flipped :: If set, flip the direction of the outline. */
/* */
/* <Return> */
/* Renderer error code. */
/* */
static int
Render_Single_Pass( RAS_ARGS Bool flipped )
{
Short i, j, k;
while ( ras.band_top >= 0 )
{
ras.maxY = (Long)ras.band_stack[ras.band_top].y_max * ras.precision;
ras.minY = (Long)ras.band_stack[ras.band_top].y_min * ras.precision;
ras.top = ras.buff;
ras.error = Raster_Err_None;
if ( Convert_Glyph( RAS_VARS flipped ) )
{
if ( ras.error != Raster_Err_Overflow )
return FAILURE;
ras.error = Raster_Err_None;
/* sub-banding */
#ifdef DEBUG_RASTER
ClearBand( RAS_VARS TRUNC( ras.minY ), TRUNC( ras.maxY ) );
#endif
i = ras.band_stack[ras.band_top].y_min;
j = ras.band_stack[ras.band_top].y_max;
k = (Short)( ( i + j ) / 2 );
if ( ras.band_top >= 7 || k < i )
{
ras.band_top = 0;
ras.error = FT_THROW( Invalid );
return ras.error;
}
ras.band_stack[ras.band_top + 1].y_min = k;
ras.band_stack[ras.band_top + 1].y_max = j;
ras.band_stack[ras.band_top].y_max = (Short)( k - 1 );
ras.band_top++;
}
else
{
if ( ras.fProfile )
if ( Draw_Sweep( RAS_VAR ) )
return ras.error;
ras.band_top--;
}
}
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Render_Glyph */
/* */
/* <Description> */
/* Render a glyph in a bitmap. Sub-banding if needed. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
Render_Glyph( RAS_ARG )
{
FT_Error error;
Set_High_Precision( RAS_VARS ras.outline.flags &
FT_OUTLINE_HIGH_PRECISION );
ras.scale_shift = ras.precision_shift;
if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
ras.dropOutControl = 2;
else
{
if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
ras.dropOutControl = 4;
else
ras.dropOutControl = 0;
if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
ras.dropOutControl += 1;
}
ras.second_pass = (FT_Byte)( !( ras.outline.flags &
FT_OUTLINE_SINGLE_PASS ) );
/* Vertical Sweep */
ras.Proc_Sweep_Init = Vertical_Sweep_Init;
ras.Proc_Sweep_Span = Vertical_Sweep_Span;
ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
ras.Proc_Sweep_Step = Vertical_Sweep_Step;
ras.band_top = 0;
ras.band_stack[0].y_min = 0;
ras.band_stack[0].y_max = (short)( ras.target.rows - 1 );
ras.bWidth = (unsigned short)ras.target.width;
ras.bTarget = (Byte*)ras.target.buffer;
if ( ( error = Render_Single_Pass( RAS_VARS 0 ) ) != 0 )
return error;
/* Horizontal Sweep */
if ( ras.second_pass && ras.dropOutControl != 2 )
{
ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
ras.Proc_Sweep_Span = Horizontal_Sweep_Span;
ras.Proc_Sweep_Drop = Horizontal_Sweep_Drop;
ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
ras.band_top = 0;
ras.band_stack[0].y_min = 0;
ras.band_stack[0].y_max = (short)( ras.target.width - 1 );
if ( ( error = Render_Single_Pass( RAS_VARS 1 ) ) != 0 )
return error;
}
return Raster_Err_None;
}
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
/*************************************************************************/
/* */
/* <Function> */
/* Render_Gray_Glyph */
/* */
/* <Description> */
/* Render a glyph with grayscaling. Sub-banding if needed. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
Render_Gray_Glyph( RAS_ARG )
{
Long pixel_width;
FT_Error error;
Set_High_Precision( RAS_VARS ras.outline.flags &
FT_OUTLINE_HIGH_PRECISION );
ras.scale_shift = ras.precision_shift + 1;
if ( ras.outline.flags & FT_OUTLINE_IGNORE_DROPOUTS )
ras.dropOutControl = 2;
else
{
if ( ras.outline.flags & FT_OUTLINE_SMART_DROPOUTS )
ras.dropOutControl = 4;
else
ras.dropOutControl = 0;
if ( !( ras.outline.flags & FT_OUTLINE_INCLUDE_STUBS ) )
ras.dropOutControl += 1;
}
ras.second_pass = !( ras.outline.flags & FT_OUTLINE_SINGLE_PASS );
/* Vertical Sweep */
ras.band_top = 0;
ras.band_stack[0].y_min = 0;
ras.band_stack[0].y_max = 2 * ras.target.rows - 1;
ras.bWidth = ras.gray_width;
pixel_width = 2 * ( ( ras.target.width + 3 ) >> 2 );
if ( ras.bWidth > pixel_width )
ras.bWidth = pixel_width;
ras.bWidth = ras.bWidth * 8;
ras.bTarget = (Byte*)ras.gray_lines;
ras.gTarget = (Byte*)ras.target.buffer;
ras.Proc_Sweep_Init = Vertical_Gray_Sweep_Init;
ras.Proc_Sweep_Span = Vertical_Sweep_Span;
ras.Proc_Sweep_Drop = Vertical_Sweep_Drop;
ras.Proc_Sweep_Step = Vertical_Gray_Sweep_Step;
error = Render_Single_Pass( RAS_VARS 0 );
if ( error )
return error;
/* Horizontal Sweep */
if ( ras.second_pass && ras.dropOutControl != 2 )
{
ras.Proc_Sweep_Init = Horizontal_Sweep_Init;
ras.Proc_Sweep_Span = Horizontal_Gray_Sweep_Span;
ras.Proc_Sweep_Drop = Horizontal_Gray_Sweep_Drop;
ras.Proc_Sweep_Step = Horizontal_Sweep_Step;
ras.band_top = 0;
ras.band_stack[0].y_min = 0;
ras.band_stack[0].y_max = ras.target.width * 2 - 1;
error = Render_Single_Pass( RAS_VARS 1 );
if ( error )
return error;
}
return Raster_Err_None;
}
#else /* !FT_RASTER_OPTION_ANTI_ALIASING */
FT_LOCAL_DEF( FT_Error )
Render_Gray_Glyph( RAS_ARG )
{
FT_UNUSED_RASTER;
return FT_THROW( Unsupported );
}
#endif /* !FT_RASTER_OPTION_ANTI_ALIASING */
static void
ft_black_init( black_PRaster raster )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
FT_UInt n;
/* set default 5-levels gray palette */
for ( n = 0; n < 5; n++ )
raster->grays[n] = n * 255 / 4;
raster->gray_width = RASTER_GRAY_LINES / 2;
#else
FT_UNUSED( raster );
#endif
}
/**** RASTER OBJECT CREATION: In standalone mode, we simply use *****/
/**** a static object. *****/
#ifdef _STANDALONE_
static int
ft_black_new( void* memory,
FT_Raster *araster )
{
static black_TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
ft_black_init( &the_raster );
return 0;
}
static void
ft_black_done( FT_Raster raster )
{
/* nothing */
FT_UNUSED( raster );
}
#else /* !_STANDALONE_ */
static int
ft_black_new( FT_Memory memory,
black_PRaster *araster )
{
FT_Error error = FT_Err_Ok;
black_PRaster raster = NULL;
*araster = 0;
if ( !FT_NEW( raster ) )
{
raster->memory = memory;
ft_black_init( raster );
*araster = raster;
}
return error;
}
static void
ft_black_done( black_PRaster raster )
{
FT_Memory memory = (FT_Memory)raster->memory;
FT_FREE( raster );
}
#endif /* !_STANDALONE_ */
static void
ft_black_reset( black_PRaster raster,
char* pool_base,
long pool_size )
{
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 )
{
black_PWorker worker = (black_PWorker)pool_base;
raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
raster->buffer_size = (long)( pool_base + pool_size -
(char*)raster->buffer );
raster->worker = worker;
}
else
{
raster->buffer = NULL;
raster->buffer_size = 0;
raster->worker = NULL;
}
}
}
static void
ft_black_set_mode( black_PRaster raster,
unsigned long mode,
const char* palette )
{
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) )
{
/* set 5-levels gray palette */
raster->grays[0] = palette[0];
raster->grays[1] = palette[1];
raster->grays[2] = palette[2];
raster->grays[3] = palette[3];
raster->grays[4] = palette[4];
}
#else
FT_UNUSED( raster );
FT_UNUSED( mode );
FT_UNUSED( palette );
#endif
}
static int
ft_black_render( black_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
black_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return FT_THROW( Not_Ini );
if ( !outline )
return FT_THROW( Invalid );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return Raster_Err_None;
if ( !outline->contours || !outline->points )
return FT_THROW( Invalid );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid );
worker = raster->worker;
/* this version of the raster does not support direct rendering, sorry */
if ( params->flags & FT_RASTER_FLAG_DIRECT )
return FT_THROW( Unsupported );
if ( !target_map )
return FT_THROW( Invalid );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return Raster_Err_None;
if ( !target_map->buffer )
return FT_THROW( Invalid );
ras.outline = *outline;
ras.target = *target_map;
worker->buff = (PLong) raster->buffer;
worker->sizeBuff = worker->buff +
raster->buffer_size / sizeof ( Long );
#ifdef FT_RASTER_OPTION_ANTI_ALIASING
worker->grays = raster->grays;
worker->gray_width = raster->gray_width;
FT_MEM_ZERO( worker->gray_lines, worker->gray_width * 2 );
#endif
return ( params->flags & FT_RASTER_FLAG_AA )
? Render_Gray_Glyph( RAS_VAR )
: Render_Glyph( RAS_VAR );
}
FT_DEFINE_RASTER_FUNCS( ft_standard_raster,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Raster_New_Func) ft_black_new,
(FT_Raster_Reset_Func) ft_black_reset,
(FT_Raster_Set_Mode_Func)ft_black_set_mode,
(FT_Raster_Render_Func) ft_black_render,
(FT_Raster_Done_Func) ft_black_done
)
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/ftraster.c | C | apache-2.0 | 120,307 |
/***************************************************************************/
/* */
/* ftraster.h */
/* */
/* The FreeType glyph rasterizer (specification). */
/* */
/* Copyright 1996-2001 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 __FTRASTER_H__
#define __FTRASTER_H__
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_IMAGE_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Uncomment the following line if you are using ftraster.c as a */
/* standalone module, fully independent of FreeType. */
/* */
/* #define _STANDALONE_ */
FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster;
FT_END_HEADER
#endif /* __FTRASTER_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/ftraster.h | C | apache-2.0 | 1,925 |
/***************************************************************************/
/* */
/* ftrend1.c */
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
/* Copyright 1996-2003, 2005, 2006, 2011, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftrend1.h"
#include "ftraster.h"
#include "rastpic.h"
#include "rasterrs.h"
/* initialize renderer -- init its raster */
static FT_Error
ft_raster1_init( FT_Renderer render )
{
FT_Library library = FT_MODULE_LIBRARY( render );
render->clazz->raster_class->raster_reset( render->raster,
library->raster_pool,
library->raster_pool_size );
return FT_Err_Ok;
}
/* set render-specific mode */
static FT_Error
ft_raster1_set_mode( FT_Renderer render,
FT_ULong mode_tag,
FT_Pointer data )
{
/* we simply pass it to the raster */
return render->clazz->raster_class->raster_set_mode( render->raster,
mode_tag,
data );
}
/* transform a given glyph image */
static FT_Error
ft_raster1_transform( FT_Renderer render,
FT_GlyphSlot slot,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
return error;
}
/* return the glyph's control box */
static void
ft_raster1_get_cbox( FT_Renderer render,
FT_GlyphSlot slot,
FT_BBox* cbox )
{
FT_MEM_ZERO( cbox, sizeof ( *cbox ) );
if ( slot->format == render->glyph_format )
FT_Outline_Get_CBox( &slot->outline, cbox );
}
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_raster1_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
FT_Error error;
FT_Outline* outline;
FT_BBox cbox;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
FT_Memory memory;
FT_Raster_Params params;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* check rendering mode */
#ifndef FT_CONFIG_OPTION_PIC
if ( mode != FT_RENDER_MODE_MONO )
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz == &ft_raster1_renderer_class )
return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz == &ft_raster5_renderer_class )
return FT_THROW( Cannot_Render_Glyph );
}
#else /* FT_CONFIG_OPTION_PIC */
/* When PIC is enabled, we cannot get to the class object */
/* so instead we check the final character in the class name */
/* ("raster5" or "raster1"). Yes this is a hack. */
/* The "correct" thing to do is have different render function */
/* for each of the classes. */
if ( mode != FT_RENDER_MODE_MONO )
{
/* raster1 is only capable of producing monochrome bitmaps */
if ( render->clazz->root.module_name[6] == '1' )
return FT_THROW( Cannot_Render_Glyph );
}
else
{
/* raster5 is only capable of producing 5-gray-levels bitmaps */
if ( render->clazz->root.module_name[6] == '5' )
return FT_THROW( Cannot_Render_Glyph );
}
#endif /* FT_CONFIG_OPTION_PIC */
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
/* undocumented but confirmed: bbox values get rounded */
#if 1
cbox.xMin = FT_PIX_ROUND( cbox.xMin );
cbox.yMin = FT_PIX_ROUND( cbox.yMin );
cbox.xMax = FT_PIX_ROUND( cbox.xMax );
cbox.yMax = FT_PIX_ROUND( cbox.yMax );
#else
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
#endif
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
bitmap = &slot->bitmap;
memory = render->root.memory;
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
/* allocate new one, depends on pixel format */
if ( !( mode & FT_RENDER_MODE_MONO ) )
{
/* we pad to 32 bits, only for backwards compatibility with FT 1.x */
pitch = FT_PAD_CEIL( width, 4 );
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
}
else
{
pitch = ( ( width + 15 ) >> 4 ) << 1;
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
}
bitmap->width = width;
bitmap->rows = height;
bitmap->pitch = pitch;
if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) )
goto Exit;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
/* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = 0;
if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY )
params.flags |= FT_RASTER_FLAG_AA;
/* render outline into the bitmap */
error = render->raster_render( render->raster, ¶ms );
FT_Outline_Translate( outline, cbox.xMin, cbox.yMin );
if ( error )
goto Exit;
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 );
slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 );
Exit:
return error;
}
FT_DEFINE_RENDERER( ft_raster1_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
"raster1",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_raster1_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_raster1_render,
(FT_Renderer_TransformFunc)ft_raster1_transform,
(FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox,
(FT_Renderer_SetModeFunc) ft_raster1_set_mode,
(FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET
)
/* This renderer is _NOT_ part of the default modules; you will need */
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
/* */
FT_DEFINE_RENDERER( ft_raster5_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
"raster5",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_raster1_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_raster1_render,
(FT_Renderer_TransformFunc)ft_raster1_transform,
(FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox,
(FT_Renderer_SetModeFunc) ft_raster1_set_mode,
(FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET
)
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/ftrend1.c | C | apache-2.0 | 9,240 |
/***************************************************************************/
/* */
/* ftrend1.h */
/* */
/* The FreeType glyph rasterizer interface (specification). */
/* */
/* Copyright 1996-2001 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 __FTREND1_H__
#define __FTREND1_H__
#include <ft2build.h>
#include FT_RENDER_H
FT_BEGIN_HEADER
FT_DECLARE_RENDERER( ft_raster1_renderer_class )
/* this renderer is _NOT_ part of the default modules, you'll need */
/* to register it by hand in your application. It should only be */
/* used for backwards-compatibility with FT 1.x anyway. */
/* */
FT_DECLARE_RENDERER( ft_raster5_renderer_class )
FT_END_HEADER
#endif /* __FTREND1_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/ftrend1.h | C | apache-2.0 | 1,806 |
#
# FreeType 2 renderer module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += RASTER_MODULE
define RASTER_MODULE
$(OPEN_DRIVER) FT_Renderer_Class, ft_raster1_renderer_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)raster $(ECHO_DRIVER_DESC)monochrome bitmap renderer$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/raster/module.mk | Makefile | apache-2.0 | 668 |
/***************************************************************************/
/* */
/* raster.c */
/* */
/* FreeType monochrome rasterer module component (body only). */
/* */
/* Copyright 1996-2001 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "rastpic.c"
#include "ftraster.c"
#include "ftrend1.c"
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/raster.c | C | apache-2.0 | 1,386 |
/***************************************************************************/
/* */
/* rasterrs.h */
/* */
/* monochrome renderer error codes (specification only). */
/* */
/* Copyright 2001, 2012 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the monochrome renderer error enumeration */
/* constants. */
/* */
/*************************************************************************/
#ifndef __RASTERRS_H__
#define __RASTERRS_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Raster_Err_
#define FT_ERR_BASE FT_Mod_Err_Raster
#include FT_ERRORS_H
#endif /* __RASTERRS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/rasterrs.h | C | apache-2.0 | 1,979 |
/***************************************************************************/
/* */
/* rastpic.c */
/* */
/* The FreeType position independent code services for raster module. */
/* */
/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "rastpic.h"
#include "rasterrs.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftraster.c */
void
FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs );
void
ft_raster1_renderer_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->raster )
{
RasterPIC* container = (RasterPIC*)pic_container->raster;
if ( --container->ref_count )
return;
FT_FREE( container );
pic_container->raster = NULL;
}
}
FT_Error
ft_raster1_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
RasterPIC* container = NULL;
FT_Memory memory = library->memory;
/* since this function also serves raster5 renderer, */
/* it implements reference counting */
if ( pic_container->raster )
{
((RasterPIC*)pic_container->raster)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->raster = container;
container->ref_count = 1;
/* initialize pointer table - */
/* this is how the module usually expects this data */
FT_Init_Class_ft_standard_raster( &container->ft_standard_raster );
return error;
}
/* re-route these init and free functions to the above functions */
FT_Error
ft_raster5_renderer_class_pic_init( FT_Library library )
{
return ft_raster1_renderer_class_pic_init( library );
}
void
ft_raster5_renderer_class_pic_free( FT_Library library )
{
ft_raster1_renderer_class_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/rastpic.c | C | apache-2.0 | 3,365 |
/***************************************************************************/
/* */
/* rastpic.h */
/* */
/* The FreeType position independent code services for raster module. */
/* */
/* Copyright 2009 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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 __RASTPIC_H__
#define __RASTPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define FT_STANDARD_RASTER_GET ft_standard_raster
#else /* FT_CONFIG_OPTION_PIC */
typedef struct RasterPIC_
{
int ref_count;
FT_Raster_Funcs ft_standard_raster;
} RasterPIC;
#define GET_PIC( lib ) \
( (RasterPIC*)( (lib)->pic_container.raster ) )
#define FT_STANDARD_RASTER_GET ( GET_PIC( library )->ft_standard_raster )
/* see rastpic.c for the implementation */
void
ft_raster1_renderer_class_pic_free( FT_Library library );
void
ft_raster5_renderer_class_pic_free( FT_Library library );
FT_Error
ft_raster1_renderer_class_pic_init( FT_Library library );
FT_Error
ft_raster5_renderer_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __RASTPIC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/raster/rastpic.h | C | apache-2.0 | 2,203 |
#
# FreeType 2 renderer module build rules
#
# Copyright 1996-2000, 2001, 2003, 2008, 2009, 2011 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.
# raster driver directory
#
RASTER_DIR := $(SRC_DIR)/raster
# compilation flags for the driver
#
RASTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(RASTER_DIR))
# raster driver sources (i.e., C files)
#
RASTER_DRV_SRC := $(RASTER_DIR)/ftraster.c \
$(RASTER_DIR)/ftrend1.c \
$(RASTER_DIR)/rastpic.c
# raster driver headers
#
RASTER_DRV_H := $(RASTER_DRV_SRC:%.c=%.h) \
$(RASTER_DIR)/rasterrs.h
# raster driver object(s)
#
# RASTER_DRV_OBJ_M is used during `multi' builds.
# RASTER_DRV_OBJ_S is used during `single' builds.
#
RASTER_DRV_OBJ_M := $(RASTER_DRV_SRC:$(RASTER_DIR)/%.c=$(OBJ_DIR)/%.$O)
RASTER_DRV_OBJ_S := $(OBJ_DIR)/raster.$O
# raster driver source file for single build
#
RASTER_DRV_SRC_S := $(RASTER_DIR)/raster.c
# raster driver - single object
#
$(RASTER_DRV_OBJ_S): $(RASTER_DRV_SRC_S) $(RASTER_DRV_SRC) \
$(FREETYPE_H) $(RASTER_DRV_H)
$(RASTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(RASTER_DRV_SRC_S))
# raster driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(RASTER_DIR)/%.c $(FREETYPE_H) $(RASTER_DRV_H)
$(RASTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(RASTER_DRV_OBJ_S)
DRV_OBJS_M += $(RASTER_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/raster/rules.mk | Makefile | apache-2.0 | 1,750 |
#
# FreeType 2 SFNT module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += SFNT_MODULE
define SFNT_MODULE
$(OPEN_DRIVER) FT_Module_Class, sfnt_module_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)sfnt $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/module.mk | Makefile | apache-2.0 | 669 |
/***************************************************************************/
/* */
/* pngshim.c */
/* */
/* PNG Bitmap glyph support. */
/* */
/* Copyright 2013 by Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_CONFIG_STANDARD_LIBRARY_H
#ifdef FT_CONFIG_OPTION_USE_PNG
/* We always include <stjmp.h>, so make libpng shut up! */
#define PNG_SKIP_SETJMP_CHECK 1
#include <png.h>
#include "pngshim.h"
#include "sferrors.h"
/* This code is freely based on cairo-png.c. There's so many ways */
/* to call libpng, and the way cairo does it is defacto standard. */
static int
multiply_alpha( int alpha,
int color )
{
int temp = ( alpha * color ) + 0x80;
return ( temp + ( temp >> 8 ) ) >> 8;
}
/* Premultiplies data and converts RGBA bytes => native endian. */
static void
premultiply_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int alpha = base[3];
if ( alpha == 0 )
base[0] = base[1] = base[2] = base[3] = 0;
else
{
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
if ( alpha != 0xFF )
{
red = multiply_alpha( alpha, red );
green = multiply_alpha( alpha, green );
blue = multiply_alpha( alpha, blue );
}
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = alpha;
}
}
}
/* Converts RGBx bytes to BGRA. */
static void
convert_bytes_to_data( png_structp png,
png_row_infop row_info,
png_bytep data )
{
unsigned int i;
FT_UNUSED( png );
for ( i = 0; i < row_info->rowbytes; i += 4 )
{
unsigned char* base = &data[i];
unsigned int red = base[0];
unsigned int green = base[1];
unsigned int blue = base[2];
base[0] = blue;
base[1] = green;
base[2] = red;
base[3] = 0xFF;
}
}
/* Use error callback to avoid png writing to stderr. */
static void
error_callback( png_structp png,
png_const_charp error_msg )
{
FT_Error* error = (FT_Error*)png_get_error_ptr( png );
FT_UNUSED( error_msg );
*error = FT_THROW( Out_Of_Memory );
#ifdef PNG_SETJMP_SUPPORTED
longjmp( png_jmpbuf( png ), 1 );
#endif
/* if we get here, then we have no choice but to abort ... */
}
/* Use warning callback to avoid png writing to stderr. */
static void
warning_callback( png_structp png,
png_const_charp error_msg )
{
FT_UNUSED( png );
FT_UNUSED( error_msg );
/* Just ignore warnings. */
}
static void
read_data_from_FT_Stream( png_structp png,
png_bytep data,
png_size_t length )
{
FT_Error error;
png_voidp p = png_get_io_ptr( png );
FT_Stream stream = (FT_Stream)p;
if ( FT_FRAME_ENTER( length ) )
{
FT_Error* e = (FT_Error*)png_get_error_ptr( png );
*e = FT_THROW( Invalid_Stream_Read );
png_error( png, NULL );
return;
}
memcpy( data, stream->cursor, length );
FT_FRAME_EXIT();
}
FT_LOCAL_DEF( FT_Error )
Load_SBit_Png( FT_GlyphSlot slot,
FT_Int x_offset,
FT_Int y_offset,
FT_Int pix_bits,
TT_SBit_Metrics metrics,
FT_Memory memory,
FT_Byte* data,
FT_UInt png_len,
FT_Bool populate_map_and_metrics )
{
FT_Bitmap *map = &slot->bitmap;
FT_Error error = FT_Err_Ok;
FT_StreamRec stream;
png_structp png;
png_infop info;
png_uint_32 imgWidth, imgHeight;
int bitdepth, color_type, interlace;
FT_Int i;
png_byte* *rows = NULL; /* pacify compiler */
if ( x_offset < 0 ||
y_offset < 0 )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( !populate_map_and_metrics &&
( x_offset + metrics->width > map->width ||
y_offset + metrics->height > map->rows ||
pix_bits != 32 ||
map->pixel_mode != FT_PIXEL_MODE_BGRA ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_Stream_OpenMemory( &stream, data, png_len );
png = png_create_read_struct( PNG_LIBPNG_VER_STRING,
&error,
error_callback,
warning_callback );
if ( !png )
{
error = FT_THROW( Out_Of_Memory );
goto Exit;
}
info = png_create_info_struct( png );
if ( !info )
{
error = FT_THROW( Out_Of_Memory );
png_destroy_read_struct( &png, NULL, NULL );
goto Exit;
}
if ( ft_setjmp( png_jmpbuf( png ) ) )
{
error = FT_THROW( Invalid_File_Format );
goto DestroyExit;
}
png_set_read_fn( png, &stream, read_data_from_FT_Stream );
png_read_info( png, info );
png_get_IHDR( png, info,
&imgWidth, &imgHeight,
&bitdepth, &color_type, &interlace,
NULL, NULL );
if ( error ||
( !populate_map_and_metrics &&
( (FT_Int)imgWidth != metrics->width ||
(FT_Int)imgHeight != metrics->height ) ) )
goto DestroyExit;
if ( populate_map_and_metrics )
{
FT_Long size;
metrics->width = (FT_Int)imgWidth;
metrics->height = (FT_Int)imgHeight;
map->width = metrics->width;
map->rows = metrics->height;
map->pixel_mode = FT_PIXEL_MODE_BGRA;
map->pitch = map->width * 4;
map->num_grays = 256;
size = map->rows * map->pitch;
error = ft_glyphslot_alloc_bitmap( slot, size );
if ( error )
goto DestroyExit;
}
/* convert palette/gray image to rgb */
if ( color_type == PNG_COLOR_TYPE_PALETTE )
png_set_palette_to_rgb( png );
/* expand gray bit depth if needed */
if ( color_type == PNG_COLOR_TYPE_GRAY )
{
#if PNG_LIBPNG_VER >= 10209
png_set_expand_gray_1_2_4_to_8( png );
#else
png_set_gray_1_2_4_to_8( png );
#endif
}
/* transform transparency to alpha */
if ( png_get_valid(png, info, PNG_INFO_tRNS ) )
png_set_tRNS_to_alpha( png );
if ( bitdepth == 16 )
png_set_strip_16( png );
if ( bitdepth < 8 )
png_set_packing( png );
/* convert grayscale to RGB */
if ( color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA )
png_set_gray_to_rgb( png );
if ( interlace != PNG_INTERLACE_NONE )
png_set_interlace_handling( png );
png_set_filler( png, 0xFF, PNG_FILLER_AFTER );
/* recheck header after setting EXPAND options */
png_read_update_info(png, info );
png_get_IHDR( png, info,
&imgWidth, &imgHeight,
&bitdepth, &color_type, &interlace,
NULL, NULL );
if ( bitdepth != 8 ||
!( color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA ) )
{
error = FT_THROW( Invalid_File_Format );
goto DestroyExit;
}
switch ( color_type )
{
default:
/* Shouldn't happen, but fall through. */
case PNG_COLOR_TYPE_RGB_ALPHA:
png_set_read_user_transform_fn( png, premultiply_data );
break;
case PNG_COLOR_TYPE_RGB:
/* Humm, this smells. Carry on though. */
png_set_read_user_transform_fn( png, convert_bytes_to_data );
break;
}
if ( FT_NEW_ARRAY( rows, imgHeight ) )
{
error = FT_THROW( Out_Of_Memory );
goto DestroyExit;
}
for ( i = 0; i < (FT_Int)imgHeight; i++ )
rows[i] = map->buffer + ( y_offset + i ) * map->pitch + x_offset * 4;
png_read_image( png, rows );
FT_FREE( rows );
png_read_end( png, info );
DestroyExit:
png_destroy_read_struct( &png, &info, NULL );
FT_Stream_Close( &stream );
Exit:
return error;
}
#endif /* FT_CONFIG_OPTION_USE_PNG */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/pngshim.c | C | apache-2.0 | 9,765 |
/***************************************************************************/
/* */
/* pngshim.h */
/* */
/* PNG Bitmap glyph support. */
/* */
/* Copyright 2013 by Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
/* 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 __PNGSHIM_H__
#define __PNGSHIM_H__
#include <ft2build.h>
#include "ttload.h"
FT_BEGIN_HEADER
#ifdef FT_CONFIG_OPTION_USE_PNG
FT_LOCAL( FT_Error )
Load_SBit_Png( FT_GlyphSlot slot,
FT_Int x_offset,
FT_Int y_offset,
FT_Int pix_bits,
TT_SBit_Metrics metrics,
FT_Memory memory,
FT_Byte* data,
FT_UInt png_len,
FT_Bool populate_map_and_metrics );
#endif
FT_END_HEADER
#endif /* __PNGSHIM_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/pngshim.h | C | apache-2.0 | 1,878 |
#
# FreeType 2 SFNT driver configuration rules
#
# Copyright 1996-2000, 2002-2007, 2009, 2011, 2013 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.
# SFNT driver directory
#
SFNT_DIR := $(SRC_DIR)/sfnt
# compilation flags for the driver
#
SFNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR))
# SFNT driver sources (i.e., C files)
#
SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c \
$(SFNT_DIR)/ttmtx.c \
$(SFNT_DIR)/ttcmap.c \
$(SFNT_DIR)/ttsbit.c \
$(SFNT_DIR)/ttpost.c \
$(SFNT_DIR)/ttkern.c \
$(SFNT_DIR)/ttbdf.c \
$(SFNT_DIR)/sfobjs.c \
$(SFNT_DIR)/sfdriver.c \
$(SFNT_DIR)/sfntpic.c \
$(SFNT_DIR)/pngshim.c
# SFNT driver headers
#
SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \
$(SFNT_DIR)/sferrors.h
# SFNT driver object(s)
#
# SFNT_DRV_OBJ_M is used during `multi' builds.
# SFNT_DRV_OBJ_S is used during `single' builds.
#
SFNT_DRV_OBJ_M := $(SFNT_DRV_SRC:$(SFNT_DIR)/%.c=$(OBJ_DIR)/%.$O)
SFNT_DRV_OBJ_S := $(OBJ_DIR)/sfnt.$O
# SFNT driver source file for single build
#
SFNT_DRV_SRC_S := $(SFNT_DIR)/sfnt.c
# SFNT driver - single object
#
$(SFNT_DRV_OBJ_S): $(SFNT_DRV_SRC_S) $(SFNT_DRV_SRC) \
$(FREETYPE_H) $(SFNT_DRV_H)
$(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SFNT_DRV_SRC_S))
# SFNT driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(SFNT_DIR)/%.c $(FREETYPE_H) $(SFNT_DRV_H)
$(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(SFNT_DRV_OBJ_S)
DRV_OBJS_M += $(SFNT_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/rules.mk | Makefile | apache-2.0 | 1,994 |
/***************************************************************************/
/* */
/* sfdriver.c */
/* */
/* High-level SFNT driver interface (body). */
/* */
/* Copyright 1996-2007, 2009-2014 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_OBJECTS_H
#include "sfdriver.h"
#include "ttload.h"
#include "sfobjs.h"
#include "sfntpic.h"
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#include "ttsbit.h"
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.h"
#endif
#ifdef TT_CONFIG_OPTION_BDF
#include "ttbdf.h"
#include FT_SERVICE_BDF_H
#endif
#include "ttcmap.h"
#include "ttkern.h"
#include "ttmtx.h"
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_TT_CMAP_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_sfdriver
/*
* SFNT TABLE SERVICE
*
*/
static void*
get_sfnt_table( TT_Face face,
FT_Sfnt_Tag tag )
{
void* table;
switch ( tag )
{
case ft_sfnt_head:
table = &face->header;
break;
case ft_sfnt_hhea:
table = &face->horizontal;
break;
case ft_sfnt_vhea:
table = face->vertical_info ? &face->vertical : 0;
break;
case ft_sfnt_os2:
table = face->os2.version == 0xFFFFU ? 0 : &face->os2;
break;
case ft_sfnt_post:
table = &face->postscript;
break;
case ft_sfnt_maxp:
table = &face->max_profile;
break;
case ft_sfnt_pclt:
table = face->pclt.Version ? &face->pclt : 0;
break;
default:
table = 0;
}
return table;
}
static FT_Error
sfnt_table_info( TT_Face face,
FT_UInt idx,
FT_ULong *tag,
FT_ULong *offset,
FT_ULong *length )
{
if ( !offset || !length )
return FT_THROW( Invalid_Argument );
if ( !tag )
*length = face->num_tables;
else
{
if ( idx >= face->num_tables )
return FT_THROW( Table_Missing );
*tag = face->dir_tables[idx].Tag;
*offset = face->dir_tables[idx].Offset;
*length = face->dir_tables[idx].Length;
}
return FT_Err_Ok;
}
FT_DEFINE_SERVICE_SFNT_TABLEREC(
sfnt_service_sfnt_table,
(FT_SFNT_TableLoadFunc)tt_face_load_any,
(FT_SFNT_TableGetFunc) get_sfnt_table,
(FT_SFNT_TableInfoFunc)sfnt_table_info )
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/*
* GLYPH DICT SERVICE
*
*/
static FT_Error
sfnt_get_glyph_name( TT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_String* gname;
FT_Error error;
error = tt_face_get_ps_name( face, glyph_index, &gname );
if ( !error )
FT_STRCPYN( buffer, gname, buffer_max );
return error;
}
static FT_UInt
sfnt_get_name_index( TT_Face face,
FT_String* glyph_name )
{
FT_Face root = &face->root;
FT_UInt i, max_gid = FT_UINT_MAX;
if ( root->num_glyphs < 0 )
return 0;
else if ( (FT_ULong)root->num_glyphs < FT_UINT_MAX )
max_gid = (FT_UInt)root->num_glyphs;
else
FT_TRACE0(( "Ignore glyph names for invalid GID 0x%08x - 0x%08x\n",
FT_UINT_MAX, root->num_glyphs ));
for ( i = 0; i < max_gid; i++ )
{
FT_String* gname;
FT_Error error = tt_face_get_ps_name( face, i, &gname );
if ( error )
continue;
if ( !ft_strcmp( glyph_name, gname ) )
return i;
}
return 0;
}
FT_DEFINE_SERVICE_GLYPHDICTREC(
sfnt_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name,
(FT_GlyphDict_NameIndexFunc)sfnt_get_name_index )
#endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/*
* POSTSCRIPT NAME SERVICE
*
*/
static const char*
sfnt_get_ps_name( TT_Face face )
{
FT_Int n, found_win, found_apple;
const char* result = NULL;
/* shouldn't happen, but just in case to avoid memory leaks */
if ( face->postscript_name )
return face->postscript_name;
/* scan the name table to see whether we have a Postscript name here, */
/* either in Macintosh or Windows platform encodings */
found_win = -1;
found_apple = -1;
for ( n = 0; n < face->num_names; n++ )
{
TT_NameEntryRec* name = face->name_table.names + n;
if ( name->nameID == 6 && name->stringLength > 0 )
{
if ( name->platformID == 3 &&
name->encodingID == 1 &&
name->languageID == 0x409 )
found_win = n;
if ( name->platformID == 1 &&
name->encodingID == 0 &&
name->languageID == 0 )
found_apple = n;
}
}
if ( found_win != -1 )
{
FT_Memory memory = face->root.memory;
TT_NameEntryRec* name = face->name_table.names + found_win;
FT_UInt len = name->stringLength / 2;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
if ( !FT_ALLOC( result, name->stringLength + 1 ) )
{
FT_Stream stream = face->name_table.stream;
FT_String* r = (FT_String*)result;
FT_Byte* p;
if ( FT_STREAM_SEEK( name->stringOffset ) ||
FT_FRAME_ENTER( name->stringLength ) )
{
FT_FREE( result );
name->stringLength = 0;
name->stringOffset = 0;
FT_FREE( name->string );
goto Exit;
}
p = (FT_Byte*)stream->cursor;
for ( ; len > 0; len--, p += 2 )
{
if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 )
*r++ = p[1];
}
*r = '\0';
FT_FRAME_EXIT();
}
goto Exit;
}
if ( found_apple != -1 )
{
FT_Memory memory = face->root.memory;
TT_NameEntryRec* name = face->name_table.names + found_apple;
FT_UInt len = name->stringLength;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
if ( !FT_ALLOC( result, len + 1 ) )
{
FT_Stream stream = face->name_table.stream;
if ( FT_STREAM_SEEK( name->stringOffset ) ||
FT_STREAM_READ( result, len ) )
{
name->stringOffset = 0;
name->stringLength = 0;
FT_FREE( name->string );
FT_FREE( result );
goto Exit;
}
((char*)result)[len] = '\0';
}
}
Exit:
face->postscript_name = result;
return result;
}
FT_DEFINE_SERVICE_PSFONTNAMEREC(
sfnt_service_ps_name,
(FT_PsName_GetFunc)sfnt_get_ps_name )
/*
* TT CMAP INFO
*/
FT_DEFINE_SERVICE_TTCMAPSREC(
tt_service_get_cmap_info,
(TT_CMap_Info_GetFunc)tt_get_cmap_info )
#ifdef TT_CONFIG_OPTION_BDF
static FT_Error
sfnt_get_charset_id( TT_Face face,
const char* *acharset_encoding,
const char* *acharset_registry )
{
BDF_PropertyRec encoding, registry;
FT_Error error;
/* XXX: I don't know whether this is correct, since
* tt_face_find_bdf_prop only returns something correct if we have
* previously selected a size that is listed in the BDF table.
* Should we change the BDF table format to include single offsets
* for `CHARSET_REGISTRY' and `CHARSET_ENCODING'?
*/
error = tt_face_find_bdf_prop( face, "CHARSET_REGISTRY", ®istry );
if ( !error )
{
error = tt_face_find_bdf_prop( face, "CHARSET_ENCODING", &encoding );
if ( !error )
{
if ( registry.type == BDF_PROPERTY_TYPE_ATOM &&
encoding.type == BDF_PROPERTY_TYPE_ATOM )
{
*acharset_encoding = encoding.u.atom;
*acharset_registry = registry.u.atom;
}
else
error = FT_THROW( Invalid_Argument );
}
}
return error;
}
FT_DEFINE_SERVICE_BDFRec(
sfnt_service_bdf,
(FT_BDF_GetCharsetIdFunc)sfnt_get_charset_id,
(FT_BDF_GetPropertyFunc) tt_face_find_bdf_prop )
#endif /* TT_CONFIG_OPTION_BDF */
/*
* SERVICE LIST
*/
#if defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES && defined TT_CONFIG_OPTION_BDF
FT_DEFINE_SERVICEDESCREC5(
sfnt_services,
FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET,
FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#elif defined TT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_DEFINE_SERVICEDESCREC4(
sfnt_services,
FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &SFNT_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#elif defined TT_CONFIG_OPTION_BDF
FT_DEFINE_SERVICEDESCREC4(
sfnt_services,
FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_BDF, &SFNT_SERVICE_BDF_GET,
FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#else
FT_DEFINE_SERVICEDESCREC3(
sfnt_services,
FT_SERVICE_ID_SFNT_TABLE, &SFNT_SERVICE_SFNT_TABLE_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET )
#endif
FT_CALLBACK_DEF( FT_Module_Interface )
sfnt_get_interface( FT_Module module,
const char* module_interface )
{
/* SFNT_SERVICES_GET derefers `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
FT_Library library;
if ( !module )
return NULL;
library = module->library;
if ( !library )
return NULL;
#else
FT_UNUSED( module );
#endif
return ft_service_list_lookup( SFNT_SERVICES_GET, module_interface );
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#define PUT_EMBEDDED_BITMAPS( a ) a
#else
#define PUT_EMBEDDED_BITMAPS( a ) NULL
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#define PUT_PS_NAMES( a ) a
#else
#define PUT_PS_NAMES( a ) NULL
#endif
FT_DEFINE_SFNT_INTERFACE(
sfnt_interface,
tt_face_goto_table,
sfnt_init_face,
sfnt_load_face,
sfnt_done_face,
sfnt_get_interface,
tt_face_load_any,
tt_face_load_head,
tt_face_load_hhea,
tt_face_load_cmap,
tt_face_load_maxp,
tt_face_load_os2,
tt_face_load_post,
tt_face_load_name,
tt_face_free_name,
tt_face_load_kern,
tt_face_load_gasp,
tt_face_load_pclt,
/* see `ttload.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
/* see `ttpost.h' */
PUT_PS_NAMES( tt_face_get_ps_name ),
PUT_PS_NAMES( tt_face_free_ps_names ),
/* since version 2.1.8 */
tt_face_get_kerning,
/* since version 2.2 */
tt_face_load_font_dir,
tt_face_load_hmtx,
/* see `ttsbit.h' and `sfnt.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
tt_face_get_metrics
)
FT_DEFINE_MODULE(
sfnt_module_class,
0, /* not a font driver or renderer */
sizeof ( FT_ModuleRec ),
"sfnt", /* driver name */
0x10000L, /* driver version 1.0 */
0x20000L, /* driver requires FreeType 2.0 or higher */
(const void*)&SFNT_INTERFACE_GET, /* module specific interface */
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
(FT_Module_Requester) sfnt_get_interface )
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfdriver.c | C | apache-2.0 | 13,628 |
/***************************************************************************/
/* */
/* sfdriver.h */
/* */
/* High-level SFNT driver interface (specification). */
/* */
/* Copyright 1996-2001 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 __SFDRIVER_H__
#define __SFDRIVER_H__
#include <ft2build.h>
#include FT_MODULE_H
FT_BEGIN_HEADER
FT_DECLARE_MODULE( sfnt_module_class )
FT_END_HEADER
#endif /* __SFDRIVER_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfdriver.h | C | apache-2.0 | 1,459 |
/***************************************************************************/
/* */
/* sferrors.h */
/* */
/* SFNT error codes (specification only). */
/* */
/* Copyright 2001, 2004, 2012, 2013 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the SFNT error enumeration constants. */
/* */
/*************************************************************************/
#ifndef __SFERRORS_H__
#define __SFERRORS_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX SFNT_Err_
#define FT_ERR_BASE FT_Mod_Err_SFNT
#include FT_ERRORS_H
#endif /* __SFERRORS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sferrors.h | C | apache-2.0 | 1,896 |
/***************************************************************************/
/* */
/* sfnt.c */
/* */
/* Single object library component. */
/* */
/* Copyright 1996-2006, 2013 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "sfntpic.c"
#include "ttload.c"
#include "ttmtx.c"
#include "ttcmap.c"
#include "ttkern.c"
#include "sfobjs.c"
#include "sfdriver.c"
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#include "pngshim.c"
#include "ttsbit.c"
#endif
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include "ttpost.c"
#endif
#ifdef TT_CONFIG_OPTION_BDF
#include "ttbdf.c"
#endif
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfnt.c | C | apache-2.0 | 1,677 |
/***************************************************************************/
/* */
/* sfntpic.c */
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "sfntpic.h"
#include "sferrors.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from sfdriver.c */
FT_Error
FT_Create_Class_sfnt_services( FT_Library library,
FT_ServiceDescRec** output_class );
void
FT_Destroy_Class_sfnt_services( FT_Library library,
FT_ServiceDescRec* clazz );
void
FT_Init_Class_sfnt_service_bdf( FT_Service_BDFRec* clazz );
void
FT_Init_Class_sfnt_interface( FT_Library library,
SFNT_Interface* clazz );
void
FT_Init_Class_sfnt_service_glyph_dict(
FT_Library library,
FT_Service_GlyphDictRec* clazz );
void
FT_Init_Class_sfnt_service_ps_name(
FT_Library library,
FT_Service_PsFontNameRec* clazz );
void
FT_Init_Class_tt_service_get_cmap_info(
FT_Library library,
FT_Service_TTCMapsRec* clazz );
void
FT_Init_Class_sfnt_service_sfnt_table(
FT_Service_SFNT_TableRec* clazz );
/* forward declaration of PIC init functions from ttcmap.c */
FT_Error
FT_Create_Class_tt_cmap_classes( FT_Library library,
TT_CMap_Class** output_class );
void
FT_Destroy_Class_tt_cmap_classes( FT_Library library,
TT_CMap_Class* clazz );
void
sfnt_module_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->sfnt )
{
sfntModulePIC* container = (sfntModulePIC*)pic_container->sfnt;
if ( container->sfnt_services )
FT_Destroy_Class_sfnt_services( library,
container->sfnt_services );
container->sfnt_services = NULL;
if ( container->tt_cmap_classes )
FT_Destroy_Class_tt_cmap_classes( library,
container->tt_cmap_classes );
container->tt_cmap_classes = NULL;
FT_FREE( container );
pic_container->sfnt = NULL;
}
}
FT_Error
sfnt_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
sfntModulePIC* container = NULL;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->sfnt = container;
/* initialize pointer table - */
/* this is how the module usually expects this data */
error = FT_Create_Class_sfnt_services( library,
&container->sfnt_services );
if ( error )
goto Exit;
error = FT_Create_Class_tt_cmap_classes( library,
&container->tt_cmap_classes );
if ( error )
goto Exit;
FT_Init_Class_sfnt_service_glyph_dict(
library, &container->sfnt_service_glyph_dict );
FT_Init_Class_sfnt_service_ps_name(
library, &container->sfnt_service_ps_name );
FT_Init_Class_tt_service_get_cmap_info(
library, &container->tt_service_get_cmap_info );
FT_Init_Class_sfnt_service_sfnt_table(
&container->sfnt_service_sfnt_table );
#ifdef TT_CONFIG_OPTION_BDF
FT_Init_Class_sfnt_service_bdf( &container->sfnt_service_bdf );
#endif
FT_Init_Class_sfnt_interface( library, &container->sfnt_interface );
Exit:
if ( error )
sfnt_module_class_pic_free( library );
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfntpic.c | C | apache-2.0 | 5,157 |
/***************************************************************************/
/* */
/* sfntpic.h */
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
/* Copyright 2009, 2012 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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 __SFNTPIC_H__
#define __SFNTPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define SFNT_SERVICES_GET sfnt_services
#define SFNT_SERVICE_GLYPH_DICT_GET sfnt_service_glyph_dict
#define SFNT_SERVICE_PS_NAME_GET sfnt_service_ps_name
#define TT_SERVICE_CMAP_INFO_GET tt_service_get_cmap_info
#define SFNT_SERVICES_GET sfnt_services
#define TT_CMAP_CLASSES_GET tt_cmap_classes
#define SFNT_SERVICE_SFNT_TABLE_GET sfnt_service_sfnt_table
#define SFNT_SERVICE_BDF_GET sfnt_service_bdf
#define SFNT_INTERFACE_GET sfnt_interface
#else /* FT_CONFIG_OPTION_PIC */
/* some include files required for members of sfntModulePIC */
#include FT_SERVICE_GLYPH_DICT_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_SFNT_H
#include FT_SERVICE_TT_CMAP_H
#ifdef TT_CONFIG_OPTION_BDF
#include "ttbdf.h"
#include FT_SERVICE_BDF_H
#endif
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include "ttcmap.h"
typedef struct sfntModulePIC_
{
FT_ServiceDescRec* sfnt_services;
FT_Service_GlyphDictRec sfnt_service_glyph_dict;
FT_Service_PsFontNameRec sfnt_service_ps_name;
FT_Service_TTCMapsRec tt_service_get_cmap_info;
TT_CMap_Class* tt_cmap_classes;
FT_Service_SFNT_TableRec sfnt_service_sfnt_table;
#ifdef TT_CONFIG_OPTION_BDF
FT_Service_BDFRec sfnt_service_bdf;
#endif
SFNT_Interface sfnt_interface;
} sfntModulePIC;
#define GET_PIC( lib ) \
( (sfntModulePIC*)( (lib)->pic_container.sfnt ) )
#define SFNT_SERVICES_GET \
( GET_PIC( library )->sfnt_services )
#define SFNT_SERVICE_GLYPH_DICT_GET \
( GET_PIC( library )->sfnt_service_glyph_dict )
#define SFNT_SERVICE_PS_NAME_GET \
( GET_PIC( library )->sfnt_service_ps_name )
#define TT_SERVICE_CMAP_INFO_GET \
( GET_PIC( library )->tt_service_get_cmap_info )
#define SFNT_SERVICES_GET \
( GET_PIC( library )->sfnt_services )
#define TT_CMAP_CLASSES_GET \
( GET_PIC( library )->tt_cmap_classes )
#define SFNT_SERVICE_SFNT_TABLE_GET \
( GET_PIC( library )->sfnt_service_sfnt_table )
#define SFNT_SERVICE_BDF_GET \
( GET_PIC( library )->sfnt_service_bdf )
#define SFNT_INTERFACE_GET \
( GET_PIC( library )->sfnt_interface )
/* see sfntpic.c for the implementation */
void
sfnt_module_class_pic_free( FT_Library library );
FT_Error
sfnt_module_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __SFNTPIC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfntpic.h | C | apache-2.0 | 4,156 |
/***************************************************************************/
/* */
/* sfobjs.c */
/* */
/* SFNT object management (base). */
/* */
/* Copyright 1996-2008, 2010-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include "sfobjs.h"
#include "ttload.h"
#include "ttcmap.h"
#include "ttkern.h"
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_DEBUG_H
#include FT_TRUETYPE_IDS_H
#include FT_TRUETYPE_TAGS_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_SFNT_NAMES_H
#include FT_GZIP_H
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_BDF
#include "ttbdf.h"
#endif
/*************************************************************************/
/* */
/* 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_sfobjs
/* convert a UTF-16 name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_utf16( TT_NameEntry entry,
FT_Memory memory )
{
FT_String* string = NULL;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
len = (FT_UInt)entry->stringLength / 2;
if ( FT_NEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
{
code = FT_NEXT_USHORT( read );
if ( code == 0 )
break;
if ( code < 32 || code > 127 )
code = '?';
string[n] = (char)code;
}
string[n] = 0;
return string;
}
/* convert an Apple Roman or symbol name entry to ASCII */
static FT_String*
tt_name_entry_ascii_from_other( TT_NameEntry entry,
FT_Memory memory )
{
FT_String* string = NULL;
FT_UInt len, code, n;
FT_Byte* read = (FT_Byte*)entry->string;
FT_Error error;
len = (FT_UInt)entry->stringLength;
if ( FT_NEW_ARRAY( string, len + 1 ) )
return NULL;
for ( n = 0; n < len; n++ )
{
code = *read++;
if ( code == 0 )
break;
if ( code < 32 || code > 127 )
code = '?';
string[n] = (char)code;
}
string[n] = 0;
return string;
}
typedef FT_String* (*TT_NameEntry_ConvertFunc)( TT_NameEntry entry,
FT_Memory memory );
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_get_name */
/* */
/* <Description> */
/* Returns a given ENGLISH name record in ASCII. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* nameid :: The name id of the name record to return. */
/* */
/* <InOut> */
/* name :: The address of a string pointer. NULL if no name is */
/* present. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static FT_Error
tt_face_get_name( TT_Face face,
FT_UShort nameid,
FT_String** name )
{
FT_Memory memory = face->root.memory;
FT_Error error = FT_Err_Ok;
FT_String* result = NULL;
FT_UShort n;
TT_NameEntryRec* rec;
FT_Int found_apple = -1;
FT_Int found_apple_roman = -1;
FT_Int found_apple_english = -1;
FT_Int found_win = -1;
FT_Int found_unicode = -1;
FT_Bool is_english = 0;
TT_NameEntry_ConvertFunc convert;
FT_ASSERT( name );
rec = face->name_table.names;
for ( n = 0; n < face->num_names; n++, rec++ )
{
/* According to the OpenType 1.3 specification, only Microsoft or */
/* Apple platform IDs might be used in the `name' table. The */
/* `Unicode' platform is reserved for the `cmap' table, and the */
/* `ISO' one is deprecated. */
/* */
/* However, the Apple TrueType specification doesn't say the same */
/* thing and goes to suggest that all Unicode `name' table entries */
/* should be coded in UTF-16 (in big-endian format I suppose). */
/* */
if ( rec->nameID == nameid && rec->stringLength > 0 )
{
switch ( rec->platformID )
{
case TT_PLATFORM_APPLE_UNICODE:
case TT_PLATFORM_ISO:
/* there is `languageID' to check there. We should use this */
/* field only as a last solution when nothing else is */
/* available. */
/* */
found_unicode = n;
break;
case TT_PLATFORM_MACINTOSH:
/* This is a bit special because some fonts will use either */
/* an English language id, or a Roman encoding id, to indicate */
/* the English version of its font name. */
/* */
if ( rec->languageID == TT_MAC_LANGID_ENGLISH )
found_apple_english = n;
else if ( rec->encodingID == TT_MAC_ID_ROMAN )
found_apple_roman = n;
break;
case TT_PLATFORM_MICROSOFT:
/* we only take a non-English name when there is nothing */
/* else available in the font */
/* */
if ( found_win == -1 || ( rec->languageID & 0x3FF ) == 0x009 )
{
switch ( rec->encodingID )
{
case TT_MS_ID_SYMBOL_CS:
case TT_MS_ID_UNICODE_CS:
case TT_MS_ID_UCS_4:
is_english = FT_BOOL( ( rec->languageID & 0x3FF ) == 0x009 );
found_win = n;
break;
default:
;
}
}
break;
default:
;
}
}
}
found_apple = found_apple_roman;
if ( found_apple_english >= 0 )
found_apple = found_apple_english;
/* some fonts contain invalid Unicode or Macintosh formatted entries; */
/* we will thus favor names encoded in Windows formats if available */
/* (provided it is an English name) */
/* */
convert = NULL;
if ( found_win >= 0 && !( found_apple >= 0 && !is_english ) )
{
rec = face->name_table.names + found_win;
switch ( rec->encodingID )
{
/* all Unicode strings are encoded using UTF-16BE */
case TT_MS_ID_UNICODE_CS:
case TT_MS_ID_SYMBOL_CS:
convert = tt_name_entry_ascii_from_utf16;
break;
case TT_MS_ID_UCS_4:
/* Apparently, if this value is found in a name table entry, it is */
/* documented as `full Unicode repertoire'. Experience with the */
/* MsGothic font shipped with Windows Vista shows that this really */
/* means UTF-16 encoded names (UCS-4 values are only used within */
/* charmaps). */
convert = tt_name_entry_ascii_from_utf16;
break;
default:
;
}
}
else if ( found_apple >= 0 )
{
rec = face->name_table.names + found_apple;
convert = tt_name_entry_ascii_from_other;
}
else if ( found_unicode >= 0 )
{
rec = face->name_table.names + found_unicode;
convert = tt_name_entry_ascii_from_utf16;
}
if ( rec && convert )
{
if ( rec->string == NULL )
{
FT_Stream stream = face->name_table.stream;
if ( FT_QNEW_ARRAY ( rec->string, rec->stringLength ) ||
FT_STREAM_SEEK( rec->stringOffset ) ||
FT_STREAM_READ( rec->string, rec->stringLength ) )
{
FT_FREE( rec->string );
rec->stringLength = 0;
result = NULL;
goto Exit;
}
}
result = convert( rec, memory );
}
Exit:
*name = result;
return error;
}
static FT_Encoding
sfnt_find_encoding( int platform_id,
int encoding_id )
{
typedef struct TEncoding_
{
int platform_id;
int encoding_id;
FT_Encoding encoding;
} TEncoding;
static
const TEncoding tt_encodings[] =
{
{ TT_PLATFORM_ISO, -1, FT_ENCODING_UNICODE },
{ TT_PLATFORM_APPLE_UNICODE, -1, FT_ENCODING_UNICODE },
{ TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, FT_ENCODING_APPLE_ROMAN },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SYMBOL_CS, FT_ENCODING_MS_SYMBOL },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UCS_4, FT_ENCODING_UNICODE },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, FT_ENCODING_UNICODE },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, FT_ENCODING_SJIS },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, FT_ENCODING_GB2312 },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, FT_ENCODING_BIG5 },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, FT_ENCODING_WANSUNG },
{ TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, FT_ENCODING_JOHAB }
};
const TEncoding *cur, *limit;
cur = tt_encodings;
limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] );
for ( ; cur < limit; cur++ )
{
if ( cur->platform_id == platform_id )
{
if ( cur->encoding_id == encoding_id ||
cur->encoding_id == -1 )
return cur->encoding;
}
}
return FT_ENCODING_NONE;
}
#define WRITE_BYTE( p, v ) \
do \
{ \
*(p)++ = (v) >> 0; \
\
} while ( 0 )
#define WRITE_USHORT( p, v ) \
do \
{ \
*(p)++ = (v) >> 8; \
*(p)++ = (v) >> 0; \
\
} while ( 0 )
#define WRITE_ULONG( p, v ) \
do \
{ \
*(p)++ = (v) >> 24; \
*(p)++ = (v) >> 16; \
*(p)++ = (v) >> 8; \
*(p)++ = (v) >> 0; \
\
} while ( 0 )
static void
sfnt_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( stream->base );
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
FT_CALLBACK_DEF( int )
compare_offsets( const void* a,
const void* b )
{
WOFF_Table table1 = *(WOFF_Table*)a;
WOFF_Table table2 = *(WOFF_Table*)b;
FT_ULong offset1 = table1->Offset;
FT_ULong offset2 = table2->Offset;
if ( offset1 > offset2 )
return 1;
else if ( offset1 < offset2 )
return -1;
else
return 0;
}
/* Replace `face->root.stream' with a stream containing the extracted */
/* SFNT of a WOFF font. */
static FT_Error
woff_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error = FT_Err_Ok;
WOFF_HeaderRec woff;
WOFF_Table tables = NULL;
WOFF_Table* indices = NULL;
FT_ULong woff_offset;
FT_Byte* sfnt = NULL;
FT_Stream sfnt_stream = NULL;
FT_Byte* sfnt_header;
FT_ULong sfnt_offset;
FT_Int nn;
FT_ULong old_tag = 0;
static const FT_Frame_Field woff_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE WOFF_HeaderRec
FT_FRAME_START( 44 ),
FT_FRAME_ULONG ( signature ),
FT_FRAME_ULONG ( flavor ),
FT_FRAME_ULONG ( length ),
FT_FRAME_USHORT( num_tables ),
FT_FRAME_USHORT( reserved ),
FT_FRAME_ULONG ( totalSfntSize ),
FT_FRAME_USHORT( majorVersion ),
FT_FRAME_USHORT( minorVersion ),
FT_FRAME_ULONG ( metaOffset ),
FT_FRAME_ULONG ( metaLength ),
FT_FRAME_ULONG ( metaOrigLength ),
FT_FRAME_ULONG ( privOffset ),
FT_FRAME_ULONG ( privLength ),
FT_FRAME_END
};
FT_ASSERT( stream == face->root.stream );
FT_ASSERT( FT_STREAM_POS() == 0 );
if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) )
return error;
/* Make sure we don't recurse back here or hit TTC code. */
if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf )
return FT_THROW( Invalid_Table );
/* Miscellaneous checks. */
if ( woff.length != stream->size ||
woff.num_tables == 0 ||
44 + woff.num_tables * 20UL >= woff.length ||
12 + woff.num_tables * 16UL >= woff.totalSfntSize ||
( woff.totalSfntSize & 3 ) != 0 ||
( woff.metaOffset == 0 && ( woff.metaLength != 0 ||
woff.metaOrigLength != 0 ) ) ||
( woff.metaLength != 0 && woff.metaOrigLength == 0 ) ||
( woff.privOffset == 0 && woff.privLength != 0 ) )
return FT_THROW( Invalid_Table );
if ( FT_ALLOC( sfnt, woff.totalSfntSize ) ||
FT_NEW( sfnt_stream ) )
goto Exit;
sfnt_header = sfnt;
/* Write sfnt header. */
{
FT_UInt searchRange, entrySelector, rangeShift, x;
x = woff.num_tables;
entrySelector = 0;
while ( x )
{
x >>= 1;
entrySelector += 1;
}
entrySelector--;
searchRange = ( 1 << entrySelector ) * 16;
rangeShift = woff.num_tables * 16 - searchRange;
WRITE_ULONG ( sfnt_header, woff.flavor );
WRITE_USHORT( sfnt_header, woff.num_tables );
WRITE_USHORT( sfnt_header, searchRange );
WRITE_USHORT( sfnt_header, entrySelector );
WRITE_USHORT( sfnt_header, rangeShift );
}
/* While the entries in the sfnt header must be sorted by the */
/* tag value, the tables themselves are not. We thus have to */
/* sort them by offset and check that they don't overlap. */
if ( FT_NEW_ARRAY( tables, woff.num_tables ) ||
FT_NEW_ARRAY( indices, woff.num_tables ) )
goto Exit;
FT_TRACE2(( "\n"
" tag offset compLen origLen checksum\n"
" -------------------------------------------\n" ));
if ( FT_FRAME_ENTER( 20L * woff.num_tables ) )
goto Exit;
for ( nn = 0; nn < woff.num_tables; nn++ )
{
WOFF_Table table = tables + nn;
table->Tag = FT_GET_TAG4();
table->Offset = FT_GET_ULONG();
table->CompLength = FT_GET_ULONG();
table->OrigLength = FT_GET_ULONG();
table->CheckSum = FT_GET_ULONG();
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n",
(FT_Char)( table->Tag >> 24 ),
(FT_Char)( table->Tag >> 16 ),
(FT_Char)( table->Tag >> 8 ),
(FT_Char)( table->Tag ),
table->Offset,
table->CompLength,
table->OrigLength,
table->CheckSum ));
if ( table->Tag <= old_tag )
{
FT_FRAME_EXIT();
error = FT_THROW( Invalid_Table );
goto Exit;
}
old_tag = table->Tag;
indices[nn] = table;
}
FT_FRAME_EXIT();
/* Sort by offset. */
ft_qsort( indices,
woff.num_tables,
sizeof ( WOFF_Table ),
compare_offsets );
/* Check offsets and lengths. */
woff_offset = 44 + woff.num_tables * 20L;
sfnt_offset = 12 + woff.num_tables * 16L;
for ( nn = 0; nn < woff.num_tables; nn++ )
{
WOFF_Table table = indices[nn];
if ( table->Offset != woff_offset ||
table->Offset + table->CompLength > woff.length ||
sfnt_offset + table->OrigLength > woff.totalSfntSize ||
table->CompLength > table->OrigLength )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
table->OrigOffset = sfnt_offset;
/* The offsets must be multiples of 4. */
woff_offset += ( table->CompLength + 3 ) & ~3;
sfnt_offset += ( table->OrigLength + 3 ) & ~3;
}
/*
* Final checks!
*
* We don't decode and check the metadata block.
* We don't check table checksums either.
* But other than those, I think we implement all
* `MUST' checks from the spec.
*/
if ( woff.metaOffset )
{
if ( woff.metaOffset != woff_offset ||
woff.metaOffset + woff.metaLength > woff.length )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* We have padding only ... */
woff_offset += woff.metaLength;
}
if ( woff.privOffset )
{
/* ... if it isn't the last block. */
woff_offset = ( woff_offset + 3 ) & ~3;
if ( woff.privOffset != woff_offset ||
woff.privOffset + woff.privLength > woff.length )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* No padding for the last block. */
woff_offset += woff.privLength;
}
if ( sfnt_offset != woff.totalSfntSize ||
woff_offset != woff.length )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* Write the tables. */
for ( nn = 0; nn < woff.num_tables; nn++ )
{
WOFF_Table table = tables + nn;
/* Write SFNT table entry. */
WRITE_ULONG( sfnt_header, table->Tag );
WRITE_ULONG( sfnt_header, table->CheckSum );
WRITE_ULONG( sfnt_header, table->OrigOffset );
WRITE_ULONG( sfnt_header, table->OrigLength );
/* Write table data. */
if ( FT_STREAM_SEEK( table->Offset ) ||
FT_FRAME_ENTER( table->CompLength ) )
goto Exit;
if ( table->CompLength == table->OrigLength )
{
/* Uncompressed data; just copy. */
ft_memcpy( sfnt + table->OrigOffset,
stream->cursor,
table->OrigLength );
}
else
{
/* Uncompress with zlib. */
FT_ULong output_len = table->OrigLength;
error = FT_Gzip_Uncompress( memory,
sfnt + table->OrigOffset, &output_len,
stream->cursor, table->CompLength );
if ( error )
goto Exit;
if ( output_len != table->OrigLength )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
}
FT_FRAME_EXIT();
/* We don't check whether the padding bytes in the WOFF file are */
/* actually '\0'. For the output, however, we do set them properly. */
sfnt_offset = table->OrigOffset + table->OrigLength;
while ( sfnt_offset & 3 )
{
sfnt[sfnt_offset] = '\0';
sfnt_offset++;
}
}
/* Ok! Finally ready. Swap out stream and return. */
FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize );
sfnt_stream->memory = stream->memory;
sfnt_stream->close = sfnt_stream_close;
FT_Stream_Free(
face->root.stream,
( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
face->root.stream = sfnt_stream;
face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
Exit:
FT_FREE( tables );
FT_FREE( indices );
if ( error )
{
FT_FREE( sfnt );
FT_Stream_Close( sfnt_stream );
FT_FREE( sfnt_stream );
}
return error;
}
#undef WRITE_BYTE
#undef WRITE_USHORT
#undef WRITE_ULONG
/* Fill in face->ttc_header. If the font is not a TTC, it is */
/* synthesized into a TTC with one offset table. */
static FT_Error
sfnt_open_font( FT_Stream stream,
TT_Face face )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_ULong tag, offset;
static const FT_Frame_Field ttc_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TTC_HeaderRec
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
FT_FRAME_LONG( count ), /* this is ULong in the specs */
FT_FRAME_END
};
face->ttc_header.tag = 0;
face->ttc_header.version = 0;
face->ttc_header.count = 0;
retry:
offset = FT_STREAM_POS();
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag == TTAG_wOFF )
{
FT_TRACE2(( "sfnt_open_font: file is a WOFF; synthesizing SFNT\n" ));
if ( FT_STREAM_SEEK( offset ) )
return error;
error = woff_open_font( stream, face );
if ( error )
return error;
/* Swap out stream and retry! */
stream = face->root.stream;
goto retry;
}
if ( tag != 0x00010000UL &&
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
tag != 0x00020000UL )
{
FT_TRACE2(( " not a font using the SFNT container format\n" ));
return FT_THROW( Unknown_File_Format );
}
face->ttc_header.tag = TTAG_ttcf;
if ( tag == TTAG_ttcf )
{
FT_Int n;
FT_TRACE3(( "sfnt_open_font: file is a collection\n" ));
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
if ( face->ttc_header.count == 0 )
return FT_THROW( Invalid_Table );
/* a rough size estimate: let's conservatively assume that there */
/* is just a single table info in each subfont header (12 + 16*1 = */
/* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
/* size of the TTC header plus `28*count' bytes for all subfont */
/* headers */
if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
return FT_THROW( Array_Too_Large );
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
if ( FT_FRAME_ENTER( face->ttc_header.count * 4L ) )
return error;
for ( n = 0; n < face->ttc_header.count; n++ )
face->ttc_header.offsets[n] = FT_GET_ULONG();
FT_FRAME_EXIT();
}
else
{
FT_TRACE3(( "sfnt_open_font: synthesize TTC\n" ));
face->ttc_header.version = 1 << 16;
face->ttc_header.count = 1;
if ( FT_NEW( face->ttc_header.offsets ) )
return error;
face->ttc_header.offsets[0] = offset;
}
return error;
}
FT_LOCAL_DEF( FT_Error )
sfnt_init_face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Library library = face->root.driver->root.library;
SFNT_Service sfnt;
/* for now, parameters are unused */
FT_UNUSED( num_params );
FT_UNUSED( params );
sfnt = (SFNT_Service)face->sfnt;
if ( !sfnt )
{
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
{
FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
return FT_THROW( Missing_Module );
}
face->sfnt = sfnt;
face->goto_table = sfnt->goto_table;
}
FT_FACE_FIND_GLOBAL_SERVICE( face, face->psnames, POSTSCRIPT_CMAPS );
FT_TRACE2(( "SFNT driver\n" ));
error = sfnt_open_font( stream, face );
if ( error )
return error;
/* Stream may have changed in sfnt_open_font. */
stream = face->root.stream;
FT_TRACE2(( "sfnt_init_face: %08p, %ld\n", face, face_index ));
if ( face_index < 0 )
face_index = 0;
if ( face_index >= face->ttc_header.count )
return FT_THROW( Invalid_Argument );
if ( FT_STREAM_SEEK( face->ttc_header.offsets[face_index] ) )
return error;
/* check that we have a valid TrueType file */
error = sfnt->load_font_dir( face, stream );
if ( error )
return error;
face->root.num_faces = face->ttc_header.count;
face->root.face_index = face_index;
return error;
}
#define LOAD_( x ) \
do \
{ \
FT_TRACE2(( "`" #x "' " )); \
FT_TRACE3(( "-->\n" )); \
\
error = sfnt->load_ ## x( face, stream ); \
\
FT_TRACE2(( "%s\n", ( !error ) \
? "loaded" \
: FT_ERR_EQ( error, Table_Missing ) \
? "missing" \
: "failed to load" )); \
FT_TRACE3(( "\n" )); \
} while ( 0 )
#define LOADM_( x, vertical ) \
do \
{ \
FT_TRACE2(( "`%s" #x "' ", \
vertical ? "vertical " : "" )); \
FT_TRACE3(( "-->\n" )); \
\
error = sfnt->load_ ## x( face, stream, vertical ); \
\
FT_TRACE2(( "%s\n", ( !error ) \
? "loaded" \
: FT_ERR_EQ( error, Table_Missing ) \
? "missing" \
: "failed to load" )); \
FT_TRACE3(( "\n" )); \
} while ( 0 )
#define GET_NAME( id, field ) \
do \
{ \
error = tt_face_get_name( face, TT_NAME_ID_ ## id, field ); \
if ( error ) \
goto Exit; \
} while ( 0 )
FT_LOCAL_DEF( FT_Error )
sfnt_load_face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_Error psnames_error;
#endif
FT_Bool has_outline;
FT_Bool is_apple_sbit;
FT_Bool is_apple_sbix;
FT_Bool ignore_preferred_family = FALSE;
FT_Bool ignore_preferred_subfamily = FALSE;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
FT_UNUSED( face_index );
/* Check parameters */
{
FT_Int i;
for ( i = 0; i < num_params; i++ )
{
if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY )
ignore_preferred_family = TRUE;
else if ( params[i].tag == FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY )
ignore_preferred_subfamily = TRUE;
}
}
/* Load tables */
/* We now support two SFNT-based bitmapped font formats. They */
/* are recognized easily as they do not include a `glyf' */
/* table. */
/* */
/* The first format comes from Apple, and uses a table named */
/* `bhed' instead of `head' to store the font header (using */
/* the same format). It also doesn't include horizontal and */
/* vertical metrics tables (i.e. `hhea' and `vhea' tables are */
/* missing). */
/* */
/* The other format comes from Microsoft, and is used with */
/* WinCE/PocketPC. It looks like a standard TTF, except that */
/* it doesn't contain outlines. */
/* */
FT_TRACE2(( "sfnt_load_face: %08p\n\n", face ));
/* do we have outlines in there? */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 ||
tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#else
has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#endif
is_apple_sbit = 0;
is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 );
/* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf'
* outline rendered on top. We don't support that yet, so just ignore
* the 'glyf' outline and advertise it as a bitmap-only font. */
if ( is_apple_sbix )
has_outline = FALSE;
/* if this font doesn't contain outlines, we try to load */
/* a `bhed' table */
if ( !has_outline && sfnt->load_bhed )
{
LOAD_( bhed );
is_apple_sbit = FT_BOOL( !error );
}
/* load the font header (`head' table) if this isn't an Apple */
/* sbit font file */
if ( !is_apple_sbit || is_apple_sbix )
{
LOAD_( head );
if ( error )
goto Exit;
}
if ( face->header.Units_Per_EM == 0 )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
/* the following tables are often not present in embedded TrueType */
/* fonts within PDF documents, so don't check for them. */
LOAD_( maxp );
LOAD_( cmap );
/* the following tables are optional in PCL fonts -- */
/* don't check for errors */
LOAD_( name );
LOAD_( post );
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
psnames_error = error;
#endif
/* do not load the metrics headers and tables if this is an Apple */
/* sbit font file */
if ( !is_apple_sbit )
{
/* load the `hhea' and `hmtx' tables */
LOADM_( hhea, 0 );
if ( !error )
{
LOADM_( hmtx, 0 );
if ( FT_ERR_EQ( error, Table_Missing ) )
{
error = FT_THROW( Hmtx_Table_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
/* overriding metrics, tolerate a missing `hmtx' table. */
if ( face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
error = FT_Err_Ok;
}
#endif
}
}
else if ( FT_ERR_EQ( error, Table_Missing ) )
{
/* No `hhea' table necessary for SFNT Mac fonts. */
if ( face->format_tag == TTAG_true )
{
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
has_outline = 0;
error = FT_Err_Ok;
}
else
{
error = FT_THROW( Horiz_Header_Missing );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If this is an incrementally loaded font and there are */
/* overriding metrics, tolerate a missing `hhea' table. */
if ( face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->
get_glyph_metrics )
{
face->horizontal.number_Of_HMetrics = 0;
error = FT_Err_Ok;
}
#endif
}
}
if ( error )
goto Exit;
/* try to load the `vhea' and `vmtx' tables */
LOADM_( hhea, 1 );
if ( !error )
{
LOADM_( hmtx, 1 );
if ( !error )
face->vertical_info = 1;
}
if ( error && FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
LOAD_( os2 );
if ( error )
{
/* we treat the table as missing if there are any errors */
face->os2.version = 0xFFFFU;
}
}
/* the optional tables */
/* embedded bitmap support */
if ( sfnt->load_eblc )
{
LOAD_( eblc );
if ( error )
{
/* a font which contains neither bitmaps nor outlines is */
/* still valid (although rather useless in most cases); */
/* however, you can find such stripped fonts in PDFs */
if ( FT_ERR_EQ( error, Table_Missing ) )
error = FT_Err_Ok;
else
goto Exit;
}
}
LOAD_( pclt );
if ( error )
{
if ( FT_ERR_NEQ( error, Table_Missing ) )
goto Exit;
face->pclt.Version = 0;
}
/* consider the kerning and gasp tables as optional */
LOAD_( gasp );
LOAD_( kern );
face->root.num_glyphs = face->max_profile.numGlyphs;
/* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */
/* a WWS-only font face. `WWS' stands for `weight', width', and */
/* `slope', a term used by Microsoft's Windows Presentation */
/* Foundation (WPF). This flag has been introduced in version */
/* 1.5 of the OpenType specification (May 2008). */
face->root.family_name = NULL;
face->root.style_name = NULL;
if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 )
{
if ( !ignore_preferred_family )
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
if ( !ignore_preferred_subfamily )
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
else
{
GET_NAME( WWS_FAMILY, &face->root.family_name );
if ( !face->root.family_name && !ignore_preferred_family )
GET_NAME( PREFERRED_FAMILY, &face->root.family_name );
if ( !face->root.family_name )
GET_NAME( FONT_FAMILY, &face->root.family_name );
GET_NAME( WWS_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name && !ignore_preferred_subfamily )
GET_NAME( PREFERRED_SUBFAMILY, &face->root.style_name );
if ( !face->root.style_name )
GET_NAME( FONT_SUBFAMILY, &face->root.style_name );
}
/* now set up root fields */
{
FT_Face root = &face->root;
FT_Long flags = root->face_flags;
/*********************************************************************/
/* */
/* Compute face flags. */
/* */
if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC ||
face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX )
flags |= FT_FACE_FLAG_COLOR; /* color glyphs */
if ( has_outline == TRUE )
flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */
/* The sfnt driver only supports bitmap fonts natively, thus we */
/* don't set FT_FACE_FLAG_HINTER. */
flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
if ( !psnames_error &&
face->postscript.FormatType != 0x00030000L )
flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
/* fixed width font? */
if ( face->postscript.isFixedPitch )
flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* vertical information? */
if ( face->vertical_info )
flags |= FT_FACE_FLAG_VERTICAL;
/* kerning available ? */
if ( TT_FACE_HAS_KERNING( face ) )
flags |= FT_FACE_FLAG_KERNING;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* Don't bother to load the tables unless somebody asks for them. */
/* No need to do work which will (probably) not be used. */
if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 &&
tt_face_lookup_table( face, TTAG_fvar ) != 0 &&
tt_face_lookup_table( face, TTAG_gvar ) != 0 )
flags |= FT_FACE_FLAG_MULTIPLE_MASTERS;
#endif
root->face_flags = flags;
/*********************************************************************/
/* */
/* Compute style flags. */
/* */
flags = 0;
if ( has_outline == TRUE && face->os2.version != 0xFFFFU )
{
/* We have an OS/2 table; use the `fsSelection' field. Bit 9 */
/* indicates an oblique font face. This flag has been */
/* introduced in version 1.5 of the OpenType specification. */
if ( face->os2.fsSelection & 512 ) /* bit 9 */
flags |= FT_STYLE_FLAG_ITALIC;
else if ( face->os2.fsSelection & 1 ) /* bit 0 */
flags |= FT_STYLE_FLAG_ITALIC;
if ( face->os2.fsSelection & 32 ) /* bit 5 */
flags |= FT_STYLE_FLAG_BOLD;
}
else
{
/* this is an old Mac font, use the header field */
if ( face->header.Mac_Style & 1 )
flags |= FT_STYLE_FLAG_BOLD;
if ( face->header.Mac_Style & 2 )
flags |= FT_STYLE_FLAG_ITALIC;
}
root->style_flags = flags;
/*********************************************************************/
/* */
/* Polish the charmaps. */
/* */
/* Try to set the charmap encoding according to the platform & */
/* encoding ID of each charmap. */
/* */
tt_face_build_cmaps( face ); /* ignore errors */
/* set the encoding fields */
{
FT_Int m;
for ( m = 0; m < root->num_charmaps; m++ )
{
FT_CharMap charmap = root->charmaps[m];
charmap->encoding = sfnt_find_encoding( charmap->platform_id,
charmap->encoding_id );
#if 0
if ( root->charmap == NULL &&
charmap->encoding == FT_ENCODING_UNICODE )
{
/* set 'root->charmap' to the first Unicode encoding we find */
root->charmap = charmap;
}
#endif
}
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/*
* Now allocate the root array of FT_Bitmap_Size records and
* populate them. Unfortunately, it isn't possible to indicate bit
* depths in the FT_Bitmap_Size record. This is a design error.
*/
{
FT_UInt i, count;
count = face->sbit_num_strikes;
if ( count > 0 )
{
FT_Memory memory = face->root.stream->memory;
FT_UShort em_size = face->header.Units_Per_EM;
FT_Short avgwidth = face->os2.xAvgCharWidth;
FT_Size_Metrics metrics;
if ( em_size == 0 || face->os2.version == 0xFFFFU )
{
avgwidth = 1;
em_size = 1;
}
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
goto Exit;
for ( i = 0; i < count; i++ )
{
FT_Bitmap_Size* bsize = root->available_sizes + i;
error = sfnt->load_strike_metrics( face, i, &metrics );
if ( error )
goto Exit;
bsize->height = (FT_Short)( metrics.height >> 6 );
bsize->width = (FT_Short)(
( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
bsize->x_ppem = metrics.x_ppem << 6;
bsize->y_ppem = metrics.y_ppem << 6;
/* assume 72dpi */
bsize->size = metrics.y_ppem << 6;
}
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
root->num_fixed_sizes = (FT_Int)count;
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* a font with no bitmaps and no outlines is scalable; */
/* it has only empty glyphs then */
if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) )
root->face_flags |= FT_FACE_FLAG_SCALABLE;
/*********************************************************************/
/* */
/* Set up metrics. */
/* */
if ( FT_IS_SCALABLE( root ) )
{
/* XXX What about if outline header is missing */
/* (e.g. sfnt wrapped bitmap)? */
root->bbox.xMin = face->header.xMin;
root->bbox.yMin = face->header.yMin;
root->bbox.xMax = face->header.xMax;
root->bbox.yMax = face->header.yMax;
root->units_per_EM = face->header.Units_Per_EM;
/* XXX: Computing the ascender/descender/height is very different */
/* from what the specification tells you. Apparently, we */
/* must be careful because */
/* */
/* - not all fonts have an OS/2 table; in this case, we take */
/* the values in the horizontal header. However, these */
/* values very often are not reliable. */
/* */
/* - otherwise, the correct typographic values are in the */
/* sTypoAscender, sTypoDescender & sTypoLineGap fields. */
/* */
/* However, certain fonts have these fields set to 0. */
/* Rather, they have usWinAscent & usWinDescent correctly */
/* set (but with different values). */
/* */
/* As an example, Arial Narrow is implemented through four */
/* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */
/* */
/* Strangely, all fonts have the same values in their */
/* sTypoXXX fields, except ARIALNB which sets them to 0. */
/* */
/* On the other hand, they all have different */
/* usWinAscent/Descent values -- as a conclusion, the OS/2 */
/* table cannot be used to compute the text height reliably! */
/* */
/* The ascender and descender are taken from the `hhea' table. */
/* If zero, they are taken from the `OS/2' table. */
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
root->height = (FT_Short)( root->ascender - root->descender +
face->horizontal.Line_Gap );
if ( !( root->ascender || root->descender ) )
{
if ( face->os2.version != 0xFFFFU )
{
if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
{
root->ascender = face->os2.sTypoAscender;
root->descender = face->os2.sTypoDescender;
root->height = (FT_Short)( root->ascender - root->descender +
face->os2.sTypoLineGap );
}
else
{
root->ascender = (FT_Short)face->os2.usWinAscent;
root->descender = -(FT_Short)face->os2.usWinDescent;
root->height = (FT_UShort)( root->ascender - root->descender );
}
}
}
root->max_advance_width = face->horizontal.advance_Width_Max;
root->max_advance_height = (FT_Short)( face->vertical_info
? face->vertical.advance_Height_Max
: root->height );
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
/* Adjust underline position from top edge to centre of */
/* stroke to convert TrueType meaning to FreeType meaning. */
root->underline_position = face->postscript.underlinePosition -
face->postscript.underlineThickness / 2;
root->underline_thickness = face->postscript.underlineThickness;
}
}
Exit:
FT_TRACE2(( "sfnt_load_face: done\n" ));
return error;
}
#undef LOAD_
#undef LOADM_
#undef GET_NAME
FT_LOCAL_DEF( void )
sfnt_done_face( TT_Face face )
{
FT_Memory memory;
SFNT_Service sfnt;
if ( !face )
return;
memory = face->root.memory;
sfnt = (SFNT_Service)face->sfnt;
if ( sfnt )
{
/* destroy the postscript names table if it is loaded */
if ( sfnt->free_psnames )
sfnt->free_psnames( face );
/* destroy the embedded bitmaps table if it is loaded */
if ( sfnt->free_eblc )
sfnt->free_eblc( face );
}
#ifdef TT_CONFIG_OPTION_BDF
/* freeing the embedded BDF properties */
tt_face_free_bdf_props( face );
#endif
/* freeing the kerning table */
tt_face_done_kern( face );
/* freeing the collection table */
FT_FREE( face->ttc_header.offsets );
face->ttc_header.count = 0;
/* freeing table directory */
FT_FREE( face->dir_tables );
face->num_tables = 0;
{
FT_Stream stream = FT_FACE_STREAM( face );
/* simply release the 'cmap' table frame */
FT_FRAME_RELEASE( face->cmap_table );
face->cmap_size = 0;
}
/* freeing the horizontal metrics */
{
FT_Stream stream = FT_FACE_STREAM( face );
FT_FRAME_RELEASE( face->horz_metrics );
FT_FRAME_RELEASE( face->vert_metrics );
face->horz_metrics_size = 0;
face->vert_metrics_size = 0;
}
/* freeing the vertical ones, if any */
if ( face->vertical_info )
{
FT_FREE( face->vertical.long_metrics );
FT_FREE( face->vertical.short_metrics );
face->vertical_info = 0;
}
/* freeing the gasp table */
FT_FREE( face->gasp.gaspRanges );
face->gasp.numRanges = 0;
/* freeing the name table */
if ( sfnt )
sfnt->free_name( face );
/* freeing family and style name */
FT_FREE( face->root.family_name );
FT_FREE( face->root.style_name );
/* freeing sbit size table */
FT_FREE( face->root.available_sizes );
face->root.num_fixed_sizes = 0;
FT_FREE( face->postscript_name );
face->sfnt = 0;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfobjs.c | C | apache-2.0 | 50,978 |
/***************************************************************************/
/* */
/* sfobjs.h */
/* */
/* SFNT object management (specification). */
/* */
/* Copyright 1996-2001, 2002 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 __SFOBJS_H__
#define __SFOBJS_H__
#include <ft2build.h>
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_OBJECTS_H
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
sfnt_init_face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( FT_Error )
sfnt_load_face( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
sfnt_done_face( TT_Face face );
FT_END_HEADER
#endif /* __SFDRIVER_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/sfobjs.h | C | apache-2.0 | 1,980 |
/***************************************************************************/
/* */
/* ttbdf.c */
/* */
/* TrueType and OpenType embedded BDF properties (body). */
/* */
/* Copyright 2005, 2006, 2010, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttbdf.h"
#include "sferrors.h"
#ifdef TT_CONFIG_OPTION_BDF
/*************************************************************************/
/* */
/* 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_ttbdf
FT_LOCAL_DEF( void )
tt_face_free_bdf_props( TT_Face face )
{
TT_BDF bdf = &face->bdf;
if ( bdf->loaded )
{
FT_Stream stream = FT_FACE(face)->stream;
if ( bdf->table != NULL )
FT_FRAME_RELEASE( bdf->table );
bdf->table_end = NULL;
bdf->strings = NULL;
bdf->strings_size = 0;
}
}
static FT_Error
tt_face_load_bdf_props( TT_Face face,
FT_Stream stream )
{
TT_BDF bdf = &face->bdf;
FT_ULong length;
FT_Error error;
FT_ZERO( bdf );
error = tt_face_goto_table( face, TTAG_BDF, stream, &length );
if ( error ||
length < 8 ||
FT_FRAME_EXTRACT( length, bdf->table ) )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
bdf->table_end = bdf->table + length;
{
FT_Byte* p = bdf->table;
FT_UInt version = FT_NEXT_USHORT( p );
FT_UInt num_strikes = FT_NEXT_USHORT( p );
FT_ULong strings = FT_NEXT_ULONG ( p );
FT_UInt count;
FT_Byte* strike;
if ( version != 0x0001 ||
strings < 8 ||
( strings - 8 ) / 4 < num_strikes ||
strings + 1 > length )
{
goto BadTable;
}
bdf->num_strikes = num_strikes;
bdf->strings = bdf->table + strings;
bdf->strings_size = length - strings;
count = bdf->num_strikes;
p = bdf->table + 8;
strike = p + count * 4;
for ( ; count > 0; count-- )
{
FT_UInt num_items = FT_PEEK_USHORT( p + 2 );
/*
* We don't need to check the value sets themselves, since this
* is done later.
*/
strike += 10 * num_items;
p += 4;
}
if ( strike > bdf->strings )
goto BadTable;
}
bdf->loaded = 1;
Exit:
return error;
BadTable:
FT_FRAME_RELEASE( bdf->table );
FT_ZERO( bdf );
error = FT_THROW( Invalid_Table );
goto Exit;
}
FT_LOCAL_DEF( FT_Error )
tt_face_find_bdf_prop( TT_Face face,
const char* property_name,
BDF_PropertyRec *aprop )
{
TT_BDF bdf = &face->bdf;
FT_Size size = FT_FACE(face)->size;
FT_Error error = FT_Err_Ok;
FT_Byte* p;
FT_UInt count;
FT_Byte* strike;
FT_Offset property_len;
aprop->type = BDF_PROPERTY_TYPE_NONE;
if ( bdf->loaded == 0 )
{
error = tt_face_load_bdf_props( face, FT_FACE( face )->stream );
if ( error )
goto Exit;
}
count = bdf->num_strikes;
p = bdf->table + 8;
strike = p + 4 * count;
error = FT_ERR( Invalid_Argument );
if ( size == NULL || property_name == NULL )
goto Exit;
property_len = ft_strlen( property_name );
if ( property_len == 0 )
goto Exit;
for ( ; count > 0; count-- )
{
FT_UInt _ppem = FT_NEXT_USHORT( p );
FT_UInt _count = FT_NEXT_USHORT( p );
if ( _ppem == size->metrics.y_ppem )
{
count = _count;
goto FoundStrike;
}
strike += 10 * _count;
}
goto Exit;
FoundStrike:
p = strike;
for ( ; count > 0; count-- )
{
FT_UInt type = FT_PEEK_USHORT( p + 4 );
if ( ( type & 0x10 ) != 0 )
{
FT_UInt32 name_offset = FT_PEEK_ULONG( p );
FT_UInt32 value = FT_PEEK_ULONG( p + 6 );
/* be a bit paranoid for invalid entries here */
if ( name_offset < bdf->strings_size &&
property_len < bdf->strings_size - name_offset &&
ft_strncmp( property_name,
(const char*)bdf->strings + name_offset,
bdf->strings_size - name_offset ) == 0 )
{
switch ( type & 0x0F )
{
case 0x00: /* string */
case 0x01: /* atoms */
/* check that the content is really 0-terminated */
if ( value < bdf->strings_size &&
ft_memchr( bdf->strings + value, 0, bdf->strings_size ) )
{
aprop->type = BDF_PROPERTY_TYPE_ATOM;
aprop->u.atom = (const char*)bdf->strings + value;
error = FT_Err_Ok;
goto Exit;
}
break;
case 0x02:
aprop->type = BDF_PROPERTY_TYPE_INTEGER;
aprop->u.integer = (FT_Int32)value;
error = FT_Err_Ok;
goto Exit;
case 0x03:
aprop->type = BDF_PROPERTY_TYPE_CARDINAL;
aprop->u.cardinal = value;
error = FT_Err_Ok;
goto Exit;
default:
;
}
}
}
p += 10;
}
Exit:
return error;
}
#endif /* TT_CONFIG_OPTION_BDF */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttbdf.c | C | apache-2.0 | 6,989 |
/***************************************************************************/
/* */
/* ttbdf.h */
/* */
/* TrueType and OpenType embedded BDF properties (specification). */
/* */
/* Copyright 2005 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 __TTBDF_H__
#define __TTBDF_H__
#include <ft2build.h>
#include "ttload.h"
#include FT_BDF_H
FT_BEGIN_HEADER
FT_LOCAL( void )
tt_face_free_bdf_props( TT_Face face );
FT_LOCAL( FT_Error )
tt_face_find_bdf_prop( TT_Face face,
const char* property_name,
BDF_PropertyRec *aprop );
FT_END_HEADER
#endif /* __TTBDF_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttbdf.h | C | apache-2.0 | 1,672 |
/***************************************************************************/
/* */
/* ttcmap.c */
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
/* Copyright 2002-2010, 2012-2014 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include "sferrors.h" /* must come before FT_INTERNAL_VALIDATE_H */
#include FT_INTERNAL_VALIDATE_H
#include FT_INTERNAL_STREAM_H
#include "ttload.h"
#include "ttcmap.h"
#include "sfntpic.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_ttcmap
#define TT_PEEK_SHORT FT_PEEK_SHORT
#define TT_PEEK_USHORT FT_PEEK_USHORT
#define TT_PEEK_UINT24 FT_PEEK_UOFF3
#define TT_PEEK_LONG FT_PEEK_LONG
#define TT_PEEK_ULONG FT_PEEK_ULONG
#define TT_NEXT_SHORT FT_NEXT_SHORT
#define TT_NEXT_USHORT FT_NEXT_USHORT
#define TT_NEXT_UINT24 FT_NEXT_UOFF3
#define TT_NEXT_LONG FT_NEXT_LONG
#define TT_NEXT_ULONG FT_NEXT_ULONG
FT_CALLBACK_DEF( FT_Error )
tt_cmap_init( TT_CMap cmap,
FT_Byte* table )
{
cmap->data = table;
return FT_Err_Ok;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 0 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 0 */
/* length 2 USHORT table length in bytes */
/* language 4 USHORT Mac language code */
/* glyph_ids 6 BYTE[256] array of glyph indices */
/* 262 */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_0
FT_CALLBACK_DEF( FT_Error )
tt_cmap0_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_UInt length;
if ( table + 2 + 2 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
if ( table + length > valid->limit || length < 262 )
FT_INVALID_TOO_SHORT;
/* check glyph indices whenever necessary */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt n, idx;
p = table + 6;
for ( n = 0; n < 256; n++ )
{
idx = *p++;
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap0_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
return char_code < 256 ? table[6 + char_code] : 0;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap0_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_Byte* table = cmap->data;
FT_UInt32 charcode = *pchar_code;
FT_UInt32 result = 0;
FT_UInt gindex = 0;
table += 6; /* go to glyph IDs */
while ( ++charcode < 256 )
{
gindex = table[charcode];
if ( gindex != 0 )
{
result = charcode;
break;
}
}
*pchar_code = result;
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap0_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 4;
cmap_info->format = 0;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap0_class_rec,
sizeof ( TT_CMapRec ),
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap0_char_index,
(FT_CMap_CharNextFunc) tt_cmap0_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
0,
(TT_CMap_ValidateFunc)tt_cmap0_validate,
(TT_CMap_Info_GetFunc)tt_cmap0_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_0 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 2 *****/
/***** *****/
/***** This is used for certain CJK encodings that encode text in a *****/
/***** mixed 8/16 bits encoding along the following lines: *****/
/***** *****/
/***** * Certain byte values correspond to an 8-bit character code *****/
/***** (typically in the range 0..127 for ASCII compatibility). *****/
/***** *****/
/***** * Certain byte values signal the first byte of a 2-byte *****/
/***** character code (but these values are also valid as the *****/
/***** second byte of a 2-byte character). *****/
/***** *****/
/***** The following charmap lookup and iteration functions all *****/
/***** assume that the value "charcode" correspond to following: *****/
/***** *****/
/***** - For one byte characters, "charcode" is simply the *****/
/***** character code. *****/
/***** *****/
/***** - For two byte characters, "charcode" is the 2-byte *****/
/***** character code in big endian format. More exactly: *****/
/***** *****/
/***** (charcode >> 8) is the first byte value *****/
/***** (charcode & 0xFF) is the second byte value *****/
/***** *****/
/***** Note that not all values of "charcode" are valid according *****/
/***** to these rules, and the function moderately check the *****/
/***** arguments. *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 2 */
/* length 2 USHORT table length in bytes */
/* language 4 USHORT Mac language code */
/* keys 6 USHORT[256] sub-header keys */
/* subs 518 SUBHEAD[NSUBS] sub-headers array */
/* glyph_ids 518+NSUB*8 USHORT[] glyph ID array */
/* */
/* The `keys' table is used to map charcode high-bytes to sub-headers. */
/* The value of `NSUBS' is the number of sub-headers defined in the */
/* table and is computed by finding the maximum of the `keys' table. */
/* */
/* Note that for any n, `keys[n]' is a byte offset within the `subs' */
/* table, i.e., it is the corresponding sub-header index multiplied */
/* by 8. */
/* */
/* Each sub-header has the following format: */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* first 0 USHORT first valid low-byte */
/* count 2 USHORT number of valid low-bytes */
/* delta 4 SHORT see below */
/* offset 6 USHORT see below */
/* */
/* A sub-header defines, for each high-byte, the range of valid */
/* low-bytes within the charmap. Note that the range defined by `first' */
/* and `count' must be completely included in the interval [0..255] */
/* according to the specification. */
/* */
/* If a character code is contained within a given sub-header, then */
/* mapping it to a glyph index is done as follows: */
/* */
/* * The value of `offset' is read. This is a _byte_ distance from the */
/* location of the `offset' field itself into a slice of the */
/* `glyph_ids' table. Let's call it `slice' (it is a USHORT[] too). */
/* */
/* * The value `slice[char.lo - first]' is read. If it is 0, there is */
/* no glyph for the charcode. Otherwise, the value of `delta' is */
/* added to it (modulo 65536) to form a new glyph index. */
/* */
/* It is up to the validation routine to check that all offsets fall */
/* within the glyph IDs table (and not within the `subs' table itself or */
/* outside of the CMap). */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_2
FT_CALLBACK_DEF( FT_Error )
tt_cmap2_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_UInt length;
FT_UInt n, max_subs;
FT_Byte* keys; /* keys table */
FT_Byte* subs; /* sub-headers */
FT_Byte* glyph_ids; /* glyph ID array */
if ( table + 2 + 2 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
if ( table + length > valid->limit || length < 6 + 512 )
FT_INVALID_TOO_SHORT;
keys = table + 6;
/* parse keys to compute sub-headers count */
p = keys;
max_subs = 0;
for ( n = 0; n < 256; n++ )
{
FT_UInt idx = TT_NEXT_USHORT( p );
/* value must be multiple of 8 */
if ( valid->level >= FT_VALIDATE_PARANOID && ( idx & 7 ) != 0 )
FT_INVALID_DATA;
idx >>= 3;
if ( idx > max_subs )
max_subs = idx;
}
FT_ASSERT( p == table + 518 );
subs = p;
glyph_ids = subs + (max_subs + 1) * 8;
if ( glyph_ids > valid->limit )
FT_INVALID_TOO_SHORT;
/* parse sub-headers */
for ( n = 0; n <= max_subs; n++ )
{
FT_UInt first_code, code_count, offset;
FT_Int delta;
first_code = TT_NEXT_USHORT( p );
code_count = TT_NEXT_USHORT( p );
delta = TT_NEXT_SHORT( p );
offset = TT_NEXT_USHORT( p );
/* many Dynalab fonts have empty sub-headers */
if ( code_count == 0 )
continue;
/* check range within 0..255 */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
if ( first_code >= 256 || first_code + code_count > 256 )
FT_INVALID_DATA;
}
/* check offset */
if ( offset != 0 )
{
FT_Byte* ids;
ids = p - 2 + offset;
if ( ids < glyph_ids || ids + code_count*2 > table + length )
FT_INVALID_OFFSET;
/* check glyph IDs */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_Byte* limit = p + code_count * 2;
FT_UInt idx;
for ( ; p < limit; )
{
idx = TT_NEXT_USHORT( p );
if ( idx != 0 )
{
idx = ( idx + delta ) & 0xFFFFU;
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
}
return FT_Err_Ok;
}
/* return sub header corresponding to a given character code */
/* NULL on invalid charcode */
static FT_Byte*
tt_cmap2_get_subheader( FT_Byte* table,
FT_UInt32 char_code )
{
FT_Byte* result = NULL;
if ( char_code < 0x10000UL )
{
FT_UInt char_lo = (FT_UInt)( char_code & 0xFF );
FT_UInt char_hi = (FT_UInt)( char_code >> 8 );
FT_Byte* p = table + 6; /* keys table */
FT_Byte* subs = table + 518; /* subheaders table */
FT_Byte* sub;
if ( char_hi == 0 )
{
/* an 8-bit character code -- we use subHeader 0 in this case */
/* to test whether the character code is in the charmap */
/* */
sub = subs; /* jump to first sub-header */
/* check that the sub-header for this byte is 0, which */
/* indicates that it is really a valid one-byte value */
/* Otherwise, return 0 */
/* */
p += char_lo * 2;
if ( TT_PEEK_USHORT( p ) != 0 )
goto Exit;
}
else
{
/* a 16-bit character code */
/* jump to key entry */
p += char_hi * 2;
/* jump to sub-header */
sub = subs + ( FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 8 ) );
/* check that the high byte isn't a valid one-byte value */
if ( sub == subs )
goto Exit;
}
result = sub;
}
Exit:
return result;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap2_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* subheader;
subheader = tt_cmap2_get_subheader( table, char_code );
if ( subheader )
{
FT_Byte* p = subheader;
FT_UInt idx = (FT_UInt)(char_code & 0xFF);
FT_UInt start, count;
FT_Int delta;
FT_UInt offset;
start = TT_NEXT_USHORT( p );
count = TT_NEXT_USHORT( p );
delta = TT_NEXT_SHORT ( p );
offset = TT_PEEK_USHORT( p );
idx -= start;
if ( idx < count && offset != 0 )
{
p += offset + 2 * idx;
idx = TT_PEEK_USHORT( p );
if ( idx != 0 )
result = (FT_UInt)( idx + delta ) & 0xFFFFU;
}
}
return result;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap2_char_next( TT_CMap cmap,
FT_UInt32 *pcharcode )
{
FT_Byte* table = cmap->data;
FT_UInt gindex = 0;
FT_UInt32 result = 0;
FT_UInt32 charcode = *pcharcode + 1;
FT_Byte* subheader;
while ( charcode < 0x10000UL )
{
subheader = tt_cmap2_get_subheader( table, charcode );
if ( subheader )
{
FT_Byte* p = subheader;
FT_UInt start = TT_NEXT_USHORT( p );
FT_UInt count = TT_NEXT_USHORT( p );
FT_Int delta = TT_NEXT_SHORT ( p );
FT_UInt offset = TT_PEEK_USHORT( p );
FT_UInt char_lo = (FT_UInt)( charcode & 0xFF );
FT_UInt pos, idx;
if ( offset == 0 )
goto Next_SubHeader;
if ( char_lo < start )
{
char_lo = start;
pos = 0;
}
else
pos = (FT_UInt)( char_lo - start );
p += offset + pos * 2;
charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo;
for ( ; pos < count; pos++, charcode++ )
{
idx = TT_NEXT_USHORT( p );
if ( idx != 0 )
{
gindex = ( idx + delta ) & 0xFFFFU;
if ( gindex != 0 )
{
result = charcode;
goto Exit;
}
}
}
}
/* jump to next sub-header, i.e. higher byte value */
Next_SubHeader:
charcode = FT_PAD_FLOOR( charcode, 256 ) + 256;
}
Exit:
*pcharcode = result;
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap2_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 4;
cmap_info->format = 2;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap2_class_rec,
sizeof ( TT_CMapRec ),
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap2_char_index,
(FT_CMap_CharNextFunc) tt_cmap2_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
2,
(TT_CMap_ValidateFunc)tt_cmap2_validate,
(TT_CMap_Info_GetFunc)tt_cmap2_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_2 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 4 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 4 */
/* length 2 USHORT table length */
/* in bytes */
/* language 4 USHORT Mac language code */
/* */
/* segCountX2 6 USHORT 2*NUM_SEGS */
/* searchRange 8 USHORT 2*(1 << LOG_SEGS) */
/* entrySelector 10 USHORT LOG_SEGS */
/* rangeShift 12 USHORT segCountX2 - */
/* searchRange */
/* */
/* endCount 14 USHORT[NUM_SEGS] end charcode for */
/* each segment; last */
/* is 0xFFFF */
/* */
/* pad 14+NUM_SEGS*2 USHORT padding */
/* */
/* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */
/* each segment */
/* */
/* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */
/* segment */
/* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */
/* each segment; can be */
/* zero */
/* */
/* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID */
/* ranges */
/* */
/* Character codes are modelled by a series of ordered (increasing) */
/* intervals called segments. Each segment has start and end codes, */
/* provided by the `startCount' and `endCount' arrays. Segments must */
/* not overlap, and the last segment should always contain the value */
/* 0xFFFF for `endCount'. */
/* */
/* The fields `searchRange', `entrySelector' and `rangeShift' are better */
/* ignored (they are traces of over-engineering in the TrueType */
/* specification). */
/* */
/* Each segment also has a signed `delta', as well as an optional offset */
/* within the `glyphIds' table. */
/* */
/* If a segment's idOffset is 0, the glyph index corresponding to any */
/* charcode within the segment is obtained by adding the value of */
/* `idDelta' directly to the charcode, modulo 65536. */
/* */
/* Otherwise, a glyph index is taken from the glyph IDs sub-array for */
/* the segment, and the value of `idDelta' is added to it. */
/* */
/* */
/* Finally, note that a lot of fonts contain an invalid last segment, */
/* where `start' and `end' are correctly set to 0xFFFF but both `delta' */
/* and `offset' are incorrect (e.g., `opens___.ttf' which comes with */
/* OpenOffice.org). We need special code to deal with them correctly. */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_4
typedef struct TT_CMap4Rec_
{
TT_CMapRec cmap;
FT_UInt32 cur_charcode; /* current charcode */
FT_UInt cur_gindex; /* current glyph index */
FT_UInt num_ranges;
FT_UInt cur_range;
FT_UInt cur_start;
FT_UInt cur_end;
FT_Int cur_delta;
FT_Byte* cur_values;
} TT_CMap4Rec, *TT_CMap4;
FT_CALLBACK_DEF( FT_Error )
tt_cmap4_init( TT_CMap4 cmap,
FT_Byte* table )
{
FT_Byte* p;
cmap->cmap.data = table;
p = table + 6;
cmap->num_ranges = FT_PEEK_USHORT( p ) >> 1;
cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
cmap->cur_gindex = 0;
return FT_Err_Ok;
}
static FT_Int
tt_cmap4_set_range( TT_CMap4 cmap,
FT_UInt range_index )
{
FT_Byte* table = cmap->cmap.data;
FT_Byte* p;
FT_UInt num_ranges = cmap->num_ranges;
while ( range_index < num_ranges )
{
FT_UInt offset;
p = table + 14 + range_index * 2;
cmap->cur_end = FT_PEEK_USHORT( p );
p += 2 + num_ranges * 2;
cmap->cur_start = FT_PEEK_USHORT( p );
p += num_ranges * 2;
cmap->cur_delta = FT_PEEK_SHORT( p );
p += num_ranges * 2;
offset = FT_PEEK_USHORT( p );
/* some fonts have an incorrect last segment; */
/* we have to catch it */
if ( range_index >= num_ranges - 1 &&
cmap->cur_start == 0xFFFFU &&
cmap->cur_end == 0xFFFFU )
{
TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
if ( offset && p + offset + 2 > limit )
{
cmap->cur_delta = 1;
offset = 0;
}
}
if ( offset != 0xFFFFU )
{
cmap->cur_values = offset ? p + offset : NULL;
cmap->cur_range = range_index;
return 0;
}
/* we skip empty segments */
range_index++;
}
return -1;
}
/* search the index of the charcode next to cmap->cur_charcode; */
/* caller should call tt_cmap4_set_range with proper range */
/* before calling this function */
/* */
static void
tt_cmap4_next( TT_CMap4 cmap )
{
FT_UInt charcode;
if ( cmap->cur_charcode >= 0xFFFFUL )
goto Fail;
charcode = (FT_UInt)cmap->cur_charcode + 1;
if ( charcode < cmap->cur_start )
charcode = cmap->cur_start;
for ( ;; )
{
FT_Byte* values = cmap->cur_values;
FT_UInt end = cmap->cur_end;
FT_Int delta = cmap->cur_delta;
if ( charcode <= end )
{
if ( values )
{
FT_Byte* p = values + 2 * ( charcode - cmap->cur_start );
do
{
FT_UInt gindex = FT_NEXT_USHORT( p );
if ( gindex != 0 )
{
gindex = (FT_UInt)( ( gindex + delta ) & 0xFFFFU );
if ( gindex != 0 )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
return;
}
}
} while ( ++charcode <= end );
}
else
{
do
{
FT_UInt gindex = (FT_UInt)( ( charcode + delta ) & 0xFFFFU );
if ( gindex != 0 )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
return;
}
} while ( ++charcode <= end );
}
}
/* we need to find another range */
if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 )
break;
if ( charcode < cmap->cur_start )
charcode = cmap->cur_start;
}
Fail:
cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL;
cmap->cur_gindex = 0;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap4_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_UInt length;
FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids;
FT_UInt num_segs;
FT_Error error = FT_Err_Ok;
if ( table + 2 + 2 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2; /* skip format */
length = TT_NEXT_USHORT( p );
if ( length < 16 )
FT_INVALID_TOO_SHORT;
/* in certain fonts, the `length' field is invalid and goes */
/* out of bound. We try to correct this here... */
if ( table + length > valid->limit )
{
if ( valid->level >= FT_VALIDATE_TIGHT )
FT_INVALID_TOO_SHORT;
length = (FT_UInt)( valid->limit - table );
}
p = table + 6;
num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
/* check that we have an even value here */
if ( num_segs & 1 )
FT_INVALID_DATA;
}
num_segs /= 2;
if ( length < 16 + num_segs * 2 * 4 )
FT_INVALID_TOO_SHORT;
/* check the search parameters - even though we never use them */
/* */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
/* check the values of `searchRange', `entrySelector', `rangeShift' */
FT_UInt search_range = TT_NEXT_USHORT( p );
FT_UInt entry_selector = TT_NEXT_USHORT( p );
FT_UInt range_shift = TT_NEXT_USHORT( p );
if ( ( search_range | range_shift ) & 1 ) /* must be even values */
FT_INVALID_DATA;
search_range /= 2;
range_shift /= 2;
/* `search range' is the greatest power of 2 that is <= num_segs */
if ( search_range > num_segs ||
search_range * 2 < num_segs ||
search_range + range_shift != num_segs ||
search_range != ( 1U << entry_selector ) )
FT_INVALID_DATA;
}
ends = table + 14;
starts = table + 16 + num_segs * 2;
deltas = starts + num_segs * 2;
offsets = deltas + num_segs * 2;
glyph_ids = offsets + num_segs * 2;
/* check last segment; its end count value must be 0xFFFF */
if ( valid->level >= FT_VALIDATE_PARANOID )
{
p = ends + ( num_segs - 1 ) * 2;
if ( TT_PEEK_USHORT( p ) != 0xFFFFU )
FT_INVALID_DATA;
}
{
FT_UInt start, end, offset, n;
FT_UInt last_start = 0, last_end = 0;
FT_Int delta;
FT_Byte* p_start = starts;
FT_Byte* p_end = ends;
FT_Byte* p_delta = deltas;
FT_Byte* p_offset = offsets;
for ( n = 0; n < num_segs; n++ )
{
p = p_offset;
start = TT_NEXT_USHORT( p_start );
end = TT_NEXT_USHORT( p_end );
delta = TT_NEXT_SHORT( p_delta );
offset = TT_NEXT_USHORT( p_offset );
if ( start > end )
FT_INVALID_DATA;
/* this test should be performed at default validation level; */
/* unfortunately, some popular Asian fonts have overlapping */
/* ranges in their charmaps */
/* */
if ( start <= last_end && n > 0 )
{
if ( valid->level >= FT_VALIDATE_TIGHT )
FT_INVALID_DATA;
else
{
/* allow overlapping segments, provided their start points */
/* and end points, respectively, are in ascending order */
/* */
if ( last_start > start || last_end > end )
error |= TT_CMAP_FLAG_UNSORTED;
else
error |= TT_CMAP_FLAG_OVERLAPPING;
}
}
if ( offset && offset != 0xFFFFU )
{
p += offset; /* start of glyph ID array */
/* check that we point within the glyph IDs table only */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( p < glyph_ids ||
p + ( end - start + 1 ) * 2 > table + length )
FT_INVALID_DATA;
}
/* Some fonts handle the last segment incorrectly. In */
/* theory, 0xFFFF might point to an ordinary glyph -- */
/* a cmap 4 is versatile and could be used for any */
/* encoding, not only Unicode. However, reality shows */
/* that far too many fonts are sloppy and incorrectly */
/* set all fields but `start' and `end' for the last */
/* segment if it contains only a single character. */
/* */
/* We thus omit the test here, delaying it to the */
/* routines which actually access the cmap. */
else if ( n != num_segs - 1 ||
!( start == 0xFFFFU && end == 0xFFFFU ) )
{
if ( p < glyph_ids ||
p + ( end - start + 1 ) * 2 > valid->limit )
FT_INVALID_DATA;
}
/* check glyph indices within the segment range */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt i, idx;
for ( i = start; i < end; i++ )
{
idx = FT_NEXT_USHORT( p );
if ( idx != 0 )
{
idx = (FT_UInt)( idx + delta ) & 0xFFFFU;
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
else if ( offset == 0xFFFFU )
{
/* some fonts (erroneously?) use a range offset of 0xFFFF */
/* to mean missing glyph in cmap table */
/* */
if ( valid->level >= FT_VALIDATE_PARANOID ||
n != num_segs - 1 ||
!( start == 0xFFFFU && end == 0xFFFFU ) )
FT_INVALID_DATA;
}
last_start = start;
last_end = end;
}
}
return error;
}
static FT_UInt
tt_cmap4_char_map_linear( TT_CMap cmap,
FT_UInt32* pcharcode,
FT_Bool next )
{
FT_UInt num_segs2, start, end, offset;
FT_Int delta;
FT_UInt i, num_segs;
FT_UInt32 charcode = *pcharcode;
FT_UInt gindex = 0;
FT_Byte* p;
p = cmap->data + 6;
num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 );
num_segs = num_segs2 >> 1;
if ( !num_segs )
return 0;
if ( next )
charcode++;
/* linear search */
for ( ; charcode <= 0xFFFFU; charcode++ )
{
FT_Byte* q;
p = cmap->data + 14; /* ends table */
q = cmap->data + 16 + num_segs2; /* starts table */
for ( i = 0; i < num_segs; i++ )
{
end = TT_NEXT_USHORT( p );
start = TT_NEXT_USHORT( q );
if ( charcode >= start && charcode <= end )
{
p = q - 2 + num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
/* some fonts have an incorrect last segment; */
/* we have to catch it */
if ( i >= num_segs - 1 &&
start == 0xFFFFU && end == 0xFFFFU )
{
TT_Face face = (TT_Face)cmap->cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
if ( offset && p + offset + 2 > limit )
{
delta = 1;
offset = 0;
}
}
if ( offset == 0xFFFFU )
continue;
if ( offset )
{
p += offset + ( charcode - start ) * 2;
gindex = TT_PEEK_USHORT( p );
if ( gindex != 0 )
gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
}
else
gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
break;
}
}
if ( !next || gindex )
break;
}
if ( next && gindex )
*pcharcode = charcode;
return gindex;
}
static FT_UInt
tt_cmap4_char_map_binary( TT_CMap cmap,
FT_UInt32* pcharcode,
FT_Bool next )
{
FT_UInt num_segs2, start, end, offset;
FT_Int delta;
FT_UInt max, min, mid, num_segs;
FT_UInt charcode = (FT_UInt)*pcharcode;
FT_UInt gindex = 0;
FT_Byte* p;
p = cmap->data + 6;
num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 );
if ( !num_segs2 )
return 0;
num_segs = num_segs2 >> 1;
/* make compiler happy */
mid = num_segs;
end = 0xFFFFU;
if ( next )
charcode++;
min = 0;
max = num_segs;
/* binary search */
while ( min < max )
{
mid = ( min + max ) >> 1;
p = cmap->data + 14 + mid * 2;
end = TT_PEEK_USHORT( p );
p += 2 + num_segs2;
start = TT_PEEK_USHORT( p );
if ( charcode < start )
max = mid;
else if ( charcode > end )
min = mid + 1;
else
{
p += num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
/* some fonts have an incorrect last segment; */
/* we have to catch it */
if ( mid >= num_segs - 1 &&
start == 0xFFFFU && end == 0xFFFFU )
{
TT_Face face = (TT_Face)cmap->cmap.charmap.face;
FT_Byte* limit = face->cmap_table + face->cmap_size;
if ( offset && p + offset + 2 > limit )
{
delta = 1;
offset = 0;
}
}
/* search the first segment containing `charcode' */
if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING )
{
FT_UInt i;
/* call the current segment `max' */
max = mid;
if ( offset == 0xFFFFU )
mid = max + 1;
/* search in segments before the current segment */
for ( i = max ; i > 0; i-- )
{
FT_UInt prev_end;
FT_Byte* old_p;
old_p = p;
p = cmap->data + 14 + ( i - 1 ) * 2;
prev_end = TT_PEEK_USHORT( p );
if ( charcode > prev_end )
{
p = old_p;
break;
}
end = prev_end;
p += 2 + num_segs2;
start = TT_PEEK_USHORT( p );
p += num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
if ( offset != 0xFFFFU )
mid = i - 1;
}
/* no luck */
if ( mid == max + 1 )
{
if ( i != max )
{
p = cmap->data + 14 + max * 2;
end = TT_PEEK_USHORT( p );
p += 2 + num_segs2;
start = TT_PEEK_USHORT( p );
p += num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
}
mid = max;
/* search in segments after the current segment */
for ( i = max + 1; i < num_segs; i++ )
{
FT_UInt next_end, next_start;
p = cmap->data + 14 + i * 2;
next_end = TT_PEEK_USHORT( p );
p += 2 + num_segs2;
next_start = TT_PEEK_USHORT( p );
if ( charcode < next_start )
break;
end = next_end;
start = next_start;
p += num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
if ( offset != 0xFFFFU )
mid = i;
}
i--;
/* still no luck */
if ( mid == max )
{
mid = i;
break;
}
}
/* end, start, delta, and offset are for the i'th segment */
if ( mid != i )
{
p = cmap->data + 14 + mid * 2;
end = TT_PEEK_USHORT( p );
p += 2 + num_segs2;
start = TT_PEEK_USHORT( p );
p += num_segs2;
delta = TT_PEEK_SHORT( p );
p += num_segs2;
offset = TT_PEEK_USHORT( p );
}
}
else
{
if ( offset == 0xFFFFU )
break;
}
if ( offset )
{
p += offset + ( charcode - start ) * 2;
gindex = TT_PEEK_USHORT( p );
if ( gindex != 0 )
gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
}
else
gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
break;
}
}
if ( next )
{
TT_CMap4 cmap4 = (TT_CMap4)cmap;
/* if `charcode' is not in any segment, then `mid' is */
/* the segment nearest to `charcode' */
/* */
if ( charcode > end )
{
mid++;
if ( mid == num_segs )
return 0;
}
if ( tt_cmap4_set_range( cmap4, mid ) )
{
if ( gindex )
*pcharcode = charcode;
}
else
{
cmap4->cur_charcode = charcode;
if ( gindex )
cmap4->cur_gindex = gindex;
else
{
cmap4->cur_charcode = charcode;
tt_cmap4_next( cmap4 );
gindex = cmap4->cur_gindex;
}
if ( gindex )
*pcharcode = cmap4->cur_charcode;
}
}
return gindex;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap4_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
if ( char_code >= 0x10000UL )
return 0;
if ( cmap->flags & TT_CMAP_FLAG_UNSORTED )
return tt_cmap4_char_map_linear( cmap, &char_code, 0 );
else
return tt_cmap4_char_map_binary( cmap, &char_code, 0 );
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap4_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UInt gindex;
if ( *pchar_code >= 0xFFFFU )
return 0;
if ( cmap->flags & TT_CMAP_FLAG_UNSORTED )
gindex = tt_cmap4_char_map_linear( cmap, pchar_code, 1 );
else
{
TT_CMap4 cmap4 = (TT_CMap4)cmap;
/* no need to search */
if ( *pchar_code == cmap4->cur_charcode )
{
tt_cmap4_next( cmap4 );
gindex = cmap4->cur_gindex;
if ( gindex )
*pchar_code = cmap4->cur_charcode;
}
else
gindex = tt_cmap4_char_map_binary( cmap, pchar_code, 1 );
}
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap4_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 4;
cmap_info->format = 4;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap4_class_rec,
sizeof ( TT_CMap4Rec ),
(FT_CMap_InitFunc) tt_cmap4_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap4_char_index,
(FT_CMap_CharNextFunc) tt_cmap4_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
4,
(TT_CMap_ValidateFunc)tt_cmap4_validate,
(TT_CMap_Info_GetFunc)tt_cmap4_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_4 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 6 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 4 */
/* length 2 USHORT table length in bytes */
/* language 4 USHORT Mac language code */
/* */
/* first 6 USHORT first segment code */
/* count 8 USHORT segment size in chars */
/* glyphIds 10 USHORT[count] glyph IDs */
/* */
/* A very simplified segment mapping. */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_6
FT_CALLBACK_DEF( FT_Error )
tt_cmap6_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_UInt length, count;
if ( table + 10 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
length = TT_NEXT_USHORT( p );
p = table + 8; /* skip language and start index */
count = TT_NEXT_USHORT( p );
if ( table + length > valid->limit || length < 10 + count * 2 )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt gindex;
for ( ; count > 0; count-- )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap6_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 6;
FT_UInt start = TT_NEXT_USHORT( p );
FT_UInt count = TT_NEXT_USHORT( p );
FT_UInt idx = (FT_UInt)( char_code - start );
if ( idx < count )
{
p += 2 * idx;
result = TT_PEEK_USHORT( p );
}
return result;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap6_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_Byte* table = cmap->data;
FT_UInt32 result = 0;
FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0;
FT_Byte* p = table + 6;
FT_UInt start = TT_NEXT_USHORT( p );
FT_UInt count = TT_NEXT_USHORT( p );
FT_UInt idx;
if ( char_code >= 0x10000UL )
goto Exit;
if ( char_code < start )
char_code = start;
idx = (FT_UInt)( char_code - start );
p += 2 * idx;
for ( ; idx < count; idx++ )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex != 0 )
{
result = char_code;
break;
}
char_code++;
}
Exit:
*pchar_code = result;
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap6_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 4;
cmap_info->format = 6;
cmap_info->language = (FT_ULong)TT_PEEK_USHORT( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap6_class_rec,
sizeof ( TT_CMapRec ),
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap6_char_index,
(FT_CMap_CharNextFunc) tt_cmap6_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
6,
(TT_CMap_ValidateFunc)tt_cmap6_validate,
(TT_CMap_Info_GetFunc)tt_cmap6_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_6 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 8 *****/
/***** *****/
/***** It is hard to completely understand what the OpenType spec *****/
/***** says about this format, but here is my conclusion. *****/
/***** *****/
/***** The purpose of this format is to easily map UTF-16 text to *****/
/***** glyph indices. Basically, the `char_code' must be in one of *****/
/***** the following formats: *****/
/***** *****/
/***** - A 16-bit value that isn't part of the Unicode Surrogates *****/
/***** Area (i.e. U+D800-U+DFFF). *****/
/***** *****/
/***** - A 32-bit value, made of two surrogate values, i.e.. if *****/
/***** `char_code = (char_hi << 16) | char_lo', then both *****/
/***** `char_hi' and `char_lo' must be in the Surrogates Area. *****/
/***** Area. *****/
/***** *****/
/***** The `is32' table embedded in the charmap indicates whether a *****/
/***** given 16-bit value is in the surrogates area or not. *****/
/***** *****/
/***** So, for any given `char_code', we can assert the following: *****/
/***** *****/
/***** If `char_hi == 0' then we must have `is32[char_lo] == 0'. *****/
/***** *****/
/***** If `char_hi != 0' then we must have both *****/
/***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 8 */
/* reserved 2 USHORT reserved */
/* length 4 ULONG length in bytes */
/* language 8 ULONG Mac language code */
/* is32 12 BYTE[8192] 32-bitness bitmap */
/* count 8204 ULONG number of groups */
/* */
/* This header is followed by `count' groups of the following format: */
/* */
/* start 0 ULONG first charcode */
/* end 4 ULONG last charcode */
/* startId 8 ULONG start glyph ID for the group */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_8
FT_CALLBACK_DEF( FT_Error )
tt_cmap8_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_Byte* is32;
FT_UInt32 length;
FT_UInt32 num_groups;
if ( table + 16 + 8192 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
if ( length > (FT_UInt32)( valid->limit - table ) || length < 8192 + 16 )
FT_INVALID_TOO_SHORT;
is32 = table + 12;
p = is32 + 8192; /* skip `is32' array */
num_groups = TT_NEXT_ULONG( p );
if ( p + num_groups * 12 > valid->limit )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_UInt32 n, start, end, start_id, count, last = 0;
for ( n = 0; n < num_groups; n++ )
{
FT_UInt hi, lo;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
count = (FT_UInt32)( end - start + 1 );
if ( start & ~0xFFFFU )
{
/* start_hi != 0; check that is32[i] is 1 for each i in */
/* the `hi' and `lo' of the range [start..end] */
for ( ; count > 0; count--, start++ )
{
hi = (FT_UInt)( start >> 16 );
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[hi >> 3] & ( 0x80 >> ( hi & 7 ) ) ) == 0 )
FT_INVALID_DATA;
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) == 0 )
FT_INVALID_DATA;
}
}
else
{
/* start_hi == 0; check that is32[i] is 0 for each i in */
/* the range [start..end] */
/* end_hi cannot be != 0! */
if ( end & ~0xFFFFU )
FT_INVALID_DATA;
for ( ; count > 0; count--, start++ )
{
lo = (FT_UInt)( start & 0xFFFFU );
if ( (is32[lo >> 3] & ( 0x80 >> ( lo & 7 ) ) ) != 0 )
FT_INVALID_DATA;
}
}
}
last = end;
}
}
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap8_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 8204;
FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 start, end, start_id;
for ( ; num_groups > 0; num_groups-- )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
break;
if ( char_code <= end )
{
result = (FT_UInt)( start_id + char_code - start );
break;
}
}
return result;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap8_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UInt32 result = 0;
FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0;
FT_Byte* table = cmap->data;
FT_Byte* p = table + 8204;
FT_UInt32 num_groups = TT_NEXT_ULONG( p );
FT_UInt32 start, end, start_id;
p = table + 8208;
for ( ; num_groups > 0; num_groups-- )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( char_code < start )
char_code = start;
if ( char_code <= end )
{
gindex = (FT_UInt)( char_code - start + start_id );
if ( gindex != 0 )
{
result = char_code;
goto Exit;
}
}
}
Exit:
*pchar_code = result;
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap8_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 8;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap8_class_rec,
sizeof ( TT_CMapRec ),
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap8_char_index,
(FT_CMap_CharNextFunc) tt_cmap8_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
8,
(TT_CMap_ValidateFunc)tt_cmap8_validate,
(TT_CMap_Info_GetFunc)tt_cmap8_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_8 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 10 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 10 */
/* reserved 2 USHORT reserved */
/* length 4 ULONG length in bytes */
/* language 8 ULONG Mac language code */
/* */
/* start 12 ULONG first char in range */
/* count 16 ULONG number of chars in range */
/* glyphIds 20 USHORT[count] glyph indices covered */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_10
FT_CALLBACK_DEF( FT_Error )
tt_cmap10_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p = table + 4;
FT_ULong length, count;
if ( table + 20 > valid->limit )
FT_INVALID_TOO_SHORT;
length = TT_NEXT_ULONG( p );
p = table + 16;
count = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
length < 20 + count * 2 )
FT_INVALID_TOO_SHORT;
/* check glyph indices */
if ( valid->level >= FT_VALIDATE_TIGHT )
{
FT_UInt gindex;
for ( ; count > 0; count-- )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap10_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_Byte* table = cmap->data;
FT_UInt result = 0;
FT_Byte* p = table + 12;
FT_UInt32 start = TT_NEXT_ULONG( p );
FT_UInt32 count = TT_NEXT_ULONG( p );
FT_UInt32 idx = (FT_ULong)( char_code - start );
if ( idx < count )
{
p += 2 * idx;
result = TT_PEEK_USHORT( p );
}
return result;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap10_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_Byte* table = cmap->data;
FT_UInt32 char_code = *pchar_code + 1;
FT_UInt gindex = 0;
FT_Byte* p = table + 12;
FT_UInt32 start = TT_NEXT_ULONG( p );
FT_UInt32 count = TT_NEXT_ULONG( p );
FT_UInt32 idx;
if ( char_code < start )
char_code = start;
idx = (FT_UInt32)( char_code - start );
p += 2 * idx;
for ( ; idx < count; idx++ )
{
gindex = TT_NEXT_USHORT( p );
if ( gindex != 0 )
break;
char_code++;
}
*pchar_code = char_code;
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap10_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 10;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap10_class_rec,
sizeof ( TT_CMapRec ),
(FT_CMap_InitFunc) tt_cmap_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap10_char_index,
(FT_CMap_CharNextFunc) tt_cmap10_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
10,
(TT_CMap_ValidateFunc)tt_cmap10_validate,
(TT_CMap_Info_GetFunc)tt_cmap10_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_10 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 12 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 12 */
/* reserved 2 USHORT reserved */
/* length 4 ULONG length in bytes */
/* language 8 ULONG Mac language code */
/* count 12 ULONG number of groups */
/* 16 */
/* */
/* This header is followed by `count' groups of the following format: */
/* */
/* start 0 ULONG first charcode */
/* end 4 ULONG last charcode */
/* startId 8 ULONG start glyph ID for the group */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_12
typedef struct TT_CMap12Rec_
{
TT_CMapRec cmap;
FT_Bool valid;
FT_ULong cur_charcode;
FT_UInt cur_gindex;
FT_ULong cur_group;
FT_ULong num_groups;
} TT_CMap12Rec, *TT_CMap12;
FT_CALLBACK_DEF( FT_Error )
tt_cmap12_init( TT_CMap12 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap12_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
length < 16 + 12 * num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, start_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( start_id + end - start >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
/* search the index of the charcode next to cmap->cur_charcode */
/* cmap->cur_group should be set up properly by caller */
/* */
static void
tt_cmap12_next( TT_CMap12 cmap )
{
FT_Byte* p;
FT_ULong start, end, start_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
start_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
for ( ; char_code <= end; char_code++ )
{
gindex = (FT_UInt)( start_id + char_code - start );
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
static FT_UInt
tt_cmap12_char_map_binary( TT_CMap cmap,
FT_UInt32* pchar_code,
FT_Bool next )
{
FT_UInt gindex = 0;
FT_Byte* p = cmap->data + 12;
FT_UInt32 num_groups = TT_PEEK_ULONG( p );
FT_UInt32 char_code = *pchar_code;
FT_UInt32 start, end, start_id;
FT_UInt32 max, min, mid;
if ( !num_groups )
return 0;
/* make compiler happy */
mid = num_groups;
end = 0xFFFFFFFFUL;
if ( next )
char_code++;
min = 0;
max = num_groups;
/* binary search */
while ( min < max )
{
mid = ( min + max ) >> 1;
p = cmap->data + 16 + 12 * mid;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
if ( char_code < start )
max = mid;
else if ( char_code > end )
min = mid + 1;
else
{
start_id = TT_PEEK_ULONG( p );
gindex = (FT_UInt)( start_id + char_code - start );
break;
}
}
if ( next )
{
TT_CMap12 cmap12 = (TT_CMap12)cmap;
/* if `char_code' is not in any group, then `mid' is */
/* the group nearest to `char_code' */
/* */
if ( char_code > end )
{
mid++;
if ( mid == num_groups )
return 0;
}
cmap12->valid = 1;
cmap12->cur_charcode = char_code;
cmap12->cur_group = mid;
if ( !gindex )
{
tt_cmap12_next( cmap12 );
if ( cmap12->valid )
gindex = cmap12->cur_gindex;
}
else
cmap12->cur_gindex = gindex;
if ( gindex )
*pchar_code = cmap12->cur_charcode;
}
return gindex;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap12_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap12_char_map_binary( cmap, &char_code, 0 );
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap12_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap12 cmap12 = (TT_CMap12)cmap;
FT_ULong gindex;
if ( cmap12->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap12->valid && cmap12->cur_charcode == *pchar_code )
{
tt_cmap12_next( cmap12 );
if ( cmap12->valid )
{
gindex = cmap12->cur_gindex;
/* XXX: check cur_charcode overflow is expected */
if ( gindex )
*pchar_code = (FT_UInt32)cmap12->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 );
/* XXX: check gindex overflow is expected */
return (FT_UInt32)gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap12_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 12;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap12_class_rec,
sizeof ( TT_CMap12Rec ),
(FT_CMap_InitFunc) tt_cmap12_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap12_char_index,
(FT_CMap_CharNextFunc) tt_cmap12_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
12,
(TT_CMap_ValidateFunc)tt_cmap12_validate,
(TT_CMap_Info_GetFunc)tt_cmap12_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_12 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 13 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 13 */
/* reserved 2 USHORT reserved */
/* length 4 ULONG length in bytes */
/* language 8 ULONG Mac language code */
/* count 12 ULONG number of groups */
/* 16 */
/* */
/* This header is followed by `count' groups of the following format: */
/* */
/* start 0 ULONG first charcode */
/* end 4 ULONG last charcode */
/* glyphId 8 ULONG glyph ID for the whole group */
/* */
#ifdef TT_CONFIG_CMAP_FORMAT_13
typedef struct TT_CMap13Rec_
{
TT_CMapRec cmap;
FT_Bool valid;
FT_ULong cur_charcode;
FT_UInt cur_gindex;
FT_ULong cur_group;
FT_ULong num_groups;
} TT_CMap13Rec, *TT_CMap13;
FT_CALLBACK_DEF( FT_Error )
tt_cmap13_init( TT_CMap13 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 12;
cmap->num_groups = FT_PEEK_ULONG( table );
cmap->valid = 0;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap13_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_groups;
if ( table + 16 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 4;
length = TT_NEXT_ULONG( p );
p = table + 12;
num_groups = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
length < 16 + 12 * num_groups )
FT_INVALID_TOO_SHORT;
/* check groups, they must be in increasing order */
{
FT_ULong n, start, end, glyph_id, last = 0;
for ( n = 0; n < num_groups; n++ )
{
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_NEXT_ULONG( p );
if ( start > end )
FT_INVALID_DATA;
if ( n > 0 && start <= last )
FT_INVALID_DATA;
if ( valid->level >= FT_VALIDATE_TIGHT )
{
if ( glyph_id >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
last = end;
}
}
return FT_Err_Ok;
}
/* search the index of the charcode next to cmap->cur_charcode */
/* cmap->cur_group should be set up properly by caller */
/* */
static void
tt_cmap13_next( TT_CMap13 cmap )
{
FT_Byte* p;
FT_ULong start, end, glyph_id, char_code;
FT_ULong n;
FT_UInt gindex;
if ( cmap->cur_charcode >= 0xFFFFFFFFUL )
goto Fail;
char_code = cmap->cur_charcode + 1;
for ( n = cmap->cur_group; n < cmap->num_groups; n++ )
{
p = cmap->cmap.data + 16 + 12 * n;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
glyph_id = TT_PEEK_ULONG( p );
if ( char_code < start )
char_code = start;
if ( char_code <= end )
{
gindex = (FT_UInt)glyph_id;
if ( gindex )
{
cmap->cur_charcode = char_code;;
cmap->cur_gindex = gindex;
cmap->cur_group = n;
return;
}
}
}
Fail:
cmap->valid = 0;
}
static FT_UInt
tt_cmap13_char_map_binary( TT_CMap cmap,
FT_UInt32* pchar_code,
FT_Bool next )
{
FT_UInt gindex = 0;
FT_Byte* p = cmap->data + 12;
FT_UInt32 num_groups = TT_PEEK_ULONG( p );
FT_UInt32 char_code = *pchar_code;
FT_UInt32 start, end;
FT_UInt32 max, min, mid;
if ( !num_groups )
return 0;
/* make compiler happy */
mid = num_groups;
end = 0xFFFFFFFFUL;
if ( next )
char_code++;
min = 0;
max = num_groups;
/* binary search */
while ( min < max )
{
mid = ( min + max ) >> 1;
p = cmap->data + 16 + 12 * mid;
start = TT_NEXT_ULONG( p );
end = TT_NEXT_ULONG( p );
if ( char_code < start )
max = mid;
else if ( char_code > end )
min = mid + 1;
else
{
gindex = (FT_UInt)TT_PEEK_ULONG( p );
break;
}
}
if ( next )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
/* if `char_code' is not in any group, then `mid' is */
/* the group nearest to `char_code' */
if ( char_code > end )
{
mid++;
if ( mid == num_groups )
return 0;
}
cmap13->valid = 1;
cmap13->cur_charcode = char_code;
cmap13->cur_group = mid;
if ( !gindex )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
gindex = cmap13->cur_gindex;
}
else
cmap13->cur_gindex = gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
return gindex;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap13_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
return tt_cmap13_char_map_binary( cmap, &char_code, 0 );
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap13_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
TT_CMap13 cmap13 = (TT_CMap13)cmap;
FT_UInt gindex;
if ( cmap13->cur_charcode >= 0xFFFFFFFFUL )
return 0;
/* no need to search */
if ( cmap13->valid && cmap13->cur_charcode == *pchar_code )
{
tt_cmap13_next( cmap13 );
if ( cmap13->valid )
{
gindex = cmap13->cur_gindex;
if ( gindex )
*pchar_code = cmap13->cur_charcode;
}
else
gindex = 0;
}
else
gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 );
return gindex;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap13_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_Byte* p = cmap->data + 8;
cmap_info->format = 13;
cmap_info->language = (FT_ULong)TT_PEEK_ULONG( p );
return FT_Err_Ok;
}
FT_DEFINE_TT_CMAP(
tt_cmap13_class_rec,
sizeof ( TT_CMap13Rec ),
(FT_CMap_InitFunc) tt_cmap13_init,
(FT_CMap_DoneFunc) NULL,
(FT_CMap_CharIndexFunc)tt_cmap13_char_index,
(FT_CMap_CharNextFunc) tt_cmap13_char_next,
NULL,
NULL,
NULL,
NULL,
NULL,
13,
(TT_CMap_ValidateFunc)tt_cmap13_validate,
(TT_CMap_Info_GetFunc)tt_cmap13_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_13 */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** FORMAT 14 *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* TABLE OVERVIEW */
/* -------------- */
/* */
/* NAME OFFSET TYPE DESCRIPTION */
/* */
/* format 0 USHORT must be 14 */
/* length 2 ULONG table length in bytes */
/* numSelector 6 ULONG number of variation sel. records */
/* */
/* Followed by numSelector records, each of which looks like */
/* */
/* varSelector 0 UINT24 Unicode codepoint of sel. */
/* defaultOff 3 ULONG offset to a default UVS table */
/* describing any variants to be found in */
/* the normal Unicode subtable. */
/* nonDefOff 7 ULONG offset to a non-default UVS table */
/* describing any variants not in the */
/* standard cmap, with GIDs here */
/* (either offset may be 0 NULL) */
/* */
/* Selectors are sorted by code point. */
/* */
/* A default Unicode Variation Selector (UVS) subtable is just a list of */
/* ranges of code points which are to be found in the standard cmap. No */
/* glyph IDs (GIDs) here. */
/* */
/* numRanges 0 ULONG number of ranges following */
/* */
/* A range looks like */
/* */
/* uniStart 0 UINT24 code point of the first character in */
/* this range */
/* additionalCnt 3 UBYTE count of additional characters in this */
/* range (zero means a range of a single */
/* character) */
/* */
/* Ranges are sorted by `uniStart'. */
/* */
/* A non-default Unicode Variation Selector (UVS) subtable is a list of */
/* mappings from codepoint to GID. */
/* */
/* numMappings 0 ULONG number of mappings */
/* */
/* A range looks like */
/* */
/* uniStart 0 UINT24 code point of the first character in */
/* this range */
/* GID 3 USHORT and its GID */
/* */
/* Ranges are sorted by `uniStart'. */
#ifdef TT_CONFIG_CMAP_FORMAT_14
typedef struct TT_CMap14Rec_
{
TT_CMapRec cmap;
FT_ULong num_selectors;
/* This array is used to store the results of various
* cmap 14 query functions. The data is overwritten
* on each call to these functions.
*/
FT_UInt32 max_results;
FT_UInt32* results;
FT_Memory memory;
} TT_CMap14Rec, *TT_CMap14;
FT_CALLBACK_DEF( void )
tt_cmap14_done( TT_CMap14 cmap )
{
FT_Memory memory = cmap->memory;
cmap->max_results = 0;
if ( memory != NULL && cmap->results != NULL )
FT_FREE( cmap->results );
}
static FT_Error
tt_cmap14_ensure( TT_CMap14 cmap,
FT_UInt32 num_results,
FT_Memory memory )
{
FT_UInt32 old_max = cmap->max_results;
FT_Error error = FT_Err_Ok;
if ( num_results > cmap->max_results )
{
cmap->memory = memory;
if ( FT_QRENEW_ARRAY( cmap->results, old_max, num_results ) )
return error;
cmap->max_results = num_results;
}
return error;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_init( TT_CMap14 cmap,
FT_Byte* table )
{
cmap->cmap.data = table;
table += 6;
cmap->num_selectors = FT_PEEK_ULONG( table );
cmap->max_results = 0;
cmap->results = NULL;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_validate( FT_Byte* table,
FT_Validator valid )
{
FT_Byte* p;
FT_ULong length;
FT_ULong num_selectors;
if ( table + 2 + 4 + 4 > valid->limit )
FT_INVALID_TOO_SHORT;
p = table + 2;
length = TT_NEXT_ULONG( p );
num_selectors = TT_NEXT_ULONG( p );
if ( length > (FT_ULong)( valid->limit - table ) ||
length < 10 + 11 * num_selectors )
FT_INVALID_TOO_SHORT;
/* check selectors, they must be in increasing order */
{
/* we start lastVarSel at 1 because a variant selector value of 0
* isn't valid.
*/
FT_ULong n, lastVarSel = 1;
for ( n = 0; n < num_selectors; n++ )
{
FT_ULong varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( defOff >= length || nondefOff >= length )
FT_INVALID_TOO_SHORT;
if ( varSel < lastVarSel )
FT_INVALID_DATA;
lastVarSel = varSel + 1;
/* check the default table (these glyphs should be reached */
/* through the normal Unicode cmap, no GIDs, just check order) */
if ( defOff != 0 )
{
FT_Byte* defp = table + defOff;
FT_ULong numRanges = TT_NEXT_ULONG( defp );
FT_ULong i;
FT_ULong lastBase = 0;
if ( defp + numRanges * 4 > valid->limit )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numRanges; ++i )
{
FT_ULong base = TT_NEXT_UINT24( defp );
FT_ULong cnt = FT_NEXT_BYTE( defp );
if ( base + cnt >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( base < lastBase )
FT_INVALID_DATA;
lastBase = base + cnt + 1U;
}
}
/* and the non-default table (these glyphs are specified here) */
if ( nondefOff != 0 )
{
FT_Byte* ndp = table + nondefOff;
FT_ULong numMappings = TT_NEXT_ULONG( ndp );
FT_ULong i, lastUni = 0;
if ( numMappings * 4 > (FT_ULong)( valid->limit - ndp ) )
FT_INVALID_TOO_SHORT;
for ( i = 0; i < numMappings; ++i )
{
FT_ULong uni = TT_NEXT_UINT24( ndp );
FT_ULong gid = TT_NEXT_USHORT( ndp );
if ( uni >= 0x110000UL ) /* end of Unicode */
FT_INVALID_DATA;
if ( uni < lastUni )
FT_INVALID_DATA;
lastUni = uni + 1U;
if ( valid->level >= FT_VALIDATE_TIGHT &&
gid >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
}
}
}
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_index( TT_CMap cmap,
FT_UInt32 char_code )
{
FT_UNUSED( cmap );
FT_UNUSED( char_code );
/* This can't happen */
return 0;
}
FT_CALLBACK_DEF( FT_UInt32 )
tt_cmap14_char_next( TT_CMap cmap,
FT_UInt32 *pchar_code )
{
FT_UNUSED( cmap );
/* This can't happen */
*pchar_code = 0;
return 0;
}
FT_CALLBACK_DEF( FT_Error )
tt_cmap14_get_info( TT_CMap cmap,
TT_CMapInfo *cmap_info )
{
FT_UNUSED( cmap );
cmap_info->format = 14;
/* subtable 14 does not define a language field */
cmap_info->language = 0xFFFFFFFFUL;
return FT_Err_Ok;
}
static FT_UInt
tt_cmap14_char_map_def_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numRanges = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numRanges;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 4 * mid;
FT_ULong start = TT_NEXT_UINT24( p );
FT_UInt cnt = FT_NEXT_BYTE( p );
if ( char_code < start )
max = mid;
else if ( char_code > start+cnt )
min = mid + 1;
else
return TRUE;
}
return FALSE;
}
static FT_UInt
tt_cmap14_char_map_nondef_binary( FT_Byte *base,
FT_UInt32 char_code )
{
FT_UInt32 numMappings = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numMappings;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 5 * mid;
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
if ( char_code < uni )
max = mid;
else if ( char_code > uni )
min = mid + 1;
else
return TT_PEEK_USHORT( p );
}
return 0;
}
static FT_Byte*
tt_cmap14_find_variant( FT_Byte *base,
FT_UInt32 variantCode )
{
FT_UInt32 numVar = TT_PEEK_ULONG( base );
FT_UInt32 max, min;
min = 0;
max = numVar;
base += 4;
/* binary search */
while ( min < max )
{
FT_UInt32 mid = ( min + max ) >> 1;
FT_Byte* p = base + 11 * mid;
FT_ULong varSel = TT_NEXT_UINT24( p );
if ( variantCode < varSel )
max = mid;
else if ( variantCode > varSel )
min = mid + 1;
else
return p;
}
return NULL;
}
FT_CALLBACK_DEF( FT_UInt )
tt_cmap14_char_var_index( TT_CMap cmap,
TT_CMap ucmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return 0;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_PEEK_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
{
/* This is the default variant of this charcode. GID not stored */
/* here; stored in the normal Unicode charmap instead. */
return ucmap->cmap.clazz->char_index( &ucmap->cmap, charcode );
}
if ( nondefOff != 0 )
return tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode );
return 0;
}
FT_CALLBACK_DEF( FT_Int )
tt_cmap14_char_var_isdefault( TT_CMap cmap,
FT_UInt32 charcode,
FT_UInt32 variantSelector )
{
FT_Byte* p = tt_cmap14_find_variant( cmap->data + 6, variantSelector );
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return -1;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff, charcode ) )
return 1;
if ( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charcode ) != 0 )
return 0;
return -1;
}
FT_CALLBACK_DEF( FT_UInt32* )
tt_cmap14_variants( TT_CMap cmap,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14)cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* result;
FT_UInt32 i;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
result = cmap14->results;
for ( i = 0; i < count; ++i )
{
result[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 8;
}
result[i] = 0;
return result;
}
FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_char_variants( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 charCode )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 count = cmap14->num_selectors;
FT_Byte* p = cmap->data + 10;
FT_UInt32* q;
if ( tt_cmap14_ensure( cmap14, ( count + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; count > 0; --count )
{
FT_UInt32 varSel = TT_NEXT_UINT24( p );
FT_ULong defOff = TT_NEXT_ULONG( p );
FT_ULong nondefOff = TT_NEXT_ULONG( p );
if ( ( defOff != 0 &&
tt_cmap14_char_map_def_binary( cmap->data + defOff,
charCode ) ) ||
( nondefOff != 0 &&
tt_cmap14_char_map_nondef_binary( cmap->data + nondefOff,
charCode ) != 0 ) )
{
q[0] = varSel;
q++;
}
}
q[0] = 0;
return cmap14->results;
}
static FT_UInt
tt_cmap14_def_char_count( FT_Byte *p )
{
FT_UInt32 numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
FT_UInt tot = 0;
p += 3; /* point to the first `cnt' field */
for ( ; numRanges > 0; numRanges-- )
{
tot += 1 + p[0];
p += 4;
}
return tot;
}
static FT_UInt32*
tt_cmap14_get_def_chars( TT_CMap cmap,
FT_Byte* p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt cnt;
FT_UInt32* q;
cnt = tt_cmap14_def_char_count( p );
numRanges = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( cnt + 1 ), memory ) )
return NULL;
for ( q = cmap14->results; numRanges > 0; --numRanges )
{
FT_UInt32 uni = (FT_UInt32)TT_NEXT_UINT24( p );
cnt = FT_NEXT_BYTE( p ) + 1;
do
{
q[0] = uni;
uni += 1;
q += 1;
} while ( --cnt != 0 );
}
q[0] = 0;
return cmap14->results;
}
static FT_UInt32*
tt_cmap14_get_nondef_chars( TT_CMap cmap,
FT_Byte *p,
FT_Memory memory )
{
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numMappings;
FT_UInt i;
FT_UInt32 *ret;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
if ( tt_cmap14_ensure( cmap14, ( numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
for ( i = 0; i < numMappings; ++i )
{
ret[i] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
ret[i] = 0;
return ret;
}
FT_CALLBACK_DEF( FT_UInt32 * )
tt_cmap14_variant_chars( TT_CMap cmap,
FT_Memory memory,
FT_UInt32 variantSelector )
{
FT_Byte *p = tt_cmap14_find_variant( cmap->data + 6,
variantSelector );
FT_Int i;
FT_ULong defOff;
FT_ULong nondefOff;
if ( !p )
return NULL;
defOff = TT_NEXT_ULONG( p );
nondefOff = TT_NEXT_ULONG( p );
if ( defOff == 0 && nondefOff == 0 )
return NULL;
if ( defOff == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
else if ( nondefOff == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
else
{
/* Both a default and a non-default glyph set? That's probably not */
/* good font design, but the spec allows for it... */
TT_CMap14 cmap14 = (TT_CMap14) cmap;
FT_UInt32 numRanges;
FT_UInt32 numMappings;
FT_UInt32 duni;
FT_UInt32 dcnt;
FT_UInt32 nuni;
FT_Byte* dp;
FT_UInt di, ni, k;
FT_UInt32 *ret;
p = cmap->data + nondefOff;
dp = cmap->data + defOff;
numMappings = (FT_UInt32)TT_NEXT_ULONG( p );
dcnt = tt_cmap14_def_char_count( dp );
numRanges = (FT_UInt32)TT_NEXT_ULONG( dp );
if ( numMappings == 0 )
return tt_cmap14_get_def_chars( cmap, cmap->data + defOff,
memory );
if ( dcnt == 0 )
return tt_cmap14_get_nondef_chars( cmap, cmap->data + nondefOff,
memory );
if ( tt_cmap14_ensure( cmap14, ( dcnt + numMappings + 1 ), memory ) )
return NULL;
ret = cmap14->results;
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
di = 1;
nuni = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
ni = 1;
i = 0;
for ( ;; )
{
if ( nuni > duni + dcnt )
{
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
if ( di > numRanges )
break;
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
}
else
{
if ( nuni < duni )
ret[i++] = nuni;
/* If it is within the default range then ignore it -- */
/* that should not have happened */
++ni;
if ( ni > numMappings )
break;
nuni = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
}
}
if ( ni <= numMappings )
{
/* If we get here then we have run out of all default ranges. */
/* We have read one non-default mapping which we haven't stored */
/* and there may be others that need to be read. */
ret[i++] = nuni;
while ( ni < numMappings )
{
ret[i++] = (FT_UInt32)TT_NEXT_UINT24( p );
p += 2;
++ni;
}
}
else if ( di <= numRanges )
{
/* If we get here then we have run out of all non-default */
/* mappings. We have read one default range which we haven't */
/* stored and there may be others that need to be read. */
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
while ( di < numRanges )
{
duni = (FT_UInt32)TT_NEXT_UINT24( dp );
dcnt = FT_NEXT_BYTE( dp );
for ( k = 0; k <= dcnt; ++k )
ret[i++] = duni + k;
++di;
}
}
ret[i] = 0;
return ret;
}
}
FT_DEFINE_TT_CMAP(
tt_cmap14_class_rec,
sizeof ( TT_CMap14Rec ),
(FT_CMap_InitFunc) tt_cmap14_init,
(FT_CMap_DoneFunc) tt_cmap14_done,
(FT_CMap_CharIndexFunc)tt_cmap14_char_index,
(FT_CMap_CharNextFunc) tt_cmap14_char_next,
/* Format 14 extension functions */
(FT_CMap_CharVarIndexFunc) tt_cmap14_char_var_index,
(FT_CMap_CharVarIsDefaultFunc)tt_cmap14_char_var_isdefault,
(FT_CMap_VariantListFunc) tt_cmap14_variants,
(FT_CMap_CharVariantListFunc) tt_cmap14_char_variants,
(FT_CMap_VariantCharListFunc) tt_cmap14_variant_chars,
14,
(TT_CMap_ValidateFunc)tt_cmap14_validate,
(TT_CMap_Info_GetFunc)tt_cmap14_get_info )
#endif /* TT_CONFIG_CMAP_FORMAT_14 */
#ifndef FT_CONFIG_OPTION_PIC
static const TT_CMap_Class tt_cmap_classes[] =
{
#define TTCMAPCITEM( a ) &a,
#include "ttcmapc.h"
NULL,
};
#else /*FT_CONFIG_OPTION_PIC*/
void
FT_Destroy_Class_tt_cmap_classes( FT_Library library,
TT_CMap_Class* clazz )
{
FT_Memory memory = library->memory;
if ( clazz )
FT_FREE( clazz );
}
FT_Error
FT_Create_Class_tt_cmap_classes( FT_Library library,
TT_CMap_Class** output_class )
{
TT_CMap_Class* clazz = NULL;
TT_CMap_ClassRec* recs;
FT_Error error;
FT_Memory memory = library->memory;
int i = 0;
#define TTCMAPCITEM( a ) i++;
#include "ttcmapc.h"
/* allocate enough space for both the pointers */
/* plus terminator and the class instances */
if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) +
sizeof ( TT_CMap_ClassRec ) * i ) )
return error;
/* the location of the class instances follows the array of pointers */
recs = (TT_CMap_ClassRec*)( (char*)clazz +
sizeof ( *clazz ) * ( i + 1 ) );
i = 0;
#undef TTCMAPCITEM
#define TTCMAPCITEM( a ) \
FT_Init_Class_ ## a( &recs[i] ); \
clazz[i] = &recs[i]; \
i++;
#include "ttcmapc.h"
clazz[i] = NULL;
*output_class = clazz;
return FT_Err_Ok;
}
#endif /*FT_CONFIG_OPTION_PIC*/
/* parse the `cmap' table and build the corresponding TT_CMap objects */
/* in the current face */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_build_cmaps( TT_Face face )
{
FT_Byte* table = face->cmap_table;
FT_Byte* limit = table + face->cmap_size;
FT_UInt volatile num_cmaps;
FT_Byte* volatile p = table;
FT_Library library = FT_FACE_LIBRARY( face );
FT_UNUSED( library );
if ( !p || p + 4 > limit )
return FT_THROW( Invalid_Table );
/* only recognize format 0 */
if ( TT_NEXT_USHORT( p ) != 0 )
{
p -= 2;
FT_ERROR(( "tt_face_build_cmaps:"
" unsupported `cmap' table format = %d\n",
TT_PEEK_USHORT( p ) ));
return FT_THROW( Invalid_Table );
}
num_cmaps = TT_NEXT_USHORT( p );
#ifdef FT_MAX_CHARMAP_CACHEABLE
if ( num_cmaps > FT_MAX_CHARMAP_CACHEABLE )
FT_ERROR(( "tt_face_build_cmaps: too many cmap subtables (%d)\n"
" subtable #%d and higher are loaded"
" but cannot be searched\n",
num_cmaps, FT_MAX_CHARMAP_CACHEABLE + 1 ));
#endif
for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
{
FT_CharMapRec charmap;
FT_UInt32 offset;
charmap.platform_id = TT_NEXT_USHORT( p );
charmap.encoding_id = TT_NEXT_USHORT( p );
charmap.face = FT_FACE( face );
charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
offset = TT_NEXT_ULONG( p );
if ( offset && offset <= face->cmap_size - 2 )
{
FT_Byte* volatile cmap = table + offset;
volatile FT_UInt format = TT_PEEK_USHORT( cmap );
const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET;
TT_CMap_Class volatile clazz;
for ( ; *pclazz; pclazz++ )
{
clazz = *pclazz;
if ( clazz->format == format )
{
volatile TT_ValidatorRec valid;
volatile FT_Error error = FT_Err_Ok;
ft_validator_init( FT_VALIDATOR( &valid ), cmap, limit,
FT_VALIDATE_DEFAULT );
valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
{
/* validate this cmap sub-table */
error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
}
if ( valid.validator.error == 0 )
{
FT_CMap ttcmap;
/* It might make sense to store the single variation */
/* selector cmap somewhere special. But it would have to be */
/* in the public FT_FaceRec, and we can't change that. */
if ( !FT_CMap_New( (FT_CMap_Class)clazz,
cmap, &charmap, &ttcmap ) )
{
/* it is simpler to directly set `flags' than adding */
/* a parameter to FT_CMap_New */
((TT_CMap)ttcmap)->flags = (FT_Int)error;
}
}
else
{
FT_TRACE0(( "tt_face_build_cmaps:"
" broken cmap sub-table ignored\n" ));
}
break;
}
}
if ( *pclazz == NULL )
{
FT_TRACE0(( "tt_face_build_cmaps:"
" unsupported cmap sub-table ignored\n" ));
}
}
}
return FT_Err_Ok;
}
FT_LOCAL( FT_Error )
tt_get_cmap_info( FT_CharMap charmap,
TT_CMapInfo *cmap_info )
{
FT_CMap cmap = (FT_CMap)charmap;
TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
return clazz->get_cmap_info( charmap, cmap_info );
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttcmap.c | C | apache-2.0 | 107,235 |
/***************************************************************************/
/* */
/* ttcmap.h */
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
/* Copyright 2002-2005, 2009, 2012 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 __TTCMAP_H__
#define __TTCMAP_H__
#include <ft2build.h>
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_VALIDATE_H
#include FT_SERVICE_TT_CMAP_H
FT_BEGIN_HEADER
#define TT_CMAP_FLAG_UNSORTED 1
#define TT_CMAP_FLAG_OVERLAPPING 2
typedef struct TT_CMapRec_
{
FT_CMapRec cmap;
FT_Byte* data; /* pointer to in-memory cmap table */
FT_Int flags; /* for format 4 only */
} TT_CMapRec, *TT_CMap;
typedef const struct TT_CMap_ClassRec_* TT_CMap_Class;
typedef FT_Error
(*TT_CMap_ValidateFunc)( FT_Byte* data,
FT_Validator valid );
typedef struct TT_CMap_ClassRec_
{
FT_CMap_ClassRec clazz;
FT_UInt format;
TT_CMap_ValidateFunc validate;
TT_CMap_Info_GetFunc get_cmap_info;
} TT_CMap_ClassRec;
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_TT_CMAP( class_, \
size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_, \
format_, \
validate_, \
get_cmap_info_ ) \
FT_CALLBACK_TABLE_DEF \
const TT_CMap_ClassRec class_ = \
{ \
{ size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_ \
}, \
\
format_, \
validate_, \
get_cmap_info_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_TT_CMAP( class_, \
size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_, \
format_, \
validate_, \
get_cmap_info_ ) \
void \
FT_Init_Class_ ## class_( TT_CMap_ClassRec* clazz ) \
{ \
clazz->clazz.size = size_; \
clazz->clazz.init = init_; \
clazz->clazz.done = done_; \
clazz->clazz.char_index = char_index_; \
clazz->clazz.char_next = char_next_; \
clazz->clazz.char_var_index = char_var_index_; \
clazz->clazz.char_var_default = char_var_default_; \
clazz->clazz.variant_list = variant_list_; \
clazz->clazz.charvariant_list = charvariant_list_; \
clazz->clazz.variantchar_list = variantchar_list_; \
clazz->format = format_; \
clazz->validate = validate_; \
clazz->get_cmap_info = get_cmap_info_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
typedef struct TT_ValidatorRec_
{
FT_ValidatorRec validator;
FT_UInt num_glyphs;
} TT_ValidatorRec, *TT_Validator;
#define TT_VALIDATOR( x ) ( (TT_Validator)( x ) )
#define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs
FT_LOCAL( FT_Error )
tt_face_build_cmaps( TT_Face face );
/* used in tt-cmaps service */
FT_LOCAL( FT_Error )
tt_get_cmap_info( FT_CharMap charmap,
TT_CMapInfo *cmap_info );
FT_END_HEADER
#endif /* __TTCMAP_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttcmap.h | C | apache-2.0 | 6,071 |
/***************************************************************************/
/* */
/* ttcmapc.h */
/* */
/* TT CMAP classes definitions (specification only). */
/* */
/* Copyright 2009 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#ifdef TT_CONFIG_CMAP_FORMAT_0
TTCMAPCITEM( tt_cmap0_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_2
TTCMAPCITEM( tt_cmap2_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_4
TTCMAPCITEM( tt_cmap4_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_6
TTCMAPCITEM( tt_cmap6_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_8
TTCMAPCITEM( tt_cmap8_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_10
TTCMAPCITEM( tt_cmap10_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_12
TTCMAPCITEM( tt_cmap12_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_13
TTCMAPCITEM( tt_cmap13_class_rec )
#endif
#ifdef TT_CONFIG_CMAP_FORMAT_14
TTCMAPCITEM( tt_cmap14_class_rec )
#endif
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttcmapc.h | C | apache-2.0 | 1,946 |
/***************************************************************************/
/* */
/* ttkern.c */
/* */
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
/* Copyright 1996-2007, 2009, 2010, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttkern.h"
#include "sferrors.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_ttkern
#undef TT_KERN_INDEX
#define TT_KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) )
FT_LOCAL_DEF( FT_Error )
tt_face_load_kern( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_ULong table_size;
FT_Byte* p;
FT_Byte* p_limit;
FT_UInt nn, num_tables;
FT_UInt32 avail = 0, ordered = 0;
/* the kern table is optional; exit silently if it is missing */
error = face->goto_table( face, TTAG_kern, stream, &table_size );
if ( error )
goto Exit;
if ( table_size < 4 ) /* the case of a malformed table */
{
FT_ERROR(( "tt_face_load_kern:"
" kerning table is too small - ignored\n" ));
error = FT_THROW( Table_Missing );
goto Exit;
}
if ( FT_FRAME_EXTRACT( table_size, face->kern_table ) )
{
FT_ERROR(( "tt_face_load_kern:"
" could not extract kerning table\n" ));
goto Exit;
}
face->kern_table_size = table_size;
p = face->kern_table;
p_limit = p + table_size;
p += 2; /* skip version */
num_tables = FT_NEXT_USHORT( p );
if ( num_tables > 32 ) /* we only support up to 32 sub-tables */
num_tables = 32;
for ( nn = 0; nn < num_tables; nn++ )
{
FT_UInt num_pairs, length, coverage;
FT_Byte* p_next;
FT_UInt32 mask = (FT_UInt32)1UL << nn;
if ( p + 6 > p_limit )
break;
p_next = p;
p += 2; /* skip version */
length = FT_NEXT_USHORT( p );
coverage = FT_NEXT_USHORT( p );
if ( length <= 6 )
break;
p_next += length;
if ( p_next > p_limit ) /* handle broken table */
p_next = p_limit;
/* only use horizontal kerning tables */
if ( ( coverage & ~8 ) != 0x0001 ||
p + 8 > p_limit )
goto NextTable;
num_pairs = FT_NEXT_USHORT( p );
p += 6;
if ( ( p_next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( p_next - p ) / 6 );
avail |= mask;
/*
* Now check whether the pairs in this table are ordered.
* We then can use binary search.
*/
if ( num_pairs > 0 )
{
FT_ULong count;
FT_ULong old_pair;
old_pair = FT_NEXT_ULONG( p );
p += 2;
for ( count = num_pairs - 1; count > 0; count-- )
{
FT_UInt32 cur_pair;
cur_pair = FT_NEXT_ULONG( p );
if ( cur_pair <= old_pair )
break;
p += 2;
old_pair = cur_pair;
}
if ( count == 0 )
ordered |= mask;
}
NextTable:
p = p_next;
}
face->num_kern_tables = nn;
face->kern_avail_bits = avail;
face->kern_order_bits = ordered;
Exit:
return error;
}
FT_LOCAL_DEF( void )
tt_face_done_kern( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->kern_table );
face->kern_table_size = 0;
face->num_kern_tables = 0;
face->kern_avail_bits = 0;
face->kern_order_bits = 0;
}
FT_LOCAL_DEF( FT_Int )
tt_face_get_kerning( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph )
{
FT_Int result = 0;
FT_UInt count, mask;
FT_Byte* p = face->kern_table;
FT_Byte* p_limit = p + face->kern_table_size;
p += 4;
mask = 0x0001;
for ( count = face->num_kern_tables;
count > 0 && p + 6 <= p_limit;
count--, mask <<= 1 )
{
FT_Byte* base = p;
FT_Byte* next;
FT_UInt version = FT_NEXT_USHORT( p );
FT_UInt length = FT_NEXT_USHORT( p );
FT_UInt coverage = FT_NEXT_USHORT( p );
FT_UInt num_pairs;
FT_Int value = 0;
FT_UNUSED( version );
next = base + length;
if ( next > p_limit ) /* handle broken table */
next = p_limit;
if ( ( face->kern_avail_bits & mask ) == 0 )
goto NextTable;
if ( p + 8 > next )
goto NextTable;
num_pairs = FT_NEXT_USHORT( p );
p += 6;
if ( ( next - p ) < 6 * (int)num_pairs ) /* handle broken count */
num_pairs = (FT_UInt)( ( next - p ) / 6 );
switch ( coverage >> 8 )
{
case 0:
{
FT_ULong key0 = TT_KERN_INDEX( left_glyph, right_glyph );
if ( face->kern_order_bits & mask ) /* binary search */
{
FT_UInt min = 0;
FT_UInt max = num_pairs;
while ( min < max )
{
FT_UInt mid = ( min + max ) >> 1;
FT_Byte* q = p + 6 * mid;
FT_ULong key;
key = FT_NEXT_ULONG( q );
if ( key == key0 )
{
value = FT_PEEK_SHORT( q );
goto Found;
}
if ( key < key0 )
min = mid + 1;
else
max = mid;
}
}
else /* linear search */
{
FT_UInt count2;
for ( count2 = num_pairs; count2 > 0; count2-- )
{
FT_ULong key = FT_NEXT_ULONG( p );
if ( key == key0 )
{
value = FT_PEEK_SHORT( p );
goto Found;
}
p += 2;
}
}
}
break;
/*
* We don't support format 2 because we haven't seen a single font
* using it in real life...
*/
default:
;
}
goto NextTable;
Found:
if ( coverage & 8 ) /* override or add */
result = value;
else
result += value;
NextTable:
p = next;
}
return result;
}
#undef TT_KERN_INDEX
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttkern.c | C | apache-2.0 | 7,908 |
/***************************************************************************/
/* */
/* ttkern.h */
/* */
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
/* Copyright 1996-2001, 2002, 2005, 2007 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 __TTKERN_H__
#define __TTKERN_H__
#include <ft2build.h>
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_load_kern( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
tt_face_done_kern( TT_Face face );
FT_LOCAL( FT_Int )
tt_face_get_kerning( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph );
#define TT_FACE_HAS_KERNING( face ) ( (face)->kern_avail_bits != 0 )
FT_END_HEADER
#endif /* __TTKERN_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttkern.h | C | apache-2.0 | 1,930 |
/***************************************************************************/
/* */
/* ttload.c */
/* */
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (body). */
/* */
/* Copyright 1996-2010, 2012, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttload.h"
#include "sferrors.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_ttload
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_lookup_table */
/* */
/* <Description> */
/* Looks for a TrueType table by name. */
/* */
/* <Input> */
/* face :: A face object handle. */
/* */
/* tag :: The searched tag. */
/* */
/* <Return> */
/* A pointer to the table directory entry. 0 if not found. */
/* */
FT_LOCAL_DEF( TT_Table )
tt_face_lookup_table( TT_Face face,
FT_ULong tag )
{
TT_Table entry;
TT_Table limit;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_Bool zero_length = FALSE;
#endif
FT_TRACE4(( "tt_face_lookup_table: %08p, `%c%c%c%c' -- ",
face,
(FT_Char)( tag >> 24 ),
(FT_Char)( tag >> 16 ),
(FT_Char)( tag >> 8 ),
(FT_Char)( tag ) ));
entry = face->dir_tables;
limit = entry + face->num_tables;
for ( ; entry < limit; entry++ )
{
/* For compatibility with Windows, we consider */
/* zero-length tables the same as missing tables. */
if ( entry->Tag == tag )
{
if ( entry->Length != 0 )
{
FT_TRACE4(( "found table.\n" ));
return entry;
}
#ifdef FT_DEBUG_LEVEL_TRACE
zero_length = TRUE;
#endif
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( zero_length )
FT_TRACE4(( "ignoring empty table\n" ));
else
FT_TRACE4(( "could not find table\n" ));
#endif
return NULL;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_goto_table */
/* */
/* <Description> */
/* Looks for a TrueType table by name, then seek a stream to it. */
/* */
/* <Input> */
/* face :: A face object handle. */
/* */
/* tag :: The searched tag. */
/* */
/* stream :: The stream to seek when the table is found. */
/* */
/* <Output> */
/* length :: The length of the table if found, undefined otherwise. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_goto_table( TT_Face face,
FT_ULong tag,
FT_Stream stream,
FT_ULong* length )
{
TT_Table table;
FT_Error error;
table = tt_face_lookup_table( face, tag );
if ( table )
{
if ( length )
*length = table->Length;
if ( FT_STREAM_SEEK( table->Offset ) )
goto Exit;
}
else
error = FT_THROW( Table_Missing );
Exit:
return error;
}
/* Here, we */
/* */
/* - check that `num_tables' is valid (and adjust it if necessary) */
/* */
/* - look for a `head' table, check its size, and parse it to check */
/* whether its `magic' field is correctly set */
/* */
/* - errors (except errors returned by stream handling) */
/* */
/* SFNT_Err_Unknown_File_Format: */
/* no table is defined in directory, it is not sfnt-wrapped */
/* data */
/* SFNT_Err_Table_Missing: */
/* table directory is valid, but essential tables */
/* (head/bhed/SING) are missing */
/* */
static FT_Error
check_table_dir( SFNT_Header sfnt,
FT_Stream stream )
{
FT_Error error;
FT_UShort nn, valid_entries = 0;
FT_UInt has_head = 0, has_sing = 0, has_meta = 0;
FT_ULong offset = sfnt->offset + 12;
static const FT_Frame_Field table_dir_entry_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_TableRec
FT_FRAME_START( 16 ),
FT_FRAME_ULONG( Tag ),
FT_FRAME_ULONG( CheckSum ),
FT_FRAME_ULONG( Offset ),
FT_FRAME_ULONG( Length ),
FT_FRAME_END
};
if ( FT_STREAM_SEEK( offset ) )
goto Exit;
for ( nn = 0; nn < sfnt->num_tables; nn++ )
{
TT_TableRec table;
if ( FT_STREAM_READ_FIELDS( table_dir_entry_fields, &table ) )
{
nn--;
FT_TRACE2(( "check_table_dir:"
" can read only %d table%s in font (instead of %d)\n",
nn, nn == 1 ? "" : "s", sfnt->num_tables ));
sfnt->num_tables = nn;
break;
}
/* we ignore invalid tables */
if ( table.Offset + table.Length > stream->size )
{
FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
continue;
}
else
valid_entries++;
if ( table.Tag == TTAG_head || table.Tag == TTAG_bhed )
{
FT_UInt32 magic;
#ifndef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
if ( table.Tag == TTAG_head )
#endif
has_head = 1;
/*
* The table length should be 0x36, but certain font tools make it
* 0x38, so we will just check that it is greater.
*
* Note that according to the specification, the table must be
* padded to 32-bit lengths, but this doesn't apply to the value of
* its `Length' field!
*
*/
if ( table.Length < 0x36 )
{
FT_TRACE2(( "check_table_dir:"
" `head' or `bhed' table too small\n" ));
error = FT_THROW( Table_Missing );
goto Exit;
}
if ( FT_STREAM_SEEK( table.Offset + 12 ) ||
FT_READ_ULONG( magic ) )
goto Exit;
if ( magic != 0x5F0F3CF5UL )
FT_TRACE2(( "check_table_dir:"
" invalid magic number in `head' or `bhed' table\n"));
if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) )
goto Exit;
}
else if ( table.Tag == TTAG_SING )
has_sing = 1;
else if ( table.Tag == TTAG_META )
has_meta = 1;
}
sfnt->num_tables = valid_entries;
if ( sfnt->num_tables == 0 )
{
FT_TRACE2(( "check_table_dir: no tables found\n" ));
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* if `sing' and `meta' tables are present, there is no `head' table */
if ( has_head || ( has_sing && has_meta ) )
{
error = FT_Err_Ok;
goto Exit;
}
else
{
FT_TRACE2(( "check_table_dir:" ));
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
FT_TRACE2(( " neither `head', `bhed', nor `sing' table found\n" ));
#else
FT_TRACE2(( " neither `head' nor `sing' table found\n" ));
#endif
error = FT_THROW( Table_Missing );
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_font_dir */
/* */
/* <Description> */
/* Loads the header of a SFNT font file. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* <Output> */
/* sfnt :: The SFNT header. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The stream cursor must be at the beginning of the font directory. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_font_dir( TT_Face face,
FT_Stream stream )
{
SFNT_HeaderRec sfnt;
FT_Error error;
FT_Memory memory = stream->memory;
TT_TableRec* entry;
FT_Int nn;
static const FT_Frame_Field offset_table_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE SFNT_HeaderRec
FT_FRAME_START( 8 ),
FT_FRAME_USHORT( num_tables ),
FT_FRAME_USHORT( search_range ),
FT_FRAME_USHORT( entry_selector ),
FT_FRAME_USHORT( range_shift ),
FT_FRAME_END
};
FT_TRACE2(( "tt_face_load_font_dir: %08p\n", face ));
/* read the offset table */
sfnt.offset = FT_STREAM_POS();
if ( FT_READ_ULONG( sfnt.format_tag ) ||
FT_STREAM_READ_FIELDS( offset_table_fields, &sfnt ) )
goto Exit;
/* many fonts don't have these fields set correctly */
#if 0
if ( sfnt.search_range != 1 << ( sfnt.entry_selector + 4 ) ||
sfnt.search_range + sfnt.range_shift != sfnt.num_tables << 4 )
return FT_THROW( Unknown_File_Format );
#endif
/* load the table directory */
FT_TRACE2(( "-- Number of tables: %10u\n", sfnt.num_tables ));
FT_TRACE2(( "-- Format version: 0x%08lx\n", sfnt.format_tag ));
if ( sfnt.format_tag != TTAG_OTTO )
{
/* check first */
error = check_table_dir( &sfnt, stream );
if ( error )
{
FT_TRACE2(( "tt_face_load_font_dir:"
" invalid table directory for TrueType\n" ));
goto Exit;
}
}
face->num_tables = sfnt.num_tables;
face->format_tag = sfnt.format_tag;
if ( FT_QNEW_ARRAY( face->dir_tables, face->num_tables ) )
goto Exit;
if ( FT_STREAM_SEEK( sfnt.offset + 12 ) ||
FT_FRAME_ENTER( face->num_tables * 16L ) )
goto Exit;
entry = face->dir_tables;
FT_TRACE2(( "\n"
" tag offset length checksum\n"
" ----------------------------------\n" ));
for ( nn = 0; nn < sfnt.num_tables; nn++ )
{
entry->Tag = FT_GET_TAG4();
entry->CheckSum = FT_GET_ULONG();
entry->Offset = FT_GET_ULONG();
entry->Length = FT_GET_ULONG();
/* ignore invalid tables */
if ( entry->Offset + entry->Length > stream->size )
continue;
else
{
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx\n",
(FT_Char)( entry->Tag >> 24 ),
(FT_Char)( entry->Tag >> 16 ),
(FT_Char)( entry->Tag >> 8 ),
(FT_Char)( entry->Tag ),
entry->Offset,
entry->Length,
entry->CheckSum ));
entry++;
}
}
FT_FRAME_EXIT();
FT_TRACE2(( "table directory loaded\n\n" ));
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_any */
/* */
/* <Description> */
/* Loads any font table into client memory. */
/* */
/* <Input> */
/* face :: The face object to look for. */
/* */
/* tag :: The tag of table to load. Use the value 0 if you want */
/* to access the whole font file, else set this parameter */
/* to a valid TrueType table tag that you can forge with */
/* the MAKE_TT_TAG macro. */
/* */
/* offset :: The starting offset in the table (or the file if */
/* tag == 0). */
/* */
/* length :: The address of the decision variable: */
/* */
/* If length == NULL: */
/* Loads the whole table. Returns an error if */
/* `offset' == 0! */
/* */
/* If *length == 0: */
/* Exits immediately; returning the length of the given */
/* table or of the font file, depending on the value of */
/* `tag'. */
/* */
/* If *length != 0: */
/* Loads the next `length' bytes of table or font, */
/* starting at offset `offset' (in table or font too). */
/* */
/* <Output> */
/* buffer :: The address of target buffer. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_any( TT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length )
{
FT_Error error;
FT_Stream stream;
TT_Table table;
FT_ULong size;
if ( tag != 0 )
{
/* look for tag in font directory */
table = tt_face_lookup_table( face, tag );
if ( !table )
{
error = FT_THROW( Table_Missing );
goto Exit;
}
offset += table->Offset;
size = table->Length;
}
else
/* tag == 0 -- the user wants to access the font file directly */
size = face->root.stream->size;
if ( length && *length == 0 )
{
*length = size;
return FT_Err_Ok;
}
if ( length )
size = *length;
stream = face->root.stream;
/* the `if' is syntactic sugar for picky compilers */
if ( FT_STREAM_READ_AT( offset, buffer, size ) )
goto Exit;
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_generic_header */
/* */
/* <Description> */
/* Loads the TrueType table `head' or `bhed'. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static FT_Error
tt_face_load_generic_header( TT_Face face,
FT_Stream stream,
FT_ULong tag )
{
FT_Error error;
TT_Header* header;
static const FT_Frame_Field header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_Header
FT_FRAME_START( 54 ),
FT_FRAME_ULONG ( Table_Version ),
FT_FRAME_ULONG ( Font_Revision ),
FT_FRAME_LONG ( CheckSum_Adjust ),
FT_FRAME_LONG ( Magic_Number ),
FT_FRAME_USHORT( Flags ),
FT_FRAME_USHORT( Units_Per_EM ),
FT_FRAME_LONG ( Created[0] ),
FT_FRAME_LONG ( Created[1] ),
FT_FRAME_LONG ( Modified[0] ),
FT_FRAME_LONG ( Modified[1] ),
FT_FRAME_SHORT ( xMin ),
FT_FRAME_SHORT ( yMin ),
FT_FRAME_SHORT ( xMax ),
FT_FRAME_SHORT ( yMax ),
FT_FRAME_USHORT( Mac_Style ),
FT_FRAME_USHORT( Lowest_Rec_PPEM ),
FT_FRAME_SHORT ( Font_Direction ),
FT_FRAME_SHORT ( Index_To_Loc_Format ),
FT_FRAME_SHORT ( Glyph_Data_Format ),
FT_FRAME_END
};
error = face->goto_table( face, tag, stream, 0 );
if ( error )
goto Exit;
header = &face->header;
if ( FT_STREAM_READ_FIELDS( header_fields, header ) )
goto Exit;
FT_TRACE3(( "Units per EM: %4u\n", header->Units_Per_EM ));
FT_TRACE3(( "IndexToLoc: %4d\n", header->Index_To_Loc_Format ));
Exit:
return error;
}
FT_LOCAL_DEF( FT_Error )
tt_face_load_head( TT_Face face,
FT_Stream stream )
{
return tt_face_load_generic_header( face, stream, TTAG_head );
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
FT_LOCAL_DEF( FT_Error )
tt_face_load_bhed( TT_Face face,
FT_Stream stream )
{
return tt_face_load_generic_header( face, stream, TTAG_bhed );
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_max_profile */
/* */
/* <Description> */
/* Loads the maximum profile into a face object. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_maxp( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_MaxProfile* maxProfile = &face->max_profile;
static const FT_Frame_Field maxp_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_MaxProfile
FT_FRAME_START( 6 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( numGlyphs ),
FT_FRAME_END
};
static const FT_Frame_Field maxp_fields_extra[] =
{
FT_FRAME_START( 26 ),
FT_FRAME_USHORT( maxPoints ),
FT_FRAME_USHORT( maxContours ),
FT_FRAME_USHORT( maxCompositePoints ),
FT_FRAME_USHORT( maxCompositeContours ),
FT_FRAME_USHORT( maxZones ),
FT_FRAME_USHORT( maxTwilightPoints ),
FT_FRAME_USHORT( maxStorage ),
FT_FRAME_USHORT( maxFunctionDefs ),
FT_FRAME_USHORT( maxInstructionDefs ),
FT_FRAME_USHORT( maxStackElements ),
FT_FRAME_USHORT( maxSizeOfInstructions ),
FT_FRAME_USHORT( maxComponentElements ),
FT_FRAME_USHORT( maxComponentDepth ),
FT_FRAME_END
};
error = face->goto_table( face, TTAG_maxp, stream, 0 );
if ( error )
goto Exit;
if ( FT_STREAM_READ_FIELDS( maxp_fields, maxProfile ) )
goto Exit;
maxProfile->maxPoints = 0;
maxProfile->maxContours = 0;
maxProfile->maxCompositePoints = 0;
maxProfile->maxCompositeContours = 0;
maxProfile->maxZones = 0;
maxProfile->maxTwilightPoints = 0;
maxProfile->maxStorage = 0;
maxProfile->maxFunctionDefs = 0;
maxProfile->maxInstructionDefs = 0;
maxProfile->maxStackElements = 0;
maxProfile->maxSizeOfInstructions = 0;
maxProfile->maxComponentElements = 0;
maxProfile->maxComponentDepth = 0;
if ( maxProfile->version >= 0x10000L )
{
if ( FT_STREAM_READ_FIELDS( maxp_fields_extra, maxProfile ) )
goto Exit;
/* XXX: an adjustment that is necessary to load certain */
/* broken fonts like `Keystrokes MT' :-( */
/* */
/* We allocate 64 function entries by default when */
/* the maxFunctionDefs value is smaller. */
if ( maxProfile->maxFunctionDefs < 64 )
maxProfile->maxFunctionDefs = 64;
/* we add 4 phantom points later */
if ( maxProfile->maxTwilightPoints > ( 0xFFFFU - 4 ) )
{
FT_TRACE0(( "tt_face_load_maxp:"
" too much twilight points in `maxp' table;\n"
" "
" some glyphs might be rendered incorrectly\n" ));
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
/* we arbitrarily limit recursion to avoid stack exhaustion */
if ( maxProfile->maxComponentDepth > 100 )
{
FT_TRACE0(( "tt_face_load_maxp:"
" abnormally large component depth (%d) set to 100\n",
maxProfile->maxComponentDepth ));
maxProfile->maxComponentDepth = 100;
}
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_name */
/* */
/* <Description> */
/* Loads the name records. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_name( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_ULong table_pos, table_len;
FT_ULong storage_start, storage_limit;
FT_UInt count;
TT_NameTable table;
static const FT_Frame_Field name_table_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_NameTableRec
FT_FRAME_START( 6 ),
FT_FRAME_USHORT( format ),
FT_FRAME_USHORT( numNameRecords ),
FT_FRAME_USHORT( storageOffset ),
FT_FRAME_END
};
static const FT_Frame_Field name_record_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_NameEntryRec
/* no FT_FRAME_START */
FT_FRAME_USHORT( platformID ),
FT_FRAME_USHORT( encodingID ),
FT_FRAME_USHORT( languageID ),
FT_FRAME_USHORT( nameID ),
FT_FRAME_USHORT( stringLength ),
FT_FRAME_USHORT( stringOffset ),
FT_FRAME_END
};
table = &face->name_table;
table->stream = stream;
error = face->goto_table( face, TTAG_name, stream, &table_len );
if ( error )
goto Exit;
table_pos = FT_STREAM_POS();
if ( FT_STREAM_READ_FIELDS( name_table_fields, table ) )
goto Exit;
/* Some popular Asian fonts have an invalid `storageOffset' value */
/* (it should be at least "6 + 12*num_names"). However, the string */
/* offsets, computed as "storageOffset + entry->stringOffset", are */
/* valid pointers within the name table... */
/* */
/* We thus can't check `storageOffset' right now. */
/* */
storage_start = table_pos + 6 + 12*table->numNameRecords;
storage_limit = table_pos + table_len;
if ( storage_start > storage_limit )
{
FT_ERROR(( "tt_face_load_name: invalid `name' table\n" ));
error = FT_THROW( Name_Table_Missing );
goto Exit;
}
/* Allocate the array of name records. */
count = table->numNameRecords;
table->numNameRecords = 0;
if ( FT_NEW_ARRAY( table->names, count ) ||
FT_FRAME_ENTER( count * 12 ) )
goto Exit;
/* Load the name records and determine how much storage is needed */
/* to hold the strings themselves. */
{
TT_NameEntryRec* entry = table->names;
for ( ; count > 0; count-- )
{
if ( FT_STREAM_READ_FIELDS( name_record_fields, entry ) )
continue;
/* check that the name is not empty */
if ( entry->stringLength == 0 )
continue;
/* check that the name string is within the table */
entry->stringOffset += table_pos + table->storageOffset;
if ( entry->stringOffset < storage_start ||
entry->stringOffset + entry->stringLength > storage_limit )
{
/* invalid entry - ignore it */
entry->stringOffset = 0;
entry->stringLength = 0;
continue;
}
entry++;
}
table->numNameRecords = (FT_UInt)( entry - table->names );
}
FT_FRAME_EXIT();
/* everything went well, update face->num_names */
face->num_names = (FT_UShort) table->numNameRecords;
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_free_names */
/* */
/* <Description> */
/* Frees the name records. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
FT_LOCAL_DEF( void )
tt_face_free_name( TT_Face face )
{
FT_Memory memory = face->root.driver->root.memory;
TT_NameTable table = &face->name_table;
TT_NameEntry entry = table->names;
FT_UInt count = table->numNameRecords;
if ( table->names )
{
for ( ; count > 0; count--, entry++ )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
/* free strings table */
FT_FREE( table->names );
}
table->numNameRecords = 0;
table->format = 0;
table->storageOffset = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_cmap */
/* */
/* <Description> */
/* Loads the cmap directory in a face object. The cmaps themselves */
/* are loaded on demand in the `ttcmap.c' module. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_cmap( TT_Face face,
FT_Stream stream )
{
FT_Error error;
error = face->goto_table( face, TTAG_cmap, stream, &face->cmap_size );
if ( error )
goto Exit;
if ( FT_FRAME_EXTRACT( face->cmap_size, face->cmap_table ) )
face->cmap_size = 0;
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_os2 */
/* */
/* <Description> */
/* Loads the OS2 table. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_os2( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_OS2* os2;
static const FT_Frame_Field os2_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_OS2
FT_FRAME_START( 78 ),
FT_FRAME_USHORT( version ),
FT_FRAME_SHORT ( xAvgCharWidth ),
FT_FRAME_USHORT( usWeightClass ),
FT_FRAME_USHORT( usWidthClass ),
FT_FRAME_SHORT ( fsType ),
FT_FRAME_SHORT ( ySubscriptXSize ),
FT_FRAME_SHORT ( ySubscriptYSize ),
FT_FRAME_SHORT ( ySubscriptXOffset ),
FT_FRAME_SHORT ( ySubscriptYOffset ),
FT_FRAME_SHORT ( ySuperscriptXSize ),
FT_FRAME_SHORT ( ySuperscriptYSize ),
FT_FRAME_SHORT ( ySuperscriptXOffset ),
FT_FRAME_SHORT ( ySuperscriptYOffset ),
FT_FRAME_SHORT ( yStrikeoutSize ),
FT_FRAME_SHORT ( yStrikeoutPosition ),
FT_FRAME_SHORT ( sFamilyClass ),
FT_FRAME_BYTE ( panose[0] ),
FT_FRAME_BYTE ( panose[1] ),
FT_FRAME_BYTE ( panose[2] ),
FT_FRAME_BYTE ( panose[3] ),
FT_FRAME_BYTE ( panose[4] ),
FT_FRAME_BYTE ( panose[5] ),
FT_FRAME_BYTE ( panose[6] ),
FT_FRAME_BYTE ( panose[7] ),
FT_FRAME_BYTE ( panose[8] ),
FT_FRAME_BYTE ( panose[9] ),
FT_FRAME_ULONG ( ulUnicodeRange1 ),
FT_FRAME_ULONG ( ulUnicodeRange2 ),
FT_FRAME_ULONG ( ulUnicodeRange3 ),
FT_FRAME_ULONG ( ulUnicodeRange4 ),
FT_FRAME_BYTE ( achVendID[0] ),
FT_FRAME_BYTE ( achVendID[1] ),
FT_FRAME_BYTE ( achVendID[2] ),
FT_FRAME_BYTE ( achVendID[3] ),
FT_FRAME_USHORT( fsSelection ),
FT_FRAME_USHORT( usFirstCharIndex ),
FT_FRAME_USHORT( usLastCharIndex ),
FT_FRAME_SHORT ( sTypoAscender ),
FT_FRAME_SHORT ( sTypoDescender ),
FT_FRAME_SHORT ( sTypoLineGap ),
FT_FRAME_USHORT( usWinAscent ),
FT_FRAME_USHORT( usWinDescent ),
FT_FRAME_END
};
/* `OS/2' version 1 and newer */
static const FT_Frame_Field os2_fields_extra1[] =
{
FT_FRAME_START( 8 ),
FT_FRAME_ULONG( ulCodePageRange1 ),
FT_FRAME_ULONG( ulCodePageRange2 ),
FT_FRAME_END
};
/* `OS/2' version 2 and newer */
static const FT_Frame_Field os2_fields_extra2[] =
{
FT_FRAME_START( 10 ),
FT_FRAME_SHORT ( sxHeight ),
FT_FRAME_SHORT ( sCapHeight ),
FT_FRAME_USHORT( usDefaultChar ),
FT_FRAME_USHORT( usBreakChar ),
FT_FRAME_USHORT( usMaxContext ),
FT_FRAME_END
};
/* `OS/2' version 5 and newer */
static const FT_Frame_Field os2_fields_extra5[] =
{
FT_FRAME_START( 4 ),
FT_FRAME_USHORT( usLowerOpticalPointSize ),
FT_FRAME_USHORT( usUpperOpticalPointSize ),
FT_FRAME_END
};
/* We now support old Mac fonts where the OS/2 table doesn't */
/* exist. Simply put, we set the `version' field to 0xFFFF */
/* and test this value each time we need to access the table. */
error = face->goto_table( face, TTAG_OS2, stream, 0 );
if ( error )
goto Exit;
os2 = &face->os2;
if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) )
goto Exit;
os2->ulCodePageRange1 = 0;
os2->ulCodePageRange2 = 0;
os2->sxHeight = 0;
os2->sCapHeight = 0;
os2->usDefaultChar = 0;
os2->usBreakChar = 0;
os2->usMaxContext = 0;
os2->usLowerOpticalPointSize = 0;
os2->usUpperOpticalPointSize = 0xFFFF;
if ( os2->version >= 0x0001 )
{
/* only version 1 tables */
if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) )
goto Exit;
if ( os2->version >= 0x0002 )
{
/* only version 2 tables */
if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) )
goto Exit;
if ( os2->version >= 0x0005 )
{
/* only version 5 tables */
if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) )
goto Exit;
}
}
}
FT_TRACE3(( "sTypoAscender: %4d\n", os2->sTypoAscender ));
FT_TRACE3(( "sTypoDescender: %4d\n", os2->sTypoDescender ));
FT_TRACE3(( "usWinAscent: %4u\n", os2->usWinAscent ));
FT_TRACE3(( "usWinDescent: %4u\n", os2->usWinDescent ));
FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection ));
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_postscript */
/* */
/* <Description> */
/* Loads the Postscript table. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_post( TT_Face face,
FT_Stream stream )
{
FT_Error error;
TT_Postscript* post = &face->postscript;
static const FT_Frame_Field post_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_Postscript
FT_FRAME_START( 32 ),
FT_FRAME_ULONG( FormatType ),
FT_FRAME_ULONG( italicAngle ),
FT_FRAME_SHORT( underlinePosition ),
FT_FRAME_SHORT( underlineThickness ),
FT_FRAME_ULONG( isFixedPitch ),
FT_FRAME_ULONG( minMemType42 ),
FT_FRAME_ULONG( maxMemType42 ),
FT_FRAME_ULONG( minMemType1 ),
FT_FRAME_ULONG( maxMemType1 ),
FT_FRAME_END
};
error = face->goto_table( face, TTAG_post, stream, 0 );
if ( error )
return error;
if ( FT_STREAM_READ_FIELDS( post_fields, post ) )
return error;
/* we don't load the glyph names, we do that in another */
/* module (ttpost). */
FT_TRACE3(( "FormatType: 0x%x\n", post->FormatType ));
FT_TRACE3(( "isFixedPitch: %s\n", post->isFixedPitch
? " yes" : " no" ));
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_pclt */
/* */
/* <Description> */
/* Loads the PCL 5 Table. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_pclt( TT_Face face,
FT_Stream stream )
{
static const FT_Frame_Field pclt_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_PCLT
FT_FRAME_START( 54 ),
FT_FRAME_ULONG ( Version ),
FT_FRAME_ULONG ( FontNumber ),
FT_FRAME_USHORT( Pitch ),
FT_FRAME_USHORT( xHeight ),
FT_FRAME_USHORT( Style ),
FT_FRAME_USHORT( TypeFamily ),
FT_FRAME_USHORT( CapHeight ),
FT_FRAME_USHORT( SymbolSet ),
FT_FRAME_BYTES ( TypeFace, 16 ),
FT_FRAME_BYTES ( CharacterComplement, 8 ),
FT_FRAME_BYTES ( FileName, 6 ),
FT_FRAME_CHAR ( StrokeWeight ),
FT_FRAME_CHAR ( WidthType ),
FT_FRAME_BYTE ( SerifStyle ),
FT_FRAME_BYTE ( Reserved ),
FT_FRAME_END
};
FT_Error error;
TT_PCLT* pclt = &face->pclt;
/* optional table */
error = face->goto_table( face, TTAG_PCLT, stream, 0 );
if ( error )
goto Exit;
if ( FT_STREAM_READ_FIELDS( pclt_fields, pclt ) )
goto Exit;
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_gasp */
/* */
/* <Description> */
/* Loads the `gasp' table into a face object. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_gasp( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_UInt j,num_ranges;
TT_GaspRange gaspranges = NULL;
/* the gasp table is optional */
error = face->goto_table( face, TTAG_gasp, stream, 0 );
if ( error )
goto Exit;
if ( FT_FRAME_ENTER( 4L ) )
goto Exit;
face->gasp.version = FT_GET_USHORT();
face->gasp.numRanges = FT_GET_USHORT();
FT_FRAME_EXIT();
/* only support versions 0 and 1 of the table */
if ( face->gasp.version >= 2 )
{
face->gasp.numRanges = 0;
error = FT_THROW( Invalid_Table );
goto Exit;
}
num_ranges = face->gasp.numRanges;
FT_TRACE3(( "numRanges: %u\n", num_ranges ));
if ( FT_QNEW_ARRAY( face->gasp.gaspRanges, num_ranges ) ||
FT_FRAME_ENTER( num_ranges * 4L ) )
goto Exit;
gaspranges = face->gasp.gaspRanges;
for ( j = 0; j < num_ranges; j++ )
{
gaspranges[j].maxPPEM = FT_GET_USHORT();
gaspranges[j].gaspFlag = FT_GET_USHORT();
FT_TRACE3(( "gaspRange %d: rangeMaxPPEM %5d, rangeGaspBehavior 0x%x\n",
j,
gaspranges[j].maxPPEM,
gaspranges[j].gaspFlag ));
}
FT_FRAME_EXIT();
Exit:
return error;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttload.c | C | apache-2.0 | 48,664 |
/***************************************************************************/
/* */
/* ttload.h */
/* */
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (specification). */
/* */
/* Copyright 1996-2001, 2002, 2005, 2006 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 __TTLOAD_H__
#define __TTLOAD_H__
#include <ft2build.h>
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
FT_LOCAL( TT_Table )
tt_face_lookup_table( TT_Face face,
FT_ULong tag );
FT_LOCAL( FT_Error )
tt_face_goto_table( TT_Face face,
FT_ULong tag,
FT_Stream stream,
FT_ULong* length );
FT_LOCAL( FT_Error )
tt_face_load_font_dir( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_any( TT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length );
FT_LOCAL( FT_Error )
tt_face_load_head( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_cmap( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_maxp( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_name( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_os2( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_post( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_pclt( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
tt_face_free_name( TT_Face face );
FT_LOCAL( FT_Error )
tt_face_load_gasp( TT_Face face,
FT_Stream stream );
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
FT_LOCAL( FT_Error )
tt_face_load_bhed( TT_Face face,
FT_Stream stream );
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
FT_END_HEADER
#endif /* __TTLOAD_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttload.h | C | apache-2.0 | 3,247 |
/***************************************************************************/
/* */
/* ttmtx.c */
/* */
/* Load the metrics tables common to TTF and OTF fonts (body). */
/* */
/* Copyright 2006-2009, 2011-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttmtx.h"
#include "sferrors.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_ttmtx
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_hmtx */
/* */
/* <Description> */
/* Load the `hmtx' or `vmtx' table into a face object. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* vertical :: A boolean flag. If set, load `vmtx'. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_hmtx( TT_Face face,
FT_Stream stream,
FT_Bool vertical )
{
FT_Error error;
FT_ULong tag, table_size;
FT_ULong* ptable_offset;
FT_ULong* ptable_size;
if ( vertical )
{
tag = TTAG_vmtx;
ptable_offset = &face->vert_metrics_offset;
ptable_size = &face->vert_metrics_size;
}
else
{
tag = TTAG_hmtx;
ptable_offset = &face->horz_metrics_offset;
ptable_size = &face->horz_metrics_size;
}
error = face->goto_table( face, tag, stream, &table_size );
if ( error )
goto Fail;
*ptable_size = table_size;
*ptable_offset = FT_STREAM_POS();
Fail:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_hhea */
/* */
/* <Description> */
/* Load the `hhea' or 'vhea' table into a face object. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: The input stream. */
/* */
/* vertical :: A boolean flag. If set, load `vhea'. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_hhea( TT_Face face,
FT_Stream stream,
FT_Bool vertical )
{
FT_Error error;
TT_HoriHeader* header;
static const FT_Frame_Field metrics_header_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE TT_HoriHeader
FT_FRAME_START( 36 ),
FT_FRAME_ULONG ( Version ),
FT_FRAME_SHORT ( Ascender ),
FT_FRAME_SHORT ( Descender ),
FT_FRAME_SHORT ( Line_Gap ),
FT_FRAME_USHORT( advance_Width_Max ),
FT_FRAME_SHORT ( min_Left_Side_Bearing ),
FT_FRAME_SHORT ( min_Right_Side_Bearing ),
FT_FRAME_SHORT ( xMax_Extent ),
FT_FRAME_SHORT ( caret_Slope_Rise ),
FT_FRAME_SHORT ( caret_Slope_Run ),
FT_FRAME_SHORT ( caret_Offset ),
FT_FRAME_SHORT ( Reserved[0] ),
FT_FRAME_SHORT ( Reserved[1] ),
FT_FRAME_SHORT ( Reserved[2] ),
FT_FRAME_SHORT ( Reserved[3] ),
FT_FRAME_SHORT ( metric_Data_Format ),
FT_FRAME_USHORT( number_Of_HMetrics ),
FT_FRAME_END
};
if ( vertical )
{
void *v = &face->vertical;
error = face->goto_table( face, TTAG_vhea, stream, 0 );
if ( error )
goto Fail;
header = (TT_HoriHeader*)v;
}
else
{
error = face->goto_table( face, TTAG_hhea, stream, 0 );
if ( error )
goto Fail;
header = &face->horizontal;
}
if ( FT_STREAM_READ_FIELDS( metrics_header_fields, header ) )
goto Fail;
FT_TRACE3(( "Ascender: %5d\n", header->Ascender ));
FT_TRACE3(( "Descender: %5d\n", header->Descender ));
FT_TRACE3(( "number_Of_Metrics: %5u\n", header->number_Of_HMetrics ));
header->long_metrics = NULL;
header->short_metrics = NULL;
Fail:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_get_metrics */
/* */
/* <Description> */
/* Return the horizontal or vertical metrics in font units for a */
/* given glyph. The values are the left side bearing (top side */
/* bearing for vertical metrics) and advance width (advance height */
/* for vertical metrics). */
/* */
/* <Input> */
/* face :: A pointer to the TrueType face structure. */
/* */
/* vertical :: If set to TRUE, get vertical metrics. */
/* */
/* gindex :: The glyph index. */
/* */
/* <Output> */
/* abearing :: The bearing, either left side or top side. */
/* */
/* aadvance :: The advance width or advance height, depending on */
/* the `vertical' flag. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_get_metrics( TT_Face face,
FT_Bool vertical,
FT_UInt gindex,
FT_Short *abearing,
FT_UShort *aadvance )
{
FT_Error error;
FT_Stream stream = face->root.stream;
TT_HoriHeader* header;
FT_ULong table_pos, table_size, table_end;
FT_UShort k;
if ( vertical )
{
void* v = &face->vertical;
header = (TT_HoriHeader*)v;
table_pos = face->vert_metrics_offset;
table_size = face->vert_metrics_size;
}
else
{
header = &face->horizontal;
table_pos = face->horz_metrics_offset;
table_size = face->horz_metrics_size;
}
table_end = table_pos + table_size;
k = header->number_Of_HMetrics;
if ( k > 0 )
{
if ( gindex < (FT_UInt)k )
{
table_pos += 4 * gindex;
if ( table_pos + 4 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance ) ||
FT_READ_SHORT( *abearing ) )
goto NoData;
}
else
{
table_pos += 4 * ( k - 1 );
if ( table_pos + 4 > table_end )
goto NoData;
if ( FT_STREAM_SEEK( table_pos ) ||
FT_READ_USHORT( *aadvance ) )
goto NoData;
table_pos += 4 + 2 * ( gindex - k );
if ( table_pos + 2 > table_end )
*abearing = 0;
else
{
if ( !FT_STREAM_SEEK( table_pos ) )
(void)FT_READ_SHORT( *abearing );
}
}
}
else
{
NoData:
*abearing = 0;
*aadvance = 0;
}
return FT_Err_Ok;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttmtx.c | C | apache-2.0 | 11,027 |
/***************************************************************************/
/* */
/* ttmtx.h */
/* */
/* Load the metrics tables common to TTF and OTF fonts (specification). */
/* */
/* Copyright 2006 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 __TTMTX_H__
#define __TTMTX_H__
#include <ft2build.h>
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_load_hhea( TT_Face face,
FT_Stream stream,
FT_Bool vertical );
FT_LOCAL( FT_Error )
tt_face_load_hmtx( TT_Face face,
FT_Stream stream,
FT_Bool vertical );
FT_LOCAL( FT_Error )
tt_face_get_metrics( TT_Face face,
FT_Bool vertical,
FT_UInt gindex,
FT_Short* abearing,
FT_UShort* aadvance );
FT_END_HEADER
#endif /* __TTMTX_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttmtx.h | C | apache-2.0 | 1,993 |
/***************************************************************************/
/* */
/* ttpost.c */
/* */
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
/* Copyright 1996-2003, 2006-2010, 2013 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* The post table is not completely loaded by the core engine. This */
/* file loads the missing PS glyph names and implements an API to access */
/* them. */
/* */
/*************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttpost.h"
#include "sferrors.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_ttpost
/* If this configuration macro is defined, we rely on the `PSNames' */
/* module to grab the glyph names. */
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) )
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
/* Otherwise, we ignore the `PSNames' module, and provide our own */
/* table of Mac names. Thus, it is possible to build a version of */
/* FreeType without the Type 1 driver & PSNames module. */
#define MAC_NAME( x ) ( (FT_String*)tt_post_default_names[x] )
/* the 258 default Mac PS glyph names */
static const FT_String* const tt_post_default_names[258] =
{
/* 0 */
".notdef", ".null", "CR", "space", "exclam",
"quotedbl", "numbersign", "dollar", "percent", "ampersand",
/* 10 */
"quotesingle", "parenleft", "parenright", "asterisk", "plus",
"comma", "hyphen", "period", "slash", "zero",
/* 20 */
"one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "colon",
/* 30 */
"semicolon", "less", "equal", "greater", "question",
"at", "A", "B", "C", "D",
/* 40 */
"E", "F", "G", "H", "I",
"J", "K", "L", "M", "N",
/* 50 */
"O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X",
/* 60 */
"Y", "Z", "bracketleft", "backslash", "bracketright",
"asciicircum", "underscore", "grave", "a", "b",
/* 70 */
"c", "d", "e", "f", "g",
"h", "i", "j", "k", "l",
/* 80 */
"m", "n", "o", "p", "q",
"r", "s", "t", "u", "v",
/* 90 */
"w", "x", "y", "z", "braceleft",
"bar", "braceright", "asciitilde", "Adieresis", "Aring",
/* 100 */
"Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis",
"aacute", "agrave", "acircumflex", "adieresis", "atilde",
/* 110 */
"aring", "ccedilla", "eacute", "egrave", "ecircumflex",
"edieresis", "iacute", "igrave", "icircumflex", "idieresis",
/* 120 */
"ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
"otilde", "uacute", "ugrave", "ucircumflex", "udieresis",
/* 130 */
"dagger", "degree", "cent", "sterling", "section",
"bullet", "paragraph", "germandbls", "registered", "copyright",
/* 140 */
"trademark", "acute", "dieresis", "notequal", "AE",
"Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
/* 150 */
"yen", "mu", "partialdiff", "summation", "product",
"pi", "integral", "ordfeminine", "ordmasculine", "Omega",
/* 160 */
"ae", "oslash", "questiondown", "exclamdown", "logicalnot",
"radical", "florin", "approxequal", "Delta", "guillemotleft",
/* 170 */
"guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde",
"Otilde", "OE", "oe", "endash", "emdash",
/* 180 */
"quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
"lozenge", "ydieresis", "Ydieresis", "fraction", "currency",
/* 190 */
"guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl",
"periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
/* 200 */
"Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
"Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
/* 210 */
"apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave",
"dotlessi", "circumflex", "tilde", "macron", "breve",
/* 220 */
"dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek",
"caron", "Lslash", "lslash", "Scaron", "scaron",
/* 230 */
"Zcaron", "zcaron", "brokenbar", "Eth", "eth",
"Yacute", "yacute", "Thorn", "thorn", "minus",
/* 240 */
"multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
"onequarter", "threequarters", "franc", "Gbreve", "gbreve",
/* 250 */
"Idot", "Scedilla", "scedilla", "Cacute", "cacute",
"Ccaron", "ccaron", "dmacron",
};
#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
static FT_Error
load_format_20( TT_Face face,
FT_Stream stream,
FT_Long post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_Int num_glyphs;
FT_UShort num_names;
FT_UShort* glyph_indices = 0;
FT_Char** name_strings = 0;
if ( FT_READ_USHORT( num_glyphs ) )
goto Exit;
/* UNDOCUMENTED! The number of glyphs in this table can be smaller */
/* than the value in the maxp table (cf. cyberbit.ttf). */
/* There already exist fonts which have more than 32768 glyph names */
/* in this table, so the test for this threshold has been dropped. */
if ( num_glyphs > face->max_profile.numGlyphs )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* load the indices */
{
FT_Int n;
if ( FT_NEW_ARRAY ( glyph_indices, num_glyphs ) ||
FT_FRAME_ENTER( num_glyphs * 2L ) )
goto Fail;
for ( n = 0; n < num_glyphs; n++ )
glyph_indices[n] = FT_GET_USHORT();
FT_FRAME_EXIT();
}
/* compute number of names stored in table */
{
FT_Int n;
num_names = 0;
for ( n = 0; n < num_glyphs; n++ )
{
FT_Int idx;
idx = glyph_indices[n];
if ( idx >= 258 )
{
idx -= 257;
if ( idx > num_names )
num_names = (FT_UShort)idx;
}
}
}
/* now load the name strings */
{
FT_UShort n;
if ( FT_NEW_ARRAY( name_strings, num_names ) )
goto Fail;
for ( n = 0; n < num_names; n++ )
{
FT_UInt len;
if ( FT_STREAM_POS() >= post_limit )
break;
else
{
FT_TRACE6(( "load_format_20: %d byte left in post table\n",
post_limit - FT_STREAM_POS() ));
if ( FT_READ_BYTE( len ) )
goto Fail1;
}
if ( (FT_Int)len > post_limit ||
FT_STREAM_POS() > post_limit - (FT_Int)len )
{
FT_ERROR(( "load_format_20:"
" exceeding string length (%d),"
" truncating at end of post table (%d byte left)\n",
len, post_limit - FT_STREAM_POS() ));
len = FT_MAX( 0, post_limit - FT_STREAM_POS() );
}
if ( FT_NEW_ARRAY( name_strings[n], len + 1 ) ||
FT_STREAM_READ( name_strings[n], len ) )
goto Fail1;
name_strings[n][len] = '\0';
}
if ( n < num_names )
{
FT_ERROR(( "load_format_20:"
" all entries in post table are already parsed,"
" using NULL names for gid %d - %d\n",
n, num_names - 1 ));
for ( ; n < num_names; n++ )
if ( FT_NEW_ARRAY( name_strings[n], 1 ) )
goto Fail1;
else
name_strings[n][0] = '\0';
}
}
/* all right, set table fields and exit successfully */
{
TT_Post_20 table = &face->postscript_names.names.format_20;
table->num_glyphs = (FT_UShort)num_glyphs;
table->num_names = (FT_UShort)num_names;
table->glyph_indices = glyph_indices;
table->glyph_names = name_strings;
}
return FT_Err_Ok;
Fail1:
{
FT_UShort n;
for ( n = 0; n < num_names; n++ )
FT_FREE( name_strings[n] );
}
Fail:
FT_FREE( name_strings );
FT_FREE( glyph_indices );
Exit:
return error;
}
static FT_Error
load_format_25( TT_Face face,
FT_Stream stream,
FT_Long post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_Int num_glyphs;
FT_Char* offset_table = 0;
FT_UNUSED( post_limit );
/* UNDOCUMENTED! This value appears only in the Apple TT specs. */
if ( FT_READ_USHORT( num_glyphs ) )
goto Exit;
/* check the number of glyphs */
if ( num_glyphs > face->max_profile.numGlyphs || num_glyphs > 258 )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( FT_NEW_ARRAY( offset_table, num_glyphs ) ||
FT_STREAM_READ( offset_table, num_glyphs ) )
goto Fail;
/* now check the offset table */
{
FT_Int n;
for ( n = 0; n < num_glyphs; n++ )
{
FT_Long idx = (FT_Long)n + offset_table[n];
if ( idx < 0 || idx > num_glyphs )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
}
}
/* OK, set table fields and exit successfully */
{
TT_Post_25 table = &face->postscript_names.names.format_25;
table->num_glyphs = (FT_UShort)num_glyphs;
table->offsets = offset_table;
}
return FT_Err_Ok;
Fail:
FT_FREE( offset_table );
Exit:
return error;
}
static FT_Error
load_post_names( TT_Face face )
{
FT_Stream stream;
FT_Error error;
FT_Fixed format;
FT_ULong post_len;
FT_Long post_limit;
/* get a stream for the face's resource */
stream = face->root.stream;
/* seek to the beginning of the PS names table */
error = face->goto_table( face, TTAG_post, stream, &post_len );
if ( error )
goto Exit;
post_limit = FT_STREAM_POS() + post_len;
format = face->postscript.FormatType;
/* go to beginning of subtable */
if ( FT_STREAM_SKIP( 32 ) )
goto Exit;
/* now read postscript table */
if ( format == 0x00020000L )
error = load_format_20( face, stream, post_limit );
else if ( format == 0x00028000L )
error = load_format_25( face, stream, post_limit );
else
error = FT_THROW( Invalid_File_Format );
face->postscript_names.loaded = 1;
Exit:
return error;
}
FT_LOCAL_DEF( void )
tt_face_free_ps_names( TT_Face face )
{
FT_Memory memory = face->root.memory;
TT_Post_Names names = &face->postscript_names;
FT_Fixed format;
if ( names->loaded )
{
format = face->postscript.FormatType;
if ( format == 0x00020000L )
{
TT_Post_20 table = &names->names.format_20;
FT_UShort n;
FT_FREE( table->glyph_indices );
table->num_glyphs = 0;
for ( n = 0; n < table->num_names; n++ )
FT_FREE( table->glyph_names[n] );
FT_FREE( table->glyph_names );
table->num_names = 0;
}
else if ( format == 0x00028000L )
{
TT_Post_25 table = &names->names.format_25;
FT_FREE( table->offsets );
table->num_glyphs = 0;
}
}
names->loaded = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_get_ps_name */
/* */
/* <Description> */
/* Get the PostScript glyph name of a glyph. */
/* */
/* <Input> */
/* face :: A handle to the parent face. */
/* */
/* idx :: The glyph index. */
/* */
/* <InOut> */
/* PSname :: The address of a string pointer. Will be NULL in case */
/* of error, otherwise it is a pointer to the glyph name. */
/* */
/* You must not modify the returned string! */
/* */
/* <Output> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_get_ps_name( TT_Face face,
FT_UInt idx,
FT_String** PSname )
{
FT_Error error;
TT_Post_Names names;
FT_Fixed format;
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
FT_Service_PsCMaps psnames;
#endif
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( idx >= (FT_UInt)face->max_profile.numGlyphs )
return FT_THROW( Invalid_Glyph_Index );
#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES
psnames = (FT_Service_PsCMaps)face->psnames;
if ( !psnames )
return FT_THROW( Unimplemented_Feature );
#endif
names = &face->postscript_names;
/* `.notdef' by default */
*PSname = MAC_NAME( 0 );
format = face->postscript.FormatType;
if ( format == 0x00010000L )
{
if ( idx < 258 ) /* paranoid checking */
*PSname = MAC_NAME( idx );
}
else if ( format == 0x00020000L )
{
TT_Post_20 table = &names->names.format_20;
if ( !names->loaded )
{
error = load_post_names( face );
if ( error )
goto End;
}
if ( idx < (FT_UInt)table->num_glyphs )
{
FT_UShort name_index = table->glyph_indices[idx];
if ( name_index < 258 )
*PSname = MAC_NAME( name_index );
else
*PSname = (FT_String*)table->glyph_names[name_index - 258];
}
}
else if ( format == 0x00028000L )
{
TT_Post_25 table = &names->names.format_25;
if ( !names->loaded )
{
error = load_post_names( face );
if ( error )
goto End;
}
if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */
{
idx += table->offsets[idx];
*PSname = MAC_NAME( idx );
}
}
/* nothing to do for format == 0x00030000L */
End:
return FT_Err_Ok;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttpost.c | C | apache-2.0 | 16,912 |
/***************************************************************************/
/* */
/* ttpost.h */
/* */
/* Postcript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002 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 __TTPOST_H__
#define __TTPOST_H__
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_get_ps_name( TT_Face face,
FT_UInt idx,
FT_String** PSname );
FT_LOCAL( void )
tt_face_free_ps_names( TT_Face face );
FT_END_HEADER
#endif /* __TTPOST_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttpost.h | C | apache-2.0 | 1,749 |
/***************************************************************************/
/* */
/* ttsbit.c */
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
/* Copyright 2005-2009, 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* Copyright 2013 by Google, Inc. */
/* Google Author(s): Behdad Esfahbod. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_BITMAP_H
#include "ttsbit.h"
#include "sferrors.h"
#include "ttmtx.h"
#include "pngshim.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_ttsbit
FT_LOCAL_DEF( FT_Error )
tt_face_load_sbit( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_ULong table_size;
face->sbit_table = NULL;
face->sbit_table_size = 0;
face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
face->sbit_num_strikes = 0;
error = face->goto_table( face, TTAG_CBLC, stream, &table_size );
if ( !error )
face->sbit_table_type = TT_SBIT_TABLE_TYPE_CBLC;
else
{
error = face->goto_table( face, TTAG_EBLC, stream, &table_size );
if ( error )
error = face->goto_table( face, TTAG_bloc, stream, &table_size );
if ( !error )
face->sbit_table_type = TT_SBIT_TABLE_TYPE_EBLC;
}
if ( error )
{
error = face->goto_table( face, TTAG_sbix, stream, &table_size );
if ( !error )
face->sbit_table_type = TT_SBIT_TABLE_TYPE_SBIX;
}
if ( error )
goto Exit;
if ( table_size < 8 )
{
FT_ERROR(( "tt_face_load_sbit_strikes: table too short\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
switch ( (FT_UInt)face->sbit_table_type )
{
case TT_SBIT_TABLE_TYPE_EBLC:
case TT_SBIT_TABLE_TYPE_CBLC:
{
FT_Byte* p;
FT_Fixed version;
FT_ULong num_strikes;
FT_UInt count;
if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) )
goto Exit;
face->sbit_table_size = table_size;
p = face->sbit_table;
version = FT_NEXT_ULONG( p );
num_strikes = FT_NEXT_ULONG( p );
if ( ( version & 0xFFFF0000UL ) != 0x00020000UL )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
if ( num_strikes >= 0x10000UL )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/*
* Count the number of strikes available in the table. We are a bit
* paranoid there and don't trust the data.
*/
count = (FT_UInt)num_strikes;
if ( 8 + 48UL * count > table_size )
count = (FT_UInt)( ( table_size - 8 ) / 48 );
face->sbit_num_strikes = count;
}
break;
case TT_SBIT_TABLE_TYPE_SBIX:
{
FT_UShort version;
FT_UShort flags;
FT_ULong num_strikes;
FT_UInt count;
if ( FT_FRAME_ENTER( 8 ) )
goto Exit;
version = FT_GET_USHORT();
flags = FT_GET_USHORT();
num_strikes = FT_GET_ULONG();
FT_FRAME_EXIT();
if ( version < 1 )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
if ( flags != 0x0001 || num_strikes >= 0x10000UL )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/*
* Count the number of strikes available in the table. We are a bit
* paranoid there and don't trust the data.
*/
count = (FT_UInt)num_strikes;
if ( 8 + 4UL * count > table_size )
count = (FT_UInt)( ( table_size - 8 ) / 4 );
if ( FT_STREAM_SEEK( FT_STREAM_POS() - 8 ) )
goto Exit;
face->sbit_table_size = 8 + count * 4;
if ( FT_FRAME_EXTRACT( face->sbit_table_size, face->sbit_table ) )
goto Exit;
face->sbit_num_strikes = count;
}
break;
default:
error = FT_THROW( Unknown_File_Format );
break;
}
if ( !error )
FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes ));
return FT_Err_Ok;
Exit:
if ( error )
{
if ( face->sbit_table )
FT_FRAME_RELEASE( face->sbit_table );
face->sbit_table_size = 0;
face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
}
return error;
}
FT_LOCAL_DEF( void )
tt_face_free_sbit( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->sbit_table );
face->sbit_table_size = 0;
face->sbit_table_type = TT_SBIT_TABLE_TYPE_NONE;
face->sbit_num_strikes = 0;
}
FT_LOCAL_DEF( FT_Error )
tt_face_set_sbit_strike( TT_Face face,
FT_Size_Request req,
FT_ULong* astrike_index )
{
return FT_Match_Size( (FT_Face)face, req, 0, astrike_index );
}
FT_LOCAL_DEF( FT_Error )
tt_face_load_strike_metrics( TT_Face face,
FT_ULong strike_index,
FT_Size_Metrics* metrics )
{
if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
return FT_THROW( Invalid_Argument );
switch ( (FT_UInt)face->sbit_table_type )
{
case TT_SBIT_TABLE_TYPE_EBLC:
case TT_SBIT_TABLE_TYPE_CBLC:
{
FT_Byte* strike;
strike = face->sbit_table + 8 + strike_index * 48;
metrics->x_ppem = (FT_UShort)strike[44];
metrics->y_ppem = (FT_UShort)strike[45];
metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */
metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */
metrics->height = metrics->ascender - metrics->descender;
/* Is this correct? */
metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */
strike[18] + /* max_width */
(FT_Char)strike[23] /* min_advance_SB */
) << 6;
return FT_Err_Ok;
}
case TT_SBIT_TABLE_TYPE_SBIX:
{
FT_Stream stream = face->root.stream;
FT_UInt offset, ppem, resolution, upem;
TT_HoriHeader *hori;
FT_ULong table_size;
FT_Error error;
FT_Byte* p;
p = face->sbit_table + 8 + 4 * strike_index;
offset = FT_NEXT_ULONG( p );
error = face->goto_table( face, TTAG_sbix, stream, &table_size );
if ( error )
return error;
if ( offset + 4 > table_size )
return FT_THROW( Invalid_File_Format );
if ( FT_STREAM_SEEK( FT_STREAM_POS() + offset ) ||
FT_FRAME_ENTER( 4 ) )
return error;
ppem = FT_GET_USHORT();
resolution = FT_GET_USHORT();
FT_UNUSED( resolution ); /* What to do with this? */
FT_FRAME_EXIT();
upem = face->header.Units_Per_EM;
hori = &face->horizontal;
metrics->x_ppem = ppem;
metrics->y_ppem = ppem;
metrics->ascender = ppem * hori->Ascender * 64 / upem;
metrics->descender = ppem * hori->Descender * 64 / upem;
metrics->height = ppem * ( hori->Ascender -
hori->Descender +
hori->Line_Gap ) * 64 / upem;
metrics->max_advance = ppem * hori->advance_Width_Max * 64 / upem;
return error;
}
default:
return FT_THROW( Unknown_File_Format );
}
}
typedef struct TT_SBitDecoderRec_
{
TT_Face face;
FT_Stream stream;
FT_Bitmap* bitmap;
TT_SBit_Metrics metrics;
FT_Bool metrics_loaded;
FT_Bool bitmap_allocated;
FT_Byte bit_depth;
FT_ULong ebdt_start;
FT_ULong ebdt_size;
FT_ULong strike_index_array;
FT_ULong strike_index_count;
FT_Byte* eblc_base;
FT_Byte* eblc_limit;
} TT_SBitDecoderRec, *TT_SBitDecoder;
static FT_Error
tt_sbit_decoder_init( TT_SBitDecoder decoder,
TT_Face face,
FT_ULong strike_index,
TT_SBit_MetricsRec* metrics )
{
FT_Error error;
FT_Stream stream = face->root.stream;
FT_ULong ebdt_size;
error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
if ( error )
error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
if ( error )
goto Exit;
decoder->face = face;
decoder->stream = stream;
decoder->bitmap = &face->root.glyph->bitmap;
decoder->metrics = metrics;
decoder->metrics_loaded = 0;
decoder->bitmap_allocated = 0;
decoder->ebdt_start = FT_STREAM_POS();
decoder->ebdt_size = ebdt_size;
decoder->eblc_base = face->sbit_table;
decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
/* now find the strike corresponding to the index */
{
FT_Byte* p;
if ( 8 + 48 * strike_index + 3 * 4 + 34 + 1 > face->sbit_table_size )
{
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
p = decoder->eblc_base + 8 + 48 * strike_index;
decoder->strike_index_array = FT_NEXT_ULONG( p );
p += 4;
decoder->strike_index_count = FT_NEXT_ULONG( p );
p += 34;
decoder->bit_depth = *p;
if ( decoder->strike_index_array > face->sbit_table_size ||
decoder->strike_index_array + 8 * decoder->strike_index_count >
face->sbit_table_size )
error = FT_THROW( Invalid_File_Format );
}
Exit:
return error;
}
static void
tt_sbit_decoder_done( TT_SBitDecoder decoder )
{
FT_UNUSED( decoder );
}
static FT_Error
tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder )
{
FT_Error error = FT_Err_Ok;
FT_UInt width, height;
FT_Bitmap* map = decoder->bitmap;
FT_Long size;
if ( !decoder->metrics_loaded )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
width = decoder->metrics->width;
height = decoder->metrics->height;
map->width = (int)width;
map->rows = (int)height;
switch ( decoder->bit_depth )
{
case 1:
map->pixel_mode = FT_PIXEL_MODE_MONO;
map->pitch = ( map->width + 7 ) >> 3;
map->num_grays = 2;
break;
case 2:
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
map->pitch = ( map->width + 3 ) >> 2;
map->num_grays = 4;
break;
case 4:
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
map->pitch = ( map->width + 1 ) >> 1;
map->num_grays = 16;
break;
case 8:
map->pixel_mode = FT_PIXEL_MODE_GRAY;
map->pitch = map->width;
map->num_grays = 256;
break;
case 32:
map->pixel_mode = FT_PIXEL_MODE_BGRA;
map->pitch = map->width * 4;
map->num_grays = 256;
break;
default:
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
size = map->rows * map->pitch;
/* check that there is no empty image */
if ( size == 0 )
goto Exit; /* exit successfully! */
error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size );
if ( error )
goto Exit;
decoder->bitmap_allocated = 1;
Exit:
return error;
}
static FT_Error
tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder,
FT_Byte* *pp,
FT_Byte* limit,
FT_Bool big )
{
FT_Byte* p = *pp;
TT_SBit_Metrics metrics = decoder->metrics;
if ( p + 5 > limit )
goto Fail;
metrics->height = p[0];
metrics->width = p[1];
metrics->horiBearingX = (FT_Char)p[2];
metrics->horiBearingY = (FT_Char)p[3];
metrics->horiAdvance = p[4];
p += 5;
if ( big )
{
if ( p + 3 > limit )
goto Fail;
metrics->vertBearingX = (FT_Char)p[0];
metrics->vertBearingY = (FT_Char)p[1];
metrics->vertAdvance = p[2];
p += 3;
}
decoder->metrics_loaded = 1;
*pp = p;
return FT_Err_Ok;
Fail:
FT_TRACE1(( "tt_sbit_decoder_load_metrics: broken table" ));
return FT_THROW( Invalid_Argument );
}
/* forward declaration */
static FT_Error
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
FT_UInt glyph_index,
FT_Int x_pos,
FT_Int y_pos );
typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder,
FT_Byte* p,
FT_Byte* plimit,
FT_Int x_pos,
FT_Int y_pos );
static FT_Error
tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder,
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
FT_Int y_pos )
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
FT_Int bit_height, bit_width, pitch, width, height, line_bits, h;
FT_Bitmap* bitmap;
/* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
bit_width = bitmap->width;
bit_height = bitmap->rows;
pitch = bitmap->pitch;
line = bitmap->buffer;
width = decoder->metrics->width;
height = decoder->metrics->height;
line_bits = width * decoder->bit_depth;
if ( x_pos < 0 || x_pos + width > bit_width ||
y_pos < 0 || y_pos + height > bit_height )
{
FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
" invalid bitmap dimensions\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( p + ( ( line_bits + 7 ) >> 3 ) * height > limit )
{
FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned: broken bitmap\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* now do the blit */
line += y_pos * pitch + ( x_pos >> 3 );
x_pos &= 7;
if ( x_pos == 0 ) /* the easy one */
{
for ( h = height; h > 0; h--, line += pitch )
{
FT_Byte* pwrite = line;
FT_Int w;
for ( w = line_bits; w >= 8; w -= 8 )
{
pwrite[0] = (FT_Byte)( pwrite[0] | *p++ );
pwrite += 1;
}
if ( w > 0 )
pwrite[0] = (FT_Byte)( pwrite[0] | ( *p++ & ( 0xFF00U >> w ) ) );
}
}
else /* x_pos > 0 */
{
for ( h = height; h > 0; h--, line += pitch )
{
FT_Byte* pwrite = line;
FT_Int w;
FT_UInt wval = 0;
for ( w = line_bits; w >= 8; w -= 8 )
{
wval = (FT_UInt)( wval | *p++ );
pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
pwrite += 1;
wval <<= 8;
}
if ( w > 0 )
wval = (FT_UInt)( wval | ( *p++ & ( 0xFF00U >> w ) ) );
/* all bits read and there are `x_pos + w' bits to be written */
pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
if ( x_pos + w > 8 )
{
pwrite++;
wval <<= 8;
pwrite[0] = (FT_Byte)( pwrite[0] | ( wval >> x_pos ) );
}
}
}
Exit:
if ( !error )
FT_TRACE3(( "tt_sbit_decoder_load_byte_aligned: loaded\n" ));
return error;
}
/*
* Load a bit-aligned bitmap (with pointer `p') into a line-aligned bitmap
* (with pointer `pwrite'). In the example below, the width is 3 pixel,
* and `x_pos' is 1 pixel.
*
* p p+1
* | | |
* | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 |...
* | | |
* +-------+ +-------+ +-------+ ...
* . . .
* . . .
* v . .
* +-------+ . .
* | | .
* | 7 6 5 4 3 2 1 0 | .
* | | .
* pwrite . .
* . .
* v .
* +-------+ .
* | |
* | 7 6 5 4 3 2 1 0 |
* | |
* pwrite+1 .
* .
* v
* +-------+
* | |
* | 7 6 5 4 3 2 1 0 |
* | |
* pwrite+2
*
*/
static FT_Error
tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder,
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
FT_Int y_pos )
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
FT_Int bit_height, bit_width, pitch, width, height, line_bits, h, nbits;
FT_Bitmap* bitmap;
FT_UShort rval;
/* check that we can write the glyph into the bitmap */
bitmap = decoder->bitmap;
bit_width = bitmap->width;
bit_height = bitmap->rows;
pitch = bitmap->pitch;
line = bitmap->buffer;
width = decoder->metrics->width;
height = decoder->metrics->height;
line_bits = width * decoder->bit_depth;
if ( x_pos < 0 || x_pos + width > bit_width ||
y_pos < 0 || y_pos + height > bit_height )
{
FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
" invalid bitmap dimensions\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
if ( p + ( ( line_bits * height + 7 ) >> 3 ) > limit )
{
FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned: broken bitmap\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
/* now do the blit */
/* adjust `line' to point to the first byte of the bitmap */
line += y_pos * pitch + ( x_pos >> 3 );
x_pos &= 7;
/* the higher byte of `rval' is used as a buffer */
rval = 0;
nbits = 0;
for ( h = height; h > 0; h--, line += pitch )
{
FT_Byte* pwrite = line;
FT_Int w = line_bits;
/* handle initial byte (in target bitmap) specially if necessary */
if ( x_pos )
{
w = ( line_bits < 8 - x_pos ) ? line_bits : 8 - x_pos;
if ( h == height )
{
rval = *p++;
nbits = x_pos;
}
else if ( nbits < w )
{
if ( p < limit )
rval |= *p++;
nbits += 8 - w;
}
else
{
rval >>= 8;
nbits -= w;
}
*pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
rval <<= 8;
w = line_bits - w;
}
/* handle medial bytes */
for ( ; w >= 8; w -= 8 )
{
rval |= *p++;
*pwrite++ |= ( rval >> nbits ) & 0xFF;
rval <<= 8;
}
/* handle final byte if necessary */
if ( w > 0 )
{
if ( nbits < w )
{
if ( p < limit )
rval |= *p++;
*pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
nbits += 8 - w;
rval <<= 8;
}
else
{
*pwrite |= ( ( rval >> nbits ) & 0xFF ) & ( 0xFF00U >> w );
nbits -= w;
}
}
}
Exit:
if ( !error )
FT_TRACE3(( "tt_sbit_decoder_load_bit_aligned: loaded\n" ));
return error;
}
static FT_Error
tt_sbit_decoder_load_compound( TT_SBitDecoder decoder,
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
FT_Int y_pos )
{
FT_Error error = FT_Err_Ok;
FT_UInt num_components, nn;
FT_Char horiBearingX = decoder->metrics->horiBearingX;
FT_Char horiBearingY = decoder->metrics->horiBearingY;
FT_Byte horiAdvance = decoder->metrics->horiAdvance;
FT_Char vertBearingX = decoder->metrics->vertBearingX;
FT_Char vertBearingY = decoder->metrics->vertBearingY;
FT_Byte vertAdvance = decoder->metrics->vertAdvance;
if ( p + 2 > limit )
goto Fail;
num_components = FT_NEXT_USHORT( p );
if ( p + 4 * num_components > limit )
{
FT_TRACE1(( "tt_sbit_decoder_load_compound: broken table\n" ));
goto Fail;
}
FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n",
num_components ));
for ( nn = 0; nn < num_components; nn++ )
{
FT_UInt gindex = FT_NEXT_USHORT( p );
FT_Byte dx = FT_NEXT_BYTE( p );
FT_Byte dy = FT_NEXT_BYTE( p );
/* NB: a recursive call */
error = tt_sbit_decoder_load_image( decoder, gindex,
x_pos + dx, y_pos + dy );
if ( error )
break;
}
FT_TRACE3(( "tt_sbit_decoder_load_compound: done\n" ));
decoder->metrics->horiBearingX = horiBearingX;
decoder->metrics->horiBearingY = horiBearingY;
decoder->metrics->horiAdvance = horiAdvance;
decoder->metrics->vertBearingX = vertBearingX;
decoder->metrics->vertBearingY = vertBearingY;
decoder->metrics->vertAdvance = vertAdvance;
decoder->metrics->width = (FT_Byte)decoder->bitmap->width;
decoder->metrics->height = (FT_Byte)decoder->bitmap->rows;
Exit:
return error;
Fail:
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
#ifdef FT_CONFIG_OPTION_USE_PNG
static FT_Error
tt_sbit_decoder_load_png( TT_SBitDecoder decoder,
FT_Byte* p,
FT_Byte* limit,
FT_Int x_pos,
FT_Int y_pos )
{
FT_Error error = FT_Err_Ok;
FT_ULong png_len;
if ( limit - p < 4 )
{
FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
png_len = FT_NEXT_ULONG( p );
if ( (FT_ULong)( limit - p ) < png_len )
{
FT_TRACE1(( "tt_sbit_decoder_load_png: broken bitmap\n" ));
error = FT_THROW( Invalid_File_Format );
goto Exit;
}
error = Load_SBit_Png( decoder->face->root.glyph,
x_pos,
y_pos,
decoder->bit_depth,
decoder->metrics,
decoder->stream->memory,
p,
png_len,
FALSE );
Exit:
if ( !error )
FT_TRACE3(( "tt_sbit_decoder_load_png: loaded\n" ));
return error;
}
#endif /* FT_CONFIG_OPTION_USE_PNG */
static FT_Error
tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder,
FT_UInt glyph_format,
FT_ULong glyph_start,
FT_ULong glyph_size,
FT_Int x_pos,
FT_Int y_pos )
{
FT_Error error;
FT_Stream stream = decoder->stream;
FT_Byte* p;
FT_Byte* p_limit;
FT_Byte* data;
/* seek into the EBDT table now */
if ( glyph_start + glyph_size > decoder->ebdt_size )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) ||
FT_FRAME_EXTRACT( glyph_size, data ) )
goto Exit;
p = data;
p_limit = p + glyph_size;
/* read the data, depending on the glyph format */
switch ( glyph_format )
{
case 1:
case 2:
case 8:
case 17:
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 );
break;
case 6:
case 7:
case 9:
case 18:
error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 );
break;
default:
error = FT_Err_Ok;
}
if ( error )
goto Fail;
{
TT_SBitDecoder_LoadFunc loader;
switch ( glyph_format )
{
case 1:
case 6:
loader = tt_sbit_decoder_load_byte_aligned;
break;
case 2:
case 7:
{
/* Don't trust `glyph_format'. For example, Apple's main Korean */
/* system font, `AppleMyungJo.ttf' (version 7.0d2e6), uses glyph */
/* format 7, but the data is format 6. We check whether we have */
/* an excessive number of bytes in the image: If it is equal to */
/* the value for a byte-aligned glyph, use the other loading */
/* routine. */
/* */
/* Note that for some (width,height) combinations, where the */
/* width is not a multiple of 8, the sizes for bit- and */
/* byte-aligned data are equal, for example (7,7) or (15,6). We */
/* then prefer what `glyph_format' specifies. */
FT_UInt width = decoder->metrics->width;
FT_UInt height = decoder->metrics->height;
FT_UInt bit_size = ( width * height + 7 ) >> 3;
FT_UInt byte_size = height * ( ( width + 7 ) >> 3 );
if ( bit_size < byte_size &&
byte_size == (FT_UInt)( p_limit - p ) )
loader = tt_sbit_decoder_load_byte_aligned;
else
loader = tt_sbit_decoder_load_bit_aligned;
}
break;
case 5:
loader = tt_sbit_decoder_load_bit_aligned;
break;
case 8:
if ( p + 1 > p_limit )
goto Fail;
p += 1; /* skip padding */
/* fall-through */
case 9:
loader = tt_sbit_decoder_load_compound;
break;
case 17: /* small metrics, PNG image data */
case 18: /* big metrics, PNG image data */
case 19: /* metrics in EBLC, PNG image data */
#ifdef FT_CONFIG_OPTION_USE_PNG
loader = tt_sbit_decoder_load_png;
break;
#else
error = FT_THROW( Unimplemented_Feature );
goto Fail;
#endif /* FT_CONFIG_OPTION_USE_PNG */
default:
error = FT_THROW( Invalid_Table );
goto Fail;
}
if ( !decoder->bitmap_allocated )
{
error = tt_sbit_decoder_alloc_bitmap( decoder );
if ( error )
goto Fail;
}
error = loader( decoder, p, p_limit, x_pos, y_pos );
}
Fail:
FT_FRAME_RELEASE( data );
Exit:
return error;
}
static FT_Error
tt_sbit_decoder_load_image( TT_SBitDecoder decoder,
FT_UInt glyph_index,
FT_Int x_pos,
FT_Int y_pos )
{
/*
* First, we find the correct strike range that applies to this
* glyph index.
*/
FT_Byte* p = decoder->eblc_base + decoder->strike_index_array;
FT_Byte* p_limit = decoder->eblc_limit;
FT_ULong num_ranges = decoder->strike_index_count;
FT_UInt start, end, index_format, image_format;
FT_ULong image_start = 0, image_end = 0, image_offset;
for ( ; num_ranges > 0; num_ranges-- )
{
start = FT_NEXT_USHORT( p );
end = FT_NEXT_USHORT( p );
if ( glyph_index >= start && glyph_index <= end )
goto FoundRange;
p += 4; /* ignore index offset */
}
goto NoBitmap;
FoundRange:
image_offset = FT_NEXT_ULONG( p );
/* overflow check */
p = decoder->eblc_base + decoder->strike_index_array;
if ( image_offset > (FT_ULong)( p_limit - p ) )
goto Failure;
p += image_offset;
if ( p + 8 > p_limit )
goto NoBitmap;
/* now find the glyph's location and extend within the ebdt table */
index_format = FT_NEXT_USHORT( p );
image_format = FT_NEXT_USHORT( p );
image_offset = FT_NEXT_ULONG ( p );
switch ( index_format )
{
case 1: /* 4-byte offsets relative to `image_offset' */
p += 4 * ( glyph_index - start );
if ( p + 8 > p_limit )
goto NoBitmap;
image_start = FT_NEXT_ULONG( p );
image_end = FT_NEXT_ULONG( p );
if ( image_start == image_end ) /* missing glyph */
goto NoBitmap;
break;
case 2: /* big metrics, constant image size */
{
FT_ULong image_size;
if ( p + 12 > p_limit )
goto NoBitmap;
image_size = FT_NEXT_ULONG( p );
if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
goto NoBitmap;
image_start = image_size * ( glyph_index - start );
image_end = image_start + image_size;
}
break;
case 3: /* 2-byte offsets relative to 'image_offset' */
p += 2 * ( glyph_index - start );
if ( p + 4 > p_limit )
goto NoBitmap;
image_start = FT_NEXT_USHORT( p );
image_end = FT_NEXT_USHORT( p );
if ( image_start == image_end ) /* missing glyph */
goto NoBitmap;
break;
case 4: /* sparse glyph array with (glyph,offset) pairs */
{
FT_ULong mm, num_glyphs;
if ( p + 4 > p_limit )
goto NoBitmap;
num_glyphs = FT_NEXT_ULONG( p );
/* overflow check for p + ( num_glyphs + 1 ) * 4 */
if ( num_glyphs > (FT_ULong)( ( ( p_limit - p ) >> 2 ) - 1 ) )
goto NoBitmap;
for ( mm = 0; mm < num_glyphs; mm++ )
{
FT_UInt gindex = FT_NEXT_USHORT( p );
if ( gindex == glyph_index )
{
image_start = FT_NEXT_USHORT( p );
p += 2;
image_end = FT_PEEK_USHORT( p );
break;
}
p += 2;
}
if ( mm >= num_glyphs )
goto NoBitmap;
}
break;
case 5: /* constant metrics with sparse glyph codes */
case 19:
{
FT_ULong image_size, mm, num_glyphs;
if ( p + 16 > p_limit )
goto NoBitmap;
image_size = FT_NEXT_ULONG( p );
if ( tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ) )
goto NoBitmap;
num_glyphs = FT_NEXT_ULONG( p );
/* overflow check for p + 2 * num_glyphs */
if ( num_glyphs > (FT_ULong)( ( p_limit - p ) >> 1 ) )
goto NoBitmap;
for ( mm = 0; mm < num_glyphs; mm++ )
{
FT_UInt gindex = FT_NEXT_USHORT( p );
if ( gindex == glyph_index )
break;
}
if ( mm >= num_glyphs )
goto NoBitmap;
image_start = image_size * mm;
image_end = image_start + image_size;
}
break;
default:
goto NoBitmap;
}
if ( image_start > image_end )
goto NoBitmap;
image_end -= image_start;
image_start = image_offset + image_start;
FT_TRACE3(( "tt_sbit_decoder_load_image:"
" found sbit (format %d) for glyph index %d\n",
image_format, glyph_index ));
return tt_sbit_decoder_load_bitmap( decoder,
image_format,
image_start,
image_end,
x_pos,
y_pos );
Failure:
return FT_THROW( Invalid_Table );
NoBitmap:
FT_TRACE4(( "tt_sbit_decoder_load_image:"
" no sbit found for glyph index %d\n", glyph_index ));
return FT_THROW( Invalid_Argument );
}
static FT_Error
tt_face_load_sbix_image( TT_Face face,
FT_ULong strike_index,
FT_UInt glyph_index,
FT_Stream stream,
FT_Bitmap *map,
TT_SBit_MetricsRec *metrics )
{
FT_UInt sbix_pos, strike_offset, glyph_start, glyph_end;
FT_ULong table_size;
FT_Int originOffsetX, originOffsetY;
FT_Tag graphicType;
FT_Int recurse_depth = 0;
FT_Error error;
FT_Byte* p;
FT_UNUSED( map );
metrics->width = 0;
metrics->height = 0;
p = face->sbit_table + 8 + 4 * strike_index;
strike_offset = FT_NEXT_ULONG( p );
error = face->goto_table( face, TTAG_sbix, stream, &table_size );
if ( error )
return error;
sbix_pos = FT_STREAM_POS();
retry:
if ( glyph_index > (FT_UInt)face->root.num_glyphs )
return FT_THROW( Invalid_Argument );
if ( strike_offset >= table_size ||
table_size - strike_offset < 4 + glyph_index * 4 + 8 )
return FT_THROW( Invalid_File_Format );
if ( FT_STREAM_SEEK( sbix_pos + strike_offset + 4 + glyph_index * 4 ) ||
FT_FRAME_ENTER( 8 ) )
return error;
glyph_start = FT_GET_ULONG();
glyph_end = FT_GET_ULONG();
FT_FRAME_EXIT();
if ( glyph_start == glyph_end )
return FT_THROW( Invalid_Argument );
if ( glyph_start > glyph_end ||
glyph_end - glyph_start < 8 ||
table_size - strike_offset < glyph_end )
return FT_THROW( Invalid_File_Format );
if ( FT_STREAM_SEEK( sbix_pos + strike_offset + glyph_start ) ||
FT_FRAME_ENTER( glyph_end - glyph_start ) )
return error;
originOffsetX = FT_GET_SHORT();
originOffsetY = FT_GET_SHORT();
graphicType = FT_GET_TAG4();
switch ( graphicType )
{
case FT_MAKE_TAG( 'd', 'u', 'p', 'e' ):
if ( recurse_depth < 4 )
{
glyph_index = FT_GET_USHORT();
FT_FRAME_EXIT();
recurse_depth++;
goto retry;
}
error = FT_THROW( Invalid_File_Format );
break;
case FT_MAKE_TAG( 'p', 'n', 'g', ' ' ):
#ifdef FT_CONFIG_OPTION_USE_PNG
error = Load_SBit_Png( face->root.glyph,
0,
0,
32,
metrics,
stream->memory,
stream->cursor,
glyph_end - glyph_start - 8,
TRUE );
#else
error = FT_THROW( Unimplemented_Feature );
#endif
break;
case FT_MAKE_TAG( 'j', 'p', 'g', ' ' ):
case FT_MAKE_TAG( 't', 'i', 'f', 'f' ):
error = FT_THROW( Unknown_File_Format );
break;
default:
error = FT_THROW( Unimplemented_Feature );
break;
}
FT_FRAME_EXIT();
if ( !error )
{
FT_Short abearing;
FT_UShort aadvance;
tt_face_get_metrics( face, FALSE, glyph_index, &abearing, &aadvance );
metrics->horiBearingX = originOffsetX;
metrics->horiBearingY = -originOffsetY + metrics->height;
metrics->horiAdvance = aadvance * face->root.size->metrics.x_ppem /
face->header.Units_Per_EM;
}
return error;
}
FT_LOCAL( FT_Error )
tt_face_load_sbit_image( TT_Face face,
FT_ULong strike_index,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Stream stream,
FT_Bitmap *map,
TT_SBit_MetricsRec *metrics )
{
FT_Error error = FT_Err_Ok;
switch ( (FT_UInt)face->sbit_table_type )
{
case TT_SBIT_TABLE_TYPE_EBLC:
case TT_SBIT_TABLE_TYPE_CBLC:
{
TT_SBitDecoderRec decoder[1];
error = tt_sbit_decoder_init( decoder, face, strike_index, metrics );
if ( !error )
{
error = tt_sbit_decoder_load_image( decoder,
glyph_index,
0,
0 );
tt_sbit_decoder_done( decoder );
}
}
break;
case TT_SBIT_TABLE_TYPE_SBIX:
error = tt_face_load_sbix_image( face,
strike_index,
glyph_index,
stream,
map,
metrics );
break;
default:
error = FT_THROW( Unknown_File_Format );
break;
}
/* Flatten color bitmaps if color was not requested. */
if ( !error &&
!( load_flags & FT_LOAD_COLOR ) &&
map->pixel_mode == FT_PIXEL_MODE_BGRA )
{
FT_Bitmap new_map;
FT_Library library = face->root.glyph->library;
FT_Bitmap_New( &new_map );
/* Convert to 8bit grayscale. */
error = FT_Bitmap_Convert( library, map, &new_map, 1 );
if ( error )
FT_Bitmap_Done( library, &new_map );
else
{
map->pixel_mode = new_map.pixel_mode;
map->pitch = new_map.pitch;
map->num_grays = new_map.num_grays;
ft_glyphslot_set_bitmap( face->root.glyph, new_map.buffer );
face->root.glyph->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
}
return error;
}
/* EOF */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttsbit.c | C | apache-2.0 | 40,448 |
/***************************************************************************/
/* */
/* ttsbit.h */
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
/* Copyright 1996-2008, 2013 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 __TTSBIT_H__
#define __TTSBIT_H__
#include <ft2build.h>
#include "ttload.h"
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_load_sbit( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
tt_face_free_sbit( TT_Face face );
FT_LOCAL( FT_Error )
tt_face_set_sbit_strike( TT_Face face,
FT_Size_Request req,
FT_ULong* astrike_index );
FT_LOCAL( FT_Error )
tt_face_load_strike_metrics( TT_Face face,
FT_ULong strike_index,
FT_Size_Metrics* metrics );
FT_LOCAL( FT_Error )
tt_face_load_sbit_image( TT_Face face,
FT_ULong strike_index,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Stream stream,
FT_Bitmap *map,
TT_SBit_MetricsRec *metrics );
FT_END_HEADER
#endif /* __TTSBIT_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/sfnt/ttsbit.h | C | apache-2.0 | 2,388 |
/***************************************************************************/
/* */
/* ftgrays.c */
/* */
/* A new `perfect' anti-aliasing renderer (body). */
/* */
/* Copyright 2000-2003, 2005-2014 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file can be compiled without the rest of the FreeType engine, by */
/* defining the _STANDALONE_ macro when compiling it. You also need to */
/* put the files `ftgrays.h' and `ftimage.h' into the current */
/* compilation directory. Typically, you could do something like */
/* */
/* - copy `src/smooth/ftgrays.c' (this file) to your current directory */
/* */
/* - copy `include/ftimage.h' and `src/smooth/ftgrays.h' to the same */
/* directory */
/* */
/* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */
/* */
/* cc -c -D_STANDALONE_ ftgrays.c */
/* */
/* The renderer can be initialized with a call to */
/* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */
/* with a call to `ft_gray_raster.raster_render'. */
/* */
/* See the comments and documentation in the file `ftimage.h' for more */
/* details on how the raster works. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* This is a new anti-aliasing scan-converter for FreeType 2. The */
/* algorithm used here is _very_ different from the one in the standard */
/* `ftraster' module. Actually, `ftgrays' computes the _exact_ */
/* coverage of the outline on each pixel cell. */
/* */
/* It is based on ideas that I initially found in Raph Levien's */
/* excellent LibArt graphics library (see http://www.levien.com/libart */
/* for more information, though the web pages do not tell anything */
/* about the renderer; you'll have to dive into the source code to */
/* understand how it works). */
/* */
/* Note, however, that this is a _very_ different implementation */
/* compared to Raph's. Coverage information is stored in a very */
/* different way, and I don't use sorted vector paths. Also, it doesn't */
/* use floating point values. */
/* */
/* This renderer has the following advantages: */
/* */
/* - It doesn't need an intermediate bitmap. Instead, one can supply a */
/* callback function that will be called by the renderer to draw gray */
/* spans on any target surface. You can thus do direct composition on */
/* any kind of bitmap, provided that you give the renderer the right */
/* callback. */
/* */
/* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */
/* each pixel cell. */
/* */
/* - It performs a single pass on the outline (the `standard' FT2 */
/* renderer makes two passes). */
/* */
/* - It can easily be modified to render to _any_ number of gray levels */
/* cheaply. */
/* */
/* - For small (< 20) pixel sizes, it is faster than the standard */
/* renderer. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* 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_smooth
#ifdef _STANDALONE_
/* Auxiliary macros for token concatenation. */
#define FT_ERR_XCAT( x, y ) x ## y
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
/* define this to dump debugging information */
/* #define FT_DEBUG_LEVEL_TRACE */
#ifdef FT_DEBUG_LEVEL_TRACE
#include <stdio.h>
#include <stdarg.h>
#endif
#include <stddef.h>
#include <string.h>
#include <setjmp.h>
#include <limits.h>
#define FT_UINT_MAX UINT_MAX
#define FT_INT_MAX INT_MAX
#define ft_memset memset
#define ft_setjmp setjmp
#define ft_longjmp longjmp
#define ft_jmp_buf jmp_buf
typedef ptrdiff_t FT_PtrDist;
#define ErrRaster_Invalid_Mode -2
#define ErrRaster_Invalid_Outline -1
#define ErrRaster_Invalid_Argument -3
#define ErrRaster_Memory_Overflow -4
#define FT_BEGIN_HEADER
#define FT_END_HEADER
#include "ftimage.h"
#include "ftgrays.h"
/* This macro is used to indicate that a function parameter is unused. */
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
/* ANSI compilers (e.g. LCC). */
#define FT_UNUSED( x ) (x) = (x)
/* we only use level 5 & 7 tracing messages; cf. ftdebug.h */
#ifdef FT_DEBUG_LEVEL_TRACE
void
FT_Message( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
va_end( ap );
}
/* empty function useful for setting a breakpoint to catch errors */
int
FT_Throw( int error,
int line,
const char* file )
{
FT_UNUSED( error );
FT_UNUSED( line );
FT_UNUSED( file );
return 0;
}
/* we don't handle tracing levels in stand-alone mode; */
#ifndef FT_TRACE5
#define FT_TRACE5( varformat ) FT_Message varformat
#endif
#ifndef FT_TRACE7
#define FT_TRACE7( varformat ) FT_Message varformat
#endif
#ifndef FT_ERROR
#define FT_ERROR( varformat ) FT_Message varformat
#endif
#define FT_THROW( e ) \
( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
__LINE__, \
__FILE__ ) | \
FT_ERR_CAT( ErrRaster, e ) )
#else /* !FT_DEBUG_LEVEL_TRACE */
#define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */
#define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */
#define FT_ERROR( x ) do { } while ( 0 ) /* nothing */
#define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e )
#endif /* !FT_DEBUG_LEVEL_TRACE */
#define FT_DEFINE_OUTLINE_FUNCS( class_, \
move_to_, line_to_, \
conic_to_, cubic_to_, \
shift_, delta_ ) \
static const FT_Outline_Funcs class_ = \
{ \
move_to_, \
line_to_, \
conic_to_, \
cubic_to_, \
shift_, \
delta_ \
};
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \
raster_new_, raster_reset_, \
raster_set_mode_, raster_render_, \
raster_done_ ) \
const FT_Raster_Funcs class_ = \
{ \
glyph_format_, \
raster_new_, \
raster_reset_, \
raster_set_mode_, \
raster_render_, \
raster_done_ \
};
#else /* !_STANDALONE_ */
#include <ft2build.h>
#include "ftgrays.h"
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_OUTLINE_H
#include "ftsmerrs.h"
#include "ftspic.h"
#define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
#define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory
#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
#endif /* !_STANDALONE_ */
#ifndef FT_MEM_SET
#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
#endif
#ifndef FT_MEM_ZERO
#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
#endif
/* as usual, for the speed hungry :-) */
#undef RAS_ARG
#undef RAS_ARG_
#undef RAS_VAR
#undef RAS_VAR_
#ifndef FT_STATIC_RASTER
#define RAS_ARG gray_PWorker worker
#define RAS_ARG_ gray_PWorker worker,
#define RAS_VAR worker
#define RAS_VAR_ worker,
#else /* FT_STATIC_RASTER */
#define RAS_ARG /* empty */
#define RAS_ARG_ /* empty */
#define RAS_VAR /* empty */
#define RAS_VAR_ /* empty */
#endif /* FT_STATIC_RASTER */
/* must be at least 6 bits! */
#define PIXEL_BITS 8
#undef FLOOR
#undef CEILING
#undef TRUNC
#undef SCALED
#define ONE_PIXEL ( 1L << PIXEL_BITS )
#define PIXEL_MASK ( -1L << PIXEL_BITS )
#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS )
#define FLOOR( x ) ( (x) & -ONE_PIXEL )
#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL )
#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL )
#if PIXEL_BITS >= 6
#define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) )
#define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) )
#else
#define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) )
#define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) )
#endif
/* Compute `dividend / divisor' and return both its quotient and */
/* remainder, cast to a specific type. This macro also ensures that */
/* the remainder is always positive. */
#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
FT_BEGIN_STMNT \
(quotient) = (type)( (dividend) / (divisor) ); \
(remainder) = (type)( (dividend) % (divisor) ); \
if ( (remainder) < 0 ) \
{ \
(quotient)--; \
(remainder) += (type)(divisor); \
} \
FT_END_STMNT
#ifdef __arm__
/* Work around a bug specific to GCC which make the compiler fail to */
/* optimize a division and modulo operation on the same parameters */
/* into a single call to `__aeabi_idivmod'. See */
/* */
/* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */
#undef FT_DIV_MOD
#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
FT_BEGIN_STMNT \
(quotient) = (type)( (dividend) / (divisor) ); \
(remainder) = (type)( (dividend) - (quotient) * (divisor) ); \
if ( (remainder) < 0 ) \
{ \
(quotient)--; \
(remainder) += (type)(divisor); \
} \
FT_END_STMNT
#endif /* __arm__ */
/*************************************************************************/
/* */
/* TYPE DEFINITIONS */
/* */
/* don't change the following types to FT_Int or FT_Pos, since we might */
/* need to define them to "float" or "double" when experimenting with */
/* new algorithms */
typedef long TCoord; /* integer scanline/pixel coordinate */
typedef long TPos; /* sub-pixel coordinate */
/* determine the type used to store cell areas. This normally takes at */
/* least PIXEL_BITS*2 + 1 bits. On 16-bit systems, we need to use */
/* `long' instead of `int', otherwise bad things happen */
#if PIXEL_BITS <= 7
typedef int TArea;
#else /* PIXEL_BITS >= 8 */
/* approximately determine the size of integers using an ANSI-C header */
#if FT_UINT_MAX == 0xFFFFU
typedef long TArea;
#else
typedef int TArea;
#endif
#endif /* PIXEL_BITS >= 8 */
/* maximum number of gray spans in a call to the span callback */
#define FT_MAX_GRAY_SPANS 32
typedef struct TCell_* PCell;
typedef struct TCell_
{
TPos x; /* same with gray_TWorker.ex */
TCoord cover; /* same with gray_TWorker.cover */
TArea area;
PCell next;
} TCell;
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `structure was padded due to */
/* __declspec(align())' in order to compile cleanly with */
/* the maximum level of warnings. */
#pragma warning( push )
#pragma warning( disable : 4324 )
#endif /* _MSC_VER */
typedef struct gray_TWorker_
{
TCoord ex, ey;
TPos min_ex, max_ex;
TPos min_ey, max_ey;
TPos count_ex, count_ey;
TArea area;
TCoord cover;
int invalid;
PCell cells;
FT_PtrDist max_cells;
FT_PtrDist num_cells;
TCoord cx, cy;
TPos x, y;
TPos last_ey;
FT_Vector bez_stack[32 * 3 + 1];
int lev_stack[32];
FT_Outline outline;
FT_Bitmap target;
FT_BBox clip_box;
FT_Span gray_spans[FT_MAX_GRAY_SPANS];
int num_gray_spans;
FT_Raster_Span_Func render_span;
void* render_span_data;
int span_y;
int band_size;
int band_shoot;
ft_jmp_buf jump_buffer;
void* buffer;
long buffer_size;
PCell* ycells;
TPos ycount;
} gray_TWorker, *gray_PWorker;
#if defined( _MSC_VER )
#pragma warning( pop )
#endif
#ifndef FT_STATIC_RASTER
#define ras (*worker)
#else
static gray_TWorker ras;
#endif
typedef struct gray_TRaster_
{
void* buffer;
long buffer_size;
int band_size;
void* memory;
gray_PWorker worker;
} gray_TRaster, *gray_PRaster;
/*************************************************************************/
/* */
/* Initialize the cells table. */
/* */
static void
gray_init_cells( RAS_ARG_ void* buffer,
long byte_size )
{
ras.buffer = buffer;
ras.buffer_size = byte_size;
ras.ycells = (PCell*) buffer;
ras.cells = NULL;
ras.max_cells = 0;
ras.num_cells = 0;
ras.area = 0;
ras.cover = 0;
ras.invalid = 1;
}
/*************************************************************************/
/* */
/* Compute the outline bounding box. */
/* */
static void
gray_compute_cbox( RAS_ARG )
{
FT_Outline* outline = &ras.outline;
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
if ( outline->n_points <= 0 )
{
ras.min_ex = ras.max_ex = 0;
ras.min_ey = ras.max_ey = 0;
return;
}
ras.min_ex = ras.max_ex = vec->x;
ras.min_ey = ras.max_ey = vec->y;
vec++;
for ( ; vec < limit; vec++ )
{
TPos x = vec->x;
TPos y = vec->y;
if ( x < ras.min_ex ) ras.min_ex = x;
if ( x > ras.max_ex ) ras.max_ex = x;
if ( y < ras.min_ey ) ras.min_ey = y;
if ( y > ras.max_ey ) ras.max_ey = y;
}
/* truncate the bounding box to integer pixels */
ras.min_ex = ras.min_ex >> 6;
ras.min_ey = ras.min_ey >> 6;
ras.max_ex = ( ras.max_ex + 63 ) >> 6;
ras.max_ey = ( ras.max_ey + 63 ) >> 6;
}
/*************************************************************************/
/* */
/* Record the current cell in the table. */
/* */
static PCell
gray_find_cell( RAS_ARG )
{
PCell *pcell, cell;
TPos x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
pcell = &ras.ycells[ras.ey];
for (;;)
{
cell = *pcell;
if ( cell == NULL || cell->x > x )
break;
if ( cell->x == x )
goto Exit;
pcell = &cell->next;
}
if ( ras.num_cells >= ras.max_cells )
ft_longjmp( ras.jump_buffer, 1 );
cell = ras.cells + ras.num_cells++;
cell->x = x;
cell->area = 0;
cell->cover = 0;
cell->next = *pcell;
*pcell = cell;
Exit:
return cell;
}
static void
gray_record_cell( RAS_ARG )
{
if ( ras.area | ras.cover )
{
PCell cell = gray_find_cell( RAS_VAR );
cell->area += ras.area;
cell->cover += ras.cover;
}
}
/*************************************************************************/
/* */
/* Set the current cell to a new position. */
/* */
static void
gray_set_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
/* Move the cell pointer to a new position. We set the `invalid' */
/* flag to indicate that the cell isn't part of those we're interested */
/* in during the render phase. This means that: */
/* */
/* . the new vertical position must be within min_ey..max_ey-1. */
/* . the new horizontal position must be strictly less than max_ex */
/* */
/* Note that if a cell is to the left of the clipping region, it is */
/* actually set to the (min_ex-1) horizontal position. */
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
{
/* record the current one if it is valid */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
ras.area = 0;
ras.cover = 0;
ras.ex = ex;
ras.ey = ey;
}
ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
ex >= ras.count_ex );
}
/*************************************************************************/
/* */
/* Start a new contour at a given cell. */
/* */
static void
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
if ( ex > ras.max_ex )
ex = (TCoord)( ras.max_ex );
if ( ex < ras.min_ex )
ex = (TCoord)( ras.min_ex - 1 );
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.last_ey = SUBPIXELS( ey );
ras.invalid = 0;
gray_set_cell( RAS_VAR_ ex, ey );
}
/*************************************************************************/
/* */
/* Render a scanline as one or more cells. */
/* */
static void
gray_render_scanline( RAS_ARG_ TCoord ey,
TPos x1,
TCoord y1,
TPos x2,
TCoord y2 )
{
TCoord ex1, ex2, fx1, fx2, delta, mod;
long p, first, dx;
int incr;
dx = x2 - x1;
ex1 = TRUNC( x1 );
ex2 = TRUNC( x2 );
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
/* trivial case. Happens often */
if ( y1 == y2 )
{
gray_set_cell( RAS_VAR_ ex2, ey );
return;
}
/* everything is located in a single cell. That is easy! */
/* */
if ( ex1 == ex2 )
{
delta = y2 - y1;
ras.area += (TArea)(( fx1 + fx2 ) * delta);
ras.cover += delta;
return;
}
/* ok, we'll have to render a run of adjacent cells on the same */
/* scanline... */
/* */
p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 );
first = ONE_PIXEL;
incr = 1;
if ( dx < 0 )
{
p = fx1 * ( y2 - y1 );
first = 0;
incr = -1;
dx = -dx;
}
FT_DIV_MOD( TCoord, p, dx, delta, mod );
ras.area += (TArea)(( fx1 + first ) * delta);
ras.cover += delta;
ex1 += incr;
gray_set_cell( RAS_VAR_ ex1, ey );
y1 += delta;
if ( ex1 != ex2 )
{
TCoord lift, rem;
p = ONE_PIXEL * ( y2 - y1 + delta );
FT_DIV_MOD( TCoord, p, dx, lift, rem );
mod -= (int)dx;
while ( ex1 != ex2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (TCoord)dx;
delta++;
}
ras.area += (TArea)(ONE_PIXEL * delta);
ras.cover += delta;
y1 += delta;
ex1 += incr;
gray_set_cell( RAS_VAR_ ex1, ey );
}
}
delta = y2 - y1;
ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta);
ras.cover += delta;
}
/*************************************************************************/
/* */
/* Render a given line as a series of scanlines. */
/* */
static void
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
TCoord ey1, ey2, fy1, fy2, mod;
TPos dx, dy, x, x2;
long p, first;
int delta, rem, lift, incr;
ey1 = TRUNC( ras.last_ey );
ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
fy1 = (TCoord)( ras.y - ras.last_ey );
fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
dx = to_x - ras.x;
dy = to_y - ras.y;
/* perform vertical clipping */
{
TCoord min, max;
min = ey1;
max = ey2;
if ( ey1 > ey2 )
{
min = ey2;
max = ey1;
}
if ( min >= ras.max_ey || max < ras.min_ey )
goto End;
}
/* everything is on a single scanline */
if ( ey1 == ey2 )
{
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
goto End;
}
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 );
TArea area;
first = ONE_PIXEL;
if ( dy < 0 )
{
first = 0;
incr = -1;
}
delta = (int)( first - fy1 );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
delta = (int)( first + first - ONE_PIXEL );
area = (TArea)two_fx * delta;
while ( ey1 != ey2 )
{
ras.area += area;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
}
delta = (int)( fy2 - ONE_PIXEL + first );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
goto End;
}
/* ok, we have to render several scanlines */
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
if ( dy < 0 )
{
p = fy1 * dx;
first = 0;
incr = -1;
dy = -dy;
}
FT_DIV_MOD( int, p, dy, delta, mod );
x = ras.x + delta;
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
if ( ey1 != ey2 )
{
p = ONE_PIXEL * dx;
FT_DIV_MOD( int, p, dy, lift, rem );
mod -= (int)dy;
while ( ey1 != ey2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (int)dy;
delta++;
}
x2 = x + delta;
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), x2,
(TCoord)first );
x = x2;
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
}
}
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), to_x,
fy2 );
End:
ras.x = to_x;
ras.y = to_y;
ras.last_ey = SUBPIXELS( ey2 );
}
static void
gray_split_conic( FT_Vector* base )
{
TPos a, b;
base[4].x = base[2].x;
b = base[1].x;
a = base[3].x = ( base[2].x + b ) / 2;
b = base[1].x = ( base[0].x + b ) / 2;
base[2].x = ( a + b ) / 2;
base[4].y = base[2].y;
b = base[1].y;
a = base[3].y = ( base[2].y + b ) / 2;
b = base[1].y = ( base[0].y + b ) / 2;
base[2].y = ( a + b ) / 2;
}
static void
gray_render_conic( RAS_ARG_ const FT_Vector* control,
const FT_Vector* to )
{
TPos dx, dy;
TPos min, max, y;
int top, level;
int* levels;
FT_Vector* arc;
levels = ras.lev_stack;
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control->x );
arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x;
arc[2].y = ras.y;
top = 0;
dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
if ( dx < dy )
dx = dy;
if ( dx < ONE_PIXEL / 4 )
goto Draw;
/* short-cut the arc that crosses the current band */
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw;
level = 0;
do
{
dx >>= 2;
level++;
} while ( dx > ONE_PIXEL / 4 );
levels[0] = level;
do
{
level = levels[top];
if ( level > 0 )
{
gray_split_conic( arc );
arc += 2;
top++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
top--;
arc -= 2;
} while ( top >= 0 );
}
static void
gray_split_cubic( FT_Vector* base )
{
TPos a, b, c, d;
base[6].x = base[3].x;
c = base[1].x;
d = base[2].x;
base[1].x = a = ( base[0].x + c ) / 2;
base[5].x = b = ( base[3].x + d ) / 2;
c = ( c + d ) / 2;
base[2].x = a = ( a + c ) / 2;
base[4].x = b = ( b + c ) / 2;
base[3].x = ( a + b ) / 2;
base[6].y = base[3].y;
c = base[1].y;
d = base[2].y;
base[1].y = a = ( base[0].y + c ) / 2;
base[5].y = b = ( base[3].y + d ) / 2;
c = ( c + d ) / 2;
base[2].y = a = ( a + c ) / 2;
base[4].y = b = ( b + c ) / 2;
base[3].y = ( a + b ) / 2;
}
static void
gray_render_cubic( RAS_ARG_ const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to )
{
FT_Vector* arc;
TPos min, max, y;
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control2->x );
arc[1].y = UPSCALE( control2->y );
arc[2].x = UPSCALE( control1->x );
arc[2].y = UPSCALE( control1->y );
arc[3].x = ras.x;
arc[3].y = ras.y;
/* Short-cut the arc that crosses the current band. */
min = max = arc[0].y;
y = arc[1].y;
if ( y < min )
min = y;
if ( y > max )
max = y;
y = arc[2].y;
if ( y < min )
min = y;
if ( y > max )
max = y;
y = arc[3].y;
if ( y < min )
min = y;
if ( y > max )
max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw;
for (;;)
{
/* Decide whether to split or draw. See `Rapid Termination */
/* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */
/* F. Hain, at */
/* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */
{
TPos dx, dy, dx_, dy_;
TPos dx1, dy1, dx2, dy2;
TPos L, s, s_limit;
/* dx and dy are x and y components of the P0-P3 chord vector. */
dx = arc[3].x - arc[0].x;
dy = arc[3].y - arc[0].y;
/* L is an (under)estimate of the Euclidean distance P0-P3. */
/* */
/* If dx >= dy, then r = sqrt(dx^2 + dy^2) can be overestimated */
/* with least maximum error by */
/* */
/* r_upperbound = dx + (sqrt(2) - 1) * dy , */
/* */
/* where sqrt(2) - 1 can be (over)estimated by 107/256, giving an */
/* error of no more than 8.4%. */
/* */
/* Similarly, some elementary calculus shows that r can be */
/* underestimated with least maximum error by */
/* */
/* r_lowerbound = sqrt(2 + sqrt(2)) / 2 * dx */
/* + sqrt(2 - sqrt(2)) / 2 * dy . */
/* */
/* 236/256 and 97/256 are (under)estimates of the two algebraic */
/* numbers, giving an error of no more than 8.1%. */
dx_ = FT_ABS( dx );
dy_ = FT_ABS( dy );
/* This is the same as */
/* */
/* L = ( 236 * FT_MAX( dx_, dy_ ) */
/* + 97 * FT_MIN( dx_, dy_ ) ) >> 8; */
L = ( dx_ > dy_ ? 236 * dx_ + 97 * dy_
: 97 * dx_ + 236 * dy_ ) >> 8;
/* Avoid possible arithmetic overflow below by splitting. */
if ( L > 32767 )
goto Split;
/* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */
s_limit = L * (TPos)( ONE_PIXEL / 6 );
/* s is L * the perpendicular distance from P1 to the line P0-P3. */
dx1 = arc[1].x - arc[0].x;
dy1 = arc[1].y - arc[0].y;
s = FT_ABS( dy * dx1 - dx * dy1 );
if ( s > s_limit )
goto Split;
/* s is L * the perpendicular distance from P2 to the line P0-P3. */
dx2 = arc[2].x - arc[0].x;
dy2 = arc[2].y - arc[0].y;
s = FT_ABS( dy * dx2 - dx * dy2 );
if ( s > s_limit )
goto Split;
/* Split super curvy segments where the off points are so far
from the chord that the angles P0-P1-P3 or P0-P2-P3 become
acute as detected by appropriate dot products. */
if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 ||
dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 )
goto Split;
/* No reason to split. */
goto Draw;
}
Split:
gray_split_cubic( arc );
arc += 3;
continue;
Draw:
gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
if ( arc == ras.bez_stack )
return;
arc -= 3;
}
}
static int
gray_move_to( const FT_Vector* to,
gray_PWorker worker )
{
TPos x, y;
/* record current cell, if any */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
/* start to a new position */
x = UPSCALE( to->x );
y = UPSCALE( to->y );
gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
worker->x = x;
worker->y = y;
return 0;
}
static int
gray_line_to( const FT_Vector* to,
gray_PWorker worker )
{
gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
return 0;
}
static int
gray_conic_to( const FT_Vector* control,
const FT_Vector* to,
gray_PWorker worker )
{
gray_render_conic( RAS_VAR_ control, to );
return 0;
}
static int
gray_cubic_to( const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
gray_PWorker worker )
{
gray_render_cubic( RAS_VAR_ control1, control2, to );
return 0;
}
static void
gray_render_span( int y,
int count,
const FT_Span* spans,
gray_PWorker worker )
{
unsigned char* p;
FT_Bitmap* map = &worker->target;
/* first of all, compute the scanline offset */
p = (unsigned char*)map->buffer - y * map->pitch;
if ( map->pitch >= 0 )
p += (unsigned)( ( map->rows - 1 ) * map->pitch );
for ( ; count > 0; count--, spans++ )
{
unsigned char coverage = spans->coverage;
if ( coverage )
{
/* For small-spans it is faster to do it by ourselves than
* calling `memset'. This is mainly due to the cost of the
* function call.
*/
if ( spans->len >= 8 )
FT_MEM_SET( p + spans->x, (unsigned char)coverage, spans->len );
else
{
unsigned char* q = p + spans->x;
switch ( spans->len )
{
case 7: *q++ = (unsigned char)coverage;
case 6: *q++ = (unsigned char)coverage;
case 5: *q++ = (unsigned char)coverage;
case 4: *q++ = (unsigned char)coverage;
case 3: *q++ = (unsigned char)coverage;
case 2: *q++ = (unsigned char)coverage;
case 1: *q = (unsigned char)coverage;
default:
;
}
}
}
}
}
static void
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TPos area,
TCoord acount )
{
int coverage;
/* compute the coverage line's coverage, depending on the */
/* outline fill rule */
/* */
/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
/* */
coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );
/* use range 0..256 */
if ( coverage < 0 )
coverage = -coverage;
if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
{
coverage &= 511;
if ( coverage > 256 )
coverage = 512 - coverage;
else if ( coverage == 256 )
coverage = 255;
}
else
{
/* normal non-zero winding rule */
if ( coverage >= 256 )
coverage = 255;
}
y += (TCoord)ras.min_ey;
x += (TCoord)ras.min_ex;
/* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
if ( x >= 32767 )
x = 32767;
/* FT_Span.y is an integer, so limit our coordinates appropriately */
if ( y >= FT_INT_MAX )
y = FT_INT_MAX;
if ( coverage )
{
FT_Span* span;
int count;
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
if ( count > 0 &&
ras.span_y == y &&
(int)span->x + span->len == (int)x &&
span->coverage == coverage )
{
span->len = (unsigned short)( span->len + acount );
return;
}
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
{
if ( ras.render_span && count > 0 )
ras.render_span( ras.span_y, count, ras.gray_spans,
ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( count > 0 )
{
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < count; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
ras.num_gray_spans = 0;
ras.span_y = (int)y;
span = ras.gray_spans;
}
else
span++;
/* add a gray span to the current list */
span->x = (short)x;
span->len = (unsigned short)acount;
span->coverage = (unsigned char)coverage;
ras.num_gray_spans++;
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
/* to be called while in the debugger -- */
/* this function causes a compiler warning since it is unused otherwise */
static void
gray_dump_cells( RAS_ARG )
{
int yindex;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell;
printf( "%3d:", yindex );
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area );
printf( "\n" );
}
}
#endif /* FT_DEBUG_LEVEL_TRACE */
static void
gray_sweep( RAS_ARG_ const FT_Bitmap* target )
{
int yindex;
FT_UNUSED( target );
if ( ras.num_cells == 0 )
return;
ras.num_gray_spans = 0;
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell = ras.ycells[yindex];
TCoord cover = 0;
TCoord x = 0;
for ( ; cell != NULL; cell = cell->next )
{
TPos area;
if ( cell->x > x && cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
cell->x - x );
cover += cell->cover;
area = cover * ( ONE_PIXEL * 2 ) - cell->area;
if ( area != 0 && cell->x >= 0 )
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
x = cell->x + 1;
}
if ( cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
ras.count_ex - x );
}
if ( ras.render_span && ras.num_gray_spans > 0 )
ras.render_span( ras.span_y, ras.num_gray_spans,
ras.gray_spans, ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ras.num_gray_spans > 0 )
{
FT_Span* span;
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < ras.num_gray_spans; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
FT_TRACE7(( "gray_sweep: end\n" ));
#endif /* FT_DEBUG_LEVEL_TRACE */
}
#ifdef _STANDALONE_
/*************************************************************************/
/* */
/* The following function should only compile in stand-alone mode, */
/* i.e., when building this component without the rest of FreeType. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* FT_Outline_Decompose */
/* */
/* <Description> */
/* Walk over an outline's structure to decompose it into individual */
/* segments and Bézier arcs. This function is also able to emit */
/* `move to' and `close to' operations to indicate the start and end */
/* of new contours in the outline. */
/* */
/* <Input> */
/* outline :: A pointer to the source target. */
/* */
/* func_interface :: A table of `emitters', i.e., function pointers */
/* called during decomposition to indicate path */
/* operations. */
/* */
/* <InOut> */
/* user :: A typeless pointer which is passed to each */
/* emitter during the decomposition. It can be */
/* used to store the state during the */
/* decomposition. */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
static int
FT_Outline_Decompose( const FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
void* user )
{
#undef SCALED
#define SCALED( x ) ( ( (x) << shift ) - delta )
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
FT_Vector* point;
FT_Vector* limit;
char* tags;
int error;
int n; /* index of contour in outline */
int first; /* index of first point in contour */
char tag; /* current point's state */
int shift;
TPos delta;
if ( !outline || !func_interface )
return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
{
int last; /* index of last point in contour */
FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
last = outline->contours[n];
if ( last < 0 )
goto Invalid_Outline;
limit = outline->points + last;
v_start = outline->points[first];
v_start.x = SCALED( v_start.x );
v_start.y = SCALED( v_start.y );
v_last = outline->points[last];
v_last.x = SCALED( v_last.x );
v_last.y = SCALED( v_last.y );
v_control = v_start;
point = outline->points + first;
tags = outline->tags + first;
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle and record its position */
/* for closure */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
v_last = v_start;
}
point--;
tags--;
}
FT_TRACE5(( " move to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->move_to( &v_start, user );
if ( error )
goto Exit;
while ( point < limit )
{
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " line to (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0 ));
error = func_interface->line_to( &vec, user );
if ( error )
goto Exit;
continue;
}
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = SCALED( point->x );
v_control.y = SCALED( point->y );
Do_Conic:
if ( point < limit )
{
FT_Vector vec;
FT_Vector v_middle;
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
if ( tag == FT_CURVE_TAG_ON )
{
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &vec, user );
if ( error )
goto Exit;
continue;
}
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2;
v_middle.y = ( v_control.y + vec.y ) / 2;
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_middle.x / 64.0, v_middle.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_middle, user );
if ( error )
goto Exit;
v_control = vec;
goto Do_Conic;
}
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_start, user );
goto Close;
default: /* FT_CURVE_TAG_CUBIC */
{
FT_Vector vec1, vec2;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
tags += 2;
vec1.x = SCALED( point[-2].x );
vec1.y = SCALED( point[-2].y );
vec2.x = SCALED( point[-1].x );
vec2.y = SCALED( point[-1].y );
if ( point <= limit )
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
if ( error )
goto Exit;
continue;
}
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
goto Close;
}
}
}
/* close the contour with a line segment */
FT_TRACE5(( " line to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->line_to( &v_start, user );
Close:
if ( error )
goto Exit;
first = last + 1;
}
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
return 0;
Exit:
FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error ));
return error;
Invalid_Outline:
return FT_THROW( Invalid_Outline );
}
#endif /* _STANDALONE_ */
typedef struct gray_TBand_
{
TPos min, max;
} gray_TBand;
FT_DEFINE_OUTLINE_FUNCS(func_interface,
(FT_Outline_MoveTo_Func) gray_move_to,
(FT_Outline_LineTo_Func) gray_line_to,
(FT_Outline_ConicTo_Func)gray_conic_to,
(FT_Outline_CubicTo_Func)gray_cubic_to,
0,
0
)
static int
gray_convert_glyph_inner( RAS_ARG )
{
volatile int error = 0;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs func_interface;
Init_Class_func_interface(&func_interface);
#endif
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
}
else
error = FT_THROW( Memory_Overflow );
return error;
}
static int
gray_convert_glyph( RAS_ARG )
{
gray_TBand bands[40];
gray_TBand* volatile band;
int volatile n, num_bands;
TPos volatile min, max, max_y;
FT_BBox* clip;
/* Set up state in the raster object */
gray_compute_cbox( RAS_VAR );
/* clip to target bitmap, exit if nothing to do */
clip = &ras.clip_box;
if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
return 0;
if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
num_bands = 39;
ras.band_shoot = 0;
min = ras.min_ey;
max_y = ras.max_ey;
for ( n = 0; n < num_bands; n++, min = max )
{
max = min + ras.band_size;
if ( n == num_bands - 1 || max > max_y )
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = bands;
while ( band >= bands )
{
TPos bottom, top, middle;
int error;
{
PCell cells_max;
int yindex;
long cell_start, cell_end, cell_mod;
ras.ycells = (PCell*)ras.buffer;
ras.ycount = band->max - band->min;
cell_start = sizeof ( PCell ) * ras.ycount;
cell_mod = cell_start % sizeof ( TCell );
if ( cell_mod > 0 )
cell_start += sizeof ( TCell ) - cell_mod;
cell_end = ras.buffer_size;
cell_end -= cell_end % sizeof ( TCell );
cells_max = (PCell)( (char*)ras.buffer + cell_end );
ras.cells = (PCell)( (char*)ras.buffer + cell_start );
if ( ras.cells >= cells_max )
goto ReduceBands;
ras.max_cells = cells_max - ras.cells;
if ( ras.max_cells < 2 )
goto ReduceBands;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
ras.ycells[yindex] = NULL;
}
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = band->min;
ras.max_ey = band->max;
ras.count_ey = band->max - band->min;
error = gray_convert_glyph_inner( RAS_VAR );
if ( !error )
{
gray_sweep( RAS_VAR_ &ras.target );
band--;
continue;
}
else if ( error != ErrRaster_Memory_Overflow )
return 1;
ReduceBands:
/* render pool overflow; we will reduce the render band by half */
bottom = band->min;
top = band->max;
middle = bottom + ( ( top - bottom ) >> 1 );
/* This is too complex for a single scanline; there must */
/* be some problems. */
if ( middle == bottom )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
#endif
return 1;
}
if ( bottom-top >= ras.band_size )
ras.band_shoot++;
band[1].min = bottom;
band[1].max = middle;
band[0].min = middle;
band[0].max = top;
band++;
}
}
if ( ras.band_shoot > 8 && ras.band_size > 16 )
ras.band_size = ras.band_size / 2;
return 0;
}
static int
gray_raster_render( gray_PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
gray_PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return FT_THROW( Invalid_Argument );
if ( !outline )
return FT_THROW( Invalid_Outline );
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
return FT_THROW( Invalid_Outline );
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return FT_THROW( Invalid_Outline );
worker = raster->worker;
/* if direct mode is not set, we must have a target bitmap */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
return FT_THROW( Invalid_Argument );
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
return FT_THROW( Invalid_Argument );
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return FT_THROW( Invalid_Mode );
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
/* compute clip box from target pixmap */
ras.clip_box.xMin = 0;
ras.clip_box.yMin = 0;
ras.clip_box.xMax = target_map->width;
ras.clip_box.yMax = target_map->rows;
}
else if ( params->flags & FT_RASTER_FLAG_CLIP )
ras.clip_box = params->clip_box;
else
{
ras.clip_box.xMin = -32768L;
ras.clip_box.yMin = -32768L;
ras.clip_box.xMax = 32767L;
ras.clip_box.yMax = 32767L;
}
gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.num_gray_spans = 0;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
ras.target = *target_map;
ras.render_span = (FT_Raster_Span_Func)gray_render_span;
ras.render_span_data = &ras;
}
return gray_convert_glyph( RAS_VAR );
}
/**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/
/**** a static object. *****/
#ifdef _STANDALONE_
static int
gray_raster_new( void* memory,
FT_Raster* araster )
{
static gray_TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
return 0;
}
static void
gray_raster_done( FT_Raster raster )
{
/* nothing */
FT_UNUSED( raster );
}
#else /* !_STANDALONE_ */
static int
gray_raster_new( FT_Memory memory,
FT_Raster* araster )
{
FT_Error error = FT_Err_Ok;
gray_PRaster raster = NULL;
*araster = 0;
if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) )
{
raster->memory = memory;
*araster = (FT_Raster)raster;
}
return error;
}
static void
gray_raster_done( FT_Raster raster )
{
FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory;
FT_FREE( raster );
}
#endif /* !_STANDALONE_ */
static void
gray_raster_reset( FT_Raster raster,
char* pool_base,
long pool_size )
{
gray_PRaster rast = (gray_PRaster)raster;
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 )
{
gray_PWorker worker = (gray_PWorker)pool_base;
rast->worker = worker;
rast->buffer = pool_base +
( ( sizeof ( gray_TWorker ) +
sizeof ( TCell ) - 1 ) &
~( sizeof ( TCell ) - 1 ) );
rast->buffer_size = (long)( ( pool_base + pool_size ) -
(char*)rast->buffer ) &
~( sizeof ( TCell ) - 1 );
rast->band_size = (int)( rast->buffer_size /
( sizeof ( TCell ) * 8 ) );
}
else
{
rast->buffer = NULL;
rast->buffer_size = 0;
rast->worker = NULL;
}
}
}
FT_DEFINE_RASTER_FUNCS(ft_grays_raster,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Raster_New_Func) gray_raster_new,
(FT_Raster_Reset_Func) gray_raster_reset,
(FT_Raster_Set_Mode_Func)0,
(FT_Raster_Render_Func) gray_raster_render,
(FT_Raster_Done_Func) gray_raster_done
)
/* END */
/* Local Variables: */
/* coding: utf-8 */
/* End: */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftgrays.c | C | apache-2.0 | 63,089 |
/***************************************************************************/
/* */
/* ftgrays.h */
/* */
/* FreeType smooth renderer declaration */
/* */
/* Copyright 1996-2001 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 __FTGRAYS_H__
#define __FTGRAYS_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _STANDALONE_
#include "ftimage.h"
#else
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H /* for FT_CONFIG_OPTION_PIC */
#include FT_IMAGE_H
#endif
/*************************************************************************/
/* */
/* To make ftgrays.h independent from configuration files we check */
/* whether FT_EXPORT_VAR has been defined already. */
/* */
/* On some systems and compilers (Win32 mostly), an extra keyword is */
/* necessary to compile the library as a DLL. */
/* */
#ifndef FT_EXPORT_VAR
#define FT_EXPORT_VAR( x ) extern x
#endif
FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_grays_raster;
#ifdef __cplusplus
}
#endif
#endif /* __FTGRAYS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftgrays.h | C | apache-2.0 | 2,318 |
/***************************************************************************/
/* */
/* ftsmerrs.h */
/* */
/* smooth renderer error codes (specification only). */
/* */
/* Copyright 2001, 2012 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the smooth renderer error enumeration */
/* constants. */
/* */
/*************************************************************************/
#ifndef __FTSMERRS_H__
#define __FTSMERRS_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX Smooth_Err_
#define FT_ERR_BASE FT_Mod_Err_Smooth
#include FT_ERRORS_H
#endif /* __FTSMERRS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftsmerrs.h | C | apache-2.0 | 1,979 |
/***************************************************************************/
/* */
/* ftsmooth.c */
/* */
/* Anti-aliasing renderer interface (body). */
/* */
/* Copyright 2000-2006, 2009-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include "ftsmooth.h"
#include "ftgrays.h"
#include "ftspic.h"
#include "ftsmerrs.h"
/* initialize renderer -- init its raster */
static FT_Error
ft_smooth_init( FT_Renderer render )
{
FT_Library library = FT_MODULE_LIBRARY( render );
render->clazz->raster_class->raster_reset( render->raster,
library->raster_pool,
library->raster_pool_size );
return 0;
}
/* sets render-specific mode */
static FT_Error
ft_smooth_set_mode( FT_Renderer render,
FT_ULong mode_tag,
FT_Pointer data )
{
/* we simply pass it to the raster */
return render->clazz->raster_class->raster_set_mode( render->raster,
mode_tag,
data );
}
/* transform a given glyph image */
static FT_Error
ft_smooth_transform( FT_Renderer render,
FT_GlyphSlot slot,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( matrix )
FT_Outline_Transform( &slot->outline, matrix );
if ( delta )
FT_Outline_Translate( &slot->outline, delta->x, delta->y );
Exit:
return error;
}
/* return the glyph's control box */
static void
ft_smooth_get_cbox( FT_Renderer render,
FT_GlyphSlot slot,
FT_BBox* cbox )
{
FT_MEM_ZERO( cbox, sizeof ( *cbox ) );
if ( slot->format == render->glyph_format )
FT_Outline_Get_CBox( &slot->outline, cbox );
}
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_smooth_render_generic( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin,
FT_Render_Mode required_mode )
{
FT_Error error;
FT_Outline* outline = NULL;
FT_BBox cbox;
FT_Pos width, height, pitch;
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
FT_Pos height_org, width_org;
#endif
FT_Bitmap* bitmap = &slot->bitmap;
FT_Memory memory = render->root.memory;
FT_Int hmul = mode == FT_RENDER_MODE_LCD;
FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
FT_Pos x_shift = 0;
FT_Pos y_shift = 0;
FT_Pos x_left, y_top;
FT_Raster_Params params;
FT_Bool have_translated_origin = FALSE;
FT_Bool have_outline_shifted = FALSE;
FT_Bool have_buffer = FALSE;
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* check mode */
if ( mode != required_mode )
{
error = FT_THROW( Cannot_Render_Glyph );
goto Exit;
}
outline = &slot->outline;
/* translate the outline to the new origin if needed */
if ( origin )
{
FT_Outline_Translate( outline, origin->x, origin->y );
have_translated_origin = TRUE;
}
/* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
cbox.xMax = FT_PIX_CEIL( cbox.xMax );
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" xMin = %d, xMax = %d\n",
cbox.xMin >> 6, cbox.xMax >> 6 ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
width = ( cbox.xMax - cbox.xMin ) >> 6;
if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
" yMin = %d, yMax = %d\n",
cbox.yMin >> 6, cbox.yMax >> 6 ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
else
height = ( cbox.yMax - cbox.yMin ) >> 6;
#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
#endif
/* release old bitmap buffer */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
/* allocate new one */
pitch = width;
if ( hmul )
{
width = width * 3;
pitch = FT_PAD_CEIL( width, 4 );
}
if ( vmul )
height *= 3;
x_shift = (FT_Int) cbox.xMin;
y_shift = (FT_Int) cbox.yMin;
x_left = (FT_Int)( cbox.xMin >> 6 );
y_top = (FT_Int)( cbox.yMax >> 6 );
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
if ( slot->library->lcd_filter_func )
{
FT_Int extra = slot->library->lcd_extra;
if ( hmul )
{
x_shift -= 64 * ( extra >> 1 );
width += 3 * extra;
pitch = FT_PAD_CEIL( width, 4 );
x_left -= extra >> 1;
}
if ( vmul )
{
y_shift -= 64 * ( extra >> 1 );
height += 3 * extra;
y_top += extra >> 1;
}
}
#endif
#if FT_UINT_MAX > 0xFFFFU
/* Required check is (pitch * height < FT_ULONG_MAX), */
/* but we care realistic cases only. Always pitch <= width. */
if ( width > 0x7FFF || height > 0x7FFF )
{
FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
width, height ));
error = FT_THROW( Raster_Overflow );
goto Exit;
}
#endif
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
bitmap->width = width;
bitmap->rows = height;
bitmap->pitch = pitch;
/* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -x_shift, -y_shift );
have_outline_shifted = TRUE;
if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
goto Exit;
else
have_buffer = TRUE;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
/* set up parameters */
params.target = bitmap;
params.source = outline;
params.flags = FT_RASTER_FLAG_AA;
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/* implode outline if needed */
{
FT_Vector* points = outline->points;
FT_Vector* points_end = points + outline->n_points;
FT_Vector* vec;
if ( hmul )
for ( vec = points; vec < points_end; vec++ )
vec->x *= 3;
if ( vmul )
for ( vec = points; vec < points_end; vec++ )
vec->y *= 3;
}
/* render outline into the bitmap */
error = render->raster_render( render->raster, ¶ms );
/* deflate outline if needed */
{
FT_Vector* points = outline->points;
FT_Vector* points_end = points + outline->n_points;
FT_Vector* vec;
if ( hmul )
for ( vec = points; vec < points_end; vec++ )
vec->x /= 3;
if ( vmul )
for ( vec = points; vec < points_end; vec++ )
vec->y /= 3;
}
if ( error )
goto Exit;
if ( slot->library->lcd_filter_func )
slot->library->lcd_filter_func( bitmap, mode, slot->library );
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/* render outline into bitmap */
error = render->raster_render( render->raster, ¶ms );
if ( error )
goto Exit;
/* expand it horizontally */
if ( hmul )
{
FT_Byte* line = bitmap->buffer;
FT_UInt hh;
for ( hh = height_org; hh > 0; hh--, line += pitch )
{
FT_UInt xx;
FT_Byte* end = line + width;
for ( xx = width_org; xx > 0; xx-- )
{
FT_UInt pixel = line[xx-1];
end[-3] = (FT_Byte)pixel;
end[-2] = (FT_Byte)pixel;
end[-1] = (FT_Byte)pixel;
end -= 3;
}
}
}
/* expand it vertically */
if ( vmul )
{
FT_Byte* read = bitmap->buffer + ( height - height_org ) * pitch;
FT_Byte* write = bitmap->buffer;
FT_UInt hh;
for ( hh = height_org; hh > 0; hh-- )
{
ft_memcpy( write, read, pitch );
write += pitch;
ft_memcpy( write, read, pitch );
write += pitch;
ft_memcpy( write, read, pitch );
write += pitch;
read += pitch;
}
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/*
* XXX: on 16bit system, we return an error for huge bitmap
* to prevent an overflow.
*/
if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
{
error = FT_THROW( Invalid_Pixel_Size );
goto Exit;
}
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = (FT_Int)x_left;
slot->bitmap_top = (FT_Int)y_top;
/* everything is fine; don't deallocate buffer */
have_buffer = FALSE;
error = FT_Err_Ok;
Exit:
if ( have_outline_shifted )
FT_Outline_Translate( outline, x_shift, y_shift );
if ( have_translated_origin )
FT_Outline_Translate( outline, -origin->x, -origin->y );
if ( have_buffer )
{
FT_FREE( bitmap->buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
return error;
}
/* convert a slot's glyph image into a bitmap */
static FT_Error
ft_smooth_render( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
if ( mode == FT_RENDER_MODE_LIGHT )
mode = FT_RENDER_MODE_NORMAL;
return ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_NORMAL );
}
/* convert a slot's glyph image into a horizontal LCD bitmap */
static FT_Error
ft_smooth_render_lcd( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
FT_Error error;
error = ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD );
if ( !error )
slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
return error;
}
/* convert a slot's glyph image into a vertical LCD bitmap */
static FT_Error
ft_smooth_render_lcd_v( FT_Renderer render,
FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
FT_Error error;
error = ft_smooth_render_generic( render, slot, mode, origin,
FT_RENDER_MODE_LCD_V );
if ( !error )
slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
return error;
}
FT_DEFINE_RENDERER( ft_smooth_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
"smooth",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
"smooth-lcd",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class,
FT_MODULE_RENDERER,
sizeof ( FT_RendererRec ),
"smooth-lcdv",
0x10000L,
0x20000L,
0, /* module specific interface */
(FT_Module_Constructor)ft_smooth_init,
(FT_Module_Destructor) 0,
(FT_Module_Requester) 0
,
FT_GLYPH_FORMAT_OUTLINE,
(FT_Renderer_RenderFunc) ft_smooth_render_lcd_v,
(FT_Renderer_TransformFunc)ft_smooth_transform,
(FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox,
(FT_Renderer_SetModeFunc) ft_smooth_set_mode,
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftsmooth.c | C | apache-2.0 | 14,244 |
/***************************************************************************/
/* */
/* ftsmooth.h */
/* */
/* Anti-aliasing renderer interface (specification). */
/* */
/* Copyright 1996-2001 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 __FTSMOOTH_H__
#define __FTSMOOTH_H__
#include <ft2build.h>
#include FT_RENDER_H
FT_BEGIN_HEADER
#ifndef FT_CONFIG_OPTION_NO_STD_RASTER
FT_DECLARE_RENDERER( ft_std_renderer_class )
#endif
#ifndef FT_CONFIG_OPTION_NO_SMOOTH_RASTER
FT_DECLARE_RENDERER( ft_smooth_renderer_class )
FT_DECLARE_RENDERER( ft_smooth_lcd_renderer_class )
FT_DECLARE_RENDERER( ft_smooth_lcd_v_renderer_class )
#endif
FT_END_HEADER
#endif /* __FTSMOOTH_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftsmooth.h | C | apache-2.0 | 1,724 |
/***************************************************************************/
/* */
/* ftspic.c */
/* */
/* The FreeType position independent code services for smooth module. */
/* */
/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "ftspic.h"
#include "ftsmerrs.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ftgrays.c */
void
FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs );
void
ft_smooth_renderer_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->smooth )
{
SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
if ( --container->ref_count )
return;
FT_FREE( container );
pic_container->smooth = NULL;
}
}
FT_Error
ft_smooth_renderer_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
SmoothPIC* container = NULL;
FT_Memory memory = library->memory;
/* since this function also serve smooth_lcd and smooth_lcdv renderers,
it implements reference counting */
if ( pic_container->smooth )
{
((SmoothPIC*)pic_container->smooth)->ref_count++;
return error;
}
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->smooth = container;
container->ref_count = 1;
/* initialize pointer table - */
/* this is how the module usually expects this data */
FT_Init_Class_ft_grays_raster( &container->ft_grays_raster );
return error;
}
/* re-route these init and free functions to the above functions */
FT_Error
ft_smooth_lcd_renderer_class_pic_init( FT_Library library )
{
return ft_smooth_renderer_class_pic_init( library );
}
void
ft_smooth_lcd_renderer_class_pic_free( FT_Library library )
{
ft_smooth_renderer_class_pic_free( library );
}
FT_Error
ft_smooth_lcdv_renderer_class_pic_init( FT_Library library )
{
return ft_smooth_renderer_class_pic_init( library );
}
void
ft_smooth_lcdv_renderer_class_pic_free( FT_Library library )
{
ft_smooth_renderer_class_pic_free( library );
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftspic.c | C | apache-2.0 | 3,629 |
/***************************************************************************/
/* */
/* ftspic.h */
/* */
/* The FreeType position independent code services for smooth module. */
/* */
/* Copyright 2009 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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 __FTSPIC_H__
#define __FTSPIC_H__
FT_BEGIN_HEADER
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define FT_GRAYS_RASTER_GET ft_grays_raster
#else /* FT_CONFIG_OPTION_PIC */
typedef struct SmoothPIC_
{
int ref_count;
FT_Raster_Funcs ft_grays_raster;
} SmoothPIC;
#define GET_PIC( lib ) \
( (SmoothPIC*)( (lib)->pic_container.smooth ) )
#define FT_GRAYS_RASTER_GET ( GET_PIC( library )->ft_grays_raster )
/* see ftspic.c for the implementation */
void
ft_smooth_renderer_class_pic_free( FT_Library library );
void
ft_smooth_lcd_renderer_class_pic_free( FT_Library library );
void
ft_smooth_lcdv_renderer_class_pic_free( FT_Library library );
FT_Error
ft_smooth_renderer_class_pic_init( FT_Library library );
FT_Error
ft_smooth_lcd_renderer_class_pic_init( FT_Library library );
FT_Error
ft_smooth_lcdv_renderer_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __FTSPIC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/ftspic.h | C | apache-2.0 | 2,302 |
#
# FreeType 2 smooth renderer module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += SMOOTH_RENDERER
define SMOOTH_RENDERER
$(OPEN_DRIVER) FT_Renderer_Class, ft_smooth_renderer_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer$(ECHO_DRIVER_DONE)
$(OPEN_DRIVER) FT_Renderer_Class, ft_smooth_lcd_renderer_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for LCDs$(ECHO_DRIVER_DONE)
$(OPEN_DRIVER) FT_Renderer_Class, ft_smooth_lcdv_renderer_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)smooth $(ECHO_DRIVER_DESC)anti-aliased bitmap renderer for vertical LCDs$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/smooth/module.mk | Makefile | apache-2.0 | 1,048 |
#
# FreeType 2 smooth renderer module build rules
#
# Copyright 1996-2000, 2001, 2003, 2011 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.
# smooth driver directory
#
SMOOTH_DIR := $(SRC_DIR)/smooth
# compilation flags for the driver
#
SMOOTH_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SMOOTH_DIR))
# smooth driver sources (i.e., C files)
#
SMOOTH_DRV_SRC := $(SMOOTH_DIR)/ftgrays.c \
$(SMOOTH_DIR)/ftsmooth.c \
$(SMOOTH_DIR)/ftspic.c
# smooth driver headers
#
SMOOTH_DRV_H := $(SMOOTH_DRV_SRC:%c=%h) \
$(SMOOTH_DIR)/ftsmerrs.h
# smooth driver object(s)
#
# SMOOTH_DRV_OBJ_M is used during `multi' builds.
# SMOOTH_DRV_OBJ_S is used during `single' builds.
#
SMOOTH_DRV_OBJ_M := $(SMOOTH_DRV_SRC:$(SMOOTH_DIR)/%.c=$(OBJ_DIR)/%.$O)
SMOOTH_DRV_OBJ_S := $(OBJ_DIR)/smooth.$O
# smooth driver source file for single build
#
SMOOTH_DRV_SRC_S := $(SMOOTH_DIR)/smooth.c
# smooth driver - single object
#
$(SMOOTH_DRV_OBJ_S): $(SMOOTH_DRV_SRC_S) $(SMOOTH_DRV_SRC) \
$(FREETYPE_H) $(SMOOTH_DRV_H)
$(SMOOTH_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SMOOTH_DRV_SRC_S))
# smooth driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(SMOOTH_DIR)/%.c $(FREETYPE_H) $(SMOOTH_DRV_H)
$(SMOOTH_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(SMOOTH_DRV_OBJ_S)
DRV_OBJS_M += $(SMOOTH_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/smooth/rules.mk | Makefile | apache-2.0 | 1,743 |
/***************************************************************************/
/* */
/* smooth.c */
/* */
/* FreeType anti-aliasing rasterer module component (body only). */
/* */
/* Copyright 1996-2001 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "ftspic.c"
#include "ftgrays.c"
#include "ftsmooth.c"
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/smooth/smooth.c | C | apache-2.0 | 1,385 |
#! /usr/bin/perl -w
# -*- Perl -*-
#
# afblue.pl
#
# Process a blue zone character data file.
#
# Copyright 2013, 2014 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.
use strict;
use warnings;
use English '-no_match_vars';
use open ':std', ':encoding(UTF-8)';
my $prog = $PROGRAM_NAME;
$prog =~ s| .* / ||x; # Remove path.
die "usage: $prog datafile < infile > outfile\n" if $#ARGV != 0;
my $datafile = $ARGV[0];
my %diversions; # The extracted and massaged data from `datafile'.
my @else_stack; # Booleans to track else-clauses.
my @name_stack; # Stack of integers used for names of aux. variables.
my $curr_enum; # Name of the current enumeration.
my $curr_array; # Name of the current array.
my $curr_max; # Name of the current maximum value.
my $curr_enum_element; # Name of the current enumeration element.
my $curr_offset; # The offset relative to current aux. variable.
my $curr_elem_size; # The size of the current string or block.
my $have_sections = 0; # Boolean; set if start of a section has been seen.
my $have_strings; # Boolean; set if current section contains strings.
my $have_blocks; # Boolean; set if current section contains blocks.
my $have_enum_element; # Boolean; set if we have an enumeration element.
my $in_string; # Boolean; set if a string has been parsed.
my $num_sections = 0; # Number of sections seen so far.
my $last_aux; # Name of last auxiliary variable.
# Regular expressions.
# [<ws>] <enum_name> <ws> <array_name> <ws> <max_name> [<ws>] ':' [<ws>] '\n'
my $section_re = qr/ ^ \s* (\S+) \s+ (\S+) \s+ (\S+) \s* : \s* $ /x;
# [<ws>] <enum_element_name> [<ws>] '\n'
my $enum_element_re = qr/ ^ \s* ( [A-Za-z0-9_]+ ) \s* $ /x;
# '#' <preprocessor directive> '\n'
my $preprocessor_re = qr/ ^ \# /x;
# '/' '/' <comment> '\n'
my $comment_re = qr| ^ // |x;
# empty line
my $whitespace_only_re = qr/ ^ \s* $ /x;
# [<ws>] '"' <string> '"' [<ws>] '\n' (<string> doesn't contain newlines)
my $string_re = qr/ ^ \s*
" ( (?> (?: (?> [^"\\]+ ) | \\. )* ) ) "
\s* $ /x;
# [<ws>] '{' <block> '}' [<ws>] '\n' (<block> can contain newlines)
my $block_start_re = qr/ ^ \s* \{ /x;
# We need the capturing group for `split' to make it return the separator
# tokens (i.e., the opening and closing brace) also.
my $brace_re = qr/ ( [{}] ) /x;
sub Warn
{
my $message = shift;
warn "$datafile:$INPUT_LINE_NUMBER: warning: $message\n";
}
sub Die
{
my $message = shift;
die "$datafile:$INPUT_LINE_NUMBER: error: $message\n";
}
my $warned_before = 0;
sub warn_before
{
Warn("data before first section gets ignored") unless $warned_before;
$warned_before = 1;
}
sub strip_newline
{
chomp;
s/ \x0D $ //x;
}
sub end_curr_string
{
# Append final null byte to string.
if ($have_strings)
{
push @{$diversions{$curr_array}}, " '\\0',\n" if $in_string;
$curr_offset++;
$in_string = 0;
}
}
sub update_max_elem_size
{
if ($curr_elem_size)
{
my $max = pop @{$diversions{$curr_max}};
$max = $curr_elem_size if $curr_elem_size > $max;
push @{$diversions{$curr_max}}, $max;
}
}
sub convert_non_ascii_char
{
# A UTF-8 character outside of the printable ASCII range, with possibly a
# leading backslash character.
my $s = shift;
# Here we count characters, not bytes.
$curr_elem_size += length $s;
utf8::encode($s);
$s = uc unpack 'H*', $s;
$curr_offset += $s =~ s/\G(..)/'\\x$1', /sg;
return $s;
}
sub convert_ascii_chars
{
# A series of ASCII characters in the printable range.
my $s = shift;
my $count = $s =~ s/\G(.)/'$1', /g;
$curr_offset += $count;
$curr_elem_size += $count;
return $s;
}
sub convert_literal
{
my $s = shift;
my $orig = $s;
# ASCII printables and space
my $safe_re = '\x20-\x7E';
# ASCII printables and space, no backslash
my $safe_no_backslash_re = '\x20-\x5B\x5D-\x7E';
$s =~ s{
(?: \\? ( [^$safe_re] )
| ( (?: [$safe_no_backslash_re]
| \\ [$safe_re] )+ ) )
}
{
defined($1) ? convert_non_ascii_char($1)
: convert_ascii_chars($2)
}egx;
# We assume that `$orig' doesn't contain `*/'
return $s . " /* $orig */";
}
sub aux_name
{
return "af_blue_" . $num_sections. "_" . join('_', @name_stack);
}
sub aux_name_next
{
$name_stack[$#name_stack]++;
my $name = aux_name();
$name_stack[$#name_stack]--;
return $name;
}
sub enum_val_string
{
# Build string that holds code to save the current offset in an
# enumeration element.
my $aux = shift;
my $add = ($last_aux eq "af_blue_" . $num_sections . "_0" )
? ""
: "$last_aux + ";
return " $aux = $add$curr_offset,\n";
}
# Process data file.
open(DATA, $datafile) || die "$prog: can't open \`$datafile': $OS_ERROR\n";
while (<DATA>)
{
strip_newline();
next if /$comment_re/;
next if /$whitespace_only_re/;
if (/$section_re/)
{
Warn("previous section is empty") if ($have_sections
&& !$have_strings
&& !$have_blocks);
end_curr_string();
update_max_elem_size();
# Save captured groups from `section_re'.
$curr_enum = $1;
$curr_array = $2;
$curr_max = $3;
$curr_enum_element = "";
$curr_offset = 0;
Warn("overwriting already defined enumeration \`$curr_enum'")
if exists($diversions{$curr_enum});
Warn("overwriting already defined array \`$curr_array'")
if exists($diversions{$curr_array});
Warn("overwriting already defined maximum value \`$curr_max'")
if exists($diversions{$curr_max});
$diversions{$curr_enum} = [];
$diversions{$curr_array} = [];
$diversions{$curr_max} = [];
push @{$diversions{$curr_max}}, 0;
@name_stack = ();
push @name_stack, 0;
$have_sections = 1;
$have_strings = 0;
$have_blocks = 0;
$have_enum_element = 0;
$in_string = 0;
$num_sections++;
$curr_elem_size = 0;
$last_aux = aux_name();
next;
}
if (/$preprocessor_re/)
{
if ($have_sections)
{
# Having preprocessor conditionals complicates the computation of
# correct offset values. We have to introduce auxiliary enumeration
# elements with the name `af_blue_<s>_<n1>_<n2>_...' that store
# offsets to be used in conditional clauses. `<s>' is the number of
# sections seen so far, `<n1>' is the number of `#if' and `#endif'
# conditionals seen so far in the topmost level, `<n2>' the number of
# `#if' and `#endif' conditionals seen so far one level deeper, etc.
# As a consequence, uneven values are used within a clause, and even
# values after a clause, since the C standard doesn't allow the
# redefinition of an enumeration value. For example, the name
# `af_blue_5_1_6' is used to construct enumeration values in the fifth
# section after the third (second-level) if-clause within the first
# (top-level) if-clause. After the first top-level clause has
# finished, `af_blue_5_2' is used. The current offset is then
# relative to the value stored in the current auxiliary element.
if (/ ^ \# \s* if /x)
{
push @else_stack, 0;
$name_stack[$#name_stack]++;
push @{$diversions{$curr_enum}}, enum_val_string(aux_name());
$last_aux = aux_name();
push @name_stack, 0;
$curr_offset = 0;
}
elsif (/ ^ \# \s* elif /x)
{
Die("unbalanced #elif") unless @else_stack;
pop @name_stack;
push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next());
$last_aux = aux_name();
push @name_stack, 0;
$curr_offset = 0;
}
elsif (/ ^ \# \s* else /x)
{
my $prev_else = pop @else_stack;
Die("unbalanced #else") unless defined($prev_else);
Die("#else already seen") if $prev_else;
push @else_stack, 1;
pop @name_stack;
push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next());
$last_aux = aux_name();
push @name_stack, 0;
$curr_offset = 0;
}
elsif (/ ^ (\# \s*) endif /x)
{
my $prev_else = pop @else_stack;
Die("unbalanced #endif") unless defined($prev_else);
pop @name_stack;
# If there is no else-clause for an if-clause, we add one. This is
# necessary to have correct offsets.
if (!$prev_else)
{
# Use amount of whitespace from `endif'.
push @{$diversions{$curr_enum}}, enum_val_string(aux_name_next())
. $1 . "else\n";
$last_aux = aux_name();
$curr_offset = 0;
}
$name_stack[$#name_stack]++;
push @{$diversions{$curr_enum}}, enum_val_string(aux_name());
$last_aux = aux_name();
$curr_offset = 0;
}
# Handle (probably continued) preprocessor lines.
CONTINUED_LOOP:
{
do
{
strip_newline();
push @{$diversions{$curr_enum}}, $ARG . "\n";
push @{$diversions{$curr_array}}, $ARG . "\n";
last CONTINUED_LOOP unless / \\ $ /x;
} while (<DATA>);
}
}
else
{
warn_before();
}
next;
}
if (/$enum_element_re/)
{
end_curr_string();
update_max_elem_size();
$curr_enum_element = $1;
$have_enum_element = 1;
$curr_elem_size = 0;
next;
}
if (/$string_re/)
{
if ($have_sections)
{
Die("strings and blocks can't be mixed in a section") if $have_blocks;
# Save captured group from `string_re'.
my $string = $1;
if ($have_enum_element)
{
push @{$diversions{$curr_enum}}, enum_val_string($curr_enum_element);
$have_enum_element = 0;
}
$string = convert_literal($string);
push @{$diversions{$curr_array}}, " $string\n";
$have_strings = 1;
$in_string = 1;
}
else
{
warn_before();
}
next;
}
if (/$block_start_re/)
{
if ($have_sections)
{
Die("strings and blocks can't be mixed in a section") if $have_strings;
my $depth = 0;
my $block = "";
my $block_end = 0;
# Count braces while getting the block.
BRACE_LOOP:
{
do
{
strip_newline();
foreach my $substring (split(/$brace_re/))
{
if ($block_end)
{
Die("invalid data after last matching closing brace")
if $substring !~ /$whitespace_only_re/;
}
$block .= $substring;
if ($substring eq '{')
{
$depth++;
}
elsif ($substring eq '}')
{
$depth--;
$block_end = 1 if $depth == 0;
}
}
# If we are here, we have run out of substrings, so get next line
# or exit.
last BRACE_LOOP if $block_end;
$block .= "\n";
} while (<DATA>);
}
if ($have_enum_element)
{
push @{$diversions{$curr_enum}}, enum_val_string($curr_enum_element);
$have_enum_element = 0;
}
push @{$diversions{$curr_array}}, $block . ",\n";
$curr_offset++;
$curr_elem_size++;
$have_blocks = 1;
}
else
{
warn_before();
}
next;
}
# Garbage. We weren't able to parse the data.
Die("syntax error");
}
# Finalize data.
end_curr_string();
update_max_elem_size();
# Filter stdin to stdout, replacing `@...@' templates.
sub emit_diversion
{
my $diversion_name = shift;
return (exists($diversions{$1})) ? "@{$diversions{$1}}"
: "@" . $diversion_name . "@";
}
$LIST_SEPARATOR = '';
my $s1 = "This file has been generated by the Perl script \`$prog',";
my $s1len = length $s1;
my $s2 = "using data from file \`$datafile'.";
my $s2len = length $s2;
my $slen = ($s1len > $s2len) ? $s1len : $s2len;
print "/* " . $s1 . " " x ($slen - $s1len) . " */\n"
. "/* " . $s2 . " " x ($slen - $s2len) . " */\n"
. "\n";
while (<STDIN>)
{
s/ @ ( [A-Za-z0-9_]+? ) @ / emit_diversion($1) /egx;
print;
}
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/tools/afblue.pl | Perl | apache-2.0 | 12,748 |
/*
* This little program is used to parse the FreeType headers and
* find the declaration of all public APIs. This is easy, because
* they all look like the following:
*
* FT_EXPORT( return_type )
* function_name( function arguments );
*
* You must pass the list of header files as arguments. Wildcards are
* accepted if you are using GCC for compilation (and probably by
* other compilers too).
*
* Author: David Turner, 2005, 2006, 2008-2013
*
* This code is explicitly placed into the public domain.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define PROGRAM_NAME "apinames"
#define PROGRAM_VERSION "0.2"
#define LINEBUFF_SIZE 1024
typedef enum OutputFormat_
{
OUTPUT_LIST = 0, /* output the list of names, one per line */
OUTPUT_WINDOWS_DEF, /* output a Windows .DEF file for Visual C++ or Mingw */
OUTPUT_BORLAND_DEF, /* output a Windows .DEF file for Borland C++ */
OUTPUT_WATCOM_LBC, /* output a Watcom Linker Command File */
OUTPUT_NETWARE_IMP /* output a NetWare ImportFile */
} OutputFormat;
static void
panic( const char* message )
{
fprintf( stderr, "PANIC: %s\n", message );
exit(2);
}
typedef struct NameRec_
{
char* name;
unsigned int hash;
} NameRec, *Name;
static Name the_names;
static int num_names;
static int max_names;
static void
names_add( const char* name,
const char* end )
{
unsigned int h;
int nn, len;
Name nm;
if ( end <= name )
return;
/* compute hash value */
len = (int)(end - name);
h = 0;
for ( nn = 0; nn < len; nn++ )
h = h*33 + name[nn];
/* check for an pre-existing name */
for ( nn = 0; nn < num_names; nn++ )
{
nm = the_names + nn;
if ( (int)nm->hash == h &&
memcmp( name, nm->name, len ) == 0 &&
nm->name[len] == 0 )
return;
}
/* add new name */
if ( num_names >= max_names )
{
max_names += (max_names >> 1) + 4;
the_names = (NameRec*)realloc( the_names,
sizeof ( the_names[0] ) * max_names );
if ( the_names == NULL )
panic( "not enough memory" );
}
nm = &the_names[num_names++];
nm->hash = h;
nm->name = (char*)malloc( len+1 );
if ( nm->name == NULL )
panic( "not enough memory" );
memcpy( nm->name, name, len );
nm->name[len] = 0;
}
static int
name_compare( const void* name1,
const void* name2 )
{
Name n1 = (Name)name1;
Name n2 = (Name)name2;
return strcmp( n1->name, n2->name );
}
static void
names_sort( void )
{
qsort( the_names, (size_t)num_names,
sizeof ( the_names[0] ), name_compare );
}
static void
names_dump( FILE* out,
OutputFormat format,
const char* dll_name )
{
int nn;
switch ( format )
{
case OUTPUT_WINDOWS_DEF:
if ( dll_name )
fprintf( out, "LIBRARY %s\n", dll_name );
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
fprintf( out, "EXPORTS\n" );
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, " %s\n", the_names[nn].name );
break;
case OUTPUT_BORLAND_DEF:
if ( dll_name )
fprintf( out, "LIBRARY %s\n", dll_name );
fprintf( out, "DESCRIPTION FreeType 2 DLL\n" );
fprintf( out, "EXPORTS\n" );
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, " _%s\n", the_names[nn].name );
break;
case OUTPUT_WATCOM_LBC:
{
const char* dot;
if ( dll_name == NULL )
{
fprintf( stderr,
"you must provide a DLL name with the -d option!\n" );
exit( 4 );
}
/* we must omit the .dll suffix from the library name */
dot = strchr( dll_name, '.' );
if ( dot != NULL )
{
char temp[512];
int len = dot - dll_name;
if ( len > (int)( sizeof ( temp ) - 1 ) )
len = sizeof ( temp ) - 1;
memcpy( temp, dll_name, len );
temp[len] = 0;
dll_name = (const char*)temp;
}
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, "++_%s.%s.%s\n", the_names[nn].name, dll_name,
the_names[nn].name );
}
break;
case OUTPUT_NETWARE_IMP:
{
if ( dll_name != NULL )
fprintf( out, " (%s)\n", dll_name );
for ( nn = 0; nn < num_names - 1; nn++ )
fprintf( out, " %s,\n", the_names[nn].name );
fprintf( out, " %s\n", the_names[num_names - 1].name );
}
break;
default: /* LIST */
for ( nn = 0; nn < num_names; nn++ )
fprintf( out, "%s\n", the_names[nn].name );
}
}
/* states of the line parser */
typedef enum State_
{
STATE_START = 0, /* waiting for FT_EXPORT keyword and return type */
STATE_TYPE /* type was read, waiting for function name */
} State;
static int
read_header_file( FILE* file, int verbose )
{
static char buff[LINEBUFF_SIZE + 1];
State state = STATE_START;
while ( !feof( file ) )
{
char* p;
if ( !fgets( buff, LINEBUFF_SIZE, file ) )
break;
p = buff;
while ( *p && (*p == ' ' || *p == '\\') ) /* skip leading whitespace */
p++;
if ( *p == '\n' || *p == '\r' ) /* skip empty lines */
continue;
switch ( state )
{
case STATE_START:
{
if ( memcmp( p, "FT_EXPORT(", 10 ) != 0 )
break;
p += 10;
for (;;)
{
if ( *p == 0 || *p == '\n' || *p == '\r' )
goto NextLine;
if ( *p == ')' )
{
p++;
break;
}
p++;
}
state = STATE_TYPE;
/* sometimes, the name is just after the FT_EXPORT(...), so
* skip whitespace, and fall-through if we find an alphanumeric
* character
*/
while ( *p == ' ' || *p == '\t' )
p++;
if ( !isalpha(*p) )
break;
}
/* fall-through */
case STATE_TYPE:
{
char* name = p;
while ( isalnum(*p) || *p == '_' )
p++;
if ( p > name )
{
if ( verbose )
fprintf( stderr, ">>> %.*s\n", (int)(p - name), name );
names_add( name, p );
}
state = STATE_START;
}
break;
default:
;
}
NextLine:
;
}
return 0;
}
static void
usage( void )
{
static const char* const format =
"%s %s: extract FreeType API names from header files\n\n"
"this program is used to extract the list of public FreeType API\n"
"functions. It receives the list of header files as argument and\n"
"generates a sorted list of unique identifiers\n\n"
"usage: %s header1 [options] [header2 ...]\n\n"
"options: - : parse the content of stdin, ignore arguments\n"
" -v : verbose mode, output sent to standard error\n"
" -oFILE : write output to FILE instead of standard output\n"
" -dNAME : indicate DLL file name, 'freetype.dll' by default\n"
" -w : output .DEF file for Visual C++ and Mingw\n"
" -wB : output .DEF file for Borland C++\n"
" -wW : output Watcom Linker Response File\n"
" -wN : output NetWare Import File\n"
"\n";
fprintf( stderr,
format,
PROGRAM_NAME,
PROGRAM_VERSION,
PROGRAM_NAME
);
exit(1);
}
int main( int argc, const char* const* argv )
{
int from_stdin = 0;
int verbose = 0;
OutputFormat format = OUTPUT_LIST; /* the default */
FILE* out = stdout;
const char* library_name = NULL;
if ( argc < 2 )
usage();
/* '-' used as a single argument means read source file from stdin */
while ( argc > 1 && argv[1][0] == '-' )
{
const char* arg = argv[1];
switch ( arg[1] )
{
case 'v':
verbose = 1;
break;
case 'o':
if ( arg[2] == 0 )
{
if ( argc < 2 )
usage();
arg = argv[2];
argv++;
argc--;
}
else
arg += 2;
out = fopen( arg, "wt" );
if ( out == NULL )
{
fprintf( stderr, "could not open '%s' for writing\n", argv[2] );
exit(3);
}
break;
case 'd':
if ( arg[2] == 0 )
{
if ( argc < 2 )
usage();
arg = argv[2];
argv++;
argc--;
}
else
arg += 2;
library_name = arg;
break;
case 'w':
format = OUTPUT_WINDOWS_DEF;
switch ( arg[2] )
{
case 'B':
format = OUTPUT_BORLAND_DEF;
break;
case 'W':
format = OUTPUT_WATCOM_LBC;
break;
case 'N':
format = OUTPUT_NETWARE_IMP;
break;
case 0:
break;
default:
usage();
}
break;
case 0:
from_stdin = 1;
break;
default:
usage();
}
argc--;
argv++;
}
if ( from_stdin )
{
read_header_file( stdin, verbose );
}
else
{
for ( --argc, argv++; argc > 0; argc--, argv++ )
{
FILE* file = fopen( argv[0], "rb" );
if ( file == NULL )
fprintf( stderr, "unable to open '%s'\n", argv[0] );
else
{
if ( verbose )
fprintf( stderr, "opening '%s'\n", argv[0] );
read_header_file( file, verbose );
fclose( file );
}
}
}
if ( num_names == 0 )
panic( "could not find exported functions !!\n" );
names_sort();
names_dump( out, format, library_name );
if ( out != stdout )
fclose( out );
return 0;
}
| YifuLiu/AliOS-Things | components/freetype/src/tools/apinames.c | C | apache-2.0 | 10,084 |
#!/usr/bin/env python
#
# Check trace components in FreeType 2 source.
# Author: suzuki toshiya, 2009, 2013
#
# This code is explicitly into the public domain.
import sys
import os
import re
SRC_FILE_LIST = []
USED_COMPONENT = {}
KNOWN_COMPONENT = {}
SRC_FILE_DIRS = [ "src" ]
TRACE_DEF_FILES = [ "include/internal/fttrace.h" ]
# --------------------------------------------------------------
# Parse command line options
#
for i in range( 1, len( sys.argv ) ):
if sys.argv[i].startswith( "--help" ):
print "Usage: %s [option]" % sys.argv[0]
print "Search used-but-defined and defined-but-not-used trace_XXX macros"
print ""
print " --help:"
print " Show this help"
print ""
print " --src-dirs=dir1:dir2:..."
print " Specify the directories of C source files to be checked"
print " Default is %s" % ":".join( SRC_FILE_DIRS )
print ""
print " --def-files=file1:file2:..."
print " Specify the header files including FT_TRACE_DEF()"
print " Default is %s" % ":".join( TRACE_DEF_FILES )
print ""
exit(0)
if sys.argv[i].startswith( "--src-dirs=" ):
SRC_FILE_DIRS = sys.argv[i].replace( "--src-dirs=", "", 1 ).split( ":" )
elif sys.argv[i].startswith( "--def-files=" ):
TRACE_DEF_FILES = sys.argv[i].replace( "--def-files=", "", 1 ).split( ":" )
# --------------------------------------------------------------
# Scan C source and header files using trace macros.
#
c_pathname_pat = re.compile( '^.*\.[ch]$', re.IGNORECASE )
trace_use_pat = re.compile( '^[ \t]*#define[ \t]+FT_COMPONENT[ \t]+trace_' )
for d in SRC_FILE_DIRS:
for ( p, dlst, flst ) in os.walk( d ):
for f in flst:
if c_pathname_pat.match( f ) != None:
src_pathname = os.path.join( p, f )
line_num = 0
for src_line in open( src_pathname, 'r' ):
line_num = line_num + 1
src_line = src_line.strip()
if trace_use_pat.match( src_line ) != None:
component_name = trace_use_pat.sub( '', src_line )
if component_name in USED_COMPONENT:
USED_COMPONENT[component_name].append( "%s:%d" % ( src_pathname, line_num ) )
else:
USED_COMPONENT[component_name] = [ "%s:%d" % ( src_pathname, line_num ) ]
# --------------------------------------------------------------
# Scan header file(s) defining trace macros.
#
trace_def_pat_opn = re.compile( '^.*FT_TRACE_DEF[ \t]*\([ \t]*' )
trace_def_pat_cls = re.compile( '[ \t\)].*$' )
for f in TRACE_DEF_FILES:
line_num = 0
for hdr_line in open( f, 'r' ):
line_num = line_num + 1
hdr_line = hdr_line.strip()
if trace_def_pat_opn.match( hdr_line ) != None:
component_name = trace_def_pat_opn.sub( '', hdr_line )
component_name = trace_def_pat_cls.sub( '', component_name )
if component_name in KNOWN_COMPONENT:
print "trace component %s is defined twice, see %s and fttrace.h:%d" % \
( component_name, KNOWN_COMPONENT[component_name], line_num )
else:
KNOWN_COMPONENT[component_name] = "%s:%d" % \
( os.path.basename( f ), line_num )
# --------------------------------------------------------------
# Compare the used and defined trace macros.
#
print "# Trace component used in the implementations but not defined in fttrace.h."
cmpnt = USED_COMPONENT.keys()
cmpnt.sort()
for c in cmpnt:
if c not in KNOWN_COMPONENT:
print "Trace component %s (used in %s) is not defined." % ( c, ", ".join( USED_COMPONENT[c] ) )
print "# Trace component is defined but not used in the implementations."
cmpnt = KNOWN_COMPONENT.keys()
cmpnt.sort()
for c in cmpnt:
if c not in USED_COMPONENT:
if c != "any":
print "Trace component %s (defined in %s) is not used." % ( c, KNOWN_COMPONENT[c] )
| YifuLiu/AliOS-Things | components/freetype/src/tools/chktrcmp.py | Python | apache-2.0 | 3,823 |
# compute arctangent table for CORDIC computations in fttrigon.c
import sys, math
#units = 64*65536.0 # don't change !!
units = 180 * 2**16
scale = units/math.pi
shrink = 1.0
comma = ""
print ""
print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units"
for n in range(1,32):
x = 0.5**n # tangent value
angle = math.atan(x) # arctangent
angle2 = round(angle*scale) # arctangent in FT_Angle units
if angle2 <= 0:
break
sys.stdout.write( comma + repr( int(angle2) ) )
comma = ", "
shrink /= math.sqrt( 1 + x*x )
print
print "shrink factor = " + repr( shrink )
print "shrink factor 2 = " + repr( int( shrink * (2**32) ) )
print "expansion factor = " + repr( 1/shrink )
print ""
| YifuLiu/AliOS-Things | components/freetype/src/tools/cordic.py | Python | apache-2.0 | 784 |
# Content (c) 2002, 2004, 2006-2009, 2012, 2013
# David Turner <david@freetype.org>
#
# This file contains routines used to parse the content of documentation
# comment blocks and build more structured objects out of them.
#
from sources import *
from utils import *
import string, re
# this regular expression is used to detect code sequences. these
# are simply code fragments embedded in '{' and '}' like in:
#
# {
# x = y + z;
# if ( zookoo == 2 )
# {
# foobar();
# }
# }
#
# note that indentation of the starting and ending accolades must be
# exactly the same. the code sequence can contain accolades at greater
# indentation
#
re_code_start = re.compile( r"(\s*){\s*$" )
re_code_end = re.compile( r"(\s*)}\s*$" )
# this regular expression is used to isolate identifiers from
# other text
#
re_identifier = re.compile( r'((?:\w|-)*)' )
# we collect macros ending in `_H'; while outputting the object data, we use
# this info together with the object's file location to emit the appropriate
# header file macro and name before the object itself
#
re_header_macro = re.compile( r'^#define\s{1,}(\w{1,}_H)\s{1,}<(.*)>' )
#############################################################################
#
# The DocCode class is used to store source code lines.
#
# 'self.lines' contains a set of source code lines that will be dumped as
# HTML in a <PRE> tag.
#
# The object is filled line by line by the parser; it strips the leading
# "margin" space from each input line before storing it in 'self.lines'.
#
class DocCode:
def __init__( self, margin, lines ):
self.lines = []
self.words = None
# remove margin spaces
for l in lines:
if string.strip( l[:margin] ) == "":
l = l[margin:]
self.lines.append( l )
def dump( self, prefix = "", width = 60 ):
lines = self.dump_lines( 0, width )
for l in lines:
print prefix + l
def dump_lines( self, margin = 0, width = 60 ):
result = []
for l in self.lines:
result.append( " " * margin + l )
return result
#############################################################################
#
# The DocPara class is used to store "normal" text paragraph.
#
# 'self.words' contains the list of words that make up the paragraph
#
class DocPara:
def __init__( self, lines ):
self.lines = None
self.words = []
for l in lines:
l = string.strip( l )
self.words.extend( string.split( l ) )
def dump( self, prefix = "", width = 60 ):
lines = self.dump_lines( 0, width )
for l in lines:
print prefix + l
def dump_lines( self, margin = 0, width = 60 ):
cur = "" # current line
col = 0 # current width
result = []
for word in self.words:
ln = len( word )
if col > 0:
ln = ln + 1
if col + ln > width:
result.append( " " * margin + cur )
cur = word
col = len( word )
else:
if col > 0:
cur = cur + " "
cur = cur + word
col = col + ln
if col > 0:
result.append( " " * margin + cur )
return result
#############################################################################
#
# The DocField class is used to store a list containing either DocPara or
# DocCode objects. Each DocField also has an optional "name" which is used
# when the object corresponds to a field or value definition
#
class DocField:
def __init__( self, name, lines ):
self.name = name # can be None for normal paragraphs/sources
self.items = [] # list of items
mode_none = 0 # start parsing mode
mode_code = 1 # parsing code sequences
mode_para = 3 # parsing normal paragraph
margin = -1 # current code sequence indentation
cur_lines = []
# now analyze the markup lines to see if they contain paragraphs,
# code sequences or fields definitions
#
start = 0
mode = mode_none
for l in lines:
# are we parsing a code sequence ?
if mode == mode_code:
m = re_code_end.match( l )
if m and len( m.group( 1 ) ) <= margin:
# that's it, we finished the code sequence
code = DocCode( 0, cur_lines )
self.items.append( code )
margin = -1
cur_lines = []
mode = mode_none
else:
# nope, continue the code sequence
cur_lines.append( l[margin:] )
else:
# start of code sequence ?
m = re_code_start.match( l )
if m:
# save current lines
if cur_lines:
para = DocPara( cur_lines )
self.items.append( para )
cur_lines = []
# switch to code extraction mode
margin = len( m.group( 1 ) )
mode = mode_code
else:
if not string.split( l ) and cur_lines:
# if the line is empty, we end the current paragraph,
# if any
para = DocPara( cur_lines )
self.items.append( para )
cur_lines = []
else:
# otherwise, simply add the line to the current
# paragraph
cur_lines.append( l )
if mode == mode_code:
# unexpected end of code sequence
code = DocCode( margin, cur_lines )
self.items.append( code )
elif cur_lines:
para = DocPara( cur_lines )
self.items.append( para )
def dump( self, prefix = "" ):
if self.field:
print prefix + self.field + " ::"
prefix = prefix + "----"
first = 1
for p in self.items:
if not first:
print ""
p.dump( prefix )
first = 0
def dump_lines( self, margin = 0, width = 60 ):
result = []
nl = None
for p in self.items:
if nl:
result.append( "" )
result.extend( p.dump_lines( margin, width ) )
nl = 1
return result
# this regular expression is used to detect field definitions
#
re_field = re.compile( r"\s*(\w*|\w(\w|\.)*\w)\s*::" )
class DocMarkup:
def __init__( self, tag, lines ):
self.tag = string.lower( tag )
self.fields = []
cur_lines = []
field = None
mode = 0
for l in lines:
m = re_field.match( l )
if m:
# we detected the start of a new field definition
# first, save the current one
if cur_lines:
f = DocField( field, cur_lines )
self.fields.append( f )
cur_lines = []
field = None
field = m.group( 1 ) # record field name
ln = len( m.group( 0 ) )
l = " " * ln + l[ln:]
cur_lines = [l]
else:
cur_lines.append( l )
if field or cur_lines:
f = DocField( field, cur_lines )
self.fields.append( f )
def get_name( self ):
try:
return self.fields[0].items[0].words[0]
except:
return None
def dump( self, margin ):
print " " * margin + "<" + self.tag + ">"
for f in self.fields:
f.dump( " " )
print " " * margin + "</" + self.tag + ">"
class DocChapter:
def __init__( self, block ):
self.block = block
self.sections = []
if block:
self.name = block.name
self.title = block.get_markup_words( "title" )
self.order = block.get_markup_words( "sections" )
else:
self.name = "Other"
self.title = string.split( "Miscellaneous" )
self.order = []
class DocSection:
def __init__( self, name = "Other" ):
self.name = name
self.blocks = {}
self.block_names = [] # ordered block names in section
self.defs = []
self.abstract = ""
self.description = ""
self.order = []
self.title = "ERROR"
self.chapter = None
def add_def( self, block ):
self.defs.append( block )
def add_block( self, block ):
self.block_names.append( block.name )
self.blocks[block.name] = block
def process( self ):
# look up one block that contains a valid section description
for block in self.defs:
title = block.get_markup_text( "title" )
if title:
self.title = title
self.abstract = block.get_markup_words( "abstract" )
self.description = block.get_markup_items( "description" )
self.order = block.get_markup_words( "order" )
return
def reorder( self ):
self.block_names = sort_order_list( self.block_names, self.order )
class ContentProcessor:
def __init__( self ):
"""initialize a block content processor"""
self.reset()
self.sections = {} # dictionary of documentation sections
self.section = None # current documentation section
self.chapters = [] # list of chapters
self.headers = {} # dictionary of header macros
def set_section( self, section_name ):
"""set current section during parsing"""
if not self.sections.has_key( section_name ):
section = DocSection( section_name )
self.sections[section_name] = section
self.section = section
else:
self.section = self.sections[section_name]
def add_chapter( self, block ):
chapter = DocChapter( block )
self.chapters.append( chapter )
def reset( self ):
"""reset the content processor for a new block"""
self.markups = []
self.markup = None
self.markup_lines = []
def add_markup( self ):
"""add a new markup section"""
if self.markup and self.markup_lines:
# get rid of last line of markup if it's empty
marks = self.markup_lines
if len( marks ) > 0 and not string.strip( marks[-1] ):
self.markup_lines = marks[:-1]
m = DocMarkup( self.markup, self.markup_lines )
self.markups.append( m )
self.markup = None
self.markup_lines = []
def process_content( self, content ):
"""process a block content and return a list of DocMarkup objects
corresponding to it"""
markup = None
markup_lines = []
first = 1
for line in content:
found = None
for t in re_markup_tags:
m = t.match( line )
if m:
found = string.lower( m.group( 1 ) )
prefix = len( m.group( 0 ) )
line = " " * prefix + line[prefix:] # remove markup from line
break
# is it the start of a new markup section ?
if found:
first = 0
self.add_markup() # add current markup content
self.markup = found
if len( string.strip( line ) ) > 0:
self.markup_lines.append( line )
elif first == 0:
self.markup_lines.append( line )
self.add_markup()
return self.markups
def parse_sources( self, source_processor ):
blocks = source_processor.blocks
count = len( blocks )
for n in range( count ):
source = blocks[n]
if source.content:
# this is a documentation comment, we need to catch
# all following normal blocks in the "follow" list
#
follow = []
m = n + 1
while m < count and not blocks[m].content:
follow.append( blocks[m] )
m = m + 1
doc_block = DocBlock( source, follow, self )
def finish( self ):
# process all sections to extract their abstract, description
# and ordered list of items
#
for sec in self.sections.values():
sec.process()
# process chapters to check that all sections are correctly
# listed there
for chap in self.chapters:
for sec in chap.order:
if self.sections.has_key( sec ):
section = self.sections[sec]
section.chapter = chap
section.reorder()
chap.sections.append( section )
else:
sys.stderr.write( "WARNING: chapter '" + \
chap.name + "' in " + chap.block.location() + \
" lists unknown section '" + sec + "'\n" )
# check that all sections are in a chapter
#
others = []
for sec in self.sections.values():
if not sec.chapter:
others.append( sec )
# create a new special chapter for all remaining sections
# when necessary
#
if others:
chap = DocChapter( None )
chap.sections = others
self.chapters.append( chap )
class DocBlock:
def __init__( self, source, follow, processor ):
processor.reset()
self.source = source
self.code = []
self.type = "ERRTYPE"
self.name = "ERRNAME"
self.section = processor.section
self.markups = processor.process_content( source.content )
# compute block type from first markup tag
try:
self.type = self.markups[0].tag
except:
pass
# compute block name from first markup paragraph
try:
markup = self.markups[0]
para = markup.fields[0].items[0]
name = para.words[0]
m = re_identifier.match( name )
if m:
name = m.group( 1 )
self.name = name
except:
pass
if self.type == "section":
# detect new section starts
processor.set_section( self.name )
processor.section.add_def( self )
elif self.type == "chapter":
# detect new chapter
processor.add_chapter( self )
else:
processor.section.add_block( self )
# now, compute the source lines relevant to this documentation
# block. We keep normal comments in for obvious reasons (??)
source = []
for b in follow:
if b.format:
break
for l in b.lines:
# collect header macro definitions
m = re_header_macro.match( l )
if m:
processor.headers[m.group( 2 )] = m.group( 1 );
# we use "/* */" as a separator
if re_source_sep.match( l ):
break
source.append( l )
# now strip the leading and trailing empty lines from the sources
start = 0
end = len( source ) - 1
while start < end and not string.strip( source[start] ):
start = start + 1
while start < end and not string.strip( source[end] ):
end = end - 1
if start == end and not string.strip( source[start] ):
self.code = []
else:
self.code = source[start:end + 1]
def location( self ):
return self.source.location()
def get_markup( self, tag_name ):
"""return the DocMarkup corresponding to a given tag in a block"""
for m in self.markups:
if m.tag == string.lower( tag_name ):
return m
return None
def get_markup_words( self, tag_name ):
try:
m = self.get_markup( tag_name )
return m.fields[0].items[0].words
except:
return []
def get_markup_text( self, tag_name ):
result = self.get_markup_words( tag_name )
return string.join( result )
def get_markup_items( self, tag_name ):
try:
m = self.get_markup( tag_name )
return m.fields[0].items
except:
return None
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/content.py | Python | apache-2.0 | 17,193 |
#!/usr/bin/env python
#
# DocBeauty (c) 2003, 2004, 2008 David Turner <david@freetype.org>
#
# This program is used to beautify the documentation comments used
# in the FreeType 2 public headers.
#
from sources import *
from content import *
from utils import *
import utils
import sys, os, time, string, getopt
content_processor = ContentProcessor()
def beautify_block( block ):
if block.content:
content_processor.reset()
markups = content_processor.process_content( block.content )
text = []
first = 1
for markup in markups:
text.extend( markup.beautify( first ) )
first = 0
# now beautify the documentation "borders" themselves
lines = [" /*************************************************************************"]
for l in text:
lines.append( " *" + l )
lines.append( " */" )
block.lines = lines
def usage():
print "\nDocBeauty 0.1 Usage information\n"
print " docbeauty [options] file1 [file2 ...]\n"
print "using the following options:\n"
print " -h : print this page"
print " -b : backup original files with the 'orig' extension"
print ""
print " --backup : same as -b"
def main( argv ):
"""main program loop"""
global output_dir
try:
opts, args = getopt.getopt( sys.argv[1:], \
"hb", \
["help", "backup"] )
except getopt.GetoptError:
usage()
sys.exit( 2 )
if args == []:
usage()
sys.exit( 1 )
# process options
#
output_dir = None
do_backup = None
for opt in opts:
if opt[0] in ( "-h", "--help" ):
usage()
sys.exit( 0 )
if opt[0] in ( "-b", "--backup" ):
do_backup = 1
# create context and processor
source_processor = SourceProcessor()
# retrieve the list of files to process
file_list = make_file_list( args )
for filename in file_list:
source_processor.parse_file( filename )
for block in source_processor.blocks:
beautify_block( block )
new_name = filename + ".new"
ok = None
try:
file = open( new_name, "wt" )
for block in source_processor.blocks:
for line in block.lines:
file.write( line )
file.write( "\n" )
file.close()
except:
ok = 0
# if called from the command line
#
if __name__ == '__main__':
main( sys.argv )
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/docbeauty.py | Python | apache-2.0 | 2,642 |
#!/usr/bin/env python
#
# DocMaker (c) 2002, 2004, 2008, 2013 David Turner <david@freetype.org>
#
# This program is a re-write of the original DocMaker tool used
# to generate the API Reference of the FreeType font engine
# by converting in-source comments into structured HTML.
#
# This new version is capable of outputting XML data, as well
# as accepts more liberal formatting options.
#
# It also uses regular expression matching and substitution
# to speed things significantly.
#
from sources import *
from content import *
from utils import *
from formatter import *
from tohtml import *
import utils
import sys, os, time, string, glob, getopt
def usage():
print "\nDocMaker Usage information\n"
print " docmaker [options] file1 [file2 ...]\n"
print "using the following options:\n"
print " -h : print this page"
print " -t : set project title, as in '-t \"My Project\"'"
print " -o : set output directory, as in '-o mydir'"
print " -p : set documentation prefix, as in '-p ft2'"
print ""
print " --title : same as -t, as in '--title=\"My Project\"'"
print " --output : same as -o, as in '--output=mydir'"
print " --prefix : same as -p, as in '--prefix=ft2'"
def main( argv ):
"""main program loop"""
global output_dir
try:
opts, args = getopt.getopt( sys.argv[1:], \
"ht:o:p:", \
["help", "title=", "output=", "prefix="] )
except getopt.GetoptError:
usage()
sys.exit( 2 )
if args == []:
usage()
sys.exit( 1 )
# process options
#
project_title = "Project"
project_prefix = None
output_dir = None
for opt in opts:
if opt[0] in ( "-h", "--help" ):
usage()
sys.exit( 0 )
if opt[0] in ( "-t", "--title" ):
project_title = opt[1]
if opt[0] in ( "-o", "--output" ):
utils.output_dir = opt[1]
if opt[0] in ( "-p", "--prefix" ):
project_prefix = opt[1]
check_output()
# create context and processor
source_processor = SourceProcessor()
content_processor = ContentProcessor()
# retrieve the list of files to process
file_list = make_file_list( args )
for filename in file_list:
source_processor.parse_file( filename )
content_processor.parse_sources( source_processor )
# process sections
content_processor.finish()
formatter = HtmlFormatter( content_processor, project_title, project_prefix )
formatter.toc_dump()
formatter.index_dump()
formatter.section_dump_all()
# if called from the command line
#
if __name__ == '__main__':
main( sys.argv )
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/docmaker.py | Python | apache-2.0 | 2,772 |
# Formatter (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org>
#
from sources import *
from content import *
from utils import *
# This is the base Formatter class. Its purpose is to convert
# a content processor's data into specific documents (i.e., table of
# contents, global index, and individual API reference indices).
#
# You need to sub-class it to output anything sensible. For example,
# the file tohtml.py contains the definition of the HtmlFormatter sub-class
# used to output -- you guessed it -- HTML.
#
class Formatter:
def __init__( self, processor ):
self.processor = processor
self.identifiers = {}
self.chapters = processor.chapters
self.sections = processor.sections.values()
self.block_index = []
# store all blocks in a dictionary
self.blocks = []
for section in self.sections:
for block in section.blocks.values():
self.add_identifier( block.name, block )
# add enumeration values to the index, since this is useful
for markup in block.markups:
if markup.tag == 'values':
for field in markup.fields:
self.add_identifier( field.name, block )
self.block_index = self.identifiers.keys()
self.block_index.sort( index_sort )
def add_identifier( self, name, block ):
if self.identifiers.has_key( name ):
# duplicate name!
sys.stderr.write( \
"WARNING: duplicate definition for '" + name + "' in " + \
block.location() + ", previous definition in " + \
self.identifiers[name].location() + "\n" )
else:
self.identifiers[name] = block
#
# Formatting the table of contents
#
def toc_enter( self ):
pass
def toc_chapter_enter( self, chapter ):
pass
def toc_section_enter( self, section ):
pass
def toc_section_exit( self, section ):
pass
def toc_chapter_exit( self, chapter ):
pass
def toc_index( self, index_filename ):
pass
def toc_exit( self ):
pass
def toc_dump( self, toc_filename = None, index_filename = None ):
output = None
if toc_filename:
output = open_output( toc_filename )
self.toc_enter()
for chap in self.processor.chapters:
self.toc_chapter_enter( chap )
for section in chap.sections:
self.toc_section_enter( section )
self.toc_section_exit( section )
self.toc_chapter_exit( chap )
self.toc_index( index_filename )
self.toc_exit()
if output:
close_output( output )
#
# Formatting the index
#
def index_enter( self ):
pass
def index_name_enter( self, name ):
pass
def index_name_exit( self, name ):
pass
def index_exit( self ):
pass
def index_dump( self, index_filename = None ):
output = None
if index_filename:
output = open_output( index_filename )
self.index_enter()
for name in self.block_index:
self.index_name_enter( name )
self.index_name_exit( name )
self.index_exit()
if output:
close_output( output )
#
# Formatting a section
#
def section_enter( self, section ):
pass
def block_enter( self, block ):
pass
def markup_enter( self, markup, block = None ):
pass
def field_enter( self, field, markup = None, block = None ):
pass
def field_exit( self, field, markup = None, block = None ):
pass
def markup_exit( self, markup, block = None ):
pass
def block_exit( self, block ):
pass
def section_exit( self, section ):
pass
def section_dump( self, section, section_filename = None ):
output = None
if section_filename:
output = open_output( section_filename )
self.section_enter( section )
for name in section.block_names:
block = self.identifiers[name]
self.block_enter( block )
for markup in block.markups[1:]: # always ignore first markup!
self.markup_enter( markup, block )
for field in markup.fields:
self.field_enter( field, markup, block )
self.field_exit( field, markup, block )
self.markup_exit( markup, block )
self.block_exit( block )
self.section_exit( section )
if output:
close_output( output )
def section_dump_all( self ):
for section in self.sections:
self.section_dump( section )
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/formatter.py | Python | apache-2.0 | 4,962 |
# Sources (c) 2002-2004, 2006-2009, 2012, 2013
# David Turner <david@freetype.org>
#
#
# this file contains definitions of classes needed to decompose
# C sources files into a series of multi-line "blocks". There are
# two kinds of blocks:
#
# - normal blocks, which contain source code or ordinary comments
#
# - documentation blocks, which have restricted formatting, and
# whose text always start with a documentation markup tag like
# "<Function>", "<Type>", etc..
#
# the routines used to process the content of documentation blocks
# are not contained here, but in "content.py"
#
# the classes and methods found here only deal with text parsing
# and basic documentation block extraction
#
import fileinput, re, sys, os, string
################################################################
##
## BLOCK FORMAT PATTERN
##
## A simple class containing compiled regular expressions used
## to detect potential documentation format block comments within
## C source code
##
## note that the 'column' pattern must contain a group that will
## be used to "unbox" the content of documentation comment blocks
##
class SourceBlockFormat:
def __init__( self, id, start, column, end ):
"""create a block pattern, used to recognize special documentation blocks"""
self.id = id
self.start = re.compile( start, re.VERBOSE )
self.column = re.compile( column, re.VERBOSE )
self.end = re.compile( end, re.VERBOSE )
#
# format 1 documentation comment blocks look like the following:
#
# /************************************/
# /* */
# /* */
# /* */
# /************************************/
#
# we define a few regular expressions here to detect them
#
start = r'''
\s* # any number of whitespace
/\*{2,}/ # followed by '/' and at least two asterisks then '/'
\s*$ # probably followed by whitespace
'''
column = r'''
\s* # any number of whitespace
/\*{1} # followed by '/' and precisely one asterisk
([^*].*) # followed by anything (group 1)
\*{1}/ # followed by one asterisk and a '/'
\s*$ # probably followed by whitespace
'''
re_source_block_format1 = SourceBlockFormat( 1, start, column, start )
#
# format 2 documentation comment blocks look like the following:
#
# /************************************ (at least 2 asterisks)
# *
# *
# *
# *
# **/ (1 or more asterisks at the end)
#
# we define a few regular expressions here to detect them
#
start = r'''
\s* # any number of whitespace
/\*{2,} # followed by '/' and at least two asterisks
\s*$ # probably followed by whitespace
'''
column = r'''
\s* # any number of whitespace
\*{1}(?!/) # followed by precisely one asterisk not followed by `/'
(.*) # then anything (group1)
'''
end = r'''
\s* # any number of whitespace
\*+/ # followed by at least one asterisk, then '/'
'''
re_source_block_format2 = SourceBlockFormat( 2, start, column, end )
#
# the list of supported documentation block formats, we could add new ones
# relatively easily
#
re_source_block_formats = [re_source_block_format1, re_source_block_format2]
#
# the following regular expressions corresponds to markup tags
# within the documentation comment blocks. they're equivalent
# despite their different syntax
#
# notice how each markup tag _must_ begin a new line
#
re_markup_tag1 = re.compile( r'''\s*<((?:\w|-)*)>''' ) # <xxxx> format
re_markup_tag2 = re.compile( r'''\s*@((?:\w|-)*):''' ) # @xxxx: format
#
# the list of supported markup tags, we could add new ones relatively
# easily
#
re_markup_tags = [re_markup_tag1, re_markup_tag2]
#
# used to detect a cross-reference, after markup tags have been stripped
#
re_crossref = re.compile( r'@((?:\w|-)*)(.*)' ) # @foo
#
# used to detect italic and bold styles in paragraph text
#
re_italic = re.compile( r"_(\w(\w|')*)_(.*)" ) # _italic_
re_bold = re.compile( r"\*(\w(\w|')*)\*(.*)" ) # *bold*
#
# this regular expression code to identify an URL has been taken from
#
# http://mail.python.org/pipermail/tutor/2002-September/017228.html
#
# (with slight modifications)
#
urls = r'(?:https?|telnet|gopher|file|wais|ftp)'
ltrs = r'\w'
gunk = r'/#~:.?+=&%@!\-'
punc = r'.:?\-'
any = "%(ltrs)s%(gunk)s%(punc)s" % { 'ltrs' : ltrs,
'gunk' : gunk,
'punc' : punc }
url = r"""
(
\b # start at word boundary
%(urls)s : # need resource and a colon
[%(any)s] +? # followed by one or more of any valid
# character, but be conservative and
# take only what you need to...
(?= # [look-ahead non-consumptive assertion]
[%(punc)s]* # either 0 or more punctuation
(?: # [non-grouping parentheses]
[^%(any)s] | $ # followed by a non-url char
# or end of the string
)
)
)
""" % {'urls' : urls,
'any' : any,
'punc' : punc }
re_url = re.compile( url, re.VERBOSE | re.MULTILINE )
#
# used to detect the end of commented source lines
#
re_source_sep = re.compile( r'\s*/\*\s*\*/' )
#
# used to perform cross-reference within source output
#
re_source_crossref = re.compile( r'(\W*)(\w*)' )
#
# a list of reserved source keywords
#
re_source_keywords = re.compile( '''\\b ( typedef |
struct |
enum |
union |
const |
char |
int |
short |
long |
void |
signed |
unsigned |
\#include |
\#define |
\#undef |
\#if |
\#ifdef |
\#ifndef |
\#else |
\#endif ) \\b''', re.VERBOSE )
################################################################
##
## SOURCE BLOCK CLASS
##
## A SourceProcessor is in charge of reading a C source file
## and decomposing it into a series of different "SourceBlocks".
## each one of these blocks can be made of the following data:
##
## - A documentation comment block that starts with "/**" and
## whose exact format will be discussed later
##
## - normal sources lines, including comments
##
## the important fields in a text block are the following ones:
##
## self.lines : a list of text lines for the corresponding block
##
## self.content : for documentation comment blocks only, this is the
## block content that has been "unboxed" from its
## decoration. This is None for all other blocks
## (i.e. sources or ordinary comments with no starting
## markup tag)
##
class SourceBlock:
def __init__( self, processor, filename, lineno, lines ):
self.processor = processor
self.filename = filename
self.lineno = lineno
self.lines = lines[:]
self.format = processor.format
self.content = []
if self.format == None:
return
words = []
# extract comment lines
lines = []
for line0 in self.lines:
m = self.format.column.match( line0 )
if m:
lines.append( m.group( 1 ) )
# now, look for a markup tag
for l in lines:
l = string.strip( l )
if len( l ) > 0:
for tag in re_markup_tags:
if tag.match( l ):
self.content = lines
return
def location( self ):
return "(" + self.filename + ":" + repr( self.lineno ) + ")"
# debugging only - not used in normal operations
def dump( self ):
if self.content:
print "{{{content start---"
for l in self.content:
print l
print "---content end}}}"
return
fmt = ""
if self.format:
fmt = repr( self.format.id ) + " "
for line in self.lines:
print line
################################################################
##
## SOURCE PROCESSOR CLASS
##
## The SourceProcessor is in charge of reading a C source file
## and decomposing it into a series of different "SourceBlock"
## objects.
##
## each one of these blocks can be made of the following data:
##
## - A documentation comment block that starts with "/**" and
## whose exact format will be discussed later
##
## - normal sources lines, include comments
##
##
class SourceProcessor:
def __init__( self ):
"""initialize a source processor"""
self.blocks = []
self.filename = None
self.format = None
self.lines = []
def reset( self ):
"""reset a block processor, clean all its blocks"""
self.blocks = []
self.format = None
def parse_file( self, filename ):
"""parse a C source file, and add its blocks to the processor's list"""
self.reset()
self.filename = filename
fileinput.close()
self.format = None
self.lineno = 0
self.lines = []
for line in fileinput.input( filename ):
# strip trailing newlines, important on Windows machines!
if line[-1] == '\012':
line = line[0:-1]
if self.format == None:
self.process_normal_line( line )
else:
if self.format.end.match( line ):
# that's a normal block end, add it to 'lines' and
# create a new block
self.lines.append( line )
self.add_block_lines()
elif self.format.column.match( line ):
# that's a normal column line, add it to 'lines'
self.lines.append( line )
else:
# humm.. this is an unexpected block end,
# create a new block, but don't process the line
self.add_block_lines()
# we need to process the line again
self.process_normal_line( line )
# record the last lines
self.add_block_lines()
def process_normal_line( self, line ):
"""process a normal line and check whether it is the start of a new block"""
for f in re_source_block_formats:
if f.start.match( line ):
self.add_block_lines()
self.format = f
self.lineno = fileinput.filelineno()
self.lines.append( line )
def add_block_lines( self ):
"""add the current accumulated lines and create a new block"""
if self.lines != []:
block = SourceBlock( self, self.filename, self.lineno, self.lines )
self.blocks.append( block )
self.format = None
self.lines = []
# debugging only, not used in normal operations
def dump( self ):
"""print all blocks in a processor"""
for b in self.blocks:
b.dump()
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/sources.py | Python | apache-2.0 | 12,081 |
# ToHTML (c) 2002, 2003, 2005-2008, 2013
# David Turner <david@freetype.org>
from sources import *
from content import *
from formatter import *
import time
# The following defines the HTML header used by all generated pages.
html_header_1 = """\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>\
"""
html_header_2 = """\
API Reference</title>
<style type="text/css">
body { font-family: Verdana, Geneva, Arial, Helvetica, serif;
color: #000000;
background: #FFFFFF; }
p { text-align: justify; }
h1 { text-align: center; }
li { text-align: justify; }
td { padding: 0 0.5em 0 0.5em; }
td.left { padding: 0 0.5em 0 0.5em;
text-align: left; }
a:link { color: #0000EF; }
a:visited { color: #51188E; }
a:hover { color: #FF0000; }
span.keyword { font-family: monospace;
text-align: left;
white-space: pre;
color: darkblue; }
pre.colored { color: blue; }
ul.empty { list-style-type: none; }
</style>
</head>
<body>
"""
html_header_3 = """
<table align=center><tr><td><font size=-1>[<a href="\
"""
html_header_3i = """
<table align=center><tr><td width="100%"></td>
<td><font size=-1>[<a href="\
"""
html_header_4 = """\
">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-1>[<a href="\
"""
html_header_5 = """\
">TOC</a>]</font></td></tr></table>
<center><h1>\
"""
html_header_5t = """\
">Index</a>]</font></td>
<td width="100%"></td></tr></table>
<center><h1>\
"""
html_header_6 = """\
API Reference</h1></center>
"""
# The HTML footer used by all generated pages.
html_footer = """\
</body>
</html>\
"""
# The header and footer used for each section.
section_title_header = "<center><h1>"
section_title_footer = "</h1></center>"
# The header and footer used for code segments.
code_header = '<pre class="colored">'
code_footer = '</pre>'
# Paragraph header and footer.
para_header = "<p>"
para_footer = "</p>"
# Block header and footer.
block_header = '<table align=center width="75%"><tr><td>'
block_footer_start = """\
</td></tr></table>
<hr width="75%">
<table align=center width="75%"><tr><td><font size=-2>[<a href="\
"""
block_footer_middle = """\
">Index</a>]</font></td>
<td width="100%"></td>
<td><font size=-2>[<a href="\
"""
block_footer_end = """\
">TOC</a>]</font></td></tr></table>
"""
# Description header/footer.
description_header = '<table align=center width="87%"><tr><td>'
description_footer = "</td></tr></table><br>"
# Marker header/inter/footer combination.
marker_header = '<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>'
marker_inter = "</b></em></td></tr><tr><td>"
marker_footer = "</td></tr></table>"
# Header location header/footer.
header_location_header = '<table align=center width="87%"><tr><td>'
header_location_footer = "</td></tr></table><br>"
# Source code extracts header/footer.
source_header = '<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n'
source_footer = "\n</pre></table><br>"
# Chapter header/inter/footer.
chapter_header = '<br><table align=center width="75%"><tr><td><h2>'
chapter_inter = '</h2><ul class="empty"><li>'
chapter_footer = '</li></ul></td></tr></table>'
# Index footer.
index_footer_start = """\
<hr>
<table><tr><td width="100%"></td>
<td><font size=-2>[<a href="\
"""
index_footer_end = """\
">TOC</a>]</font></td></tr></table>
"""
# TOC footer.
toc_footer_start = """\
<hr>
<table><tr><td><font size=-2>[<a href="\
"""
toc_footer_end = """\
">Index</a>]</font></td>
<td width="100%"></td>
</tr></table>
"""
# source language keyword coloration/styling
keyword_prefix = '<span class="keyword">'
keyword_suffix = '</span>'
section_synopsis_header = '<h2>Synopsis</h2>'
section_synopsis_footer = ''
# Translate a single line of source to HTML. This will convert
# a "<" into "<.", ">" into ">.", etc.
def html_quote( line ):
result = string.replace( line, "&", "&" )
result = string.replace( result, "<", "<" )
result = string.replace( result, ">", ">" )
return result
class HtmlFormatter( Formatter ):
def __init__( self, processor, project_title, file_prefix ):
Formatter.__init__( self, processor )
global html_header_1, html_header_2, html_header_3
global html_header_4, html_header_5, html_footer
if file_prefix:
file_prefix = file_prefix + "-"
else:
file_prefix = ""
self.headers = processor.headers
self.project_title = project_title
self.file_prefix = file_prefix
self.html_header = html_header_1 + project_title + \
html_header_2 + \
html_header_3 + file_prefix + "index.html" + \
html_header_4 + file_prefix + "toc.html" + \
html_header_5 + project_title + \
html_header_6
self.html_index_header = html_header_1 + project_title + \
html_header_2 + \
html_header_3i + file_prefix + "toc.html" + \
html_header_5 + project_title + \
html_header_6
self.html_toc_header = html_header_1 + project_title + \
html_header_2 + \
html_header_3 + file_prefix + "index.html" + \
html_header_5t + project_title + \
html_header_6
self.html_footer = "<center><font size=""-2"">generated on " + \
time.asctime( time.localtime( time.time() ) ) + \
"</font></center>" + html_footer
self.columns = 3
def make_section_url( self, section ):
return self.file_prefix + section.name + ".html"
def make_block_url( self, block ):
return self.make_section_url( block.section ) + "#" + block.name
def make_html_word( self, word ):
"""analyze a simple word to detect cross-references and styling"""
# look for cross-references
m = re_crossref.match( word )
if m:
try:
name = m.group( 1 )
rest = m.group( 2 )
block = self.identifiers[name]
url = self.make_block_url( block )
return '<a href="' + url + '">' + name + '</a>' + rest
except:
# we detected a cross-reference to an unknown item
sys.stderr.write( \
"WARNING: undefined cross reference '" + name + "'.\n" )
return '?' + name + '?' + rest
# look for italics and bolds
m = re_italic.match( word )
if m:
name = m.group( 1 )
rest = m.group( 3 )
return '<i>' + name + '</i>' + rest
m = re_bold.match( word )
if m:
name = m.group( 1 )
rest = m.group( 3 )
return '<b>' + name + '</b>' + rest
return html_quote( word )
def make_html_para( self, words ):
""" convert words of a paragraph into tagged HTML text, handle xrefs """
line = ""
if words:
line = self.make_html_word( words[0] )
for word in words[1:]:
line = line + " " + self.make_html_word( word )
# handle hyperlinks
line = re_url.sub( r'<a href="\1">\1</a>', line )
# convert `...' quotations into real left and right single quotes
line = re.sub( r"(^|\W)`(.*?)'(\W|$)", \
r'\1‘\2’\3', \
line )
# convert tilde into non-breakable space
line = string.replace( line, "~", " " )
return para_header + line + para_footer
def make_html_code( self, lines ):
""" convert a code sequence to HTML """
line = code_header + '\n'
for l in lines:
line = line + html_quote( l ) + '\n'
return line + code_footer
def make_html_items( self, items ):
""" convert a field's content into some valid HTML """
lines = []
for item in items:
if item.lines:
lines.append( self.make_html_code( item.lines ) )
else:
lines.append( self.make_html_para( item.words ) )
return string.join( lines, '\n' )
def print_html_items( self, items ):
print self.make_html_items( items )
def print_html_field( self, field ):
if field.name:
print "<table><tr valign=top><td><b>" + field.name + "</b></td><td>"
print self.make_html_items( field.items )
if field.name:
print "</td></tr></table>"
def html_source_quote( self, line, block_name = None ):
result = ""
while line:
m = re_source_crossref.match( line )
if m:
name = m.group( 2 )
prefix = html_quote( m.group( 1 ) )
length = len( m.group( 0 ) )
if name == block_name:
# this is the current block name, if any
result = result + prefix + '<b>' + name + '</b>'
elif re_source_keywords.match( name ):
# this is a C keyword
result = result + prefix + keyword_prefix + name + keyword_suffix
elif self.identifiers.has_key( name ):
# this is a known identifier
block = self.identifiers[name]
result = result + prefix + '<a href="' + \
self.make_block_url( block ) + '">' + name + '</a>'
else:
result = result + html_quote( line[:length] )
line = line[length:]
else:
result = result + html_quote( line )
line = []
return result
def print_html_field_list( self, fields ):
print "<p></p>"
print "<table cellpadding=3 border=0>"
for field in fields:
if len( field.name ) > 22:
print "<tr valign=top><td colspan=0><b>" + field.name + "</b></td></tr>"
print "<tr valign=top><td></td><td>"
else:
print "<tr valign=top><td><b>" + field.name + "</b></td><td>"
self.print_html_items( field.items )
print "</td></tr>"
print "</table>"
def print_html_markup( self, markup ):
table_fields = []
for field in markup.fields:
if field.name:
# we begin a new series of field or value definitions, we
# will record them in the 'table_fields' list before outputting
# all of them as a single table
#
table_fields.append( field )
else:
if table_fields:
self.print_html_field_list( table_fields )
table_fields = []
self.print_html_items( field.items )
if table_fields:
self.print_html_field_list( table_fields )
#
# Formatting the index
#
def index_enter( self ):
print self.html_index_header
self.index_items = {}
def index_name_enter( self, name ):
block = self.identifiers[name]
url = self.make_block_url( block )
self.index_items[name] = url
def index_exit( self ):
# block_index already contains the sorted list of index names
count = len( self.block_index )
rows = ( count + self.columns - 1 ) / self.columns
print "<table align=center border=0 cellpadding=0 cellspacing=0>"
for r in range( rows ):
line = "<tr>"
for c in range( self.columns ):
i = r + c * rows
if i < count:
bname = self.block_index[r + c * rows]
url = self.index_items[bname]
line = line + '<td><a href="' + url + '">' + bname + '</a></td>'
else:
line = line + '<td></td>'
line = line + "</tr>"
print line
print "</table>"
print index_footer_start + \
self.file_prefix + "toc.html" + \
index_footer_end
print self.html_footer
self.index_items = {}
def index_dump( self, index_filename = None ):
if index_filename == None:
index_filename = self.file_prefix + "index.html"
Formatter.index_dump( self, index_filename )
#
# Formatting the table of content
#
def toc_enter( self ):
print self.html_toc_header
print "<center><h1>Table of Contents</h1></center>"
def toc_chapter_enter( self, chapter ):
print chapter_header + string.join( chapter.title ) + chapter_inter
print "<table cellpadding=5>"
def toc_section_enter( self, section ):
print '<tr valign=top><td class="left">'
print '<a href="' + self.make_section_url( section ) + '">' + \
section.title + '</a></td><td>'
print self.make_html_para( section.abstract )
def toc_section_exit( self, section ):
print "</td></tr>"
def toc_chapter_exit( self, chapter ):
print "</table>"
print chapter_footer
def toc_index( self, index_filename ):
print chapter_header + \
'<a href="' + index_filename + '">Global Index</a>' + \
chapter_inter + chapter_footer
def toc_exit( self ):
print toc_footer_start + \
self.file_prefix + "index.html" + \
toc_footer_end
print self.html_footer
def toc_dump( self, toc_filename = None, index_filename = None ):
if toc_filename == None:
toc_filename = self.file_prefix + "toc.html"
if index_filename == None:
index_filename = self.file_prefix + "index.html"
Formatter.toc_dump( self, toc_filename, index_filename )
#
# Formatting sections
#
def section_enter( self, section ):
print self.html_header
print section_title_header
print section.title
print section_title_footer
maxwidth = 0
for b in section.blocks.values():
if len( b.name ) > maxwidth:
maxwidth = len( b.name )
width = 70 # XXX magic number
if maxwidth <> 0:
# print section synopsis
print section_synopsis_header
print "<table align=center cellspacing=5 cellpadding=0 border=0>"
columns = width / maxwidth
if columns < 1:
columns = 1
count = len( section.block_names )
rows = ( count + columns - 1 ) / columns
for r in range( rows ):
line = "<tr>"
for c in range( columns ):
i = r + c * rows
line = line + '<td></td><td>'
if i < count:
name = section.block_names[i]
line = line + '<a href="#' + name + '">' + name + '</a>'
line = line + '</td>'
line = line + "</tr>"
print line
print "</table><br><br>"
print section_synopsis_footer
print description_header
print self.make_html_items( section.description )
print description_footer
def block_enter( self, block ):
print block_header
# place html anchor if needed
if block.name:
print '<h4><a name="' + block.name + '">' + block.name + '</a></h4>'
# dump the block C source lines now
if block.code:
header = ''
for f in self.headers.keys():
if block.source.filename.find( f ) >= 0:
header = self.headers[f] + ' (' + f + ')'
break;
# if not header:
# sys.stderr.write( \
# 'WARNING: No header macro for ' + block.source.filename + '.\n' )
if header:
print header_location_header
print 'Defined in ' + header + '.'
print header_location_footer
print source_header
for l in block.code:
print self.html_source_quote( l, block.name )
print source_footer
def markup_enter( self, markup, block ):
if markup.tag == "description":
print description_header
else:
print marker_header + markup.tag + marker_inter
self.print_html_markup( markup )
def markup_exit( self, markup, block ):
if markup.tag == "description":
print description_footer
else:
print marker_footer
def block_exit( self, block ):
print block_footer_start + self.file_prefix + "index.html" + \
block_footer_middle + self.file_prefix + "toc.html" + \
block_footer_end
def section_exit( self, section ):
print html_footer
def section_dump_all( self ):
for section in self.sections:
self.section_dump( section, self.file_prefix + section.name + '.html' )
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/tohtml.py | Python | apache-2.0 | 17,922 |
# Utils (c) 2002, 2004, 2007, 2008 David Turner <david@freetype.org>
#
import string, sys, os, glob
# current output directory
#
output_dir = None
# This function is used to sort the index. It is a simple lexicographical
# sort, except that it places capital letters before lowercase ones.
#
def index_sort( s1, s2 ):
if not s1:
return -1
if not s2:
return 1
l1 = len( s1 )
l2 = len( s2 )
m1 = string.lower( s1 )
m2 = string.lower( s2 )
for i in range( l1 ):
if i >= l2 or m1[i] > m2[i]:
return 1
if m1[i] < m2[i]:
return -1
if s1[i] < s2[i]:
return -1
if s1[i] > s2[i]:
return 1
if l2 > l1:
return -1
return 0
# Sort input_list, placing the elements of order_list in front.
#
def sort_order_list( input_list, order_list ):
new_list = order_list[:]
for id in input_list:
if not id in order_list:
new_list.append( id )
return new_list
# Open the standard output to a given project documentation file. Use
# "output_dir" to determine the filename location if necessary and save the
# old stdout in a tuple that is returned by this function.
#
def open_output( filename ):
global output_dir
if output_dir and output_dir != "":
filename = output_dir + os.sep + filename
old_stdout = sys.stdout
new_file = open( filename, "w" )
sys.stdout = new_file
return ( new_file, old_stdout )
# Close the output that was returned by "close_output".
#
def close_output( output ):
output[0].close()
sys.stdout = output[1]
# Check output directory.
#
def check_output():
global output_dir
if output_dir:
if output_dir != "":
if not os.path.isdir( output_dir ):
sys.stderr.write( "argument" + " '" + output_dir + "' " + \
"is not a valid directory" )
sys.exit( 2 )
else:
output_dir = None
def file_exists( pathname ):
"""checks that a given file exists"""
result = 1
try:
file = open( pathname, "r" )
file.close()
except:
result = None
sys.stderr.write( pathname + " couldn't be accessed\n" )
return result
def make_file_list( args = None ):
"""builds a list of input files from command-line arguments"""
file_list = []
# sys.stderr.write( repr( sys.argv[1 :] ) + '\n' )
if not args:
args = sys.argv[1 :]
for pathname in args:
if string.find( pathname, '*' ) >= 0:
newpath = glob.glob( pathname )
newpath.sort() # sort files -- this is important because
# of the order of files
else:
newpath = [pathname]
file_list.extend( newpath )
if len( file_list ) == 0:
file_list = None
else:
# now filter the file list to remove non-existing ones
file_list = filter( file_exists, file_list )
return file_list
# eof
| YifuLiu/AliOS-Things | components/freetype/src/tools/docmaker/utils.py | Python | apache-2.0 | 3,063 |
# TOP_DIR and OBJ_DIR should be set by the user to the right directories,
# if necessary.
TOP_DIR ?= ../../..
OBJ_DIR ?= $(TOP_DIR)/objs
# The setup below is for gcc on a Unix-like platform.
SRC_DIR = $(TOP_DIR)/src/tools/ftrandom
CC = gcc
WFLAGS = -Wmissing-prototypes \
-Wunused \
-Wimplicit \
-Wreturn-type \
-Wparentheses \
-pedantic \
-Wformat \
-Wchar-subscripts \
-Wsequence-point
CFLAGS = $(WFLAGS) \
-g \
-I $(TOP_DIR)/include
LIBS = -lm \
-L $(OBJ_DIR) \
-lfreetype \
-lz
all: $(OBJ_DIR)/ftrandom
$(OBJ_DIR)/ftrandom: $(SRC_DIR)/ftrandom.c $(OBJ_DIR)/libfreetype.a
$(CC) -o $(OBJ_DIR)/ftrandom $(CFLAGS) $(SRC_DIR)/ftrandom.c $(LIBS)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/tools/ftrandom/Makefile | Makefile | apache-2.0 | 770 |
/* Copyright (C) 2005, 2007, 2008, 2013 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* modified by Werner Lemberg <wl@gnu.org> */
/* This file is now part of the FreeType library */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <dirent.h>
#include <math.h>
#include <signal.h>
#include <time.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#define true 1
#define false 0
#define forever for (;;)
static int check_outlines = false;
static int nohints = false;
static int rasterize = false;
static char* results_dir = "results";
#define GOOD_FONTS_DIR "/home/wl/freetype-testfonts"
static char* default_dir_list[] =
{
GOOD_FONTS_DIR,
NULL
};
static char* default_ext_list[] =
{
"ttf",
"otf",
"ttc",
"cid",
"pfb",
"pfa",
"bdf",
"pcf",
"pfr",
"fon",
"otb",
"cff",
NULL
};
static int error_count = 1;
static int error_fraction = 0;
static FT_F26Dot6 font_size = 12 * 64;
static struct fontlist
{
char* name;
int len;
unsigned int isbinary: 1;
unsigned int isascii: 1;
unsigned int ishex: 1;
} *fontlist;
static int fcnt;
static int
FT_MoveTo( const FT_Vector *to,
void *user )
{
return 0;
}
static int
FT_LineTo( const FT_Vector *to,
void *user )
{
return 0;
}
static int
FT_ConicTo( const FT_Vector *_cp,
const FT_Vector *to,
void *user )
{
return 0;
}
static int
FT_CubicTo( const FT_Vector *cp1,
const FT_Vector *cp2,
const FT_Vector *to,
void *user )
{
return 0;
}
static FT_Outline_Funcs outlinefuncs =
{
FT_MoveTo,
FT_LineTo,
FT_ConicTo,
FT_CubicTo,
0, 0 /* No shift, no delta */
};
static void
TestFace( FT_Face face )
{
int gid;
int load_flags = FT_LOAD_DEFAULT;
if ( check_outlines &&
FT_IS_SCALABLE( face ) )
load_flags = FT_LOAD_NO_BITMAP;
if ( nohints )
load_flags |= FT_LOAD_NO_HINTING;
FT_Set_Char_Size( face, 0, font_size, 72, 72 );
for ( gid = 0; gid < face->num_glyphs; ++gid )
{
if ( check_outlines &&
FT_IS_SCALABLE( face ) )
{
if ( !FT_Load_Glyph( face, gid, load_flags ) )
FT_Outline_Decompose( &face->glyph->outline, &outlinefuncs, NULL );
}
else
FT_Load_Glyph( face, gid, load_flags );
if ( rasterize )
FT_Render_Glyph( face->glyph, ft_render_mode_normal );
}
FT_Done_Face( face );
}
static void
ExecuteTest( char* testfont )
{
FT_Library context;
FT_Face face;
if ( FT_Init_FreeType( &context ) )
{
fprintf( stderr, "Can't initialize FreeType.\n" );
exit( 1 );
}
if ( FT_New_Face( context, testfont, 0, &face ) )
{
/* The font is erroneous, so if this fails that's ok. */
exit( 0 );
}
if ( face->num_faces == 1 )
TestFace( face );
else
{
int i, num;
num = face->num_faces;
FT_Done_Face( face );
for ( i = 0; i < num; ++i )
{
if ( !FT_New_Face( context, testfont, i, &face ) )
TestFace( face );
}
}
exit( 0 );
}
static int
extmatch( char* filename,
char** extensions )
{
int i;
char* pt;
if ( extensions == NULL )
return true;
pt = strrchr( filename, '.' );
if ( pt == NULL )
return false;
if ( pt < strrchr( filename, '/' ) )
return false;
for ( i = 0; extensions[i] != NULL; ++i )
if ( strcasecmp( pt + 1, extensions[i] ) == 0 ||
strcasecmp( pt, extensions[i] ) == 0 )
return true;
return false;
}
static void
figurefiletype( struct fontlist* item )
{
FILE* foo;
item->isbinary = item->isascii = item->ishex = false;
foo = fopen( item->name, "rb" );
if ( foo != NULL )
{
/* Try to guess the file type from the first few characters... */
int ch1 = getc( foo );
int ch2 = getc( foo );
int ch3 = getc( foo );
int ch4 = getc( foo );
fclose( foo );
if ( ( ch1 == 0 && ch2 == 1 && ch3 == 0 && ch4 == 0 ) ||
( ch1 == 'O' && ch2 == 'T' && ch3 == 'T' && ch4 == 'O' ) ||
( ch1 == 't' && ch2 == 'r' && ch3 == 'u' && ch4 == 'e' ) ||
( ch1 == 't' && ch2 == 't' && ch3 == 'c' && ch4 == 'f' ) )
{
/* ttf, otf, ttc files */
item->isbinary = true;
}
else if ( ch1 == 0x80 && ch2 == '\01' )
{
/* PFB header */
item->isbinary = true;
}
else if ( ch1 == '%' && ch2 == '!' )
{
/* Random PostScript */
if ( strstr( item->name, ".pfa" ) != NULL ||
strstr( item->name, ".PFA" ) != NULL )
item->ishex = true;
else
item->isascii = true;
}
else if ( ch1 == 1 && ch2 == 0 && ch3 == 4 )
{
/* Bare CFF */
item->isbinary = true;
}
else if ( ch1 == 'S' && ch2 == 'T' && ch3 == 'A' && ch4 == 'R' )
{
/* BDF */
item->ishex = true;
}
else if ( ch1 == 'P' && ch2 == 'F' && ch3 == 'R' && ch4 == '0' )
{
/* PFR */
item->isbinary = true;
}
else if ( ( ch1 == '\1' && ch2 == 'f' && ch3 == 'c' && ch4 == 'p' ) ||
( ch1 == 'M' && ch2 == 'Z' ) )
{
/* Windows FON */
item->isbinary = true;
}
else
{
fprintf( stderr,
"Can't recognize file type of `%s', assuming binary\n",
item->name );
item->isbinary = true;
}
}
else
{
fprintf( stderr, "Can't open `%s' for typing the file.\n",
item->name );
item->isbinary = true;
}
}
static void
FindFonts( char** fontdirs,
char** extensions )
{
int i, max;
char buffer[1025];
struct stat statb;
max = 0;
fcnt = 0;
for ( i = 0; fontdirs[i] != NULL; ++i )
{
DIR* examples;
struct dirent* ent;
examples = opendir( fontdirs[i] );
if ( examples == NULL )
{
fprintf( stderr,
"Can't open example font directory `%s'\n",
fontdirs[i] );
exit( 1 );
}
while ( ( ent = readdir( examples ) ) != NULL )
{
snprintf( buffer, sizeof ( buffer ),
"%s/%s", fontdirs[i], ent->d_name );
if ( stat( buffer, &statb ) == -1 || S_ISDIR( statb.st_mode ) )
continue;
if ( extensions == NULL || extmatch( buffer, extensions ) )
{
if ( fcnt >= max )
{
max += 100;
fontlist = realloc( fontlist, max * sizeof ( struct fontlist ) );
if ( fontlist == NULL )
{
fprintf( stderr, "Can't allocate memory\n" );
exit( 1 );
}
}
fontlist[fcnt].name = strdup( buffer );
fontlist[fcnt].len = statb.st_size;
figurefiletype( &fontlist[fcnt] );
++fcnt;
}
}
closedir( examples );
}
if ( fcnt == 0 )
{
fprintf( stderr, "Can't find matching font files.\n" );
exit( 1 );
}
fontlist[fcnt].name = NULL;
}
static int
getErrorCnt( struct fontlist* item )
{
if ( error_count == 0 && error_fraction == 0 )
return 0;
return error_count + ceil( error_fraction * item->len );
}
static int
getRandom( int low,
int high )
{
if ( low - high < 0x10000L )
return low + ( ( random() >> 8 ) % ( high + 1 - low ) );
return low + ( random() % ( high + 1 - low ) );
}
static int
copyfont( struct fontlist* item,
char* newfont )
{
static char buffer[8096];
FILE *good, *new;
int len;
int i, err_cnt;
good = fopen( item->name, "r" );
if ( good == NULL )
{
fprintf( stderr, "Can't open `%s'\n", item->name );
return false;
}
new = fopen( newfont, "w+" );
if ( new == NULL )
{
fprintf( stderr, "Can't create temporary output file `%s'\n",
newfont );
exit( 1 );
}
while ( ( len = fread( buffer, 1, sizeof ( buffer ), good ) ) > 0 )
fwrite( buffer, 1, len, new );
fclose( good );
err_cnt = getErrorCnt( item );
for ( i = 0; i < err_cnt; ++i )
{
fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET );
if ( item->isbinary )
putc( getRandom( 0, 0xff ), new );
else if ( item->isascii )
putc( getRandom( 0x20, 0x7e ), new );
else
{
int hex = getRandom( 0, 15 );
if ( hex < 10 )
hex += '0';
else
hex += 'A' - 10;
putc( hex, new );
}
}
if ( ferror( new ) )
{
fclose( new );
unlink( newfont );
return false;
}
fclose( new );
return true;
}
static int child_pid;
static void
abort_test( int sig )
{
/* If a time-out happens, then kill the child */
kill( child_pid, SIGFPE );
write( 2, "Timeout... ", 11 );
}
static void
do_test( void )
{
int i = getRandom( 0, fcnt - 1 );
static int test_num = 0;
char buffer[1024];
sprintf( buffer, "%s/test%d", results_dir, test_num++ );
if ( copyfont ( &fontlist[i], buffer ) )
{
signal( SIGALRM, abort_test );
/* Anything that takes more than 20 seconds */
/* to parse and/or rasterize is an error. */
alarm( 20 );
if ( ( child_pid = fork() ) == 0 )
ExecuteTest( buffer );
else if ( child_pid != -1 )
{
int status;
waitpid( child_pid, &status, 0 );
alarm( 0 );
if ( WIFSIGNALED ( status ) )
printf( "Error found in file `%s'\n", buffer );
else
unlink( buffer );
}
else
{
fprintf( stderr, "Can't fork test case.\n" );
exit( 1 );
}
alarm( 0 );
}
}
static void
usage( FILE* out,
char* name )
{
fprintf( out, "%s [options] -- Generate random erroneous fonts\n"
" and attempt to parse them with FreeType.\n\n", name );
fprintf( out, " --all All non-directory files are assumed to be fonts.\n" );
fprintf( out, " --check-outlines Make sure we can parse the outlines of each glyph.\n" );
fprintf( out, " --dir <path> Append <path> to list of font search directories.\n" );
fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font.\n" );
fprintf( out, " --error-fraction <frac> Introduce <frac>*filesize single byte errors\n"
" into each font.\n" );
fprintf( out, " --ext <ext> Add <ext> to list of extensions indicating fonts.\n" );
fprintf( out, " --help Print this.\n" );
fprintf( out, " --nohints Turn off hinting.\n" );
fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" );
fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" );
fprintf( out, " --size <float> Use the given font size for the tests.\n" );
fprintf( out, " --test <file> Run a single test on an already existing file.\n" );
}
int
main( int argc,
char** argv )
{
char **dirs, **exts;
int dcnt = 0, ecnt = 0, rset = false, allexts = false;
int i;
time_t now;
char* testfile = NULL;
dirs = calloc( argc + 1, sizeof ( char ** ) );
exts = calloc( argc + 1, sizeof ( char ** ) );
for ( i = 1; i < argc; ++i )
{
char* pt = argv[i];
char* end;
if ( pt[0] == '-' && pt[1] == '-' )
++pt;
if ( strcmp( pt, "-all" ) == 0 )
allexts = true;
else if ( strcmp( pt, "-check-outlines" ) == 0 )
check_outlines = true;
else if ( strcmp( pt, "-dir" ) == 0 )
dirs[dcnt++] = argv[++i];
else if ( strcmp( pt, "-error-count" ) == 0 )
{
if ( !rset )
error_fraction = 0;
rset = true;
error_count = strtol( argv[++i], &end, 10 );
if ( *end != '\0' )
{
fprintf( stderr, "Bad value for error-count: %s\n", argv[i] );
exit( 1 );
}
}
else if ( strcmp( pt, "-error-fraction" ) == 0 )
{
if ( !rset )
error_count = 0;
rset = true;
error_fraction = strtod( argv[++i], &end );
if ( *end != '\0' )
{
fprintf( stderr, "Bad value for error-fraction: %s\n", argv[i] );
exit( 1 );
}
}
else if ( strcmp( pt, "-ext" ) == 0 )
exts[ecnt++] = argv[++i];
else if ( strcmp( pt, "-help" ) == 0 )
{
usage( stdout, argv[0] );
exit( 0 );
}
else if ( strcmp( pt, "-nohints" ) == 0 )
nohints = true;
else if ( strcmp( pt, "-rasterize" ) == 0 )
rasterize = true;
else if ( strcmp( pt, "-results" ) == 0 )
results_dir = argv[++i];
else if ( strcmp( pt, "-size" ) == 0 )
{
font_size = (FT_F26Dot6)( strtod( argv[++i], &end ) * 64 );
if ( *end != '\0' || font_size < 64 )
{
fprintf( stderr, "Bad value for size: %s\n", argv[i] );
exit( 1 );
}
}
else if ( strcmp( pt, "-test" ) == 0 )
testfile = argv[++i];
else
{
usage( stderr, argv[0] );
exit( 1 );
}
}
if ( allexts )
{
free( exts );
exts = NULL;
}
else if ( ecnt == 0 )
{
free( exts );
exts = default_ext_list;
}
if ( dcnt == 0 )
{
free( dirs );
dirs = default_dir_list;
}
if ( testfile != NULL )
ExecuteTest( testfile ); /* This should never return */
time( &now );
srandom( now );
FindFonts( dirs, exts );
mkdir( results_dir, 0755 );
forever
do_test();
return 0;
}
/* EOF */
| YifuLiu/AliOS-Things | components/freetype/src/tools/ftrandom/ftrandom.c | C | apache-2.0 | 16,000 |
#!/usr/bin/env python
#
#
# FreeType 2 glyph name builder
#
# Copyright 1996-2000, 2003, 2005, 2007, 2008, 2011 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.
"""\
usage: %s <output-file>
This python script generates the glyph names tables defined in the
`psnames' module.
Its single argument is the name of the header file to be created.
"""
import sys, string, struct, re, os.path
# This table lists the glyphs according to the Macintosh specification.
# It is used by the TrueType Postscript names table.
#
# See
#
# http://fonts.apple.com/TTRefMan/RM06/Chap6post.html
#
# for the official list.
#
mac_standard_names = \
[
# 0
".notdef", ".null", "nonmarkingreturn", "space", "exclam",
"quotedbl", "numbersign", "dollar", "percent", "ampersand",
# 10
"quotesingle", "parenleft", "parenright", "asterisk", "plus",
"comma", "hyphen", "period", "slash", "zero",
# 20
"one", "two", "three", "four", "five",
"six", "seven", "eight", "nine", "colon",
# 30
"semicolon", "less", "equal", "greater", "question",
"at", "A", "B", "C", "D",
# 40
"E", "F", "G", "H", "I",
"J", "K", "L", "M", "N",
# 50
"O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X",
# 60
"Y", "Z", "bracketleft", "backslash", "bracketright",
"asciicircum", "underscore", "grave", "a", "b",
# 70
"c", "d", "e", "f", "g",
"h", "i", "j", "k", "l",
# 80
"m", "n", "o", "p", "q",
"r", "s", "t", "u", "v",
# 90
"w", "x", "y", "z", "braceleft",
"bar", "braceright", "asciitilde", "Adieresis", "Aring",
# 100
"Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis",
"aacute", "agrave", "acircumflex", "adieresis", "atilde",
# 110
"aring", "ccedilla", "eacute", "egrave", "ecircumflex",
"edieresis", "iacute", "igrave", "icircumflex", "idieresis",
# 120
"ntilde", "oacute", "ograve", "ocircumflex", "odieresis",
"otilde", "uacute", "ugrave", "ucircumflex", "udieresis",
# 130
"dagger", "degree", "cent", "sterling", "section",
"bullet", "paragraph", "germandbls", "registered", "copyright",
# 140
"trademark", "acute", "dieresis", "notequal", "AE",
"Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
# 150
"yen", "mu", "partialdiff", "summation", "product",
"pi", "integral", "ordfeminine", "ordmasculine", "Omega",
# 160
"ae", "oslash", "questiondown", "exclamdown", "logicalnot",
"radical", "florin", "approxequal", "Delta", "guillemotleft",
# 170
"guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde",
"Otilde", "OE", "oe", "endash", "emdash",
# 180
"quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide",
"lozenge", "ydieresis", "Ydieresis", "fraction", "currency",
# 190
"guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl",
"periodcentered", "quotesinglbase", "quotedblbase", "perthousand",
"Acircumflex",
# 200
"Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
"Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
# 210
"apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave",
"dotlessi", "circumflex", "tilde", "macron", "breve",
# 220
"dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek",
"caron", "Lslash", "lslash", "Scaron", "scaron",
# 230
"Zcaron", "zcaron", "brokenbar", "Eth", "eth",
"Yacute", "yacute", "Thorn", "thorn", "minus",
# 240
"multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf",
"onequarter", "threequarters", "franc", "Gbreve", "gbreve",
# 250
"Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute",
"Ccaron", "ccaron", "dcroat"
]
# The list of standard `SID' glyph names. For the official list,
# see Annex A of document at
#
# http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf .
#
sid_standard_names = \
[
# 0
".notdef", "space", "exclam", "quotedbl", "numbersign",
"dollar", "percent", "ampersand", "quoteright", "parenleft",
# 10
"parenright", "asterisk", "plus", "comma", "hyphen",
"period", "slash", "zero", "one", "two",
# 20
"three", "four", "five", "six", "seven",
"eight", "nine", "colon", "semicolon", "less",
# 30
"equal", "greater", "question", "at", "A",
"B", "C", "D", "E", "F",
# 40
"G", "H", "I", "J", "K",
"L", "M", "N", "O", "P",
# 50
"Q", "R", "S", "T", "U",
"V", "W", "X", "Y", "Z",
# 60
"bracketleft", "backslash", "bracketright", "asciicircum", "underscore",
"quoteleft", "a", "b", "c", "d",
# 70
"e", "f", "g", "h", "i",
"j", "k", "l", "m", "n",
# 80
"o", "p", "q", "r", "s",
"t", "u", "v", "w", "x",
# 90
"y", "z", "braceleft", "bar", "braceright",
"asciitilde", "exclamdown", "cent", "sterling", "fraction",
# 100
"yen", "florin", "section", "currency", "quotesingle",
"quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi",
# 110
"fl", "endash", "dagger", "daggerdbl", "periodcentered",
"paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright",
# 120
"guillemotright", "ellipsis", "perthousand", "questiondown", "grave",
"acute", "circumflex", "tilde", "macron", "breve",
# 130
"dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut",
"ogonek", "caron", "emdash", "AE", "ordfeminine",
# 140
"Lslash", "Oslash", "OE", "ordmasculine", "ae",
"dotlessi", "lslash", "oslash", "oe", "germandbls",
# 150
"onesuperior", "logicalnot", "mu", "trademark", "Eth",
"onehalf", "plusminus", "Thorn", "onequarter", "divide",
# 160
"brokenbar", "degree", "thorn", "threequarters", "twosuperior",
"registered", "minus", "eth", "multiply", "threesuperior",
# 170
"copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave",
"Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex",
# 180
"Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis",
"Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis",
# 190
"Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex",
"Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron",
# 200
"aacute", "acircumflex", "adieresis", "agrave", "aring",
"atilde", "ccedilla", "eacute", "ecircumflex", "edieresis",
# 210
"egrave", "iacute", "icircumflex", "idieresis", "igrave",
"ntilde", "oacute", "ocircumflex", "odieresis", "ograve",
# 220
"otilde", "scaron", "uacute", "ucircumflex", "udieresis",
"ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall",
# 230
"Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall",
"Acutesmall",
"parenleftsuperior", "parenrightsuperior", "twodotenleader",
"onedotenleader", "zerooldstyle",
# 240
"oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle",
"fiveoldstyle",
"sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle",
"commasuperior",
# 250
"threequartersemdash", "periodsuperior", "questionsmall", "asuperior",
"bsuperior",
"centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior",
# 260
"msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior",
"tsuperior", "ff", "ffi", "ffl", "parenleftinferior",
# 270
"parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall",
"Asmall",
"Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall",
# 280
"Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall",
"Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall",
# 290
"Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall",
"Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall",
# 300
"colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall",
"centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall",
"Dieresissmall",
# 310
"Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash",
"hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall",
"questiondownsmall",
# 320
"oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird",
"twothirds", "zerosuperior", "foursuperior", "fivesuperior",
"sixsuperior",
# 330
"sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior",
"oneinferior",
"twoinferior", "threeinferior", "fourinferior", "fiveinferior",
"sixinferior",
# 340
"seveninferior", "eightinferior", "nineinferior", "centinferior",
"dollarinferior",
"periodinferior", "commainferior", "Agravesmall", "Aacutesmall",
"Acircumflexsmall",
# 350
"Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall",
"Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall",
"Igravesmall",
# 360
"Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall",
"Ntildesmall",
"Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall",
"Odieresissmall",
# 370
"OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall",
"Ucircumflexsmall",
"Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall",
"001.000",
# 380
"001.001", "001.002", "001.003", "Black", "Bold",
"Book", "Light", "Medium", "Regular", "Roman",
# 390
"Semibold"
]
# This table maps character codes of the Adobe Standard Type 1
# encoding to glyph indices in the sid_standard_names table.
#
t1_standard_encoding = \
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
89, 90, 91, 92, 93, 94, 95, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 0, 111, 112, 113,
114, 0, 115, 116, 117, 118, 119, 120, 121, 122,
0, 123, 0, 124, 125, 126, 127, 128, 129, 130,
131, 0, 132, 133, 0, 134, 135, 136, 137, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 138, 0, 139, 0, 0,
0, 0, 140, 141, 142, 143, 0, 0, 0, 0,
0, 144, 0, 0, 0, 145, 0, 0, 146, 147,
148, 149, 0, 0, 0, 0
]
# This table maps character codes of the Adobe Expert Type 1
# encoding to glyph indices in the sid_standard_names table.
#
t1_expert_encoding = \
[
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 229, 230, 0, 231, 232, 233, 234,
235, 236, 237, 238, 13, 14, 15, 99, 239, 240,
241, 242, 243, 244, 245, 246, 247, 248, 27, 28,
249, 250, 251, 252, 0, 253, 254, 255, 256, 257,
0, 0, 0, 258, 0, 0, 259, 260, 261, 262,
0, 0, 263, 264, 265, 0, 266, 109, 110, 267,
268, 269, 0, 270, 271, 272, 273, 274, 275, 276,
277, 278, 279, 280, 281, 282, 283, 284, 285, 286,
287, 288, 289, 290, 291, 292, 293, 294, 295, 296,
297, 298, 299, 300, 301, 302, 303, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 304, 305, 306, 0, 0, 307, 308, 309, 310,
311, 0, 312, 0, 0, 313, 0, 0, 314, 315,
0, 0, 316, 317, 318, 0, 0, 0, 158, 155,
163, 319, 320, 321, 322, 323, 324, 325, 0, 0,
326, 150, 164, 169, 327, 328, 329, 330, 331, 332,
333, 334, 335, 336, 337, 338, 339, 340, 341, 342,
343, 344, 345, 346, 347, 348, 349, 350, 351, 352,
353, 354, 355, 356, 357, 358, 359, 360, 361, 362,
363, 364, 365, 366, 367, 368, 369, 370, 371, 372,
373, 374, 375, 376, 377, 378
]
# This data has been taken literally from the files `glyphlist.txt'
# and `zapfdingbats.txt' version 2.0, Sept 2002. It is available from
#
# http://sourceforge.net/adobe/aglfn/
#
adobe_glyph_list = """\
A;0041
AE;00C6
AEacute;01FC
AEmacron;01E2
AEsmall;F7E6
Aacute;00C1
Aacutesmall;F7E1
Abreve;0102
Abreveacute;1EAE
Abrevecyrillic;04D0
Abrevedotbelow;1EB6
Abrevegrave;1EB0
Abrevehookabove;1EB2
Abrevetilde;1EB4
Acaron;01CD
Acircle;24B6
Acircumflex;00C2
Acircumflexacute;1EA4
Acircumflexdotbelow;1EAC
Acircumflexgrave;1EA6
Acircumflexhookabove;1EA8
Acircumflexsmall;F7E2
Acircumflextilde;1EAA
Acute;F6C9
Acutesmall;F7B4
Acyrillic;0410
Adblgrave;0200
Adieresis;00C4
Adieresiscyrillic;04D2
Adieresismacron;01DE
Adieresissmall;F7E4
Adotbelow;1EA0
Adotmacron;01E0
Agrave;00C0
Agravesmall;F7E0
Ahookabove;1EA2
Aiecyrillic;04D4
Ainvertedbreve;0202
Alpha;0391
Alphatonos;0386
Amacron;0100
Amonospace;FF21
Aogonek;0104
Aring;00C5
Aringacute;01FA
Aringbelow;1E00
Aringsmall;F7E5
Asmall;F761
Atilde;00C3
Atildesmall;F7E3
Aybarmenian;0531
B;0042
Bcircle;24B7
Bdotaccent;1E02
Bdotbelow;1E04
Becyrillic;0411
Benarmenian;0532
Beta;0392
Bhook;0181
Blinebelow;1E06
Bmonospace;FF22
Brevesmall;F6F4
Bsmall;F762
Btopbar;0182
C;0043
Caarmenian;053E
Cacute;0106
Caron;F6CA
Caronsmall;F6F5
Ccaron;010C
Ccedilla;00C7
Ccedillaacute;1E08
Ccedillasmall;F7E7
Ccircle;24B8
Ccircumflex;0108
Cdot;010A
Cdotaccent;010A
Cedillasmall;F7B8
Chaarmenian;0549
Cheabkhasiancyrillic;04BC
Checyrillic;0427
Chedescenderabkhasiancyrillic;04BE
Chedescendercyrillic;04B6
Chedieresiscyrillic;04F4
Cheharmenian;0543
Chekhakassiancyrillic;04CB
Cheverticalstrokecyrillic;04B8
Chi;03A7
Chook;0187
Circumflexsmall;F6F6
Cmonospace;FF23
Coarmenian;0551
Csmall;F763
D;0044
DZ;01F1
DZcaron;01C4
Daarmenian;0534
Dafrican;0189
Dcaron;010E
Dcedilla;1E10
Dcircle;24B9
Dcircumflexbelow;1E12
Dcroat;0110
Ddotaccent;1E0A
Ddotbelow;1E0C
Decyrillic;0414
Deicoptic;03EE
Delta;2206
Deltagreek;0394
Dhook;018A
Dieresis;F6CB
DieresisAcute;F6CC
DieresisGrave;F6CD
Dieresissmall;F7A8
Digammagreek;03DC
Djecyrillic;0402
Dlinebelow;1E0E
Dmonospace;FF24
Dotaccentsmall;F6F7
Dslash;0110
Dsmall;F764
Dtopbar;018B
Dz;01F2
Dzcaron;01C5
Dzeabkhasiancyrillic;04E0
Dzecyrillic;0405
Dzhecyrillic;040F
E;0045
Eacute;00C9
Eacutesmall;F7E9
Ebreve;0114
Ecaron;011A
Ecedillabreve;1E1C
Echarmenian;0535
Ecircle;24BA
Ecircumflex;00CA
Ecircumflexacute;1EBE
Ecircumflexbelow;1E18
Ecircumflexdotbelow;1EC6
Ecircumflexgrave;1EC0
Ecircumflexhookabove;1EC2
Ecircumflexsmall;F7EA
Ecircumflextilde;1EC4
Ecyrillic;0404
Edblgrave;0204
Edieresis;00CB
Edieresissmall;F7EB
Edot;0116
Edotaccent;0116
Edotbelow;1EB8
Efcyrillic;0424
Egrave;00C8
Egravesmall;F7E8
Eharmenian;0537
Ehookabove;1EBA
Eightroman;2167
Einvertedbreve;0206
Eiotifiedcyrillic;0464
Elcyrillic;041B
Elevenroman;216A
Emacron;0112
Emacronacute;1E16
Emacrongrave;1E14
Emcyrillic;041C
Emonospace;FF25
Encyrillic;041D
Endescendercyrillic;04A2
Eng;014A
Enghecyrillic;04A4
Enhookcyrillic;04C7
Eogonek;0118
Eopen;0190
Epsilon;0395
Epsilontonos;0388
Ercyrillic;0420
Ereversed;018E
Ereversedcyrillic;042D
Escyrillic;0421
Esdescendercyrillic;04AA
Esh;01A9
Esmall;F765
Eta;0397
Etarmenian;0538
Etatonos;0389
Eth;00D0
Ethsmall;F7F0
Etilde;1EBC
Etildebelow;1E1A
Euro;20AC
Ezh;01B7
Ezhcaron;01EE
Ezhreversed;01B8
F;0046
Fcircle;24BB
Fdotaccent;1E1E
Feharmenian;0556
Feicoptic;03E4
Fhook;0191
Fitacyrillic;0472
Fiveroman;2164
Fmonospace;FF26
Fourroman;2163
Fsmall;F766
G;0047
GBsquare;3387
Gacute;01F4
Gamma;0393
Gammaafrican;0194
Gangiacoptic;03EA
Gbreve;011E
Gcaron;01E6
Gcedilla;0122
Gcircle;24BC
Gcircumflex;011C
Gcommaaccent;0122
Gdot;0120
Gdotaccent;0120
Gecyrillic;0413
Ghadarmenian;0542
Ghemiddlehookcyrillic;0494
Ghestrokecyrillic;0492
Gheupturncyrillic;0490
Ghook;0193
Gimarmenian;0533
Gjecyrillic;0403
Gmacron;1E20
Gmonospace;FF27
Grave;F6CE
Gravesmall;F760
Gsmall;F767
Gsmallhook;029B
Gstroke;01E4
H;0048
H18533;25CF
H18543;25AA
H18551;25AB
H22073;25A1
HPsquare;33CB
Haabkhasiancyrillic;04A8
Hadescendercyrillic;04B2
Hardsigncyrillic;042A
Hbar;0126
Hbrevebelow;1E2A
Hcedilla;1E28
Hcircle;24BD
Hcircumflex;0124
Hdieresis;1E26
Hdotaccent;1E22
Hdotbelow;1E24
Hmonospace;FF28
Hoarmenian;0540
Horicoptic;03E8
Hsmall;F768
Hungarumlaut;F6CF
Hungarumlautsmall;F6F8
Hzsquare;3390
I;0049
IAcyrillic;042F
IJ;0132
IUcyrillic;042E
Iacute;00CD
Iacutesmall;F7ED
Ibreve;012C
Icaron;01CF
Icircle;24BE
Icircumflex;00CE
Icircumflexsmall;F7EE
Icyrillic;0406
Idblgrave;0208
Idieresis;00CF
Idieresisacute;1E2E
Idieresiscyrillic;04E4
Idieresissmall;F7EF
Idot;0130
Idotaccent;0130
Idotbelow;1ECA
Iebrevecyrillic;04D6
Iecyrillic;0415
Ifraktur;2111
Igrave;00CC
Igravesmall;F7EC
Ihookabove;1EC8
Iicyrillic;0418
Iinvertedbreve;020A
Iishortcyrillic;0419
Imacron;012A
Imacroncyrillic;04E2
Imonospace;FF29
Iniarmenian;053B
Iocyrillic;0401
Iogonek;012E
Iota;0399
Iotaafrican;0196
Iotadieresis;03AA
Iotatonos;038A
Ismall;F769
Istroke;0197
Itilde;0128
Itildebelow;1E2C
Izhitsacyrillic;0474
Izhitsadblgravecyrillic;0476
J;004A
Jaarmenian;0541
Jcircle;24BF
Jcircumflex;0134
Jecyrillic;0408
Jheharmenian;054B
Jmonospace;FF2A
Jsmall;F76A
K;004B
KBsquare;3385
KKsquare;33CD
Kabashkircyrillic;04A0
Kacute;1E30
Kacyrillic;041A
Kadescendercyrillic;049A
Kahookcyrillic;04C3
Kappa;039A
Kastrokecyrillic;049E
Kaverticalstrokecyrillic;049C
Kcaron;01E8
Kcedilla;0136
Kcircle;24C0
Kcommaaccent;0136
Kdotbelow;1E32
Keharmenian;0554
Kenarmenian;053F
Khacyrillic;0425
Kheicoptic;03E6
Khook;0198
Kjecyrillic;040C
Klinebelow;1E34
Kmonospace;FF2B
Koppacyrillic;0480
Koppagreek;03DE
Ksicyrillic;046E
Ksmall;F76B
L;004C
LJ;01C7
LL;F6BF
Lacute;0139
Lambda;039B
Lcaron;013D
Lcedilla;013B
Lcircle;24C1
Lcircumflexbelow;1E3C
Lcommaaccent;013B
Ldot;013F
Ldotaccent;013F
Ldotbelow;1E36
Ldotbelowmacron;1E38
Liwnarmenian;053C
Lj;01C8
Ljecyrillic;0409
Llinebelow;1E3A
Lmonospace;FF2C
Lslash;0141
Lslashsmall;F6F9
Lsmall;F76C
M;004D
MBsquare;3386
Macron;F6D0
Macronsmall;F7AF
Macute;1E3E
Mcircle;24C2
Mdotaccent;1E40
Mdotbelow;1E42
Menarmenian;0544
Mmonospace;FF2D
Msmall;F76D
Mturned;019C
Mu;039C
N;004E
NJ;01CA
Nacute;0143
Ncaron;0147
Ncedilla;0145
Ncircle;24C3
Ncircumflexbelow;1E4A
Ncommaaccent;0145
Ndotaccent;1E44
Ndotbelow;1E46
Nhookleft;019D
Nineroman;2168
Nj;01CB
Njecyrillic;040A
Nlinebelow;1E48
Nmonospace;FF2E
Nowarmenian;0546
Nsmall;F76E
Ntilde;00D1
Ntildesmall;F7F1
Nu;039D
O;004F
OE;0152
OEsmall;F6FA
Oacute;00D3
Oacutesmall;F7F3
Obarredcyrillic;04E8
Obarreddieresiscyrillic;04EA
Obreve;014E
Ocaron;01D1
Ocenteredtilde;019F
Ocircle;24C4
Ocircumflex;00D4
Ocircumflexacute;1ED0
Ocircumflexdotbelow;1ED8
Ocircumflexgrave;1ED2
Ocircumflexhookabove;1ED4
Ocircumflexsmall;F7F4
Ocircumflextilde;1ED6
Ocyrillic;041E
Odblacute;0150
Odblgrave;020C
Odieresis;00D6
Odieresiscyrillic;04E6
Odieresissmall;F7F6
Odotbelow;1ECC
Ogoneksmall;F6FB
Ograve;00D2
Ogravesmall;F7F2
Oharmenian;0555
Ohm;2126
Ohookabove;1ECE
Ohorn;01A0
Ohornacute;1EDA
Ohorndotbelow;1EE2
Ohorngrave;1EDC
Ohornhookabove;1EDE
Ohorntilde;1EE0
Ohungarumlaut;0150
Oi;01A2
Oinvertedbreve;020E
Omacron;014C
Omacronacute;1E52
Omacrongrave;1E50
Omega;2126
Omegacyrillic;0460
Omegagreek;03A9
Omegaroundcyrillic;047A
Omegatitlocyrillic;047C
Omegatonos;038F
Omicron;039F
Omicrontonos;038C
Omonospace;FF2F
Oneroman;2160
Oogonek;01EA
Oogonekmacron;01EC
Oopen;0186
Oslash;00D8
Oslashacute;01FE
Oslashsmall;F7F8
Osmall;F76F
Ostrokeacute;01FE
Otcyrillic;047E
Otilde;00D5
Otildeacute;1E4C
Otildedieresis;1E4E
Otildesmall;F7F5
P;0050
Pacute;1E54
Pcircle;24C5
Pdotaccent;1E56
Pecyrillic;041F
Peharmenian;054A
Pemiddlehookcyrillic;04A6
Phi;03A6
Phook;01A4
Pi;03A0
Piwrarmenian;0553
Pmonospace;FF30
Psi;03A8
Psicyrillic;0470
Psmall;F770
Q;0051
Qcircle;24C6
Qmonospace;FF31
Qsmall;F771
R;0052
Raarmenian;054C
Racute;0154
Rcaron;0158
Rcedilla;0156
Rcircle;24C7
Rcommaaccent;0156
Rdblgrave;0210
Rdotaccent;1E58
Rdotbelow;1E5A
Rdotbelowmacron;1E5C
Reharmenian;0550
Rfraktur;211C
Rho;03A1
Ringsmall;F6FC
Rinvertedbreve;0212
Rlinebelow;1E5E
Rmonospace;FF32
Rsmall;F772
Rsmallinverted;0281
Rsmallinvertedsuperior;02B6
S;0053
SF010000;250C
SF020000;2514
SF030000;2510
SF040000;2518
SF050000;253C
SF060000;252C
SF070000;2534
SF080000;251C
SF090000;2524
SF100000;2500
SF110000;2502
SF190000;2561
SF200000;2562
SF210000;2556
SF220000;2555
SF230000;2563
SF240000;2551
SF250000;2557
SF260000;255D
SF270000;255C
SF280000;255B
SF360000;255E
SF370000;255F
SF380000;255A
SF390000;2554
SF400000;2569
SF410000;2566
SF420000;2560
SF430000;2550
SF440000;256C
SF450000;2567
SF460000;2568
SF470000;2564
SF480000;2565
SF490000;2559
SF500000;2558
SF510000;2552
SF520000;2553
SF530000;256B
SF540000;256A
Sacute;015A
Sacutedotaccent;1E64
Sampigreek;03E0
Scaron;0160
Scarondotaccent;1E66
Scaronsmall;F6FD
Scedilla;015E
Schwa;018F
Schwacyrillic;04D8
Schwadieresiscyrillic;04DA
Scircle;24C8
Scircumflex;015C
Scommaaccent;0218
Sdotaccent;1E60
Sdotbelow;1E62
Sdotbelowdotaccent;1E68
Seharmenian;054D
Sevenroman;2166
Shaarmenian;0547
Shacyrillic;0428
Shchacyrillic;0429
Sheicoptic;03E2
Shhacyrillic;04BA
Shimacoptic;03EC
Sigma;03A3
Sixroman;2165
Smonospace;FF33
Softsigncyrillic;042C
Ssmall;F773
Stigmagreek;03DA
T;0054
Tau;03A4
Tbar;0166
Tcaron;0164
Tcedilla;0162
Tcircle;24C9
Tcircumflexbelow;1E70
Tcommaaccent;0162
Tdotaccent;1E6A
Tdotbelow;1E6C
Tecyrillic;0422
Tedescendercyrillic;04AC
Tenroman;2169
Tetsecyrillic;04B4
Theta;0398
Thook;01AC
Thorn;00DE
Thornsmall;F7FE
Threeroman;2162
Tildesmall;F6FE
Tiwnarmenian;054F
Tlinebelow;1E6E
Tmonospace;FF34
Toarmenian;0539
Tonefive;01BC
Tonesix;0184
Tonetwo;01A7
Tretroflexhook;01AE
Tsecyrillic;0426
Tshecyrillic;040B
Tsmall;F774
Twelveroman;216B
Tworoman;2161
U;0055
Uacute;00DA
Uacutesmall;F7FA
Ubreve;016C
Ucaron;01D3
Ucircle;24CA
Ucircumflex;00DB
Ucircumflexbelow;1E76
Ucircumflexsmall;F7FB
Ucyrillic;0423
Udblacute;0170
Udblgrave;0214
Udieresis;00DC
Udieresisacute;01D7
Udieresisbelow;1E72
Udieresiscaron;01D9
Udieresiscyrillic;04F0
Udieresisgrave;01DB
Udieresismacron;01D5
Udieresissmall;F7FC
Udotbelow;1EE4
Ugrave;00D9
Ugravesmall;F7F9
Uhookabove;1EE6
Uhorn;01AF
Uhornacute;1EE8
Uhorndotbelow;1EF0
Uhorngrave;1EEA
Uhornhookabove;1EEC
Uhorntilde;1EEE
Uhungarumlaut;0170
Uhungarumlautcyrillic;04F2
Uinvertedbreve;0216
Ukcyrillic;0478
Umacron;016A
Umacroncyrillic;04EE
Umacrondieresis;1E7A
Umonospace;FF35
Uogonek;0172
Upsilon;03A5
Upsilon1;03D2
Upsilonacutehooksymbolgreek;03D3
Upsilonafrican;01B1
Upsilondieresis;03AB
Upsilondieresishooksymbolgreek;03D4
Upsilonhooksymbol;03D2
Upsilontonos;038E
Uring;016E
Ushortcyrillic;040E
Usmall;F775
Ustraightcyrillic;04AE
Ustraightstrokecyrillic;04B0
Utilde;0168
Utildeacute;1E78
Utildebelow;1E74
V;0056
Vcircle;24CB
Vdotbelow;1E7E
Vecyrillic;0412
Vewarmenian;054E
Vhook;01B2
Vmonospace;FF36
Voarmenian;0548
Vsmall;F776
Vtilde;1E7C
W;0057
Wacute;1E82
Wcircle;24CC
Wcircumflex;0174
Wdieresis;1E84
Wdotaccent;1E86
Wdotbelow;1E88
Wgrave;1E80
Wmonospace;FF37
Wsmall;F777
X;0058
Xcircle;24CD
Xdieresis;1E8C
Xdotaccent;1E8A
Xeharmenian;053D
Xi;039E
Xmonospace;FF38
Xsmall;F778
Y;0059
Yacute;00DD
Yacutesmall;F7FD
Yatcyrillic;0462
Ycircle;24CE
Ycircumflex;0176
Ydieresis;0178
Ydieresissmall;F7FF
Ydotaccent;1E8E
Ydotbelow;1EF4
Yericyrillic;042B
Yerudieresiscyrillic;04F8
Ygrave;1EF2
Yhook;01B3
Yhookabove;1EF6
Yiarmenian;0545
Yicyrillic;0407
Yiwnarmenian;0552
Ymonospace;FF39
Ysmall;F779
Ytilde;1EF8
Yusbigcyrillic;046A
Yusbigiotifiedcyrillic;046C
Yuslittlecyrillic;0466
Yuslittleiotifiedcyrillic;0468
Z;005A
Zaarmenian;0536
Zacute;0179
Zcaron;017D
Zcaronsmall;F6FF
Zcircle;24CF
Zcircumflex;1E90
Zdot;017B
Zdotaccent;017B
Zdotbelow;1E92
Zecyrillic;0417
Zedescendercyrillic;0498
Zedieresiscyrillic;04DE
Zeta;0396
Zhearmenian;053A
Zhebrevecyrillic;04C1
Zhecyrillic;0416
Zhedescendercyrillic;0496
Zhedieresiscyrillic;04DC
Zlinebelow;1E94
Zmonospace;FF3A
Zsmall;F77A
Zstroke;01B5
a;0061
aabengali;0986
aacute;00E1
aadeva;0906
aagujarati;0A86
aagurmukhi;0A06
aamatragurmukhi;0A3E
aarusquare;3303
aavowelsignbengali;09BE
aavowelsigndeva;093E
aavowelsigngujarati;0ABE
abbreviationmarkarmenian;055F
abbreviationsigndeva;0970
abengali;0985
abopomofo;311A
abreve;0103
abreveacute;1EAF
abrevecyrillic;04D1
abrevedotbelow;1EB7
abrevegrave;1EB1
abrevehookabove;1EB3
abrevetilde;1EB5
acaron;01CE
acircle;24D0
acircumflex;00E2
acircumflexacute;1EA5
acircumflexdotbelow;1EAD
acircumflexgrave;1EA7
acircumflexhookabove;1EA9
acircumflextilde;1EAB
acute;00B4
acutebelowcmb;0317
acutecmb;0301
acutecomb;0301
acutedeva;0954
acutelowmod;02CF
acutetonecmb;0341
acyrillic;0430
adblgrave;0201
addakgurmukhi;0A71
adeva;0905
adieresis;00E4
adieresiscyrillic;04D3
adieresismacron;01DF
adotbelow;1EA1
adotmacron;01E1
ae;00E6
aeacute;01FD
aekorean;3150
aemacron;01E3
afii00208;2015
afii08941;20A4
afii10017;0410
afii10018;0411
afii10019;0412
afii10020;0413
afii10021;0414
afii10022;0415
afii10023;0401
afii10024;0416
afii10025;0417
afii10026;0418
afii10027;0419
afii10028;041A
afii10029;041B
afii10030;041C
afii10031;041D
afii10032;041E
afii10033;041F
afii10034;0420
afii10035;0421
afii10036;0422
afii10037;0423
afii10038;0424
afii10039;0425
afii10040;0426
afii10041;0427
afii10042;0428
afii10043;0429
afii10044;042A
afii10045;042B
afii10046;042C
afii10047;042D
afii10048;042E
afii10049;042F
afii10050;0490
afii10051;0402
afii10052;0403
afii10053;0404
afii10054;0405
afii10055;0406
afii10056;0407
afii10057;0408
afii10058;0409
afii10059;040A
afii10060;040B
afii10061;040C
afii10062;040E
afii10063;F6C4
afii10064;F6C5
afii10065;0430
afii10066;0431
afii10067;0432
afii10068;0433
afii10069;0434
afii10070;0435
afii10071;0451
afii10072;0436
afii10073;0437
afii10074;0438
afii10075;0439
afii10076;043A
afii10077;043B
afii10078;043C
afii10079;043D
afii10080;043E
afii10081;043F
afii10082;0440
afii10083;0441
afii10084;0442
afii10085;0443
afii10086;0444
afii10087;0445
afii10088;0446
afii10089;0447
afii10090;0448
afii10091;0449
afii10092;044A
afii10093;044B
afii10094;044C
afii10095;044D
afii10096;044E
afii10097;044F
afii10098;0491
afii10099;0452
afii10100;0453
afii10101;0454
afii10102;0455
afii10103;0456
afii10104;0457
afii10105;0458
afii10106;0459
afii10107;045A
afii10108;045B
afii10109;045C
afii10110;045E
afii10145;040F
afii10146;0462
afii10147;0472
afii10148;0474
afii10192;F6C6
afii10193;045F
afii10194;0463
afii10195;0473
afii10196;0475
afii10831;F6C7
afii10832;F6C8
afii10846;04D9
afii299;200E
afii300;200F
afii301;200D
afii57381;066A
afii57388;060C
afii57392;0660
afii57393;0661
afii57394;0662
afii57395;0663
afii57396;0664
afii57397;0665
afii57398;0666
afii57399;0667
afii57400;0668
afii57401;0669
afii57403;061B
afii57407;061F
afii57409;0621
afii57410;0622
afii57411;0623
afii57412;0624
afii57413;0625
afii57414;0626
afii57415;0627
afii57416;0628
afii57417;0629
afii57418;062A
afii57419;062B
afii57420;062C
afii57421;062D
afii57422;062E
afii57423;062F
afii57424;0630
afii57425;0631
afii57426;0632
afii57427;0633
afii57428;0634
afii57429;0635
afii57430;0636
afii57431;0637
afii57432;0638
afii57433;0639
afii57434;063A
afii57440;0640
afii57441;0641
afii57442;0642
afii57443;0643
afii57444;0644
afii57445;0645
afii57446;0646
afii57448;0648
afii57449;0649
afii57450;064A
afii57451;064B
afii57452;064C
afii57453;064D
afii57454;064E
afii57455;064F
afii57456;0650
afii57457;0651
afii57458;0652
afii57470;0647
afii57505;06A4
afii57506;067E
afii57507;0686
afii57508;0698
afii57509;06AF
afii57511;0679
afii57512;0688
afii57513;0691
afii57514;06BA
afii57519;06D2
afii57534;06D5
afii57636;20AA
afii57645;05BE
afii57658;05C3
afii57664;05D0
afii57665;05D1
afii57666;05D2
afii57667;05D3
afii57668;05D4
afii57669;05D5
afii57670;05D6
afii57671;05D7
afii57672;05D8
afii57673;05D9
afii57674;05DA
afii57675;05DB
afii57676;05DC
afii57677;05DD
afii57678;05DE
afii57679;05DF
afii57680;05E0
afii57681;05E1
afii57682;05E2
afii57683;05E3
afii57684;05E4
afii57685;05E5
afii57686;05E6
afii57687;05E7
afii57688;05E8
afii57689;05E9
afii57690;05EA
afii57694;FB2A
afii57695;FB2B
afii57700;FB4B
afii57705;FB1F
afii57716;05F0
afii57717;05F1
afii57718;05F2
afii57723;FB35
afii57793;05B4
afii57794;05B5
afii57795;05B6
afii57796;05BB
afii57797;05B8
afii57798;05B7
afii57799;05B0
afii57800;05B2
afii57801;05B1
afii57802;05B3
afii57803;05C2
afii57804;05C1
afii57806;05B9
afii57807;05BC
afii57839;05BD
afii57841;05BF
afii57842;05C0
afii57929;02BC
afii61248;2105
afii61289;2113
afii61352;2116
afii61573;202C
afii61574;202D
afii61575;202E
afii61664;200C
afii63167;066D
afii64937;02BD
agrave;00E0
agujarati;0A85
agurmukhi;0A05
ahiragana;3042
ahookabove;1EA3
aibengali;0990
aibopomofo;311E
aideva;0910
aiecyrillic;04D5
aigujarati;0A90
aigurmukhi;0A10
aimatragurmukhi;0A48
ainarabic;0639
ainfinalarabic;FECA
aininitialarabic;FECB
ainmedialarabic;FECC
ainvertedbreve;0203
aivowelsignbengali;09C8
aivowelsigndeva;0948
aivowelsigngujarati;0AC8
akatakana;30A2
akatakanahalfwidth;FF71
akorean;314F
alef;05D0
alefarabic;0627
alefdageshhebrew;FB30
aleffinalarabic;FE8E
alefhamzaabovearabic;0623
alefhamzaabovefinalarabic;FE84
alefhamzabelowarabic;0625
alefhamzabelowfinalarabic;FE88
alefhebrew;05D0
aleflamedhebrew;FB4F
alefmaddaabovearabic;0622
alefmaddaabovefinalarabic;FE82
alefmaksuraarabic;0649
alefmaksurafinalarabic;FEF0
alefmaksurainitialarabic;FEF3
alefmaksuramedialarabic;FEF4
alefpatahhebrew;FB2E
alefqamatshebrew;FB2F
aleph;2135
allequal;224C
alpha;03B1
alphatonos;03AC
amacron;0101
amonospace;FF41
ampersand;0026
ampersandmonospace;FF06
ampersandsmall;F726
amsquare;33C2
anbopomofo;3122
angbopomofo;3124
angkhankhuthai;0E5A
angle;2220
anglebracketleft;3008
anglebracketleftvertical;FE3F
anglebracketright;3009
anglebracketrightvertical;FE40
angleleft;2329
angleright;232A
angstrom;212B
anoteleia;0387
anudattadeva;0952
anusvarabengali;0982
anusvaradeva;0902
anusvaragujarati;0A82
aogonek;0105
apaatosquare;3300
aparen;249C
apostrophearmenian;055A
apostrophemod;02BC
apple;F8FF
approaches;2250
approxequal;2248
approxequalorimage;2252
approximatelyequal;2245
araeaekorean;318E
araeakorean;318D
arc;2312
arighthalfring;1E9A
aring;00E5
aringacute;01FB
aringbelow;1E01
arrowboth;2194
arrowdashdown;21E3
arrowdashleft;21E0
arrowdashright;21E2
arrowdashup;21E1
arrowdblboth;21D4
arrowdbldown;21D3
arrowdblleft;21D0
arrowdblright;21D2
arrowdblup;21D1
arrowdown;2193
arrowdownleft;2199
arrowdownright;2198
arrowdownwhite;21E9
arrowheaddownmod;02C5
arrowheadleftmod;02C2
arrowheadrightmod;02C3
arrowheadupmod;02C4
arrowhorizex;F8E7
arrowleft;2190
arrowleftdbl;21D0
arrowleftdblstroke;21CD
arrowleftoverright;21C6
arrowleftwhite;21E6
arrowright;2192
arrowrightdblstroke;21CF
arrowrightheavy;279E
arrowrightoverleft;21C4
arrowrightwhite;21E8
arrowtableft;21E4
arrowtabright;21E5
arrowup;2191
arrowupdn;2195
arrowupdnbse;21A8
arrowupdownbase;21A8
arrowupleft;2196
arrowupleftofdown;21C5
arrowupright;2197
arrowupwhite;21E7
arrowvertex;F8E6
asciicircum;005E
asciicircummonospace;FF3E
asciitilde;007E
asciitildemonospace;FF5E
ascript;0251
ascriptturned;0252
asmallhiragana;3041
asmallkatakana;30A1
asmallkatakanahalfwidth;FF67
asterisk;002A
asteriskaltonearabic;066D
asteriskarabic;066D
asteriskmath;2217
asteriskmonospace;FF0A
asterisksmall;FE61
asterism;2042
asuperior;F6E9
asymptoticallyequal;2243
at;0040
atilde;00E3
atmonospace;FF20
atsmall;FE6B
aturned;0250
aubengali;0994
aubopomofo;3120
audeva;0914
augujarati;0A94
augurmukhi;0A14
aulengthmarkbengali;09D7
aumatragurmukhi;0A4C
auvowelsignbengali;09CC
auvowelsigndeva;094C
auvowelsigngujarati;0ACC
avagrahadeva;093D
aybarmenian;0561
ayin;05E2
ayinaltonehebrew;FB20
ayinhebrew;05E2
b;0062
babengali;09AC
backslash;005C
backslashmonospace;FF3C
badeva;092C
bagujarati;0AAC
bagurmukhi;0A2C
bahiragana;3070
bahtthai;0E3F
bakatakana;30D0
bar;007C
barmonospace;FF5C
bbopomofo;3105
bcircle;24D1
bdotaccent;1E03
bdotbelow;1E05
beamedsixteenthnotes;266C
because;2235
becyrillic;0431
beharabic;0628
behfinalarabic;FE90
behinitialarabic;FE91
behiragana;3079
behmedialarabic;FE92
behmeeminitialarabic;FC9F
behmeemisolatedarabic;FC08
behnoonfinalarabic;FC6D
bekatakana;30D9
benarmenian;0562
bet;05D1
beta;03B2
betasymbolgreek;03D0
betdagesh;FB31
betdageshhebrew;FB31
bethebrew;05D1
betrafehebrew;FB4C
bhabengali;09AD
bhadeva;092D
bhagujarati;0AAD
bhagurmukhi;0A2D
bhook;0253
bihiragana;3073
bikatakana;30D3
bilabialclick;0298
bindigurmukhi;0A02
birusquare;3331
blackcircle;25CF
blackdiamond;25C6
blackdownpointingtriangle;25BC
blackleftpointingpointer;25C4
blackleftpointingtriangle;25C0
blacklenticularbracketleft;3010
blacklenticularbracketleftvertical;FE3B
blacklenticularbracketright;3011
blacklenticularbracketrightvertical;FE3C
blacklowerlefttriangle;25E3
blacklowerrighttriangle;25E2
blackrectangle;25AC
blackrightpointingpointer;25BA
blackrightpointingtriangle;25B6
blacksmallsquare;25AA
blacksmilingface;263B
blacksquare;25A0
blackstar;2605
blackupperlefttriangle;25E4
blackupperrighttriangle;25E5
blackuppointingsmalltriangle;25B4
blackuppointingtriangle;25B2
blank;2423
blinebelow;1E07
block;2588
bmonospace;FF42
bobaimaithai;0E1A
bohiragana;307C
bokatakana;30DC
bparen;249D
bqsquare;33C3
braceex;F8F4
braceleft;007B
braceleftbt;F8F3
braceleftmid;F8F2
braceleftmonospace;FF5B
braceleftsmall;FE5B
bracelefttp;F8F1
braceleftvertical;FE37
braceright;007D
bracerightbt;F8FE
bracerightmid;F8FD
bracerightmonospace;FF5D
bracerightsmall;FE5C
bracerighttp;F8FC
bracerightvertical;FE38
bracketleft;005B
bracketleftbt;F8F0
bracketleftex;F8EF
bracketleftmonospace;FF3B
bracketlefttp;F8EE
bracketright;005D
bracketrightbt;F8FB
bracketrightex;F8FA
bracketrightmonospace;FF3D
bracketrighttp;F8F9
breve;02D8
brevebelowcmb;032E
brevecmb;0306
breveinvertedbelowcmb;032F
breveinvertedcmb;0311
breveinverteddoublecmb;0361
bridgebelowcmb;032A
bridgeinvertedbelowcmb;033A
brokenbar;00A6
bstroke;0180
bsuperior;F6EA
btopbar;0183
buhiragana;3076
bukatakana;30D6
bullet;2022
bulletinverse;25D8
bulletoperator;2219
bullseye;25CE
c;0063
caarmenian;056E
cabengali;099A
cacute;0107
cadeva;091A
cagujarati;0A9A
cagurmukhi;0A1A
calsquare;3388
candrabindubengali;0981
candrabinducmb;0310
candrabindudeva;0901
candrabindugujarati;0A81
capslock;21EA
careof;2105
caron;02C7
caronbelowcmb;032C
caroncmb;030C
carriagereturn;21B5
cbopomofo;3118
ccaron;010D
ccedilla;00E7
ccedillaacute;1E09
ccircle;24D2
ccircumflex;0109
ccurl;0255
cdot;010B
cdotaccent;010B
cdsquare;33C5
cedilla;00B8
cedillacmb;0327
cent;00A2
centigrade;2103
centinferior;F6DF
centmonospace;FFE0
centoldstyle;F7A2
centsuperior;F6E0
chaarmenian;0579
chabengali;099B
chadeva;091B
chagujarati;0A9B
chagurmukhi;0A1B
chbopomofo;3114
cheabkhasiancyrillic;04BD
checkmark;2713
checyrillic;0447
chedescenderabkhasiancyrillic;04BF
chedescendercyrillic;04B7
chedieresiscyrillic;04F5
cheharmenian;0573
chekhakassiancyrillic;04CC
cheverticalstrokecyrillic;04B9
chi;03C7
chieuchacirclekorean;3277
chieuchaparenkorean;3217
chieuchcirclekorean;3269
chieuchkorean;314A
chieuchparenkorean;3209
chochangthai;0E0A
chochanthai;0E08
chochingthai;0E09
chochoethai;0E0C
chook;0188
cieucacirclekorean;3276
cieucaparenkorean;3216
cieuccirclekorean;3268
cieuckorean;3148
cieucparenkorean;3208
cieucuparenkorean;321C
circle;25CB
circlemultiply;2297
circleot;2299
circleplus;2295
circlepostalmark;3036
circlewithlefthalfblack;25D0
circlewithrighthalfblack;25D1
circumflex;02C6
circumflexbelowcmb;032D
circumflexcmb;0302
clear;2327
clickalveolar;01C2
clickdental;01C0
clicklateral;01C1
clickretroflex;01C3
club;2663
clubsuitblack;2663
clubsuitwhite;2667
cmcubedsquare;33A4
cmonospace;FF43
cmsquaredsquare;33A0
coarmenian;0581
colon;003A
colonmonetary;20A1
colonmonospace;FF1A
colonsign;20A1
colonsmall;FE55
colontriangularhalfmod;02D1
colontriangularmod;02D0
comma;002C
commaabovecmb;0313
commaaboverightcmb;0315
commaaccent;F6C3
commaarabic;060C
commaarmenian;055D
commainferior;F6E1
commamonospace;FF0C
commareversedabovecmb;0314
commareversedmod;02BD
commasmall;FE50
commasuperior;F6E2
commaturnedabovecmb;0312
commaturnedmod;02BB
compass;263C
congruent;2245
contourintegral;222E
control;2303
controlACK;0006
controlBEL;0007
controlBS;0008
controlCAN;0018
controlCR;000D
controlDC1;0011
controlDC2;0012
controlDC3;0013
controlDC4;0014
controlDEL;007F
controlDLE;0010
controlEM;0019
controlENQ;0005
controlEOT;0004
controlESC;001B
controlETB;0017
controlETX;0003
controlFF;000C
controlFS;001C
controlGS;001D
controlHT;0009
controlLF;000A
controlNAK;0015
controlRS;001E
controlSI;000F
controlSO;000E
controlSOT;0002
controlSTX;0001
controlSUB;001A
controlSYN;0016
controlUS;001F
controlVT;000B
copyright;00A9
copyrightsans;F8E9
copyrightserif;F6D9
cornerbracketleft;300C
cornerbracketlefthalfwidth;FF62
cornerbracketleftvertical;FE41
cornerbracketright;300D
cornerbracketrighthalfwidth;FF63
cornerbracketrightvertical;FE42
corporationsquare;337F
cosquare;33C7
coverkgsquare;33C6
cparen;249E
cruzeiro;20A2
cstretched;0297
curlyand;22CF
curlyor;22CE
currency;00A4
cyrBreve;F6D1
cyrFlex;F6D2
cyrbreve;F6D4
cyrflex;F6D5
d;0064
daarmenian;0564
dabengali;09A6
dadarabic;0636
dadeva;0926
dadfinalarabic;FEBE
dadinitialarabic;FEBF
dadmedialarabic;FEC0
dagesh;05BC
dageshhebrew;05BC
dagger;2020
daggerdbl;2021
dagujarati;0AA6
dagurmukhi;0A26
dahiragana;3060
dakatakana;30C0
dalarabic;062F
dalet;05D3
daletdagesh;FB33
daletdageshhebrew;FB33
dalethatafpatah;05D3 05B2
dalethatafpatahhebrew;05D3 05B2
dalethatafsegol;05D3 05B1
dalethatafsegolhebrew;05D3 05B1
dalethebrew;05D3
dalethiriq;05D3 05B4
dalethiriqhebrew;05D3 05B4
daletholam;05D3 05B9
daletholamhebrew;05D3 05B9
daletpatah;05D3 05B7
daletpatahhebrew;05D3 05B7
daletqamats;05D3 05B8
daletqamatshebrew;05D3 05B8
daletqubuts;05D3 05BB
daletqubutshebrew;05D3 05BB
daletsegol;05D3 05B6
daletsegolhebrew;05D3 05B6
daletsheva;05D3 05B0
daletshevahebrew;05D3 05B0
dalettsere;05D3 05B5
dalettserehebrew;05D3 05B5
dalfinalarabic;FEAA
dammaarabic;064F
dammalowarabic;064F
dammatanaltonearabic;064C
dammatanarabic;064C
danda;0964
dargahebrew;05A7
dargalefthebrew;05A7
dasiapneumatacyrilliccmb;0485
dblGrave;F6D3
dblanglebracketleft;300A
dblanglebracketleftvertical;FE3D
dblanglebracketright;300B
dblanglebracketrightvertical;FE3E
dblarchinvertedbelowcmb;032B
dblarrowleft;21D4
dblarrowright;21D2
dbldanda;0965
dblgrave;F6D6
dblgravecmb;030F
dblintegral;222C
dbllowline;2017
dbllowlinecmb;0333
dbloverlinecmb;033F
dblprimemod;02BA
dblverticalbar;2016
dblverticallineabovecmb;030E
dbopomofo;3109
dbsquare;33C8
dcaron;010F
dcedilla;1E11
dcircle;24D3
dcircumflexbelow;1E13
dcroat;0111
ddabengali;09A1
ddadeva;0921
ddagujarati;0AA1
ddagurmukhi;0A21
ddalarabic;0688
ddalfinalarabic;FB89
dddhadeva;095C
ddhabengali;09A2
ddhadeva;0922
ddhagujarati;0AA2
ddhagurmukhi;0A22
ddotaccent;1E0B
ddotbelow;1E0D
decimalseparatorarabic;066B
decimalseparatorpersian;066B
decyrillic;0434
degree;00B0
dehihebrew;05AD
dehiragana;3067
deicoptic;03EF
dekatakana;30C7
deleteleft;232B
deleteright;2326
delta;03B4
deltaturned;018D
denominatorminusonenumeratorbengali;09F8
dezh;02A4
dhabengali;09A7
dhadeva;0927
dhagujarati;0AA7
dhagurmukhi;0A27
dhook;0257
dialytikatonos;0385
dialytikatonoscmb;0344
diamond;2666
diamondsuitwhite;2662
dieresis;00A8
dieresisacute;F6D7
dieresisbelowcmb;0324
dieresiscmb;0308
dieresisgrave;F6D8
dieresistonos;0385
dihiragana;3062
dikatakana;30C2
dittomark;3003
divide;00F7
divides;2223
divisionslash;2215
djecyrillic;0452
dkshade;2593
dlinebelow;1E0F
dlsquare;3397
dmacron;0111
dmonospace;FF44
dnblock;2584
dochadathai;0E0E
dodekthai;0E14
dohiragana;3069
dokatakana;30C9
dollar;0024
dollarinferior;F6E3
dollarmonospace;FF04
dollaroldstyle;F724
dollarsmall;FE69
dollarsuperior;F6E4
dong;20AB
dorusquare;3326
dotaccent;02D9
dotaccentcmb;0307
dotbelowcmb;0323
dotbelowcomb;0323
dotkatakana;30FB
dotlessi;0131
dotlessj;F6BE
dotlessjstrokehook;0284
dotmath;22C5
dottedcircle;25CC
doubleyodpatah;FB1F
doubleyodpatahhebrew;FB1F
downtackbelowcmb;031E
downtackmod;02D5
dparen;249F
dsuperior;F6EB
dtail;0256
dtopbar;018C
duhiragana;3065
dukatakana;30C5
dz;01F3
dzaltone;02A3
dzcaron;01C6
dzcurl;02A5
dzeabkhasiancyrillic;04E1
dzecyrillic;0455
dzhecyrillic;045F
e;0065
eacute;00E9
earth;2641
ebengali;098F
ebopomofo;311C
ebreve;0115
ecandradeva;090D
ecandragujarati;0A8D
ecandravowelsigndeva;0945
ecandravowelsigngujarati;0AC5
ecaron;011B
ecedillabreve;1E1D
echarmenian;0565
echyiwnarmenian;0587
ecircle;24D4
ecircumflex;00EA
ecircumflexacute;1EBF
ecircumflexbelow;1E19
ecircumflexdotbelow;1EC7
ecircumflexgrave;1EC1
ecircumflexhookabove;1EC3
ecircumflextilde;1EC5
ecyrillic;0454
edblgrave;0205
edeva;090F
edieresis;00EB
edot;0117
edotaccent;0117
edotbelow;1EB9
eegurmukhi;0A0F
eematragurmukhi;0A47
efcyrillic;0444
egrave;00E8
egujarati;0A8F
eharmenian;0567
ehbopomofo;311D
ehiragana;3048
ehookabove;1EBB
eibopomofo;311F
eight;0038
eightarabic;0668
eightbengali;09EE
eightcircle;2467
eightcircleinversesansserif;2791
eightdeva;096E
eighteencircle;2471
eighteenparen;2485
eighteenperiod;2499
eightgujarati;0AEE
eightgurmukhi;0A6E
eighthackarabic;0668
eighthangzhou;3028
eighthnotebeamed;266B
eightideographicparen;3227
eightinferior;2088
eightmonospace;FF18
eightoldstyle;F738
eightparen;247B
eightperiod;248F
eightpersian;06F8
eightroman;2177
eightsuperior;2078
eightthai;0E58
einvertedbreve;0207
eiotifiedcyrillic;0465
ekatakana;30A8
ekatakanahalfwidth;FF74
ekonkargurmukhi;0A74
ekorean;3154
elcyrillic;043B
element;2208
elevencircle;246A
elevenparen;247E
elevenperiod;2492
elevenroman;217A
ellipsis;2026
ellipsisvertical;22EE
emacron;0113
emacronacute;1E17
emacrongrave;1E15
emcyrillic;043C
emdash;2014
emdashvertical;FE31
emonospace;FF45
emphasismarkarmenian;055B
emptyset;2205
enbopomofo;3123
encyrillic;043D
endash;2013
endashvertical;FE32
endescendercyrillic;04A3
eng;014B
engbopomofo;3125
enghecyrillic;04A5
enhookcyrillic;04C8
enspace;2002
eogonek;0119
eokorean;3153
eopen;025B
eopenclosed;029A
eopenreversed;025C
eopenreversedclosed;025E
eopenreversedhook;025D
eparen;24A0
epsilon;03B5
epsilontonos;03AD
equal;003D
equalmonospace;FF1D
equalsmall;FE66
equalsuperior;207C
equivalence;2261
erbopomofo;3126
ercyrillic;0440
ereversed;0258
ereversedcyrillic;044D
escyrillic;0441
esdescendercyrillic;04AB
esh;0283
eshcurl;0286
eshortdeva;090E
eshortvowelsigndeva;0946
eshreversedloop;01AA
eshsquatreversed;0285
esmallhiragana;3047
esmallkatakana;30A7
esmallkatakanahalfwidth;FF6A
estimated;212E
esuperior;F6EC
eta;03B7
etarmenian;0568
etatonos;03AE
eth;00F0
etilde;1EBD
etildebelow;1E1B
etnahtafoukhhebrew;0591
etnahtafoukhlefthebrew;0591
etnahtahebrew;0591
etnahtalefthebrew;0591
eturned;01DD
eukorean;3161
euro;20AC
evowelsignbengali;09C7
evowelsigndeva;0947
evowelsigngujarati;0AC7
exclam;0021
exclamarmenian;055C
exclamdbl;203C
exclamdown;00A1
exclamdownsmall;F7A1
exclammonospace;FF01
exclamsmall;F721
existential;2203
ezh;0292
ezhcaron;01EF
ezhcurl;0293
ezhreversed;01B9
ezhtail;01BA
f;0066
fadeva;095E
fagurmukhi;0A5E
fahrenheit;2109
fathaarabic;064E
fathalowarabic;064E
fathatanarabic;064B
fbopomofo;3108
fcircle;24D5
fdotaccent;1E1F
feharabic;0641
feharmenian;0586
fehfinalarabic;FED2
fehinitialarabic;FED3
fehmedialarabic;FED4
feicoptic;03E5
female;2640
ff;FB00
ffi;FB03
ffl;FB04
fi;FB01
fifteencircle;246E
fifteenparen;2482
fifteenperiod;2496
figuredash;2012
filledbox;25A0
filledrect;25AC
finalkaf;05DA
finalkafdagesh;FB3A
finalkafdageshhebrew;FB3A
finalkafhebrew;05DA
finalkafqamats;05DA 05B8
finalkafqamatshebrew;05DA 05B8
finalkafsheva;05DA 05B0
finalkafshevahebrew;05DA 05B0
finalmem;05DD
finalmemhebrew;05DD
finalnun;05DF
finalnunhebrew;05DF
finalpe;05E3
finalpehebrew;05E3
finaltsadi;05E5
finaltsadihebrew;05E5
firsttonechinese;02C9
fisheye;25C9
fitacyrillic;0473
five;0035
fivearabic;0665
fivebengali;09EB
fivecircle;2464
fivecircleinversesansserif;278E
fivedeva;096B
fiveeighths;215D
fivegujarati;0AEB
fivegurmukhi;0A6B
fivehackarabic;0665
fivehangzhou;3025
fiveideographicparen;3224
fiveinferior;2085
fivemonospace;FF15
fiveoldstyle;F735
fiveparen;2478
fiveperiod;248C
fivepersian;06F5
fiveroman;2174
fivesuperior;2075
fivethai;0E55
fl;FB02
florin;0192
fmonospace;FF46
fmsquare;3399
fofanthai;0E1F
fofathai;0E1D
fongmanthai;0E4F
forall;2200
four;0034
fourarabic;0664
fourbengali;09EA
fourcircle;2463
fourcircleinversesansserif;278D
fourdeva;096A
fourgujarati;0AEA
fourgurmukhi;0A6A
fourhackarabic;0664
fourhangzhou;3024
fourideographicparen;3223
fourinferior;2084
fourmonospace;FF14
fournumeratorbengali;09F7
fouroldstyle;F734
fourparen;2477
fourperiod;248B
fourpersian;06F4
fourroman;2173
foursuperior;2074
fourteencircle;246D
fourteenparen;2481
fourteenperiod;2495
fourthai;0E54
fourthtonechinese;02CB
fparen;24A1
fraction;2044
franc;20A3
g;0067
gabengali;0997
gacute;01F5
gadeva;0917
gafarabic;06AF
gaffinalarabic;FB93
gafinitialarabic;FB94
gafmedialarabic;FB95
gagujarati;0A97
gagurmukhi;0A17
gahiragana;304C
gakatakana;30AC
gamma;03B3
gammalatinsmall;0263
gammasuperior;02E0
gangiacoptic;03EB
gbopomofo;310D
gbreve;011F
gcaron;01E7
gcedilla;0123
gcircle;24D6
gcircumflex;011D
gcommaaccent;0123
gdot;0121
gdotaccent;0121
gecyrillic;0433
gehiragana;3052
gekatakana;30B2
geometricallyequal;2251
gereshaccenthebrew;059C
gereshhebrew;05F3
gereshmuqdamhebrew;059D
germandbls;00DF
gershayimaccenthebrew;059E
gershayimhebrew;05F4
getamark;3013
ghabengali;0998
ghadarmenian;0572
ghadeva;0918
ghagujarati;0A98
ghagurmukhi;0A18
ghainarabic;063A
ghainfinalarabic;FECE
ghaininitialarabic;FECF
ghainmedialarabic;FED0
ghemiddlehookcyrillic;0495
ghestrokecyrillic;0493
gheupturncyrillic;0491
ghhadeva;095A
ghhagurmukhi;0A5A
ghook;0260
ghzsquare;3393
gihiragana;304E
gikatakana;30AE
gimarmenian;0563
gimel;05D2
gimeldagesh;FB32
gimeldageshhebrew;FB32
gimelhebrew;05D2
gjecyrillic;0453
glottalinvertedstroke;01BE
glottalstop;0294
glottalstopinverted;0296
glottalstopmod;02C0
glottalstopreversed;0295
glottalstopreversedmod;02C1
glottalstopreversedsuperior;02E4
glottalstopstroke;02A1
glottalstopstrokereversed;02A2
gmacron;1E21
gmonospace;FF47
gohiragana;3054
gokatakana;30B4
gparen;24A2
gpasquare;33AC
gradient;2207
grave;0060
gravebelowcmb;0316
gravecmb;0300
gravecomb;0300
gravedeva;0953
gravelowmod;02CE
gravemonospace;FF40
gravetonecmb;0340
greater;003E
greaterequal;2265
greaterequalorless;22DB
greatermonospace;FF1E
greaterorequivalent;2273
greaterorless;2277
greateroverequal;2267
greatersmall;FE65
gscript;0261
gstroke;01E5
guhiragana;3050
guillemotleft;00AB
guillemotright;00BB
guilsinglleft;2039
guilsinglright;203A
gukatakana;30B0
guramusquare;3318
gysquare;33C9
h;0068
haabkhasiancyrillic;04A9
haaltonearabic;06C1
habengali;09B9
hadescendercyrillic;04B3
hadeva;0939
hagujarati;0AB9
hagurmukhi;0A39
haharabic;062D
hahfinalarabic;FEA2
hahinitialarabic;FEA3
hahiragana;306F
hahmedialarabic;FEA4
haitusquare;332A
hakatakana;30CF
hakatakanahalfwidth;FF8A
halantgurmukhi;0A4D
hamzaarabic;0621
hamzadammaarabic;0621 064F
hamzadammatanarabic;0621 064C
hamzafathaarabic;0621 064E
hamzafathatanarabic;0621 064B
hamzalowarabic;0621
hamzalowkasraarabic;0621 0650
hamzalowkasratanarabic;0621 064D
hamzasukunarabic;0621 0652
hangulfiller;3164
hardsigncyrillic;044A
harpoonleftbarbup;21BC
harpoonrightbarbup;21C0
hasquare;33CA
hatafpatah;05B2
hatafpatah16;05B2
hatafpatah23;05B2
hatafpatah2f;05B2
hatafpatahhebrew;05B2
hatafpatahnarrowhebrew;05B2
hatafpatahquarterhebrew;05B2
hatafpatahwidehebrew;05B2
hatafqamats;05B3
hatafqamats1b;05B3
hatafqamats28;05B3
hatafqamats34;05B3
hatafqamatshebrew;05B3
hatafqamatsnarrowhebrew;05B3
hatafqamatsquarterhebrew;05B3
hatafqamatswidehebrew;05B3
hatafsegol;05B1
hatafsegol17;05B1
hatafsegol24;05B1
hatafsegol30;05B1
hatafsegolhebrew;05B1
hatafsegolnarrowhebrew;05B1
hatafsegolquarterhebrew;05B1
hatafsegolwidehebrew;05B1
hbar;0127
hbopomofo;310F
hbrevebelow;1E2B
hcedilla;1E29
hcircle;24D7
hcircumflex;0125
hdieresis;1E27
hdotaccent;1E23
hdotbelow;1E25
he;05D4
heart;2665
heartsuitblack;2665
heartsuitwhite;2661
hedagesh;FB34
hedageshhebrew;FB34
hehaltonearabic;06C1
heharabic;0647
hehebrew;05D4
hehfinalaltonearabic;FBA7
hehfinalalttwoarabic;FEEA
hehfinalarabic;FEEA
hehhamzaabovefinalarabic;FBA5
hehhamzaaboveisolatedarabic;FBA4
hehinitialaltonearabic;FBA8
hehinitialarabic;FEEB
hehiragana;3078
hehmedialaltonearabic;FBA9
hehmedialarabic;FEEC
heiseierasquare;337B
hekatakana;30D8
hekatakanahalfwidth;FF8D
hekutaarusquare;3336
henghook;0267
herutusquare;3339
het;05D7
hethebrew;05D7
hhook;0266
hhooksuperior;02B1
hieuhacirclekorean;327B
hieuhaparenkorean;321B
hieuhcirclekorean;326D
hieuhkorean;314E
hieuhparenkorean;320D
hihiragana;3072
hikatakana;30D2
hikatakanahalfwidth;FF8B
hiriq;05B4
hiriq14;05B4
hiriq21;05B4
hiriq2d;05B4
hiriqhebrew;05B4
hiriqnarrowhebrew;05B4
hiriqquarterhebrew;05B4
hiriqwidehebrew;05B4
hlinebelow;1E96
hmonospace;FF48
hoarmenian;0570
hohipthai;0E2B
hohiragana;307B
hokatakana;30DB
hokatakanahalfwidth;FF8E
holam;05B9
holam19;05B9
holam26;05B9
holam32;05B9
holamhebrew;05B9
holamnarrowhebrew;05B9
holamquarterhebrew;05B9
holamwidehebrew;05B9
honokhukthai;0E2E
hookabovecomb;0309
hookcmb;0309
hookpalatalizedbelowcmb;0321
hookretroflexbelowcmb;0322
hoonsquare;3342
horicoptic;03E9
horizontalbar;2015
horncmb;031B
hotsprings;2668
house;2302
hparen;24A3
hsuperior;02B0
hturned;0265
huhiragana;3075
huiitosquare;3333
hukatakana;30D5
hukatakanahalfwidth;FF8C
hungarumlaut;02DD
hungarumlautcmb;030B
hv;0195
hyphen;002D
hypheninferior;F6E5
hyphenmonospace;FF0D
hyphensmall;FE63
hyphensuperior;F6E6
hyphentwo;2010
i;0069
iacute;00ED
iacyrillic;044F
ibengali;0987
ibopomofo;3127
ibreve;012D
icaron;01D0
icircle;24D8
icircumflex;00EE
icyrillic;0456
idblgrave;0209
ideographearthcircle;328F
ideographfirecircle;328B
ideographicallianceparen;323F
ideographiccallparen;323A
ideographiccentrecircle;32A5
ideographicclose;3006
ideographiccomma;3001
ideographiccommaleft;FF64
ideographiccongratulationparen;3237
ideographiccorrectcircle;32A3
ideographicearthparen;322F
ideographicenterpriseparen;323D
ideographicexcellentcircle;329D
ideographicfestivalparen;3240
ideographicfinancialcircle;3296
ideographicfinancialparen;3236
ideographicfireparen;322B
ideographichaveparen;3232
ideographichighcircle;32A4
ideographiciterationmark;3005
ideographiclaborcircle;3298
ideographiclaborparen;3238
ideographicleftcircle;32A7
ideographiclowcircle;32A6
ideographicmedicinecircle;32A9
ideographicmetalparen;322E
ideographicmoonparen;322A
ideographicnameparen;3234
ideographicperiod;3002
ideographicprintcircle;329E
ideographicreachparen;3243
ideographicrepresentparen;3239
ideographicresourceparen;323E
ideographicrightcircle;32A8
ideographicsecretcircle;3299
ideographicselfparen;3242
ideographicsocietyparen;3233
ideographicspace;3000
ideographicspecialparen;3235
ideographicstockparen;3231
ideographicstudyparen;323B
ideographicsunparen;3230
ideographicsuperviseparen;323C
ideographicwaterparen;322C
ideographicwoodparen;322D
ideographiczero;3007
ideographmetalcircle;328E
ideographmooncircle;328A
ideographnamecircle;3294
ideographsuncircle;3290
ideographwatercircle;328C
ideographwoodcircle;328D
ideva;0907
idieresis;00EF
idieresisacute;1E2F
idieresiscyrillic;04E5
idotbelow;1ECB
iebrevecyrillic;04D7
iecyrillic;0435
ieungacirclekorean;3275
ieungaparenkorean;3215
ieungcirclekorean;3267
ieungkorean;3147
ieungparenkorean;3207
igrave;00EC
igujarati;0A87
igurmukhi;0A07
ihiragana;3044
ihookabove;1EC9
iibengali;0988
iicyrillic;0438
iideva;0908
iigujarati;0A88
iigurmukhi;0A08
iimatragurmukhi;0A40
iinvertedbreve;020B
iishortcyrillic;0439
iivowelsignbengali;09C0
iivowelsigndeva;0940
iivowelsigngujarati;0AC0
ij;0133
ikatakana;30A4
ikatakanahalfwidth;FF72
ikorean;3163
ilde;02DC
iluyhebrew;05AC
imacron;012B
imacroncyrillic;04E3
imageorapproximatelyequal;2253
imatragurmukhi;0A3F
imonospace;FF49
increment;2206
infinity;221E
iniarmenian;056B
integral;222B
integralbottom;2321
integralbt;2321
integralex;F8F5
integraltop;2320
integraltp;2320
intersection;2229
intisquare;3305
invbullet;25D8
invcircle;25D9
invsmileface;263B
iocyrillic;0451
iogonek;012F
iota;03B9
iotadieresis;03CA
iotadieresistonos;0390
iotalatin;0269
iotatonos;03AF
iparen;24A4
irigurmukhi;0A72
ismallhiragana;3043
ismallkatakana;30A3
ismallkatakanahalfwidth;FF68
issharbengali;09FA
istroke;0268
isuperior;F6ED
iterationhiragana;309D
iterationkatakana;30FD
itilde;0129
itildebelow;1E2D
iubopomofo;3129
iucyrillic;044E
ivowelsignbengali;09BF
ivowelsigndeva;093F
ivowelsigngujarati;0ABF
izhitsacyrillic;0475
izhitsadblgravecyrillic;0477
j;006A
jaarmenian;0571
jabengali;099C
jadeva;091C
jagujarati;0A9C
jagurmukhi;0A1C
jbopomofo;3110
jcaron;01F0
jcircle;24D9
jcircumflex;0135
jcrossedtail;029D
jdotlessstroke;025F
jecyrillic;0458
jeemarabic;062C
jeemfinalarabic;FE9E
jeeminitialarabic;FE9F
jeemmedialarabic;FEA0
jeharabic;0698
jehfinalarabic;FB8B
jhabengali;099D
jhadeva;091D
jhagujarati;0A9D
jhagurmukhi;0A1D
jheharmenian;057B
jis;3004
jmonospace;FF4A
jparen;24A5
jsuperior;02B2
k;006B
kabashkircyrillic;04A1
kabengali;0995
kacute;1E31
kacyrillic;043A
kadescendercyrillic;049B
kadeva;0915
kaf;05DB
kafarabic;0643
kafdagesh;FB3B
kafdageshhebrew;FB3B
kaffinalarabic;FEDA
kafhebrew;05DB
kafinitialarabic;FEDB
kafmedialarabic;FEDC
kafrafehebrew;FB4D
kagujarati;0A95
kagurmukhi;0A15
kahiragana;304B
kahookcyrillic;04C4
kakatakana;30AB
kakatakanahalfwidth;FF76
kappa;03BA
kappasymbolgreek;03F0
kapyeounmieumkorean;3171
kapyeounphieuphkorean;3184
kapyeounpieupkorean;3178
kapyeounssangpieupkorean;3179
karoriisquare;330D
kashidaautoarabic;0640
kashidaautonosidebearingarabic;0640
kasmallkatakana;30F5
kasquare;3384
kasraarabic;0650
kasratanarabic;064D
kastrokecyrillic;049F
katahiraprolongmarkhalfwidth;FF70
kaverticalstrokecyrillic;049D
kbopomofo;310E
kcalsquare;3389
kcaron;01E9
kcedilla;0137
kcircle;24DA
kcommaaccent;0137
kdotbelow;1E33
keharmenian;0584
kehiragana;3051
kekatakana;30B1
kekatakanahalfwidth;FF79
kenarmenian;056F
kesmallkatakana;30F6
kgreenlandic;0138
khabengali;0996
khacyrillic;0445
khadeva;0916
khagujarati;0A96
khagurmukhi;0A16
khaharabic;062E
khahfinalarabic;FEA6
khahinitialarabic;FEA7
khahmedialarabic;FEA8
kheicoptic;03E7
khhadeva;0959
khhagurmukhi;0A59
khieukhacirclekorean;3278
khieukhaparenkorean;3218
khieukhcirclekorean;326A
khieukhkorean;314B
khieukhparenkorean;320A
khokhaithai;0E02
khokhonthai;0E05
khokhuatthai;0E03
khokhwaithai;0E04
khomutthai;0E5B
khook;0199
khorakhangthai;0E06
khzsquare;3391
kihiragana;304D
kikatakana;30AD
kikatakanahalfwidth;FF77
kiroguramusquare;3315
kiromeetorusquare;3316
kirosquare;3314
kiyeokacirclekorean;326E
kiyeokaparenkorean;320E
kiyeokcirclekorean;3260
kiyeokkorean;3131
kiyeokparenkorean;3200
kiyeoksioskorean;3133
kjecyrillic;045C
klinebelow;1E35
klsquare;3398
kmcubedsquare;33A6
kmonospace;FF4B
kmsquaredsquare;33A2
kohiragana;3053
kohmsquare;33C0
kokaithai;0E01
kokatakana;30B3
kokatakanahalfwidth;FF7A
kooposquare;331E
koppacyrillic;0481
koreanstandardsymbol;327F
koroniscmb;0343
kparen;24A6
kpasquare;33AA
ksicyrillic;046F
ktsquare;33CF
kturned;029E
kuhiragana;304F
kukatakana;30AF
kukatakanahalfwidth;FF78
kvsquare;33B8
kwsquare;33BE
l;006C
labengali;09B2
lacute;013A
ladeva;0932
lagujarati;0AB2
lagurmukhi;0A32
lakkhangyaothai;0E45
lamaleffinalarabic;FEFC
lamalefhamzaabovefinalarabic;FEF8
lamalefhamzaaboveisolatedarabic;FEF7
lamalefhamzabelowfinalarabic;FEFA
lamalefhamzabelowisolatedarabic;FEF9
lamalefisolatedarabic;FEFB
lamalefmaddaabovefinalarabic;FEF6
lamalefmaddaaboveisolatedarabic;FEF5
lamarabic;0644
lambda;03BB
lambdastroke;019B
lamed;05DC
lameddagesh;FB3C
lameddageshhebrew;FB3C
lamedhebrew;05DC
lamedholam;05DC 05B9
lamedholamdagesh;05DC 05B9 05BC
lamedholamdageshhebrew;05DC 05B9 05BC
lamedholamhebrew;05DC 05B9
lamfinalarabic;FEDE
lamhahinitialarabic;FCCA
laminitialarabic;FEDF
lamjeeminitialarabic;FCC9
lamkhahinitialarabic;FCCB
lamlamhehisolatedarabic;FDF2
lammedialarabic;FEE0
lammeemhahinitialarabic;FD88
lammeeminitialarabic;FCCC
lammeemjeeminitialarabic;FEDF FEE4 FEA0
lammeemkhahinitialarabic;FEDF FEE4 FEA8
largecircle;25EF
lbar;019A
lbelt;026C
lbopomofo;310C
lcaron;013E
lcedilla;013C
lcircle;24DB
lcircumflexbelow;1E3D
lcommaaccent;013C
ldot;0140
ldotaccent;0140
ldotbelow;1E37
ldotbelowmacron;1E39
leftangleabovecmb;031A
lefttackbelowcmb;0318
less;003C
lessequal;2264
lessequalorgreater;22DA
lessmonospace;FF1C
lessorequivalent;2272
lessorgreater;2276
lessoverequal;2266
lesssmall;FE64
lezh;026E
lfblock;258C
lhookretroflex;026D
lira;20A4
liwnarmenian;056C
lj;01C9
ljecyrillic;0459
ll;F6C0
lladeva;0933
llagujarati;0AB3
llinebelow;1E3B
llladeva;0934
llvocalicbengali;09E1
llvocalicdeva;0961
llvocalicvowelsignbengali;09E3
llvocalicvowelsigndeva;0963
lmiddletilde;026B
lmonospace;FF4C
lmsquare;33D0
lochulathai;0E2C
logicaland;2227
logicalnot;00AC
logicalnotreversed;2310
logicalor;2228
lolingthai;0E25
longs;017F
lowlinecenterline;FE4E
lowlinecmb;0332
lowlinedashed;FE4D
lozenge;25CA
lparen;24A7
lslash;0142
lsquare;2113
lsuperior;F6EE
ltshade;2591
luthai;0E26
lvocalicbengali;098C
lvocalicdeva;090C
lvocalicvowelsignbengali;09E2
lvocalicvowelsigndeva;0962
lxsquare;33D3
m;006D
mabengali;09AE
macron;00AF
macronbelowcmb;0331
macroncmb;0304
macronlowmod;02CD
macronmonospace;FFE3
macute;1E3F
madeva;092E
magujarati;0AAE
magurmukhi;0A2E
mahapakhhebrew;05A4
mahapakhlefthebrew;05A4
mahiragana;307E
maichattawalowleftthai;F895
maichattawalowrightthai;F894
maichattawathai;0E4B
maichattawaupperleftthai;F893
maieklowleftthai;F88C
maieklowrightthai;F88B
maiekthai;0E48
maiekupperleftthai;F88A
maihanakatleftthai;F884
maihanakatthai;0E31
maitaikhuleftthai;F889
maitaikhuthai;0E47
maitholowleftthai;F88F
maitholowrightthai;F88E
maithothai;0E49
maithoupperleftthai;F88D
maitrilowleftthai;F892
maitrilowrightthai;F891
maitrithai;0E4A
maitriupperleftthai;F890
maiyamokthai;0E46
makatakana;30DE
makatakanahalfwidth;FF8F
male;2642
mansyonsquare;3347
maqafhebrew;05BE
mars;2642
masoracirclehebrew;05AF
masquare;3383
mbopomofo;3107
mbsquare;33D4
mcircle;24DC
mcubedsquare;33A5
mdotaccent;1E41
mdotbelow;1E43
meemarabic;0645
meemfinalarabic;FEE2
meeminitialarabic;FEE3
meemmedialarabic;FEE4
meemmeeminitialarabic;FCD1
meemmeemisolatedarabic;FC48
meetorusquare;334D
mehiragana;3081
meizierasquare;337E
mekatakana;30E1
mekatakanahalfwidth;FF92
mem;05DE
memdagesh;FB3E
memdageshhebrew;FB3E
memhebrew;05DE
menarmenian;0574
merkhahebrew;05A5
merkhakefulahebrew;05A6
merkhakefulalefthebrew;05A6
merkhalefthebrew;05A5
mhook;0271
mhzsquare;3392
middledotkatakanahalfwidth;FF65
middot;00B7
mieumacirclekorean;3272
mieumaparenkorean;3212
mieumcirclekorean;3264
mieumkorean;3141
mieumpansioskorean;3170
mieumparenkorean;3204
mieumpieupkorean;316E
mieumsioskorean;316F
mihiragana;307F
mikatakana;30DF
mikatakanahalfwidth;FF90
minus;2212
minusbelowcmb;0320
minuscircle;2296
minusmod;02D7
minusplus;2213
minute;2032
miribaarusquare;334A
mirisquare;3349
mlonglegturned;0270
mlsquare;3396
mmcubedsquare;33A3
mmonospace;FF4D
mmsquaredsquare;339F
mohiragana;3082
mohmsquare;33C1
mokatakana;30E2
mokatakanahalfwidth;FF93
molsquare;33D6
momathai;0E21
moverssquare;33A7
moverssquaredsquare;33A8
mparen;24A8
mpasquare;33AB
mssquare;33B3
msuperior;F6EF
mturned;026F
mu;00B5
mu1;00B5
muasquare;3382
muchgreater;226B
muchless;226A
mufsquare;338C
mugreek;03BC
mugsquare;338D
muhiragana;3080
mukatakana;30E0
mukatakanahalfwidth;FF91
mulsquare;3395
multiply;00D7
mumsquare;339B
munahhebrew;05A3
munahlefthebrew;05A3
musicalnote;266A
musicalnotedbl;266B
musicflatsign;266D
musicsharpsign;266F
mussquare;33B2
muvsquare;33B6
muwsquare;33BC
mvmegasquare;33B9
mvsquare;33B7
mwmegasquare;33BF
mwsquare;33BD
n;006E
nabengali;09A8
nabla;2207
nacute;0144
nadeva;0928
nagujarati;0AA8
nagurmukhi;0A28
nahiragana;306A
nakatakana;30CA
nakatakanahalfwidth;FF85
napostrophe;0149
nasquare;3381
nbopomofo;310B
nbspace;00A0
ncaron;0148
ncedilla;0146
ncircle;24DD
ncircumflexbelow;1E4B
ncommaaccent;0146
ndotaccent;1E45
ndotbelow;1E47
nehiragana;306D
nekatakana;30CD
nekatakanahalfwidth;FF88
newsheqelsign;20AA
nfsquare;338B
ngabengali;0999
ngadeva;0919
ngagujarati;0A99
ngagurmukhi;0A19
ngonguthai;0E07
nhiragana;3093
nhookleft;0272
nhookretroflex;0273
nieunacirclekorean;326F
nieunaparenkorean;320F
nieuncieuckorean;3135
nieuncirclekorean;3261
nieunhieuhkorean;3136
nieunkorean;3134
nieunpansioskorean;3168
nieunparenkorean;3201
nieunsioskorean;3167
nieuntikeutkorean;3166
nihiragana;306B
nikatakana;30CB
nikatakanahalfwidth;FF86
nikhahitleftthai;F899
nikhahitthai;0E4D
nine;0039
ninearabic;0669
ninebengali;09EF
ninecircle;2468
ninecircleinversesansserif;2792
ninedeva;096F
ninegujarati;0AEF
ninegurmukhi;0A6F
ninehackarabic;0669
ninehangzhou;3029
nineideographicparen;3228
nineinferior;2089
ninemonospace;FF19
nineoldstyle;F739
nineparen;247C
nineperiod;2490
ninepersian;06F9
nineroman;2178
ninesuperior;2079
nineteencircle;2472
nineteenparen;2486
nineteenperiod;249A
ninethai;0E59
nj;01CC
njecyrillic;045A
nkatakana;30F3
nkatakanahalfwidth;FF9D
nlegrightlong;019E
nlinebelow;1E49
nmonospace;FF4E
nmsquare;339A
nnabengali;09A3
nnadeva;0923
nnagujarati;0AA3
nnagurmukhi;0A23
nnnadeva;0929
nohiragana;306E
nokatakana;30CE
nokatakanahalfwidth;FF89
nonbreakingspace;00A0
nonenthai;0E13
nonuthai;0E19
noonarabic;0646
noonfinalarabic;FEE6
noonghunnaarabic;06BA
noonghunnafinalarabic;FB9F
noonhehinitialarabic;FEE7 FEEC
nooninitialarabic;FEE7
noonjeeminitialarabic;FCD2
noonjeemisolatedarabic;FC4B
noonmedialarabic;FEE8
noonmeeminitialarabic;FCD5
noonmeemisolatedarabic;FC4E
noonnoonfinalarabic;FC8D
notcontains;220C
notelement;2209
notelementof;2209
notequal;2260
notgreater;226F
notgreaternorequal;2271
notgreaternorless;2279
notidentical;2262
notless;226E
notlessnorequal;2270
notparallel;2226
notprecedes;2280
notsubset;2284
notsucceeds;2281
notsuperset;2285
nowarmenian;0576
nparen;24A9
nssquare;33B1
nsuperior;207F
ntilde;00F1
nu;03BD
nuhiragana;306C
nukatakana;30CC
nukatakanahalfwidth;FF87
nuktabengali;09BC
nuktadeva;093C
nuktagujarati;0ABC
nuktagurmukhi;0A3C
numbersign;0023
numbersignmonospace;FF03
numbersignsmall;FE5F
numeralsigngreek;0374
numeralsignlowergreek;0375
numero;2116
nun;05E0
nundagesh;FB40
nundageshhebrew;FB40
nunhebrew;05E0
nvsquare;33B5
nwsquare;33BB
nyabengali;099E
nyadeva;091E
nyagujarati;0A9E
nyagurmukhi;0A1E
o;006F
oacute;00F3
oangthai;0E2D
obarred;0275
obarredcyrillic;04E9
obarreddieresiscyrillic;04EB
obengali;0993
obopomofo;311B
obreve;014F
ocandradeva;0911
ocandragujarati;0A91
ocandravowelsigndeva;0949
ocandravowelsigngujarati;0AC9
ocaron;01D2
ocircle;24DE
ocircumflex;00F4
ocircumflexacute;1ED1
ocircumflexdotbelow;1ED9
ocircumflexgrave;1ED3
ocircumflexhookabove;1ED5
ocircumflextilde;1ED7
ocyrillic;043E
odblacute;0151
odblgrave;020D
odeva;0913
odieresis;00F6
odieresiscyrillic;04E7
odotbelow;1ECD
oe;0153
oekorean;315A
ogonek;02DB
ogonekcmb;0328
ograve;00F2
ogujarati;0A93
oharmenian;0585
ohiragana;304A
ohookabove;1ECF
ohorn;01A1
ohornacute;1EDB
ohorndotbelow;1EE3
ohorngrave;1EDD
ohornhookabove;1EDF
ohorntilde;1EE1
ohungarumlaut;0151
oi;01A3
oinvertedbreve;020F
okatakana;30AA
okatakanahalfwidth;FF75
okorean;3157
olehebrew;05AB
omacron;014D
omacronacute;1E53
omacrongrave;1E51
omdeva;0950
omega;03C9
omega1;03D6
omegacyrillic;0461
omegalatinclosed;0277
omegaroundcyrillic;047B
omegatitlocyrillic;047D
omegatonos;03CE
omgujarati;0AD0
omicron;03BF
omicrontonos;03CC
omonospace;FF4F
one;0031
onearabic;0661
onebengali;09E7
onecircle;2460
onecircleinversesansserif;278A
onedeva;0967
onedotenleader;2024
oneeighth;215B
onefitted;F6DC
onegujarati;0AE7
onegurmukhi;0A67
onehackarabic;0661
onehalf;00BD
onehangzhou;3021
oneideographicparen;3220
oneinferior;2081
onemonospace;FF11
onenumeratorbengali;09F4
oneoldstyle;F731
oneparen;2474
oneperiod;2488
onepersian;06F1
onequarter;00BC
oneroman;2170
onesuperior;00B9
onethai;0E51
onethird;2153
oogonek;01EB
oogonekmacron;01ED
oogurmukhi;0A13
oomatragurmukhi;0A4B
oopen;0254
oparen;24AA
openbullet;25E6
option;2325
ordfeminine;00AA
ordmasculine;00BA
orthogonal;221F
oshortdeva;0912
oshortvowelsigndeva;094A
oslash;00F8
oslashacute;01FF
osmallhiragana;3049
osmallkatakana;30A9
osmallkatakanahalfwidth;FF6B
ostrokeacute;01FF
osuperior;F6F0
otcyrillic;047F
otilde;00F5
otildeacute;1E4D
otildedieresis;1E4F
oubopomofo;3121
overline;203E
overlinecenterline;FE4A
overlinecmb;0305
overlinedashed;FE49
overlinedblwavy;FE4C
overlinewavy;FE4B
overscore;00AF
ovowelsignbengali;09CB
ovowelsigndeva;094B
ovowelsigngujarati;0ACB
p;0070
paampssquare;3380
paasentosquare;332B
pabengali;09AA
pacute;1E55
padeva;092A
pagedown;21DF
pageup;21DE
pagujarati;0AAA
pagurmukhi;0A2A
pahiragana;3071
paiyannoithai;0E2F
pakatakana;30D1
palatalizationcyrilliccmb;0484
palochkacyrillic;04C0
pansioskorean;317F
paragraph;00B6
parallel;2225
parenleft;0028
parenleftaltonearabic;FD3E
parenleftbt;F8ED
parenleftex;F8EC
parenleftinferior;208D
parenleftmonospace;FF08
parenleftsmall;FE59
parenleftsuperior;207D
parenlefttp;F8EB
parenleftvertical;FE35
parenright;0029
parenrightaltonearabic;FD3F
parenrightbt;F8F8
parenrightex;F8F7
parenrightinferior;208E
parenrightmonospace;FF09
parenrightsmall;FE5A
parenrightsuperior;207E
parenrighttp;F8F6
parenrightvertical;FE36
partialdiff;2202
paseqhebrew;05C0
pashtahebrew;0599
pasquare;33A9
patah;05B7
patah11;05B7
patah1d;05B7
patah2a;05B7
patahhebrew;05B7
patahnarrowhebrew;05B7
patahquarterhebrew;05B7
patahwidehebrew;05B7
pazerhebrew;05A1
pbopomofo;3106
pcircle;24DF
pdotaccent;1E57
pe;05E4
pecyrillic;043F
pedagesh;FB44
pedageshhebrew;FB44
peezisquare;333B
pefinaldageshhebrew;FB43
peharabic;067E
peharmenian;057A
pehebrew;05E4
pehfinalarabic;FB57
pehinitialarabic;FB58
pehiragana;307A
pehmedialarabic;FB59
pekatakana;30DA
pemiddlehookcyrillic;04A7
perafehebrew;FB4E
percent;0025
percentarabic;066A
percentmonospace;FF05
percentsmall;FE6A
period;002E
periodarmenian;0589
periodcentered;00B7
periodhalfwidth;FF61
periodinferior;F6E7
periodmonospace;FF0E
periodsmall;FE52
periodsuperior;F6E8
perispomenigreekcmb;0342
perpendicular;22A5
perthousand;2030
peseta;20A7
pfsquare;338A
phabengali;09AB
phadeva;092B
phagujarati;0AAB
phagurmukhi;0A2B
phi;03C6
phi1;03D5
phieuphacirclekorean;327A
phieuphaparenkorean;321A
phieuphcirclekorean;326C
phieuphkorean;314D
phieuphparenkorean;320C
philatin;0278
phinthuthai;0E3A
phisymbolgreek;03D5
phook;01A5
phophanthai;0E1E
phophungthai;0E1C
phosamphaothai;0E20
pi;03C0
pieupacirclekorean;3273
pieupaparenkorean;3213
pieupcieuckorean;3176
pieupcirclekorean;3265
pieupkiyeokkorean;3172
pieupkorean;3142
pieupparenkorean;3205
pieupsioskiyeokkorean;3174
pieupsioskorean;3144
pieupsiostikeutkorean;3175
pieupthieuthkorean;3177
pieuptikeutkorean;3173
pihiragana;3074
pikatakana;30D4
pisymbolgreek;03D6
piwrarmenian;0583
plus;002B
plusbelowcmb;031F
pluscircle;2295
plusminus;00B1
plusmod;02D6
plusmonospace;FF0B
plussmall;FE62
plussuperior;207A
pmonospace;FF50
pmsquare;33D8
pohiragana;307D
pointingindexdownwhite;261F
pointingindexleftwhite;261C
pointingindexrightwhite;261E
pointingindexupwhite;261D
pokatakana;30DD
poplathai;0E1B
postalmark;3012
postalmarkface;3020
pparen;24AB
precedes;227A
prescription;211E
primemod;02B9
primereversed;2035
product;220F
projective;2305
prolongedkana;30FC
propellor;2318
propersubset;2282
propersuperset;2283
proportion;2237
proportional;221D
psi;03C8
psicyrillic;0471
psilipneumatacyrilliccmb;0486
pssquare;33B0
puhiragana;3077
pukatakana;30D7
pvsquare;33B4
pwsquare;33BA
q;0071
qadeva;0958
qadmahebrew;05A8
qafarabic;0642
qaffinalarabic;FED6
qafinitialarabic;FED7
qafmedialarabic;FED8
qamats;05B8
qamats10;05B8
qamats1a;05B8
qamats1c;05B8
qamats27;05B8
qamats29;05B8
qamats33;05B8
qamatsde;05B8
qamatshebrew;05B8
qamatsnarrowhebrew;05B8
qamatsqatanhebrew;05B8
qamatsqatannarrowhebrew;05B8
qamatsqatanquarterhebrew;05B8
qamatsqatanwidehebrew;05B8
qamatsquarterhebrew;05B8
qamatswidehebrew;05B8
qarneyparahebrew;059F
qbopomofo;3111
qcircle;24E0
qhook;02A0
qmonospace;FF51
qof;05E7
qofdagesh;FB47
qofdageshhebrew;FB47
qofhatafpatah;05E7 05B2
qofhatafpatahhebrew;05E7 05B2
qofhatafsegol;05E7 05B1
qofhatafsegolhebrew;05E7 05B1
qofhebrew;05E7
qofhiriq;05E7 05B4
qofhiriqhebrew;05E7 05B4
qofholam;05E7 05B9
qofholamhebrew;05E7 05B9
qofpatah;05E7 05B7
qofpatahhebrew;05E7 05B7
qofqamats;05E7 05B8
qofqamatshebrew;05E7 05B8
qofqubuts;05E7 05BB
qofqubutshebrew;05E7 05BB
qofsegol;05E7 05B6
qofsegolhebrew;05E7 05B6
qofsheva;05E7 05B0
qofshevahebrew;05E7 05B0
qoftsere;05E7 05B5
qoftserehebrew;05E7 05B5
qparen;24AC
quarternote;2669
qubuts;05BB
qubuts18;05BB
qubuts25;05BB
qubuts31;05BB
qubutshebrew;05BB
qubutsnarrowhebrew;05BB
qubutsquarterhebrew;05BB
qubutswidehebrew;05BB
question;003F
questionarabic;061F
questionarmenian;055E
questiondown;00BF
questiondownsmall;F7BF
questiongreek;037E
questionmonospace;FF1F
questionsmall;F73F
quotedbl;0022
quotedblbase;201E
quotedblleft;201C
quotedblmonospace;FF02
quotedblprime;301E
quotedblprimereversed;301D
quotedblright;201D
quoteleft;2018
quoteleftreversed;201B
quotereversed;201B
quoteright;2019
quoterightn;0149
quotesinglbase;201A
quotesingle;0027
quotesinglemonospace;FF07
r;0072
raarmenian;057C
rabengali;09B0
racute;0155
radeva;0930
radical;221A
radicalex;F8E5
radoverssquare;33AE
radoverssquaredsquare;33AF
radsquare;33AD
rafe;05BF
rafehebrew;05BF
ragujarati;0AB0
ragurmukhi;0A30
rahiragana;3089
rakatakana;30E9
rakatakanahalfwidth;FF97
ralowerdiagonalbengali;09F1
ramiddlediagonalbengali;09F0
ramshorn;0264
ratio;2236
rbopomofo;3116
rcaron;0159
rcedilla;0157
rcircle;24E1
rcommaaccent;0157
rdblgrave;0211
rdotaccent;1E59
rdotbelow;1E5B
rdotbelowmacron;1E5D
referencemark;203B
reflexsubset;2286
reflexsuperset;2287
registered;00AE
registersans;F8E8
registerserif;F6DA
reharabic;0631
reharmenian;0580
rehfinalarabic;FEAE
rehiragana;308C
rehyehaleflamarabic;0631 FEF3 FE8E 0644
rekatakana;30EC
rekatakanahalfwidth;FF9A
resh;05E8
reshdageshhebrew;FB48
reshhatafpatah;05E8 05B2
reshhatafpatahhebrew;05E8 05B2
reshhatafsegol;05E8 05B1
reshhatafsegolhebrew;05E8 05B1
reshhebrew;05E8
reshhiriq;05E8 05B4
reshhiriqhebrew;05E8 05B4
reshholam;05E8 05B9
reshholamhebrew;05E8 05B9
reshpatah;05E8 05B7
reshpatahhebrew;05E8 05B7
reshqamats;05E8 05B8
reshqamatshebrew;05E8 05B8
reshqubuts;05E8 05BB
reshqubutshebrew;05E8 05BB
reshsegol;05E8 05B6
reshsegolhebrew;05E8 05B6
reshsheva;05E8 05B0
reshshevahebrew;05E8 05B0
reshtsere;05E8 05B5
reshtserehebrew;05E8 05B5
reversedtilde;223D
reviahebrew;0597
reviamugrashhebrew;0597
revlogicalnot;2310
rfishhook;027E
rfishhookreversed;027F
rhabengali;09DD
rhadeva;095D
rho;03C1
rhook;027D
rhookturned;027B
rhookturnedsuperior;02B5
rhosymbolgreek;03F1
rhotichookmod;02DE
rieulacirclekorean;3271
rieulaparenkorean;3211
rieulcirclekorean;3263
rieulhieuhkorean;3140
rieulkiyeokkorean;313A
rieulkiyeoksioskorean;3169
rieulkorean;3139
rieulmieumkorean;313B
rieulpansioskorean;316C
rieulparenkorean;3203
rieulphieuphkorean;313F
rieulpieupkorean;313C
rieulpieupsioskorean;316B
rieulsioskorean;313D
rieulthieuthkorean;313E
rieultikeutkorean;316A
rieulyeorinhieuhkorean;316D
rightangle;221F
righttackbelowcmb;0319
righttriangle;22BF
rihiragana;308A
rikatakana;30EA
rikatakanahalfwidth;FF98
ring;02DA
ringbelowcmb;0325
ringcmb;030A
ringhalfleft;02BF
ringhalfleftarmenian;0559
ringhalfleftbelowcmb;031C
ringhalfleftcentered;02D3
ringhalfright;02BE
ringhalfrightbelowcmb;0339
ringhalfrightcentered;02D2
rinvertedbreve;0213
rittorusquare;3351
rlinebelow;1E5F
rlongleg;027C
rlonglegturned;027A
rmonospace;FF52
rohiragana;308D
rokatakana;30ED
rokatakanahalfwidth;FF9B
roruathai;0E23
rparen;24AD
rrabengali;09DC
rradeva;0931
rragurmukhi;0A5C
rreharabic;0691
rrehfinalarabic;FB8D
rrvocalicbengali;09E0
rrvocalicdeva;0960
rrvocalicgujarati;0AE0
rrvocalicvowelsignbengali;09C4
rrvocalicvowelsigndeva;0944
rrvocalicvowelsigngujarati;0AC4
rsuperior;F6F1
rtblock;2590
rturned;0279
rturnedsuperior;02B4
ruhiragana;308B
rukatakana;30EB
rukatakanahalfwidth;FF99
rupeemarkbengali;09F2
rupeesignbengali;09F3
rupiah;F6DD
ruthai;0E24
rvocalicbengali;098B
rvocalicdeva;090B
rvocalicgujarati;0A8B
rvocalicvowelsignbengali;09C3
rvocalicvowelsigndeva;0943
rvocalicvowelsigngujarati;0AC3
s;0073
sabengali;09B8
sacute;015B
sacutedotaccent;1E65
sadarabic;0635
sadeva;0938
sadfinalarabic;FEBA
sadinitialarabic;FEBB
sadmedialarabic;FEBC
sagujarati;0AB8
sagurmukhi;0A38
sahiragana;3055
sakatakana;30B5
sakatakanahalfwidth;FF7B
sallallahoualayhewasallamarabic;FDFA
samekh;05E1
samekhdagesh;FB41
samekhdageshhebrew;FB41
samekhhebrew;05E1
saraaathai;0E32
saraaethai;0E41
saraaimaimalaithai;0E44
saraaimaimuanthai;0E43
saraamthai;0E33
saraathai;0E30
saraethai;0E40
saraiileftthai;F886
saraiithai;0E35
saraileftthai;F885
saraithai;0E34
saraothai;0E42
saraueeleftthai;F888
saraueethai;0E37
saraueleftthai;F887
sarauethai;0E36
sarauthai;0E38
sarauuthai;0E39
sbopomofo;3119
scaron;0161
scarondotaccent;1E67
scedilla;015F
schwa;0259
schwacyrillic;04D9
schwadieresiscyrillic;04DB
schwahook;025A
scircle;24E2
scircumflex;015D
scommaaccent;0219
sdotaccent;1E61
sdotbelow;1E63
sdotbelowdotaccent;1E69
seagullbelowcmb;033C
second;2033
secondtonechinese;02CA
section;00A7
seenarabic;0633
seenfinalarabic;FEB2
seeninitialarabic;FEB3
seenmedialarabic;FEB4
segol;05B6
segol13;05B6
segol1f;05B6
segol2c;05B6
segolhebrew;05B6
segolnarrowhebrew;05B6
segolquarterhebrew;05B6
segoltahebrew;0592
segolwidehebrew;05B6
seharmenian;057D
sehiragana;305B
sekatakana;30BB
sekatakanahalfwidth;FF7E
semicolon;003B
semicolonarabic;061B
semicolonmonospace;FF1B
semicolonsmall;FE54
semivoicedmarkkana;309C
semivoicedmarkkanahalfwidth;FF9F
sentisquare;3322
sentosquare;3323
seven;0037
sevenarabic;0667
sevenbengali;09ED
sevencircle;2466
sevencircleinversesansserif;2790
sevendeva;096D
seveneighths;215E
sevengujarati;0AED
sevengurmukhi;0A6D
sevenhackarabic;0667
sevenhangzhou;3027
sevenideographicparen;3226
seveninferior;2087
sevenmonospace;FF17
sevenoldstyle;F737
sevenparen;247A
sevenperiod;248E
sevenpersian;06F7
sevenroman;2176
sevensuperior;2077
seventeencircle;2470
seventeenparen;2484
seventeenperiod;2498
seventhai;0E57
sfthyphen;00AD
shaarmenian;0577
shabengali;09B6
shacyrillic;0448
shaddaarabic;0651
shaddadammaarabic;FC61
shaddadammatanarabic;FC5E
shaddafathaarabic;FC60
shaddafathatanarabic;0651 064B
shaddakasraarabic;FC62
shaddakasratanarabic;FC5F
shade;2592
shadedark;2593
shadelight;2591
shademedium;2592
shadeva;0936
shagujarati;0AB6
shagurmukhi;0A36
shalshelethebrew;0593
shbopomofo;3115
shchacyrillic;0449
sheenarabic;0634
sheenfinalarabic;FEB6
sheeninitialarabic;FEB7
sheenmedialarabic;FEB8
sheicoptic;03E3
sheqel;20AA
sheqelhebrew;20AA
sheva;05B0
sheva115;05B0
sheva15;05B0
sheva22;05B0
sheva2e;05B0
shevahebrew;05B0
shevanarrowhebrew;05B0
shevaquarterhebrew;05B0
shevawidehebrew;05B0
shhacyrillic;04BB
shimacoptic;03ED
shin;05E9
shindagesh;FB49
shindageshhebrew;FB49
shindageshshindot;FB2C
shindageshshindothebrew;FB2C
shindageshsindot;FB2D
shindageshsindothebrew;FB2D
shindothebrew;05C1
shinhebrew;05E9
shinshindot;FB2A
shinshindothebrew;FB2A
shinsindot;FB2B
shinsindothebrew;FB2B
shook;0282
sigma;03C3
sigma1;03C2
sigmafinal;03C2
sigmalunatesymbolgreek;03F2
sihiragana;3057
sikatakana;30B7
sikatakanahalfwidth;FF7C
siluqhebrew;05BD
siluqlefthebrew;05BD
similar;223C
sindothebrew;05C2
siosacirclekorean;3274
siosaparenkorean;3214
sioscieuckorean;317E
sioscirclekorean;3266
sioskiyeokkorean;317A
sioskorean;3145
siosnieunkorean;317B
siosparenkorean;3206
siospieupkorean;317D
siostikeutkorean;317C
six;0036
sixarabic;0666
sixbengali;09EC
sixcircle;2465
sixcircleinversesansserif;278F
sixdeva;096C
sixgujarati;0AEC
sixgurmukhi;0A6C
sixhackarabic;0666
sixhangzhou;3026
sixideographicparen;3225
sixinferior;2086
sixmonospace;FF16
sixoldstyle;F736
sixparen;2479
sixperiod;248D
sixpersian;06F6
sixroman;2175
sixsuperior;2076
sixteencircle;246F
sixteencurrencydenominatorbengali;09F9
sixteenparen;2483
sixteenperiod;2497
sixthai;0E56
slash;002F
slashmonospace;FF0F
slong;017F
slongdotaccent;1E9B
smileface;263A
smonospace;FF53
sofpasuqhebrew;05C3
softhyphen;00AD
softsigncyrillic;044C
sohiragana;305D
sokatakana;30BD
sokatakanahalfwidth;FF7F
soliduslongoverlaycmb;0338
solidusshortoverlaycmb;0337
sorusithai;0E29
sosalathai;0E28
sosothai;0E0B
sosuathai;0E2A
space;0020
spacehackarabic;0020
spade;2660
spadesuitblack;2660
spadesuitwhite;2664
sparen;24AE
squarebelowcmb;033B
squarecc;33C4
squarecm;339D
squarediagonalcrosshatchfill;25A9
squarehorizontalfill;25A4
squarekg;338F
squarekm;339E
squarekmcapital;33CE
squareln;33D1
squarelog;33D2
squaremg;338E
squaremil;33D5
squaremm;339C
squaremsquared;33A1
squareorthogonalcrosshatchfill;25A6
squareupperlefttolowerrightfill;25A7
squareupperrighttolowerleftfill;25A8
squareverticalfill;25A5
squarewhitewithsmallblack;25A3
srsquare;33DB
ssabengali;09B7
ssadeva;0937
ssagujarati;0AB7
ssangcieuckorean;3149
ssanghieuhkorean;3185
ssangieungkorean;3180
ssangkiyeokkorean;3132
ssangnieunkorean;3165
ssangpieupkorean;3143
ssangsioskorean;3146
ssangtikeutkorean;3138
ssuperior;F6F2
sterling;00A3
sterlingmonospace;FFE1
strokelongoverlaycmb;0336
strokeshortoverlaycmb;0335
subset;2282
subsetnotequal;228A
subsetorequal;2286
succeeds;227B
suchthat;220B
suhiragana;3059
sukatakana;30B9
sukatakanahalfwidth;FF7D
sukunarabic;0652
summation;2211
sun;263C
superset;2283
supersetnotequal;228B
supersetorequal;2287
svsquare;33DC
syouwaerasquare;337C
t;0074
tabengali;09A4
tackdown;22A4
tackleft;22A3
tadeva;0924
tagujarati;0AA4
tagurmukhi;0A24
taharabic;0637
tahfinalarabic;FEC2
tahinitialarabic;FEC3
tahiragana;305F
tahmedialarabic;FEC4
taisyouerasquare;337D
takatakana;30BF
takatakanahalfwidth;FF80
tatweelarabic;0640
tau;03C4
tav;05EA
tavdages;FB4A
tavdagesh;FB4A
tavdageshhebrew;FB4A
tavhebrew;05EA
tbar;0167
tbopomofo;310A
tcaron;0165
tccurl;02A8
tcedilla;0163
tcheharabic;0686
tchehfinalarabic;FB7B
tchehinitialarabic;FB7C
tchehmedialarabic;FB7D
tchehmeeminitialarabic;FB7C FEE4
tcircle;24E3
tcircumflexbelow;1E71
tcommaaccent;0163
tdieresis;1E97
tdotaccent;1E6B
tdotbelow;1E6D
tecyrillic;0442
tedescendercyrillic;04AD
teharabic;062A
tehfinalarabic;FE96
tehhahinitialarabic;FCA2
tehhahisolatedarabic;FC0C
tehinitialarabic;FE97
tehiragana;3066
tehjeeminitialarabic;FCA1
tehjeemisolatedarabic;FC0B
tehmarbutaarabic;0629
tehmarbutafinalarabic;FE94
tehmedialarabic;FE98
tehmeeminitialarabic;FCA4
tehmeemisolatedarabic;FC0E
tehnoonfinalarabic;FC73
tekatakana;30C6
tekatakanahalfwidth;FF83
telephone;2121
telephoneblack;260E
telishagedolahebrew;05A0
telishaqetanahebrew;05A9
tencircle;2469
tenideographicparen;3229
tenparen;247D
tenperiod;2491
tenroman;2179
tesh;02A7
tet;05D8
tetdagesh;FB38
tetdageshhebrew;FB38
tethebrew;05D8
tetsecyrillic;04B5
tevirhebrew;059B
tevirlefthebrew;059B
thabengali;09A5
thadeva;0925
thagujarati;0AA5
thagurmukhi;0A25
thalarabic;0630
thalfinalarabic;FEAC
thanthakhatlowleftthai;F898
thanthakhatlowrightthai;F897
thanthakhatthai;0E4C
thanthakhatupperleftthai;F896
theharabic;062B
thehfinalarabic;FE9A
thehinitialarabic;FE9B
thehmedialarabic;FE9C
thereexists;2203
therefore;2234
theta;03B8
theta1;03D1
thetasymbolgreek;03D1
thieuthacirclekorean;3279
thieuthaparenkorean;3219
thieuthcirclekorean;326B
thieuthkorean;314C
thieuthparenkorean;320B
thirteencircle;246C
thirteenparen;2480
thirteenperiod;2494
thonangmonthothai;0E11
thook;01AD
thophuthaothai;0E12
thorn;00FE
thothahanthai;0E17
thothanthai;0E10
thothongthai;0E18
thothungthai;0E16
thousandcyrillic;0482
thousandsseparatorarabic;066C
thousandsseparatorpersian;066C
three;0033
threearabic;0663
threebengali;09E9
threecircle;2462
threecircleinversesansserif;278C
threedeva;0969
threeeighths;215C
threegujarati;0AE9
threegurmukhi;0A69
threehackarabic;0663
threehangzhou;3023
threeideographicparen;3222
threeinferior;2083
threemonospace;FF13
threenumeratorbengali;09F6
threeoldstyle;F733
threeparen;2476
threeperiod;248A
threepersian;06F3
threequarters;00BE
threequartersemdash;F6DE
threeroman;2172
threesuperior;00B3
threethai;0E53
thzsquare;3394
tihiragana;3061
tikatakana;30C1
tikatakanahalfwidth;FF81
tikeutacirclekorean;3270
tikeutaparenkorean;3210
tikeutcirclekorean;3262
tikeutkorean;3137
tikeutparenkorean;3202
tilde;02DC
tildebelowcmb;0330
tildecmb;0303
tildecomb;0303
tildedoublecmb;0360
tildeoperator;223C
tildeoverlaycmb;0334
tildeverticalcmb;033E
timescircle;2297
tipehahebrew;0596
tipehalefthebrew;0596
tippigurmukhi;0A70
titlocyrilliccmb;0483
tiwnarmenian;057F
tlinebelow;1E6F
tmonospace;FF54
toarmenian;0569
tohiragana;3068
tokatakana;30C8
tokatakanahalfwidth;FF84
tonebarextrahighmod;02E5
tonebarextralowmod;02E9
tonebarhighmod;02E6
tonebarlowmod;02E8
tonebarmidmod;02E7
tonefive;01BD
tonesix;0185
tonetwo;01A8
tonos;0384
tonsquare;3327
topatakthai;0E0F
tortoiseshellbracketleft;3014
tortoiseshellbracketleftsmall;FE5D
tortoiseshellbracketleftvertical;FE39
tortoiseshellbracketright;3015
tortoiseshellbracketrightsmall;FE5E
tortoiseshellbracketrightvertical;FE3A
totaothai;0E15
tpalatalhook;01AB
tparen;24AF
trademark;2122
trademarksans;F8EA
trademarkserif;F6DB
tretroflexhook;0288
triagdn;25BC
triaglf;25C4
triagrt;25BA
triagup;25B2
ts;02A6
tsadi;05E6
tsadidagesh;FB46
tsadidageshhebrew;FB46
tsadihebrew;05E6
tsecyrillic;0446
tsere;05B5
tsere12;05B5
tsere1e;05B5
tsere2b;05B5
tserehebrew;05B5
tserenarrowhebrew;05B5
tserequarterhebrew;05B5
tserewidehebrew;05B5
tshecyrillic;045B
tsuperior;F6F3
ttabengali;099F
ttadeva;091F
ttagujarati;0A9F
ttagurmukhi;0A1F
tteharabic;0679
ttehfinalarabic;FB67
ttehinitialarabic;FB68
ttehmedialarabic;FB69
tthabengali;09A0
tthadeva;0920
tthagujarati;0AA0
tthagurmukhi;0A20
tturned;0287
tuhiragana;3064
tukatakana;30C4
tukatakanahalfwidth;FF82
tusmallhiragana;3063
tusmallkatakana;30C3
tusmallkatakanahalfwidth;FF6F
twelvecircle;246B
twelveparen;247F
twelveperiod;2493
twelveroman;217B
twentycircle;2473
twentyhangzhou;5344
twentyparen;2487
twentyperiod;249B
two;0032
twoarabic;0662
twobengali;09E8
twocircle;2461
twocircleinversesansserif;278B
twodeva;0968
twodotenleader;2025
twodotleader;2025
twodotleadervertical;FE30
twogujarati;0AE8
twogurmukhi;0A68
twohackarabic;0662
twohangzhou;3022
twoideographicparen;3221
twoinferior;2082
twomonospace;FF12
twonumeratorbengali;09F5
twooldstyle;F732
twoparen;2475
twoperiod;2489
twopersian;06F2
tworoman;2171
twostroke;01BB
twosuperior;00B2
twothai;0E52
twothirds;2154
u;0075
uacute;00FA
ubar;0289
ubengali;0989
ubopomofo;3128
ubreve;016D
ucaron;01D4
ucircle;24E4
ucircumflex;00FB
ucircumflexbelow;1E77
ucyrillic;0443
udattadeva;0951
udblacute;0171
udblgrave;0215
udeva;0909
udieresis;00FC
udieresisacute;01D8
udieresisbelow;1E73
udieresiscaron;01DA
udieresiscyrillic;04F1
udieresisgrave;01DC
udieresismacron;01D6
udotbelow;1EE5
ugrave;00F9
ugujarati;0A89
ugurmukhi;0A09
uhiragana;3046
uhookabove;1EE7
uhorn;01B0
uhornacute;1EE9
uhorndotbelow;1EF1
uhorngrave;1EEB
uhornhookabove;1EED
uhorntilde;1EEF
uhungarumlaut;0171
uhungarumlautcyrillic;04F3
uinvertedbreve;0217
ukatakana;30A6
ukatakanahalfwidth;FF73
ukcyrillic;0479
ukorean;315C
umacron;016B
umacroncyrillic;04EF
umacrondieresis;1E7B
umatragurmukhi;0A41
umonospace;FF55
underscore;005F
underscoredbl;2017
underscoremonospace;FF3F
underscorevertical;FE33
underscorewavy;FE4F
union;222A
universal;2200
uogonek;0173
uparen;24B0
upblock;2580
upperdothebrew;05C4
upsilon;03C5
upsilondieresis;03CB
upsilondieresistonos;03B0
upsilonlatin;028A
upsilontonos;03CD
uptackbelowcmb;031D
uptackmod;02D4
uragurmukhi;0A73
uring;016F
ushortcyrillic;045E
usmallhiragana;3045
usmallkatakana;30A5
usmallkatakanahalfwidth;FF69
ustraightcyrillic;04AF
ustraightstrokecyrillic;04B1
utilde;0169
utildeacute;1E79
utildebelow;1E75
uubengali;098A
uudeva;090A
uugujarati;0A8A
uugurmukhi;0A0A
uumatragurmukhi;0A42
uuvowelsignbengali;09C2
uuvowelsigndeva;0942
uuvowelsigngujarati;0AC2
uvowelsignbengali;09C1
uvowelsigndeva;0941
uvowelsigngujarati;0AC1
v;0076
vadeva;0935
vagujarati;0AB5
vagurmukhi;0A35
vakatakana;30F7
vav;05D5
vavdagesh;FB35
vavdagesh65;FB35
vavdageshhebrew;FB35
vavhebrew;05D5
vavholam;FB4B
vavholamhebrew;FB4B
vavvavhebrew;05F0
vavyodhebrew;05F1
vcircle;24E5
vdotbelow;1E7F
vecyrillic;0432
veharabic;06A4
vehfinalarabic;FB6B
vehinitialarabic;FB6C
vehmedialarabic;FB6D
vekatakana;30F9
venus;2640
verticalbar;007C
verticallineabovecmb;030D
verticallinebelowcmb;0329
verticallinelowmod;02CC
verticallinemod;02C8
vewarmenian;057E
vhook;028B
vikatakana;30F8
viramabengali;09CD
viramadeva;094D
viramagujarati;0ACD
visargabengali;0983
visargadeva;0903
visargagujarati;0A83
vmonospace;FF56
voarmenian;0578
voicediterationhiragana;309E
voicediterationkatakana;30FE
voicedmarkkana;309B
voicedmarkkanahalfwidth;FF9E
vokatakana;30FA
vparen;24B1
vtilde;1E7D
vturned;028C
vuhiragana;3094
vukatakana;30F4
w;0077
wacute;1E83
waekorean;3159
wahiragana;308F
wakatakana;30EF
wakatakanahalfwidth;FF9C
wakorean;3158
wasmallhiragana;308E
wasmallkatakana;30EE
wattosquare;3357
wavedash;301C
wavyunderscorevertical;FE34
wawarabic;0648
wawfinalarabic;FEEE
wawhamzaabovearabic;0624
wawhamzaabovefinalarabic;FE86
wbsquare;33DD
wcircle;24E6
wcircumflex;0175
wdieresis;1E85
wdotaccent;1E87
wdotbelow;1E89
wehiragana;3091
weierstrass;2118
wekatakana;30F1
wekorean;315E
weokorean;315D
wgrave;1E81
whitebullet;25E6
whitecircle;25CB
whitecircleinverse;25D9
whitecornerbracketleft;300E
whitecornerbracketleftvertical;FE43
whitecornerbracketright;300F
whitecornerbracketrightvertical;FE44
whitediamond;25C7
whitediamondcontainingblacksmalldiamond;25C8
whitedownpointingsmalltriangle;25BF
whitedownpointingtriangle;25BD
whiteleftpointingsmalltriangle;25C3
whiteleftpointingtriangle;25C1
whitelenticularbracketleft;3016
whitelenticularbracketright;3017
whiterightpointingsmalltriangle;25B9
whiterightpointingtriangle;25B7
whitesmallsquare;25AB
whitesmilingface;263A
whitesquare;25A1
whitestar;2606
whitetelephone;260F
whitetortoiseshellbracketleft;3018
whitetortoiseshellbracketright;3019
whiteuppointingsmalltriangle;25B5
whiteuppointingtriangle;25B3
wihiragana;3090
wikatakana;30F0
wikorean;315F
wmonospace;FF57
wohiragana;3092
wokatakana;30F2
wokatakanahalfwidth;FF66
won;20A9
wonmonospace;FFE6
wowaenthai;0E27
wparen;24B2
wring;1E98
wsuperior;02B7
wturned;028D
wynn;01BF
x;0078
xabovecmb;033D
xbopomofo;3112
xcircle;24E7
xdieresis;1E8D
xdotaccent;1E8B
xeharmenian;056D
xi;03BE
xmonospace;FF58
xparen;24B3
xsuperior;02E3
y;0079
yaadosquare;334E
yabengali;09AF
yacute;00FD
yadeva;092F
yaekorean;3152
yagujarati;0AAF
yagurmukhi;0A2F
yahiragana;3084
yakatakana;30E4
yakatakanahalfwidth;FF94
yakorean;3151
yamakkanthai;0E4E
yasmallhiragana;3083
yasmallkatakana;30E3
yasmallkatakanahalfwidth;FF6C
yatcyrillic;0463
ycircle;24E8
ycircumflex;0177
ydieresis;00FF
ydotaccent;1E8F
ydotbelow;1EF5
yeharabic;064A
yehbarreearabic;06D2
yehbarreefinalarabic;FBAF
yehfinalarabic;FEF2
yehhamzaabovearabic;0626
yehhamzaabovefinalarabic;FE8A
yehhamzaaboveinitialarabic;FE8B
yehhamzaabovemedialarabic;FE8C
yehinitialarabic;FEF3
yehmedialarabic;FEF4
yehmeeminitialarabic;FCDD
yehmeemisolatedarabic;FC58
yehnoonfinalarabic;FC94
yehthreedotsbelowarabic;06D1
yekorean;3156
yen;00A5
yenmonospace;FFE5
yeokorean;3155
yeorinhieuhkorean;3186
yerahbenyomohebrew;05AA
yerahbenyomolefthebrew;05AA
yericyrillic;044B
yerudieresiscyrillic;04F9
yesieungkorean;3181
yesieungpansioskorean;3183
yesieungsioskorean;3182
yetivhebrew;059A
ygrave;1EF3
yhook;01B4
yhookabove;1EF7
yiarmenian;0575
yicyrillic;0457
yikorean;3162
yinyang;262F
yiwnarmenian;0582
ymonospace;FF59
yod;05D9
yoddagesh;FB39
yoddageshhebrew;FB39
yodhebrew;05D9
yodyodhebrew;05F2
yodyodpatahhebrew;FB1F
yohiragana;3088
yoikorean;3189
yokatakana;30E8
yokatakanahalfwidth;FF96
yokorean;315B
yosmallhiragana;3087
yosmallkatakana;30E7
yosmallkatakanahalfwidth;FF6E
yotgreek;03F3
yoyaekorean;3188
yoyakorean;3187
yoyakthai;0E22
yoyingthai;0E0D
yparen;24B4
ypogegrammeni;037A
ypogegrammenigreekcmb;0345
yr;01A6
yring;1E99
ysuperior;02B8
ytilde;1EF9
yturned;028E
yuhiragana;3086
yuikorean;318C
yukatakana;30E6
yukatakanahalfwidth;FF95
yukorean;3160
yusbigcyrillic;046B
yusbigiotifiedcyrillic;046D
yuslittlecyrillic;0467
yuslittleiotifiedcyrillic;0469
yusmallhiragana;3085
yusmallkatakana;30E5
yusmallkatakanahalfwidth;FF6D
yuyekorean;318B
yuyeokorean;318A
yyabengali;09DF
yyadeva;095F
z;007A
zaarmenian;0566
zacute;017A
zadeva;095B
zagurmukhi;0A5B
zaharabic;0638
zahfinalarabic;FEC6
zahinitialarabic;FEC7
zahiragana;3056
zahmedialarabic;FEC8
zainarabic;0632
zainfinalarabic;FEB0
zakatakana;30B6
zaqefgadolhebrew;0595
zaqefqatanhebrew;0594
zarqahebrew;0598
zayin;05D6
zayindagesh;FB36
zayindageshhebrew;FB36
zayinhebrew;05D6
zbopomofo;3117
zcaron;017E
zcircle;24E9
zcircumflex;1E91
zcurl;0291
zdot;017C
zdotaccent;017C
zdotbelow;1E93
zecyrillic;0437
zedescendercyrillic;0499
zedieresiscyrillic;04DF
zehiragana;305C
zekatakana;30BC
zero;0030
zeroarabic;0660
zerobengali;09E6
zerodeva;0966
zerogujarati;0AE6
zerogurmukhi;0A66
zerohackarabic;0660
zeroinferior;2080
zeromonospace;FF10
zerooldstyle;F730
zeropersian;06F0
zerosuperior;2070
zerothai;0E50
zerowidthjoiner;FEFF
zerowidthnonjoiner;200C
zerowidthspace;200B
zeta;03B6
zhbopomofo;3113
zhearmenian;056A
zhebrevecyrillic;04C2
zhecyrillic;0436
zhedescendercyrillic;0497
zhedieresiscyrillic;04DD
zihiragana;3058
zikatakana;30B8
zinorhebrew;05AE
zlinebelow;1E95
zmonospace;FF5A
zohiragana;305E
zokatakana;30BE
zparen;24B5
zretroflexhook;0290
zstroke;01B6
zuhiragana;305A
zukatakana;30BA
a100;275E
a101;2761
a102;2762
a103;2763
a104;2764
a105;2710
a106;2765
a107;2766
a108;2767
a109;2660
a10;2721
a110;2665
a111;2666
a112;2663
a117;2709
a118;2708
a119;2707
a11;261B
a120;2460
a121;2461
a122;2462
a123;2463
a124;2464
a125;2465
a126;2466
a127;2467
a128;2468
a129;2469
a12;261E
a130;2776
a131;2777
a132;2778
a133;2779
a134;277A
a135;277B
a136;277C
a137;277D
a138;277E
a139;277F
a13;270C
a140;2780
a141;2781
a142;2782
a143;2783
a144;2784
a145;2785
a146;2786
a147;2787
a148;2788
a149;2789
a14;270D
a150;278A
a151;278B
a152;278C
a153;278D
a154;278E
a155;278F
a156;2790
a157;2791
a158;2792
a159;2793
a15;270E
a160;2794
a161;2192
a162;27A3
a163;2194
a164;2195
a165;2799
a166;279B
a167;279C
a168;279D
a169;279E
a16;270F
a170;279F
a171;27A0
a172;27A1
a173;27A2
a174;27A4
a175;27A5
a176;27A6
a177;27A7
a178;27A8
a179;27A9
a17;2711
a180;27AB
a181;27AD
a182;27AF
a183;27B2
a184;27B3
a185;27B5
a186;27B8
a187;27BA
a188;27BB
a189;27BC
a18;2712
a190;27BD
a191;27BE
a192;279A
a193;27AA
a194;27B6
a195;27B9
a196;2798
a197;27B4
a198;27B7
a199;27AC
a19;2713
a1;2701
a200;27AE
a201;27B1
a202;2703
a203;2750
a204;2752
a205;276E
a206;2770
a20;2714
a21;2715
a22;2716
a23;2717
a24;2718
a25;2719
a26;271A
a27;271B
a28;271C
a29;2722
a2;2702
a30;2723
a31;2724
a32;2725
a33;2726
a34;2727
a35;2605
a36;2729
a37;272A
a38;272B
a39;272C
a3;2704
a40;272D
a41;272E
a42;272F
a43;2730
a44;2731
a45;2732
a46;2733
a47;2734
a48;2735
a49;2736
a4;260E
a50;2737
a51;2738
a52;2739
a53;273A
a54;273B
a55;273C
a56;273D
a57;273E
a58;273F
a59;2740
a5;2706
a60;2741
a61;2742
a62;2743
a63;2744
a64;2745
a65;2746
a66;2747
a67;2748
a68;2749
a69;274A
a6;271D
a70;274B
a71;25CF
a72;274D
a73;25A0
a74;274F
a75;2751
a76;25B2
a77;25BC
a78;25C6
a79;2756
a7;271E
a81;25D7
a82;2758
a83;2759
a84;275A
a85;276F
a86;2771
a87;2772
a88;2773
a89;2768
a8;271F
a90;2769
a91;276C
a92;276D
a93;276A
a94;276B
a95;2774
a96;2775
a97;275B
a98;275C
a99;275D
a9;2720
"""
# string table management
#
class StringTable:
def __init__( self, name_list, master_table_name ):
self.names = name_list
self.master_table = master_table_name
self.indices = {}
index = 0
for name in name_list:
self.indices[name] = index
index += len( name ) + 1
self.total = index
def dump( self, file ):
write = file.write
write( " static const char " + self.master_table +
"[" + repr( self.total ) + "] =\n" )
write( " {\n" )
line = ""
for name in self.names:
line += " '"
line += string.join( ( re.findall( ".", name ) ), "','" )
line += "', 0,\n"
write( line + " };\n\n\n" )
def dump_sublist( self, file, table_name, macro_name, sublist ):
write = file.write
write( "#define " + macro_name + " " + repr( len( sublist ) ) + "\n\n" )
write( " /* Values are offsets into the `" +
self.master_table + "' table */\n\n" )
write( " static const short " + table_name +
"[" + macro_name + "] =\n" )
write( " {\n" )
line = " "
comma = ""
col = 0
for name in sublist:
line += comma
line += "%4d" % self.indices[name]
col += 1
comma = ","
if col == 14:
col = 0
comma = ",\n "
write( line + "\n };\n\n\n" )
# We now store the Adobe Glyph List in compressed form. The list is put
# into a data structure called `trie' (because it has a tree-like
# appearance). Consider, for example, that you want to store the
# following name mapping:
#
# A => 1
# Aacute => 6
# Abalon => 2
# Abstract => 4
#
# It is possible to store the entries as follows.
#
# A => 1
# |
# +-acute => 6
# |
# +-b
# |
# +-alon => 2
# |
# +-stract => 4
#
# We see that each node in the trie has:
#
# - one or more `letters'
# - an optional value
# - zero or more child nodes
#
# The first step is to call
#
# root = StringNode( "", 0 )
# for word in map.values():
# root.add( word, map[word] )
#
# which creates a large trie where each node has only one children.
#
# Executing
#
# root = root.optimize()
#
# optimizes the trie by merging the letters of successive nodes whenever
# possible.
#
# Each node of the trie is stored as follows.
#
# - First the node's letter, according to the following scheme. We
# use the fact that in the AGL no name contains character codes > 127.
#
# name bitsize description
# ----------------------------------------------------------------
# notlast 1 Set to 1 if this is not the last letter
# in the word.
# ascii 7 The letter's ASCII value.
#
# - The letter is followed by a children count and the value of the
# current key (if any). Again we can do some optimization because all
# AGL entries are from the BMP; this means that 16 bits are sufficient
# to store its Unicode values. Additionally, no node has more than
# 127 children.
#
# name bitsize description
# -----------------------------------------
# hasvalue 1 Set to 1 if a 16-bit Unicode value follows.
# num_children 7 Number of children. Can be 0 only if
# `hasvalue' is set to 1.
# value 16 Optional Unicode value.
#
# - A node is finished by a list of 16bit absolute offsets to the
# children, which must be sorted in increasing order of their first
# letter.
#
# For simplicity, all 16bit quantities are stored in big-endian order.
#
# The root node has first letter = 0, and no value.
#
class StringNode:
def __init__( self, letter, value ):
self.letter = letter
self.value = value
self.children = {}
def __cmp__( self, other ):
return ord( self.letter[0] ) - ord( other.letter[0] )
def add( self, word, value ):
if len( word ) == 0:
self.value = value
return
letter = word[0]
word = word[1:]
if self.children.has_key( letter ):
child = self.children[letter]
else:
child = StringNode( letter, 0 )
self.children[letter] = child
child.add( word, value )
def optimize( self ):
# optimize all children first
children = self.children.values()
self.children = {}
for child in children:
self.children[child.letter[0]] = child.optimize()
# don't optimize if there's a value,
# if we don't have any child or if we
# have more than one child
if ( self.value != 0 ) or ( not children ) or len( children ) > 1:
return self
child = children[0]
self.letter += child.letter
self.value = child.value
self.children = child.children
return self
def dump_debug( self, write, margin ):
# this is used during debugging
line = margin + "+-"
if len( self.letter ) == 0:
line += "<NOLETTER>"
else:
line += self.letter
if self.value:
line += " => " + repr( self.value )
write( line + "\n" )
if self.children:
margin += "| "
for child in self.children.values():
child.dump_debug( write, margin )
def locate( self, index ):
self.index = index
if len( self.letter ) > 0:
index += len( self.letter ) + 1
else:
index += 2
if self.value != 0:
index += 2
children = self.children.values()
children.sort()
index += 2 * len( children )
for child in children:
index = child.locate( index )
return index
def store( self, storage ):
# write the letters
l = len( self.letter )
if l == 0:
storage += struct.pack( "B", 0 )
else:
for n in range( l ):
val = ord( self.letter[n] )
if n < l - 1:
val += 128
storage += struct.pack( "B", val )
# write the count
children = self.children.values()
children.sort()
count = len( children )
if self.value != 0:
storage += struct.pack( "!BH", count + 128, self.value )
else:
storage += struct.pack( "B", count )
for child in children:
storage += struct.pack( "!H", child.index )
for child in children:
storage = child.store( storage )
return storage
def adobe_glyph_values():
"""return the list of glyph names and their unicode values"""
lines = string.split( adobe_glyph_list, '\n' )
glyphs = []
values = []
for line in lines:
if line:
fields = string.split( line, ';' )
# print fields[1] + ' - ' + fields[0]
subfields = string.split( fields[1], ' ' )
if len( subfields ) == 1:
glyphs.append( fields[0] )
values.append( fields[1] )
return glyphs, values
def filter_glyph_names( alist, filter ):
"""filter `alist' by taking _out_ all glyph names that are in `filter'"""
count = 0
extras = []
for name in alist:
try:
filtered_index = filter.index( name )
except:
extras.append( name )
return extras
def dump_encoding( file, encoding_name, encoding_list ):
"""dump a given encoding"""
write = file.write
write( " /* the following are indices into the SID name table */\n" )
write( " static const unsigned short " + encoding_name +
"[" + repr( len( encoding_list ) ) + "] =\n" )
write( " {\n" )
line = " "
comma = ""
col = 0
for value in encoding_list:
line += comma
line += "%3d" % value
comma = ","
col += 1
if col == 16:
col = 0
comma = ",\n "
write( line + "\n };\n\n\n" )
def dump_array( the_array, write, array_name ):
"""dumps a given encoding"""
write( " static const unsigned char " + array_name +
"[" + repr( len( the_array ) ) + "L] =\n" )
write( " {\n" )
line = ""
comma = " "
col = 0
for value in the_array:
line += comma
line += "%3d" % ord( value )
comma = ","
col += 1
if col == 16:
col = 0
comma = ",\n "
if len( line ) > 1024:
write( line )
line = ""
write( line + "\n };\n\n\n" )
def main():
"""main program body"""
if len( sys.argv ) != 2:
print __doc__ % sys.argv[0]
sys.exit( 1 )
file = open( sys.argv[1], "w\n" )
write = file.write
count_sid = len( sid_standard_names )
# `mac_extras' contains the list of glyph names in the Macintosh standard
# encoding which are not in the SID Standard Names.
#
mac_extras = filter_glyph_names( mac_standard_names, sid_standard_names )
# `base_list' contains the names of our final glyph names table.
# It consists of the `mac_extras' glyph names, followed by the SID
# standard names.
#
mac_extras_count = len( mac_extras )
base_list = mac_extras + sid_standard_names
write( "/***************************************************************************/\n" )
write( "/* */\n" )
write( "/* %-71s*/\n" % os.path.basename( sys.argv[1] ) )
write( "/* */\n" )
write( "/* PostScript glyph names. */\n" )
write( "/* */\n" )
write( "/* Copyright 2005, 2008, 2011 by */\n" )
write( "/* David Turner, Robert Wilhelm, and Werner Lemberg. */\n" )
write( "/* */\n" )
write( "/* This file is part of the FreeType project, and may only be used, */\n" )
write( "/* modified, and distributed under the terms of the FreeType project */\n" )
write( "/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\n" )
write( "/* this file you indicate that you have read the license and */\n" )
write( "/* understand and accept it fully. */\n" )
write( "/* */\n" )
write( "/***************************************************************************/\n" )
write( "\n" )
write( "\n" )
write( " /* This file has been generated automatically -- do not edit! */\n" )
write( "\n" )
write( "\n" )
# dump final glyph list (mac extras + sid standard names)
#
st = StringTable( base_list, "ft_standard_glyph_names" )
st.dump( file )
st.dump_sublist( file, "ft_mac_names",
"FT_NUM_MAC_NAMES", mac_standard_names )
st.dump_sublist( file, "ft_sid_names",
"FT_NUM_SID_NAMES", sid_standard_names )
dump_encoding( file, "t1_standard_encoding", t1_standard_encoding )
dump_encoding( file, "t1_expert_encoding", t1_expert_encoding )
# dump the AGL in its compressed form
#
agl_glyphs, agl_values = adobe_glyph_values()
dict = StringNode( "", 0 )
for g in range( len( agl_glyphs ) ):
dict.add( agl_glyphs[g], eval( "0x" + agl_values[g] ) )
dict = dict.optimize()
dict_len = dict.locate( 0 )
dict_array = dict.store( "" )
write( """\
/*
* This table is a compressed version of the Adobe Glyph List (AGL),
* optimized for efficient searching. It has been generated by the
* `glnames.py' python script located in the `src/tools' directory.
*
* The lookup function to get the Unicode value for a given string
* is defined below the table.
*/
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
""" )
dump_array( dict_array, write, "ft_adobe_glyph_list" )
# write the lookup routine now
#
write( """\
/*
* This function searches the compressed table efficiently.
*/
static unsigned long
ft_get_adobe_glyph_index( const char* name,
const char* limit )
{
int c = 0;
int count, min, max;
const unsigned char* p = ft_adobe_glyph_list;
if ( name == 0 || name >= limit )
goto NotFound;
c = *name++;
count = p[1];
p += 2;
min = 0;
max = count;
while ( min < max )
{
int mid = ( min + max ) >> 1;
const unsigned char* q = p + mid * 2;
int c2;
q = ft_adobe_glyph_list + ( ( (int)q[0] << 8 ) | q[1] );
c2 = q[0] & 127;
if ( c2 == c )
{
p = q;
goto Found;
}
if ( c2 < c )
min = mid + 1;
else
max = mid;
}
goto NotFound;
Found:
for (;;)
{
/* assert (*p & 127) == c */
if ( name >= limit )
{
if ( (p[0] & 128) == 0 &&
(p[1] & 128) != 0 )
return (unsigned long)( ( (int)p[2] << 8 ) | p[3] );
goto NotFound;
}
c = *name++;
if ( p[0] & 128 )
{
p++;
if ( c != (p[0] & 127) )
goto NotFound;
continue;
}
p++;
count = p[0] & 127;
if ( p[0] & 128 )
p += 2;
p++;
for ( ; count > 0; count--, p += 2 )
{
int offset = ( (int)p[0] << 8 ) | p[1];
const unsigned char* q = ft_adobe_glyph_list + offset;
if ( c == ( q[0] & 127 ) )
{
p = q;
goto NextIter;
}
}
goto NotFound;
NextIter:
;
}
NotFound:
return 0;
}
#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
""" )
if 0: # generate unit test, or don't
#
# now write the unit test to check that everything works OK
#
write( "#ifdef TEST\n\n" )
write( "static const char* const the_names[] = {\n" )
for name in agl_glyphs:
write( ' "' + name + '",\n' )
write( " 0\n};\n" )
write( "static const unsigned long the_values[] = {\n" )
for val in agl_values:
write( ' 0x' + val + ',\n' )
write( " 0\n};\n" )
write( """
#include <stdlib.h>
#include <stdio.h>
int
main( void )
{
int result = 0;
const char* const* names = the_names;
const unsigned long* values = the_values;
for ( ; *names; names++, values++ )
{
const char* name = *names;
unsigned long reference = *values;
unsigned long value;
value = ft_get_adobe_glyph_index( name, name + strlen( name ) );
if ( value != reference )
{
result = 1;
fprintf( stderr, "name '%s' => %04x instead of %04x\\n",
name, value, reference );
}
}
return result;
}
""" )
write( "#endif /* TEST */\n" )
write("\n/* END */\n")
# Now run the main routine
#
main()
# END
| YifuLiu/AliOS-Things | components/freetype/src/tools/glnames.py | Python | apache-2.0 | 105,239 |
/*
* gcc -DFT2_BUILD_LIBRARY -I../../include -o test_afm test_afm.c \
* -L../../objs/.libs -lfreetype -lz -static
*/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
void dump_fontinfo( AFM_FontInfo fi )
{
FT_Int i;
printf( "This AFM is for %sCID font.\n\n",
( fi->IsCIDFont ) ? "" : "non-" );
printf( "FontBBox: %.2f %.2f %.2f %.2f\n", fi->FontBBox.xMin / 65536.,
fi->FontBBox.yMin / 65536.,
fi->FontBBox.xMax / 65536.,
fi->FontBBox.yMax / 65536. );
printf( "Ascender: %.2f\n", fi->Ascender / 65536. );
printf( "Descender: %.2f\n\n", fi->Descender / 65536. );
if ( fi->NumTrackKern )
printf( "There are %d sets of track kernings:\n",
fi->NumTrackKern );
else
printf( "There is no track kerning.\n" );
for ( i = 0; i < fi->NumTrackKern; i++ )
{
AFM_TrackKern tk = fi->TrackKerns + i;
printf( "\t%2d: %5.2f %5.2f %5.2f %5.2f\n", tk->degree,
tk->min_ptsize / 65536.,
tk->min_kern / 65536.,
tk->max_ptsize / 65536.,
tk->max_kern / 65536. );
}
printf( "\n" );
if ( fi->NumKernPair )
printf( "There are %d kerning pairs:\n",
fi->NumKernPair );
else
printf( "There is no kerning pair.\n" );
for ( i = 0; i < fi->NumKernPair; i++ )
{
AFM_KernPair kp = fi->KernPairs + i;
printf( "\t%3d + %3d => (%4d, %4d)\n", kp->index1,
kp->index2,
kp->x,
kp->y );
}
}
int
dummy_get_index( const char* name,
FT_Offset len,
void* user_data )
{
if ( len )
return name[0];
else
return 0;
}
FT_Error
parse_afm( FT_Library library,
FT_Stream stream,
AFM_FontInfo fi )
{
PSAux_Service psaux;
AFM_ParserRec parser;
FT_Error error = FT_Err_Ok;
psaux = (PSAux_Service)FT_Get_Module_Interface( library, "psaux" );
if ( !psaux || !psaux->afm_parser_funcs )
return -1;
error = FT_Stream_EnterFrame( stream, stream->size );
if ( error )
return error;
error = psaux->afm_parser_funcs->init( &parser,
library->memory,
stream->cursor,
stream->limit );
if ( error )
return error;
parser.FontInfo = fi;
parser.get_index = dummy_get_index;
error = psaux->afm_parser_funcs->parse( &parser );
psaux->afm_parser_funcs->done( &parser );
return error;
}
int main( int argc,
char** argv )
{
FT_Library library;
FT_StreamRec stream;
FT_Error error = FT_Err_Ok;
AFM_FontInfoRec fi;
if ( argc < 2 )
return FT_ERR( Invalid_Argument );
error = FT_Init_FreeType( &library );
if ( error )
return error;
FT_ZERO( &stream );
error = FT_Stream_Open( &stream, argv[1] );
if ( error )
goto Exit;
stream.memory = library->memory;
FT_ZERO( &fi );
error = parse_afm( library, &stream, &fi );
if ( !error )
{
FT_Memory memory = library->memory;
dump_fontinfo( &fi );
if ( fi.KernPairs )
FT_FREE( fi.KernPairs );
if ( fi.TrackKerns )
FT_FREE( fi.TrackKerns );
}
else
printf( "parse error\n" );
FT_Stream_Close( &stream );
Exit:
FT_Done_FreeType( library );
return error;
}
| YifuLiu/AliOS-Things | components/freetype/src/tools/test_afm.c | C | apache-2.0 | 3,973 |
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BBOX_H
#include <time.h> /* for clock() */
/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
/* to get the HZ macro which is the equivalent. */
#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4)
#include <sys/param.h>
#define CLOCKS_PER_SEC HZ
#endif
static long
get_time( void )
{
return clock() * 10000L / CLOCKS_PER_SEC;
}
/* test bbox computations */
#define XSCALE 65536
#define XX(x) ((FT_Pos)(x*XSCALE))
#define XVEC(x,y) { XX(x), XX(y) }
#define XVAL(x) ((x)/(1.0*XSCALE))
/* dummy outline #1 */
static FT_Vector dummy_vec_1[4] =
{
#if 1
XVEC( 408.9111, 535.3164 ),
XVEC( 455.8887, 634.396 ),
XVEC( -37.8765, 786.2207 ),
XVEC( 164.6074, 535.3164 )
#else
{ (FT_Int32)0x0198E93DL , (FT_Int32)0x021750FFL }, /* 408.9111, 535.3164 */
{ (FT_Int32)0x01C7E312L , (FT_Int32)0x027A6560L }, /* 455.8887, 634.3960 */
{ (FT_Int32)0xFFDA1F9EL , (FT_Int32)0x0312387FL }, /* -37.8765, 786.2207 */
{ (FT_Int32)0x00A49B7EL , (FT_Int32)0x021750FFL } /* 164.6074, 535.3164 */
#endif
};
static char dummy_tag_1[4] =
{
FT_CURVE_TAG_ON,
FT_CURVE_TAG_CUBIC,
FT_CURVE_TAG_CUBIC,
FT_CURVE_TAG_ON
};
static short dummy_contour_1[1] =
{
3
};
static FT_Outline dummy_outline_1 =
{
1,
4,
dummy_vec_1,
dummy_tag_1,
dummy_contour_1,
0
};
/* dummy outline #2 */
static FT_Vector dummy_vec_2[4] =
{
XVEC( 100.0, 100.0 ),
XVEC( 100.0, 200.0 ),
XVEC( 200.0, 200.0 ),
XVEC( 200.0, 133.0 )
};
static FT_Outline dummy_outline_2 =
{
1,
4,
dummy_vec_2,
dummy_tag_1,
dummy_contour_1,
0
};
/* dummy outline #3 with bbox of [0 100 128 128] precisely */
static FT_Vector dummy_vec_3[4] =
{
XVEC( 100.0, 127.0 ),
XVEC( 200.0, 127.0 ),
XVEC( 0.0, 136.0 ),
XVEC( 0.0, 100.0 )
};
static FT_Outline dummy_outline_3 =
{
1,
4,
dummy_vec_3,
dummy_tag_1,
dummy_contour_1,
0
};
static void
dump_outline( FT_Outline* outline )
{
FT_BBox bbox;
/* compute and display cbox */
FT_Outline_Get_CBox( outline, &bbox );
printf( "cbox = [%.2f %.2f %.2f %.2f]\n",
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
/* compute and display bbox */
FT_Outline_Get_BBox( outline, &bbox );
printf( "bbox = [%.2f %.2f %.2f %.2f]\n",
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
}
static void
profile_outline( FT_Outline* outline,
long repeat )
{
FT_BBox bbox;
long count;
long time0;
time0 = get_time();
for ( count = repeat; count > 0; count-- )
FT_Outline_Get_CBox( outline, &bbox );
time0 = get_time() - time0;
printf( "time = %6.3f cbox = [%8.4f %8.4f %8.4f %8.4f]\n",
((double)time0/10000.0),
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
printf( "cbox_hex = [%08X %08X %08X %08X]\n",
bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax );
time0 = get_time();
for ( count = repeat; count > 0; count-- )
FT_Outline_Get_BBox( outline, &bbox );
time0 = get_time() - time0;
printf( "time = %6.3f bbox = [%8.4f %8.4f %8.4f %8.4f]\n",
((double)time0/10000.0),
XVAL( bbox.xMin ),
XVAL( bbox.yMin ),
XVAL( bbox.xMax ),
XVAL( bbox.yMax ) );
printf( "bbox_hex = [%08X %08X %08X %08X]\n",
bbox.xMin, bbox.yMin, bbox.xMax, bbox.yMax );
}
#define REPEAT 1000000L
int main( int argc, char** argv )
{
printf( "outline #1\n" );
profile_outline( &dummy_outline_1, REPEAT );
printf( "outline #2\n" );
profile_outline( &dummy_outline_2, REPEAT );
printf( "outline #3\n" );
profile_outline( &dummy_outline_3, REPEAT );
return 0;
}
| YifuLiu/AliOS-Things | components/freetype/src/tools/test_bbox.c | C | apache-2.0 | 4,195 |
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRIGONOMETRY_H
#include <math.h>
#include <stdio.h>
#define PI 3.14159265358979323846
#define SPI (PI/FT_ANGLE_PI)
/* the precision in 16.16 fixed-point checks. Expect between 2 and 5 */
/* noise LSB bits during operations, due to rounding errors.. */
#define THRESHOLD 64
static error = 0;
static void
test_cos( void )
{
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed f1, f2;
double d2;
f1 = FT_Cos(i);
d2 = cos( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
if ( abs( f2-f1 ) > THRESHOLD )
{
error = 1;
printf( "FT_Cos[%3d] = %.7f cos[%3d] = %.7f\n",
(i >> 16), f1/65536.0, (i >> 16), d2 );
}
}
}
static void
test_sin( void )
{
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed f1, f2;
double d2;
f1 = FT_Sin(i);
d2 = sin( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
if ( abs( f2-f1 ) > THRESHOLD )
{
error = 1;
printf( "FT_Sin[%3d] = %.7f sin[%3d] = %.7f\n",
(i >> 16), f1/65536.0, (i >> 16), d2 );
}
}
}
static void
test_tan( void )
{
int i;
for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 )
{
FT_Fixed f1, f2;
double d2;
f1 = FT_Tan(i);
d2 = tan( i*SPI );
f2 = (FT_Fixed)(d2*65536.0);
if ( abs( f2-f1 ) > THRESHOLD )
{
error = 1;
printf( "FT_Tan[%3d] = %.7f tan[%3d] = %.7f\n",
(i >> 16), f1/65536.0, (i >> 16), d2 );
}
}
}
static void
test_atan2( void )
{
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed c2, s2;
double l, a, c1, s1;
int j;
l = 5.0;
a = i*SPI;
c1 = l * cos(a);
s1 = l * sin(a);
c2 = (FT_Fixed)(c1*65536.0);
s2 = (FT_Fixed)(s1*65536.0);
j = FT_Atan2( c2, s2 );
if ( j < 0 )
j += FT_ANGLE_2PI;
if ( abs( i - j ) > 1 )
{
printf( "FT_Atan2( %.7f, %.7f ) = %.5f, atan = %.5f\n",
c2/65536.0, s2/65536.0, j/65536.0, i/65536.0 );
}
}
}
static void
test_unit( void )
{
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Vector v;
double a, c1, s1;
FT_Fixed c2, s2;
FT_Vector_Unit( &v, i );
a = ( i*SPI );
c1 = cos(a);
s1 = sin(a);
c2 = (FT_Fixed)(c1*65536.0);
s2 = (FT_Fixed)(s1*65536.0);
if ( abs( v.x-c2 ) > THRESHOLD ||
abs( v.y-s2 ) > THRESHOLD )
{
error = 1;
printf( "FT_Vector_Unit[%3d] = ( %.7f, %.7f ) vec = ( %.7f, %.7f )\n",
(i >> 16),
v.x/65536.0, v.y/65536.0,
c1, s1 );
}
}
}
static void
test_length( void )
{
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Vector v;
FT_Fixed l, l2;
l = (FT_Fixed)(500.0*65536.0);
v.x = (FT_Fixed)( l * cos( i*SPI ) );
v.y = (FT_Fixed)( l * sin( i*SPI ) );
l2 = FT_Vector_Length( &v );
if ( abs( l2-l ) > THRESHOLD )
{
error = 1;
printf( "FT_Length( %.7f, %.7f ) = %.5f, length = %.5f\n",
v.x/65536.0, v.y/65536.0, l2/65536.0, l/65536.0 );
}
}
}
static void
test_rotate( void )
{
int rotate;
for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 )
{
double ra, cra, sra;
int i;
ra = rotate*SPI;
cra = cos( ra );
sra = sin( ra );
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed c2, s2, c4, s4;
FT_Vector v;
double l, a, c1, s1, c3, s3;
l = 500.0;
a = i*SPI;
c1 = l * cos(a);
s1 = l * sin(a);
v.x = c2 = (FT_Fixed)(c1*65536.0);
v.y = s2 = (FT_Fixed)(s1*65536.0);
FT_Vector_Rotate( &v, rotate );
c3 = c1 * cra - s1 * sra;
s3 = c1 * sra + s1 * cra;
c4 = (FT_Fixed)(c3*65536.0);
s4 = (FT_Fixed)(s3*65536.0);
if ( abs( c4 - v.x ) > THRESHOLD ||
abs( s4 - v.y ) > THRESHOLD )
{
error = 1;
printf( "FT_Rotate( (%.7f,%.7f), %.5f ) = ( %.7f, %.7f ), rot = ( %.7f, %.7f )\n",
c1, s1, ra,
c2/65536.0, s2/65536.0,
c4/65536.0, s4/65536.0 );
}
}
}
}
int main( void )
{
test_cos();
test_sin();
test_tan();
test_atan2();
test_unit();
test_length();
test_rotate();
if (!error)
printf( "trigonometry test ok !\n" );
return !error;
}
| YifuLiu/AliOS-Things | components/freetype/src/tools/test_trig.c | C | apache-2.0 | 4,825 |
#
# FreeType 2 TrueType module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += TRUETYPE_DRIVER
define TRUETYPE_DRIVER
$(OPEN_DRIVER) FT_Driver_ClassRec, tt_driver_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)truetype $(ECHO_DRIVER_DESC)Windows/Mac font files with extension *.ttf or *.ttc$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/truetype/module.mk | Makefile | apache-2.0 | 689 |
#
# FreeType 2 TrueType driver configuration rules
#
# Copyright 1996-2001, 2003-2004, 2011-2012 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.
# TrueType driver directory
#
TT_DIR := $(SRC_DIR)/truetype
# compilation flags for the driver
#
TT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(TT_DIR))
# TrueType driver sources (i.e., C files)
#
TT_DRV_SRC := $(TT_DIR)/ttdriver.c \
$(TT_DIR)/ttgload.c \
$(TT_DIR)/ttgxvar.c \
$(TT_DIR)/ttinterp.c \
$(TT_DIR)/ttobjs.c \
$(TT_DIR)/ttpic.c \
$(TT_DIR)/ttpload.c \
$(TT_DIR)/ttsubpix.c
# TrueType driver headers
#
TT_DRV_H := $(TT_DRV_SRC:%.c=%.h) \
$(TT_DIR)/tterrors.h
# TrueType driver object(s)
#
# TT_DRV_OBJ_M is used during `multi' builds
# TT_DRV_OBJ_S is used during `single' builds
#
TT_DRV_OBJ_M := $(TT_DRV_SRC:$(TT_DIR)/%.c=$(OBJ_DIR)/%.$O)
TT_DRV_OBJ_S := $(OBJ_DIR)/truetype.$O
# TrueType driver source file for single build
#
TT_DRV_SRC_S := $(TT_DIR)/truetype.c
# TrueType driver - single object
#
$(TT_DRV_OBJ_S): $(TT_DRV_SRC_S) $(TT_DRV_SRC) $(FREETYPE_H) $(TT_DRV_H)
$(TT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(TT_DRV_SRC_S))
# driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(TT_DIR)/%.c $(FREETYPE_H) $(TT_DRV_H)
$(TT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(TT_DRV_OBJ_S)
DRV_OBJS_M += $(TT_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/truetype/rules.mk | Makefile | apache-2.0 | 1,794 |
/***************************************************************************/
/* */
/* truetype.c */
/* */
/* FreeType TrueType driver component (body only). */
/* */
/* Copyright 1996-2001, 2004, 2006, 2012 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "ttpic.c"
#include "ttdriver.c" /* driver interface */
#include "ttpload.c" /* tables loader */
#include "ttgload.c" /* glyph loader */
#include "ttobjs.c" /* object manager */
#ifdef TT_USE_BYTECODE_INTERPRETER
#include "ttinterp.c"
#include "ttsubpix.c"
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.c" /* gx distortable font */
#endif
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/truetype.c | C | apache-2.0 | 1,725 |
/***************************************************************************/
/* */
/* ttdriver.c */
/* */
/* TrueType font driver implementation (body). */
/* */
/* Copyright 1996-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_SERVICE_XFREE86_NAME_H
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_MULTIPLE_MASTERS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#endif
#include FT_SERVICE_TRUETYPE_ENGINE_H
#include FT_SERVICE_TRUETYPE_GLYF_H
#include FT_SERVICE_PROPERTIES_H
#include FT_TRUETYPE_DRIVER_H
#include "ttdriver.h"
#include "ttgload.h"
#include "ttpload.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
#include "tterrors.h"
#include "ttpic.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_ttdriver
/*
* PROPERTY SERVICE
*
*/
static FT_Error
tt_property_set( FT_Module module, /* TT_Driver */
const char* property_name,
const void* value )
{
FT_Error error = FT_Err_Ok;
TT_Driver driver = (TT_Driver)module;
if ( !ft_strcmp( property_name, "interpreter-version" ) )
{
FT_UInt* interpreter_version = (FT_UInt*)value;
#ifndef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( *interpreter_version != TT_INTERPRETER_VERSION_35 )
error = FT_ERR( Unimplemented_Feature );
else
#endif
driver->interpreter_version = *interpreter_version;
return error;
}
FT_TRACE0(( "tt_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
static FT_Error
tt_property_get( FT_Module module, /* TT_Driver */
const char* property_name,
const void* value )
{
FT_Error error = FT_Err_Ok;
TT_Driver driver = (TT_Driver)module;
FT_UInt interpreter_version = driver->interpreter_version;
if ( !ft_strcmp( property_name, "interpreter-version" ) )
{
FT_UInt* val = (FT_UInt*)value;
*val = interpreter_version;
return error;
}
FT_TRACE0(( "tt_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
FT_DEFINE_SERVICE_PROPERTIESREC(
tt_service_properties,
(FT_Properties_SetFunc)tt_property_set,
(FT_Properties_GetFunc)tt_property_get )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** F A C E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#undef PAIR_TAG
#define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \
(FT_ULong)right )
/*************************************************************************/
/* */
/* <Function> */
/* tt_get_kerning */
/* */
/* <Description> */
/* A driver method used to return the kerning vector between two */
/* glyphs of the same face. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* left_glyph :: The index of the left glyph in the kern pair. */
/* */
/* right_glyph :: The index of the right glyph in the kern pair. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
/* supported by this function. Other layouts, or more sophisticated */
/* kernings, are out of scope of this method (the basic driver */
/* interface is meant to be simple). */
/* */
/* They can be implemented by format-specific interfaces. */
/* */
static FT_Error
tt_get_kerning( FT_Face ttface, /* TT_Face */
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_Vector* kerning )
{
TT_Face face = (TT_Face)ttface;
SFNT_Service sfnt = (SFNT_Service)face->sfnt;
kerning->x = 0;
kerning->y = 0;
if ( sfnt )
kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph );
return 0;
}
#undef PAIR_TAG
static FT_Error
tt_get_advances( FT_Face ttface,
FT_UInt start,
FT_UInt count,
FT_Int32 flags,
FT_Fixed *advances )
{
FT_UInt nn;
TT_Face face = (TT_Face) ttface;
/* XXX: TODO: check for sbits */
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
{
for ( nn = 0; nn < count; nn++ )
{
FT_Short tsb;
FT_UShort ah;
/* since we don't need `tsb', we use zero for `yMax' parameter */
TT_Get_VMetrics( face, start + nn, 0, &tsb, &ah );
advances[nn] = ah;
}
}
else
{
for ( nn = 0; nn < count; nn++ )
{
FT_Short lsb;
FT_UShort aw;
TT_Get_HMetrics( face, start + nn, &lsb, &aw );
advances[nn] = aw;
}
}
return FT_Err_Ok;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** S I Z E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
static FT_Error
tt_size_select( FT_Size size,
FT_ULong strike_index )
{
TT_Face ttface = (TT_Face)size->face;
TT_Size ttsize = (TT_Size)size;
FT_Error error = FT_Err_Ok;
ttsize->strike_index = strike_index;
if ( FT_IS_SCALABLE( size->face ) )
{
/* use the scaled metrics, even when tt_size_reset fails */
FT_Select_Metrics( size->face, strike_index );
tt_size_reset( ttsize );
}
else
{
SFNT_Service sfnt = (SFNT_Service) ttface->sfnt;
FT_Size_Metrics* metrics = &size->metrics;
error = sfnt->load_strike_metrics( ttface, strike_index, metrics );
if ( error )
ttsize->strike_index = 0xFFFFFFFFUL;
}
return error;
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
static FT_Error
tt_size_request( FT_Size size,
FT_Size_Request req )
{
TT_Size ttsize = (TT_Size)size;
FT_Error error = FT_Err_Ok;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
if ( FT_HAS_FIXED_SIZES( size->face ) )
{
TT_Face ttface = (TT_Face)size->face;
SFNT_Service sfnt = (SFNT_Service) ttface->sfnt;
FT_ULong strike_index;
error = sfnt->set_sbit_strike( ttface, req, &strike_index );
if ( error )
ttsize->strike_index = 0xFFFFFFFFUL;
else
return tt_size_select( size, strike_index );
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
FT_Request_Metrics( size->face, req );
if ( FT_IS_SCALABLE( size->face ) )
{
error = tt_size_reset( ttsize );
ttsize->root.metrics = ttsize->metrics;
}
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_glyph_load */
/* */
/* <Description> */
/* A driver method used to load a glyph within a given glyph slot. */
/* */
/* <Input> */
/* slot :: A handle to the target slot object where the glyph */
/* will be loaded. */
/* */
/* size :: A handle to the source face size at which the glyph */
/* must be scaled, loaded, etc. */
/* */
/* glyph_index :: The index of the glyph in the font file. */
/* */
/* load_flags :: A flag indicating what to load for this glyph. The */
/* FT_LOAD_XXX constants can be used to control the */
/* glyph loading process (e.g., whether the outline */
/* should be scaled, whether to load bitmaps or not, */
/* whether to hint the outline, etc). */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static FT_Error
tt_glyph_load( FT_GlyphSlot ttslot, /* TT_GlyphSlot */
FT_Size ttsize, /* TT_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
{
TT_GlyphSlot slot = (TT_GlyphSlot)ttslot;
TT_Size size = (TT_Size)ttsize;
FT_Face face = ttslot->face;
FT_Error error;
if ( !slot )
return FT_THROW( Invalid_Slot_Handle );
if ( !size )
return FT_THROW( Invalid_Size_Handle );
if ( !face )
return FT_THROW( Invalid_Argument );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( glyph_index >= (FT_UInt)face->num_glyphs &&
!face->internal->incremental_interface )
#else
if ( glyph_index >= (FT_UInt)face->num_glyphs )
#endif
return FT_THROW( Invalid_Argument );
if ( load_flags & FT_LOAD_NO_HINTING )
{
/* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */
/* are necessary to disable hinting for tricky fonts */
if ( FT_IS_TRICKY( face ) )
load_flags &= ~FT_LOAD_NO_HINTING;
if ( load_flags & FT_LOAD_NO_AUTOHINT )
load_flags |= FT_LOAD_NO_HINTING;
}
if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) )
{
load_flags |= FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE;
if ( !FT_IS_TRICKY( face ) )
load_flags |= FT_LOAD_NO_HINTING;
}
/* now load the glyph outline if necessary */
error = TT_Load_Glyph( size, slot, glyph_index, load_flags );
/* force drop-out mode to 2 - irrelevant now */
/* slot->outline.dropout_mode = 2; */
return error;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** D R I V E R I N T E R F A C E ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICE_MULTIMASTERSREC(
tt_service_gx_multi_masters,
(FT_Get_MM_Func) NULL,
(FT_Set_MM_Design_Func) NULL,
(FT_Set_MM_Blend_Func) TT_Set_MM_Blend,
(FT_Get_MM_Var_Func) TT_Get_MM_Var,
(FT_Set_Var_Design_Func)TT_Set_Var_Design )
#endif
static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine =
{
#ifdef TT_USE_BYTECODE_INTERPRETER
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_TRUETYPE_ENGINE_TYPE_UNPATENTED
#else
FT_TRUETYPE_ENGINE_TYPE_PATENTED
#endif
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_TRUETYPE_ENGINE_TYPE_NONE
#endif /* TT_USE_BYTECODE_INTERPRETER */
};
FT_DEFINE_SERVICE_TTGLYFREC(
tt_service_truetype_glyf,
(TT_Glyf_GetLocationFunc)tt_face_get_location )
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC5(
tt_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE,
FT_SERVICE_ID_MULTI_MASTERS, &TT_SERVICE_GX_MULTI_MASTERS_GET,
FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
#else
FT_DEFINE_SERVICEDESCREC4(
tt_services,
FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE,
FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine,
FT_SERVICE_ID_TT_GLYF, &TT_SERVICE_TRUETYPE_GLYF_GET,
FT_SERVICE_ID_PROPERTIES, &TT_SERVICE_PROPERTIES_GET )
#endif
FT_CALLBACK_DEF( FT_Module_Interface )
tt_get_interface( FT_Module driver, /* TT_Driver */
const char* tt_interface )
{
FT_Library library;
FT_Module_Interface result;
FT_Module sfntd;
SFNT_Service sfnt;
/* TT_SERVICES_GET derefers `library' in PIC mode */
#ifdef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
library = driver->library;
if ( !library )
return NULL;
#endif
result = ft_service_list_lookup( TT_SERVICES_GET, tt_interface );
if ( result != NULL )
return result;
#ifndef FT_CONFIG_OPTION_PIC
if ( !driver )
return NULL;
library = driver->library;
if ( !library )
return NULL;
#endif
/* only return the default interface from the SFNT module */
sfntd = FT_Get_Module( library, "sfnt" );
if ( sfntd )
{
sfnt = (SFNT_Service)( sfntd->clazz->module_interface );
if ( sfnt )
return sfnt->get_interface( driver, tt_interface );
}
return 0;
}
/* The FT_DriverInterface structure is defined in ftdriver.h. */
#ifdef TT_USE_BYTECODE_INTERPRETER
#define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER
#else
#define TT_HINTER_FLAG 0
#endif
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#define TT_SIZE_SELECT tt_size_select
#else
#define TT_SIZE_SELECT 0
#endif
FT_DEFINE_DRIVER(
tt_driver_class,
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
TT_HINTER_FLAG,
sizeof ( TT_DriverRec ),
"truetype", /* driver name */
0x10000L, /* driver version == 1.0 */
0x20000L, /* driver requires FreeType 2.0 or above */
(void*)0, /* driver specific interface */
tt_driver_init,
tt_driver_done,
tt_get_interface,
sizeof ( TT_FaceRec ),
sizeof ( TT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
tt_face_init,
tt_face_done,
tt_size_init,
tt_size_done,
tt_slot_init,
0, /* FT_Slot_DoneFunc */
tt_glyph_load,
tt_get_kerning,
0, /* FT_Face_AttachFunc */
tt_get_advances,
tt_size_request,
TT_SIZE_SELECT
)
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttdriver.c | C | apache-2.0 | 19,676 |
/***************************************************************************/
/* */
/* ttdriver.h */
/* */
/* High-level TrueType driver interface (specification). */
/* */
/* Copyright 1996-2001, 2002 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 __TTDRIVER_H__
#define __TTDRIVER_H__
#include <ft2build.h>
#include FT_INTERNAL_DRIVER_H
FT_BEGIN_HEADER
FT_DECLARE_DRIVER( tt_driver_class )
FT_END_HEADER
#endif /* __TTDRIVER_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttdriver.h | C | apache-2.0 | 1,466 |
/***************************************************************************/
/* */
/* tterrors.h */
/* */
/* TrueType error codes (specification only). */
/* */
/* Copyright 2001, 2012 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the TrueType error enumeration */
/* constants. */
/* */
/*************************************************************************/
#ifndef __TTERRORS_H__
#define __TTERRORS_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX TT_Err_
#define FT_ERR_BASE FT_Mod_Err_TrueType
#include FT_ERRORS_H
#endif /* __TTERRORS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/tterrors.h | C | apache-2.0 | 1,976 |
/***************************************************************************/
/* */
/* ttgload.c */
/* */
/* TrueType Glyph Loader (body). */
/* */
/* Copyright 1996-2013 */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_TAGS_H
#include FT_OUTLINE_H
#include FT_TRUETYPE_DRIVER_H
#include "ttgload.h"
#include "ttpload.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
#include "tterrors.h"
#include "ttsubpix.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_ttgload
/*************************************************************************/
/* */
/* Composite glyph flags. */
/* */
#define ARGS_ARE_WORDS 0x0001
#define ARGS_ARE_XY_VALUES 0x0002
#define ROUND_XY_TO_GRID 0x0004
#define WE_HAVE_A_SCALE 0x0008
/* reserved 0x0010 */
#define MORE_COMPONENTS 0x0020
#define WE_HAVE_AN_XY_SCALE 0x0040
#define WE_HAVE_A_2X2 0x0080
#define WE_HAVE_INSTR 0x0100
#define USE_MY_METRICS 0x0200
#define OVERLAP_COMPOUND 0x0400
#define SCALED_COMPONENT_OFFSET 0x0800
#define UNSCALED_COMPONENT_OFFSET 0x1000
/*************************************************************************/
/* */
/* Return the horizontal metrics in font units for a given glyph. */
/* */
FT_LOCAL_DEF( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
FT_Short* lsb,
FT_UShort* aw )
{
( (SFNT_Service)face->sfnt )->get_metrics( face, 0, idx, lsb, aw );
FT_TRACE5(( " advance width (font units): %d\n", *aw ));
FT_TRACE5(( " left side bearing (font units): %d\n", *lsb ));
}
/*************************************************************************/
/* */
/* Return the vertical metrics in font units for a given glyph. */
/* See macro `TT_LOADER_SET_PP' below for explanations. */
/* */
FT_LOCAL_DEF( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
FT_Pos yMax,
FT_Short* tsb,
FT_UShort* ah )
{
if ( face->vertical_info )
( (SFNT_Service)face->sfnt )->get_metrics( face, 1, idx, tsb, ah );
else if ( face->os2.version != 0xFFFFU )
{
*tsb = face->os2.sTypoAscender - yMax;
*ah = face->os2.sTypoAscender - face->os2.sTypoDescender;
}
else
{
*tsb = face->horizontal.Ascender - yMax;
*ah = face->horizontal.Ascender - face->horizontal.Descender;
}
FT_TRACE5(( " advance height (font units): %d\n", *ah ));
FT_TRACE5(( " top side bearing (font units): %d\n", *tsb ));
}
static FT_Error
tt_get_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
TT_Face face = (TT_Face)loader->face;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
FT_Error error = FT_Err_Ok;
FT_Stream stream = loader->stream;
FT_Short left_bearing = 0, top_bearing = 0;
FT_UShort advance_width = 0, advance_height = 0;
/* we must preserve the stream position */
/* (which gets altered by the metrics functions) */
FT_ULong pos = FT_STREAM_POS();
TT_Get_HMetrics( face, glyph_index,
&left_bearing,
&advance_width );
TT_Get_VMetrics( face, glyph_index,
loader->bbox.yMax,
&top_bearing,
&advance_height );
if ( FT_STREAM_SEEK( pos ) )
return error;
loader->left_bearing = left_bearing;
loader->advance = advance_width;
loader->top_bearing = top_bearing;
loader->vadvance = advance_height;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
if ( loader->exec )
loader->exec->sph_tweak_flags = 0;
/* this may not be the right place for this, but it works */
if ( loader->exec && loader->exec->ignore_x_mode )
sph_set_tweaks( loader, glyph_index );
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( !loader->linear_def )
{
loader->linear_def = 1;
loader->linear = advance_width;
}
return FT_Err_Ok;
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
static void
tt_get_metrics_incr_overrides( TT_Loader loader,
FT_UInt glyph_index )
{
TT_Face face = (TT_Face)loader->face;
FT_Short left_bearing = 0, top_bearing = 0;
FT_UShort advance_width = 0, advance_height = 0;
/* If this is an incrementally loaded font check whether there are */
/* overriding metrics for this glyph. */
if ( face->root.internal->incremental_interface &&
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
{
FT_Incremental_MetricsRec metrics;
FT_Error error;
metrics.bearing_x = loader->left_bearing;
metrics.bearing_y = 0;
metrics.advance = loader->advance;
metrics.advance_v = 0;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
glyph_index, FALSE, &metrics );
if ( error )
goto Exit;
left_bearing = (FT_Short)metrics.bearing_x;
advance_width = (FT_UShort)metrics.advance;
#if 0
/* GWW: Do I do the same for vertical metrics? */
metrics.bearing_x = 0;
metrics.bearing_y = loader->top_bearing;
metrics.advance = loader->vadvance;
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
face->root.internal->incremental_interface->object,
glyph_index, TRUE, &metrics );
if ( error )
goto Exit;
top_bearing = (FT_Short)metrics.bearing_y;
advance_height = (FT_UShort)metrics.advance;
#endif /* 0 */
loader->left_bearing = left_bearing;
loader->advance = advance_width;
loader->top_bearing = top_bearing;
loader->vadvance = advance_height;
if ( !loader->linear_def )
{
loader->linear_def = 1;
loader->linear = advance_width;
}
}
Exit:
return;
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/*************************************************************************/
/* */
/* Translates an array of coordinates. */
/* */
static void
translate_array( FT_UInt n,
FT_Vector* coords,
FT_Pos delta_x,
FT_Pos delta_y )
{
FT_UInt k;
if ( delta_x )
for ( k = 0; k < n; k++ )
coords[k].x += delta_x;
if ( delta_y )
for ( k = 0; k < n; k++ )
coords[k].y += delta_y;
}
/*************************************************************************/
/* */
/* The following functions are used by default with TrueType fonts. */
/* However, they can be replaced by alternatives if we need to support */
/* TrueType-compressed formats (like MicroType) in the future. */
/* */
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
TT_Access_Glyph_Frame( TT_Loader loader,
FT_UInt glyph_index,
FT_ULong offset,
FT_UInt byte_count )
{
FT_Error error = FT_Err_Ok;
FT_Stream stream = loader->stream;
/* for non-debug mode */
FT_UNUSED( glyph_index );
FT_TRACE4(( "Glyph %ld\n", glyph_index ));
/* the following line sets the `error' variable through macros! */
if ( FT_STREAM_SEEK( offset ) || FT_FRAME_ENTER( byte_count ) )
return error;
loader->cursor = stream->cursor;
loader->limit = stream->limit;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( void )
TT_Forget_Glyph_Frame( TT_Loader loader )
{
FT_Stream stream = loader->stream;
FT_FRAME_EXIT();
}
FT_CALLBACK_DEF( FT_Error )
TT_Load_Glyph_Header( TT_Loader loader )
{
FT_Byte* p = loader->cursor;
FT_Byte* limit = loader->limit;
if ( p + 10 > limit )
return FT_THROW( Invalid_Outline );
loader->n_contours = FT_NEXT_SHORT( p );
loader->bbox.xMin = FT_NEXT_SHORT( p );
loader->bbox.yMin = FT_NEXT_SHORT( p );
loader->bbox.xMax = FT_NEXT_SHORT( p );
loader->bbox.yMax = FT_NEXT_SHORT( p );
FT_TRACE5(( " # of contours: %d\n", loader->n_contours ));
FT_TRACE5(( " xMin: %4d xMax: %4d\n", loader->bbox.xMin,
loader->bbox.xMax ));
FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin,
loader->bbox.yMax ));
loader->cursor = p;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
TT_Load_Simple_Glyph( TT_Loader load )
{
FT_Error error;
FT_Byte* p = load->cursor;
FT_Byte* limit = load->limit;
FT_GlyphLoader gloader = load->gloader;
FT_Int n_contours = load->n_contours;
FT_Outline* outline;
FT_UShort n_ins;
FT_Int n_points;
FT_ULong tmp;
FT_Byte *flag, *flag_limit;
FT_Byte c, count;
FT_Vector *vec, *vec_limit;
FT_Pos x;
FT_Short *cont, *cont_limit, prev_cont;
FT_Int xy_size = 0;
/* check that we can add the contours to the glyph */
error = FT_GLYPHLOADER_CHECK_POINTS( gloader, 0, n_contours );
if ( error )
goto Fail;
/* reading the contours' endpoints & number of points */
cont = gloader->current.outline.contours;
cont_limit = cont + n_contours;
/* check space for contours array + instructions count */
if ( n_contours >= 0xFFF || p + ( n_contours + 1 ) * 2 > limit )
goto Invalid_Outline;
prev_cont = FT_NEXT_SHORT( p );
if ( n_contours > 0 )
cont[0] = prev_cont;
if ( prev_cont < 0 )
goto Invalid_Outline;
for ( cont++; cont < cont_limit; cont++ )
{
cont[0] = FT_NEXT_SHORT( p );
if ( cont[0] <= prev_cont )
{
/* unordered contours: this is invalid */
goto Invalid_Outline;
}
prev_cont = cont[0];
}
n_points = 0;
if ( n_contours > 0 )
{
n_points = cont[-1] + 1;
if ( n_points < 0 )
goto Invalid_Outline;
}
/* note that we will add four phantom points later */
error = FT_GLYPHLOADER_CHECK_POINTS( gloader, n_points + 4, 0 );
if ( error )
goto Fail;
/* reading the bytecode instructions */
load->glyph->control_len = 0;
load->glyph->control_data = 0;
if ( p + 2 > limit )
goto Invalid_Outline;
n_ins = FT_NEXT_USHORT( p );
FT_TRACE5(( " Instructions size: %u\n", n_ins ));
/* check it */
if ( ( limit - p ) < n_ins )
{
FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" ));
error = FT_THROW( Too_Many_Hints );
goto Fail;
}
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( IS_HINTED( load->load_flags ) )
{
/* we don't trust `maxSizeOfInstructions' in the `maxp' table */
/* and thus update the bytecode array size by ourselves */
tmp = load->exec->glyphSize;
error = Update_Max( load->exec->memory,
&tmp,
sizeof ( FT_Byte ),
(void*)&load->exec->glyphIns,
n_ins );
load->exec->glyphSize = (FT_UShort)tmp;
if ( error )
return error;
load->glyph->control_len = n_ins;
load->glyph->control_data = load->exec->glyphIns;
FT_MEM_COPY( load->exec->glyphIns, p, (FT_Long)n_ins );
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
p += n_ins;
outline = &gloader->current.outline;
/* reading the point tags */
flag = (FT_Byte*)outline->tags;
flag_limit = flag + n_points;
FT_ASSERT( flag != NULL );
while ( flag < flag_limit )
{
if ( p + 1 > limit )
goto Invalid_Outline;
*flag++ = c = FT_NEXT_BYTE( p );
if ( c & 8 )
{
if ( p + 1 > limit )
goto Invalid_Outline;
count = FT_NEXT_BYTE( p );
if ( flag + (FT_Int)count > flag_limit )
goto Invalid_Outline;
for ( ; count > 0; count-- )
*flag++ = c;
}
}
/* reading the X coordinates */
vec = outline->points;
vec_limit = vec + n_points;
flag = (FT_Byte*)outline->tags;
x = 0;
if ( p + xy_size > limit )
goto Invalid_Outline;
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
FT_Byte f = *flag;
if ( f & 2 )
{
if ( p + 1 > limit )
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_BYTE( p );
if ( ( f & 16 ) == 0 )
y = -y;
}
else if ( ( f & 16 ) == 0 )
{
if ( p + 2 > limit )
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_SHORT( p );
}
x += y;
vec->x = x;
/* the cast is for stupid compilers */
*flag = (FT_Byte)( f & ~( 2 | 16 ) );
}
/* reading the Y coordinates */
vec = gloader->current.outline.points;
vec_limit = vec + n_points;
flag = (FT_Byte*)outline->tags;
x = 0;
for ( ; vec < vec_limit; vec++, flag++ )
{
FT_Pos y = 0;
FT_Byte f = *flag;
if ( f & 4 )
{
if ( p + 1 > limit )
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_BYTE( p );
if ( ( f & 32 ) == 0 )
y = -y;
}
else if ( ( f & 32 ) == 0 )
{
if ( p + 2 > limit )
goto Invalid_Outline;
y = (FT_Pos)FT_NEXT_SHORT( p );
}
x += y;
vec->y = x;
/* the cast is for stupid compilers */
*flag = (FT_Byte)( f & FT_CURVE_TAG_ON );
}
outline->n_points = (FT_UShort)n_points;
outline->n_contours = (FT_Short) n_contours;
load->cursor = p;
Fail:
return error;
Invalid_Outline:
error = FT_THROW( Invalid_Outline );
goto Fail;
}
FT_CALLBACK_DEF( FT_Error )
TT_Load_Composite_Glyph( TT_Loader loader )
{
FT_Error error;
FT_Byte* p = loader->cursor;
FT_Byte* limit = loader->limit;
FT_GlyphLoader gloader = loader->gloader;
FT_SubGlyph subglyph;
FT_UInt num_subglyphs;
num_subglyphs = 0;
do
{
FT_Fixed xx, xy, yy, yx;
FT_UInt count;
/* check that we can load a new subglyph */
error = FT_GlyphLoader_CheckSubGlyphs( gloader, num_subglyphs + 1 );
if ( error )
goto Fail;
/* check space */
if ( p + 4 > limit )
goto Invalid_Composite;
subglyph = gloader->current.subglyphs + num_subglyphs;
subglyph->arg1 = subglyph->arg2 = 0;
subglyph->flags = FT_NEXT_USHORT( p );
subglyph->index = FT_NEXT_USHORT( p );
/* check space */
count = 2;
if ( subglyph->flags & ARGS_ARE_WORDS )
count += 2;
if ( subglyph->flags & WE_HAVE_A_SCALE )
count += 2;
else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
count += 4;
else if ( subglyph->flags & WE_HAVE_A_2X2 )
count += 8;
if ( p + count > limit )
goto Invalid_Composite;
/* read arguments */
if ( subglyph->flags & ARGS_ARE_WORDS )
{
subglyph->arg1 = FT_NEXT_SHORT( p );
subglyph->arg2 = FT_NEXT_SHORT( p );
}
else
{
subglyph->arg1 = FT_NEXT_CHAR( p );
subglyph->arg2 = FT_NEXT_CHAR( p );
}
/* read transform */
xx = yy = 0x10000L;
xy = yx = 0;
if ( subglyph->flags & WE_HAVE_A_SCALE )
{
xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
yy = xx;
}
else if ( subglyph->flags & WE_HAVE_AN_XY_SCALE )
{
xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
}
else if ( subglyph->flags & WE_HAVE_A_2X2 )
{
xx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
yx = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
xy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
yy = (FT_Fixed)FT_NEXT_SHORT( p ) << 2;
}
subglyph->transform.xx = xx;
subglyph->transform.xy = xy;
subglyph->transform.yx = yx;
subglyph->transform.yy = yy;
num_subglyphs++;
} while ( subglyph->flags & MORE_COMPONENTS );
gloader->current.num_subglyphs = num_subglyphs;
#ifdef TT_USE_BYTECODE_INTERPRETER
{
FT_Stream stream = loader->stream;
/* we must undo the FT_FRAME_ENTER in order to point */
/* to the composite instructions, if we find some. */
/* We will process them later. */
/* */
loader->ins_pos = (FT_ULong)( FT_STREAM_POS() +
p - limit );
}
#endif
loader->cursor = p;
Fail:
return error;
Invalid_Composite:
error = FT_THROW( Invalid_Composite );
goto Fail;
}
FT_LOCAL_DEF( void )
TT_Init_Glyph_Loading( TT_Face face )
{
face->access_glyph_frame = TT_Access_Glyph_Frame;
face->read_glyph_header = TT_Load_Glyph_Header;
face->read_simple_glyph = TT_Load_Simple_Glyph;
face->read_composite_glyph = TT_Load_Composite_Glyph;
face->forget_glyph_frame = TT_Forget_Glyph_Frame;
}
static void
tt_prepare_zone( TT_GlyphZone zone,
FT_GlyphLoad load,
FT_UInt start_point,
FT_UInt start_contour )
{
zone->n_points = (FT_UShort)( load->outline.n_points - start_point );
zone->n_contours = (FT_Short) ( load->outline.n_contours -
start_contour );
zone->org = load->extra_points + start_point;
zone->cur = load->outline.points + start_point;
zone->orus = load->extra_points2 + start_point;
zone->tags = (FT_Byte*)load->outline.tags + start_point;
zone->contours = (FT_UShort*)load->outline.contours + start_contour;
zone->first_point = (FT_UShort)start_point;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Hint_Glyph */
/* */
/* <Description> */
/* Hint the glyph using the zone prepared by the caller. Note that */
/* the zone is supposed to include four phantom points. */
/* */
static FT_Error
TT_Hint_Glyph( TT_Loader loader,
FT_Bool is_composite )
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Face face = (TT_Face)loader->face;
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
TT_GlyphZone zone = &loader->zone;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_UInt n_ins;
#else
FT_UNUSED( is_composite );
#endif
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( loader->glyph->control_len > 0xFFFFL )
{
FT_TRACE1(( "TT_Hint_Glyph: too long instructions" ));
FT_TRACE1(( " (0x%lx byte) is truncated\n",
loader->glyph->control_len ));
}
n_ins = (FT_UInt)( loader->glyph->control_len );
/* save original point position in org */
if ( n_ins > 0 )
FT_ARRAY_COPY( zone->org, zone->cur, zone->n_points );
/* Reset graphics state. */
loader->exec->GS = ((TT_Size)loader->size)->GS;
/* XXX: UNDOCUMENTED! Hinting instructions of a composite glyph */
/* completely refer to the (already) hinted subglyphs. */
if ( is_composite )
{
loader->exec->metrics.x_scale = 1 << 16;
loader->exec->metrics.y_scale = 1 << 16;
FT_ARRAY_COPY( zone->orus, zone->cur, zone->n_points );
}
else
{
loader->exec->metrics.x_scale =
((TT_Size)loader->size)->metrics.x_scale;
loader->exec->metrics.y_scale =
((TT_Size)loader->size)->metrics.y_scale;
}
#endif
/* round phantom points */
zone->cur[zone->n_points - 4].x =
FT_PIX_ROUND( zone->cur[zone->n_points - 4].x );
zone->cur[zone->n_points - 3].x =
FT_PIX_ROUND( zone->cur[zone->n_points - 3].x );
zone->cur[zone->n_points - 2].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 2].y );
zone->cur[zone->n_points - 1].y =
FT_PIX_ROUND( zone->cur[zone->n_points - 1].y );
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( n_ins > 0 )
{
FT_Bool debug;
FT_Error error;
FT_GlyphLoader gloader = loader->gloader;
FT_Outline current_outline = gloader->current.outline;
error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph,
loader->exec->glyphIns, n_ins );
if ( error )
return error;
loader->exec->is_composite = is_composite;
loader->exec->pts = *zone;
debug = FT_BOOL( !( loader->load_flags & FT_LOAD_NO_SCALE ) &&
((TT_Size)loader->size)->debug );
error = TT_Run_Context( loader->exec, debug );
if ( error && loader->exec->pedantic_hinting )
return error;
/* store drop-out mode in bits 5-7; set bit 2 also as a marker */
current_outline.tags[0] |=
( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE;
}
#endif
/* save glyph phantom points */
loader->pp1 = zone->cur[zone->n_points - 4];
loader->pp2 = zone->cur[zone->n_points - 3];
loader->pp3 = zone->cur[zone->n_points - 2];
loader->pp4 = zone->cur[zone->n_points - 1];
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
if ( loader->exec->sph_tweak_flags & SPH_TWEAK_DEEMBOLDEN )
FT_Outline_EmboldenXY( &loader->gloader->current.outline, -24, 0 );
else if ( loader->exec->sph_tweak_flags & SPH_TWEAK_EMBOLDEN )
FT_Outline_EmboldenXY( &loader->gloader->current.outline, 24, 0 );
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Process_Simple_Glyph */
/* */
/* <Description> */
/* Once a simple glyph has been loaded, it needs to be processed. */
/* Usually, this means scaling and hinting through bytecode */
/* interpretation. */
/* */
static FT_Error
TT_Process_Simple_Glyph( TT_Loader loader )
{
FT_GlyphLoader gloader = loader->gloader;
FT_Error error = FT_Err_Ok;
FT_Outline* outline;
FT_Int n_points;
outline = &gloader->current.outline;
n_points = outline->n_points;
/* set phantom points */
outline->points[n_points ] = loader->pp1;
outline->points[n_points + 1] = loader->pp2;
outline->points[n_points + 2] = loader->pp3;
outline->points[n_points + 3] = loader->pp4;
outline->tags[n_points ] = 0;
outline->tags[n_points + 1] = 0;
outline->tags[n_points + 2] = 0;
outline->tags[n_points + 3] = 0;
n_points += 4;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( ((TT_Face)loader->face)->doblend )
{
/* Deltas apply to the unscaled data. */
FT_Vector* deltas;
FT_Memory memory = loader->face->memory;
FT_Int i;
error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
loader->glyph_index,
&deltas,
n_points );
if ( error )
return error;
for ( i = 0; i < n_points; ++i )
{
outline->points[i].x += deltas[i].x;
outline->points[i].y += deltas[i].y;
}
FT_FREE( deltas );
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
if ( IS_HINTED( loader->load_flags ) )
{
tt_prepare_zone( &loader->zone, &gloader->current, 0, 0 );
FT_ARRAY_COPY( loader->zone.orus, loader->zone.cur,
loader->zone.n_points + 4 );
}
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Face face = (TT_Face)loader->face;
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
FT_String* family = face->root.family_name;
FT_Int ppem = loader->size->metrics.x_ppem;
FT_String* style = face->root.style_name;
FT_Int x_scale_factor = 1000;
#endif
FT_Vector* vec = outline->points;
FT_Vector* limit = outline->points + n_points;
FT_Fixed x_scale = 0; /* pacify compiler */
FT_Fixed y_scale = 0;
FT_Bool do_scale = FALSE;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
/* scale, but only if enabled and only if TT hinting is being used */
if ( IS_HINTED( loader->load_flags ) )
x_scale_factor = sph_test_tweak_x_scaling( face,
family,
ppem,
style,
loader->glyph_index );
/* scale the glyph */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 ||
x_scale_factor != 1000 )
{
x_scale = FT_MulDiv( ((TT_Size)loader->size)->metrics.x_scale,
x_scale_factor, 1000 );
y_scale = ((TT_Size)loader->size)->metrics.y_scale;
/* compensate for any scaling by de/emboldening; */
/* the amount was determined via experimentation */
if ( x_scale_factor != 1000 && ppem > 11 )
FT_Outline_EmboldenXY( outline,
FT_MulFix( 1280 * ppem,
1000 - x_scale_factor ),
0 );
do_scale = TRUE;
}
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
{
/* scale the glyph */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
x_scale = ((TT_Size)loader->size)->metrics.x_scale;
y_scale = ((TT_Size)loader->size)->metrics.y_scale;
do_scale = TRUE;
}
}
if ( do_scale )
{
for ( ; vec < limit; vec++ )
{
vec->x = FT_MulFix( vec->x, x_scale );
vec->y = FT_MulFix( vec->y, y_scale );
}
loader->pp1 = outline->points[n_points - 4];
loader->pp2 = outline->points[n_points - 3];
loader->pp3 = outline->points[n_points - 2];
loader->pp4 = outline->points[n_points - 1];
}
}
if ( IS_HINTED( loader->load_flags ) )
{
loader->zone.n_points += 4;
error = TT_Hint_Glyph( loader, 0 );
}
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Process_Composite_Component */
/* */
/* <Description> */
/* Once a composite component has been loaded, it needs to be */
/* processed. Usually, this means transforming and translating. */
/* */
static FT_Error
TT_Process_Composite_Component( TT_Loader loader,
FT_SubGlyph subglyph,
FT_UInt start_point,
FT_UInt num_base_points )
{
FT_GlyphLoader gloader = loader->gloader;
FT_Vector* base_vec = gloader->base.outline.points;
FT_UInt num_points = gloader->base.outline.n_points;
FT_Bool have_scale;
FT_Pos x, y;
have_scale = FT_BOOL( subglyph->flags & ( WE_HAVE_A_SCALE |
WE_HAVE_AN_XY_SCALE |
WE_HAVE_A_2X2 ) );
/* perform the transform required for this subglyph */
if ( have_scale )
{
FT_UInt i;
for ( i = num_base_points; i < num_points; i++ )
FT_Vector_Transform( base_vec + i, &subglyph->transform );
}
/* get offset */
if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
{
FT_UInt k = subglyph->arg1;
FT_UInt l = subglyph->arg2;
FT_Vector* p1;
FT_Vector* p2;
/* match l-th point of the newly loaded component to the k-th point */
/* of the previously loaded components. */
/* change to the point numbers used by our outline */
k += start_point;
l += num_base_points;
if ( k >= num_base_points ||
l >= num_points )
return FT_THROW( Invalid_Composite );
p1 = gloader->base.outline.points + k;
p2 = gloader->base.outline.points + l;
x = p1->x - p2->x;
y = p1->y - p2->y;
}
else
{
x = subglyph->arg1;
y = subglyph->arg2;
if ( !x && !y )
return FT_Err_Ok;
/* Use a default value dependent on */
/* TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED. This is useful for old */
/* TT fonts which don't set the xxx_COMPONENT_OFFSET bit. */
if ( have_scale &&
#ifdef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
!( subglyph->flags & UNSCALED_COMPONENT_OFFSET ) )
#else
( subglyph->flags & SCALED_COMPONENT_OFFSET ) )
#endif
{
#if 0
/*******************************************************************/
/* */
/* This algorithm is what Apple documents. But it doesn't work. */
/* */
int a = subglyph->transform.xx > 0 ? subglyph->transform.xx
: -subglyph->transform.xx;
int b = subglyph->transform.yx > 0 ? subglyph->transform.yx
: -subglyph->transform.yx;
int c = subglyph->transform.xy > 0 ? subglyph->transform.xy
: -subglyph->transform.xy;
int d = subglyph->transform.yy > 0 ? subglyph->transform.yy
: -subglyph->transform.yy;
int m = a > b ? a : b;
int n = c > d ? c : d;
if ( a - b <= 33 && a - b >= -33 )
m *= 2;
if ( c - d <= 33 && c - d >= -33 )
n *= 2;
x = FT_MulFix( x, m );
y = FT_MulFix( y, n );
#else /* 1 */
/*******************************************************************/
/* */
/* This algorithm is a guess and works much better than the above. */
/* */
FT_Fixed mac_xscale = FT_Hypot( subglyph->transform.xx,
subglyph->transform.xy );
FT_Fixed mac_yscale = FT_Hypot( subglyph->transform.yy,
subglyph->transform.yx );
x = FT_MulFix( x, mac_xscale );
y = FT_MulFix( y, mac_yscale );
#endif /* 1 */
}
if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
{
FT_Fixed x_scale = ((TT_Size)loader->size)->metrics.x_scale;
FT_Fixed y_scale = ((TT_Size)loader->size)->metrics.y_scale;
x = FT_MulFix( x, x_scale );
y = FT_MulFix( y, y_scale );
if ( subglyph->flags & ROUND_XY_TO_GRID )
{
x = FT_PIX_ROUND( x );
y = FT_PIX_ROUND( y );
}
}
}
if ( x || y )
translate_array( num_points - num_base_points,
base_vec + num_base_points,
x, y );
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Process_Composite_Glyph */
/* */
/* <Description> */
/* This is slightly different from TT_Process_Simple_Glyph, in that */
/* its sole purpose is to hint the glyph. Thus this function is */
/* only available when bytecode interpreter is enabled. */
/* */
static FT_Error
TT_Process_Composite_Glyph( TT_Loader loader,
FT_UInt start_point,
FT_UInt start_contour )
{
FT_Error error;
FT_Outline* outline;
FT_UInt i;
outline = &loader->gloader->base.outline;
/* make room for phantom points */
error = FT_GLYPHLOADER_CHECK_POINTS( loader->gloader,
outline->n_points + 4,
0 );
if ( error )
return error;
outline->points[outline->n_points ] = loader->pp1;
outline->points[outline->n_points + 1] = loader->pp2;
outline->points[outline->n_points + 2] = loader->pp3;
outline->points[outline->n_points + 3] = loader->pp4;
outline->tags[outline->n_points ] = 0;
outline->tags[outline->n_points + 1] = 0;
outline->tags[outline->n_points + 2] = 0;
outline->tags[outline->n_points + 3] = 0;
#ifdef TT_USE_BYTECODE_INTERPRETER
{
FT_Stream stream = loader->stream;
FT_UShort n_ins, max_ins;
FT_ULong tmp;
/* TT_Load_Composite_Glyph only gives us the offset of instructions */
/* so we read them here */
if ( FT_STREAM_SEEK( loader->ins_pos ) ||
FT_READ_USHORT( n_ins ) )
return error;
FT_TRACE5(( " Instructions size = %d\n", n_ins ));
/* check it */
max_ins = ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions;
if ( n_ins > max_ins )
{
/* don't trust `maxSizeOfInstructions'; */
/* only do a rough safety check */
if ( (FT_Int)n_ins > loader->byte_len )
{
FT_TRACE1(( "TT_Process_Composite_Glyph:"
" too many instructions (%d) for glyph with length %d\n",
n_ins, loader->byte_len ));
return FT_THROW( Too_Many_Hints );
}
tmp = loader->exec->glyphSize;
error = Update_Max( loader->exec->memory,
&tmp,
sizeof ( FT_Byte ),
(void*)&loader->exec->glyphIns,
n_ins );
loader->exec->glyphSize = (FT_UShort)tmp;
if ( error )
return error;
}
else if ( n_ins == 0 )
return FT_Err_Ok;
if ( FT_STREAM_READ( loader->exec->glyphIns, n_ins ) )
return error;
loader->glyph->control_data = loader->exec->glyphIns;
loader->glyph->control_len = n_ins;
}
#endif
tt_prepare_zone( &loader->zone, &loader->gloader->base,
start_point, start_contour );
/* Some points are likely touched during execution of */
/* instructions on components. So let's untouch them. */
for ( i = 0; i < loader->zone.n_points; i++ )
loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH;
loader->zone.n_points += 4;
return TT_Hint_Glyph( loader, 1 );
}
/*
* Calculate the phantom points
*
* Defining the right side bearing (rsb) as
*
* rsb = aw - (lsb + xmax - xmin)
*
* (with `aw' the advance width, `lsb' the left side bearing, and `xmin'
* and `xmax' the glyph's minimum and maximum x value), the OpenType
* specification defines the initial position of horizontal phantom points
* as
*
* pp1 = (round(xmin - lsb), 0) ,
* pp2 = (round(pp1 + aw), 0) .
*
* Note that the rounding to the grid (in the device space) is not
* documented currently in the specification.
*
* However, the specification lacks the precise definition of vertical
* phantom points. Greg Hitchcock provided the following explanation.
*
* - a `vmtx' table is present
*
* For any glyph, the minimum and maximum y values (`ymin' and `ymax')
* are given in the `glyf' table, the top side bearing (tsb) and advance
* height (ah) are given in the `vmtx' table. The bottom side bearing
* (bsb) is then calculated as
*
* bsb = ah - (tsb + ymax - ymin) ,
*
* and the initial position of vertical phantom points is
*
* pp3 = (x, round(ymax + tsb)) ,
* pp4 = (x, round(pp3 - ah)) .
*
* See below for value `x'.
*
* - no `vmtx' table in the font
*
* If there is an `OS/2' table, we set
*
* DefaultAscender = sTypoAscender ,
* DefaultDescender = sTypoDescender ,
*
* otherwise we use data from the `hhea' table:
*
* DefaultAscender = Ascender ,
* DefaultDescender = Descender .
*
* With these two variables we can now set
*
* ah = DefaultAscender - sDefaultDescender ,
* tsb = DefaultAscender - yMax ,
*
* and proceed as if a `vmtx' table was present.
*
* Usually we have
*
* x = aw / 2 , (1)
*
* but there is one compatibility case where it can be set to
*
* x = -DefaultDescender -
* ((DefaultAscender - DefaultDescender - aw) / 2) . (2)
*
* and another one with
*
* x = 0 . (3)
*
* In Windows, the history of those values is quite complicated,
* depending on the hinting engine (that is, the graphics framework).
*
* framework from to formula
* ----------------------------------------------------------
* GDI Windows 98 current (1)
* (Windows 2000 for NT)
* GDI+ Windows XP Windows 7 (2)
* GDI+ Windows 8 current (3)
* DWrite Windows 7 current (3)
*
* For simplicity, FreeType uses (1) for grayscale subpixel hinting and
* (3) for everything else.
*
*/
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
#define TT_LOADER_SET_PP( loader ) \
do \
{ \
FT_Bool subpixel_ = loader->exec ? loader->exec->subpixel \
: 0; \
FT_Bool grayscale_ = loader->exec ? loader->exec->grayscale \
: 0; \
FT_Bool use_aw_2_ = (FT_Bool)( subpixel_ && grayscale_ ); \
\
\
(loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
(loader)->pp1.y = 0; \
(loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
(loader)->pp2.y = 0; \
\
(loader)->pp3.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
(loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
(loader)->pp4.x = use_aw_2_ ? (loader)->advance / 2 : 0; \
(loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
} while ( 0 )
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#define TT_LOADER_SET_PP( loader ) \
do \
{ \
(loader)->pp1.x = (loader)->bbox.xMin - (loader)->left_bearing; \
(loader)->pp1.y = 0; \
(loader)->pp2.x = (loader)->pp1.x + (loader)->advance; \
(loader)->pp2.y = 0; \
\
(loader)->pp3.x = 0; \
(loader)->pp3.y = (loader)->bbox.yMax + (loader)->top_bearing; \
(loader)->pp4.x = 0; \
(loader)->pp4.y = (loader)->pp3.y - (loader)->vadvance; \
} while ( 0 )
#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/*************************************************************************/
/* */
/* <Function> */
/* load_truetype_glyph */
/* */
/* <Description> */
/* Loads a given truetype glyph. Handles composites and uses a */
/* TT_Loader object. */
/* */
static FT_Error
load_truetype_glyph( TT_Loader loader,
FT_UInt glyph_index,
FT_UInt recurse_count,
FT_Bool header_only )
{
FT_Error error = FT_Err_Ok;
FT_Fixed x_scale, y_scale;
FT_ULong offset;
TT_Face face = (TT_Face)loader->face;
FT_GlyphLoader gloader = loader->gloader;
FT_Bool opened_frame = 0;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Vector* deltas = NULL;
#endif
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_StreamRec inc_stream;
FT_Data glyph_data;
FT_Bool glyph_data_loaded = 0;
#endif
/* some fonts have an incorrect value of `maxComponentDepth', */
/* thus we allow depth 1 to catch the majority of them */
if ( recurse_count > 1 &&
recurse_count > face->max_profile.maxComponentDepth )
{
error = FT_THROW( Invalid_Composite );
goto Exit;
}
/* check glyph index */
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
{
error = FT_THROW( Invalid_Glyph_Index );
goto Exit;
}
loader->glyph_index = glyph_index;
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
x_scale = ((TT_Size)loader->size)->metrics.x_scale;
y_scale = ((TT_Size)loader->size)->metrics.y_scale;
}
else
{
x_scale = 0x10000L;
y_scale = 0x10000L;
}
/* Set `offset' to the start of the glyph relative to the start of */
/* the `glyf' table, and `byte_len' to the length of the glyph in */
/* bytes. */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* If we are loading glyph data via the incremental interface, set */
/* the loader stream to a memory stream reading the data returned */
/* by the interface. */
if ( face->root.internal->incremental_interface )
{
error = face->root.internal->incremental_interface->funcs->get_glyph_data(
face->root.internal->incremental_interface->object,
glyph_index, &glyph_data );
if ( error )
goto Exit;
glyph_data_loaded = 1;
offset = 0;
loader->byte_len = glyph_data.length;
FT_MEM_ZERO( &inc_stream, sizeof ( inc_stream ) );
FT_Stream_OpenMemory( &inc_stream,
glyph_data.pointer, glyph_data.length );
loader->stream = &inc_stream;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
offset = tt_face_get_location( face, glyph_index,
(FT_UInt*)&loader->byte_len );
if ( loader->byte_len > 0 )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* for the incremental interface, `glyf_offset' is always zero */
if ( !loader->glyf_offset &&
!face->root.internal->incremental_interface )
#else
if ( !loader->glyf_offset )
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
{
FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
error = face->access_glyph_frame( loader, glyph_index,
loader->glyf_offset + offset,
loader->byte_len );
if ( error )
goto Exit;
opened_frame = 1;
/* read glyph header first */
error = face->read_glyph_header( loader );
if ( error )
goto Exit;
/* the metrics must be computed after loading the glyph header */
/* since we need the glyph's `yMax' value in case the vertical */
/* metrics must be emulated */
error = tt_get_metrics( loader, glyph_index );
if ( error )
goto Exit;
if ( header_only )
goto Exit;
}
if ( loader->byte_len == 0 || loader->n_contours == 0 )
{
loader->bbox.xMin = 0;
loader->bbox.xMax = 0;
loader->bbox.yMin = 0;
loader->bbox.yMax = 0;
error = tt_get_metrics( loader, glyph_index );
if ( error )
goto Exit;
if ( header_only )
goto Exit;
/* must initialize points before (possibly) overriding */
/* glyph metrics from the incremental interface */
TT_LOADER_SET_PP( loader );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
tt_get_metrics_incr_overrides( loader, glyph_index );
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( ((TT_Face)(loader->face))->doblend )
{
/* this must be done before scaling */
FT_Memory memory = loader->face->memory;
error = TT_Vary_Get_Glyph_Deltas( (TT_Face)(loader->face),
glyph_index, &deltas, 4 );
if ( error )
goto Exit;
loader->pp1.x += deltas[0].x;
loader->pp1.y += deltas[0].y;
loader->pp2.x += deltas[1].x;
loader->pp2.y += deltas[1].y;
loader->pp3.x += deltas[2].x;
loader->pp3.y += deltas[2].y;
loader->pp4.x += deltas[3].x;
loader->pp4.y += deltas[3].y;
FT_FREE( deltas );
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* scale phantom points, if necessary; */
/* they get rounded in `TT_Hint_Glyph' */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
/* pp1.y and pp2.y are always zero */
loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
}
error = FT_Err_Ok;
goto Exit;
}
/* must initialize phantom points before (possibly) overriding */
/* glyph metrics from the incremental interface */
TT_LOADER_SET_PP( loader );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
tt_get_metrics_incr_overrides( loader, glyph_index );
#endif
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/* if it is a simple glyph, load it */
if ( loader->n_contours > 0 )
{
error = face->read_simple_glyph( loader );
if ( error )
goto Exit;
/* all data have been read */
face->forget_glyph_frame( loader );
opened_frame = 0;
error = TT_Process_Simple_Glyph( loader );
if ( error )
goto Exit;
FT_GlyphLoader_Add( gloader );
}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/* otherwise, load a composite! */
else if ( loader->n_contours == -1 )
{
FT_UInt start_point;
FT_UInt start_contour;
FT_ULong ins_pos; /* position of composite instructions, if any */
start_point = gloader->base.outline.n_points;
start_contour = gloader->base.outline.n_contours;
/* for each subglyph, read composite header */
error = face->read_composite_glyph( loader );
if ( error )
goto Exit;
/* store the offset of instructions */
ins_pos = loader->ins_pos;
/* all data we need are read */
face->forget_glyph_frame( loader );
opened_frame = 0;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( face->doblend )
{
FT_Int i, limit;
FT_SubGlyph subglyph;
FT_Memory memory = face->root.memory;
/* this provides additional offsets */
/* for each component's translation */
if ( ( error = TT_Vary_Get_Glyph_Deltas(
face,
glyph_index,
&deltas,
gloader->current.num_subglyphs + 4 ) ) != 0 )
goto Exit;
subglyph = gloader->current.subglyphs + gloader->base.num_subglyphs;
limit = gloader->current.num_subglyphs;
for ( i = 0; i < limit; ++i, ++subglyph )
{
if ( subglyph->flags & ARGS_ARE_XY_VALUES )
{
/* XXX: overflow check for subglyph->{arg1,arg2}. */
/* deltas[i].{x,y} must be within signed 16-bit, */
/* but the restriction of summed delta is not clear */
subglyph->arg1 += (FT_Int16)deltas[i].x;
subglyph->arg2 += (FT_Int16)deltas[i].y;
}
}
loader->pp1.x += deltas[i + 0].x;
loader->pp1.y += deltas[i + 0].y;
loader->pp2.x += deltas[i + 1].x;
loader->pp2.y += deltas[i + 1].y;
loader->pp3.x += deltas[i + 2].x;
loader->pp3.y += deltas[i + 2].y;
loader->pp4.x += deltas[i + 3].x;
loader->pp4.y += deltas[i + 3].y;
FT_FREE( deltas );
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* scale phantom points, if necessary; */
/* they get rounded in `TT_Hint_Glyph' */
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
/* pp1.y and pp2.y are always zero */
loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
}
/* if the flag FT_LOAD_NO_RECURSE is set, we return the subglyph */
/* `as is' in the glyph slot (the client application will be */
/* responsible for interpreting these data)... */
if ( loader->load_flags & FT_LOAD_NO_RECURSE )
{
FT_GlyphLoader_Add( gloader );
loader->glyph->format = FT_GLYPH_FORMAT_COMPOSITE;
goto Exit;
}
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
{
FT_UInt n, num_base_points;
FT_SubGlyph subglyph = 0;
FT_UInt num_points = start_point;
FT_UInt num_subglyphs = gloader->current.num_subglyphs;
FT_UInt num_base_subgs = gloader->base.num_subglyphs;
FT_Stream old_stream = loader->stream;
FT_Int old_byte_len = loader->byte_len;
FT_GlyphLoader_Add( gloader );
/* read each subglyph independently */
for ( n = 0; n < num_subglyphs; n++ )
{
FT_Vector pp[4];
/* Each time we call load_truetype_glyph in this loop, the */
/* value of `gloader.base.subglyphs' can change due to table */
/* reallocations. We thus need to recompute the subglyph */
/* pointer on each iteration. */
subglyph = gloader->base.subglyphs + num_base_subgs + n;
pp[0] = loader->pp1;
pp[1] = loader->pp2;
pp[2] = loader->pp3;
pp[3] = loader->pp4;
num_base_points = gloader->base.outline.n_points;
error = load_truetype_glyph( loader, subglyph->index,
recurse_count + 1, FALSE );
if ( error )
goto Exit;
/* restore subglyph pointer */
subglyph = gloader->base.subglyphs + num_base_subgs + n;
/* restore phantom points if necessary */
if ( !( subglyph->flags & USE_MY_METRICS ) )
{
loader->pp1 = pp[0];
loader->pp2 = pp[1];
loader->pp3 = pp[2];
loader->pp4 = pp[3];
}
num_points = gloader->base.outline.n_points;
if ( num_points == num_base_points )
continue;
/* gloader->base.outline consists of three parts: */
/* 0 -(1)-> start_point -(2)-> num_base_points -(3)-> n_points. */
/* */
/* (1): exists from the beginning */
/* (2): components that have been loaded so far */
/* (3): the newly loaded component */
TT_Process_Composite_Component( loader, subglyph, start_point,
num_base_points );
}
loader->stream = old_stream;
loader->byte_len = old_byte_len;
/* process the glyph */
loader->ins_pos = ins_pos;
if ( IS_HINTED( loader->load_flags ) &&
#ifdef TT_USE_BYTECODE_INTERPRETER
subglyph->flags & WE_HAVE_INSTR &&
#endif
num_points > start_point )
TT_Process_Composite_Glyph( loader, start_point, start_contour );
}
}
else
{
/* invalid composite count (negative but not -1) */
error = FT_THROW( Invalid_Outline );
goto Exit;
}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
Exit:
if ( opened_frame )
face->forget_glyph_frame( loader );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( glyph_data_loaded )
face->root.internal->incremental_interface->funcs->free_glyph_data(
face->root.internal->incremental_interface->object,
&glyph_data );
#endif
return error;
}
static FT_Error
compute_glyph_metrics( TT_Loader loader,
FT_UInt glyph_index )
{
TT_Face face = (TT_Face)loader->face;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
#endif
FT_BBox bbox;
FT_Fixed y_scale;
TT_GlyphSlot glyph = loader->glyph;
TT_Size size = (TT_Size)loader->size;
y_scale = 0x10000L;
if ( ( loader->load_flags & FT_LOAD_NO_SCALE ) == 0 )
y_scale = size->root.metrics.y_scale;
if ( glyph->format != FT_GLYPH_FORMAT_COMPOSITE )
FT_Outline_Get_CBox( &glyph->outline, &bbox );
else
bbox = loader->bbox;
/* get the device-independent horizontal advance; it is scaled later */
/* by the base layer. */
glyph->linearHoriAdvance = loader->linear;
glyph->metrics.horiBearingX = bbox.xMin;
glyph->metrics.horiBearingY = bbox.yMax;
glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
/* adjust advance width to the value contained in the hdmx table */
if ( !face->postscript.isFixedPitch &&
IS_HINTED( loader->load_flags ) )
{
FT_Byte* widthp;
widthp = tt_face_get_device_metrics( face,
size->root.metrics.x_ppem,
glyph_index );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
FT_Bool ignore_x_mode;
ignore_x_mode = FT_BOOL( FT_LOAD_TARGET_MODE( loader->load_flags ) !=
FT_RENDER_MODE_MONO );
if ( widthp &&
( ( ignore_x_mode && loader->exec->compatible_widths ) ||
!ignore_x_mode ||
SPH_OPTION_BITMAP_WIDTHS ) )
glyph->metrics.horiAdvance = *widthp << 6;
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
{
if ( widthp )
glyph->metrics.horiAdvance = *widthp << 6;
}
}
/* set glyph dimensions */
glyph->metrics.width = bbox.xMax - bbox.xMin;
glyph->metrics.height = bbox.yMax - bbox.yMin;
/* Now take care of vertical metrics. In the case where there is */
/* no vertical information within the font (relatively common), */
/* create some metrics manually */
{
FT_Pos top; /* scaled vertical top side bearing */
FT_Pos advance; /* scaled vertical advance height */
/* Get the unscaled top bearing and advance height. */
if ( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 )
{
top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
y_scale );
if ( loader->pp3.y <= loader->pp4.y )
advance = 0;
else
advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
y_scale );
}
else
{
FT_Pos height;
/* XXX Compute top side bearing and advance height in */
/* Get_VMetrics instead of here. */
/* NOTE: The OS/2 values are the only `portable' ones, */
/* which is why we use them, if there is an OS/2 */
/* table in the font. Otherwise, we use the */
/* values defined in the horizontal header. */
height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin,
y_scale );
if ( face->os2.version != 0xFFFFU )
advance = (FT_Pos)( face->os2.sTypoAscender -
face->os2.sTypoDescender );
else
advance = (FT_Pos)( face->horizontal.Ascender -
face->horizontal.Descender );
top = ( advance - height ) / 2;
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
FT_Incremental_InterfaceRec* incr;
FT_Incremental_MetricsRec metrics;
FT_Error error;
incr = face->root.internal->incremental_interface;
/* If this is an incrementally loaded font see if there are */
/* overriding metrics for this glyph. */
if ( incr && incr->funcs->get_glyph_metrics )
{
metrics.bearing_x = 0;
metrics.bearing_y = top;
metrics.advance = advance;
error = incr->funcs->get_glyph_metrics( incr->object,
glyph_index,
TRUE,
&metrics );
if ( error )
return error;
top = metrics.bearing_y;
advance = metrics.advance;
}
}
/* GWW: Do vertical metrics get loaded incrementally too? */
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
glyph->linearVertAdvance = advance;
/* scale the metrics */
if ( !( loader->load_flags & FT_LOAD_NO_SCALE ) )
{
top = FT_MulFix( top, y_scale );
advance = FT_MulFix( advance, y_scale );
}
/* XXX: for now, we have no better algorithm for the lsb, but it */
/* should work fine. */
/* */
glyph->metrics.vertBearingX = glyph->metrics.horiBearingX -
glyph->metrics.horiAdvance / 2;
glyph->metrics.vertBearingY = top;
glyph->metrics.vertAdvance = advance;
}
return 0;
}
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
static FT_Error
load_sbit_image( TT_Size size,
TT_GlyphSlot glyph,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
TT_Face face;
SFNT_Service sfnt;
FT_Stream stream;
FT_Error error;
TT_SBit_MetricsRec metrics;
face = (TT_Face)glyph->face;
sfnt = (SFNT_Service)face->sfnt;
stream = face->root.stream;
error = sfnt->load_sbit_image( face,
size->strike_index,
glyph_index,
(FT_Int)load_flags,
stream,
&glyph->bitmap,
&metrics );
if ( !error )
{
glyph->outline.n_points = 0;
glyph->outline.n_contours = 0;
glyph->metrics.width = (FT_Pos)metrics.width << 6;
glyph->metrics.height = (FT_Pos)metrics.height << 6;
glyph->metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
glyph->metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
glyph->metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
glyph->metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
glyph->metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
glyph->metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
glyph->format = FT_GLYPH_FORMAT_BITMAP;
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
glyph->bitmap_left = metrics.vertBearingX;
glyph->bitmap_top = metrics.vertBearingY;
}
else
{
glyph->bitmap_left = metrics.horiBearingX;
glyph->bitmap_top = metrics.horiBearingY;
}
}
return error;
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
static FT_Error
tt_loader_init( TT_Loader loader,
TT_Size size,
TT_GlyphSlot glyph,
FT_Int32 load_flags,
FT_Bool glyf_table_only )
{
TT_Face face;
FT_Stream stream;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Bool pedantic = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
#endif
face = (TT_Face)glyph->face;
stream = face->root.stream;
FT_MEM_ZERO( loader, sizeof ( TT_LoaderRec ) );
#ifdef TT_USE_BYTECODE_INTERPRETER
/* load execution context */
if ( IS_HINTED( load_flags ) && !glyf_table_only )
{
TT_ExecContext exec;
FT_Bool grayscale;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face );
FT_Bool subpixel = FALSE;
#if 0
/* not used yet */
FT_Bool compatible_widths;
FT_Bool symmetrical_smoothing;
FT_Bool bgr;
FT_Bool subpixel_positioned;
#endif
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
FT_Bool reexecute = FALSE;
if ( !size->cvt_ready )
{
FT_Error error = tt_size_ready_bytecode( size, pedantic );
if ( error )
return error;
}
/* query new execution context */
exec = size->debug ? size->context
: ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
return FT_THROW( Could_Not_Find_Context );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
subpixel = FT_BOOL( ( FT_LOAD_TARGET_MODE( load_flags ) !=
FT_RENDER_MODE_MONO ) &&
SPH_OPTION_SET_SUBPIXEL );
if ( subpixel )
grayscale = FALSE;
else if ( SPH_OPTION_SET_GRAYSCALE )
{
grayscale = TRUE;
subpixel = FALSE;
}
else
grayscale = FALSE;
if ( FT_IS_TRICKY( glyph->face ) )
subpixel = FALSE;
exec->ignore_x_mode = subpixel || grayscale;
exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
if ( exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
#if 1
exec->compatible_widths = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
exec->symmetrical_smoothing = FALSE;
exec->bgr = FALSE;
exec->subpixel_positioned = TRUE;
#else /* 0 */
exec->compatible_widths =
FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
TT_LOAD_COMPATIBLE_WIDTHS );
exec->symmetrical_smoothing =
FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
TT_LOAD_SYMMETRICAL_SMOOTHING );
exec->bgr =
FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
TT_LOAD_BGR );
exec->subpixel_positioned =
FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
TT_LOAD_SUBPIXEL_POSITIONED );
#endif /* 0 */
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
{
grayscale = FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
FT_RENDER_MODE_MONO );
}
TT_Load_Context( exec, face, size );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( driver->interpreter_version == TT_INTERPRETER_VERSION_38 )
{
/* a change from mono to subpixel rendering (and vice versa) */
/* requires a re-execution of the CVT program */
if ( subpixel != exec->subpixel )
{
FT_TRACE4(( "tt_loader_init: subpixel hinting change,"
" re-executing `prep' table\n" ));
exec->subpixel = subpixel;
reexecute = TRUE;
}
/* a change from mono to grayscale rendering (and vice versa) */
/* requires a re-execution of the CVT program */
if ( grayscale != exec->grayscale )
{
FT_TRACE4(( "tt_loader_init: grayscale hinting change,"
" re-executing `prep' table\n" ));
exec->grayscale = grayscale;
reexecute = TRUE;
}
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
{
/* a change from mono to grayscale rendering (and vice versa) */
/* requires a re-execution of the CVT program */
if ( grayscale != exec->grayscale )
{
FT_TRACE4(( "tt_loader_init: grayscale change,"
" re-executing `prep' table\n" ));
exec->grayscale = grayscale;
reexecute = TRUE;
}
}
if ( reexecute )
{
FT_UInt i;
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
tt_size_run_prep( size, pedantic );
}
/* see whether the cvt program has disabled hinting */
if ( exec->GS.instruct_control & 1 )
load_flags |= FT_LOAD_NO_HINTING;
/* load default graphics state -- if needed */
if ( exec->GS.instruct_control & 2 )
exec->GS = tt_default_graphics_state;
exec->pedantic_hinting = FT_BOOL( load_flags & FT_LOAD_PEDANTIC );
loader->exec = exec;
loader->instructions = exec->glyphIns;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
/* seek to the beginning of the glyph table -- for Type 42 fonts */
/* the table might be accessed from a Postscript stream or something */
/* else... */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( face->root.internal->incremental_interface )
loader->glyf_offset = 0;
else
#endif
{
FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 );
if ( FT_ERR_EQ( error, Table_Missing ) )
loader->glyf_offset = 0;
else if ( error )
{
FT_ERROR(( "tt_loader_init: could not access glyph table\n" ));
return error;
}
else
loader->glyf_offset = FT_STREAM_POS();
}
/* get face's glyph loader */
if ( !glyf_table_only )
{
FT_GlyphLoader gloader = glyph->internal->loader;
FT_GlyphLoader_Rewind( gloader );
loader->gloader = gloader;
}
loader->load_flags = load_flags;
loader->face = (FT_Face)face;
loader->size = (FT_Size)size;
loader->glyph = (FT_GlyphSlot)glyph;
loader->stream = stream;
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_Glyph */
/* */
/* <Description> */
/* A function used to load a single glyph within a given glyph slot, */
/* for a given size. */
/* */
/* <Input> */
/* glyph :: A handle to a target slot object where the glyph */
/* will be loaded. */
/* */
/* size :: A handle to the source face size at which the glyph */
/* must be scaled/loaded. */
/* */
/* glyph_index :: The index of the glyph in the font file. */
/* */
/* load_flags :: A flag indicating what to load for this glyph. The */
/* FT_LOAD_XXX constants can be used to control the */
/* glyph loading process (e.g., whether the outline */
/* should be scaled, whether to load bitmaps or not, */
/* whether to hint the outline, etc). */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
TT_LoaderRec loader;
FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index ));
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* try to load embedded bitmap if any */
/* */
/* XXX: The convention should be emphasized in */
/* the documents because it can be confusing. */
if ( size->strike_index != 0xFFFFFFFFUL &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
error = load_sbit_image( size, glyph, glyph_index, load_flags );
if ( !error )
{
if ( FT_IS_SCALABLE( glyph->face ) )
{
/* for the bbox we need the header only */
(void)tt_loader_init( &loader, size, glyph, load_flags, TRUE );
(void)load_truetype_glyph( &loader, glyph_index, 0, TRUE );
glyph->linearHoriAdvance = loader.linear;
glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax -
loader.vadvance;
/* sanity check: if `horiAdvance' in the sbit metric */
/* structure isn't set, use `linearHoriAdvance' */
if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance )
glyph->metrics.horiAdvance =
FT_MulFix( glyph->linearHoriAdvance,
size->root.metrics.x_scale );
}
return FT_Err_Ok;
}
}
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
/* if FT_LOAD_NO_SCALE is not set, `ttmetrics' must be valid */
if ( !( load_flags & FT_LOAD_NO_SCALE ) && !size->ttmetrics.valid )
return FT_THROW( Invalid_Size_Handle );
if ( load_flags & FT_LOAD_SBITS_ONLY )
return FT_THROW( Invalid_Argument );
error = tt_loader_init( &loader, size, glyph, load_flags, FALSE );
if ( error )
return error;
glyph->format = FT_GLYPH_FORMAT_OUTLINE;
glyph->num_subglyphs = 0;
glyph->outline.flags = 0;
/* main loading loop */
error = load_truetype_glyph( &loader, glyph_index, 0, FALSE );
if ( !error )
{
if ( glyph->format == FT_GLYPH_FORMAT_COMPOSITE )
{
glyph->num_subglyphs = loader.gloader->base.num_subglyphs;
glyph->subglyphs = loader.gloader->base.subglyphs;
}
else
{
glyph->outline = loader.gloader->base.outline;
glyph->outline.flags &= ~FT_OUTLINE_SINGLE_PASS;
/* Translate array so that (0,0) is the glyph's origin. Note */
/* that this behaviour is independent on the value of bit 1 of */
/* the `flags' field in the `head' table -- at least major */
/* applications like Acroread indicate that. */
if ( loader.pp1.x )
FT_Outline_Translate( &glyph->outline, -loader.pp1.x, 0 );
}
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( IS_HINTED( load_flags ) )
{
if ( loader.exec->GS.scan_control )
{
/* convert scan conversion mode to FT_OUTLINE_XXX flags */
switch ( loader.exec->GS.scan_type )
{
case 0: /* simple drop-outs including stubs */
glyph->outline.flags |= FT_OUTLINE_INCLUDE_STUBS;
break;
case 1: /* simple drop-outs excluding stubs */
/* nothing; it's the default rendering mode */
break;
case 4: /* smart drop-outs including stubs */
glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS |
FT_OUTLINE_INCLUDE_STUBS;
break;
case 5: /* smart drop-outs excluding stubs */
glyph->outline.flags |= FT_OUTLINE_SMART_DROPOUTS;
break;
default: /* no drop-out control */
glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
break;
}
}
else
glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
compute_glyph_metrics( &loader, glyph_index );
}
/* Set the `high precision' bit flag. */
/* This is _critical_ to get correct output for monochrome */
/* TrueType glyphs at all sizes using the bytecode interpreter. */
/* */
if ( !( load_flags & FT_LOAD_NO_SCALE ) &&
size->root.metrics.y_ppem < 24 )
glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
return error;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttgload.c | C | apache-2.0 | 81,347 |
/***************************************************************************/
/* */
/* ttgload.h */
/* */
/* TrueType Glyph Loader (specification). */
/* */
/* Copyright 1996-2006, 2008, 2011 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 __TTGLOAD_H__
#define __TTGLOAD_H__
#include <ft2build.h>
#include "ttobjs.h"
#ifdef TT_USE_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
FT_BEGIN_HEADER
FT_LOCAL( void )
TT_Init_Glyph_Loading( TT_Face face );
FT_LOCAL( void )
TT_Get_HMetrics( TT_Face face,
FT_UInt idx,
FT_Short* lsb,
FT_UShort* aw );
FT_LOCAL( void )
TT_Get_VMetrics( TT_Face face,
FT_UInt idx,
FT_Pos yMax,
FT_Short* tsb,
FT_UShort* ah );
FT_LOCAL( FT_Error )
TT_Load_Glyph( TT_Size size,
TT_GlyphSlot glyph,
FT_UInt glyph_index,
FT_Int32 load_flags );
FT_END_HEADER
#endif /* __TTGLOAD_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttgload.h | C | apache-2.0 | 2,097 |
/***************************************************************************/
/* */
/* ttgxvar.c */
/* */
/* TrueType GX Font Variation loader */
/* */
/* Copyright 2004-2013 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */
/* */
/* 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */
/* */
/* http://developer.apple.com/fonts/TTRefMan/RM06/Chap6[fgca]var.html */
/* */
/* The documentation for `fvar' is inconsistent. At one point it says */
/* that `countSizePairs' should be 3, at another point 2. It should */
/* be 2. */
/* */
/* The documentation for `gvar' is not intelligible; `cvar' refers you */
/* to `gvar' and is thus also incomprehensible. */
/* */
/* The documentation for `avar' appears correct, but Apple has no fonts */
/* with an `avar' table, so it is hard to test. */
/* */
/* Many thanks to John Jenkins (at Apple) in figuring this out. */
/* */
/* */
/* Apple's `kern' table has some references to tuple indices, but as */
/* there is no indication where these indices are defined, nor how to */
/* interpolate the kerning values (different tuples have different */
/* classes) this issue is ignored. */
/* */
/*************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_CONFIG_CONFIG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_TAGS_H
#include FT_MULTIPLE_MASTERS_H
#include "ttpload.h"
#include "ttgxvar.h"
#include "tterrors.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#define FT_Stream_FTell( stream ) \
(FT_ULong)( (stream)->cursor - (stream)->base )
#define FT_Stream_SeekSet( stream, off ) \
( (stream)->cursor = (stream)->base + (off) )
/*************************************************************************/
/* */
/* 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_ttgxvar
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** Internal Routines *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* The macro ALL_POINTS is used in `ft_var_readpackedpoints'. It */
/* indicates that there is a delta for every point without needing to */
/* enumerate all of them. */
/* */
/* ensure that value `0' has the same width as a pointer */
#define ALL_POINTS (FT_UShort*)~(FT_PtrDist)0
#define GX_PT_POINTS_ARE_WORDS 0x80
#define GX_PT_POINT_RUN_COUNT_MASK 0x7F
/*************************************************************************/
/* */
/* <Function> */
/* ft_var_readpackedpoints */
/* */
/* <Description> */
/* Read a set of points to which the following deltas will apply. */
/* Points are packed with a run length encoding. */
/* */
/* <Input> */
/* stream :: The data stream. */
/* */
/* <Output> */
/* point_cnt :: The number of points read. A zero value means that */
/* all points in the glyph will be affected, without */
/* enumerating them individually. */
/* */
/* <Return> */
/* An array of FT_UShort containing the affected points or the */
/* special value ALL_POINTS. */
/* */
static FT_UShort*
ft_var_readpackedpoints( FT_Stream stream,
FT_UInt *point_cnt )
{
FT_UShort *points = NULL;
FT_Int n;
FT_Int runcnt;
FT_Int i;
FT_Int j;
FT_Int first;
FT_Memory memory = stream->memory;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
*point_cnt = n = FT_GET_BYTE();
if ( n == 0 )
return ALL_POINTS;
if ( n & GX_PT_POINTS_ARE_WORDS )
n = FT_GET_BYTE() | ( ( n & GX_PT_POINT_RUN_COUNT_MASK ) << 8 );
if ( FT_NEW_ARRAY( points, n ) )
return NULL;
i = 0;
while ( i < n )
{
runcnt = FT_GET_BYTE();
if ( runcnt & GX_PT_POINTS_ARE_WORDS )
{
runcnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK;
first = points[i++] = FT_GET_USHORT();
if ( runcnt < 1 || i + runcnt >= n )
goto Exit;
/* first point not included in runcount */
for ( j = 0; j < runcnt; ++j )
points[i++] = (FT_UShort)( first += FT_GET_USHORT() );
}
else
{
first = points[i++] = FT_GET_BYTE();
if ( runcnt < 1 || i + runcnt >= n )
goto Exit;
for ( j = 0; j < runcnt; ++j )
points[i++] = (FT_UShort)( first += FT_GET_BYTE() );
}
}
Exit:
return points;
}
enum
{
GX_DT_DELTAS_ARE_ZERO = 0x80,
GX_DT_DELTAS_ARE_WORDS = 0x40,
GX_DT_DELTA_RUN_COUNT_MASK = 0x3F
};
/*************************************************************************/
/* */
/* <Function> */
/* ft_var_readpackeddeltas */
/* */
/* <Description> */
/* Read a set of deltas. These are packed slightly differently than */
/* points. In particular there is no overall count. */
/* */
/* <Input> */
/* stream :: The data stream. */
/* */
/* delta_cnt :: The number of to be read. */
/* */
/* <Return> */
/* An array of FT_Short containing the deltas for the affected */
/* points. (This only gets the deltas for one dimension. It will */
/* generally be called twice, once for x, once for y. When used in */
/* cvt table, it will only be called once.) */
/* */
static FT_Short*
ft_var_readpackeddeltas( FT_Stream stream,
FT_Offset delta_cnt )
{
FT_Short *deltas = NULL;
FT_UInt runcnt;
FT_Offset i;
FT_UInt j;
FT_Memory memory = stream->memory;
FT_Error error = FT_Err_Ok;
FT_UNUSED( error );
if ( FT_NEW_ARRAY( deltas, delta_cnt ) )
return NULL;
i = 0;
while ( i < delta_cnt )
{
runcnt = FT_GET_BYTE();
if ( runcnt & GX_DT_DELTAS_ARE_ZERO )
{
/* runcnt zeroes get added */
for ( j = 0;
j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
++j )
deltas[i++] = 0;
}
else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
{
/* runcnt shorts from the stack */
for ( j = 0;
j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
++j )
deltas[i++] = FT_GET_SHORT();
}
else
{
/* runcnt signed bytes from the stack */
for ( j = 0;
j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
++j )
deltas[i++] = FT_GET_CHAR();
}
if ( j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) )
{
/* Bad format */
FT_FREE( deltas );
return NULL;
}
}
return deltas;
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_var_load_avar */
/* */
/* <Description> */
/* Parse the `avar' table if present. It need not be, so we return */
/* nothing. */
/* */
/* <InOut> */
/* face :: The font face. */
/* */
static void
ft_var_load_avar( TT_Face face )
{
FT_Stream stream = FT_FACE_STREAM(face);
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
GX_AVarSegment segment;
FT_Error error = FT_Err_Ok;
FT_ULong version;
FT_Long axisCount;
FT_Int i, j;
FT_ULong table_len;
FT_UNUSED( error );
blend->avar_checked = TRUE;
if ( (error = face->goto_table( face, TTAG_avar, stream, &table_len )) != 0 )
return;
if ( FT_FRAME_ENTER( table_len ) )
return;
version = FT_GET_LONG();
axisCount = FT_GET_LONG();
if ( version != 0x00010000L ||
axisCount != (FT_Long)blend->mmvar->num_axis )
goto Exit;
if ( FT_NEW_ARRAY( blend->avar_segment, axisCount ) )
goto Exit;
segment = &blend->avar_segment[0];
for ( i = 0; i < axisCount; ++i, ++segment )
{
segment->pairCount = FT_GET_USHORT();
if ( FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
{
/* Failure. Free everything we have done so far. We must do */
/* it right now since loading the `avar' table is optional. */
for ( j = i - 1; j >= 0; --j )
FT_FREE( blend->avar_segment[j].correspondence );
FT_FREE( blend->avar_segment );
blend->avar_segment = NULL;
goto Exit;
}
for ( j = 0; j < segment->pairCount; ++j )
{
segment->correspondence[j].fromCoord =
FT_GET_SHORT() << 2; /* convert to Fixed */
segment->correspondence[j].toCoord =
FT_GET_SHORT()<<2; /* convert to Fixed */
}
}
Exit:
FT_FRAME_EXIT();
}
typedef struct GX_GVar_Head_
{
FT_Long version;
FT_UShort axisCount;
FT_UShort globalCoordCount;
FT_ULong offsetToCoord;
FT_UShort glyphCount;
FT_UShort flags;
FT_ULong offsetToData;
} GX_GVar_Head;
/*************************************************************************/
/* */
/* <Function> */
/* ft_var_load_gvar */
/* */
/* <Description> */
/* Parses the `gvar' table if present. If `fvar' is there, `gvar' */
/* had better be there too. */
/* */
/* <InOut> */
/* face :: The font face. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static FT_Error
ft_var_load_gvar( TT_Face face )
{
FT_Stream stream = FT_FACE_STREAM(face);
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
FT_Error error;
FT_UInt i, j;
FT_ULong table_len;
FT_ULong gvar_start;
FT_ULong offsetToData;
GX_GVar_Head gvar_head;
static const FT_Frame_Field gvar_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE GX_GVar_Head
FT_FRAME_START( 20 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( axisCount ),
FT_FRAME_USHORT( globalCoordCount ),
FT_FRAME_ULONG ( offsetToCoord ),
FT_FRAME_USHORT( glyphCount ),
FT_FRAME_USHORT( flags ),
FT_FRAME_ULONG ( offsetToData ),
FT_FRAME_END
};
if ( (error = face->goto_table( face, TTAG_gvar, stream, &table_len )) != 0 )
goto Exit;
gvar_start = FT_STREAM_POS( );
if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) )
goto Exit;
blend->tuplecount = gvar_head.globalCoordCount;
blend->gv_glyphcnt = gvar_head.glyphCount;
offsetToData = gvar_start + gvar_head.offsetToData;
if ( gvar_head.version != (FT_Long)0x00010000L ||
gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) )
goto Exit;
if ( gvar_head.flags & 1 )
{
/* long offsets (one more offset than glyphs, to mark size of last) */
if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) )
goto Exit;
for ( i = 0; i <= blend->gv_glyphcnt; ++i )
blend->glyphoffsets[i] = offsetToData + FT_GET_LONG();
FT_FRAME_EXIT();
}
else
{
/* short offsets (one more offset than glyphs, to mark size of last) */
if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) )
goto Exit;
for ( i = 0; i <= blend->gv_glyphcnt; ++i )
blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2;
/* XXX: Undocumented: `*2'! */
FT_FRAME_EXIT();
}
if ( blend->tuplecount != 0 )
{
if ( FT_NEW_ARRAY( blend->tuplecoords,
gvar_head.axisCount * blend->tuplecount ) )
goto Exit;
if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord ) ||
FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L ) )
goto Exit;
for ( i = 0; i < blend->tuplecount; ++i )
for ( j = 0 ; j < (FT_UInt)gvar_head.axisCount; ++j )
blend->tuplecoords[i * gvar_head.axisCount + j] =
FT_GET_SHORT() << 2; /* convert to FT_Fixed */
FT_FRAME_EXIT();
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* ft_var_apply_tuple */
/* */
/* <Description> */
/* Figure out whether a given tuple (design) applies to the current */
/* blend, and if so, what is the scaling factor. */
/* */
/* <Input> */
/* blend :: The current blend of the font. */
/* */
/* tupleIndex :: A flag saying whether this is an intermediate */
/* tuple or not. */
/* */
/* tuple_coords :: The coordinates of the tuple in normalized axis */
/* units. */
/* */
/* im_start_coords :: The initial coordinates where this tuple starts */
/* to apply (for intermediate coordinates). */
/* */
/* im_end_coords :: The final coordinates after which this tuple no */
/* longer applies (for intermediate coordinates). */
/* */
/* <Return> */
/* An FT_Fixed value containing the scaling factor. */
/* */
static FT_Fixed
ft_var_apply_tuple( GX_Blend blend,
FT_UShort tupleIndex,
FT_Fixed* tuple_coords,
FT_Fixed* im_start_coords,
FT_Fixed* im_end_coords )
{
FT_UInt i;
FT_Fixed apply = 0x10000L;
for ( i = 0; i < blend->num_axis; ++i )
{
if ( tuple_coords[i] == 0 )
/* It's not clear why (for intermediate tuples) we don't need */
/* to check against start/end -- the documentation says we don't. */
/* Similarly, it's unclear why we don't need to scale along the */
/* axis. */
continue;
else if ( blend->normalizedcoords[i] == 0 ||
( blend->normalizedcoords[i] < 0 && tuple_coords[i] > 0 ) ||
( blend->normalizedcoords[i] > 0 && tuple_coords[i] < 0 ) )
{
apply = 0;
break;
}
else if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
/* not an intermediate tuple */
apply = FT_MulFix( apply,
blend->normalizedcoords[i] > 0
? blend->normalizedcoords[i]
: -blend->normalizedcoords[i] );
else if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
blend->normalizedcoords[i] >= im_end_coords[i] )
{
apply = 0;
break;
}
else if ( blend->normalizedcoords[i] < tuple_coords[i] )
apply = FT_MulDiv( apply,
blend->normalizedcoords[i] - im_start_coords[i],
tuple_coords[i] - im_start_coords[i] );
else
apply = FT_MulDiv( apply,
im_end_coords[i] - blend->normalizedcoords[i],
im_end_coords[i] - tuple_coords[i] );
}
return apply;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** MULTIPLE MASTERS SERVICE FUNCTIONS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct GX_FVar_Head_
{
FT_Long version;
FT_UShort offsetToData;
FT_UShort countSizePairs;
FT_UShort axisCount;
FT_UShort axisSize;
FT_UShort instanceCount;
FT_UShort instanceSize;
} GX_FVar_Head;
typedef struct fvar_axis_
{
FT_ULong axisTag;
FT_ULong minValue;
FT_ULong defaultValue;
FT_ULong maxValue;
FT_UShort flags;
FT_UShort nameID;
} GX_FVar_Axis;
/*************************************************************************/
/* */
/* <Function> */
/* TT_Get_MM_Var */
/* */
/* <Description> */
/* Check that the font's `fvar' table is valid, parse it, and return */
/* those data. */
/* */
/* <InOut> */
/* face :: The font face. */
/* TT_Get_MM_Var initializes the blend structure. */
/* */
/* <Output> */
/* master :: The `fvar' data (must be freed by caller). */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Get_MM_Var( TT_Face face,
FT_MM_Var* *master )
{
FT_Stream stream = face->root.stream;
FT_Memory memory = face->root.memory;
FT_ULong table_len;
FT_Error error = FT_Err_Ok;
FT_ULong fvar_start;
FT_Int i, j;
FT_MM_Var* mmvar = NULL;
FT_Fixed* next_coords;
FT_String* next_name;
FT_Var_Axis* a;
FT_Var_Named_Style* ns;
GX_FVar_Head fvar_head;
static const FT_Frame_Field fvar_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE GX_FVar_Head
FT_FRAME_START( 16 ),
FT_FRAME_LONG ( version ),
FT_FRAME_USHORT( offsetToData ),
FT_FRAME_USHORT( countSizePairs ),
FT_FRAME_USHORT( axisCount ),
FT_FRAME_USHORT( axisSize ),
FT_FRAME_USHORT( instanceCount ),
FT_FRAME_USHORT( instanceSize ),
FT_FRAME_END
};
static const FT_Frame_Field fvaraxis_fields[] =
{
#undef FT_STRUCTURE
#define FT_STRUCTURE GX_FVar_Axis
FT_FRAME_START( 20 ),
FT_FRAME_ULONG ( axisTag ),
FT_FRAME_ULONG ( minValue ),
FT_FRAME_ULONG ( defaultValue ),
FT_FRAME_ULONG ( maxValue ),
FT_FRAME_USHORT( flags ),
FT_FRAME_USHORT( nameID ),
FT_FRAME_END
};
if ( face->blend == NULL )
{
/* both `fvar' and `gvar' must be present */
if ( (error = face->goto_table( face, TTAG_gvar,
stream, &table_len )) != 0 )
goto Exit;
if ( (error = face->goto_table( face, TTAG_fvar,
stream, &table_len )) != 0 )
goto Exit;
fvar_start = FT_STREAM_POS( );
if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) )
goto Exit;
if ( fvar_head.version != (FT_Long)0x00010000L ||
fvar_head.countSizePairs != 2 ||
fvar_head.axisSize != 20 ||
/* axisCount limit implied by 16-bit instanceSize */
fvar_head.axisCount > 0x3FFE ||
fvar_head.instanceSize != 4 + 4 * fvar_head.axisCount ||
/* instanceCount limit implied by limited range of name IDs */
fvar_head.instanceCount > 0x7EFF ||
fvar_head.offsetToData + fvar_head.axisCount * 20U +
fvar_head.instanceCount * fvar_head.instanceSize > table_len )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
if ( FT_NEW( face->blend ) )
goto Exit;
/* cannot overflow 32-bit arithmetic because of limits above */
face->blend->mmvar_len =
sizeof ( FT_MM_Var ) +
fvar_head.axisCount * sizeof ( FT_Var_Axis ) +
fvar_head.instanceCount * sizeof ( FT_Var_Named_Style ) +
fvar_head.instanceCount * fvar_head.axisCount * sizeof ( FT_Fixed ) +
5 * fvar_head.axisCount;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
face->blend->mmvar = mmvar;
mmvar->num_axis =
fvar_head.axisCount;
mmvar->num_designs =
~0U; /* meaningless in this context; each glyph */
/* may have a different number of designs */
/* (or tuples, as called by Apple) */
mmvar->num_namedstyles =
fvar_head.instanceCount;
mmvar->axis =
(FT_Var_Axis*)&(mmvar[1]);
mmvar->namedstyle =
(FT_Var_Named_Style*)&(mmvar->axis[fvar_head.axisCount]);
next_coords =
(FT_Fixed*)&(mmvar->namedstyle[fvar_head.instanceCount]);
for ( i = 0; i < fvar_head.instanceCount; ++i )
{
mmvar->namedstyle[i].coords = next_coords;
next_coords += fvar_head.axisCount;
}
next_name = (FT_String*)next_coords;
for ( i = 0; i < fvar_head.axisCount; ++i )
{
mmvar->axis[i].name = next_name;
next_name += 5;
}
if ( FT_STREAM_SEEK( fvar_start + fvar_head.offsetToData ) )
goto Exit;
a = mmvar->axis;
for ( i = 0; i < fvar_head.axisCount; ++i )
{
GX_FVar_Axis axis_rec;
if ( FT_STREAM_READ_FIELDS( fvaraxis_fields, &axis_rec ) )
goto Exit;
a->tag = axis_rec.axisTag;
a->minimum = axis_rec.minValue; /* A Fixed */
a->def = axis_rec.defaultValue; /* A Fixed */
a->maximum = axis_rec.maxValue; /* A Fixed */
a->strid = axis_rec.nameID;
a->name[0] = (FT_String)( a->tag >> 24 );
a->name[1] = (FT_String)( ( a->tag >> 16 ) & 0xFF );
a->name[2] = (FT_String)( ( a->tag >> 8 ) & 0xFF );
a->name[3] = (FT_String)( ( a->tag ) & 0xFF );
a->name[4] = 0;
++a;
}
ns = mmvar->namedstyle;
for ( i = 0; i < fvar_head.instanceCount; ++i, ++ns )
{
if ( FT_FRAME_ENTER( 4L + 4L * fvar_head.axisCount ) )
goto Exit;
ns->strid = FT_GET_USHORT();
(void) /* flags = */ FT_GET_USHORT();
for ( j = 0; j < fvar_head.axisCount; ++j )
ns->coords[j] = FT_GET_ULONG(); /* A Fixed */
FT_FRAME_EXIT();
}
}
if ( master != NULL )
{
FT_UInt n;
if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
goto Exit;
FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
mmvar->axis =
(FT_Var_Axis*)&(mmvar[1]);
mmvar->namedstyle =
(FT_Var_Named_Style*)&(mmvar->axis[mmvar->num_axis]);
next_coords =
(FT_Fixed*)&(mmvar->namedstyle[mmvar->num_namedstyles]);
for ( n = 0; n < mmvar->num_namedstyles; ++n )
{
mmvar->namedstyle[n].coords = next_coords;
next_coords += mmvar->num_axis;
}
a = mmvar->axis;
next_name = (FT_String*)next_coords;
for ( n = 0; n < mmvar->num_axis; ++n )
{
a->name = next_name;
/* standard PostScript names for some standard apple tags */
if ( a->tag == TTAG_wght )
a->name = (char *)"Weight";
else if ( a->tag == TTAG_wdth )
a->name = (char *)"Width";
else if ( a->tag == TTAG_opsz )
a->name = (char *)"OpticalSize";
else if ( a->tag == TTAG_slnt )
a->name = (char *)"Slant";
next_name += 5;
++a;
}
*master = mmvar;
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Set_MM_Blend */
/* */
/* <Description> */
/* Set the blend (normalized) coordinates for this instance of the */
/* font. Check that the `gvar' table is reasonable and does some */
/* initial preparation. */
/* */
/* <InOut> */
/* face :: The font. */
/* Initialize the blend structure with `gvar' data. */
/* */
/* <Input> */
/* num_coords :: Must be the axis count of the font. */
/* */
/* coords :: An array of num_coords, each between [-1,1]. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Set_MM_Blend( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error = FT_Err_Ok;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i;
FT_Memory memory = face->root.memory;
enum
{
mcvt_retain,
mcvt_modify,
mcvt_load
} manageCvt;
face->doblend = FALSE;
if ( face->blend == NULL )
{
if ( (error = TT_Get_MM_Var( face, NULL)) != 0 )
goto Exit;
}
blend = face->blend;
mmvar = blend->mmvar;
if ( num_coords != mmvar->num_axis )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
for ( i = 0; i < num_coords; ++i )
if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( blend->glyphoffsets == NULL )
if ( (error = ft_var_load_gvar( face )) != 0 )
goto Exit;
if ( blend->normalizedcoords == NULL )
{
if ( FT_NEW_ARRAY( blend->normalizedcoords, num_coords ) )
goto Exit;
manageCvt = mcvt_modify;
/* If we have not set the blend coordinates before this, then the */
/* cvt table will still be what we read from the `cvt ' table and */
/* we don't need to reload it. We may need to change it though... */
}
else
{
manageCvt = mcvt_retain;
for ( i = 0; i < num_coords; ++i )
{
if ( blend->normalizedcoords[i] != coords[i] )
{
manageCvt = mcvt_load;
break;
}
}
/* If we don't change the blend coords then we don't need to do */
/* anything to the cvt table. It will be correct. Otherwise we */
/* no longer have the original cvt (it was modified when we set */
/* the blend last time), so we must reload and then modify it. */
}
blend->num_axis = num_coords;
FT_MEM_COPY( blend->normalizedcoords,
coords,
num_coords * sizeof ( FT_Fixed ) );
face->doblend = TRUE;
if ( face->cvt != NULL )
{
switch ( manageCvt )
{
case mcvt_load:
/* The cvt table has been loaded already; every time we change the */
/* blend we may need to reload and remodify the cvt table. */
FT_FREE( face->cvt );
face->cvt = NULL;
tt_face_load_cvt( face, face->root.stream );
break;
case mcvt_modify:
/* The original cvt table is in memory. All we need to do is */
/* apply the `cvar' table (if any). */
tt_face_vary_cvt( face, face->root.stream );
break;
case mcvt_retain:
/* The cvt table is correct for this set of coordinates. */
break;
}
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Set_Var_Design */
/* */
/* <Description> */
/* Set the coordinates for the instance, measured in the user */
/* coordinate system. Parse the `avar' table (if present) to convert */
/* from user to normalized coordinates. */
/* */
/* <InOut> */
/* face :: The font face. */
/* Initialize the blend struct with `gvar' data. */
/* */
/* <Input> */
/* num_coords :: This must be the axis count of the font. */
/* */
/* coords :: A coordinate array with `num_coords' elements. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Set_Var_Design( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error = FT_Err_Ok;
FT_Fixed* normalized = NULL;
GX_Blend blend;
FT_MM_Var* mmvar;
FT_UInt i, j;
FT_Var_Axis* a;
GX_AVarSegment av;
FT_Memory memory = face->root.memory;
if ( face->blend == NULL )
{
if ( (error = TT_Get_MM_Var( face, NULL )) != 0 )
goto Exit;
}
blend = face->blend;
mmvar = blend->mmvar;
if ( num_coords != mmvar->num_axis )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* Axis normalization is a two stage process. First we normalize */
/* based on the [min,def,max] values for the axis to be [-1,0,1]. */
/* Then, if there's an `avar' table, we renormalize this range. */
if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
goto Exit;
a = mmvar->axis;
for ( i = 0; i < mmvar->num_axis; ++i, ++a )
{
if ( coords[i] > a->maximum || coords[i] < a->minimum )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( coords[i] < a->def )
normalized[i] = -FT_DivFix( coords[i] - a->def, a->minimum - a->def );
else if ( a->maximum == a->def )
normalized[i] = 0;
else
normalized[i] = FT_DivFix( coords[i] - a->def, a->maximum - a->def );
}
if ( !blend->avar_checked )
ft_var_load_avar( face );
if ( blend->avar_segment != NULL )
{
av = blend->avar_segment;
for ( i = 0; i < mmvar->num_axis; ++i, ++av )
{
for ( j = 1; j < (FT_UInt)av->pairCount; ++j )
if ( normalized[i] < av->correspondence[j].fromCoord )
{
normalized[i] =
FT_MulDiv( normalized[i] - av->correspondence[j - 1].fromCoord,
av->correspondence[j].toCoord -
av->correspondence[j - 1].toCoord,
av->correspondence[j].fromCoord -
av->correspondence[j - 1].fromCoord ) +
av->correspondence[j - 1].toCoord;
break;
}
}
}
error = TT_Set_MM_Blend( face, num_coords, normalized );
Exit:
FT_FREE( normalized );
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** GX VAR PARSING ROUTINES *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_vary_cvt */
/* */
/* <Description> */
/* Modify the loaded cvt table according to the `cvar' table and the */
/* font's blend. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* Most errors are ignored. It is perfectly valid not to have a */
/* `cvar' table even if there is a `gvar' and `fvar' table. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_ULong table_start;
FT_ULong table_len;
FT_UInt tupleCount;
FT_ULong offsetToData;
FT_ULong here;
FT_UInt i, j;
FT_Fixed* tuple_coords = NULL;
FT_Fixed* im_start_coords = NULL;
FT_Fixed* im_end_coords = NULL;
GX_Blend blend = face->blend;
FT_UInt point_count;
FT_UShort* localpoints;
FT_Short* deltas;
FT_TRACE2(( "CVAR " ));
if ( blend == NULL )
{
FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
error = FT_Err_Ok;
goto Exit;
}
if ( face->cvt == NULL )
{
FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
error = FT_Err_Ok;
goto Exit;
}
error = face->goto_table( face, TTAG_cvar, stream, &table_len );
if ( error )
{
FT_TRACE2(( "is missing\n" ));
error = FT_Err_Ok;
goto Exit;
}
if ( FT_FRAME_ENTER( table_len ) )
{
error = FT_Err_Ok;
goto Exit;
}
table_start = FT_Stream_FTell( stream );
if ( FT_GET_LONG() != 0x00010000L )
{
FT_TRACE2(( "bad table version\n" ));
error = FT_Err_Ok;
goto FExit;
}
if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_end_coords, blend->num_axis ) )
goto FExit;
tupleCount = FT_GET_USHORT();
offsetToData = table_start + FT_GET_USHORT();
/* The documentation implies there are flags packed into the */
/* tuplecount, but John Jenkins says that shared points don't apply */
/* to `cvar', and no other flags are defined. */
for ( i = 0; i < ( tupleCount & 0xFFF ); ++i )
{
FT_UInt tupleDataSize;
FT_UInt tupleIndex;
FT_Fixed apply;
tupleDataSize = FT_GET_USHORT();
tupleIndex = FT_GET_USHORT();
/* There is no provision here for a global tuple coordinate section, */
/* so John says. There are no tuple indices, just embedded tuples. */
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; ++j )
tuple_coords[j] = FT_GET_SHORT() << 2; /* convert from */
/* short frac to fixed */
}
else
{
/* skip this tuple; it makes no sense */
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
for ( j = 0; j < 2 * blend->num_axis; ++j )
(void)FT_GET_SHORT();
offsetToData += tupleDataSize;
continue;
}
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; ++j )
im_start_coords[j] = FT_GET_SHORT() << 2;
for ( j = 0; j < blend->num_axis; ++j )
im_end_coords[j] = FT_GET_SHORT() << 2;
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
im_start_coords,
im_end_coords );
if ( /* tuple isn't active for our blend */
apply == 0 ||
/* global points not allowed, */
/* if they aren't local, makes no sense */
!( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) )
{
offsetToData += tupleDataSize;
continue;
}
here = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, offsetToData );
localpoints = ft_var_readpackedpoints( stream, &point_count );
deltas = ft_var_readpackeddeltas( stream,
point_count == 0 ? face->cvt_size
: point_count );
if ( localpoints == NULL || deltas == NULL )
/* failure, ignore it */;
else if ( localpoints == ALL_POINTS )
{
/* this means that there are deltas for every entry in cvt */
for ( j = 0; j < face->cvt_size; ++j )
face->cvt[j] = (FT_Short)( face->cvt[j] +
FT_MulFix( deltas[j], apply ) );
}
else
{
for ( j = 0; j < point_count; ++j )
{
int pindex = localpoints[j];
face->cvt[pindex] = (FT_Short)( face->cvt[pindex] +
FT_MulFix( deltas[j], apply ) );
}
}
if ( localpoints != ALL_POINTS )
FT_FREE( localpoints );
FT_FREE( deltas );
offsetToData += tupleDataSize;
FT_Stream_SeekSet( stream, here );
}
FExit:
FT_FRAME_EXIT();
Exit:
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Vary_Get_Glyph_Deltas */
/* */
/* <Description> */
/* Load the appropriate deltas for the current glyph. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* glyph_index :: The index of the glyph being modified. */
/* */
/* n_points :: The number of the points in the glyph, including */
/* phantom points. */
/* */
/* <Output> */
/* deltas :: The array of points to change. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Vary_Get_Glyph_Deltas( TT_Face face,
FT_UInt glyph_index,
FT_Vector* *deltas,
FT_UInt n_points )
{
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
GX_Blend blend = face->blend;
FT_Vector* delta_xy = NULL;
FT_Error error;
FT_ULong glyph_start;
FT_UInt tupleCount;
FT_ULong offsetToData;
FT_ULong here;
FT_UInt i, j;
FT_Fixed* tuple_coords = NULL;
FT_Fixed* im_start_coords = NULL;
FT_Fixed* im_end_coords = NULL;
FT_UInt point_count, spoint_count = 0;
FT_UShort* sharedpoints = NULL;
FT_UShort* localpoints = NULL;
FT_UShort* points;
FT_Short *deltas_x, *deltas_y;
if ( !face->doblend || blend == NULL )
return FT_THROW( Invalid_Argument );
/* to be freed by the caller */
if ( FT_NEW_ARRAY( delta_xy, n_points ) )
goto Exit;
*deltas = delta_xy;
if ( glyph_index >= blend->gv_glyphcnt ||
blend->glyphoffsets[glyph_index] ==
blend->glyphoffsets[glyph_index + 1] )
return FT_Err_Ok; /* no variation data for this glyph */
if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] ) ||
FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
blend->glyphoffsets[glyph_index] ) )
goto Fail1;
glyph_start = FT_Stream_FTell( stream );
/* each set of glyph variation data is formatted similarly to `cvar' */
/* (except we get shared points and global tuples) */
if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
FT_NEW_ARRAY( im_end_coords, blend->num_axis ) )
goto Fail2;
tupleCount = FT_GET_USHORT();
offsetToData = glyph_start + FT_GET_USHORT();
if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
{
here = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, offsetToData );
sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
offsetToData = FT_Stream_FTell( stream );
FT_Stream_SeekSet( stream, here );
}
for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); ++i )
{
FT_UInt tupleDataSize;
FT_UInt tupleIndex;
FT_Fixed apply;
tupleDataSize = FT_GET_USHORT();
tupleIndex = FT_GET_USHORT();
if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
{
for ( j = 0; j < blend->num_axis; ++j )
tuple_coords[j] = FT_GET_SHORT() << 2; /* convert from */
/* short frac to fixed */
}
else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
{
error = FT_THROW( Invalid_Table );
goto Fail3;
}
else
{
FT_MEM_COPY(
tuple_coords,
&blend->tuplecoords[(tupleIndex & 0xFFF) * blend->num_axis],
blend->num_axis * sizeof ( FT_Fixed ) );
}
if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
{
for ( j = 0; j < blend->num_axis; ++j )
im_start_coords[j] = FT_GET_SHORT() << 2;
for ( j = 0; j < blend->num_axis; ++j )
im_end_coords[j] = FT_GET_SHORT() << 2;
}
apply = ft_var_apply_tuple( blend,
(FT_UShort)tupleIndex,
tuple_coords,
im_start_coords,
im_end_coords );
if ( apply == 0 ) /* tuple isn't active for our blend */
{
offsetToData += tupleDataSize;
continue;
}
here = FT_Stream_FTell( stream );
if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
{
FT_Stream_SeekSet( stream, offsetToData );
localpoints = ft_var_readpackedpoints( stream, &point_count );
points = localpoints;
}
else
{
points = sharedpoints;
point_count = spoint_count;
}
deltas_x = ft_var_readpackeddeltas( stream,
point_count == 0 ? n_points
: point_count );
deltas_y = ft_var_readpackeddeltas( stream,
point_count == 0 ? n_points
: point_count );
if ( points == NULL || deltas_y == NULL || deltas_x == NULL )
; /* failure, ignore it */
else if ( points == ALL_POINTS )
{
/* this means that there are deltas for every point in the glyph */
for ( j = 0; j < n_points; ++j )
{
delta_xy[j].x += FT_MulFix( deltas_x[j], apply );
delta_xy[j].y += FT_MulFix( deltas_y[j], apply );
}
}
else
{
for ( j = 0; j < point_count; ++j )
{
if ( localpoints[j] >= n_points )
continue;
delta_xy[localpoints[j]].x += FT_MulFix( deltas_x[j], apply );
delta_xy[localpoints[j]].y += FT_MulFix( deltas_y[j], apply );
}
}
if ( localpoints != ALL_POINTS )
FT_FREE( localpoints );
FT_FREE( deltas_x );
FT_FREE( deltas_y );
offsetToData += tupleDataSize;
FT_Stream_SeekSet( stream, here );
}
Fail3:
FT_FREE( tuple_coords );
FT_FREE( im_start_coords );
FT_FREE( im_end_coords );
Fail2:
FT_FRAME_EXIT();
Fail1:
if ( error )
{
FT_FREE( delta_xy );
*deltas = NULL;
}
Exit:
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_done_blend */
/* */
/* <Description> */
/* Frees the blend internal data structure. */
/* */
FT_LOCAL_DEF( void )
tt_done_blend( FT_Memory memory,
GX_Blend blend )
{
if ( blend != NULL )
{
FT_UInt i;
FT_FREE( blend->normalizedcoords );
FT_FREE( blend->mmvar );
if ( blend->avar_segment != NULL )
{
for ( i = 0; i < blend->num_axis; ++i )
FT_FREE( blend->avar_segment[i].correspondence );
FT_FREE( blend->avar_segment );
}
FT_FREE( blend->tuplecoords );
FT_FREE( blend->glyphoffsets );
FT_FREE( blend );
}
}
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttgxvar.c | C | apache-2.0 | 56,340 |
/***************************************************************************/
/* */
/* ttgxvar.h */
/* */
/* TrueType GX Font Variation loader (specification) */
/* */
/* Copyright 2004 by */
/* David Turner, Robert Wilhelm, Werner Lemberg and George Williams. */
/* */
/* 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 __TTGXVAR_H__
#define __TTGXVAR_H__
#include <ft2build.h>
#include "ttobjs.h"
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Struct> */
/* GX_AVarCorrespondenceRec */
/* */
/* <Description> */
/* A data structure representing `shortFracCorrespondence' in `avar' */
/* table according to the specifications from Apple. */
/* */
typedef struct GX_AVarCorrespondenceRec_
{
FT_Fixed fromCoord;
FT_Fixed toCoord;
} GX_AVarCorrespondenceRec_, *GX_AVarCorrespondence;
/*************************************************************************/
/* */
/* <Struct> */
/* GX_AVarRec */
/* */
/* <Description> */
/* Data from the segment field of `avar' table. */
/* There is one of these for each axis. */
/* */
typedef struct GX_AVarSegmentRec_
{
FT_UShort pairCount;
GX_AVarCorrespondence correspondence; /* array with pairCount entries */
} GX_AVarSegmentRec, *GX_AVarSegment;
/*************************************************************************/
/* */
/* <Struct> */
/* GX_BlendRec */
/* */
/* <Description> */
/* Data for interpolating a font from a distortable font specified */
/* by the GX *var tables ([fgca]var). */
/* */
/* <Fields> */
/* num_axis :: The number of axes along which interpolation */
/* may happen */
/* */
/* normalizedcoords :: A normalized value (between [-1,1]) indicating */
/* the contribution along each axis to the final */
/* interpolated font. */
/* */
typedef struct GX_BlendRec_
{
FT_UInt num_axis;
FT_Fixed* normalizedcoords;
FT_MM_Var* mmvar;
FT_Offset mmvar_len;
FT_Bool avar_checked;
GX_AVarSegment avar_segment;
FT_UInt tuplecount; /* shared tuples in `gvar' */
FT_Fixed* tuplecoords; /* tuplecoords[tuplecount][num_axis] */
FT_UInt gv_glyphcnt;
FT_ULong* glyphoffsets;
} GX_BlendRec;
/*************************************************************************/
/* */
/* <enum> */
/* GX_TupleCountFlags */
/* */
/* <Description> */
/* Flags used within the `TupleCount' field of the `gvar' table. */
/* */
typedef enum GX_TupleCountFlags_
{
GX_TC_TUPLES_SHARE_POINT_NUMBERS = 0x8000,
GX_TC_RESERVED_TUPLE_FLAGS = 0x7000,
GX_TC_TUPLE_COUNT_MASK = 0x0FFF
} GX_TupleCountFlags;
/*************************************************************************/
/* */
/* <enum> */
/* GX_TupleIndexFlags */
/* */
/* <Description> */
/* Flags used within the `TupleIndex' field of the `gvar' and `cvar' */
/* tables. */
/* */
typedef enum GX_TupleIndexFlags_
{
GX_TI_EMBEDDED_TUPLE_COORD = 0x8000,
GX_TI_INTERMEDIATE_TUPLE = 0x4000,
GX_TI_PRIVATE_POINT_NUMBERS = 0x2000,
GX_TI_RESERVED_TUPLE_FLAG = 0x1000,
GX_TI_TUPLE_INDEX_MASK = 0x0FFF
} GX_TupleIndexFlags;
#define TTAG_wght FT_MAKE_TAG( 'w', 'g', 'h', 't' )
#define TTAG_wdth FT_MAKE_TAG( 'w', 'd', 't', 'h' )
#define TTAG_opsz FT_MAKE_TAG( 'o', 'p', 's', 'z' )
#define TTAG_slnt FT_MAKE_TAG( 's', 'l', 'n', 't' )
FT_LOCAL( FT_Error )
TT_Set_MM_Blend( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
TT_Set_Var_Design( TT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
FT_LOCAL( FT_Error )
TT_Get_MM_Var( TT_Face face,
FT_MM_Var* *master );
FT_LOCAL( FT_Error )
tt_face_vary_cvt( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
TT_Vary_Get_Glyph_Deltas( TT_Face face,
FT_UInt glyph_index,
FT_Vector* *deltas,
FT_UInt n_points );
FT_LOCAL( void )
tt_done_blend( FT_Memory memory,
GX_Blend blend );
FT_END_HEADER
#endif /* __TTGXVAR_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttgxvar.h | C | apache-2.0 | 7,810 |
/***************************************************************************/
/* */
/* ttinterp.c */
/* */
/* TrueType bytecode interpreter (body). */
/* */
/* Copyright 1996-2014 */
/* 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. */
/* */
/***************************************************************************/
/* Greg Hitchcock from Microsoft has helped a lot in resolving unclear */
/* issues; many thanks! */
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_TRIGONOMETRY_H
#include FT_SYSTEM_H
#include FT_TRUETYPE_DRIVER_H
#include "ttinterp.h"
#include "tterrors.h"
#include "ttsubpix.h"
#ifdef TT_USE_BYTECODE_INTERPRETER
/*************************************************************************/
/* */
/* 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_ttinterp
/*************************************************************************/
/* */
/* In order to detect infinite loops in the code, we set up a counter */
/* within the run loop. A single stroke of interpretation is now */
/* limited to a maximum number of opcodes defined below. */
/* */
#define MAX_RUNNABLE_OPCODES 1000000L
/*************************************************************************/
/* */
/* There are two kinds of implementations: */
/* */
/* a. static implementation */
/* */
/* The current execution context is a static variable, which fields */
/* are accessed directly by the interpreter during execution. The */
/* context is named `cur'. */
/* */
/* This version is non-reentrant, of course. */
/* */
/* b. indirect implementation */
/* */
/* The current execution context is passed to _each_ function as its */
/* first argument, and each field is thus accessed indirectly. */
/* */
/* This version is fully re-entrant. */
/* */
/* The idea is that an indirect implementation may be slower to execute */
/* on low-end processors that are used in some systems (like 386s or */
/* even 486s). */
/* */
/* As a consequence, the indirect implementation is now the default, as */
/* its performance costs can be considered negligible in our context. */
/* Note, however, that we kept the same source with macros because: */
/* */
/* - The code is kept very close in design to the Pascal code used for */
/* development. */
/* */
/* - It's much more readable that way! */
/* */
/* - It's still open to experimentation and tuning. */
/* */
/*************************************************************************/
#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
#define CUR (*exc) /* see ttobjs.h */
/*************************************************************************/
/* */
/* This macro is used whenever `exec' is unused in a function, to avoid */
/* stupid warnings from pedantic compilers. */
/* */
#define FT_UNUSED_EXEC FT_UNUSED( exc )
#else /* static implementation */
#define CUR cur
#define FT_UNUSED_EXEC int __dummy = __dummy
static
TT_ExecContextRec cur; /* static exec. context variable */
/* apparently, we have a _lot_ of direct indexing when accessing */
/* the static `cur', which makes the code bigger (due to all the */
/* four bytes addresses). */
#endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
/*************************************************************************/
/* */
/* The instruction argument stack. */
/* */
#define INS_ARG EXEC_OP_ FT_Long* args /* see ttobjs.h for EXEC_OP_ */
/*************************************************************************/
/* */
/* This macro is used whenever `args' is unused in a function, to avoid */
/* stupid warnings from pedantic compilers. */
/* */
#define FT_UNUSED_ARG FT_UNUSED_EXEC; FT_UNUSED( args )
#define SUBPIXEL_HINTING \
( ((TT_Driver)FT_FACE_DRIVER( CUR.face ))->interpreter_version == \
TT_INTERPRETER_VERSION_38 )
/*************************************************************************/
/* */
/* The following macros hide the use of EXEC_ARG and EXEC_ARG_ to */
/* increase readability of the code. */
/* */
/*************************************************************************/
#define SKIP_Code() \
SkipCode( EXEC_ARG )
#define GET_ShortIns() \
GetShortIns( EXEC_ARG )
#define NORMalize( x, y, v ) \
Normalize( EXEC_ARG_ x, y, v )
#define SET_SuperRound( scale, flags ) \
SetSuperRound( EXEC_ARG_ scale, flags )
#define ROUND_None( d, c ) \
Round_None( EXEC_ARG_ d, c )
#define INS_Goto_CodeRange( range, ip ) \
Ins_Goto_CodeRange( EXEC_ARG_ range, ip )
#define CUR_Func_move( z, p, d ) \
CUR.func_move( EXEC_ARG_ z, p, d )
#define CUR_Func_move_orig( z, p, d ) \
CUR.func_move_orig( EXEC_ARG_ z, p, d )
#define CUR_Func_round( d, c ) \
CUR.func_round( EXEC_ARG_ d, c )
#define CUR_Func_read_cvt( index ) \
CUR.func_read_cvt( EXEC_ARG_ index )
#define CUR_Func_write_cvt( index, val ) \
CUR.func_write_cvt( EXEC_ARG_ index, val )
#define CUR_Func_move_cvt( index, val ) \
CUR.func_move_cvt( EXEC_ARG_ index, val )
#define CURRENT_Ratio() \
Current_Ratio( EXEC_ARG )
#define CURRENT_Ppem() \
Current_Ppem( EXEC_ARG )
#define CUR_Ppem() \
Cur_PPEM( EXEC_ARG )
#define INS_SxVTL( a, b, c, d ) \
Ins_SxVTL( EXEC_ARG_ a, b, c, d )
#define COMPUTE_Funcs() \
Compute_Funcs( EXEC_ARG )
#define COMPUTE_Round( a ) \
Compute_Round( EXEC_ARG_ a )
#define COMPUTE_Point_Displacement( a, b, c, d ) \
Compute_Point_Displacement( EXEC_ARG_ a, b, c, d )
#define MOVE_Zp2_Point( a, b, c, t ) \
Move_Zp2_Point( EXEC_ARG_ a, b, c, t )
#define CUR_Func_project( v1, v2 ) \
CUR.func_project( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
#define CUR_Func_dualproj( v1, v2 ) \
CUR.func_dualproj( EXEC_ARG_ (v1)->x - (v2)->x, (v1)->y - (v2)->y )
#define CUR_fast_project( v ) \
CUR.func_project( EXEC_ARG_ (v)->x, (v)->y )
#define CUR_fast_dualproj( v ) \
CUR.func_dualproj( EXEC_ARG_ (v)->x, (v)->y )
/*************************************************************************/
/* */
/* Instruction dispatch function, as used by the interpreter. */
/* */
typedef void (*TInstruction_Function)( INS_ARG );
/*************************************************************************/
/* */
/* Two simple bounds-checking macros. */
/* */
#define BOUNDS( x, n ) ( (FT_UInt)(x) >= (FT_UInt)(n) )
#define BOUNDSL( x, n ) ( (FT_ULong)(x) >= (FT_ULong)(n) )
/*************************************************************************/
/* */
/* This macro computes (a*2^14)/b and complements TT_MulFix14. */
/* */
#define TT_DivFix14( a, b ) \
FT_DivFix( a, (b) << 2 )
#undef SUCCESS
#define SUCCESS 0
#undef FAILURE
#define FAILURE 1
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
#define GUESS_VECTOR( V ) \
if ( CUR.face->unpatented_hinting ) \
{ \
CUR.GS.V.x = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0x4000 : 0 ); \
CUR.GS.V.y = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0 : 0x4000 ); \
}
#else
#define GUESS_VECTOR( V )
#endif
/*************************************************************************/
/* */
/* CODERANGE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* TT_Goto_CodeRange */
/* */
/* <Description> */
/* Switches to a new code range (updates the code related elements in */
/* `exec', and `IP'). */
/* */
/* <Input> */
/* range :: The new execution code range. */
/* */
/* IP :: The new IP in the new code range. */
/* */
/* <InOut> */
/* exec :: The target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP )
{
TT_CodeRange* coderange;
FT_ASSERT( range >= 1 && range <= 3 );
coderange = &exec->codeRangeTable[range - 1];
FT_ASSERT( coderange->base != NULL );
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for IP <= Size instead of IP < Size. */
/* */
FT_ASSERT( (FT_ULong)IP <= coderange->size );
exec->code = coderange->base;
exec->codeSize = coderange->size;
exec->IP = IP;
exec->curRange = range;
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Set_CodeRange */
/* */
/* <Description> */
/* Sets a code range. */
/* */
/* <Input> */
/* range :: The code range index. */
/* */
/* base :: The new code base. */
/* */
/* length :: The range size in bytes. */
/* */
/* <InOut> */
/* exec :: The target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = (FT_Byte*)base;
exec->codeRangeTable[range - 1].size = length;
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Clear_CodeRange */
/* */
/* <Description> */
/* Clears a code range. */
/* */
/* <Input> */
/* range :: The code range index. */
/* */
/* <InOut> */
/* exec :: The target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Does not set the Error variable. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range )
{
FT_ASSERT( range >= 1 && range <= 3 );
exec->codeRangeTable[range - 1].base = NULL;
exec->codeRangeTable[range - 1].size = 0;
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* EXECUTION CONTEXT ROUTINES */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Context */
/* */
/* <Description> */
/* Destroys a given context. */
/* */
/* <Input> */
/* exec :: A handle to the target execution context. */
/* */
/* memory :: A handle to the parent memory object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Done_Context( TT_ExecContext exec )
{
FT_Memory memory = exec->memory;
/* points zone */
exec->maxPoints = 0;
exec->maxContours = 0;
/* free stack */
FT_FREE( exec->stack );
exec->stackSize = 0;
/* free call stack */
FT_FREE( exec->callStack );
exec->callSize = 0;
exec->callTop = 0;
/* free glyph code range */
FT_FREE( exec->glyphIns );
exec->glyphSize = 0;
exec->size = NULL;
exec->face = NULL;
FT_FREE( exec );
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* Init_Context */
/* */
/* <Description> */
/* Initializes a context object. */
/* */
/* <Input> */
/* memory :: A handle to the parent memory object. */
/* */
/* <InOut> */
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
static FT_Error
Init_Context( TT_ExecContext exec,
FT_Memory memory )
{
FT_Error error;
FT_TRACE1(( "Init_Context: new object at 0x%08p\n", exec ));
exec->memory = memory;
exec->callSize = 32;
if ( FT_NEW_ARRAY( exec->callStack, exec->callSize ) )
goto Fail_Memory;
/* all values in the context are set to 0 already, but this is */
/* here as a remainder */
exec->maxPoints = 0;
exec->maxContours = 0;
exec->stackSize = 0;
exec->glyphSize = 0;
exec->stack = NULL;
exec->glyphIns = NULL;
exec->face = NULL;
exec->size = NULL;
return FT_Err_Ok;
Fail_Memory:
FT_ERROR(( "Init_Context: not enough memory for %p\n", exec ));
TT_Done_Context( exec );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* Update_Max */
/* */
/* <Description> */
/* Checks the size of a buffer and reallocates it if necessary. */
/* */
/* <Input> */
/* memory :: A handle to the parent memory object. */
/* */
/* multiplier :: The size in bytes of each element in the buffer. */
/* */
/* new_max :: The new capacity (size) of the buffer. */
/* */
/* <InOut> */
/* size :: The address of the buffer's current size expressed */
/* in elements. */
/* */
/* buff :: The address of the buffer base pointer. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
Update_Max( FT_Memory memory,
FT_ULong* size,
FT_Long multiplier,
void* _pbuff,
FT_ULong new_max )
{
FT_Error error;
void** pbuff = (void**)_pbuff;
if ( *size < new_max )
{
if ( FT_REALLOC( *pbuff, *size * multiplier, new_max * multiplier ) )
return error;
*size = new_max;
}
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Load_Context */
/* */
/* <Description> */
/* Prepare an execution context for glyph hinting. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* size :: A handle to the source size object. */
/* */
/* <InOut> */
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size )
{
FT_Int i;
FT_ULong tmp;
TT_MaxProfile* maxp;
FT_Error error;
exec->face = face;
maxp = &face->max_profile;
exec->size = size;
if ( size )
{
exec->numFDefs = size->num_function_defs;
exec->maxFDefs = size->max_function_defs;
exec->numIDefs = size->num_instruction_defs;
exec->maxIDefs = size->max_instruction_defs;
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->tt_metrics = size->ttmetrics;
exec->metrics = size->metrics;
exec->maxFunc = size->max_func;
exec->maxIns = size->max_ins;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
exec->codeRangeTable[i] = size->codeRangeTable[i];
/* set graphics state */
exec->GS = size->GS;
exec->cvtSize = size->cvt_size;
exec->cvt = size->cvt;
exec->storeSize = size->storage_size;
exec->storage = size->storage;
exec->twilight = size->twilight;
/* In case of multi-threading it can happen that the old size object */
/* no longer exists, thus we must clear all glyph zone references. */
ft_memset( &exec->zp0, 0, sizeof ( exec->zp0 ) );
exec->zp1 = exec->zp0;
exec->zp2 = exec->zp0;
}
/* XXX: We reserve a little more elements on the stack to deal safely */
/* with broken fonts like arialbs, courbs, timesbs, etc. */
tmp = exec->stackSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_F26Dot6 ),
(void*)&exec->stack,
maxp->maxStackElements + 32 );
exec->stackSize = (FT_UInt)tmp;
if ( error )
return error;
tmp = exec->glyphSize;
error = Update_Max( exec->memory,
&tmp,
sizeof ( FT_Byte ),
(void*)&exec->glyphIns,
maxp->maxSizeOfInstructions );
exec->glyphSize = (FT_UShort)tmp;
if ( error )
return error;
exec->pts.n_points = 0;
exec->pts.n_contours = 0;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->zp0 = exec->pts;
exec->instruction_trap = FALSE;
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Save_Context */
/* */
/* <Description> */
/* Saves the code ranges in a `size' object. */
/* */
/* <Input> */
/* exec :: A handle to the source execution context. */
/* */
/* <InOut> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Save_Context( TT_ExecContext exec,
TT_Size size )
{
FT_Int i;
/* XXX: Will probably disappear soon with all the code range */
/* management, which is now rather obsolete. */
/* */
size->num_function_defs = exec->numFDefs;
size->num_instruction_defs = exec->numIDefs;
size->max_func = exec->maxFunc;
size->max_ins = exec->maxIns;
for ( i = 0; i < TT_MAX_CODE_RANGES; i++ )
size->codeRangeTable[i] = exec->codeRangeTable[i];
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* TT_Run_Context */
/* */
/* <Description> */
/* Executes one or more instructions in the execution context. */
/* */
/* <Input> */
/* debug :: A Boolean flag. If set, the function sets some internal */
/* variables and returns immediately, otherwise TT_RunIns() */
/* is called. */
/* */
/* This is commented out currently. */
/* */
/* <Input> */
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
FT_LOCAL_DEF( FT_Error )
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug )
{
FT_Error error;
if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) )
!= FT_Err_Ok )
return error;
exec->zp0 = exec->pts;
exec->zp1 = exec->pts;
exec->zp2 = exec->pts;
exec->GS.gep0 = 1;
exec->GS.gep1 = 1;
exec->GS.gep2 = 1;
exec->GS.projVector.x = 0x4000;
exec->GS.projVector.y = 0x0000;
exec->GS.freeVector = exec->GS.projVector;
exec->GS.dualVector = exec->GS.projVector;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
exec->GS.both_x_axis = TRUE;
#endif
exec->GS.round_state = 1;
exec->GS.loop = 1;
/* some glyphs leave something on the stack. so we clean it */
/* before a new execution. */
exec->top = 0;
exec->callTop = 0;
#if 1
FT_UNUSED( debug );
return exec->face->interpreter( exec );
#else
if ( !debug )
return TT_RunIns( exec );
else
return FT_Err_Ok;
#endif
}
/* The default value for `scan_control' is documented as FALSE in the */
/* TrueType specification. This is confusing since it implies a */
/* Boolean value. However, this is not the case, thus both the */
/* default values of our `scan_type' and `scan_control' fields (which */
/* the documentation's `scan_control' variable is split into) are */
/* zero. */
const TT_GraphicsState tt_default_graphics_state =
{
0, 0, 0,
{ 0x4000, 0 },
{ 0x4000, 0 },
{ 0x4000, 0 },
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
TRUE,
#endif
1, 64, 1,
TRUE, 68, 0, 0, 9, 3,
0, FALSE, 0, 1, 1, 1
};
/* documentation is in ttinterp.h */
FT_EXPORT_DEF( TT_ExecContext )
TT_New_Context( TT_Driver driver )
{
FT_Memory memory = driver->root.root.memory;
if ( !driver->context )
{
FT_Error error;
TT_ExecContext exec;
/* allocate object */
if ( FT_NEW( exec ) )
goto Fail;
/* initialize it; in case of error this deallocates `exec' too */
error = Init_Context( exec, memory );
if ( error )
goto Fail;
/* store it into the driver */
driver->context = exec;
}
return driver->context;
Fail:
return NULL;
}
/*************************************************************************/
/* */
/* Before an opcode is executed, the interpreter verifies that there are */
/* enough arguments on the stack, with the help of the `Pop_Push_Count' */
/* table. */
/* */
/* For each opcode, the first column gives the number of arguments that */
/* are popped from the stack; the second one gives the number of those */
/* that are pushed in result. */
/* */
/* Opcodes which have a varying number of parameters in the data stream */
/* (NPUSHB, NPUSHW) are handled specially; they have a negative value in */
/* the `opcode_length' table, and the value in `Pop_Push_Count' is set */
/* to zero. */
/* */
/*************************************************************************/
#undef PACK
#define PACK( x, y ) ( ( x << 4 ) | y )
static
const FT_Byte Pop_Push_Count[256] =
{
/* opcodes are gathered in groups of 16 */
/* please keep the spaces as they are */
/* SVTCA y */ PACK( 0, 0 ),
/* SVTCA x */ PACK( 0, 0 ),
/* SPvTCA y */ PACK( 0, 0 ),
/* SPvTCA x */ PACK( 0, 0 ),
/* SFvTCA y */ PACK( 0, 0 ),
/* SFvTCA x */ PACK( 0, 0 ),
/* SPvTL // */ PACK( 2, 0 ),
/* SPvTL + */ PACK( 2, 0 ),
/* SFvTL // */ PACK( 2, 0 ),
/* SFvTL + */ PACK( 2, 0 ),
/* SPvFS */ PACK( 2, 0 ),
/* SFvFS */ PACK( 2, 0 ),
/* GPV */ PACK( 0, 2 ),
/* GFV */ PACK( 0, 2 ),
/* SFvTPv */ PACK( 0, 0 ),
/* ISECT */ PACK( 5, 0 ),
/* SRP0 */ PACK( 1, 0 ),
/* SRP1 */ PACK( 1, 0 ),
/* SRP2 */ PACK( 1, 0 ),
/* SZP0 */ PACK( 1, 0 ),
/* SZP1 */ PACK( 1, 0 ),
/* SZP2 */ PACK( 1, 0 ),
/* SZPS */ PACK( 1, 0 ),
/* SLOOP */ PACK( 1, 0 ),
/* RTG */ PACK( 0, 0 ),
/* RTHG */ PACK( 0, 0 ),
/* SMD */ PACK( 1, 0 ),
/* ELSE */ PACK( 0, 0 ),
/* JMPR */ PACK( 1, 0 ),
/* SCvTCi */ PACK( 1, 0 ),
/* SSwCi */ PACK( 1, 0 ),
/* SSW */ PACK( 1, 0 ),
/* DUP */ PACK( 1, 2 ),
/* POP */ PACK( 1, 0 ),
/* CLEAR */ PACK( 0, 0 ),
/* SWAP */ PACK( 2, 2 ),
/* DEPTH */ PACK( 0, 1 ),
/* CINDEX */ PACK( 1, 1 ),
/* MINDEX */ PACK( 1, 0 ),
/* AlignPTS */ PACK( 2, 0 ),
/* INS_$28 */ PACK( 0, 0 ),
/* UTP */ PACK( 1, 0 ),
/* LOOPCALL */ PACK( 2, 0 ),
/* CALL */ PACK( 1, 0 ),
/* FDEF */ PACK( 1, 0 ),
/* ENDF */ PACK( 0, 0 ),
/* MDAP[0] */ PACK( 1, 0 ),
/* MDAP[1] */ PACK( 1, 0 ),
/* IUP[0] */ PACK( 0, 0 ),
/* IUP[1] */ PACK( 0, 0 ),
/* SHP[0] */ PACK( 0, 0 ),
/* SHP[1] */ PACK( 0, 0 ),
/* SHC[0] */ PACK( 1, 0 ),
/* SHC[1] */ PACK( 1, 0 ),
/* SHZ[0] */ PACK( 1, 0 ),
/* SHZ[1] */ PACK( 1, 0 ),
/* SHPIX */ PACK( 1, 0 ),
/* IP */ PACK( 0, 0 ),
/* MSIRP[0] */ PACK( 2, 0 ),
/* MSIRP[1] */ PACK( 2, 0 ),
/* AlignRP */ PACK( 0, 0 ),
/* RTDG */ PACK( 0, 0 ),
/* MIAP[0] */ PACK( 2, 0 ),
/* MIAP[1] */ PACK( 2, 0 ),
/* NPushB */ PACK( 0, 0 ),
/* NPushW */ PACK( 0, 0 ),
/* WS */ PACK( 2, 0 ),
/* RS */ PACK( 1, 1 ),
/* WCvtP */ PACK( 2, 0 ),
/* RCvt */ PACK( 1, 1 ),
/* GC[0] */ PACK( 1, 1 ),
/* GC[1] */ PACK( 1, 1 ),
/* SCFS */ PACK( 2, 0 ),
/* MD[0] */ PACK( 2, 1 ),
/* MD[1] */ PACK( 2, 1 ),
/* MPPEM */ PACK( 0, 1 ),
/* MPS */ PACK( 0, 1 ),
/* FlipON */ PACK( 0, 0 ),
/* FlipOFF */ PACK( 0, 0 ),
/* DEBUG */ PACK( 1, 0 ),
/* LT */ PACK( 2, 1 ),
/* LTEQ */ PACK( 2, 1 ),
/* GT */ PACK( 2, 1 ),
/* GTEQ */ PACK( 2, 1 ),
/* EQ */ PACK( 2, 1 ),
/* NEQ */ PACK( 2, 1 ),
/* ODD */ PACK( 1, 1 ),
/* EVEN */ PACK( 1, 1 ),
/* IF */ PACK( 1, 0 ),
/* EIF */ PACK( 0, 0 ),
/* AND */ PACK( 2, 1 ),
/* OR */ PACK( 2, 1 ),
/* NOT */ PACK( 1, 1 ),
/* DeltaP1 */ PACK( 1, 0 ),
/* SDB */ PACK( 1, 0 ),
/* SDS */ PACK( 1, 0 ),
/* ADD */ PACK( 2, 1 ),
/* SUB */ PACK( 2, 1 ),
/* DIV */ PACK( 2, 1 ),
/* MUL */ PACK( 2, 1 ),
/* ABS */ PACK( 1, 1 ),
/* NEG */ PACK( 1, 1 ),
/* FLOOR */ PACK( 1, 1 ),
/* CEILING */ PACK( 1, 1 ),
/* ROUND[0] */ PACK( 1, 1 ),
/* ROUND[1] */ PACK( 1, 1 ),
/* ROUND[2] */ PACK( 1, 1 ),
/* ROUND[3] */ PACK( 1, 1 ),
/* NROUND[0] */ PACK( 1, 1 ),
/* NROUND[1] */ PACK( 1, 1 ),
/* NROUND[2] */ PACK( 1, 1 ),
/* NROUND[3] */ PACK( 1, 1 ),
/* WCvtF */ PACK( 2, 0 ),
/* DeltaP2 */ PACK( 1, 0 ),
/* DeltaP3 */ PACK( 1, 0 ),
/* DeltaCn[0] */ PACK( 1, 0 ),
/* DeltaCn[1] */ PACK( 1, 0 ),
/* DeltaCn[2] */ PACK( 1, 0 ),
/* SROUND */ PACK( 1, 0 ),
/* S45Round */ PACK( 1, 0 ),
/* JROT */ PACK( 2, 0 ),
/* JROF */ PACK( 2, 0 ),
/* ROFF */ PACK( 0, 0 ),
/* INS_$7B */ PACK( 0, 0 ),
/* RUTG */ PACK( 0, 0 ),
/* RDTG */ PACK( 0, 0 ),
/* SANGW */ PACK( 1, 0 ),
/* AA */ PACK( 1, 0 ),
/* FlipPT */ PACK( 0, 0 ),
/* FlipRgON */ PACK( 2, 0 ),
/* FlipRgOFF */ PACK( 2, 0 ),
/* INS_$83 */ PACK( 0, 0 ),
/* INS_$84 */ PACK( 0, 0 ),
/* ScanCTRL */ PACK( 1, 0 ),
/* SDPVTL[0] */ PACK( 2, 0 ),
/* SDPVTL[1] */ PACK( 2, 0 ),
/* GetINFO */ PACK( 1, 1 ),
/* IDEF */ PACK( 1, 0 ),
/* ROLL */ PACK( 3, 3 ),
/* MAX */ PACK( 2, 1 ),
/* MIN */ PACK( 2, 1 ),
/* ScanTYPE */ PACK( 1, 0 ),
/* InstCTRL */ PACK( 2, 0 ),
/* INS_$8F */ PACK( 0, 0 ),
/* INS_$90 */ PACK( 0, 0 ),
/* INS_$91 */ PACK( 0, 0 ),
/* INS_$92 */ PACK( 0, 0 ),
/* INS_$93 */ PACK( 0, 0 ),
/* INS_$94 */ PACK( 0, 0 ),
/* INS_$95 */ PACK( 0, 0 ),
/* INS_$96 */ PACK( 0, 0 ),
/* INS_$97 */ PACK( 0, 0 ),
/* INS_$98 */ PACK( 0, 0 ),
/* INS_$99 */ PACK( 0, 0 ),
/* INS_$9A */ PACK( 0, 0 ),
/* INS_$9B */ PACK( 0, 0 ),
/* INS_$9C */ PACK( 0, 0 ),
/* INS_$9D */ PACK( 0, 0 ),
/* INS_$9E */ PACK( 0, 0 ),
/* INS_$9F */ PACK( 0, 0 ),
/* INS_$A0 */ PACK( 0, 0 ),
/* INS_$A1 */ PACK( 0, 0 ),
/* INS_$A2 */ PACK( 0, 0 ),
/* INS_$A3 */ PACK( 0, 0 ),
/* INS_$A4 */ PACK( 0, 0 ),
/* INS_$A5 */ PACK( 0, 0 ),
/* INS_$A6 */ PACK( 0, 0 ),
/* INS_$A7 */ PACK( 0, 0 ),
/* INS_$A8 */ PACK( 0, 0 ),
/* INS_$A9 */ PACK( 0, 0 ),
/* INS_$AA */ PACK( 0, 0 ),
/* INS_$AB */ PACK( 0, 0 ),
/* INS_$AC */ PACK( 0, 0 ),
/* INS_$AD */ PACK( 0, 0 ),
/* INS_$AE */ PACK( 0, 0 ),
/* INS_$AF */ PACK( 0, 0 ),
/* PushB[0] */ PACK( 0, 1 ),
/* PushB[1] */ PACK( 0, 2 ),
/* PushB[2] */ PACK( 0, 3 ),
/* PushB[3] */ PACK( 0, 4 ),
/* PushB[4] */ PACK( 0, 5 ),
/* PushB[5] */ PACK( 0, 6 ),
/* PushB[6] */ PACK( 0, 7 ),
/* PushB[7] */ PACK( 0, 8 ),
/* PushW[0] */ PACK( 0, 1 ),
/* PushW[1] */ PACK( 0, 2 ),
/* PushW[2] */ PACK( 0, 3 ),
/* PushW[3] */ PACK( 0, 4 ),
/* PushW[4] */ PACK( 0, 5 ),
/* PushW[5] */ PACK( 0, 6 ),
/* PushW[6] */ PACK( 0, 7 ),
/* PushW[7] */ PACK( 0, 8 ),
/* MDRP[00] */ PACK( 1, 0 ),
/* MDRP[01] */ PACK( 1, 0 ),
/* MDRP[02] */ PACK( 1, 0 ),
/* MDRP[03] */ PACK( 1, 0 ),
/* MDRP[04] */ PACK( 1, 0 ),
/* MDRP[05] */ PACK( 1, 0 ),
/* MDRP[06] */ PACK( 1, 0 ),
/* MDRP[07] */ PACK( 1, 0 ),
/* MDRP[08] */ PACK( 1, 0 ),
/* MDRP[09] */ PACK( 1, 0 ),
/* MDRP[10] */ PACK( 1, 0 ),
/* MDRP[11] */ PACK( 1, 0 ),
/* MDRP[12] */ PACK( 1, 0 ),
/* MDRP[13] */ PACK( 1, 0 ),
/* MDRP[14] */ PACK( 1, 0 ),
/* MDRP[15] */ PACK( 1, 0 ),
/* MDRP[16] */ PACK( 1, 0 ),
/* MDRP[17] */ PACK( 1, 0 ),
/* MDRP[18] */ PACK( 1, 0 ),
/* MDRP[19] */ PACK( 1, 0 ),
/* MDRP[20] */ PACK( 1, 0 ),
/* MDRP[21] */ PACK( 1, 0 ),
/* MDRP[22] */ PACK( 1, 0 ),
/* MDRP[23] */ PACK( 1, 0 ),
/* MDRP[24] */ PACK( 1, 0 ),
/* MDRP[25] */ PACK( 1, 0 ),
/* MDRP[26] */ PACK( 1, 0 ),
/* MDRP[27] */ PACK( 1, 0 ),
/* MDRP[28] */ PACK( 1, 0 ),
/* MDRP[29] */ PACK( 1, 0 ),
/* MDRP[30] */ PACK( 1, 0 ),
/* MDRP[31] */ PACK( 1, 0 ),
/* MIRP[00] */ PACK( 2, 0 ),
/* MIRP[01] */ PACK( 2, 0 ),
/* MIRP[02] */ PACK( 2, 0 ),
/* MIRP[03] */ PACK( 2, 0 ),
/* MIRP[04] */ PACK( 2, 0 ),
/* MIRP[05] */ PACK( 2, 0 ),
/* MIRP[06] */ PACK( 2, 0 ),
/* MIRP[07] */ PACK( 2, 0 ),
/* MIRP[08] */ PACK( 2, 0 ),
/* MIRP[09] */ PACK( 2, 0 ),
/* MIRP[10] */ PACK( 2, 0 ),
/* MIRP[11] */ PACK( 2, 0 ),
/* MIRP[12] */ PACK( 2, 0 ),
/* MIRP[13] */ PACK( 2, 0 ),
/* MIRP[14] */ PACK( 2, 0 ),
/* MIRP[15] */ PACK( 2, 0 ),
/* MIRP[16] */ PACK( 2, 0 ),
/* MIRP[17] */ PACK( 2, 0 ),
/* MIRP[18] */ PACK( 2, 0 ),
/* MIRP[19] */ PACK( 2, 0 ),
/* MIRP[20] */ PACK( 2, 0 ),
/* MIRP[21] */ PACK( 2, 0 ),
/* MIRP[22] */ PACK( 2, 0 ),
/* MIRP[23] */ PACK( 2, 0 ),
/* MIRP[24] */ PACK( 2, 0 ),
/* MIRP[25] */ PACK( 2, 0 ),
/* MIRP[26] */ PACK( 2, 0 ),
/* MIRP[27] */ PACK( 2, 0 ),
/* MIRP[28] */ PACK( 2, 0 ),
/* MIRP[29] */ PACK( 2, 0 ),
/* MIRP[30] */ PACK( 2, 0 ),
/* MIRP[31] */ PACK( 2, 0 )
};
#ifdef FT_DEBUG_LEVEL_TRACE
static
const char* const opcode_name[256] =
{
"SVTCA y",
"SVTCA x",
"SPvTCA y",
"SPvTCA x",
"SFvTCA y",
"SFvTCA x",
"SPvTL ||",
"SPvTL +",
"SFvTL ||",
"SFvTL +",
"SPvFS",
"SFvFS",
"GPV",
"GFV",
"SFvTPv",
"ISECT",
"SRP0",
"SRP1",
"SRP2",
"SZP0",
"SZP1",
"SZP2",
"SZPS",
"SLOOP",
"RTG",
"RTHG",
"SMD",
"ELSE",
"JMPR",
"SCvTCi",
"SSwCi",
"SSW",
"DUP",
"POP",
"CLEAR",
"SWAP",
"DEPTH",
"CINDEX",
"MINDEX",
"AlignPTS",
"INS_$28",
"UTP",
"LOOPCALL",
"CALL",
"FDEF",
"ENDF",
"MDAP[0]",
"MDAP[1]",
"IUP[0]",
"IUP[1]",
"SHP[0]",
"SHP[1]",
"SHC[0]",
"SHC[1]",
"SHZ[0]",
"SHZ[1]",
"SHPIX",
"IP",
"MSIRP[0]",
"MSIRP[1]",
"AlignRP",
"RTDG",
"MIAP[0]",
"MIAP[1]",
"NPushB",
"NPushW",
"WS",
"RS",
"WCvtP",
"RCvt",
"GC[0]",
"GC[1]",
"SCFS",
"MD[0]",
"MD[1]",
"MPPEM",
"MPS",
"FlipON",
"FlipOFF",
"DEBUG",
"LT",
"LTEQ",
"GT",
"GTEQ",
"EQ",
"NEQ",
"ODD",
"EVEN",
"IF",
"EIF",
"AND",
"OR",
"NOT",
"DeltaP1",
"SDB",
"SDS",
"ADD",
"SUB",
"DIV",
"MUL",
"ABS",
"NEG",
"FLOOR",
"CEILING",
"ROUND[0]",
"ROUND[1]",
"ROUND[2]",
"ROUND[3]",
"NROUND[0]",
"NROUND[1]",
"NROUND[2]",
"NROUND[3]",
"WCvtF",
"DeltaP2",
"DeltaP3",
"DeltaCn[0]",
"DeltaCn[1]",
"DeltaCn[2]",
"SROUND",
"S45Round",
"JROT",
"JROF",
"ROFF",
"INS_$7B",
"RUTG",
"RDTG",
"SANGW",
"AA",
"FlipPT",
"FlipRgON",
"FlipRgOFF",
"INS_$83",
"INS_$84",
"ScanCTRL",
"SDVPTL[0]",
"SDVPTL[1]",
"GetINFO",
"IDEF",
"ROLL",
"MAX",
"MIN",
"ScanTYPE",
"InstCTRL",
"INS_$8F",
"INS_$90",
"INS_$91",
"INS_$92",
"INS_$93",
"INS_$94",
"INS_$95",
"INS_$96",
"INS_$97",
"INS_$98",
"INS_$99",
"INS_$9A",
"INS_$9B",
"INS_$9C",
"INS_$9D",
"INS_$9E",
"INS_$9F",
"INS_$A0",
"INS_$A1",
"INS_$A2",
"INS_$A3",
"INS_$A4",
"INS_$A5",
"INS_$A6",
"INS_$A7",
"INS_$A8",
"INS_$A9",
"INS_$AA",
"INS_$AB",
"INS_$AC",
"INS_$AD",
"INS_$AE",
"INS_$AF",
"PushB[0]",
"PushB[1]",
"PushB[2]",
"PushB[3]",
"PushB[4]",
"PushB[5]",
"PushB[6]",
"PushB[7]",
"PushW[0]",
"PushW[1]",
"PushW[2]",
"PushW[3]",
"PushW[4]",
"PushW[5]",
"PushW[6]",
"PushW[7]",
"MDRP[00]",
"MDRP[01]",
"MDRP[02]",
"MDRP[03]",
"MDRP[04]",
"MDRP[05]",
"MDRP[06]",
"MDRP[07]",
"MDRP[08]",
"MDRP[09]",
"MDRP[10]",
"MDRP[11]",
"MDRP[12]",
"MDRP[13]",
"MDRP[14]",
"MDRP[15]",
"MDRP[16]",
"MDRP[17]",
"MDRP[18]",
"MDRP[19]",
"MDRP[20]",
"MDRP[21]",
"MDRP[22]",
"MDRP[23]",
"MDRP[24]",
"MDRP[25]",
"MDRP[26]",
"MDRP[27]",
"MDRP[28]",
"MDRP[29]",
"MDRP[30]",
"MDRP[31]",
"MIRP[00]",
"MIRP[01]",
"MIRP[02]",
"MIRP[03]",
"MIRP[04]",
"MIRP[05]",
"MIRP[06]",
"MIRP[07]",
"MIRP[08]",
"MIRP[09]",
"MIRP[10]",
"MIRP[11]",
"MIRP[12]",
"MIRP[13]",
"MIRP[14]",
"MIRP[15]",
"MIRP[16]",
"MIRP[17]",
"MIRP[18]",
"MIRP[19]",
"MIRP[20]",
"MIRP[21]",
"MIRP[22]",
"MIRP[23]",
"MIRP[24]",
"MIRP[25]",
"MIRP[26]",
"MIRP[27]",
"MIRP[28]",
"MIRP[29]",
"MIRP[30]",
"MIRP[31]"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
static
const FT_Char opcode_length[256] =
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-1,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 3, 4, 5, 6, 7, 8, 9, 3, 5, 7, 9, 11,13,15,17,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
#undef PACK
#ifndef FT_CONFIG_OPTION_NO_ASSEMBLER
#if defined( __arm__ ) && \
( defined( __thumb2__ ) || !defined( __thumb__ ) )
#define TT_MulFix14 TT_MulFix14_arm
static FT_Int32
TT_MulFix14_arm( FT_Int32 a,
FT_Int b )
{
register FT_Int32 t, t2;
#if defined( __CC_ARM ) || defined( __ARMCC__ )
__asm
{
smull t2, t, b, a /* (lo=t2,hi=t) = a*b */
mov a, t, asr #31 /* a = (hi >> 31) */
add a, a, #0x2000 /* a += 0x2000 */
adds t2, t2, a /* t2 += a */
adc t, t, #0 /* t += carry */
mov a, t2, lsr #14 /* a = t2 >> 14 */
orr a, a, t, lsl #18 /* a |= t << 18 */
}
#elif defined( __GNUC__ )
__asm__ __volatile__ (
"smull %1, %2, %4, %3\n\t" /* (lo=%1,hi=%2) = a*b */
"mov %0, %2, asr #31\n\t" /* %0 = (hi >> 31) */
#if defined( __clang__ ) && defined( __thumb2__ )
"add.w %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
#else
"add %0, %0, #0x2000\n\t" /* %0 += 0x2000 */
#endif
"adds %1, %1, %0\n\t" /* %1 += %0 */
"adc %2, %2, #0\n\t" /* %2 += carry */
"mov %0, %1, lsr #14\n\t" /* %0 = %1 >> 16 */
"orr %0, %0, %2, lsl #18\n\t" /* %0 |= %2 << 16 */
: "=r"(a), "=&r"(t2), "=&r"(t)
: "r"(a), "r"(b)
: "cc" );
#endif
return a;
}
#endif /* __arm__ && ( __thumb2__ || !__thumb__ ) */
#endif /* !FT_CONFIG_OPTION_NO_ASSEMBLER */
#if defined( __GNUC__ ) && \
( defined( __i386__ ) || defined( __x86_64__ ) )
#define TT_MulFix14 TT_MulFix14_long_long
/* Temporarily disable the warning that C90 doesn't support `long long'. */
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wlong-long"
/* This is declared `noinline' because inlining the function results */
/* in slower code. The `pure' attribute indicates that the result */
/* only depends on the parameters. */
static __attribute__(( noinline ))
__attribute__(( pure )) FT_Int32
TT_MulFix14_long_long( FT_Int32 a,
FT_Int b )
{
long long ret = (long long)a * b;
/* The following line assumes that right shifting of signed values */
/* will actually preserve the sign bit. The exact behaviour is */
/* undefined, but this is true on x86 and x86_64. */
long long tmp = ret >> 63;
ret += 0x2000 + tmp;
return (FT_Int32)( ret >> 14 );
}
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
#pragma GCC diagnostic pop
#endif
#endif /* __GNUC__ && ( __i386__ || __x86_64__ ) */
#ifndef TT_MulFix14
/* Compute (a*b)/2^14 with maximum accuracy and rounding. */
/* This is optimized to be faster than calling FT_MulFix() */
/* for platforms where sizeof(int) == 2. */
static FT_Int32
TT_MulFix14( FT_Int32 a,
FT_Int b )
{
FT_Int32 sign;
FT_UInt32 ah, al, mid, lo, hi;
sign = a ^ b;
if ( a < 0 )
a = -a;
if ( b < 0 )
b = -b;
ah = (FT_UInt32)( ( a >> 16 ) & 0xFFFFU );
al = (FT_UInt32)( a & 0xFFFFU );
lo = al * b;
mid = ah * b;
hi = mid >> 16;
mid = ( mid << 16 ) + ( 1 << 13 ); /* rounding */
lo += mid;
if ( lo < mid )
hi += 1;
mid = ( lo >> 14 ) | ( hi << 18 );
return sign >= 0 ? (FT_Int32)mid : -(FT_Int32)mid;
}
#endif /* !TT_MulFix14 */
#if defined( __GNUC__ ) && \
( defined( __i386__ ) || \
defined( __x86_64__ ) || \
defined( __arm__ ) )
#define TT_DotFix14 TT_DotFix14_long_long
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wlong-long"
static __attribute__(( pure )) FT_Int32
TT_DotFix14_long_long( FT_Int32 ax,
FT_Int32 ay,
FT_Int bx,
FT_Int by )
{
/* Temporarily disable the warning that C90 doesn't support */
/* `long long'. */
long long temp1 = (long long)ax * bx;
long long temp2 = (long long)ay * by;
temp1 += temp2;
temp2 = temp1 >> 63;
temp1 += 0x2000 + temp2;
return (FT_Int32)( temp1 >> 14 );
}
#if ( __GNUC__ * 100 + __GNUC_MINOR__ ) >= 406
#pragma GCC diagnostic pop
#endif
#endif /* __GNUC__ && (__arm__ || __i386__ || __x86_64__) */
#ifndef TT_DotFix14
/* compute (ax*bx+ay*by)/2^14 with maximum accuracy and rounding */
static FT_Int32
TT_DotFix14( FT_Int32 ax,
FT_Int32 ay,
FT_Int bx,
FT_Int by )
{
FT_Int32 m, s, hi1, hi2, hi;
FT_UInt32 l, lo1, lo2, lo;
/* compute ax*bx as 64-bit value */
l = (FT_UInt32)( ( ax & 0xFFFFU ) * bx );
m = ( ax >> 16 ) * bx;
lo1 = l + ( (FT_UInt32)m << 16 );
hi1 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo1 < l );
/* compute ay*by as 64-bit value */
l = (FT_UInt32)( ( ay & 0xFFFFU ) * by );
m = ( ay >> 16 ) * by;
lo2 = l + ( (FT_UInt32)m << 16 );
hi2 = ( m >> 16 ) + ( (FT_Int32)l >> 31 ) + ( lo2 < l );
/* add them */
lo = lo1 + lo2;
hi = hi1 + hi2 + ( lo < lo1 );
/* divide the result by 2^14 with rounding */
s = hi >> 31;
l = lo + (FT_UInt32)s;
hi += s + ( l < lo );
lo = l;
l = lo + 0x2000U;
hi += ( l < lo );
return (FT_Int32)( ( (FT_UInt32)hi << 18 ) | ( l >> 14 ) );
}
#endif /* TT_DotFix14 */
/*************************************************************************/
/* */
/* <Function> */
/* Current_Ratio */
/* */
/* <Description> */
/* Returns the current aspect ratio scaling factor depending on the */
/* projection vector's state and device resolutions. */
/* */
/* <Return> */
/* The aspect ratio in 16.16 format, always <= 1.0 . */
/* */
static FT_Long
Current_Ratio( EXEC_OP )
{
if ( !CUR.tt_metrics.ratio )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
}
else
#endif
{
if ( CUR.GS.projVector.y == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
else if ( CUR.GS.projVector.x == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.y_ratio;
else
{
FT_F26Dot6 x, y;
x = TT_MulFix14( CUR.tt_metrics.x_ratio,
CUR.GS.projVector.x );
y = TT_MulFix14( CUR.tt_metrics.y_ratio,
CUR.GS.projVector.y );
CUR.tt_metrics.ratio = FT_Hypot( x, y );
}
}
}
return CUR.tt_metrics.ratio;
}
static FT_Long
Current_Ppem( EXEC_OP )
{
return FT_MulFix( CUR.tt_metrics.ppem, CURRENT_Ratio() );
}
/*************************************************************************/
/* */
/* Functions related to the control value table (CVT). */
/* */
/*************************************************************************/
FT_CALLBACK_DEF( FT_F26Dot6 )
Read_CVT( EXEC_OP_ FT_ULong idx )
{
return CUR.cvt[idx];
}
FT_CALLBACK_DEF( FT_F26Dot6 )
Read_CVT_Stretched( EXEC_OP_ FT_ULong idx )
{
return FT_MulFix( CUR.cvt[idx], CURRENT_Ratio() );
}
FT_CALLBACK_DEF( void )
Write_CVT( EXEC_OP_ FT_ULong idx,
FT_F26Dot6 value )
{
CUR.cvt[idx] = value;
}
FT_CALLBACK_DEF( void )
Write_CVT_Stretched( EXEC_OP_ FT_ULong idx,
FT_F26Dot6 value )
{
CUR.cvt[idx] = FT_DivFix( value, CURRENT_Ratio() );
}
FT_CALLBACK_DEF( void )
Move_CVT( EXEC_OP_ FT_ULong idx,
FT_F26Dot6 value )
{
CUR.cvt[idx] += value;
}
FT_CALLBACK_DEF( void )
Move_CVT_Stretched( EXEC_OP_ FT_ULong idx,
FT_F26Dot6 value )
{
CUR.cvt[idx] += FT_DivFix( value, CURRENT_Ratio() );
}
/*************************************************************************/
/* */
/* <Function> */
/* GetShortIns */
/* */
/* <Description> */
/* Returns a short integer taken from the instruction stream at */
/* address IP. */
/* */
/* <Return> */
/* Short read at code[IP]. */
/* */
/* <Note> */
/* This one could become a macro. */
/* */
static FT_Short
GetShortIns( EXEC_OP )
{
/* Reading a byte stream so there is no endianess (DaveP) */
CUR.IP += 2;
return (FT_Short)( ( CUR.code[CUR.IP - 2] << 8 ) +
CUR.code[CUR.IP - 1] );
}
/*************************************************************************/
/* */
/* <Function> */
/* Ins_Goto_CodeRange */
/* */
/* <Description> */
/* Goes to a certain code range in the instruction stream. */
/* */
/* <Input> */
/* aRange :: The index of the code range. */
/* */
/* aIP :: The new IP address in the code range. */
/* */
/* <Return> */
/* SUCCESS or FAILURE. */
/* */
static FT_Bool
Ins_Goto_CodeRange( EXEC_OP_ FT_Int aRange,
FT_ULong aIP )
{
TT_CodeRange* range;
if ( aRange < 1 || aRange > 3 )
{
CUR.error = FT_THROW( Bad_Argument );
return FAILURE;
}
range = &CUR.codeRangeTable[aRange - 1];
if ( range->base == NULL ) /* invalid coderange */
{
CUR.error = FT_THROW( Invalid_CodeRange );
return FAILURE;
}
/* NOTE: Because the last instruction of a program may be a CALL */
/* which will return to the first byte *after* the code */
/* range, we test for aIP <= Size, instead of aIP < Size. */
if ( aIP > range->size )
{
CUR.error = FT_THROW( Code_Overflow );
return FAILURE;
}
CUR.code = range->base;
CUR.codeSize = range->size;
CUR.IP = aIP;
CUR.curRange = aRange;
return SUCCESS;
}
/*************************************************************************/
/* */
/* <Function> */
/* Direct_Move */
/* */
/* <Description> */
/* Moves a point by a given distance along the freedom vector. The */
/* point will be `touched'. */
/* */
/* <Input> */
/* point :: The index of the point to move. */
/* */
/* distance :: The distance to apply. */
/* */
/* <InOut> */
/* zone :: The affected glyph zone. */
/* */
static void
Direct_Move( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_F26Dot6 v;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
v = CUR.GS.freeVector.x;
if ( v != 0 )
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( !SUBPIXEL_HINTING ||
( !CUR.ignore_x_mode ||
( CUR.sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) )
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
zone->cur[point].x += FT_MulDiv( distance, v, CUR.F_dot_P );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
v = CUR.GS.freeVector.y;
if ( v != 0 )
{
zone->cur[point].y += FT_MulDiv( distance, v, CUR.F_dot_P );
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* Direct_Move_Orig */
/* */
/* <Description> */
/* Moves the *original* position of a point by a given distance along */
/* the freedom vector. Obviously, the point will not be `touched'. */
/* */
/* <Input> */
/* point :: The index of the point to move. */
/* */
/* distance :: The distance to apply. */
/* */
/* <InOut> */
/* zone :: The affected glyph zone. */
/* */
static void
Direct_Move_Orig( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_F26Dot6 v;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
v = CUR.GS.freeVector.x;
if ( v != 0 )
zone->org[point].x += FT_MulDiv( distance, v, CUR.F_dot_P );
v = CUR.GS.freeVector.y;
if ( v != 0 )
zone->org[point].y += FT_MulDiv( distance, v, CUR.F_dot_P );
}
/*************************************************************************/
/* */
/* Special versions of Direct_Move() */
/* */
/* The following versions are used whenever both vectors are both */
/* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
/* */
/*************************************************************************/
static void
Direct_Move_X( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_UNUSED_EXEC;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( !SUBPIXEL_HINTING ||
!CUR.ignore_x_mode )
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
zone->cur[point].x += distance;
zone->tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
static void
Direct_Move_Y( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_UNUSED_EXEC;
zone->cur[point].y += distance;
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
/*************************************************************************/
/* */
/* Special versions of Direct_Move_Orig() */
/* */
/* The following versions are used whenever both vectors are both */
/* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
/* */
/*************************************************************************/
static void
Direct_Move_Orig_X( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_UNUSED_EXEC;
zone->org[point].x += distance;
}
static void
Direct_Move_Orig_Y( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance )
{
FT_UNUSED_EXEC;
zone->org[point].y += distance;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_None */
/* */
/* <Description> */
/* Does not round, but adds engine compensation. */
/* */
/* <Input> */
/* distance :: The distance (not) to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* The compensated distance. */
/* */
/* <Note> */
/* The TrueType specification says very few about the relationship */
/* between rounding and engine compensation. However, it seems from */
/* the description of super round that we should add the compensation */
/* before rounding. */
/* */
static FT_F26Dot6
Round_None( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation;
if ( distance && val < 0 )
val = 0;
}
else
{
val = distance - compensation;
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_To_Grid */
/* */
/* <Description> */
/* Rounds value to grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
static FT_F26Dot6
Round_To_Grid( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation + 32;
if ( distance && val > 0 )
val &= ~63;
else
val = 0;
}
else
{
val = -FT_PIX_ROUND( compensation - distance );
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_To_Half_Grid */
/* */
/* <Description> */
/* Rounds value to half grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
static FT_F26Dot6
Round_To_Half_Grid( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = FT_PIX_FLOOR( distance + compensation ) + 32;
if ( distance && val < 0 )
val = 0;
}
else
{
val = -( FT_PIX_FLOOR( compensation - distance ) + 32 );
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_Down_To_Grid */
/* */
/* <Description> */
/* Rounds value down to grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
static FT_F26Dot6
Round_Down_To_Grid( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation;
if ( distance && val > 0 )
val &= ~63;
else
val = 0;
}
else
{
val = -( ( compensation - distance ) & -64 );
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_Up_To_Grid */
/* */
/* <Description> */
/* Rounds value up to grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
static FT_F26Dot6
Round_Up_To_Grid( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation + 63;
if ( distance && val > 0 )
val &= ~63;
else
val = 0;
}
else
{
val = -FT_PIX_CEIL( compensation - distance );
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_To_Double_Grid */
/* */
/* <Description> */
/* Rounds value to double grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
static FT_F26Dot6
Round_To_Double_Grid( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
FT_UNUSED_EXEC;
if ( distance >= 0 )
{
val = distance + compensation + 16;
if ( distance && val > 0 )
val &= ~31;
else
val = 0;
}
else
{
val = -FT_PAD_ROUND( compensation - distance, 32 );
if ( val > 0 )
val = 0;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_Super */
/* */
/* <Description> */
/* Super-rounds value to grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
/* <Note> */
/* The TrueType specification says very few about the relationship */
/* between rounding and engine compensation. However, it seems from */
/* the description of super round that we should add the compensation */
/* before rounding. */
/* */
static FT_F26Dot6
Round_Super( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
if ( distance >= 0 )
{
val = ( distance - CUR.phase + CUR.threshold + compensation ) &
-CUR.period;
if ( distance && val < 0 )
val = 0;
val += CUR.phase;
}
else
{
val = -( ( CUR.threshold - CUR.phase - distance + compensation ) &
-CUR.period );
if ( val > 0 )
val = 0;
val -= CUR.phase;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Round_Super_45 */
/* */
/* <Description> */
/* Super-rounds value to grid after adding engine compensation. */
/* */
/* <Input> */
/* distance :: The distance to round. */
/* */
/* compensation :: The engine compensation. */
/* */
/* <Return> */
/* Rounded distance. */
/* */
/* <Note> */
/* There is a separate function for Round_Super_45() as we may need */
/* greater precision. */
/* */
static FT_F26Dot6
Round_Super_45( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation )
{
FT_F26Dot6 val;
if ( distance >= 0 )
{
val = ( ( distance - CUR.phase + CUR.threshold + compensation ) /
CUR.period ) * CUR.period;
if ( distance && val < 0 )
val = 0;
val += CUR.phase;
}
else
{
val = -( ( ( CUR.threshold - CUR.phase - distance + compensation ) /
CUR.period ) * CUR.period );
if ( val > 0 )
val = 0;
val -= CUR.phase;
}
return val;
}
/*************************************************************************/
/* */
/* <Function> */
/* Compute_Round */
/* */
/* <Description> */
/* Sets the rounding mode. */
/* */
/* <Input> */
/* round_mode :: The rounding mode to be used. */
/* */
static void
Compute_Round( EXEC_OP_ FT_Byte round_mode )
{
switch ( round_mode )
{
case TT_Round_Off:
CUR.func_round = (TT_Round_Func)Round_None;
break;
case TT_Round_To_Grid:
CUR.func_round = (TT_Round_Func)Round_To_Grid;
break;
case TT_Round_Up_To_Grid:
CUR.func_round = (TT_Round_Func)Round_Up_To_Grid;
break;
case TT_Round_Down_To_Grid:
CUR.func_round = (TT_Round_Func)Round_Down_To_Grid;
break;
case TT_Round_To_Half_Grid:
CUR.func_round = (TT_Round_Func)Round_To_Half_Grid;
break;
case TT_Round_To_Double_Grid:
CUR.func_round = (TT_Round_Func)Round_To_Double_Grid;
break;
case TT_Round_Super:
CUR.func_round = (TT_Round_Func)Round_Super;
break;
case TT_Round_Super_45:
CUR.func_round = (TT_Round_Func)Round_Super_45;
break;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* SetSuperRound */
/* */
/* <Description> */
/* Sets Super Round parameters. */
/* */
/* <Input> */
/* GridPeriod :: The grid period. */
/* */
/* selector :: The SROUND opcode. */
/* */
static void
SetSuperRound( EXEC_OP_ FT_F26Dot6 GridPeriod,
FT_Long selector )
{
switch ( (FT_Int)( selector & 0xC0 ) )
{
case 0:
CUR.period = GridPeriod / 2;
break;
case 0x40:
CUR.period = GridPeriod;
break;
case 0x80:
CUR.period = GridPeriod * 2;
break;
/* This opcode is reserved, but... */
case 0xC0:
CUR.period = GridPeriod;
break;
}
switch ( (FT_Int)( selector & 0x30 ) )
{
case 0:
CUR.phase = 0;
break;
case 0x10:
CUR.phase = CUR.period / 4;
break;
case 0x20:
CUR.phase = CUR.period / 2;
break;
case 0x30:
CUR.phase = CUR.period * 3 / 4;
break;
}
if ( ( selector & 0x0F ) == 0 )
CUR.threshold = CUR.period - 1;
else
CUR.threshold = ( (FT_Int)( selector & 0x0F ) - 4 ) * CUR.period / 8;
CUR.period /= 256;
CUR.phase /= 256;
CUR.threshold /= 256;
}
/*************************************************************************/
/* */
/* <Function> */
/* Project */
/* */
/* <Description> */
/* Computes the projection of vector given by (v2-v1) along the */
/* current projection vector. */
/* */
/* <Input> */
/* v1 :: First input vector. */
/* v2 :: Second input vector. */
/* */
/* <Return> */
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
return TT_DotFix14( (FT_UInt32)dx, (FT_UInt32)dy,
CUR.GS.projVector.x,
CUR.GS.projVector.y );
}
/*************************************************************************/
/* */
/* <Function> */
/* Dual_Project */
/* */
/* <Description> */
/* Computes the projection of the vector given by (v2-v1) along the */
/* current dual vector. */
/* */
/* <Input> */
/* v1 :: First input vector. */
/* v2 :: Second input vector. */
/* */
/* <Return> */
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Dual_Project( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
return TT_DotFix14( (FT_UInt32)dx, (FT_UInt32)dy,
CUR.GS.dualVector.x,
CUR.GS.dualVector.y );
}
/*************************************************************************/
/* */
/* <Function> */
/* Project_x */
/* */
/* <Description> */
/* Computes the projection of the vector given by (v2-v1) along the */
/* horizontal axis. */
/* */
/* <Input> */
/* v1 :: First input vector. */
/* v2 :: Second input vector. */
/* */
/* <Return> */
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project_x( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
FT_UNUSED_EXEC;
FT_UNUSED( dy );
return dx;
}
/*************************************************************************/
/* */
/* <Function> */
/* Project_y */
/* */
/* <Description> */
/* Computes the projection of the vector given by (v2-v1) along the */
/* vertical axis. */
/* */
/* <Input> */
/* v1 :: First input vector. */
/* v2 :: Second input vector. */
/* */
/* <Return> */
/* The distance in F26dot6 format. */
/* */
static FT_F26Dot6
Project_y( EXEC_OP_ FT_Pos dx,
FT_Pos dy )
{
FT_UNUSED_EXEC;
FT_UNUSED( dx );
return dy;
}
/*************************************************************************/
/* */
/* <Function> */
/* Compute_Funcs */
/* */
/* <Description> */
/* Computes the projection and movement function pointers according */
/* to the current graphics state. */
/* */
static void
Compute_Funcs( EXEC_OP )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
/* If both vectors point rightwards along the x axis, set */
/* `both-x-axis' true, otherwise set it false. The x values only */
/* need be tested because the vector has been normalised to a unit */
/* vector of length 0x4000 = unity. */
CUR.GS.both_x_axis = (FT_Bool)( CUR.GS.projVector.x == 0x4000 &&
CUR.GS.freeVector.x == 0x4000 );
/* Throw away projection and freedom vector information */
/* because the patents don't allow them to be stored. */
/* The relevant US Patents are 5155805 and 5325479. */
CUR.GS.projVector.x = 0;
CUR.GS.projVector.y = 0;
CUR.GS.freeVector.x = 0;
CUR.GS.freeVector.y = 0;
if ( CUR.GS.both_x_axis )
{
CUR.func_project = Project_x;
CUR.func_move = Direct_Move_X;
CUR.func_move_orig = Direct_Move_Orig_X;
}
else
{
CUR.func_project = Project_y;
CUR.func_move = Direct_Move_Y;
CUR.func_move_orig = Direct_Move_Orig_Y;
}
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = Project_x;
else if ( CUR.GS.dualVector.y == 0x4000 )
CUR.func_dualproj = Project_y;
else
CUR.func_dualproj = Dual_Project;
/* Force recalculation of cached aspect ratio */
CUR.tt_metrics.ratio = 0;
return;
}
#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING */
if ( CUR.GS.freeVector.x == 0x4000 )
CUR.F_dot_P = CUR.GS.projVector.x;
else if ( CUR.GS.freeVector.y == 0x4000 )
CUR.F_dot_P = CUR.GS.projVector.y;
else
CUR.F_dot_P = ( (FT_Long)CUR.GS.projVector.x * CUR.GS.freeVector.x +
(FT_Long)CUR.GS.projVector.y * CUR.GS.freeVector.y ) >>
14;
if ( CUR.GS.projVector.x == 0x4000 )
CUR.func_project = (TT_Project_Func)Project_x;
else if ( CUR.GS.projVector.y == 0x4000 )
CUR.func_project = (TT_Project_Func)Project_y;
else
CUR.func_project = (TT_Project_Func)Project;
if ( CUR.GS.dualVector.x == 0x4000 )
CUR.func_dualproj = (TT_Project_Func)Project_x;
else if ( CUR.GS.dualVector.y == 0x4000 )
CUR.func_dualproj = (TT_Project_Func)Project_y;
else
CUR.func_dualproj = (TT_Project_Func)Dual_Project;
CUR.func_move = (TT_Move_Func)Direct_Move;
CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig;
if ( CUR.F_dot_P == 0x4000L )
{
if ( CUR.GS.freeVector.x == 0x4000 )
{
CUR.func_move = (TT_Move_Func)Direct_Move_X;
CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_X;
}
else if ( CUR.GS.freeVector.y == 0x4000 )
{
CUR.func_move = (TT_Move_Func)Direct_Move_Y;
CUR.func_move_orig = (TT_Move_Func)Direct_Move_Orig_Y;
}
}
/* at small sizes, F_dot_P can become too small, resulting */
/* in overflows and `spikes' in a number of glyphs like `w'. */
if ( FT_ABS( CUR.F_dot_P ) < 0x400L )
CUR.F_dot_P = 0x4000L;
/* Disable cached aspect ratio */
CUR.tt_metrics.ratio = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* Normalize */
/* */
/* <Description> */
/* Norms a vector. */
/* */
/* <Input> */
/* Vx :: The horizontal input vector coordinate. */
/* Vy :: The vertical input vector coordinate. */
/* */
/* <Output> */
/* R :: The normed unit vector. */
/* */
/* <Return> */
/* Returns FAILURE if a vector parameter is zero. */
/* */
/* <Note> */
/* In case Vx and Vy are both zero, Normalize() returns SUCCESS, and */
/* R is undefined. */
/* */
static FT_Bool
Normalize( EXEC_OP_ FT_F26Dot6 Vx,
FT_F26Dot6 Vy,
FT_UnitVector* R )
{
FT_F26Dot6 W;
FT_UNUSED_EXEC;
if ( FT_ABS( Vx ) < 0x4000L && FT_ABS( Vy ) < 0x4000L )
{
if ( Vx == 0 && Vy == 0 )
{
/* XXX: UNDOCUMENTED! It seems that it is possible to try */
/* to normalize the vector (0,0). Return immediately. */
return SUCCESS;
}
Vx *= 0x4000;
Vy *= 0x4000;
}
W = FT_Hypot( Vx, Vy );
R->x = (FT_F2Dot14)TT_DivFix14( Vx, W );
R->y = (FT_F2Dot14)TT_DivFix14( Vy, W );
return SUCCESS;
}
/*************************************************************************/
/* */
/* Here we start with the implementation of the various opcodes. */
/* */
/*************************************************************************/
static FT_Bool
Ins_SxVTL( EXEC_OP_ FT_UShort aIdx1,
FT_UShort aIdx2,
FT_Int aOpc,
FT_UnitVector* Vec )
{
FT_Long A, B, C;
FT_Vector* p1;
FT_Vector* p2;
if ( BOUNDS( aIdx1, CUR.zp2.n_points ) ||
BOUNDS( aIdx2, CUR.zp1.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return FAILURE;
}
p1 = CUR.zp1.cur + aIdx2;
p2 = CUR.zp2.cur + aIdx1;
A = p1->x - p2->x;
B = p1->y - p2->y;
/* If p1 == p2, SPVTL and SFVTL behave the same as */
/* SPVTCA[X] and SFVTCA[X], respectively. */
/* */
/* Confirmed by Greg Hitchcock. */
if ( A == 0 && B == 0 )
{
A = 0x4000;
aOpc = 0;
}
if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
NORMalize( A, B, Vec );
return SUCCESS;
}
/* When not using the big switch statements, the interpreter uses a */
/* call table defined later below in this source. Each opcode must */
/* thus have a corresponding function, even trivial ones. */
/* */
/* They are all defined there. */
#define DO_SVTCA \
{ \
FT_Short A, B; \
\
\
A = (FT_Short)( CUR.opcode & 1 ) << 14; \
B = A ^ (FT_Short)0x4000; \
\
CUR.GS.freeVector.x = A; \
CUR.GS.projVector.x = A; \
CUR.GS.dualVector.x = A; \
\
CUR.GS.freeVector.y = B; \
CUR.GS.projVector.y = B; \
CUR.GS.dualVector.y = B; \
\
COMPUTE_Funcs(); \
}
#define DO_SPVTCA \
{ \
FT_Short A, B; \
\
\
A = (FT_Short)( CUR.opcode & 1 ) << 14; \
B = A ^ (FT_Short)0x4000; \
\
CUR.GS.projVector.x = A; \
CUR.GS.dualVector.x = A; \
\
CUR.GS.projVector.y = B; \
CUR.GS.dualVector.y = B; \
\
GUESS_VECTOR( freeVector ); \
\
COMPUTE_Funcs(); \
}
#define DO_SFVTCA \
{ \
FT_Short A, B; \
\
\
A = (FT_Short)( CUR.opcode & 1 ) << 14; \
B = A ^ (FT_Short)0x4000; \
\
CUR.GS.freeVector.x = A; \
CUR.GS.freeVector.y = B; \
\
GUESS_VECTOR( projVector ); \
\
COMPUTE_Funcs(); \
}
#define DO_SPVTL \
if ( INS_SxVTL( (FT_UShort)args[1], \
(FT_UShort)args[0], \
CUR.opcode, \
&CUR.GS.projVector ) == SUCCESS ) \
{ \
CUR.GS.dualVector = CUR.GS.projVector; \
GUESS_VECTOR( freeVector ); \
COMPUTE_Funcs(); \
}
#define DO_SFVTL \
if ( INS_SxVTL( (FT_UShort)args[1], \
(FT_UShort)args[0], \
CUR.opcode, \
&CUR.GS.freeVector ) == SUCCESS ) \
{ \
GUESS_VECTOR( projVector ); \
COMPUTE_Funcs(); \
}
#define DO_SFVTPV \
GUESS_VECTOR( projVector ); \
CUR.GS.freeVector = CUR.GS.projVector; \
COMPUTE_Funcs();
#define DO_SPVFS \
{ \
FT_Short S; \
FT_Long X, Y; \
\
\
/* Only use low 16bits, then sign extend */ \
S = (FT_Short)args[1]; \
Y = (FT_Long)S; \
S = (FT_Short)args[0]; \
X = (FT_Long)S; \
\
NORMalize( X, Y, &CUR.GS.projVector ); \
\
CUR.GS.dualVector = CUR.GS.projVector; \
GUESS_VECTOR( freeVector ); \
COMPUTE_Funcs(); \
}
#define DO_SFVFS \
{ \
FT_Short S; \
FT_Long X, Y; \
\
\
/* Only use low 16bits, then sign extend */ \
S = (FT_Short)args[1]; \
Y = (FT_Long)S; \
S = (FT_Short)args[0]; \
X = S; \
\
NORMalize( X, Y, &CUR.GS.freeVector ); \
GUESS_VECTOR( projVector ); \
COMPUTE_Funcs(); \
}
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
#define DO_GPV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
} \
else \
{ \
args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y; \
}
#else
#define DO_GPV \
args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y;
#endif
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
#define DO_GFV \
if ( CUR.face->unpatented_hinting ) \
{ \
args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
} \
else \
{ \
args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y; \
}
#else
#define DO_GFV \
args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y;
#endif
#define DO_SRP0 \
CUR.GS.rp0 = (FT_UShort)args[0];
#define DO_SRP1 \
CUR.GS.rp1 = (FT_UShort)args[0];
#define DO_SRP2 \
CUR.GS.rp2 = (FT_UShort)args[0];
#define DO_RTHG \
CUR.GS.round_state = TT_Round_To_Half_Grid; \
CUR.func_round = (TT_Round_Func)Round_To_Half_Grid;
#define DO_RTG \
CUR.GS.round_state = TT_Round_To_Grid; \
CUR.func_round = (TT_Round_Func)Round_To_Grid;
#define DO_RTDG \
CUR.GS.round_state = TT_Round_To_Double_Grid; \
CUR.func_round = (TT_Round_Func)Round_To_Double_Grid;
#define DO_RUTG \
CUR.GS.round_state = TT_Round_Up_To_Grid; \
CUR.func_round = (TT_Round_Func)Round_Up_To_Grid;
#define DO_RDTG \
CUR.GS.round_state = TT_Round_Down_To_Grid; \
CUR.func_round = (TT_Round_Func)Round_Down_To_Grid;
#define DO_ROFF \
CUR.GS.round_state = TT_Round_Off; \
CUR.func_round = (TT_Round_Func)Round_None;
#define DO_SROUND \
SET_SuperRound( 0x4000, args[0] ); \
CUR.GS.round_state = TT_Round_Super; \
CUR.func_round = (TT_Round_Func)Round_Super;
#define DO_S45ROUND \
SET_SuperRound( 0x2D41, args[0] ); \
CUR.GS.round_state = TT_Round_Super_45; \
CUR.func_round = (TT_Round_Func)Round_Super_45;
#define DO_SLOOP \
if ( args[0] < 0 ) \
CUR.error = FT_THROW( Bad_Argument ); \
else \
CUR.GS.loop = args[0];
#define DO_SMD \
CUR.GS.minimum_distance = args[0];
#define DO_SCVTCI \
CUR.GS.control_value_cutin = (FT_F26Dot6)args[0];
#define DO_SSWCI \
CUR.GS.single_width_cutin = (FT_F26Dot6)args[0];
#define DO_SSW \
CUR.GS.single_width_value = FT_MulFix( args[0], \
CUR.tt_metrics.scale );
#define DO_FLIPON \
CUR.GS.auto_flip = TRUE;
#define DO_FLIPOFF \
CUR.GS.auto_flip = FALSE;
#define DO_SDB \
CUR.GS.delta_base = (FT_Short)args[0];
#define DO_SDS \
CUR.GS.delta_shift = (FT_Short)args[0];
#define DO_MD /* nothing */
#define DO_MPPEM \
args[0] = CURRENT_Ppem();
/* Note: The pointSize should be irrelevant in a given font program; */
/* we thus decide to return only the ppem. */
#if 0
#define DO_MPS \
args[0] = CUR.metrics.pointSize;
#else
#define DO_MPS \
args[0] = CURRENT_Ppem();
#endif /* 0 */
#define DO_DUP \
args[1] = args[0];
#define DO_CLEAR \
CUR.new_top = 0;
#define DO_SWAP \
{ \
FT_Long L; \
\
\
L = args[0]; \
args[0] = args[1]; \
args[1] = L; \
}
#define DO_DEPTH \
args[0] = CUR.top;
#define DO_CINDEX \
{ \
FT_Long L; \
\
\
L = args[0]; \
\
if ( L <= 0 || L > CUR.args ) \
{ \
if ( CUR.pedantic_hinting ) \
CUR.error = FT_THROW( Invalid_Reference ); \
args[0] = 0; \
} \
else \
args[0] = CUR.stack[CUR.args - L]; \
}
#define DO_JROT \
if ( args[1] != 0 ) \
{ \
if ( args[0] == 0 && CUR.args == 0 ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.IP += args[0]; \
if ( CUR.IP < 0 || \
( CUR.callTop > 0 && \
CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.step_ins = FALSE; \
}
#define DO_JMPR \
if ( args[0] == 0 && CUR.args == 0 ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.IP += args[0]; \
if ( CUR.IP < 0 || \
( CUR.callTop > 0 && \
CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.step_ins = FALSE;
#define DO_JROF \
if ( args[1] == 0 ) \
{ \
if ( args[0] == 0 && CUR.args == 0 ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.IP += args[0]; \
if ( CUR.IP < 0 || \
( CUR.callTop > 0 && \
CUR.IP > CUR.callStack[CUR.callTop - 1].Def->end ) ) \
CUR.error = FT_THROW( Bad_Argument ); \
CUR.step_ins = FALSE; \
}
#define DO_LT \
args[0] = ( args[0] < args[1] );
#define DO_LTEQ \
args[0] = ( args[0] <= args[1] );
#define DO_GT \
args[0] = ( args[0] > args[1] );
#define DO_GTEQ \
args[0] = ( args[0] >= args[1] );
#define DO_EQ \
args[0] = ( args[0] == args[1] );
#define DO_NEQ \
args[0] = ( args[0] != args[1] );
#define DO_ODD \
args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 64 );
#define DO_EVEN \
args[0] = ( ( CUR_Func_round( args[0], 0 ) & 127 ) == 0 );
#define DO_AND \
args[0] = ( args[0] && args[1] );
#define DO_OR \
args[0] = ( args[0] || args[1] );
#define DO_NOT \
args[0] = !args[0];
#define DO_ADD \
args[0] += args[1];
#define DO_SUB \
args[0] -= args[1];
#define DO_DIV \
if ( args[1] == 0 ) \
CUR.error = FT_THROW( Divide_By_Zero ); \
else \
args[0] = FT_MulDiv_No_Round( args[0], 64L, args[1] );
#define DO_MUL \
args[0] = FT_MulDiv( args[0], args[1], 64L );
#define DO_ABS \
args[0] = FT_ABS( args[0] );
#define DO_NEG \
args[0] = -args[0];
#define DO_FLOOR \
args[0] = FT_PIX_FLOOR( args[0] );
#define DO_CEILING \
args[0] = FT_PIX_CEIL( args[0] );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
#define DO_RS \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.storeSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
ARRAY_BOUND_ERROR; \
else \
args[0] = 0; \
} \
else \
{ \
/* subpixel hinting - avoid Typeman Dstroke and */ \
/* IStroke and Vacuform rounds */ \
\
if ( SUBPIXEL_HINTING && \
CUR.ignore_x_mode && \
( ( I == 24 && \
( CUR.face->sph_found_func_flags & \
( SPH_FDEF_SPACING_1 | \
SPH_FDEF_SPACING_2 ) ) ) || \
( I == 22 && \
( CUR.sph_in_func_flags & \
SPH_FDEF_TYPEMAN_STROKES ) ) || \
( I == 8 && \
( CUR.face->sph_found_func_flags & \
SPH_FDEF_VACUFORM_ROUND_1 ) && \
CUR.iup_called ) ) ) \
args[0] = 0; \
else \
args[0] = CUR.storage[I]; \
} \
}
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#define DO_RS \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.storeSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
ARRAY_BOUND_ERROR; \
} \
else \
args[0] = 0; \
} \
else \
args[0] = CUR.storage[I]; \
}
#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#define DO_WS \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.storeSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
ARRAY_BOUND_ERROR; \
} \
} \
else \
CUR.storage[I] = args[1]; \
}
#define DO_RCVT \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
ARRAY_BOUND_ERROR; \
} \
else \
args[0] = 0; \
} \
else \
args[0] = CUR_Func_read_cvt( I ); \
}
#define DO_WCVTP \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
ARRAY_BOUND_ERROR; \
} \
} \
else \
CUR_Func_write_cvt( I, args[1] ); \
}
#define DO_WCVTF \
{ \
FT_ULong I = (FT_ULong)args[0]; \
\
\
if ( BOUNDSL( I, CUR.cvtSize ) ) \
{ \
if ( CUR.pedantic_hinting ) \
{ \
ARRAY_BOUND_ERROR; \
} \
} \
else \
CUR.cvt[I] = FT_MulFix( args[1], CUR.tt_metrics.scale ); \
}
#define DO_DEBUG \
CUR.error = FT_THROW( Debug_OpCode );
#define DO_ROUND \
args[0] = CUR_Func_round( \
args[0], \
CUR.tt_metrics.compensations[CUR.opcode - 0x68] );
#define DO_NROUND \
args[0] = ROUND_None( args[0], \
CUR.tt_metrics.compensations[CUR.opcode - 0x6C] );
#define DO_MAX \
if ( args[1] > args[0] ) \
args[0] = args[1];
#define DO_MIN \
if ( args[1] < args[0] ) \
args[0] = args[1];
#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH
#undef ARRAY_BOUND_ERROR
#define ARRAY_BOUND_ERROR \
{ \
CUR.error = FT_THROW( Invalid_Reference ); \
return; \
}
/*************************************************************************/
/* */
/* SVTCA[a]: Set (F and P) Vectors to Coordinate Axis */
/* Opcode range: 0x00-0x01 */
/* Stack: --> */
/* */
static void
Ins_SVTCA( INS_ARG )
{
DO_SVTCA
}
/*************************************************************************/
/* */
/* SPVTCA[a]: Set PVector to Coordinate Axis */
/* Opcode range: 0x02-0x03 */
/* Stack: --> */
/* */
static void
Ins_SPVTCA( INS_ARG )
{
DO_SPVTCA
}
/*************************************************************************/
/* */
/* SFVTCA[a]: Set FVector to Coordinate Axis */
/* Opcode range: 0x04-0x05 */
/* Stack: --> */
/* */
static void
Ins_SFVTCA( INS_ARG )
{
DO_SFVTCA
}
/*************************************************************************/
/* */
/* SPVTL[a]: Set PVector To Line */
/* Opcode range: 0x06-0x07 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_SPVTL( INS_ARG )
{
DO_SPVTL
}
/*************************************************************************/
/* */
/* SFVTL[a]: Set FVector To Line */
/* Opcode range: 0x08-0x09 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_SFVTL( INS_ARG )
{
DO_SFVTL
}
/*************************************************************************/
/* */
/* SFVTPV[]: Set FVector To PVector */
/* Opcode range: 0x0E */
/* Stack: --> */
/* */
static void
Ins_SFVTPV( INS_ARG )
{
DO_SFVTPV
}
/*************************************************************************/
/* */
/* SPVFS[]: Set PVector From Stack */
/* Opcode range: 0x0A */
/* Stack: f2.14 f2.14 --> */
/* */
static void
Ins_SPVFS( INS_ARG )
{
DO_SPVFS
}
/*************************************************************************/
/* */
/* SFVFS[]: Set FVector From Stack */
/* Opcode range: 0x0B */
/* Stack: f2.14 f2.14 --> */
/* */
static void
Ins_SFVFS( INS_ARG )
{
DO_SFVFS
}
/*************************************************************************/
/* */
/* GPV[]: Get Projection Vector */
/* Opcode range: 0x0C */
/* Stack: ef2.14 --> ef2.14 */
/* */
static void
Ins_GPV( INS_ARG )
{
DO_GPV
}
/*************************************************************************/
/* GFV[]: Get Freedom Vector */
/* Opcode range: 0x0D */
/* Stack: ef2.14 --> ef2.14 */
/* */
static void
Ins_GFV( INS_ARG )
{
DO_GFV
}
/*************************************************************************/
/* */
/* SRP0[]: Set Reference Point 0 */
/* Opcode range: 0x10 */
/* Stack: uint32 --> */
/* */
static void
Ins_SRP0( INS_ARG )
{
DO_SRP0
}
/*************************************************************************/
/* */
/* SRP1[]: Set Reference Point 1 */
/* Opcode range: 0x11 */
/* Stack: uint32 --> */
/* */
static void
Ins_SRP1( INS_ARG )
{
DO_SRP1
}
/*************************************************************************/
/* */
/* SRP2[]: Set Reference Point 2 */
/* Opcode range: 0x12 */
/* Stack: uint32 --> */
/* */
static void
Ins_SRP2( INS_ARG )
{
DO_SRP2
}
/*************************************************************************/
/* */
/* RTHG[]: Round To Half Grid */
/* Opcode range: 0x19 */
/* Stack: --> */
/* */
static void
Ins_RTHG( INS_ARG )
{
DO_RTHG
}
/*************************************************************************/
/* */
/* RTG[]: Round To Grid */
/* Opcode range: 0x18 */
/* Stack: --> */
/* */
static void
Ins_RTG( INS_ARG )
{
DO_RTG
}
/*************************************************************************/
/* RTDG[]: Round To Double Grid */
/* Opcode range: 0x3D */
/* Stack: --> */
/* */
static void
Ins_RTDG( INS_ARG )
{
DO_RTDG
}
/*************************************************************************/
/* RUTG[]: Round Up To Grid */
/* Opcode range: 0x7C */
/* Stack: --> */
/* */
static void
Ins_RUTG( INS_ARG )
{
DO_RUTG
}
/*************************************************************************/
/* */
/* RDTG[]: Round Down To Grid */
/* Opcode range: 0x7D */
/* Stack: --> */
/* */
static void
Ins_RDTG( INS_ARG )
{
DO_RDTG
}
/*************************************************************************/
/* */
/* ROFF[]: Round OFF */
/* Opcode range: 0x7A */
/* Stack: --> */
/* */
static void
Ins_ROFF( INS_ARG )
{
DO_ROFF
}
/*************************************************************************/
/* */
/* SROUND[]: Super ROUND */
/* Opcode range: 0x76 */
/* Stack: Eint8 --> */
/* */
static void
Ins_SROUND( INS_ARG )
{
DO_SROUND
}
/*************************************************************************/
/* */
/* S45ROUND[]: Super ROUND 45 degrees */
/* Opcode range: 0x77 */
/* Stack: uint32 --> */
/* */
static void
Ins_S45ROUND( INS_ARG )
{
DO_S45ROUND
}
/*************************************************************************/
/* */
/* SLOOP[]: Set LOOP variable */
/* Opcode range: 0x17 */
/* Stack: int32? --> */
/* */
static void
Ins_SLOOP( INS_ARG )
{
DO_SLOOP
}
/*************************************************************************/
/* */
/* SMD[]: Set Minimum Distance */
/* Opcode range: 0x1A */
/* Stack: f26.6 --> */
/* */
static void
Ins_SMD( INS_ARG )
{
DO_SMD
}
/*************************************************************************/
/* */
/* SCVTCI[]: Set Control Value Table Cut In */
/* Opcode range: 0x1D */
/* Stack: f26.6 --> */
/* */
static void
Ins_SCVTCI( INS_ARG )
{
DO_SCVTCI
}
/*************************************************************************/
/* */
/* SSWCI[]: Set Single Width Cut In */
/* Opcode range: 0x1E */
/* Stack: f26.6 --> */
/* */
static void
Ins_SSWCI( INS_ARG )
{
DO_SSWCI
}
/*************************************************************************/
/* */
/* SSW[]: Set Single Width */
/* Opcode range: 0x1F */
/* Stack: int32? --> */
/* */
static void
Ins_SSW( INS_ARG )
{
DO_SSW
}
/*************************************************************************/
/* */
/* FLIPON[]: Set auto-FLIP to ON */
/* Opcode range: 0x4D */
/* Stack: --> */
/* */
static void
Ins_FLIPON( INS_ARG )
{
DO_FLIPON
}
/*************************************************************************/
/* */
/* FLIPOFF[]: Set auto-FLIP to OFF */
/* Opcode range: 0x4E */
/* Stack: --> */
/* */
static void
Ins_FLIPOFF( INS_ARG )
{
DO_FLIPOFF
}
/*************************************************************************/
/* */
/* SANGW[]: Set ANGle Weight */
/* Opcode range: 0x7E */
/* Stack: uint32 --> */
/* */
static void
Ins_SANGW( INS_ARG )
{
/* instruction not supported anymore */
}
/*************************************************************************/
/* */
/* SDB[]: Set Delta Base */
/* Opcode range: 0x5E */
/* Stack: uint32 --> */
/* */
static void
Ins_SDB( INS_ARG )
{
DO_SDB
}
/*************************************************************************/
/* */
/* SDS[]: Set Delta Shift */
/* Opcode range: 0x5F */
/* Stack: uint32 --> */
/* */
static void
Ins_SDS( INS_ARG )
{
DO_SDS
}
/*************************************************************************/
/* */
/* MPPEM[]: Measure Pixel Per EM */
/* Opcode range: 0x4B */
/* Stack: --> Euint16 */
/* */
static void
Ins_MPPEM( INS_ARG )
{
DO_MPPEM
}
/*************************************************************************/
/* */
/* MPS[]: Measure Point Size */
/* Opcode range: 0x4C */
/* Stack: --> Euint16 */
/* */
static void
Ins_MPS( INS_ARG )
{
DO_MPS
}
/*************************************************************************/
/* */
/* DUP[]: DUPlicate the top stack's element */
/* Opcode range: 0x20 */
/* Stack: StkElt --> StkElt StkElt */
/* */
static void
Ins_DUP( INS_ARG )
{
DO_DUP
}
/*************************************************************************/
/* */
/* POP[]: POP the stack's top element */
/* Opcode range: 0x21 */
/* Stack: StkElt --> */
/* */
static void
Ins_POP( INS_ARG )
{
/* nothing to do */
}
/*************************************************************************/
/* */
/* CLEAR[]: CLEAR the entire stack */
/* Opcode range: 0x22 */
/* Stack: StkElt... --> */
/* */
static void
Ins_CLEAR( INS_ARG )
{
DO_CLEAR
}
/*************************************************************************/
/* */
/* SWAP[]: SWAP the stack's top two elements */
/* Opcode range: 0x23 */
/* Stack: 2 * StkElt --> 2 * StkElt */
/* */
static void
Ins_SWAP( INS_ARG )
{
DO_SWAP
}
/*************************************************************************/
/* */
/* DEPTH[]: return the stack DEPTH */
/* Opcode range: 0x24 */
/* Stack: --> uint32 */
/* */
static void
Ins_DEPTH( INS_ARG )
{
DO_DEPTH
}
/*************************************************************************/
/* */
/* CINDEX[]: Copy INDEXed element */
/* Opcode range: 0x25 */
/* Stack: int32 --> StkElt */
/* */
static void
Ins_CINDEX( INS_ARG )
{
DO_CINDEX
}
/*************************************************************************/
/* */
/* EIF[]: End IF */
/* Opcode range: 0x59 */
/* Stack: --> */
/* */
static void
Ins_EIF( INS_ARG )
{
/* nothing to do */
}
/*************************************************************************/
/* */
/* JROT[]: Jump Relative On True */
/* Opcode range: 0x78 */
/* Stack: StkElt int32 --> */
/* */
static void
Ins_JROT( INS_ARG )
{
DO_JROT
}
/*************************************************************************/
/* */
/* JMPR[]: JuMP Relative */
/* Opcode range: 0x1C */
/* Stack: int32 --> */
/* */
static void
Ins_JMPR( INS_ARG )
{
DO_JMPR
}
/*************************************************************************/
/* */
/* JROF[]: Jump Relative On False */
/* Opcode range: 0x79 */
/* Stack: StkElt int32 --> */
/* */
static void
Ins_JROF( INS_ARG )
{
DO_JROF
}
/*************************************************************************/
/* */
/* LT[]: Less Than */
/* Opcode range: 0x50 */
/* Stack: int32? int32? --> bool */
/* */
static void
Ins_LT( INS_ARG )
{
DO_LT
}
/*************************************************************************/
/* */
/* LTEQ[]: Less Than or EQual */
/* Opcode range: 0x51 */
/* Stack: int32? int32? --> bool */
/* */
static void
Ins_LTEQ( INS_ARG )
{
DO_LTEQ
}
/*************************************************************************/
/* */
/* GT[]: Greater Than */
/* Opcode range: 0x52 */
/* Stack: int32? int32? --> bool */
/* */
static void
Ins_GT( INS_ARG )
{
DO_GT
}
/*************************************************************************/
/* */
/* GTEQ[]: Greater Than or EQual */
/* Opcode range: 0x53 */
/* Stack: int32? int32? --> bool */
/* */
static void
Ins_GTEQ( INS_ARG )
{
DO_GTEQ
}
/*************************************************************************/
/* */
/* EQ[]: EQual */
/* Opcode range: 0x54 */
/* Stack: StkElt StkElt --> bool */
/* */
static void
Ins_EQ( INS_ARG )
{
DO_EQ
}
/*************************************************************************/
/* */
/* NEQ[]: Not EQual */
/* Opcode range: 0x55 */
/* Stack: StkElt StkElt --> bool */
/* */
static void
Ins_NEQ( INS_ARG )
{
DO_NEQ
}
/*************************************************************************/
/* */
/* ODD[]: Is ODD */
/* Opcode range: 0x56 */
/* Stack: f26.6 --> bool */
/* */
static void
Ins_ODD( INS_ARG )
{
DO_ODD
}
/*************************************************************************/
/* */
/* EVEN[]: Is EVEN */
/* Opcode range: 0x57 */
/* Stack: f26.6 --> bool */
/* */
static void
Ins_EVEN( INS_ARG )
{
DO_EVEN
}
/*************************************************************************/
/* */
/* AND[]: logical AND */
/* Opcode range: 0x5A */
/* Stack: uint32 uint32 --> uint32 */
/* */
static void
Ins_AND( INS_ARG )
{
DO_AND
}
/*************************************************************************/
/* */
/* OR[]: logical OR */
/* Opcode range: 0x5B */
/* Stack: uint32 uint32 --> uint32 */
/* */
static void
Ins_OR( INS_ARG )
{
DO_OR
}
/*************************************************************************/
/* */
/* NOT[]: logical NOT */
/* Opcode range: 0x5C */
/* Stack: StkElt --> uint32 */
/* */
static void
Ins_NOT( INS_ARG )
{
DO_NOT
}
/*************************************************************************/
/* */
/* ADD[]: ADD */
/* Opcode range: 0x60 */
/* Stack: f26.6 f26.6 --> f26.6 */
/* */
static void
Ins_ADD( INS_ARG )
{
DO_ADD
}
/*************************************************************************/
/* */
/* SUB[]: SUBtract */
/* Opcode range: 0x61 */
/* Stack: f26.6 f26.6 --> f26.6 */
/* */
static void
Ins_SUB( INS_ARG )
{
DO_SUB
}
/*************************************************************************/
/* */
/* DIV[]: DIVide */
/* Opcode range: 0x62 */
/* Stack: f26.6 f26.6 --> f26.6 */
/* */
static void
Ins_DIV( INS_ARG )
{
DO_DIV
}
/*************************************************************************/
/* */
/* MUL[]: MULtiply */
/* Opcode range: 0x63 */
/* Stack: f26.6 f26.6 --> f26.6 */
/* */
static void
Ins_MUL( INS_ARG )
{
DO_MUL
}
/*************************************************************************/
/* */
/* ABS[]: ABSolute value */
/* Opcode range: 0x64 */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_ABS( INS_ARG )
{
DO_ABS
}
/*************************************************************************/
/* */
/* NEG[]: NEGate */
/* Opcode range: 0x65 */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_NEG( INS_ARG )
{
DO_NEG
}
/*************************************************************************/
/* */
/* FLOOR[]: FLOOR */
/* Opcode range: 0x66 */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_FLOOR( INS_ARG )
{
DO_FLOOR
}
/*************************************************************************/
/* */
/* CEILING[]: CEILING */
/* Opcode range: 0x67 */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_CEILING( INS_ARG )
{
DO_CEILING
}
/*************************************************************************/
/* */
/* RS[]: Read Store */
/* Opcode range: 0x43 */
/* Stack: uint32 --> uint32 */
/* */
static void
Ins_RS( INS_ARG )
{
DO_RS
}
/*************************************************************************/
/* */
/* WS[]: Write Store */
/* Opcode range: 0x42 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_WS( INS_ARG )
{
DO_WS
}
/*************************************************************************/
/* */
/* WCVTP[]: Write CVT in Pixel units */
/* Opcode range: 0x44 */
/* Stack: f26.6 uint32 --> */
/* */
static void
Ins_WCVTP( INS_ARG )
{
DO_WCVTP
}
/*************************************************************************/
/* */
/* WCVTF[]: Write CVT in Funits */
/* Opcode range: 0x70 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_WCVTF( INS_ARG )
{
DO_WCVTF
}
/*************************************************************************/
/* */
/* RCVT[]: Read CVT */
/* Opcode range: 0x45 */
/* Stack: uint32 --> f26.6 */
/* */
static void
Ins_RCVT( INS_ARG )
{
DO_RCVT
}
/*************************************************************************/
/* */
/* AA[]: Adjust Angle */
/* Opcode range: 0x7F */
/* Stack: uint32 --> */
/* */
static void
Ins_AA( INS_ARG )
{
/* intentionally no longer supported */
}
/*************************************************************************/
/* */
/* DEBUG[]: DEBUG. Unsupported. */
/* Opcode range: 0x4F */
/* Stack: uint32 --> */
/* */
/* Note: The original instruction pops a value from the stack. */
/* */
static void
Ins_DEBUG( INS_ARG )
{
DO_DEBUG
}
/*************************************************************************/
/* */
/* ROUND[ab]: ROUND value */
/* Opcode range: 0x68-0x6B */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_ROUND( INS_ARG )
{
DO_ROUND
}
/*************************************************************************/
/* */
/* NROUND[ab]: No ROUNDing of value */
/* Opcode range: 0x6C-0x6F */
/* Stack: f26.6 --> f26.6 */
/* */
static void
Ins_NROUND( INS_ARG )
{
DO_NROUND
}
/*************************************************************************/
/* */
/* MAX[]: MAXimum */
/* Opcode range: 0x68 */
/* Stack: int32? int32? --> int32 */
/* */
static void
Ins_MAX( INS_ARG )
{
DO_MAX
}
/*************************************************************************/
/* */
/* MIN[]: MINimum */
/* Opcode range: 0x69 */
/* Stack: int32? int32? --> int32 */
/* */
static void
Ins_MIN( INS_ARG )
{
DO_MIN
}
#endif /* !TT_CONFIG_OPTION_INTERPRETER_SWITCH */
/*************************************************************************/
/* */
/* The following functions are called as is within the switch statement. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* MINDEX[]: Move INDEXed element */
/* Opcode range: 0x26 */
/* Stack: int32? --> StkElt */
/* */
static void
Ins_MINDEX( INS_ARG )
{
FT_Long L, K;
L = args[0];
if ( L <= 0 || L > CUR.args )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
}
else
{
K = CUR.stack[CUR.args - L];
FT_ARRAY_MOVE( &CUR.stack[CUR.args - L ],
&CUR.stack[CUR.args - L + 1],
( L - 1 ) );
CUR.stack[CUR.args - 1] = K;
}
}
/*************************************************************************/
/* */
/* ROLL[]: ROLL top three elements */
/* Opcode range: 0x8A */
/* Stack: 3 * StkElt --> 3 * StkElt */
/* */
static void
Ins_ROLL( INS_ARG )
{
FT_Long A, B, C;
FT_UNUSED_EXEC;
A = args[2];
B = args[1];
C = args[0];
args[2] = C;
args[1] = A;
args[0] = B;
}
/*************************************************************************/
/* */
/* MANAGING THE FLOW OF CONTROL */
/* */
/* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
static FT_Bool
SkipCode( EXEC_OP )
{
CUR.IP += CUR.length;
if ( CUR.IP < CUR.codeSize )
{
CUR.opcode = CUR.code[CUR.IP];
CUR.length = opcode_length[CUR.opcode];
if ( CUR.length < 0 )
{
if ( CUR.IP + 1 >= CUR.codeSize )
goto Fail_Overflow;
CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1];
}
if ( CUR.IP + CUR.length <= CUR.codeSize )
return SUCCESS;
}
Fail_Overflow:
CUR.error = FT_THROW( Code_Overflow );
return FAILURE;
}
/*************************************************************************/
/* */
/* IF[]: IF test */
/* Opcode range: 0x58 */
/* Stack: StkElt --> */
/* */
static void
Ins_IF( INS_ARG )
{
FT_Int nIfs;
FT_Bool Out;
if ( args[0] != 0 )
return;
nIfs = 1;
Out = 0;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x1B: /* ELSE */
Out = FT_BOOL( nIfs == 1 );
break;
case 0x59: /* EIF */
nIfs--;
Out = FT_BOOL( nIfs == 0 );
break;
}
} while ( Out == 0 );
}
/*************************************************************************/
/* */
/* ELSE[]: ELSE */
/* Opcode range: 0x1B */
/* Stack: --> */
/* */
static void
Ins_ELSE( INS_ARG )
{
FT_Int nIfs;
FT_UNUSED_ARG;
nIfs = 1;
do
{
if ( SKIP_Code() == FAILURE )
return;
switch ( CUR.opcode )
{
case 0x58: /* IF */
nIfs++;
break;
case 0x59: /* EIF */
nIfs--;
break;
}
} while ( nIfs != 0 );
}
/*************************************************************************/
/* */
/* DEFINING AND USING FUNCTIONS AND INSTRUCTIONS */
/* */
/* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FDEF[]: Function DEFinition */
/* Opcode range: 0x2C */
/* Stack: uint32 --> */
/* */
static void
Ins_FDEF( INS_ARG )
{
FT_ULong n;
TT_DefRecord* rec;
TT_DefRecord* limit;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* arguments to opcodes are skipped by `SKIP_Code' */
FT_Byte opcode_pattern[9][12] = {
/* #0 inline delta function 1 */
{
0x4B, /* PPEM */
0x53, /* GTEQ */
0x23, /* SWAP */
0x4B, /* PPEM */
0x51, /* LTEQ */
0x5A, /* AND */
0x58, /* IF */
0x38, /* SHPIX */
0x1B, /* ELSE */
0x21, /* POP */
0x21, /* POP */
0x59 /* EIF */
},
/* #1 inline delta function 2 */
{
0x4B, /* PPEM */
0x54, /* EQ */
0x58, /* IF */
0x38, /* SHPIX */
0x1B, /* ELSE */
0x21, /* POP */
0x21, /* POP */
0x59 /* EIF */
},
/* #2 diagonal stroke function */
{
0x20, /* DUP */
0x20, /* DUP */
0xB0, /* PUSHB_1 */
/* 1 */
0x60, /* ADD */
0x46, /* GC_cur */
0xB0, /* PUSHB_1 */
/* 64 */
0x23, /* SWAP */
0x42 /* WS */
},
/* #3 VacuFormRound function */
{
0x45, /* RCVT */
0x23, /* SWAP */
0x46, /* GC_cur */
0x60, /* ADD */
0x20, /* DUP */
0xB0 /* PUSHB_1 */
/* 38 */
},
/* #4 TTFautohint bytecode (old) */
{
0x20, /* DUP */
0x64, /* ABS */
0xB0, /* PUSHB_1 */
/* 32 */
0x60, /* ADD */
0x66, /* FLOOR */
0x23, /* SWAP */
0xB0 /* PUSHB_1 */
},
/* #5 spacing function 1 */
{
0x01, /* SVTCA_x */
0xB0, /* PUSHB_1 */
/* 24 */
0x43, /* RS */
0x58 /* IF */
},
/* #6 spacing function 2 */
{
0x01, /* SVTCA_x */
0x18, /* RTG */
0xB0, /* PUSHB_1 */
/* 24 */
0x43, /* RS */
0x58 /* IF */
},
/* #7 TypeMan Talk DiagEndCtrl function */
{
0x01, /* SVTCA_x */
0x20, /* DUP */
0xB0, /* PUSHB_1 */
/* 3 */
0x25, /* CINDEX */
},
/* #8 TypeMan Talk Align */
{
0x06, /* SPVTL */
0x7D, /* RDTG */
},
};
FT_UShort opcode_patterns = 9;
FT_UShort opcode_pointer[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
FT_UShort opcode_size[9] = { 12, 8, 8, 6, 7, 4, 5, 4, 2 };
FT_UShort i;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* some font programs are broken enough to redefine functions! */
/* We will then parse the current table. */
rec = CUR.FDefs;
limit = rec + CUR.numFDefs;
n = args[0];
for ( ; rec < limit; rec++ )
{
if ( rec->opc == n )
break;
}
if ( rec == limit )
{
/* check that there is enough room for new functions */
if ( CUR.numFDefs >= CUR.maxFDefs )
{
CUR.error = FT_THROW( Too_Many_Function_Defs );
return;
}
CUR.numFDefs++;
}
/* Although FDEF takes unsigned 32-bit integer, */
/* func # must be within unsigned 16-bit integer */
if ( n > 0xFFFFU )
{
CUR.error = FT_THROW( Too_Many_Function_Defs );
return;
}
rec->range = CUR.curRange;
rec->opc = (FT_UInt16)n;
rec->start = CUR.IP + 1;
rec->active = TRUE;
rec->inline_delta = FALSE;
rec->sph_fdef_flags = 0x0000;
if ( n > CUR.maxFunc )
CUR.maxFunc = (FT_UInt16)n;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* We don't know for sure these are typeman functions, */
/* however they are only active when RS 22 is called */
if ( n >= 64 && n <= 66 )
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_STROKES;
#endif
/* Now skip the whole function definition. */
/* We don't allow nested IDEFS & FDEFs. */
while ( SKIP_Code() == SUCCESS )
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING )
{
for ( i = 0; i < opcode_patterns; i++ )
{
if ( opcode_pointer[i] < opcode_size[i] &&
CUR.opcode == opcode_pattern[i][opcode_pointer[i]] )
{
opcode_pointer[i] += 1;
if ( opcode_pointer[i] == opcode_size[i] )
{
FT_TRACE7(( "sph: Function %d, opcode ptrn: %d, %s %s\n",
i, n,
CUR.face->root.family_name,
CUR.face->root.style_name ));
switch ( i )
{
case 0:
rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_1;
CUR.face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_1;
break;
case 1:
rec->sph_fdef_flags |= SPH_FDEF_INLINE_DELTA_2;
CUR.face->sph_found_func_flags |= SPH_FDEF_INLINE_DELTA_2;
break;
case 2:
switch ( n )
{
/* needs to be implemented still */
case 58:
rec->sph_fdef_flags |= SPH_FDEF_DIAGONAL_STROKE;
CUR.face->sph_found_func_flags |= SPH_FDEF_DIAGONAL_STROKE;
}
break;
case 3:
switch ( n )
{
case 0:
rec->sph_fdef_flags |= SPH_FDEF_VACUFORM_ROUND_1;
CUR.face->sph_found_func_flags |= SPH_FDEF_VACUFORM_ROUND_1;
}
break;
case 4:
/* probably not necessary to detect anymore */
rec->sph_fdef_flags |= SPH_FDEF_TTFAUTOHINT_1;
CUR.face->sph_found_func_flags |= SPH_FDEF_TTFAUTOHINT_1;
break;
case 5:
switch ( n )
{
case 0:
case 1:
case 2:
case 4:
case 7:
case 8:
rec->sph_fdef_flags |= SPH_FDEF_SPACING_1;
CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_1;
}
break;
case 6:
switch ( n )
{
case 0:
case 1:
case 2:
case 4:
case 7:
case 8:
rec->sph_fdef_flags |= SPH_FDEF_SPACING_2;
CUR.face->sph_found_func_flags |= SPH_FDEF_SPACING_2;
}
break;
case 7:
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
CUR.face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
break;
case 8:
#if 0
rec->sph_fdef_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
CUR.face->sph_found_func_flags |= SPH_FDEF_TYPEMAN_DIAGENDCTRL;
#endif
break;
}
opcode_pointer[i] = 0;
}
}
else
opcode_pointer[i] = 0;
}
/* Set sph_compatibility_mode only when deltas are detected */
CUR.face->sph_compatibility_mode =
( ( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_1 ) |
( CUR.face->sph_found_func_flags & SPH_FDEF_INLINE_DELTA_2 ) );
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
switch ( CUR.opcode )
{
case 0x89: /* IDEF */
case 0x2C: /* FDEF */
CUR.error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
rec->end = CUR.IP;
return;
}
}
}
/*************************************************************************/
/* */
/* ENDF[]: END Function definition */
/* Opcode range: 0x2D */
/* Stack: --> */
/* */
static void
Ins_ENDF( INS_ARG )
{
TT_CallRec* pRec;
FT_UNUSED_ARG;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
CUR.sph_in_func_flags = 0x0000;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( CUR.callTop <= 0 ) /* We encountered an ENDF without a call */
{
CUR.error = FT_THROW( ENDF_In_Exec_Stream );
return;
}
CUR.callTop--;
pRec = &CUR.callStack[CUR.callTop];
pRec->Cur_Count--;
CUR.step_ins = FALSE;
if ( pRec->Cur_Count > 0 )
{
CUR.callTop++;
CUR.IP = pRec->Def->start;
}
else
/* Loop through the current function */
INS_Goto_CodeRange( pRec->Caller_Range,
pRec->Caller_IP );
/* Exit the current call frame. */
/* NOTE: If the last instruction of a program is a */
/* CALL or LOOPCALL, the return address is */
/* always out of the code range. This is a */
/* valid address, and it is why we do not test */
/* the result of Ins_Goto_CodeRange() here! */
}
/*************************************************************************/
/* */
/* CALL[]: CALL function */
/* Opcode range: 0x2B */
/* Stack: uint32? --> */
/* */
static void
Ins_CALL( INS_ARG )
{
FT_ULong F;
TT_CallRec* pCrec;
TT_DefRecord* def;
/* first of all, check the index */
F = args[0];
if ( BOUNDSL( F, CUR.maxFunc + 1 ) )
goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
/* font are defined in increasing order, starting from 0. This */
/* means that we normally have */
/* */
/* CUR.maxFunc+1 == CUR.numFDefs */
/* CUR.FDefs[n].opc == n for n in 0..CUR.maxFunc */
/* */
/* If this isn't true, we need to look up the function table. */
def = CUR.FDefs + F;
if ( CUR.maxFunc + 1 != CUR.numFDefs || def->opc != F )
{
/* look up the FDefs table */
TT_DefRecord* limit;
def = CUR.FDefs;
limit = def + CUR.numFDefs;
while ( def < limit && def->opc != F )
def++;
if ( def == limit )
goto Fail;
}
/* check that the function is active */
if ( !def->active )
goto Fail;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
( ( CUR.iup_called &&
( CUR.sph_tweak_flags & SPH_TWEAK_NO_CALL_AFTER_IUP ) ) ||
( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) ) )
goto Fail;
else
CUR.sph_in_func_flags = def->sph_fdef_flags;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* check the call stack */
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
pCrec = CUR.callStack + CUR.callTop;
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = 1;
pCrec->Def = def;
CUR.callTop++;
INS_Goto_CodeRange( def->range,
def->start );
CUR.step_ins = FALSE;
return;
Fail:
CUR.error = FT_THROW( Invalid_Reference );
}
/*************************************************************************/
/* */
/* LOOPCALL[]: LOOP and CALL function */
/* Opcode range: 0x2A */
/* Stack: uint32? Eint16? --> */
/* */
static void
Ins_LOOPCALL( INS_ARG )
{
FT_ULong F;
TT_CallRec* pCrec;
TT_DefRecord* def;
/* first of all, check the index */
F = args[1];
if ( BOUNDSL( F, CUR.maxFunc + 1 ) )
goto Fail;
/* Except for some old Apple fonts, all functions in a TrueType */
/* font are defined in increasing order, starting from 0. This */
/* means that we normally have */
/* */
/* CUR.maxFunc+1 == CUR.numFDefs */
/* CUR.FDefs[n].opc == n for n in 0..CUR.maxFunc */
/* */
/* If this isn't true, we need to look up the function table. */
def = CUR.FDefs + F;
if ( CUR.maxFunc + 1 != CUR.numFDefs || def->opc != F )
{
/* look up the FDefs table */
TT_DefRecord* limit;
def = CUR.FDefs;
limit = def + CUR.numFDefs;
while ( def < limit && def->opc != F )
def++;
if ( def == limit )
goto Fail;
}
/* check that the function is active */
if ( !def->active )
goto Fail;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
( def->sph_fdef_flags & SPH_FDEF_VACUFORM_ROUND_1 ) )
goto Fail;
else
CUR.sph_in_func_flags = def->sph_fdef_flags;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* check stack */
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
if ( args[0] > 0 )
{
pCrec = CUR.callStack + CUR.callTop;
pCrec->Caller_Range = CUR.curRange;
pCrec->Caller_IP = CUR.IP + 1;
pCrec->Cur_Count = (FT_Int)args[0];
pCrec->Def = def;
CUR.callTop++;
INS_Goto_CodeRange( def->range, def->start );
CUR.step_ins = FALSE;
}
return;
Fail:
CUR.error = FT_THROW( Invalid_Reference );
}
/*************************************************************************/
/* */
/* IDEF[]: Instruction DEFinition */
/* Opcode range: 0x89 */
/* Stack: Eint8 --> */
/* */
static void
Ins_IDEF( INS_ARG )
{
TT_DefRecord* def;
TT_DefRecord* limit;
/* First of all, look for the same function in our table */
def = CUR.IDefs;
limit = def + CUR.numIDefs;
for ( ; def < limit; def++ )
if ( def->opc == (FT_ULong)args[0] )
break;
if ( def == limit )
{
/* check that there is enough room for a new instruction */
if ( CUR.numIDefs >= CUR.maxIDefs )
{
CUR.error = FT_THROW( Too_Many_Instruction_Defs );
return;
}
CUR.numIDefs++;
}
/* opcode must be unsigned 8-bit integer */
if ( 0 > args[0] || args[0] > 0x00FF )
{
CUR.error = FT_THROW( Too_Many_Instruction_Defs );
return;
}
def->opc = (FT_Byte)args[0];
def->start = CUR.IP + 1;
def->range = CUR.curRange;
def->active = TRUE;
if ( (FT_ULong)args[0] > CUR.maxIns )
CUR.maxIns = (FT_Byte)args[0];
/* Now skip the whole function definition. */
/* We don't allow nested IDEFs & FDEFs. */
while ( SKIP_Code() == SUCCESS )
{
switch ( CUR.opcode )
{
case 0x89: /* IDEF */
case 0x2C: /* FDEF */
CUR.error = FT_THROW( Nested_DEFS );
return;
case 0x2D: /* ENDF */
return;
}
}
}
/*************************************************************************/
/* */
/* PUSHING DATA ONTO THE INTERPRETER STACK */
/* */
/* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* NPUSHB[]: PUSH N Bytes */
/* Opcode range: 0x40 */
/* Stack: --> uint32... */
/* */
static void
Ins_NPUSHB( INS_ARG )
{
FT_UShort L, K;
L = (FT_UShort)CUR.code[CUR.IP + 1];
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
for ( K = 1; K <= L; K++ )
args[K - 1] = CUR.code[CUR.IP + K + 1];
CUR.new_top += L;
}
/*************************************************************************/
/* */
/* NPUSHW[]: PUSH N Words */
/* Opcode range: 0x41 */
/* Stack: --> int32... */
/* */
static void
Ins_NPUSHW( INS_ARG )
{
FT_UShort L, K;
L = (FT_UShort)CUR.code[CUR.IP + 1];
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
CUR.IP += 2;
for ( K = 0; K < L; K++ )
args[K] = GET_ShortIns();
CUR.step_ins = FALSE;
CUR.new_top += L;
}
/*************************************************************************/
/* */
/* PUSHB[abc]: PUSH Bytes */
/* Opcode range: 0xB0-0xB7 */
/* Stack: --> uint32... */
/* */
static void
Ins_PUSHB( INS_ARG )
{
FT_UShort L, K;
L = (FT_UShort)( CUR.opcode - 0xB0 + 1 );
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
for ( K = 1; K <= L; K++ )
args[K - 1] = CUR.code[CUR.IP + K];
}
/*************************************************************************/
/* */
/* PUSHW[abc]: PUSH Words */
/* Opcode range: 0xB8-0xBF */
/* Stack: --> int32... */
/* */
static void
Ins_PUSHW( INS_ARG )
{
FT_UShort L, K;
L = (FT_UShort)( CUR.opcode - 0xB8 + 1 );
if ( BOUNDS( L, CUR.stackSize + 1 - CUR.top ) )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
CUR.IP++;
for ( K = 0; K < L; K++ )
args[K] = GET_ShortIns();
CUR.step_ins = FALSE;
}
/*************************************************************************/
/* */
/* MANAGING THE GRAPHICS STATE */
/* */
/* Instructions appear in the specs' order. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* GC[a]: Get Coordinate projected onto */
/* Opcode range: 0x46-0x47 */
/* Stack: uint32 --> f26.6 */
/* */
/* XXX: UNDOCUMENTED: Measures from the original glyph must be taken */
/* along the dual projection vector! */
/* */
static void
Ins_GC( INS_ARG )
{
FT_ULong L;
FT_F26Dot6 R;
L = (FT_ULong)args[0];
if ( BOUNDSL( L, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
R = 0;
}
else
{
if ( CUR.opcode & 1 )
R = CUR_fast_dualproj( &CUR.zp2.org[L] );
else
R = CUR_fast_project( &CUR.zp2.cur[L] );
}
args[0] = R;
}
/*************************************************************************/
/* */
/* SCFS[]: Set Coordinate From Stack */
/* Opcode range: 0x48 */
/* Stack: f26.6 uint32 --> */
/* */
/* Formula: */
/* */
/* OA := OA + ( value - OA.p )/( f.p ) * f */
/* */
static void
Ins_SCFS( INS_ARG )
{
FT_Long K;
FT_UShort L;
L = (FT_UShort)args[0];
if ( BOUNDS( L, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
K = CUR_fast_project( &CUR.zp2.cur[L] );
CUR_Func_move( &CUR.zp2, L, args[1] - K );
/* UNDOCUMENTED! The MS rasterizer does that with */
/* twilight points (confirmed by Greg Hitchcock) */
if ( CUR.GS.gep2 == 0 )
CUR.zp2.org[L] = CUR.zp2.cur[L];
}
/*************************************************************************/
/* */
/* MD[a]: Measure Distance */
/* Opcode range: 0x49-0x4A */
/* Stack: uint32 uint32 --> f26.6 */
/* */
/* XXX: UNDOCUMENTED: Measure taken in the original glyph must be along */
/* the dual projection vector. */
/* */
/* XXX: UNDOCUMENTED: Flag attributes are inverted! */
/* 0 => measure distance in original outline */
/* 1 => measure distance in grid-fitted outline */
/* */
/* XXX: UNDOCUMENTED: `zp0 - zp1', and not `zp2 - zp1! */
/* */
static void
Ins_MD( INS_ARG )
{
FT_UShort K, L;
FT_F26Dot6 D;
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
if ( BOUNDS( L, CUR.zp0.n_points ) ||
BOUNDS( K, CUR.zp1.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
D = 0;
}
else
{
if ( CUR.opcode & 1 )
D = CUR_Func_project( CUR.zp0.cur + L, CUR.zp1.cur + K );
else
{
/* XXX: UNDOCUMENTED: twilight zone special case */
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
{
FT_Vector* vec1 = CUR.zp0.org + L;
FT_Vector* vec2 = CUR.zp1.org + K;
D = CUR_Func_dualproj( vec1, vec2 );
}
else
{
FT_Vector* vec1 = CUR.zp0.orus + L;
FT_Vector* vec2 = CUR.zp1.orus + K;
if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
{
/* this should be faster */
D = CUR_Func_dualproj( vec1, vec2 );
D = FT_MulFix( D, CUR.metrics.x_scale );
}
else
{
FT_Vector vec;
vec.x = FT_MulFix( vec1->x - vec2->x, CUR.metrics.x_scale );
vec.y = FT_MulFix( vec1->y - vec2->y, CUR.metrics.y_scale );
D = CUR_fast_dualproj( &vec );
}
}
}
}
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* Disable Type 2 Vacuform Rounds - e.g. Arial Narrow */
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode && FT_ABS( D ) == 64 )
D += 1;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
args[0] = D;
}
/*************************************************************************/
/* */
/* SDPVTL[a]: Set Dual PVector to Line */
/* Opcode range: 0x86-0x87 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_SDPVTL( INS_ARG )
{
FT_Long A, B, C;
FT_UShort p1, p2; /* was FT_Int in pas type ERROR */
FT_Int aOpc = CUR.opcode;
p1 = (FT_UShort)args[1];
p2 = (FT_UShort)args[0];
if ( BOUNDS( p2, CUR.zp1.n_points ) ||
BOUNDS( p1, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
{
FT_Vector* v1 = CUR.zp1.org + p2;
FT_Vector* v2 = CUR.zp2.org + p1;
A = v1->x - v2->x;
B = v1->y - v2->y;
/* If v1 == v2, SDPVTL behaves the same as */
/* SVTCA[X], respectively. */
/* */
/* Confirmed by Greg Hitchcock. */
if ( A == 0 && B == 0 )
{
A = 0x4000;
aOpc = 0;
}
}
if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
NORMalize( A, B, &CUR.GS.dualVector );
{
FT_Vector* v1 = CUR.zp1.cur + p2;
FT_Vector* v2 = CUR.zp2.cur + p1;
A = v1->x - v2->x;
B = v1->y - v2->y;
if ( A == 0 && B == 0 )
{
A = 0x4000;
aOpc = 0;
}
}
if ( ( aOpc & 1 ) != 0 )
{
C = B; /* counter clockwise rotation */
B = A;
A = -C;
}
NORMalize( A, B, &CUR.GS.projVector );
GUESS_VECTOR( freeVector );
COMPUTE_Funcs();
}
/*************************************************************************/
/* */
/* SZP0[]: Set Zone Pointer 0 */
/* Opcode range: 0x13 */
/* Stack: uint32 --> */
/* */
static void
Ins_SZP0( INS_ARG )
{
switch ( (FT_Int)args[0] )
{
case 0:
CUR.zp0 = CUR.twilight;
break;
case 1:
CUR.zp0 = CUR.pts;
break;
default:
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
CUR.GS.gep0 = (FT_UShort)args[0];
}
/*************************************************************************/
/* */
/* SZP1[]: Set Zone Pointer 1 */
/* Opcode range: 0x14 */
/* Stack: uint32 --> */
/* */
static void
Ins_SZP1( INS_ARG )
{
switch ( (FT_Int)args[0] )
{
case 0:
CUR.zp1 = CUR.twilight;
break;
case 1:
CUR.zp1 = CUR.pts;
break;
default:
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
CUR.GS.gep1 = (FT_UShort)args[0];
}
/*************************************************************************/
/* */
/* SZP2[]: Set Zone Pointer 2 */
/* Opcode range: 0x15 */
/* Stack: uint32 --> */
/* */
static void
Ins_SZP2( INS_ARG )
{
switch ( (FT_Int)args[0] )
{
case 0:
CUR.zp2 = CUR.twilight;
break;
case 1:
CUR.zp2 = CUR.pts;
break;
default:
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
CUR.GS.gep2 = (FT_UShort)args[0];
}
/*************************************************************************/
/* */
/* SZPS[]: Set Zone PointerS */
/* Opcode range: 0x16 */
/* Stack: uint32 --> */
/* */
static void
Ins_SZPS( INS_ARG )
{
switch ( (FT_Int)args[0] )
{
case 0:
CUR.zp0 = CUR.twilight;
break;
case 1:
CUR.zp0 = CUR.pts;
break;
default:
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
CUR.zp1 = CUR.zp0;
CUR.zp2 = CUR.zp0;
CUR.GS.gep0 = (FT_UShort)args[0];
CUR.GS.gep1 = (FT_UShort)args[0];
CUR.GS.gep2 = (FT_UShort)args[0];
}
/*************************************************************************/
/* */
/* INSTCTRL[]: INSTruction ConTRoL */
/* Opcode range: 0x8e */
/* Stack: int32 int32 --> */
/* */
static void
Ins_INSTCTRL( INS_ARG )
{
FT_Long K, L;
K = args[1];
L = args[0];
if ( K < 1 || K > 2 )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
if ( L != 0 )
L = K;
CUR.GS.instruct_control = FT_BOOL(
( (FT_Byte)CUR.GS.instruct_control & ~(FT_Byte)K ) | (FT_Byte)L );
}
/*************************************************************************/
/* */
/* SCANCTRL[]: SCAN ConTRoL */
/* Opcode range: 0x85 */
/* Stack: uint32? --> */
/* */
static void
Ins_SCANCTRL( INS_ARG )
{
FT_Int A;
/* Get Threshold */
A = (FT_Int)( args[0] & 0xFF );
if ( A == 0xFF )
{
CUR.GS.scan_control = TRUE;
return;
}
else if ( A == 0 )
{
CUR.GS.scan_control = FALSE;
return;
}
if ( ( args[0] & 0x100 ) != 0 && CUR.tt_metrics.ppem <= A )
CUR.GS.scan_control = TRUE;
if ( ( args[0] & 0x200 ) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = TRUE;
if ( ( args[0] & 0x400 ) != 0 && CUR.tt_metrics.stretched )
CUR.GS.scan_control = TRUE;
if ( ( args[0] & 0x800 ) != 0 && CUR.tt_metrics.ppem > A )
CUR.GS.scan_control = FALSE;
if ( ( args[0] & 0x1000 ) != 0 && CUR.tt_metrics.rotated )
CUR.GS.scan_control = FALSE;
if ( ( args[0] & 0x2000 ) != 0 && CUR.tt_metrics.stretched )
CUR.GS.scan_control = FALSE;
}
/*************************************************************************/
/* */
/* SCANTYPE[]: SCAN TYPE */
/* Opcode range: 0x8D */
/* Stack: uint32? --> */
/* */
static void
Ins_SCANTYPE( INS_ARG )
{
if ( args[0] >= 0 )
CUR.GS.scan_type = (FT_Int)args[0];
}
/*************************************************************************/
/* */
/* MANAGING OUTLINES */
/* */
/* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FLIPPT[]: FLIP PoinT */
/* Opcode range: 0x80 */
/* Stack: uint32... --> */
/* */
static void
Ins_FLIPPT( INS_ARG )
{
FT_UShort point;
FT_UNUSED_ARG;
if ( CUR.top < CUR.GS.loop )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Too_Few_Arguments );
goto Fail;
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (FT_UShort)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.pts.n_points ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
CUR.pts.tags[point] ^= FT_CURVE_TAG_ON;
CUR.GS.loop--;
}
Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* FLIPRGON[]: FLIP RanGe ON */
/* Opcode range: 0x81 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_FLIPRGON( INS_ARG )
{
FT_UShort I, K, L;
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
if ( BOUNDS( K, CUR.pts.n_points ) ||
BOUNDS( L, CUR.pts.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
for ( I = L; I <= K; I++ )
CUR.pts.tags[I] |= FT_CURVE_TAG_ON;
}
/*************************************************************************/
/* */
/* FLIPRGOFF: FLIP RanGe OFF */
/* Opcode range: 0x82 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_FLIPRGOFF( INS_ARG )
{
FT_UShort I, K, L;
K = (FT_UShort)args[1];
L = (FT_UShort)args[0];
if ( BOUNDS( K, CUR.pts.n_points ) ||
BOUNDS( L, CUR.pts.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
for ( I = L; I <= K; I++ )
CUR.pts.tags[I] &= ~FT_CURVE_TAG_ON;
}
static FT_Bool
Compute_Point_Displacement( EXEC_OP_ FT_F26Dot6* x,
FT_F26Dot6* y,
TT_GlyphZone zone,
FT_UShort* refp )
{
TT_GlyphZoneRec zp;
FT_UShort p;
FT_F26Dot6 d;
if ( CUR.opcode & 1 )
{
zp = CUR.zp0;
p = CUR.GS.rp1;
}
else
{
zp = CUR.zp1;
p = CUR.GS.rp2;
}
if ( BOUNDS( p, zp.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
*refp = 0;
return FAILURE;
}
*zone = zp;
*refp = p;
d = CUR_Func_project( zp.cur + p, zp.org + p );
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
*x = d;
*y = 0;
}
else
{
*x = 0;
*y = d;
}
}
else
#endif
{
*x = FT_MulDiv( d, (FT_Long)CUR.GS.freeVector.x, CUR.F_dot_P );
*y = FT_MulDiv( d, (FT_Long)CUR.GS.freeVector.y, CUR.F_dot_P );
}
return SUCCESS;
}
static void
Move_Zp2_Point( EXEC_OP_ FT_UShort point,
FT_F26Dot6 dx,
FT_F26Dot6 dy,
FT_Bool touch )
{
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
CUR.zp2.cur[point].x += dx;
if ( touch )
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
else
{
CUR.zp2.cur[point].y += dy;
if ( touch )
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
return;
}
#endif
if ( CUR.GS.freeVector.x != 0 )
{
CUR.zp2.cur[point].x += dx;
if ( touch )
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X;
}
if ( CUR.GS.freeVector.y != 0 )
{
CUR.zp2.cur[point].y += dy;
if ( touch )
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
}
/*************************************************************************/
/* */
/* SHP[a]: SHift Point by the last point */
/* Opcode range: 0x32-0x33 */
/* Stack: uint32... --> */
/* */
static void
Ins_SHP( INS_ARG )
{
TT_GlyphZoneRec zp;
FT_UShort refp;
FT_F26Dot6 dx,
dy;
FT_UShort point;
FT_UNUSED_ARG;
if ( CUR.top < CUR.GS.loop )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
return;
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (FT_UShort)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* doesn't follow Cleartype spec but produces better result */
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode )
MOVE_Zp2_Point( point, 0, dy, TRUE );
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
MOVE_Zp2_Point( point, dx, dy, TRUE );
CUR.GS.loop--;
}
Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* SHC[a]: SHift Contour */
/* Opcode range: 0x34-35 */
/* Stack: uint32 --> */
/* */
/* UNDOCUMENTED: According to Greg Hitchcock, there is one (virtual) */
/* contour in the twilight zone, namely contour number */
/* zero which includes all points of it. */
/* */
static void
Ins_SHC( INS_ARG )
{
TT_GlyphZoneRec zp;
FT_UShort refp;
FT_F26Dot6 dx, dy;
FT_Short contour, bounds;
FT_UShort start, limit, i;
contour = (FT_UShort)args[0];
bounds = ( CUR.GS.gep2 == 0 ) ? 1 : CUR.zp2.n_contours;
if ( BOUNDS( contour, bounds ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
return;
if ( contour == 0 )
start = 0;
else
start = (FT_UShort)( CUR.zp2.contours[contour - 1] + 1 -
CUR.zp2.first_point );
/* we use the number of points if in the twilight zone */
if ( CUR.GS.gep2 == 0 )
limit = CUR.zp2.n_points;
else
limit = (FT_UShort)( CUR.zp2.contours[contour] -
CUR.zp2.first_point + 1 );
for ( i = start; i < limit; i++ )
{
if ( zp.cur != CUR.zp2.cur || refp != i )
MOVE_Zp2_Point( i, dx, dy, TRUE );
}
}
/*************************************************************************/
/* */
/* SHZ[a]: SHift Zone */
/* Opcode range: 0x36-37 */
/* Stack: uint32 --> */
/* */
static void
Ins_SHZ( INS_ARG )
{
TT_GlyphZoneRec zp;
FT_UShort refp;
FT_F26Dot6 dx,
dy;
FT_UShort limit, i;
if ( BOUNDS( args[0], 2 ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
if ( COMPUTE_Point_Displacement( &dx, &dy, &zp, &refp ) )
return;
/* XXX: UNDOCUMENTED! SHZ doesn't move the phantom points. */
/* Twilight zone has no real contours, so use `n_points'. */
/* Normal zone's `n_points' includes phantoms, so must */
/* use end of last contour. */
if ( CUR.GS.gep2 == 0 )
limit = (FT_UShort)CUR.zp2.n_points;
else if ( CUR.GS.gep2 == 1 && CUR.zp2.n_contours > 0 )
limit = (FT_UShort)( CUR.zp2.contours[CUR.zp2.n_contours - 1] + 1 );
else
limit = 0;
/* XXX: UNDOCUMENTED! SHZ doesn't touch the points */
for ( i = 0; i < limit; i++ )
{
if ( zp.cur != CUR.zp2.cur || refp != i )
MOVE_Zp2_Point( i, dx, dy, FALSE );
}
}
/*************************************************************************/
/* */
/* SHPIX[]: SHift points by a PIXel amount */
/* Opcode range: 0x38 */
/* Stack: f26.6 uint32... --> */
/* */
static void
Ins_SHPIX( INS_ARG )
{
FT_F26Dot6 dx, dy;
FT_UShort point;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_Int B1, B2;
#endif
if ( CUR.top < CUR.GS.loop + 1 )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
dx = (FT_UInt32)args[0];
dy = 0;
}
else
{
dx = 0;
dy = (FT_UInt32)args[0];
}
}
else
#endif
{
dx = TT_MulFix14( (FT_UInt32)args[0], CUR.GS.freeVector.x );
dy = TT_MulFix14( (FT_UInt32)args[0], CUR.GS.freeVector.y );
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (FT_UShort)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
{
/* If not using ignore_x_mode rendering, allow ZP2 move. */
/* If inline deltas aren't allowed, skip ZP2 move. */
/* If using ignore_x_mode rendering, allow ZP2 point move if: */
/* - freedom vector is y and sph_compatibility_mode is off */
/* - the glyph is composite and the move is in the Y direction */
/* - the glyph is specifically set to allow SHPIX moves */
/* - the move is on a previously Y-touched point */
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode )
{
/* save point for later comparison */
if ( CUR.GS.freeVector.y != 0 )
B1 = CUR.zp2.cur[point].y;
else
B1 = CUR.zp2.cur[point].x;
if ( !CUR.face->sph_compatibility_mode &&
CUR.GS.freeVector.y != 0 )
{
MOVE_Zp2_Point( point, dx, dy, TRUE );
/* save new point */
if ( CUR.GS.freeVector.y != 0 )
{
B2 = CUR.zp2.cur[point].y;
/* reverse any disallowed moves */
if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 &&
B1 != B2 )
MOVE_Zp2_Point( point, -dx, -dy, TRUE );
}
}
else if ( CUR.face->sph_compatibility_mode )
{
if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
{
dx = FT_PIX_ROUND( B1 + dx ) - B1;
dy = FT_PIX_ROUND( B1 + dy ) - B1;
}
/* skip post-iup deltas */
if ( CUR.iup_called &&
( ( CUR.sph_in_func_flags & SPH_FDEF_INLINE_DELTA_1 ) ||
( CUR.sph_in_func_flags & SPH_FDEF_INLINE_DELTA_2 ) ) )
goto Skip;
if ( !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) &&
( ( CUR.is_composite && CUR.GS.freeVector.y != 0 ) ||
( CUR.zp2.tags[point] & FT_CURVE_TAG_TOUCH_Y ) ||
( CUR.sph_tweak_flags & SPH_TWEAK_DO_SHPIX ) ) )
MOVE_Zp2_Point( point, 0, dy, TRUE );
/* save new point */
if ( CUR.GS.freeVector.y != 0 )
{
B2 = CUR.zp2.cur[point].y;
/* reverse any disallowed moves */
if ( ( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 &&
B1 != B2 )
MOVE_Zp2_Point( point, 0, -dy, TRUE );
}
}
else if ( CUR.sph_in_func_flags & SPH_FDEF_TYPEMAN_DIAGENDCTRL )
MOVE_Zp2_Point( point, dx, dy, TRUE );
}
else
MOVE_Zp2_Point( point, dx, dy, TRUE );
}
Skip:
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
MOVE_Zp2_Point( point, dx, dy, TRUE );
#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR.GS.loop--;
}
Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* MSIRP[a]: Move Stack Indirect Relative Position */
/* Opcode range: 0x3A-0x3B */
/* Stack: f26.6 uint32 --> */
/* */
static void
Ins_MSIRP( INS_ARG )
{
FT_UShort point;
FT_F26Dot6 distance;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_F26Dot6 control_value_cutin = 0; /* pacify compiler */
if ( SUBPIXEL_HINTING )
{
control_value_cutin = CUR.GS.control_value_cutin;
if ( CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 &&
!( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = 0;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
point = (FT_UShort)args[0];
if ( BOUNDS( point, CUR.zp1.n_points ) ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
/* UNDOCUMENTED! The MS rasterizer does that with */
/* twilight points (confirmed by Greg Hitchcock) */
if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org[point] = CUR.zp0.org[CUR.GS.rp0];
CUR_Func_move_orig( &CUR.zp1, point, args[1] );
CUR.zp1.cur[point] = CUR.zp1.org[point];
}
distance = CUR_Func_project( CUR.zp1.cur + point,
CUR.zp0.cur + CUR.GS.rp0 );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* subpixel hinting - make MSIRP respect CVT cut-in; */
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 &&
FT_ABS( distance - args[1] ) >= control_value_cutin )
distance = args[1];
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR_Func_move( &CUR.zp1, point, args[1] - distance );
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
if ( ( CUR.opcode & 1 ) != 0 )
CUR.GS.rp0 = point;
}
/*************************************************************************/
/* */
/* MDAP[a]: Move Direct Absolute Point */
/* Opcode range: 0x2E-0x2F */
/* Stack: uint32 --> */
/* */
static void
Ins_MDAP( INS_ARG )
{
FT_UShort point;
FT_F26Dot6 cur_dist;
FT_F26Dot6 distance;
point = (FT_UShort)args[0];
if ( BOUNDS( point, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
if ( ( CUR.opcode & 1 ) != 0 )
{
cur_dist = CUR_fast_project( &CUR.zp0.cur[point] );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 )
distance = ROUND_None(
cur_dist,
CUR.tt_metrics.compensations[0] ) - cur_dist;
else
#endif
distance = CUR_Func_round(
cur_dist,
CUR.tt_metrics.compensations[0] ) - cur_dist;
}
else
distance = 0;
CUR_Func_move( &CUR.zp0, point, distance );
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
/*************************************************************************/
/* */
/* MIAP[a]: Move Indirect Absolute Point */
/* Opcode range: 0x3E-0x3F */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_MIAP( INS_ARG )
{
FT_ULong cvtEntry;
FT_UShort point;
FT_F26Dot6 distance;
FT_F26Dot6 org_dist;
FT_F26Dot6 control_value_cutin;
control_value_cutin = CUR.GS.control_value_cutin;
cvtEntry = (FT_ULong)args[1];
point = (FT_UShort)args[0];
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 &&
CUR.GS.freeVector.y == 0 &&
!( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = 0;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( BOUNDS( point, CUR.zp0.n_points ) ||
BOUNDSL( cvtEntry, CUR.cvtSize ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
/* UNDOCUMENTED! */
/* */
/* The behaviour of an MIAP instruction is quite different when used */
/* in the twilight zone. */
/* */
/* First, no control value cut-in test is performed as it would fail */
/* anyway. Second, the original point, i.e. (org_x,org_y) of */
/* zp0.point, is set to the absolute, unrounded distance found in the */
/* CVT. */
/* */
/* This is used in the CVT programs of the Microsoft fonts Arial, */
/* Times, etc., in order to re-adjust some key font heights. It */
/* allows the use of the IP instruction in the twilight zone, which */
/* otherwise would be invalid according to the specification. */
/* */
/* We implement it with a special sequence for the twilight zone. */
/* This is a bad hack, but it seems to work. */
/* */
/* Confirmed by Greg Hitchcock. */
distance = CUR_Func_read_cvt( cvtEntry );
if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* Only adjust if not in sph_compatibility_mode or ignore_x_mode. */
/* Determined via experimentation and may be incorrect... */
if ( !SUBPIXEL_HINTING ||
( !CUR.ignore_x_mode ||
!CUR.face->sph_compatibility_mode ) )
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance,
CUR.GS.freeVector.x );
CUR.zp0.org[point].y = TT_MulFix14( (FT_UInt32)distance,
CUR.GS.freeVector.y ),
CUR.zp0.cur[point] = CUR.zp0.org[point];
}
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
( CUR.sph_tweak_flags & SPH_TWEAK_MIAP_HACK ) &&
distance > 0 &&
CUR.GS.freeVector.y != 0 )
distance = 0;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
org_dist = CUR_fast_project( &CUR.zp0.cur[point] );
if ( ( CUR.opcode & 1 ) != 0 ) /* rounding and control cut-in flag */
{
if ( FT_ABS( distance - org_dist ) > control_value_cutin )
distance = org_dist;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 )
distance = ROUND_None( distance,
CUR.tt_metrics.compensations[0] );
else
#endif
distance = CUR_Func_round( distance,
CUR.tt_metrics.compensations[0] );
}
CUR_Func_move( &CUR.zp0, point, distance - org_dist );
Fail:
CUR.GS.rp0 = point;
CUR.GS.rp1 = point;
}
/*************************************************************************/
/* */
/* MDRP[abcde]: Move Direct Relative Point */
/* Opcode range: 0xC0-0xDF */
/* Stack: uint32 --> */
/* */
static void
Ins_MDRP( INS_ARG )
{
FT_UShort point;
FT_F26Dot6 org_dist, distance, minimum_distance;
minimum_distance = CUR.GS.minimum_distance;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 &&
!( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
minimum_distance = 0;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
point = (FT_UShort)args[0];
if ( BOUNDS( point, CUR.zp1.n_points ) ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
/* XXX: Is there some undocumented feature while in the */
/* twilight zone? */
/* XXX: UNDOCUMENTED: twilight zone special case */
if ( CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 )
{
FT_Vector* vec1 = &CUR.zp1.org[point];
FT_Vector* vec2 = &CUR.zp0.org[CUR.GS.rp0];
org_dist = CUR_Func_dualproj( vec1, vec2 );
}
else
{
FT_Vector* vec1 = &CUR.zp1.orus[point];
FT_Vector* vec2 = &CUR.zp0.orus[CUR.GS.rp0];
if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
{
/* this should be faster */
org_dist = CUR_Func_dualproj( vec1, vec2 );
org_dist = FT_MulFix( org_dist, CUR.metrics.x_scale );
}
else
{
FT_Vector vec;
vec.x = FT_MulFix( vec1->x - vec2->x, CUR.metrics.x_scale );
vec.y = FT_MulFix( vec1->y - vec2->y, CUR.metrics.y_scale );
org_dist = CUR_fast_dualproj( &vec );
}
}
/* single width cut-in test */
if ( FT_ABS( org_dist - CUR.GS.single_width_value ) <
CUR.GS.single_width_cutin )
{
if ( org_dist >= 0 )
org_dist = CUR.GS.single_width_value;
else
org_dist = -CUR.GS.single_width_value;
}
/* round flag */
if ( ( CUR.opcode & 4 ) != 0 )
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 )
distance = ROUND_None(
org_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
else
#endif
distance = CUR_Func_round(
org_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
}
else
distance = ROUND_None(
org_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
/* minimum distance flag */
if ( ( CUR.opcode & 8 ) != 0 )
{
if ( org_dist >= 0 )
{
if ( distance < minimum_distance )
distance = minimum_distance;
}
else
{
if ( distance > -minimum_distance )
distance = -minimum_distance;
}
}
/* now move the point */
org_dist = CUR_Func_project( CUR.zp1.cur + point,
CUR.zp0.cur + CUR.GS.rp0 );
CUR_Func_move( &CUR.zp1, point, distance - org_dist );
Fail:
CUR.GS.rp1 = CUR.GS.rp0;
CUR.GS.rp2 = point;
if ( ( CUR.opcode & 16 ) != 0 )
CUR.GS.rp0 = point;
}
/*************************************************************************/
/* */
/* MIRP[abcde]: Move Indirect Relative Point */
/* Opcode range: 0xE0-0xFF */
/* Stack: int32? uint32 --> */
/* */
static void
Ins_MIRP( INS_ARG )
{
FT_UShort point;
FT_ULong cvtEntry;
FT_F26Dot6 cvt_dist,
distance,
cur_dist,
org_dist,
control_value_cutin,
minimum_distance;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_Int B1 = 0; /* pacify compiler */
FT_Int B2 = 0;
FT_Bool reverse_move = FALSE;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
minimum_distance = CUR.GS.minimum_distance;
control_value_cutin = CUR.GS.control_value_cutin;
point = (FT_UShort)args[0];
cvtEntry = (FT_ULong)( args[1] + 1 );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.x != 0 &&
!( CUR.sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) )
control_value_cutin = minimum_distance = 0;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* XXX: UNDOCUMENTED! cvt[-1] = 0 always */
if ( BOUNDS( point, CUR.zp1.n_points ) ||
BOUNDSL( cvtEntry, CUR.cvtSize + 1 ) ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
if ( !cvtEntry )
cvt_dist = 0;
else
cvt_dist = CUR_Func_read_cvt( cvtEntry - 1 );
/* single width test */
if ( FT_ABS( cvt_dist - CUR.GS.single_width_value ) <
CUR.GS.single_width_cutin )
{
if ( cvt_dist >= 0 )
cvt_dist = CUR.GS.single_width_value;
else
cvt_dist = -CUR.GS.single_width_value;
}
/* UNDOCUMENTED! The MS rasterizer does that with */
/* twilight points (confirmed by Greg Hitchcock) */
if ( CUR.GS.gep1 == 0 )
{
CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x +
TT_MulFix14( (FT_UInt32)cvt_dist,
CUR.GS.freeVector.x );
CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y +
TT_MulFix14( (FT_UInt32)cvt_dist,
CUR.GS.freeVector.y );
CUR.zp1.cur[point] = CUR.zp1.org[point];
}
org_dist = CUR_Func_dualproj( &CUR.zp1.org[point],
&CUR.zp0.org[CUR.GS.rp0] );
cur_dist = CUR_Func_project ( &CUR.zp1.cur[point],
&CUR.zp0.cur[CUR.GS.rp0] );
/* auto-flip test */
if ( CUR.GS.auto_flip )
{
if ( ( org_dist ^ cvt_dist ) < 0 )
cvt_dist = -cvt_dist;
}
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.freeVector.y != 0 &&
( CUR.sph_tweak_flags & SPH_TWEAK_TIMES_NEW_ROMAN_HACK ) )
{
if ( cur_dist < -64 )
cvt_dist -= 16;
else if ( cur_dist > 64 && cur_dist < 84 )
cvt_dist += 32;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* control value cut-in and round */
if ( ( CUR.opcode & 4 ) != 0 )
{
/* XXX: UNDOCUMENTED! Only perform cut-in test when both points */
/* refer to the same zone. */
if ( CUR.GS.gep0 == CUR.GS.gep1 )
{
/* XXX: According to Greg Hitchcock, the following wording is */
/* the right one: */
/* */
/* When the absolute difference between the value in */
/* the table [CVT] and the measurement directly from */
/* the outline is _greater_ than the cut_in value, the */
/* outline measurement is used. */
/* */
/* This is from `instgly.doc'. The description in */
/* `ttinst2.doc', version 1.66, is thus incorrect since */
/* it implies `>=' instead of `>'. */
if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
cvt_dist = org_dist;
}
distance = CUR_Func_round(
cvt_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
}
else
{
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/* do cvt cut-in always in MIRP for sph */
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.GS.gep0 == CUR.GS.gep1 )
{
if ( FT_ABS( cvt_dist - org_dist ) > control_value_cutin )
cvt_dist = org_dist;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
distance = ROUND_None(
cvt_dist,
CUR.tt_metrics.compensations[CUR.opcode & 3] );
}
/* minimum distance test */
if ( ( CUR.opcode & 8 ) != 0 )
{
if ( org_dist >= 0 )
{
if ( distance < minimum_distance )
distance = minimum_distance;
}
else
{
if ( distance > -minimum_distance )
distance = -minimum_distance;
}
}
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING )
{
B1 = CUR.zp1.cur[point].y;
/* Round moves if necessary */
if ( CUR.ignore_x_mode &&
CUR.GS.freeVector.y != 0 &&
( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) )
distance = FT_PIX_ROUND( B1 + distance - cur_dist ) - B1 + cur_dist;
if ( CUR.ignore_x_mode &&
CUR.GS.freeVector.y != 0 &&
( CUR.opcode & 16 ) == 0 &&
( CUR.opcode & 8 ) == 0 &&
( CUR.sph_tweak_flags & SPH_TWEAK_COURIER_NEW_2_HACK ) )
distance += 64;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR_Func_move( &CUR.zp1, point, distance - cur_dist );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING )
{
B2 = CUR.zp1.cur[point].y;
/* Reverse move if necessary */
if ( CUR.ignore_x_mode )
{
if ( CUR.face->sph_compatibility_mode &&
CUR.GS.freeVector.y != 0 &&
( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 )
reverse_move = TRUE;
if ( ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES ) &&
CUR.GS.freeVector.y != 0 &&
( B2 & 63 ) != 0 &&
( B1 & 63 ) != 0 )
reverse_move = TRUE;
}
if ( reverse_move )
CUR_Func_move( &CUR.zp1, point, -( distance - cur_dist ) );
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
Fail:
CUR.GS.rp1 = CUR.GS.rp0;
if ( ( CUR.opcode & 16 ) != 0 )
CUR.GS.rp0 = point;
CUR.GS.rp2 = point;
}
/*************************************************************************/
/* */
/* ALIGNRP[]: ALIGN Relative Point */
/* Opcode range: 0x3C */
/* Stack: uint32 uint32... --> */
/* */
static void
Ins_ALIGNRP( INS_ARG )
{
FT_UShort point;
FT_F26Dot6 distance;
FT_UNUSED_ARG;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.iup_called &&
( CUR.sph_tweak_flags & SPH_TWEAK_NO_ALIGNRP_AFTER_IUP ) )
{
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( CUR.top < CUR.GS.loop ||
BOUNDS( CUR.GS.rp0, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
while ( CUR.GS.loop > 0 )
{
CUR.args--;
point = (FT_UShort)CUR.stack[CUR.args];
if ( BOUNDS( point, CUR.zp1.n_points ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
{
distance = CUR_Func_project( CUR.zp1.cur + point,
CUR.zp0.cur + CUR.GS.rp0 );
CUR_Func_move( &CUR.zp1, point, -distance );
}
CUR.GS.loop--;
}
Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* ISECT[]: moves point to InterSECTion */
/* Opcode range: 0x0F */
/* Stack: 5 * uint32 --> */
/* */
static void
Ins_ISECT( INS_ARG )
{
FT_UShort point,
a0, a1,
b0, b1;
FT_F26Dot6 discriminant, dotproduct;
FT_F26Dot6 dx, dy,
dax, day,
dbx, dby;
FT_F26Dot6 val;
FT_Vector R;
point = (FT_UShort)args[0];
a0 = (FT_UShort)args[1];
a1 = (FT_UShort)args[2];
b0 = (FT_UShort)args[3];
b1 = (FT_UShort)args[4];
if ( BOUNDS( b0, CUR.zp0.n_points ) ||
BOUNDS( b1, CUR.zp0.n_points ) ||
BOUNDS( a0, CUR.zp1.n_points ) ||
BOUNDS( a1, CUR.zp1.n_points ) ||
BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
/* Cramer's rule */
dbx = CUR.zp0.cur[b1].x - CUR.zp0.cur[b0].x;
dby = CUR.zp0.cur[b1].y - CUR.zp0.cur[b0].y;
dax = CUR.zp1.cur[a1].x - CUR.zp1.cur[a0].x;
day = CUR.zp1.cur[a1].y - CUR.zp1.cur[a0].y;
dx = CUR.zp0.cur[b0].x - CUR.zp1.cur[a0].x;
dy = CUR.zp0.cur[b0].y - CUR.zp1.cur[a0].y;
CUR.zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH;
discriminant = FT_MulDiv( dax, -dby, 0x40 ) +
FT_MulDiv( day, dbx, 0x40 );
dotproduct = FT_MulDiv( dax, dbx, 0x40 ) +
FT_MulDiv( day, dby, 0x40 );
/* The discriminant above is actually a cross product of vectors */
/* da and db. Together with the dot product, they can be used as */
/* surrogates for sine and cosine of the angle between the vectors. */
/* Indeed, */
/* dotproduct = |da||db|cos(angle) */
/* discriminant = |da||db|sin(angle) . */
/* We use these equations to reject grazing intersections by */
/* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */
if ( 19 * FT_ABS( discriminant ) > FT_ABS( dotproduct ) )
{
val = FT_MulDiv( dx, -dby, 0x40 ) + FT_MulDiv( dy, dbx, 0x40 );
R.x = FT_MulDiv( val, dax, discriminant );
R.y = FT_MulDiv( val, day, discriminant );
CUR.zp2.cur[point].x = CUR.zp1.cur[a0].x + R.x;
CUR.zp2.cur[point].y = CUR.zp1.cur[a0].y + R.y;
}
else
{
/* else, take the middle of the middles of A and B */
CUR.zp2.cur[point].x = ( CUR.zp1.cur[a0].x +
CUR.zp1.cur[a1].x +
CUR.zp0.cur[b0].x +
CUR.zp0.cur[b1].x ) / 4;
CUR.zp2.cur[point].y = ( CUR.zp1.cur[a0].y +
CUR.zp1.cur[a1].y +
CUR.zp0.cur[b0].y +
CUR.zp0.cur[b1].y ) / 4;
}
}
/*************************************************************************/
/* */
/* ALIGNPTS[]: ALIGN PoinTS */
/* Opcode range: 0x27 */
/* Stack: uint32 uint32 --> */
/* */
static void
Ins_ALIGNPTS( INS_ARG )
{
FT_UShort p1, p2;
FT_F26Dot6 distance;
p1 = (FT_UShort)args[0];
p2 = (FT_UShort)args[1];
if ( BOUNDS( p1, CUR.zp1.n_points ) ||
BOUNDS( p2, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
distance = CUR_Func_project( CUR.zp0.cur + p2,
CUR.zp1.cur + p1 ) / 2;
CUR_Func_move( &CUR.zp1, p1, distance );
CUR_Func_move( &CUR.zp0, p2, -distance );
}
/*************************************************************************/
/* */
/* IP[]: Interpolate Point */
/* Opcode range: 0x39 */
/* Stack: uint32... --> */
/* */
/* SOMETIMES, DUMBER CODE IS BETTER CODE */
static void
Ins_IP( INS_ARG )
{
FT_F26Dot6 old_range, cur_range;
FT_Vector* orus_base;
FT_Vector* cur_base;
FT_Int twilight;
FT_UNUSED_ARG;
if ( CUR.top < CUR.GS.loop )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
/*
* We need to deal in a special way with the twilight zone.
* Otherwise, by definition, the value of CUR.twilight.orus[n] is (0,0),
* for every n.
*/
twilight = CUR.GS.gep0 == 0 || CUR.GS.gep1 == 0 || CUR.GS.gep2 == 0;
if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
goto Fail;
}
if ( twilight )
orus_base = &CUR.zp0.org[CUR.GS.rp1];
else
orus_base = &CUR.zp0.orus[CUR.GS.rp1];
cur_base = &CUR.zp0.cur[CUR.GS.rp1];
/* XXX: There are some glyphs in some braindead but popular */
/* fonts out there (e.g. [aeu]grave in monotype.ttf) */
/* calling IP[] with bad values of rp[12]. */
/* Do something sane when this odd thing happens. */
if ( BOUNDS( CUR.GS.rp1, CUR.zp0.n_points ) ||
BOUNDS( CUR.GS.rp2, CUR.zp1.n_points ) )
{
old_range = 0;
cur_range = 0;
}
else
{
if ( twilight )
old_range = CUR_Func_dualproj( &CUR.zp1.org[CUR.GS.rp2],
orus_base );
else if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
old_range = CUR_Func_dualproj( &CUR.zp1.orus[CUR.GS.rp2],
orus_base );
else
{
FT_Vector vec;
vec.x = FT_MulFix( CUR.zp1.orus[CUR.GS.rp2].x - orus_base->x,
CUR.metrics.x_scale );
vec.y = FT_MulFix( CUR.zp1.orus[CUR.GS.rp2].y - orus_base->y,
CUR.metrics.y_scale );
old_range = CUR_fast_dualproj( &vec );
}
cur_range = CUR_Func_project ( &CUR.zp1.cur[CUR.GS.rp2], cur_base );
}
for ( ; CUR.GS.loop > 0; --CUR.GS.loop )
{
FT_UInt point = (FT_UInt)CUR.stack[--CUR.args];
FT_F26Dot6 org_dist, cur_dist, new_dist;
/* check point bounds */
if ( BOUNDS( point, CUR.zp2.n_points ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
continue;
}
if ( twilight )
org_dist = CUR_Func_dualproj( &CUR.zp2.org[point], orus_base );
else if ( CUR.metrics.x_scale == CUR.metrics.y_scale )
org_dist = CUR_Func_dualproj( &CUR.zp2.orus[point], orus_base );
else
{
FT_Vector vec;
vec.x = FT_MulFix( CUR.zp2.orus[point].x - orus_base->x,
CUR.metrics.x_scale );
vec.y = FT_MulFix( CUR.zp2.orus[point].y - orus_base->y,
CUR.metrics.y_scale );
org_dist = CUR_fast_dualproj( &vec );
}
cur_dist = CUR_Func_project( &CUR.zp2.cur[point], cur_base );
if ( org_dist )
{
if ( old_range )
new_dist = FT_MulDiv( org_dist, cur_range, old_range );
else
{
/* This is the same as what MS does for the invalid case: */
/* */
/* delta = (Original_Pt - Original_RP1) - */
/* (Current_Pt - Current_RP1) ; */
/* */
/* In FreeType speak: */
/* */
/* delta = org_dist - cur_dist . */
/* */
/* We move `point' by `new_dist - cur_dist' after leaving */
/* this block, thus we have */
/* */
/* new_dist - cur_dist = delta , */
/* new_dist - cur_dist = org_dist - cur_dist , */
/* new_dist = org_dist . */
new_dist = org_dist;
}
}
else
new_dist = 0;
CUR_Func_move( &CUR.zp2, (FT_UShort)point, new_dist - cur_dist );
}
Fail:
CUR.GS.loop = 1;
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* UTP[a]: UnTouch Point */
/* Opcode range: 0x29 */
/* Stack: uint32 --> */
/* */
static void
Ins_UTP( INS_ARG )
{
FT_UShort point;
FT_Byte mask;
point = (FT_UShort)args[0];
if ( BOUNDS( point, CUR.zp0.n_points ) )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
return;
}
mask = 0xFF;
if ( CUR.GS.freeVector.x != 0 )
mask &= ~FT_CURVE_TAG_TOUCH_X;
if ( CUR.GS.freeVector.y != 0 )
mask &= ~FT_CURVE_TAG_TOUCH_Y;
CUR.zp0.tags[point] &= mask;
}
/* Local variables for Ins_IUP: */
typedef struct IUP_WorkerRec_
{
FT_Vector* orgs; /* original and current coordinate */
FT_Vector* curs; /* arrays */
FT_Vector* orus;
FT_UInt max_points;
} IUP_WorkerRec, *IUP_Worker;
static void
_iup_worker_shift( IUP_Worker worker,
FT_UInt p1,
FT_UInt p2,
FT_UInt p )
{
FT_UInt i;
FT_F26Dot6 dx;
dx = worker->curs[p].x - worker->orgs[p].x;
if ( dx != 0 )
{
for ( i = p1; i < p; i++ )
worker->curs[i].x += dx;
for ( i = p + 1; i <= p2; i++ )
worker->curs[i].x += dx;
}
}
static void
_iup_worker_interpolate( IUP_Worker worker,
FT_UInt p1,
FT_UInt p2,
FT_UInt ref1,
FT_UInt ref2 )
{
FT_UInt i;
FT_F26Dot6 orus1, orus2, org1, org2, delta1, delta2;
if ( p1 > p2 )
return;
if ( BOUNDS( ref1, worker->max_points ) ||
BOUNDS( ref2, worker->max_points ) )
return;
orus1 = worker->orus[ref1].x;
orus2 = worker->orus[ref2].x;
if ( orus1 > orus2 )
{
FT_F26Dot6 tmp_o;
FT_UInt tmp_r;
tmp_o = orus1;
orus1 = orus2;
orus2 = tmp_o;
tmp_r = ref1;
ref1 = ref2;
ref2 = tmp_r;
}
org1 = worker->orgs[ref1].x;
org2 = worker->orgs[ref2].x;
delta1 = worker->curs[ref1].x - org1;
delta2 = worker->curs[ref2].x - org2;
if ( orus1 == orus2 )
{
/* simple shift of untouched points */
for ( i = p1; i <= p2; i++ )
{
FT_F26Dot6 x = worker->orgs[i].x;
if ( x <= org1 )
x += delta1;
else
x += delta2;
worker->curs[i].x = x;
}
}
else
{
FT_Fixed scale = 0;
FT_Bool scale_valid = 0;
/* interpolation */
for ( i = p1; i <= p2; i++ )
{
FT_F26Dot6 x = worker->orgs[i].x;
if ( x <= org1 )
x += delta1;
else if ( x >= org2 )
x += delta2;
else
{
if ( !scale_valid )
{
scale_valid = 1;
scale = FT_DivFix( org2 + delta2 - ( org1 + delta1 ),
orus2 - orus1 );
}
x = ( org1 + delta1 ) +
FT_MulFix( worker->orus[i].x - orus1, scale );
}
worker->curs[i].x = x;
}
}
}
/*************************************************************************/
/* */
/* IUP[a]: Interpolate Untouched Points */
/* Opcode range: 0x30-0x31 */
/* Stack: --> */
/* */
static void
Ins_IUP( INS_ARG )
{
IUP_WorkerRec V;
FT_Byte mask;
FT_UInt first_point; /* first point of contour */
FT_UInt end_point; /* end point (last+1) of contour */
FT_UInt first_touched; /* first touched point in contour */
FT_UInt cur_touched; /* current touched point in contour */
FT_UInt point; /* current point */
FT_Short contour; /* current contour */
FT_UNUSED_ARG;
/* ignore empty outlines */
if ( CUR.pts.n_contours == 0 )
return;
if ( CUR.opcode & 1 )
{
mask = FT_CURVE_TAG_TOUCH_X;
V.orgs = CUR.pts.org;
V.curs = CUR.pts.cur;
V.orus = CUR.pts.orus;
}
else
{
mask = FT_CURVE_TAG_TOUCH_Y;
V.orgs = (FT_Vector*)( (FT_Pos*)CUR.pts.org + 1 );
V.curs = (FT_Vector*)( (FT_Pos*)CUR.pts.cur + 1 );
V.orus = (FT_Vector*)( (FT_Pos*)CUR.pts.orus + 1 );
}
V.max_points = CUR.pts.n_points;
contour = 0;
point = 0;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode )
{
CUR.iup_called = TRUE;
if ( CUR.sph_tweak_flags & SPH_TWEAK_SKIP_IUP )
return;
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
do
{
end_point = CUR.pts.contours[contour] - CUR.pts.first_point;
first_point = point;
if ( BOUNDS ( end_point, CUR.pts.n_points ) )
end_point = CUR.pts.n_points - 1;
while ( point <= end_point && ( CUR.pts.tags[point] & mask ) == 0 )
point++;
if ( point <= end_point )
{
first_touched = point;
cur_touched = point;
point++;
while ( point <= end_point )
{
if ( ( CUR.pts.tags[point] & mask ) != 0 )
{
_iup_worker_interpolate( &V,
cur_touched + 1,
point - 1,
cur_touched,
point );
cur_touched = point;
}
point++;
}
if ( cur_touched == first_touched )
_iup_worker_shift( &V, first_point, end_point, cur_touched );
else
{
_iup_worker_interpolate( &V,
(FT_UShort)( cur_touched + 1 ),
end_point,
cur_touched,
first_touched );
if ( first_touched > 0 )
_iup_worker_interpolate( &V,
first_point,
first_touched - 1,
cur_touched,
first_touched );
}
}
contour++;
} while ( contour < CUR.pts.n_contours );
}
/*************************************************************************/
/* */
/* DELTAPn[]: DELTA exceptions P1, P2, P3 */
/* Opcode range: 0x5D,0x71,0x72 */
/* Stack: uint32 (2 * uint32)... --> */
/* */
static void
Ins_DELTAP( INS_ARG )
{
FT_ULong k, nump;
FT_UShort A;
FT_ULong C;
FT_Long B;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_UShort B1, B2;
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.iup_called &&
( CUR.sph_tweak_flags & SPH_TWEAK_NO_DELTAP_AFTER_IUP ) )
goto Fail;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
{
FT_Long n = args[0] * 2;
if ( CUR.args < n )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Too_Few_Arguments );
n = CUR.args;
}
CUR.args -= n;
CUR.new_top = CUR.args;
return;
}
#endif
nump = (FT_ULong)args[0]; /* some points theoretically may occur more
than once, thus UShort isn't enough */
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Too_Few_Arguments );
CUR.args = 0;
goto Fail;
}
CUR.args -= 2;
A = (FT_UShort)CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
/* XXX: Because some popular fonts contain some invalid DeltaP */
/* instructions, we simply ignore them when the stacked */
/* point reference is off limit, rather than returning an */
/* error. As a delta instruction doesn't change a glyph */
/* in great ways, this shouldn't be a problem. */
if ( !BOUNDS( A, CUR.zp0.n_points ) )
{
C = ( (FT_ULong)B & 0xF0 ) >> 4;
switch ( CUR.opcode )
{
case 0x5D:
break;
case 0x71:
C += 16;
break;
case 0x72:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == (FT_Long)C )
{
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
B = B * 64 / ( 1L << CUR.GS.delta_shift );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING )
{
/*
* Allow delta move if
*
* - not using ignore_x_mode rendering
* - glyph is specifically set to allow it
* - glyph is composite and freedom vector is not subpixel
* vector
*/
if ( !CUR.ignore_x_mode ||
( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) ||
( CUR.is_composite && CUR.GS.freeVector.y != 0 ) )
CUR_Func_move( &CUR.zp0, A, B );
/* Otherwise apply subpixel hinting and */
/* compatibility mode rules */
else if ( CUR.ignore_x_mode )
{
if ( CUR.GS.freeVector.y != 0 )
B1 = CUR.zp0.cur[A].y;
else
B1 = CUR.zp0.cur[A].x;
#if 0
/* Standard Subpixel Hinting: Allow y move. */
/* This messes up dejavu and may not be needed... */
if ( !CUR.face->sph_compatibility_mode &&
CUR.GS.freeVector.y != 0 )
CUR_Func_move( &CUR.zp0, A, B );
else
#endif /* 0 */
/* Compatibility Mode: Allow x or y move if point touched in */
/* Y direction. */
if ( CUR.face->sph_compatibility_mode &&
!( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) )
{
/* save the y value of the point now; compare after move */
B1 = CUR.zp0.cur[A].y;
if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES )
B = FT_PIX_ROUND( B1 + B ) - B1;
/* Allow delta move if using sph_compatibility_mode, */
/* IUP has not been called, and point is touched on Y. */
if ( !CUR.iup_called &&
( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) )
CUR_Func_move( &CUR.zp0, A, B );
}
B2 = CUR.zp0.cur[A].y;
/* Reverse this move if it results in a disallowed move */
if ( CUR.GS.freeVector.y != 0 &&
( ( CUR.face->sph_compatibility_mode &&
( B1 & 63 ) == 0 &&
( B2 & 63 ) != 0 ) ||
( ( CUR.sph_tweak_flags &
SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP ) &&
( B1 & 63 ) != 0 &&
( B2 & 63 ) != 0 ) ) )
CUR_Func_move( &CUR.zp0, A, -B );
}
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
CUR_Func_move( &CUR.zp0, A, B );
}
}
else
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Invalid_Reference );
}
Fail:
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* DELTACn[]: DELTA exceptions C1, C2, C3 */
/* Opcode range: 0x73,0x74,0x75 */
/* Stack: uint32 (2 * uint32)... --> */
/* */
static void
Ins_DELTAC( INS_ARG )
{
FT_ULong nump, k;
FT_ULong A, C;
FT_Long B;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
{
FT_Long n = args[0] * 2;
if ( CUR.args < n )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Too_Few_Arguments );
n = CUR.args;
}
CUR.args -= n;
CUR.new_top = CUR.args;
return;
}
#endif
nump = (FT_ULong)args[0];
for ( k = 1; k <= nump; k++ )
{
if ( CUR.args < 2 )
{
if ( CUR.pedantic_hinting )
CUR.error = FT_THROW( Too_Few_Arguments );
CUR.args = 0;
goto Fail;
}
CUR.args -= 2;
A = (FT_ULong)CUR.stack[CUR.args + 1];
B = CUR.stack[CUR.args];
if ( BOUNDSL( A, CUR.cvtSize ) )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Invalid_Reference );
return;
}
}
else
{
C = ( (FT_ULong)B & 0xF0 ) >> 4;
switch ( CUR.opcode )
{
case 0x73:
break;
case 0x74:
C += 16;
break;
case 0x75:
C += 32;
break;
}
C += CUR.GS.delta_base;
if ( CURRENT_Ppem() == (FT_Long)C )
{
B = ( (FT_ULong)B & 0xF ) - 8;
if ( B >= 0 )
B++;
B = B * 64 / ( 1L << CUR.GS.delta_shift );
CUR_Func_move_cvt( A, B );
}
}
}
Fail:
CUR.new_top = CUR.args;
}
/*************************************************************************/
/* */
/* MISC. INSTRUCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* GETINFO[]: GET INFOrmation */
/* Opcode range: 0x88 */
/* Stack: uint32 --> uint32 */
/* */
static void
Ins_GETINFO( INS_ARG )
{
FT_Long K;
K = 0;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/********************************/
/* RASTERIZER VERSION */
/* Selector Bit: 0 */
/* Return Bit(s): 0-7 */
/* */
if ( SUBPIXEL_HINTING &&
( args[0] & 1 ) != 0 &&
CUR.ignore_x_mode )
{
K = CUR.rasterizer_version;
FT_TRACE7(( "Setting rasterizer version %d\n",
CUR.rasterizer_version ));
}
else
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
if ( ( args[0] & 1 ) != 0 )
K = TT_INTERPRETER_VERSION_35;
/********************************/
/* GLYPH ROTATED */
/* Selector Bit: 1 */
/* Return Bit(s): 8 */
/* */
if ( ( args[0] & 2 ) != 0 && CUR.tt_metrics.rotated )
K |= 0x80;
/********************************/
/* GLYPH STRETCHED */
/* Selector Bit: 2 */
/* Return Bit(s): 9 */
/* */
if ( ( args[0] & 4 ) != 0 && CUR.tt_metrics.stretched )
K |= 1 << 8;
/********************************/
/* HINTING FOR GRAYSCALE */
/* Selector Bit: 5 */
/* Return Bit(s): 12 */
/* */
if ( ( args[0] & 32 ) != 0 && CUR.grayscale )
K |= 1 << 12;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING &&
CUR.ignore_x_mode &&
CUR.rasterizer_version >= TT_INTERPRETER_VERSION_35 )
{
if ( CUR.rasterizer_version >= 37 )
{
/********************************/
/* HINTING FOR SUBPIXEL */
/* Selector Bit: 6 */
/* Return Bit(s): 13 */
/* */
if ( ( args[0] & 64 ) != 0 && CUR.subpixel )
K |= 1 << 13;
/********************************/
/* COMPATIBLE WIDTHS ENABLED */
/* Selector Bit: 7 */
/* Return Bit(s): 14 */
/* */
/* Functionality still needs to be added */
if ( ( args[0] & 128 ) != 0 && CUR.compatible_widths )
K |= 1 << 14;
/********************************/
/* SYMMETRICAL SMOOTHING */
/* Selector Bit: 8 */
/* Return Bit(s): 15 */
/* */
/* Functionality still needs to be added */
if ( ( args[0] & 256 ) != 0 && CUR.symmetrical_smoothing )
K |= 1 << 15;
/********************************/
/* HINTING FOR BGR? */
/* Selector Bit: 9 */
/* Return Bit(s): 16 */
/* */
/* Functionality still needs to be added */
if ( ( args[0] & 512 ) != 0 && CUR.bgr )
K |= 1 << 16;
if ( CUR.rasterizer_version >= 38 )
{
/********************************/
/* SUBPIXEL POSITIONED? */
/* Selector Bit: 10 */
/* Return Bit(s): 17 */
/* */
/* Functionality still needs to be added */
if ( ( args[0] & 1024 ) != 0 && CUR.subpixel_positioned )
K |= 1 << 17;
}
}
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
args[0] = K;
}
static void
Ins_UNKNOWN( INS_ARG )
{
TT_DefRecord* def = CUR.IDefs;
TT_DefRecord* limit = def + CUR.numIDefs;
FT_UNUSED_ARG;
for ( ; def < limit; def++ )
{
if ( (FT_Byte)def->opc == CUR.opcode && def->active )
{
TT_CallRec* call;
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = FT_THROW( Stack_Overflow );
return;
}
call = CUR.callStack + CUR.callTop++;
call->Caller_Range = CUR.curRange;
call->Caller_IP = CUR.IP + 1;
call->Cur_Count = 1;
call->Def = def;
INS_Goto_CodeRange( def->range, def->start );
CUR.step_ins = FALSE;
return;
}
}
CUR.error = FT_THROW( Invalid_Opcode );
}
#ifndef TT_CONFIG_OPTION_INTERPRETER_SWITCH
static
TInstruction_Function Instruct_Dispatch[256] =
{
/* Opcodes are gathered in groups of 16. */
/* Please keep the spaces as they are. */
/* SVTCA y */ Ins_SVTCA,
/* SVTCA x */ Ins_SVTCA,
/* SPvTCA y */ Ins_SPVTCA,
/* SPvTCA x */ Ins_SPVTCA,
/* SFvTCA y */ Ins_SFVTCA,
/* SFvTCA x */ Ins_SFVTCA,
/* SPvTL // */ Ins_SPVTL,
/* SPvTL + */ Ins_SPVTL,
/* SFvTL // */ Ins_SFVTL,
/* SFvTL + */ Ins_SFVTL,
/* SPvFS */ Ins_SPVFS,
/* SFvFS */ Ins_SFVFS,
/* GPV */ Ins_GPV,
/* GFV */ Ins_GFV,
/* SFvTPv */ Ins_SFVTPV,
/* ISECT */ Ins_ISECT,
/* SRP0 */ Ins_SRP0,
/* SRP1 */ Ins_SRP1,
/* SRP2 */ Ins_SRP2,
/* SZP0 */ Ins_SZP0,
/* SZP1 */ Ins_SZP1,
/* SZP2 */ Ins_SZP2,
/* SZPS */ Ins_SZPS,
/* SLOOP */ Ins_SLOOP,
/* RTG */ Ins_RTG,
/* RTHG */ Ins_RTHG,
/* SMD */ Ins_SMD,
/* ELSE */ Ins_ELSE,
/* JMPR */ Ins_JMPR,
/* SCvTCi */ Ins_SCVTCI,
/* SSwCi */ Ins_SSWCI,
/* SSW */ Ins_SSW,
/* DUP */ Ins_DUP,
/* POP */ Ins_POP,
/* CLEAR */ Ins_CLEAR,
/* SWAP */ Ins_SWAP,
/* DEPTH */ Ins_DEPTH,
/* CINDEX */ Ins_CINDEX,
/* MINDEX */ Ins_MINDEX,
/* AlignPTS */ Ins_ALIGNPTS,
/* INS_0x28 */ Ins_UNKNOWN,
/* UTP */ Ins_UTP,
/* LOOPCALL */ Ins_LOOPCALL,
/* CALL */ Ins_CALL,
/* FDEF */ Ins_FDEF,
/* ENDF */ Ins_ENDF,
/* MDAP[0] */ Ins_MDAP,
/* MDAP[1] */ Ins_MDAP,
/* IUP[0] */ Ins_IUP,
/* IUP[1] */ Ins_IUP,
/* SHP[0] */ Ins_SHP,
/* SHP[1] */ Ins_SHP,
/* SHC[0] */ Ins_SHC,
/* SHC[1] */ Ins_SHC,
/* SHZ[0] */ Ins_SHZ,
/* SHZ[1] */ Ins_SHZ,
/* SHPIX */ Ins_SHPIX,
/* IP */ Ins_IP,
/* MSIRP[0] */ Ins_MSIRP,
/* MSIRP[1] */ Ins_MSIRP,
/* AlignRP */ Ins_ALIGNRP,
/* RTDG */ Ins_RTDG,
/* MIAP[0] */ Ins_MIAP,
/* MIAP[1] */ Ins_MIAP,
/* NPushB */ Ins_NPUSHB,
/* NPushW */ Ins_NPUSHW,
/* WS */ Ins_WS,
/* RS */ Ins_RS,
/* WCvtP */ Ins_WCVTP,
/* RCvt */ Ins_RCVT,
/* GC[0] */ Ins_GC,
/* GC[1] */ Ins_GC,
/* SCFS */ Ins_SCFS,
/* MD[0] */ Ins_MD,
/* MD[1] */ Ins_MD,
/* MPPEM */ Ins_MPPEM,
/* MPS */ Ins_MPS,
/* FlipON */ Ins_FLIPON,
/* FlipOFF */ Ins_FLIPOFF,
/* DEBUG */ Ins_DEBUG,
/* LT */ Ins_LT,
/* LTEQ */ Ins_LTEQ,
/* GT */ Ins_GT,
/* GTEQ */ Ins_GTEQ,
/* EQ */ Ins_EQ,
/* NEQ */ Ins_NEQ,
/* ODD */ Ins_ODD,
/* EVEN */ Ins_EVEN,
/* IF */ Ins_IF,
/* EIF */ Ins_EIF,
/* AND */ Ins_AND,
/* OR */ Ins_OR,
/* NOT */ Ins_NOT,
/* DeltaP1 */ Ins_DELTAP,
/* SDB */ Ins_SDB,
/* SDS */ Ins_SDS,
/* ADD */ Ins_ADD,
/* SUB */ Ins_SUB,
/* DIV */ Ins_DIV,
/* MUL */ Ins_MUL,
/* ABS */ Ins_ABS,
/* NEG */ Ins_NEG,
/* FLOOR */ Ins_FLOOR,
/* CEILING */ Ins_CEILING,
/* ROUND[0] */ Ins_ROUND,
/* ROUND[1] */ Ins_ROUND,
/* ROUND[2] */ Ins_ROUND,
/* ROUND[3] */ Ins_ROUND,
/* NROUND[0] */ Ins_NROUND,
/* NROUND[1] */ Ins_NROUND,
/* NROUND[2] */ Ins_NROUND,
/* NROUND[3] */ Ins_NROUND,
/* WCvtF */ Ins_WCVTF,
/* DeltaP2 */ Ins_DELTAP,
/* DeltaP3 */ Ins_DELTAP,
/* DeltaCn[0] */ Ins_DELTAC,
/* DeltaCn[1] */ Ins_DELTAC,
/* DeltaCn[2] */ Ins_DELTAC,
/* SROUND */ Ins_SROUND,
/* S45Round */ Ins_S45ROUND,
/* JROT */ Ins_JROT,
/* JROF */ Ins_JROF,
/* ROFF */ Ins_ROFF,
/* INS_0x7B */ Ins_UNKNOWN,
/* RUTG */ Ins_RUTG,
/* RDTG */ Ins_RDTG,
/* SANGW */ Ins_SANGW,
/* AA */ Ins_AA,
/* FlipPT */ Ins_FLIPPT,
/* FlipRgON */ Ins_FLIPRGON,
/* FlipRgOFF */ Ins_FLIPRGOFF,
/* INS_0x83 */ Ins_UNKNOWN,
/* INS_0x84 */ Ins_UNKNOWN,
/* ScanCTRL */ Ins_SCANCTRL,
/* SDPVTL[0] */ Ins_SDPVTL,
/* SDPVTL[1] */ Ins_SDPVTL,
/* GetINFO */ Ins_GETINFO,
/* IDEF */ Ins_IDEF,
/* ROLL */ Ins_ROLL,
/* MAX */ Ins_MAX,
/* MIN */ Ins_MIN,
/* ScanTYPE */ Ins_SCANTYPE,
/* InstCTRL */ Ins_INSTCTRL,
/* INS_0x8F */ Ins_UNKNOWN,
/* INS_0x90 */ Ins_UNKNOWN,
/* INS_0x91 */ Ins_UNKNOWN,
/* INS_0x92 */ Ins_UNKNOWN,
/* INS_0x93 */ Ins_UNKNOWN,
/* INS_0x94 */ Ins_UNKNOWN,
/* INS_0x95 */ Ins_UNKNOWN,
/* INS_0x96 */ Ins_UNKNOWN,
/* INS_0x97 */ Ins_UNKNOWN,
/* INS_0x98 */ Ins_UNKNOWN,
/* INS_0x99 */ Ins_UNKNOWN,
/* INS_0x9A */ Ins_UNKNOWN,
/* INS_0x9B */ Ins_UNKNOWN,
/* INS_0x9C */ Ins_UNKNOWN,
/* INS_0x9D */ Ins_UNKNOWN,
/* INS_0x9E */ Ins_UNKNOWN,
/* INS_0x9F */ Ins_UNKNOWN,
/* INS_0xA0 */ Ins_UNKNOWN,
/* INS_0xA1 */ Ins_UNKNOWN,
/* INS_0xA2 */ Ins_UNKNOWN,
/* INS_0xA3 */ Ins_UNKNOWN,
/* INS_0xA4 */ Ins_UNKNOWN,
/* INS_0xA5 */ Ins_UNKNOWN,
/* INS_0xA6 */ Ins_UNKNOWN,
/* INS_0xA7 */ Ins_UNKNOWN,
/* INS_0xA8 */ Ins_UNKNOWN,
/* INS_0xA9 */ Ins_UNKNOWN,
/* INS_0xAA */ Ins_UNKNOWN,
/* INS_0xAB */ Ins_UNKNOWN,
/* INS_0xAC */ Ins_UNKNOWN,
/* INS_0xAD */ Ins_UNKNOWN,
/* INS_0xAE */ Ins_UNKNOWN,
/* INS_0xAF */ Ins_UNKNOWN,
/* PushB[0] */ Ins_PUSHB,
/* PushB[1] */ Ins_PUSHB,
/* PushB[2] */ Ins_PUSHB,
/* PushB[3] */ Ins_PUSHB,
/* PushB[4] */ Ins_PUSHB,
/* PushB[5] */ Ins_PUSHB,
/* PushB[6] */ Ins_PUSHB,
/* PushB[7] */ Ins_PUSHB,
/* PushW[0] */ Ins_PUSHW,
/* PushW[1] */ Ins_PUSHW,
/* PushW[2] */ Ins_PUSHW,
/* PushW[3] */ Ins_PUSHW,
/* PushW[4] */ Ins_PUSHW,
/* PushW[5] */ Ins_PUSHW,
/* PushW[6] */ Ins_PUSHW,
/* PushW[7] */ Ins_PUSHW,
/* MDRP[00] */ Ins_MDRP,
/* MDRP[01] */ Ins_MDRP,
/* MDRP[02] */ Ins_MDRP,
/* MDRP[03] */ Ins_MDRP,
/* MDRP[04] */ Ins_MDRP,
/* MDRP[05] */ Ins_MDRP,
/* MDRP[06] */ Ins_MDRP,
/* MDRP[07] */ Ins_MDRP,
/* MDRP[08] */ Ins_MDRP,
/* MDRP[09] */ Ins_MDRP,
/* MDRP[10] */ Ins_MDRP,
/* MDRP[11] */ Ins_MDRP,
/* MDRP[12] */ Ins_MDRP,
/* MDRP[13] */ Ins_MDRP,
/* MDRP[14] */ Ins_MDRP,
/* MDRP[15] */ Ins_MDRP,
/* MDRP[16] */ Ins_MDRP,
/* MDRP[17] */ Ins_MDRP,
/* MDRP[18] */ Ins_MDRP,
/* MDRP[19] */ Ins_MDRP,
/* MDRP[20] */ Ins_MDRP,
/* MDRP[21] */ Ins_MDRP,
/* MDRP[22] */ Ins_MDRP,
/* MDRP[23] */ Ins_MDRP,
/* MDRP[24] */ Ins_MDRP,
/* MDRP[25] */ Ins_MDRP,
/* MDRP[26] */ Ins_MDRP,
/* MDRP[27] */ Ins_MDRP,
/* MDRP[28] */ Ins_MDRP,
/* MDRP[29] */ Ins_MDRP,
/* MDRP[30] */ Ins_MDRP,
/* MDRP[31] */ Ins_MDRP,
/* MIRP[00] */ Ins_MIRP,
/* MIRP[01] */ Ins_MIRP,
/* MIRP[02] */ Ins_MIRP,
/* MIRP[03] */ Ins_MIRP,
/* MIRP[04] */ Ins_MIRP,
/* MIRP[05] */ Ins_MIRP,
/* MIRP[06] */ Ins_MIRP,
/* MIRP[07] */ Ins_MIRP,
/* MIRP[08] */ Ins_MIRP,
/* MIRP[09] */ Ins_MIRP,
/* MIRP[10] */ Ins_MIRP,
/* MIRP[11] */ Ins_MIRP,
/* MIRP[12] */ Ins_MIRP,
/* MIRP[13] */ Ins_MIRP,
/* MIRP[14] */ Ins_MIRP,
/* MIRP[15] */ Ins_MIRP,
/* MIRP[16] */ Ins_MIRP,
/* MIRP[17] */ Ins_MIRP,
/* MIRP[18] */ Ins_MIRP,
/* MIRP[19] */ Ins_MIRP,
/* MIRP[20] */ Ins_MIRP,
/* MIRP[21] */ Ins_MIRP,
/* MIRP[22] */ Ins_MIRP,
/* MIRP[23] */ Ins_MIRP,
/* MIRP[24] */ Ins_MIRP,
/* MIRP[25] */ Ins_MIRP,
/* MIRP[26] */ Ins_MIRP,
/* MIRP[27] */ Ins_MIRP,
/* MIRP[28] */ Ins_MIRP,
/* MIRP[29] */ Ins_MIRP,
/* MIRP[30] */ Ins_MIRP,
/* MIRP[31] */ Ins_MIRP
};
#endif /* !TT_CONFIG_OPTION_INTERPRETER_SWITCH */
/*************************************************************************/
/* */
/* RUN */
/* */
/* This function executes a run of opcodes. It will exit in the */
/* following cases: */
/* */
/* - Errors (in which case it returns FALSE). */
/* */
/* - Reaching the end of the main code range (returns TRUE). */
/* Reaching the end of a code range within a function call is an */
/* error. */
/* */
/* - After executing one single opcode, if the flag `Instruction_Trap' */
/* is set to TRUE (returns TRUE). */
/* */
/* On exit with TRUE, test IP < CodeSize to know whether it comes from */
/* an instruction trap or a normal termination. */
/* */
/* */
/* Note: The documented DEBUG opcode pops a value from the stack. This */
/* behaviour is unsupported; here a DEBUG opcode is always an */
/* error. */
/* */
/* */
/* THIS IS THE INTERPRETER'S MAIN LOOP. */
/* */
/* Instructions appear in the specification's order. */
/* */
/*************************************************************************/
/* documentation is in ttinterp.h */
FT_EXPORT_DEF( FT_Error )
TT_RunIns( TT_ExecContext exc )
{
FT_Long ins_counter = 0; /* executed instructions counter */
FT_UShort i;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
FT_Byte opcode_pattern[1][2] = {
/* #8 TypeMan Talk Align */
{
0x06, /* SPVTL */
0x7D, /* RDTG */
},
};
FT_UShort opcode_patterns = 1;
FT_UShort opcode_pointer[1] = { 0 };
FT_UShort opcode_size[1] = { 1 };
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_STATIC_RASTER
cur = *exc;
#endif
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
CUR.iup_called = FALSE;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* set CVT functions */
CUR.tt_metrics.ratio = 0;
if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem )
{
/* non-square pixels, use the stretched routines */
CUR.func_read_cvt = Read_CVT_Stretched;
CUR.func_write_cvt = Write_CVT_Stretched;
CUR.func_move_cvt = Move_CVT_Stretched;
}
else
{
/* square pixels, use normal routines */
CUR.func_read_cvt = Read_CVT;
CUR.func_write_cvt = Write_CVT;
CUR.func_move_cvt = Move_CVT;
}
COMPUTE_Funcs();
COMPUTE_Round( (FT_Byte)exc->GS.round_state );
do
{
CUR.opcode = CUR.code[CUR.IP];
FT_TRACE7(( " " ));
FT_TRACE7(( opcode_name[CUR.opcode] ));
FT_TRACE7(( "\n" ));
if ( ( CUR.length = opcode_length[CUR.opcode] ) < 0 )
{
if ( CUR.IP + 1 >= CUR.codeSize )
goto LErrorCodeOverflow_;
CUR.length = 2 - CUR.length * CUR.code[CUR.IP + 1];
}
if ( CUR.IP + CUR.length > CUR.codeSize )
goto LErrorCodeOverflow_;
/* First, let's check for empty stack and overflow */
CUR.args = CUR.top - ( Pop_Push_Count[CUR.opcode] >> 4 );
/* `args' is the top of the stack once arguments have been popped. */
/* One can also interpret it as the index of the last argument. */
if ( CUR.args < 0 )
{
if ( CUR.pedantic_hinting )
{
CUR.error = FT_THROW( Too_Few_Arguments );
goto LErrorLabel_;
}
/* push zeroes onto the stack */
for ( i = 0; i < Pop_Push_Count[CUR.opcode] >> 4; i++ )
CUR.stack[i] = 0;
CUR.args = 0;
}
CUR.new_top = CUR.args + ( Pop_Push_Count[CUR.opcode] & 15 );
/* `new_top' is the new top of the stack, after the instruction's */
/* execution. `top' will be set to `new_top' after the `switch' */
/* statement. */
if ( CUR.new_top > CUR.stackSize )
{
CUR.error = FT_THROW( Stack_Overflow );
goto LErrorLabel_;
}
CUR.step_ins = TRUE;
CUR.error = FT_Err_Ok;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
if ( SUBPIXEL_HINTING )
{
for ( i = 0; i < opcode_patterns; i++ )
{
if ( opcode_pointer[i] < opcode_size[i] &&
CUR.opcode == opcode_pattern[i][opcode_pointer[i]] )
{
opcode_pointer[i] += 1;
if ( opcode_pointer[i] == opcode_size[i] )
{
FT_TRACE7(( "sph: opcode ptrn: %d, %s %s\n",
i,
CUR.face->root.family_name,
CUR.face->root.style_name ));
switch ( i )
{
case 0:
break;
}
opcode_pointer[i] = 0;
}
}
else
opcode_pointer[i] = 0;
}
}
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
#ifdef TT_CONFIG_OPTION_INTERPRETER_SWITCH
{
FT_Long* args = CUR.stack + CUR.args;
FT_Byte opcode = CUR.opcode;
#undef ARRAY_BOUND_ERROR
#define ARRAY_BOUND_ERROR goto Set_Invalid_Ref
switch ( opcode )
{
case 0x00: /* SVTCA y */
case 0x01: /* SVTCA x */
case 0x02: /* SPvTCA y */
case 0x03: /* SPvTCA x */
case 0x04: /* SFvTCA y */
case 0x05: /* SFvTCA x */
{
FT_Short AA, BB;
AA = (FT_Short)( ( opcode & 1 ) << 14 );
BB = (FT_Short)( AA ^ 0x4000 );
if ( opcode < 4 )
{
CUR.GS.projVector.x = AA;
CUR.GS.projVector.y = BB;
CUR.GS.dualVector.x = AA;
CUR.GS.dualVector.y = BB;
}
else
{
GUESS_VECTOR( projVector );
}
if ( ( opcode & 2 ) == 0 )
{
CUR.GS.freeVector.x = AA;
CUR.GS.freeVector.y = BB;
}
else
{
GUESS_VECTOR( freeVector );
}
COMPUTE_Funcs();
}
break;
case 0x06: /* SPvTL // */
case 0x07: /* SPvTL + */
DO_SPVTL
break;
case 0x08: /* SFvTL // */
case 0x09: /* SFvTL + */
DO_SFVTL
break;
case 0x0A: /* SPvFS */
DO_SPVFS
break;
case 0x0B: /* SFvFS */
DO_SFVFS
break;
case 0x0C: /* GPV */
DO_GPV
break;
case 0x0D: /* GFV */
DO_GFV
break;
case 0x0E: /* SFvTPv */
DO_SFVTPV
break;
case 0x0F: /* ISECT */
Ins_ISECT( EXEC_ARG_ args );
break;
case 0x10: /* SRP0 */
DO_SRP0
break;
case 0x11: /* SRP1 */
DO_SRP1
break;
case 0x12: /* SRP2 */
DO_SRP2
break;
case 0x13: /* SZP0 */
Ins_SZP0( EXEC_ARG_ args );
break;
case 0x14: /* SZP1 */
Ins_SZP1( EXEC_ARG_ args );
break;
case 0x15: /* SZP2 */
Ins_SZP2( EXEC_ARG_ args );
break;
case 0x16: /* SZPS */
Ins_SZPS( EXEC_ARG_ args );
break;
case 0x17: /* SLOOP */
DO_SLOOP
break;
case 0x18: /* RTG */
DO_RTG
break;
case 0x19: /* RTHG */
DO_RTHG
break;
case 0x1A: /* SMD */
DO_SMD
break;
case 0x1B: /* ELSE */
Ins_ELSE( EXEC_ARG_ args );
break;
case 0x1C: /* JMPR */
DO_JMPR
break;
case 0x1D: /* SCVTCI */
DO_SCVTCI
break;
case 0x1E: /* SSWCI */
DO_SSWCI
break;
case 0x1F: /* SSW */
DO_SSW
break;
case 0x20: /* DUP */
DO_DUP
break;
case 0x21: /* POP */
/* nothing :-) */
break;
case 0x22: /* CLEAR */
DO_CLEAR
break;
case 0x23: /* SWAP */
DO_SWAP
break;
case 0x24: /* DEPTH */
DO_DEPTH
break;
case 0x25: /* CINDEX */
DO_CINDEX
break;
case 0x26: /* MINDEX */
Ins_MINDEX( EXEC_ARG_ args );
break;
case 0x27: /* ALIGNPTS */
Ins_ALIGNPTS( EXEC_ARG_ args );
break;
case 0x28: /* ???? */
Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x29: /* UTP */
Ins_UTP( EXEC_ARG_ args );
break;
case 0x2A: /* LOOPCALL */
Ins_LOOPCALL( EXEC_ARG_ args );
break;
case 0x2B: /* CALL */
Ins_CALL( EXEC_ARG_ args );
break;
case 0x2C: /* FDEF */
Ins_FDEF( EXEC_ARG_ args );
break;
case 0x2D: /* ENDF */
Ins_ENDF( EXEC_ARG_ args );
break;
case 0x2E: /* MDAP */
case 0x2F: /* MDAP */
Ins_MDAP( EXEC_ARG_ args );
break;
case 0x30: /* IUP */
case 0x31: /* IUP */
Ins_IUP( EXEC_ARG_ args );
break;
case 0x32: /* SHP */
case 0x33: /* SHP */
Ins_SHP( EXEC_ARG_ args );
break;
case 0x34: /* SHC */
case 0x35: /* SHC */
Ins_SHC( EXEC_ARG_ args );
break;
case 0x36: /* SHZ */
case 0x37: /* SHZ */
Ins_SHZ( EXEC_ARG_ args );
break;
case 0x38: /* SHPIX */
Ins_SHPIX( EXEC_ARG_ args );
break;
case 0x39: /* IP */
Ins_IP( EXEC_ARG_ args );
break;
case 0x3A: /* MSIRP */
case 0x3B: /* MSIRP */
Ins_MSIRP( EXEC_ARG_ args );
break;
case 0x3C: /* AlignRP */
Ins_ALIGNRP( EXEC_ARG_ args );
break;
case 0x3D: /* RTDG */
DO_RTDG
break;
case 0x3E: /* MIAP */
case 0x3F: /* MIAP */
Ins_MIAP( EXEC_ARG_ args );
break;
case 0x40: /* NPUSHB */
Ins_NPUSHB( EXEC_ARG_ args );
break;
case 0x41: /* NPUSHW */
Ins_NPUSHW( EXEC_ARG_ args );
break;
case 0x42: /* WS */
DO_WS
break;
Set_Invalid_Ref:
CUR.error = FT_THROW( Invalid_Reference );
break;
case 0x43: /* RS */
DO_RS
break;
case 0x44: /* WCVTP */
DO_WCVTP
break;
case 0x45: /* RCVT */
DO_RCVT
break;
case 0x46: /* GC */
case 0x47: /* GC */
Ins_GC( EXEC_ARG_ args );
break;
case 0x48: /* SCFS */
Ins_SCFS( EXEC_ARG_ args );
break;
case 0x49: /* MD */
case 0x4A: /* MD */
Ins_MD( EXEC_ARG_ args );
break;
case 0x4B: /* MPPEM */
DO_MPPEM
break;
case 0x4C: /* MPS */
DO_MPS
break;
case 0x4D: /* FLIPON */
DO_FLIPON
break;
case 0x4E: /* FLIPOFF */
DO_FLIPOFF
break;
case 0x4F: /* DEBUG */
DO_DEBUG
break;
case 0x50: /* LT */
DO_LT
break;
case 0x51: /* LTEQ */
DO_LTEQ
break;
case 0x52: /* GT */
DO_GT
break;
case 0x53: /* GTEQ */
DO_GTEQ
break;
case 0x54: /* EQ */
DO_EQ
break;
case 0x55: /* NEQ */
DO_NEQ
break;
case 0x56: /* ODD */
DO_ODD
break;
case 0x57: /* EVEN */
DO_EVEN
break;
case 0x58: /* IF */
Ins_IF( EXEC_ARG_ args );
break;
case 0x59: /* EIF */
/* do nothing */
break;
case 0x5A: /* AND */
DO_AND
break;
case 0x5B: /* OR */
DO_OR
break;
case 0x5C: /* NOT */
DO_NOT
break;
case 0x5D: /* DELTAP1 */
Ins_DELTAP( EXEC_ARG_ args );
break;
case 0x5E: /* SDB */
DO_SDB
break;
case 0x5F: /* SDS */
DO_SDS
break;
case 0x60: /* ADD */
DO_ADD
break;
case 0x61: /* SUB */
DO_SUB
break;
case 0x62: /* DIV */
DO_DIV
break;
case 0x63: /* MUL */
DO_MUL
break;
case 0x64: /* ABS */
DO_ABS
break;
case 0x65: /* NEG */
DO_NEG
break;
case 0x66: /* FLOOR */
DO_FLOOR
break;
case 0x67: /* CEILING */
DO_CEILING
break;
case 0x68: /* ROUND */
case 0x69: /* ROUND */
case 0x6A: /* ROUND */
case 0x6B: /* ROUND */
DO_ROUND
break;
case 0x6C: /* NROUND */
case 0x6D: /* NROUND */
case 0x6E: /* NRRUND */
case 0x6F: /* NROUND */
DO_NROUND
break;
case 0x70: /* WCVTF */
DO_WCVTF
break;
case 0x71: /* DELTAP2 */
case 0x72: /* DELTAP3 */
Ins_DELTAP( EXEC_ARG_ args );
break;
case 0x73: /* DELTAC0 */
case 0x74: /* DELTAC1 */
case 0x75: /* DELTAC2 */
Ins_DELTAC( EXEC_ARG_ args );
break;
case 0x76: /* SROUND */
DO_SROUND
break;
case 0x77: /* S45Round */
DO_S45ROUND
break;
case 0x78: /* JROT */
DO_JROT
break;
case 0x79: /* JROF */
DO_JROF
break;
case 0x7A: /* ROFF */
DO_ROFF
break;
case 0x7B: /* ???? */
Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x7C: /* RUTG */
DO_RUTG
break;
case 0x7D: /* RDTG */
DO_RDTG
break;
case 0x7E: /* SANGW */
case 0x7F: /* AA */
/* nothing - obsolete */
break;
case 0x80: /* FLIPPT */
Ins_FLIPPT( EXEC_ARG_ args );
break;
case 0x81: /* FLIPRGON */
Ins_FLIPRGON( EXEC_ARG_ args );
break;
case 0x82: /* FLIPRGOFF */
Ins_FLIPRGOFF( EXEC_ARG_ args );
break;
case 0x83: /* UNKNOWN */
case 0x84: /* UNKNOWN */
Ins_UNKNOWN( EXEC_ARG_ args );
break;
case 0x85: /* SCANCTRL */
Ins_SCANCTRL( EXEC_ARG_ args );
break;
case 0x86: /* SDPVTL */
case 0x87: /* SDPVTL */
Ins_SDPVTL( EXEC_ARG_ args );
break;
case 0x88: /* GETINFO */
Ins_GETINFO( EXEC_ARG_ args );
break;
case 0x89: /* IDEF */
Ins_IDEF( EXEC_ARG_ args );
break;
case 0x8A: /* ROLL */
Ins_ROLL( EXEC_ARG_ args );
break;
case 0x8B: /* MAX */
DO_MAX
break;
case 0x8C: /* MIN */
DO_MIN
break;
case 0x8D: /* SCANTYPE */
Ins_SCANTYPE( EXEC_ARG_ args );
break;
case 0x8E: /* INSTCTRL */
Ins_INSTCTRL( EXEC_ARG_ args );
break;
case 0x8F:
Ins_UNKNOWN( EXEC_ARG_ args );
break;
default:
if ( opcode >= 0xE0 )
Ins_MIRP( EXEC_ARG_ args );
else if ( opcode >= 0xC0 )
Ins_MDRP( EXEC_ARG_ args );
else if ( opcode >= 0xB8 )
Ins_PUSHW( EXEC_ARG_ args );
else if ( opcode >= 0xB0 )
Ins_PUSHB( EXEC_ARG_ args );
else
Ins_UNKNOWN( EXEC_ARG_ args );
}
}
#else
Instruct_Dispatch[CUR.opcode]( EXEC_ARG_ &CUR.stack[CUR.args] );
#endif /* TT_CONFIG_OPTION_INTERPRETER_SWITCH */
if ( CUR.error )
{
switch ( CUR.error )
{
/* looking for redefined instructions */
case FT_ERR( Invalid_Opcode ):
{
TT_DefRecord* def = CUR.IDefs;
TT_DefRecord* limit = def + CUR.numIDefs;
for ( ; def < limit; def++ )
{
if ( def->active && CUR.opcode == (FT_Byte)def->opc )
{
TT_CallRec* callrec;
if ( CUR.callTop >= CUR.callSize )
{
CUR.error = FT_THROW( Invalid_Reference );
goto LErrorLabel_;
}
callrec = &CUR.callStack[CUR.callTop];
callrec->Caller_Range = CUR.curRange;
callrec->Caller_IP = CUR.IP + 1;
callrec->Cur_Count = 1;
callrec->Def = def;
if ( INS_Goto_CodeRange( def->range, def->start ) == FAILURE )
goto LErrorLabel_;
goto LSuiteLabel_;
}
}
}
CUR.error = FT_THROW( Invalid_Opcode );
goto LErrorLabel_;
#if 0
break; /* Unreachable code warning suppression. */
/* Leave to remind in case a later change the editor */
/* to consider break; */
#endif
default:
goto LErrorLabel_;
#if 0
break;
#endif
}
}
CUR.top = CUR.new_top;
if ( CUR.step_ins )
CUR.IP += CUR.length;
/* increment instruction counter and check if we didn't */
/* run this program for too long (e.g. infinite loops). */
if ( ++ins_counter > MAX_RUNNABLE_OPCODES )
return FT_THROW( Execution_Too_Long );
LSuiteLabel_:
if ( CUR.IP >= CUR.codeSize )
{
if ( CUR.callTop > 0 )
{
CUR.error = FT_THROW( Code_Overflow );
goto LErrorLabel_;
}
else
goto LNo_Error_;
}
} while ( !CUR.instruction_trap );
LNo_Error_:
#ifdef TT_CONFIG_OPTION_STATIC_RASTER
*exc = cur;
#endif
return FT_Err_Ok;
LErrorCodeOverflow_:
CUR.error = FT_THROW( Code_Overflow );
LErrorLabel_:
#ifdef TT_CONFIG_OPTION_STATIC_RASTER
*exc = cur;
#endif
/* If any errors have occurred, function tables may be broken. */
/* Force a re-execution of `prep' and `fpgm' tables if no */
/* bytecode debugger is run. */
if ( CUR.error && !CUR.instruction_trap )
{
FT_TRACE1(( " The interpreter returned error 0x%x\n", CUR.error ));
exc->size->cvt_ready = FALSE;
}
return CUR.error;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttinterp.c | C | apache-2.0 | 300,897 |
/***************************************************************************/
/* */
/* ttinterp.h */
/* */
/* TrueType bytecode interpreter (specification). */
/* */
/* Copyright 1996-2007, 2010, 2012-2013 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 __TTINTERP_H__
#define __TTINTERP_H__
#include <ft2build.h>
#include "ttobjs.h"
FT_BEGIN_HEADER
#ifndef TT_CONFIG_OPTION_STATIC_INTERPRETER /* indirect implementation */
#define EXEC_OP_ TT_ExecContext exc,
#define EXEC_OP TT_ExecContext exc
#define EXEC_ARG_ exc,
#define EXEC_ARG exc
#else /* static implementation */
#define EXEC_OP_ /* void */
#define EXEC_OP /* void */
#define EXEC_ARG_ /* void */
#define EXEC_ARG /* void */
#endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */
/*************************************************************************/
/* */
/* Rounding mode constants. */
/* */
#define TT_Round_Off 5
#define TT_Round_To_Half_Grid 0
#define TT_Round_To_Grid 1
#define TT_Round_To_Double_Grid 2
#define TT_Round_Up_To_Grid 4
#define TT_Round_Down_To_Grid 3
#define TT_Round_Super 6
#define TT_Round_Super_45 7
/*************************************************************************/
/* */
/* Function types used by the interpreter, depending on various modes */
/* (e.g. the rounding mode, whether to render a vertical or horizontal */
/* line etc). */
/* */
/*************************************************************************/
/* Rounding function */
typedef FT_F26Dot6
(*TT_Round_Func)( EXEC_OP_ FT_F26Dot6 distance,
FT_F26Dot6 compensation );
/* Point displacement along the freedom vector routine */
typedef void
(*TT_Move_Func)( EXEC_OP_ TT_GlyphZone zone,
FT_UShort point,
FT_F26Dot6 distance );
/* Distance projection along one of the projection vectors */
typedef FT_F26Dot6
(*TT_Project_Func)( EXEC_OP_ FT_Pos dx,
FT_Pos dy );
/* reading a cvt value. Take care of non-square pixels if necessary */
typedef FT_F26Dot6
(*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong idx );
/* setting or moving a cvt value. Take care of non-square pixels */
/* if necessary */
typedef void
(*TT_Set_CVT_Func)( EXEC_OP_ FT_ULong idx,
FT_F26Dot6 value );
/*************************************************************************/
/* */
/* This structure defines a call record, used to manage function calls. */
/* */
typedef struct TT_CallRec_
{
FT_Int Caller_Range;
FT_Long Caller_IP;
FT_Long Cur_Count;
TT_DefRecord *Def; /* either FDEF or IDEF */
} TT_CallRec, *TT_CallStack;
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/*************************************************************************/
/* */
/* These structures define rules used to tweak subpixel hinting for */
/* various fonts. "", 0, "", NULL value indicates to match any value. */
/* */
#define SPH_MAX_NAME_SIZE 32
#define SPH_MAX_CLASS_MEMBERS 100
typedef struct SPH_TweakRule_
{
const char family[SPH_MAX_NAME_SIZE];
const FT_UInt ppem;
const char style[SPH_MAX_NAME_SIZE];
const FT_ULong glyph;
} SPH_TweakRule;
typedef struct SPH_ScaleRule_
{
const char family[SPH_MAX_NAME_SIZE];
const FT_UInt ppem;
const char style[SPH_MAX_NAME_SIZE];
const FT_ULong glyph;
const FT_ULong scale;
} SPH_ScaleRule;
typedef struct SPH_Font_Class_
{
const char name[SPH_MAX_NAME_SIZE];
const char member[SPH_MAX_CLASS_MEMBERS][SPH_MAX_NAME_SIZE];
} SPH_Font_Class;
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/*************************************************************************/
/* */
/* The main structure for the interpreter which collects all necessary */
/* variables and states. */
/* */
typedef struct TT_ExecContextRec_
{
TT_Face face;
TT_Size size;
FT_Memory memory;
/* instructions state */
FT_Error error; /* last execution error */
FT_Long top; /* top of exec. stack */
FT_UInt stackSize; /* size of exec. stack */
FT_Long* stack; /* current exec. stack */
FT_Long args;
FT_UInt new_top; /* new top after exec. */
TT_GlyphZoneRec zp0, /* zone records */
zp1,
zp2,
pts,
twilight;
FT_Size_Metrics metrics;
TT_Size_Metrics tt_metrics; /* size metrics */
TT_GraphicsState GS; /* current graphics state */
FT_Int curRange; /* current code range number */
FT_Byte* code; /* current code range */
FT_Long IP; /* current instruction pointer */
FT_Long codeSize; /* size of current range */
FT_Byte opcode; /* current opcode */
FT_Int length; /* length of current opcode */
FT_Bool step_ins; /* true if the interpreter must */
/* increment IP after ins. exec */
FT_ULong cvtSize;
FT_Long* cvt;
FT_UInt glyphSize; /* glyph instructions buffer size */
FT_Byte* glyphIns; /* glyph instructions buffer */
FT_UInt numFDefs; /* number of function defs */
FT_UInt maxFDefs; /* maximum number of function defs */
TT_DefArray FDefs; /* table of FDefs entries */
FT_UInt numIDefs; /* number of instruction defs */
FT_UInt maxIDefs; /* maximum number of ins defs */
TT_DefArray IDefs; /* table of IDefs entries */
FT_UInt maxFunc; /* maximum function index */
FT_UInt maxIns; /* maximum instruction index */
FT_Int callTop, /* top of call stack during execution */
callSize; /* size of call stack */
TT_CallStack callStack; /* call stack */
FT_UShort maxPoints; /* capacity of this context's `pts' */
FT_Short maxContours; /* record, expressed in points and */
/* contours. */
TT_CodeRangeTable codeRangeTable; /* table of valid code ranges */
/* useful for the debugger */
FT_UShort storeSize; /* size of current storage */
FT_Long* storage; /* storage area */
FT_F26Dot6 period; /* values used for the */
FT_F26Dot6 phase; /* `SuperRounding' */
FT_F26Dot6 threshold;
#if 0
/* this seems to be unused */
FT_Int cur_ppem; /* ppem along the current proj vector */
#endif
FT_Bool instruction_trap; /* If `True', the interpreter will */
/* exit after each instruction */
TT_GraphicsState default_GS; /* graphics state resulting from */
/* the prep program */
FT_Bool is_composite; /* true if the glyph is composite */
FT_Bool pedantic_hinting; /* true if pedantic interpretation */
/* latest interpreter additions */
FT_Long F_dot_P; /* dot product of freedom and projection */
/* vectors */
TT_Round_Func func_round; /* current rounding function */
TT_Project_Func func_project, /* current projection function */
func_dualproj, /* current dual proj. function */
func_freeProj; /* current freedom proj. func */
TT_Move_Func func_move; /* current point move function */
TT_Move_Func func_move_orig; /* move original position function */
TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */
TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */
TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */
FT_Bool grayscale; /* are we hinting for grayscale? */
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
TT_Round_Func func_round_sphn; /* subpixel rounding function */
FT_Bool subpixel; /* Using subpixel hinting? */
FT_Bool ignore_x_mode; /* Standard rendering mode for */
/* subpixel hinting. On if gray */
/* or subpixel hinting is on. */
/* The following 4 aren't fully implemented but here for MS rasterizer */
/* compatibility. */
FT_Bool compatible_widths; /* compatible widths? */
FT_Bool symmetrical_smoothing; /* symmetrical_smoothing? */
FT_Bool bgr; /* bgr instead of rgb? */
FT_Bool subpixel_positioned; /* subpixel positioned */
/* (DirectWrite ClearType)? */
FT_Int rasterizer_version; /* MS rasterizer version */
FT_Bool iup_called; /* IUP called for glyph? */
FT_ULong sph_tweak_flags; /* flags to control */
/* hint tweaks */
FT_ULong sph_in_func_flags; /* flags to indicate if in */
/* special functions */
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
} TT_ExecContextRec;
extern const TT_GraphicsState tt_default_graphics_state;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( FT_Error )
TT_Goto_CodeRange( TT_ExecContext exec,
FT_Int range,
FT_Long IP );
FT_LOCAL( FT_Error )
TT_Set_CodeRange( TT_ExecContext exec,
FT_Int range,
void* base,
FT_Long length );
FT_LOCAL( FT_Error )
TT_Clear_CodeRange( TT_ExecContext exec,
FT_Int range );
FT_LOCAL( FT_Error )
Update_Max( FT_Memory memory,
FT_ULong* size,
FT_Long multiplier,
void* _pbuff,
FT_ULong new_max );
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/
/* */
/* <Function> */
/* TT_New_Context */
/* */
/* <Description> */
/* Queries the face context for a given font. Note that there is */
/* now a _single_ execution context in the TrueType driver which is */
/* shared among faces. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* <Return> */
/* A handle to the execution context. Initialized for `face'. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
/* */
FT_EXPORT( TT_ExecContext )
TT_New_Context( TT_Driver driver );
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( FT_Error )
TT_Done_Context( TT_ExecContext exec );
FT_LOCAL( FT_Error )
TT_Load_Context( TT_ExecContext exec,
TT_Face face,
TT_Size size );
FT_LOCAL( FT_Error )
TT_Save_Context( TT_ExecContext exec,
TT_Size ins );
FT_LOCAL( FT_Error )
TT_Run_Context( TT_ExecContext exec,
FT_Bool debug );
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/
/* */
/* <Function> */
/* TT_RunIns */
/* */
/* <Description> */
/* Executes one or more instruction in the execution context. This */
/* is the main function of the TrueType opcode interpreter. */
/* */
/* <Input> */
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the object manager and debugger should call this function. */
/* */
/* This function is publicly exported because it is directly */
/* invoked by the TrueType debugger. */
/* */
FT_EXPORT( FT_Error )
TT_RunIns( TT_ExecContext exec );
FT_END_HEADER
#endif /* __TTINTERP_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttinterp.h | C | apache-2.0 | 16,633 |
/***************************************************************************/
/* */
/* ttobjs.c */
/* */
/* Objects manager (body). */
/* */
/* Copyright 1996-2013 */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_DRIVER_H
#include "ttgload.h"
#include "ttpload.h"
#include "tterrors.h"
#ifdef TT_USE_BYTECODE_INTERPRETER
#include "ttinterp.h"
#endif
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
#include FT_TRUETYPE_UNPATENTED_H
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
/*************************************************************************/
/* */
/* 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_ttobjs
#ifdef TT_USE_BYTECODE_INTERPRETER
/*************************************************************************/
/* */
/* GLYPH ZONE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* tt_glyphzone_done */
/* */
/* <Description> */
/* Deallocate a glyph zone. */
/* */
/* <Input> */
/* zone :: A pointer to the target glyph zone. */
/* */
FT_LOCAL_DEF( void )
tt_glyphzone_done( TT_GlyphZone zone )
{
FT_Memory memory = zone->memory;
if ( memory )
{
FT_FREE( zone->contours );
FT_FREE( zone->tags );
FT_FREE( zone->cur );
FT_FREE( zone->org );
FT_FREE( zone->orus );
zone->max_points = zone->n_points = 0;
zone->max_contours = zone->n_contours = 0;
zone->memory = NULL;
}
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_glyphzone_new */
/* */
/* <Description> */
/* Allocate a new glyph zone. */
/* */
/* <Input> */
/* memory :: A handle to the current memory object. */
/* */
/* maxPoints :: The capacity of glyph zone in points. */
/* */
/* maxContours :: The capacity of glyph zone in contours. */
/* */
/* <Output> */
/* zone :: A pointer to the target glyph zone record. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_glyphzone_new( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
TT_GlyphZone zone )
{
FT_Error error;
FT_MEM_ZERO( zone, sizeof ( *zone ) );
zone->memory = memory;
if ( FT_NEW_ARRAY( zone->org, maxPoints ) ||
FT_NEW_ARRAY( zone->cur, maxPoints ) ||
FT_NEW_ARRAY( zone->orus, maxPoints ) ||
FT_NEW_ARRAY( zone->tags, maxPoints ) ||
FT_NEW_ARRAY( zone->contours, maxContours ) )
{
tt_glyphzone_done( zone );
}
else
{
zone->max_points = maxPoints;
zone->max_contours = maxContours;
}
return error;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
/* Compare the face with a list of well-known `tricky' fonts. */
/* This list shall be expanded as we find more of them. */
static FT_Bool
tt_check_trickyness_family( FT_String* name )
{
#define TRICK_NAMES_MAX_CHARACTERS 19
#define TRICK_NAMES_COUNT 9
static const char trick_names[TRICK_NAMES_COUNT]
[TRICK_NAMES_MAX_CHARACTERS + 1] =
{
"DFKaiSho-SB", /* dfkaisb.ttf */
"DFKaiShu",
"DFKai-SB", /* kaiu.ttf */
"HuaTianKaiTi?", /* htkt2.ttf */
"HuaTianSongTi?", /* htst3.ttf */
"Ming(for ISO10646)", /* hkscsiic.ttf & iicore.ttf */
"MingLiU", /* mingliu.ttf & mingliu.ttc */
"PMingLiU", /* mingliu.ttc */
"MingLi43", /* mingli.ttf */
};
int nn;
for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ )
if ( ft_strstr( name, trick_names[nn] ) )
return TRUE;
return FALSE;
}
/* XXX: This function should be in the `sfnt' module. */
/* Some PDF generators clear the checksums in the TrueType header table. */
/* For example, Quartz ContextPDF clears all entries, or Bullzip PDF */
/* Printer clears the entries for subsetted subtables. We thus have to */
/* recalculate the checksums where necessary. */
static FT_UInt32
tt_synth_sfnt_checksum( FT_Stream stream,
FT_ULong length )
{
FT_Error error;
FT_UInt32 checksum = 0;
int i;
if ( FT_FRAME_ENTER( length ) )
return 0;
for ( ; length > 3; length -= 4 )
checksum += (FT_UInt32)FT_GET_ULONG();
for ( i = 3; length > 0; length --, i-- )
checksum += (FT_UInt32)( FT_GET_BYTE() << ( i * 8 ) );
FT_FRAME_EXIT();
return checksum;
}
/* XXX: This function should be in the `sfnt' module. */
static FT_ULong
tt_get_sfnt_checksum( TT_Face face,
FT_UShort i )
{
#if 0 /* if we believe the written value, use following part. */
if ( face->dir_tables[i].CheckSum )
return face->dir_tables[i].CheckSum;
#endif
if ( !face->goto_table )
return 0;
if ( face->goto_table( face,
face->dir_tables[i].Tag,
face->root.stream,
NULL ) )
return 0;
return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream,
face->dir_tables[i].Length );
}
typedef struct tt_sfnt_id_rec_
{
FT_ULong CheckSum;
FT_ULong Length;
} tt_sfnt_id_rec;
static FT_Bool
tt_check_trickyness_sfnt_ids( TT_Face face )
{
#define TRICK_SFNT_IDS_PER_FACE 3
#define TRICK_SFNT_IDS_NUM_FACES 17
static const tt_sfnt_id_rec sfnt_id[TRICK_SFNT_IDS_NUM_FACES]
[TRICK_SFNT_IDS_PER_FACE] = {
#define TRICK_SFNT_ID_cvt 0
#define TRICK_SFNT_ID_fpgm 1
#define TRICK_SFNT_ID_prep 2
{ /* MingLiU 1995 */
{ 0x05bcf058, 0x000002e4 }, /* cvt */
{ 0x28233bf1, 0x000087c4 }, /* fpgm */
{ 0xa344a1ea, 0x000001e1 } /* prep */
},
{ /* MingLiU 1996- */
{ 0x05bcf058, 0x000002e4 }, /* cvt */
{ 0x28233bf1, 0x000087c4 }, /* fpgm */
{ 0xa344a1eb, 0x000001e1 } /* prep */
},
{ /* DFKaiShu */
{ 0x11e5ead4, 0x00000350 }, /* cvt */
{ 0x5a30ca3b, 0x00009063 }, /* fpgm */
{ 0x13a42602, 0x0000007e } /* prep */
},
{ /* HuaTianKaiTi */
{ 0xfffbfffc, 0x00000008 }, /* cvt */
{ 0x9c9e48b8, 0x0000bea2 }, /* fpgm */
{ 0x70020112, 0x00000008 } /* prep */
},
{ /* HuaTianSongTi */
{ 0xfffbfffc, 0x00000008 }, /* cvt */
{ 0x0a5a0483, 0x00017c39 }, /* fpgm */
{ 0x70020112, 0x00000008 } /* prep */
},
{ /* NEC fadpop7.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x40c92555, 0x000000e5 }, /* fpgm */
{ 0xa39b58e3, 0x0000117c } /* prep */
},
{ /* NEC fadrei5.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x33c41652, 0x000000e5 }, /* fpgm */
{ 0x26d6c52a, 0x00000f6a } /* prep */
},
{ /* NEC fangot7.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x6db1651d, 0x0000019d }, /* fpgm */
{ 0x6c6e4b03, 0x00002492 } /* prep */
},
{ /* NEC fangyo5.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x40c92555, 0x000000e5 }, /* fpgm */
{ 0xde51fad0, 0x0000117c } /* prep */
},
{ /* NEC fankyo5.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x85e47664, 0x000000e5 }, /* fpgm */
{ 0xa6c62831, 0x00001caa } /* prep */
},
{ /* NEC fanrgo5.ttf */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x2d891cfd, 0x0000019d }, /* fpgm */
{ 0xa0604633, 0x00001de8 } /* prep */
},
{ /* NEC fangot5.ttc */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x40aa774c, 0x000001cb }, /* fpgm */
{ 0x9b5caa96, 0x00001f9a } /* prep */
},
{ /* NEC fanmin3.ttc */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x0d3de9cb, 0x00000141 }, /* fpgm */
{ 0xd4127766, 0x00002280 } /* prep */
},
{ /* NEC FA-Gothic, 1996 */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x4a692698, 0x000001f0 }, /* fpgm */
{ 0x340d4346, 0x00001fca } /* prep */
},
{ /* NEC FA-Minchou, 1996 */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0xcd34c604, 0x00000166 }, /* fpgm */
{ 0x6cf31046, 0x000022b0 } /* prep */
},
{ /* NEC FA-RoundGothicB, 1996 */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0x5da75315, 0x0000019d }, /* fpgm */
{ 0x40745a5f, 0x000022e0 } /* prep */
},
{ /* NEC FA-RoundGothicM, 1996 */
{ 0x00000000, 0x00000000 }, /* cvt */
{ 0xf055fc48, 0x000001c2 }, /* fpgm */
{ 0x3900ded3, 0x00001e18 } /* prep */
}
};
FT_ULong checksum;
int num_matched_ids[TRICK_SFNT_IDS_NUM_FACES];
FT_Bool has_cvt, has_fpgm, has_prep;
FT_UShort i;
int j, k;
FT_MEM_SET( num_matched_ids, 0,
sizeof ( int ) * TRICK_SFNT_IDS_NUM_FACES );
has_cvt = FALSE;
has_fpgm = FALSE;
has_prep = FALSE;
for ( i = 0; i < face->num_tables; i++ )
{
checksum = 0;
switch( face->dir_tables[i].Tag )
{
case TTAG_cvt:
k = TRICK_SFNT_ID_cvt;
has_cvt = TRUE;
break;
case TTAG_fpgm:
k = TRICK_SFNT_ID_fpgm;
has_fpgm = TRUE;
break;
case TTAG_prep:
k = TRICK_SFNT_ID_prep;
has_prep = TRUE;
break;
default:
continue;
}
for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
if ( face->dir_tables[i].Length == sfnt_id[j][k].Length )
{
if ( !checksum )
checksum = tt_get_sfnt_checksum( face, i );
if ( sfnt_id[j][k].CheckSum == checksum )
num_matched_ids[j]++;
if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
return TRUE;
}
}
for ( j = 0; j < TRICK_SFNT_IDS_NUM_FACES; j++ )
{
if ( !has_cvt && !sfnt_id[j][TRICK_SFNT_ID_cvt].Length )
num_matched_ids[j] ++;
if ( !has_fpgm && !sfnt_id[j][TRICK_SFNT_ID_fpgm].Length )
num_matched_ids[j] ++;
if ( !has_prep && !sfnt_id[j][TRICK_SFNT_ID_prep].Length )
num_matched_ids[j] ++;
if ( num_matched_ids[j] == TRICK_SFNT_IDS_PER_FACE )
return TRUE;
}
return FALSE;
}
static FT_Bool
tt_check_trickyness( FT_Face face )
{
if ( !face )
return FALSE;
/* For first, check the face name for quick check. */
if ( face->family_name &&
tt_check_trickyness_family( face->family_name ) )
return TRUE;
/* Type42 fonts may lack `name' tables, we thus try to identify */
/* tricky fonts by checking the checksums of Type42-persistent */
/* sfnt tables (`cvt', `fpgm', and `prep'). */
if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) )
return TRUE;
return FALSE;
}
/* Check whether `.notdef' is the only glyph in the `loca' table. */
static FT_Bool
tt_check_single_notdef( FT_Face ttface )
{
FT_Bool result = FALSE;
TT_Face face = (TT_Face)ttface;
FT_UInt asize;
FT_ULong i;
FT_ULong glyph_index = 0;
FT_UInt count = 0;
for( i = 0; i < face->num_locations; i++ )
{
tt_face_get_location( face, i, &asize );
if ( asize > 0 )
{
count += 1;
if ( count > 1 )
break;
glyph_index = i;
}
}
/* Only have a single outline. */
if ( count == 1 )
{
if ( glyph_index == 0 )
result = TRUE;
else
{
/* FIXME: Need to test glyphname == .notdef ? */
FT_Error error;
char buf[8];
error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 );
if ( !error &&
buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) )
result = TRUE;
}
}
return result;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_init */
/* */
/* <Description> */
/* Initialize a given TrueType face object. */
/* */
/* <Input> */
/* stream :: The source font stream. */
/* */
/* face_index :: The index of the font face in the resource. */
/* */
/* num_params :: Number of additional generic parameters. Ignored. */
/* */
/* params :: Additional generic parameters. Ignored. */
/* */
/* <InOut> */
/* face :: The newly built face object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_init( FT_Stream stream,
FT_Face ttface, /* TT_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Library library;
SFNT_Service sfnt;
TT_Face face = (TT_Face)ttface;
FT_TRACE2(( "TTF driver\n" ));
library = ttface->driver->root.library;
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
{
FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
goto Exit;
/* check that we have a valid TrueType file */
error = sfnt->init_face( stream, face, face_index, num_params, params );
/* Stream may have changed. */
stream = face->root.stream;
if ( error )
goto Exit;
/* We must also be able to accept Mac/GX fonts, as well as OT ones. */
/* The 0x00020000 tag is completely undocumented; some fonts from */
/* Arphic made for Chinese Windows 3.1 have this. */
if ( face->format_tag != 0x00010000L && /* MS fonts */
face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */
face->format_tag != TTAG_true ) /* Mac fonts */
{
FT_TRACE2(( " not a TTF font\n" ));
goto Bad_Format;
}
#ifdef TT_USE_BYTECODE_INTERPRETER
ttface->face_flags |= FT_FACE_FLAG_HINTER;
#endif
/* If we are performing a simple font format check, exit immediately. */
if ( face_index < 0 )
return FT_Err_Ok;
/* Load font directory */
error = sfnt->load_face( stream, face, face_index, num_params, params );
if ( error )
goto Exit;
if ( tt_check_trickyness( ttface ) )
ttface->face_flags |= FT_FACE_FLAG_TRICKY;
error = tt_face_load_hdmx( face, stream );
if ( error )
goto Exit;
if ( FT_IS_SCALABLE( ttface ) )
{
#ifdef FT_CONFIG_OPTION_INCREMENTAL
if ( !ttface->internal->incremental_interface )
error = tt_face_load_loca( face, stream );
if ( !error )
error = tt_face_load_cvt( face, stream );
if ( !error )
error = tt_face_load_fpgm( face, stream );
if ( !error )
error = tt_face_load_prep( face, stream );
/* Check the scalable flag based on `loca'. */
if ( !ttface->internal->incremental_interface &&
ttface->num_fixed_sizes &&
face->glyph_locations &&
tt_check_single_notdef( ttface ) )
{
FT_TRACE5(( "tt_face_init:"
" Only the `.notdef' glyph has an outline.\n"
" "
" Resetting scalable flag to FALSE.\n" ));
ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
}
#else
if ( !error )
error = tt_face_load_loca( face, stream );
if ( !error )
error = tt_face_load_cvt( face, stream );
if ( !error )
error = tt_face_load_fpgm( face, stream );
if ( !error )
error = tt_face_load_prep( face, stream );
/* Check the scalable flag based on `loca'. */
if ( ttface->num_fixed_sizes &&
face->glyph_locations &&
tt_check_single_notdef( ttface ) )
{
FT_TRACE5(( "tt_face_init:"
" Only the `.notdef' glyph has an outline.\n"
" "
" Resetting scalable flag to FALSE.\n" ));
ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE;
}
#endif
}
#if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
!defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
{
FT_Bool unpatented_hinting;
int i;
/* Determine whether unpatented hinting is to be used for this face. */
unpatented_hinting = FT_BOOL
( library->debug_hooks[FT_DEBUG_HOOK_UNPATENTED_HINTING] != NULL );
for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
unpatented_hinting = TRUE;
if ( !unpatented_hinting )
ttface->internal->ignore_unpatented_hinter = TRUE;
}
#endif /* TT_CONFIG_OPTION_UNPATENTED_HINTING &&
!TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );
Exit:
return error;
Bad_Format:
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_done */
/* */
/* <Description> */
/* Finalize a given face object. */
/* */
/* <Input> */
/* face :: A pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF( void )
tt_face_done( FT_Face ttface ) /* TT_Face */
{
TT_Face face = (TT_Face)ttface;
FT_Memory memory;
FT_Stream stream;
SFNT_Service sfnt;
if ( !face )
return;
memory = ttface->memory;
stream = ttface->stream;
sfnt = (SFNT_Service)face->sfnt;
/* for `extended TrueType formats' (i.e. compressed versions) */
if ( face->extra.finalizer )
face->extra.finalizer( face->extra.data );
if ( sfnt )
sfnt->done_face( face );
/* freeing the locations table */
tt_face_done_loca( face );
tt_face_free_hdmx( face );
/* freeing the CVT */
FT_FREE( face->cvt );
face->cvt_size = 0;
/* freeing the programs */
FT_FRAME_RELEASE( face->font_program );
FT_FRAME_RELEASE( face->cvt_program );
face->font_program_size = 0;
face->cvt_program_size = 0;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
tt_done_blend( memory, face->blend );
face->blend = NULL;
#endif
}
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/*************************************************************************/
#ifdef TT_USE_BYTECODE_INTERPRETER
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_run_fpgm */
/* */
/* <Description> */
/* Run the font program. */
/* */
/* <Input> */
/* size :: A handle to the size object. */
/* */
/* pedantic :: Set if bytecode execution should be pedantic. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_run_fpgm( TT_Size size,
FT_Bool pedantic )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
/* debugging instances have their own context */
if ( size->debug )
exec = size->context;
else
exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
return FT_THROW( Could_Not_Find_Context );
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->period = 64;
exec->phase = 0;
exec->threshold = 0;
exec->instruction_trap = FALSE;
exec->F_dot_P = 0x4000L;
exec->pedantic_hinting = pedantic;
{
FT_Size_Metrics* metrics = &exec->metrics;
TT_Size_Metrics* tt_metrics = &exec->tt_metrics;
metrics->x_ppem = 0;
metrics->y_ppem = 0;
metrics->x_scale = 0;
metrics->y_scale = 0;
tt_metrics->ppem = 0;
tt_metrics->scale = 0;
tt_metrics->ratio = 0x10000L;
}
/* allow font program execution */
TT_Set_CodeRange( exec,
tt_coderange_font,
face->font_program,
face->font_program_size );
/* disable CVT and glyph programs coderange */
TT_Clear_CodeRange( exec, tt_coderange_cvt );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->font_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 );
if ( !error )
{
FT_TRACE4(( "Executing `fpgm' table.\n" ));
error = face->interpreter( exec );
}
}
else
error = FT_Err_Ok;
if ( !error )
TT_Save_Context( exec, size );
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_run_prep */
/* */
/* <Description> */
/* Run the control value program. */
/* */
/* <Input> */
/* size :: A handle to the size object. */
/* */
/* pedantic :: Set if bytecode execution should be pedantic. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_run_prep( TT_Size size,
FT_Bool pedantic )
{
TT_Face face = (TT_Face)size->root.face;
TT_ExecContext exec;
FT_Error error;
/* debugging instances have their own context */
if ( size->debug )
exec = size->context;
else
exec = ( (TT_Driver)FT_FACE_DRIVER( face ) )->context;
if ( !exec )
return FT_THROW( Could_Not_Find_Context );
TT_Load_Context( exec, face, size );
exec->callTop = 0;
exec->top = 0;
exec->instruction_trap = FALSE;
exec->pedantic_hinting = pedantic;
TT_Set_CodeRange( exec,
tt_coderange_cvt,
face->cvt_program,
face->cvt_program_size );
TT_Clear_CodeRange( exec, tt_coderange_glyph );
if ( face->cvt_program_size > 0 )
{
error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 );
if ( !error && !size->debug )
{
FT_TRACE4(( "Executing `prep' table.\n" ));
error = face->interpreter( exec );
}
}
else
error = FT_Err_Ok;
/* UNDOCUMENTED! The MS rasterizer doesn't allow the following */
/* graphics state variables to be modified by the CVT program. */
exec->GS.dualVector.x = 0x4000;
exec->GS.dualVector.y = 0;
exec->GS.projVector.x = 0x4000;
exec->GS.projVector.y = 0x0;
exec->GS.freeVector.x = 0x4000;
exec->GS.freeVector.y = 0x0;
exec->GS.rp0 = 0;
exec->GS.rp1 = 0;
exec->GS.rp2 = 0;
exec->GS.gep0 = 1;
exec->GS.gep1 = 1;
exec->GS.gep2 = 1;
exec->GS.loop = 1;
/* save as default graphics state */
size->GS = exec->GS;
TT_Save_Context( exec, size );
return error;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
#ifdef TT_USE_BYTECODE_INTERPRETER
static void
tt_size_done_bytecode( FT_Size ftsize )
{
TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
if ( size->debug )
{
/* the debug context must be deleted by the debugger itself */
size->context = NULL;
size->debug = FALSE;
}
FT_FREE( size->cvt );
size->cvt_size = 0;
/* free storage area */
FT_FREE( size->storage );
size->storage_size = 0;
/* twilight zone */
tt_glyphzone_done( &size->twilight );
FT_FREE( size->function_defs );
FT_FREE( size->instruction_defs );
size->num_function_defs = 0;
size->max_function_defs = 0;
size->num_instruction_defs = 0;
size->max_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
size->bytecode_ready = 0;
size->cvt_ready = 0;
}
/* Initialize bytecode-related fields in the size object. */
/* We do this only if bytecode interpretation is really needed. */
static FT_Error
tt_size_init_bytecode( FT_Size ftsize,
FT_Bool pedantic )
{
FT_Error error;
TT_Size size = (TT_Size)ftsize;
TT_Face face = (TT_Face)ftsize->face;
FT_Memory memory = face->root.memory;
FT_Int i;
FT_UShort n_twilight;
TT_MaxProfile* maxp = &face->max_profile;
size->bytecode_ready = 1;
size->cvt_ready = 0;
size->max_function_defs = maxp->maxFunctionDefs;
size->max_instruction_defs = maxp->maxInstructionDefs;
size->num_function_defs = 0;
size->num_instruction_defs = 0;
size->max_func = 0;
size->max_ins = 0;
size->cvt_size = face->cvt_size;
size->storage_size = maxp->maxStorage;
/* Set default metrics */
{
TT_Size_Metrics* metrics = &size->ttmetrics;
metrics->rotated = FALSE;
metrics->stretched = FALSE;
/* set default compensation (all 0) */
for ( i = 0; i < 4; i++ )
metrics->compensations[i] = 0;
}
/* allocate function defs, instruction defs, cvt, and storage area */
if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) ||
FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) ||
FT_NEW_ARRAY( size->cvt, size->cvt_size ) ||
FT_NEW_ARRAY( size->storage, size->storage_size ) )
goto Exit;
/* reserve twilight zone */
n_twilight = maxp->maxTwilightPoints;
/* there are 4 phantom points (do we need this?) */
n_twilight += 4;
error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight );
if ( error )
goto Exit;
size->twilight.n_points = n_twilight;
size->GS = tt_default_graphics_state;
/* set `face->interpreter' according to the debug hook present */
{
FT_Library library = face->root.driver->root.library;
face->interpreter = (TT_Interpreter)
library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
if ( !face->interpreter )
face->interpreter = (TT_Interpreter)TT_RunIns;
}
/* Fine, now run the font program! */
error = tt_size_run_fpgm( size, pedantic );
Exit:
if ( error )
tt_size_done_bytecode( ftsize );
return error;
}
FT_LOCAL_DEF( FT_Error )
tt_size_ready_bytecode( TT_Size size,
FT_Bool pedantic )
{
FT_Error error = FT_Err_Ok;
if ( !size->bytecode_ready )
{
error = tt_size_init_bytecode( (FT_Size)size, pedantic );
if ( error )
goto Exit;
}
/* rescale CVT when needed */
if ( !size->cvt_ready )
{
FT_UInt i;
TT_Face face = (TT_Face)size->root.face;
/* Scale the cvt values to the new ppem. */
/* We use by default the y ppem to scale the CVT. */
for ( i = 0; i < size->cvt_size; i++ )
size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale );
/* all twilight points are originally zero */
for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ )
{
size->twilight.org[i].x = 0;
size->twilight.org[i].y = 0;
size->twilight.cur[i].x = 0;
size->twilight.cur[i].y = 0;
}
/* clear storage area */
for ( i = 0; i < (FT_UInt)size->storage_size; i++ )
size->storage[i] = 0;
size->GS = tt_default_graphics_state;
error = tt_size_run_prep( size, pedantic );
if ( !error )
size->cvt_ready = 1;
}
Exit:
return error;
}
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_init */
/* */
/* <Description> */
/* Initialize a new TrueType size object. */
/* */
/* <InOut> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_init( FT_Size ttsize ) /* TT_Size */
{
TT_Size size = (TT_Size)ttsize;
FT_Error error = FT_Err_Ok;
#ifdef TT_USE_BYTECODE_INTERPRETER
size->bytecode_ready = 0;
size->cvt_ready = 0;
#endif
size->ttmetrics.valid = FALSE;
size->strike_index = 0xFFFFFFFFUL;
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_done */
/* */
/* <Description> */
/* The TrueType size object finalizer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
FT_LOCAL_DEF( void )
tt_size_done( FT_Size ttsize ) /* TT_Size */
{
TT_Size size = (TT_Size)ttsize;
#ifdef TT_USE_BYTECODE_INTERPRETER
if ( size->bytecode_ready )
tt_size_done_bytecode( ttsize );
#endif
size->ttmetrics.valid = FALSE;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_size_reset */
/* */
/* <Description> */
/* Reset a TrueType size when resolutions and character dimensions */
/* have been changed. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_size_reset( TT_Size size )
{
TT_Face face;
FT_Error error = FT_Err_Ok;
FT_Size_Metrics* metrics;
size->ttmetrics.valid = FALSE;
face = (TT_Face)size->root.face;
metrics = &size->metrics;
/* copy the result from base layer */
*metrics = size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return FT_THROW( Invalid_PPem );
/* This bit flag, if set, indicates that the ppems must be */
/* rounded to integers. Nearly all TrueType fonts have this bit */
/* set, as hinting won't work really well otherwise. */
/* */
if ( face->header.Flags & 8 )
{
metrics->x_scale = FT_DivFix( metrics->x_ppem << 6,
face->root.units_per_EM );
metrics->y_scale = FT_DivFix( metrics->y_ppem << 6,
face->root.units_per_EM );
metrics->ascender =
FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) );
metrics->descender =
FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) );
metrics->height =
FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) );
metrics->max_advance =
FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) );
}
/* compute new transformation */
if ( metrics->x_ppem >= metrics->y_ppem )
{
size->ttmetrics.scale = metrics->x_scale;
size->ttmetrics.ppem = metrics->x_ppem;
size->ttmetrics.x_ratio = 0x10000L;
size->ttmetrics.y_ratio = FT_DivFix( metrics->y_ppem,
metrics->x_ppem );
}
else
{
size->ttmetrics.scale = metrics->y_scale;
size->ttmetrics.ppem = metrics->y_ppem;
size->ttmetrics.x_ratio = FT_DivFix( metrics->x_ppem,
metrics->y_ppem );
size->ttmetrics.y_ratio = 0x10000L;
}
#ifdef TT_USE_BYTECODE_INTERPRETER
size->cvt_ready = 0;
#endif /* TT_USE_BYTECODE_INTERPRETER */
if ( !error )
size->ttmetrics.valid = TRUE;
return error;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_driver_init */
/* */
/* <Description> */
/* Initialize a given TrueType driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_driver_init( FT_Module ttdriver ) /* TT_Driver */
{
#ifdef TT_USE_BYTECODE_INTERPRETER
TT_Driver driver = (TT_Driver)ttdriver;
if ( !TT_New_Context( driver ) )
return FT_THROW( Could_Not_Find_Context );
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
driver->interpreter_version = TT_INTERPRETER_VERSION_38;
#else
driver->interpreter_version = TT_INTERPRETER_VERSION_35;
#endif
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( ttdriver );
#endif /* !TT_USE_BYTECODE_INTERPRETER */
return FT_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_driver_done */
/* */
/* <Description> */
/* Finalize a given TrueType driver. */
/* */
/* <Input> */
/* driver :: A handle to the target TrueType driver. */
/* */
FT_LOCAL_DEF( void )
tt_driver_done( FT_Module ttdriver ) /* TT_Driver */
{
#ifdef TT_USE_BYTECODE_INTERPRETER
TT_Driver driver = (TT_Driver)ttdriver;
/* destroy the execution context */
if ( driver->context )
{
TT_Done_Context( driver->context );
driver->context = NULL;
}
#else
FT_UNUSED( ttdriver );
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_slot_init */
/* */
/* <Description> */
/* Initialize a new slot object. */
/* */
/* <InOut> */
/* slot :: A handle to the slot object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_slot_init( FT_GlyphSlot slot )
{
return FT_GlyphLoader_CreateExtra( slot->internal->loader );
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttobjs.c | C | apache-2.0 | 45,266 |
/***************************************************************************/
/* */
/* ttobjs.h */
/* */
/* Objects manager (specification). */
/* */
/* Copyright 1996-2009, 2011-2013 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 __TTOBJS_H__
#define __TTOBJS_H__
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Type> */
/* TT_Driver */
/* */
/* <Description> */
/* A handle to a TrueType driver object. */
/* */
typedef struct TT_DriverRec_* TT_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* TT_Instance */
/* */
/* <Description> */
/* A handle to a TrueType size object. */
/* */
typedef struct TT_SizeRec_* TT_Size;
/*************************************************************************/
/* */
/* <Type> */
/* TT_GlyphSlot */
/* */
/* <Description> */
/* A handle to a TrueType glyph slot object. */
/* */
/* <Note> */
/* This is a direct typedef of FT_GlyphSlot, as there is nothing */
/* specific about the TrueType glyph slot. */
/* */
typedef FT_GlyphSlot TT_GlyphSlot;
/*************************************************************************/
/* */
/* <Struct> */
/* TT_GraphicsState */
/* */
/* <Description> */
/* The TrueType graphics state used during bytecode interpretation. */
/* */
typedef struct TT_GraphicsState_
{
FT_UShort rp0;
FT_UShort rp1;
FT_UShort rp2;
FT_UnitVector dualVector;
FT_UnitVector projVector;
FT_UnitVector freeVector;
#ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING
FT_Bool both_x_axis;
#endif
FT_Long loop;
FT_F26Dot6 minimum_distance;
FT_Int round_state;
FT_Bool auto_flip;
FT_F26Dot6 control_value_cutin;
FT_F26Dot6 single_width_cutin;
FT_F26Dot6 single_width_value;
FT_Short delta_base;
FT_Short delta_shift;
FT_Byte instruct_control;
/* According to Greg Hitchcock from Microsoft, the `scan_control' */
/* variable as documented in the TrueType specification is a 32-bit */
/* integer; the high-word part holds the SCANTYPE value, the low-word */
/* part the SCANCTRL value. We separate it into two fields. */
FT_Bool scan_control;
FT_Int scan_type;
FT_UShort gep0;
FT_UShort gep1;
FT_UShort gep2;
} TT_GraphicsState;
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( void )
tt_glyphzone_done( TT_GlyphZone zone );
FT_LOCAL( FT_Error )
tt_glyphzone_new( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
TT_GlyphZone zone );
#endif /* TT_USE_BYTECODE_INTERPRETER */
/*************************************************************************/
/* */
/* EXECUTION SUBTABLES */
/* */
/* These sub-tables relate to instruction execution. */
/* */
/*************************************************************************/
#define TT_MAX_CODE_RANGES 3
/*************************************************************************/
/* */
/* There can only be 3 active code ranges at once: */
/* - the Font Program */
/* - the CVT Program */
/* - a glyph's instructions set */
/* */
typedef enum TT_CodeRange_Tag_
{
tt_coderange_none = 0,
tt_coderange_font,
tt_coderange_cvt,
tt_coderange_glyph
} TT_CodeRange_Tag;
typedef struct TT_CodeRange_
{
FT_Byte* base;
FT_ULong size;
} TT_CodeRange;
typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
/*************************************************************************/
/* */
/* Defines a function/instruction definition record. */
/* */
typedef struct TT_DefRecord_
{
FT_Int range; /* in which code range is it located? */
FT_Long start; /* where does it start? */
FT_Long end; /* where does it end? */
FT_UInt opc; /* function #, or instruction code */
FT_Bool active; /* is it active? */
FT_Bool inline_delta; /* is function that defines inline delta? */
FT_ULong sph_fdef_flags; /* flags to identify special functions */
} TT_DefRecord, *TT_DefArray;
/*************************************************************************/
/* */
/* Subglyph transformation record. */
/* */
typedef struct TT_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
FT_F26Dot6 ox, oy; /* offsets */
} TT_Transform;
/*************************************************************************/
/* */
/* A note regarding non-squared pixels: */
/* */
/* (This text will probably go into some docs at some time; for now, it */
/* is kept here to explain some definitions in the TT_Size_Metrics */
/* record). */
/* */
/* The CVT is a one-dimensional array containing values that control */
/* certain important characteristics in a font, like the height of all */
/* capitals, all lowercase letter, default spacing or stem width/height. */
/* */
/* These values are found in FUnits in the font file, and must be scaled */
/* to pixel coordinates before being used by the CVT and glyph programs. */
/* Unfortunately, when using distinct x and y resolutions (or distinct x */
/* and y pointsizes), there are two possible scalings. */
/* */
/* A first try was to implement a `lazy' scheme where all values were */
/* scaled when first used. However, while some values are always used */
/* in the same direction, some others are used under many different */
/* circumstances and orientations. */
/* */
/* I have found a simpler way to do the same, and it even seems to work */
/* in most of the cases: */
/* */
/* - All CVT values are scaled to the maximum ppem size. */
/* */
/* - When performing a read or write in the CVT, a ratio factor is used */
/* to perform adequate scaling. Example: */
/* */
/* x_ppem = 14 */
/* y_ppem = 10 */
/* */
/* We choose ppem = x_ppem = 14 as the CVT scaling size. All cvt */
/* entries are scaled to it. */
/* */
/* x_ratio = 1.0 */
/* y_ratio = y_ppem/ppem (< 1.0) */
/* */
/* We compute the current ratio like: */
/* */
/* - If projVector is horizontal, */
/* ratio = x_ratio = 1.0 */
/* */
/* - if projVector is vertical, */
/* ratio = y_ratio */
/* */
/* - else, */
/* ratio = sqrt( (proj.x * x_ratio) ^ 2 + (proj.y * y_ratio) ^ 2 ) */
/* */
/* Reading a cvt value returns */
/* ratio * cvt[index] */
/* */
/* Writing a cvt value in pixels: */
/* cvt[index] / ratio */
/* */
/* The current ppem is simply */
/* ratio * ppem */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Metrics used by the TrueType size and context objects. */
/* */
typedef struct TT_Size_Metrics_
{
/* for non-square pixels */
FT_Long x_ratio;
FT_Long y_ratio;
FT_UShort ppem; /* maximum ppem size */
FT_Long ratio; /* current ratio */
FT_Fixed scale;
FT_F26Dot6 compensations[4]; /* device-specific compensations */
FT_Bool valid;
FT_Bool rotated; /* `is the glyph rotated?'-flag */
FT_Bool stretched; /* `is the glyph stretched?'-flag */
} TT_Size_Metrics;
/*************************************************************************/
/* */
/* TrueType size class. */
/* */
typedef struct TT_SizeRec_
{
FT_SizeRec root;
/* we have our own copy of metrics so that we can modify */
/* it without affecting auto-hinting (when used) */
FT_Size_Metrics metrics;
TT_Size_Metrics ttmetrics;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_UInt num_function_defs; /* number of function definitions */
FT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */
FT_UInt num_instruction_defs; /* number of ins. definitions */
FT_UInt max_instruction_defs;
TT_DefArray instruction_defs; /* table of ins. definitions */
FT_UInt max_func;
FT_UInt max_ins;
TT_CodeRangeTable codeRangeTable;
TT_GraphicsState GS;
FT_ULong cvt_size; /* the scaled control value table */
FT_Long* cvt;
FT_UShort storage_size; /* The storage area is now part of */
FT_Long* storage; /* the instance */
TT_GlyphZoneRec twilight; /* The instance's twilight zone */
/* debugging variables */
/* When using the debugger, we must keep the */
/* execution context tied to the instance */
/* object rather than asking it on demand. */
FT_Bool debug;
TT_ExecContext context;
FT_Bool bytecode_ready;
FT_Bool cvt_ready;
#endif /* TT_USE_BYTECODE_INTERPRETER */
} TT_SizeRec;
/*************************************************************************/
/* */
/* TrueType driver class. */
/* */
typedef struct TT_DriverRec_
{
FT_DriverRec root;
TT_ExecContext context; /* execution context */
TT_GlyphZoneRec zone; /* glyph loader points zone */
FT_UInt interpreter_version;
} TT_DriverRec;
/* Note: All of the functions below (except tt_size_reset()) are used */
/* as function pointers in a FT_Driver_ClassRec. Therefore their */
/* parameters are of types FT_Face, FT_Size, etc., rather than TT_Face, */
/* TT_Size, etc., so that the compiler can confirm that the types and */
/* number of parameters are correct. In all cases the FT_xxx types are */
/* cast to their TT_xxx counterparts inside the functions since FreeType */
/* will always use the TT driver to create them. */
/*************************************************************************/
/* */
/* Face functions */
/* */
FT_LOCAL( FT_Error )
tt_face_init( FT_Stream stream,
FT_Face ttface, /* TT_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
FT_LOCAL( void )
tt_face_done( FT_Face ttface ); /* TT_Face */
/*************************************************************************/
/* */
/* Size functions */
/* */
FT_LOCAL( FT_Error )
tt_size_init( FT_Size ttsize ); /* TT_Size */
FT_LOCAL( void )
tt_size_done( FT_Size ttsize ); /* TT_Size */
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_LOCAL( FT_Error )
tt_size_run_fpgm( TT_Size size,
FT_Bool pedantic );
FT_LOCAL( FT_Error )
tt_size_run_prep( TT_Size size,
FT_Bool pedantic );
FT_LOCAL( FT_Error )
tt_size_ready_bytecode( TT_Size size,
FT_Bool pedantic );
#endif /* TT_USE_BYTECODE_INTERPRETER */
FT_LOCAL( FT_Error )
tt_size_reset( TT_Size size );
/*************************************************************************/
/* */
/* Driver functions */
/* */
FT_LOCAL( FT_Error )
tt_driver_init( FT_Module ttdriver ); /* TT_Driver */
FT_LOCAL( void )
tt_driver_done( FT_Module ttdriver ); /* TT_Driver */
/*************************************************************************/
/* */
/* Slot functions */
/* */
FT_LOCAL( FT_Error )
tt_slot_init( FT_GlyphSlot slot );
/* auxiliary */
#define IS_HINTED( flags ) ( ( flags & FT_LOAD_NO_HINTING ) == 0 )
FT_END_HEADER
#endif /* __TTOBJS_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttobjs.h | C | apache-2.0 | 19,825 |
/***************************************************************************/
/* */
/* ttpic.c */
/* */
/* The FreeType position independent code services for truetype module. */
/* */
/* Copyright 2009, 2010, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_INTERNAL_OBJECTS_H
#include "ttpic.h"
#include "tterrors.h"
#ifdef FT_CONFIG_OPTION_PIC
/* forward declaration of PIC init functions from ttdriver.c */
FT_Error
FT_Create_Class_tt_services( FT_Library library,
FT_ServiceDescRec** output_class );
void
FT_Destroy_Class_tt_services( FT_Library library,
FT_ServiceDescRec* clazz );
void
FT_Init_Class_tt_service_gx_multi_masters(
FT_Service_MultiMastersRec* sv_mm );
void
FT_Init_Class_tt_service_truetype_glyf(
FT_Service_TTGlyfRec* sv_ttglyf );
void
tt_driver_class_pic_free( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Memory memory = library->memory;
if ( pic_container->truetype )
{
TTModulePIC* container = (TTModulePIC*)pic_container->truetype;
if ( container->tt_services )
FT_Destroy_Class_tt_services( library, container->tt_services );
container->tt_services = NULL;
FT_FREE( container );
pic_container->truetype = NULL;
}
}
FT_Error
tt_driver_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
TTModulePIC* container = NULL;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->truetype = container;
/* initialize pointer table - this is how the module usually */
/* expects this data */
error = FT_Create_Class_tt_services( library,
&container->tt_services );
if ( error )
goto Exit;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Init_Class_tt_service_gx_multi_masters(
&container->tt_service_gx_multi_masters );
#endif
FT_Init_Class_tt_service_truetype_glyf(
&container->tt_service_truetype_glyf );
Exit:
if ( error )
tt_driver_class_pic_free( library );
return error;
}
#endif /* FT_CONFIG_OPTION_PIC */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttpic.c | C | apache-2.0 | 3,619 |
/***************************************************************************/
/* */
/* ttpic.h */
/* */
/* The FreeType position independent code services for truetype module. */
/* */
/* Copyright 2009, 2012, 2013 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* 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 __TTPIC_H__
#define __TTPIC_H__
FT_BEGIN_HEADER
#ifndef FT_CONFIG_OPTION_PIC
#define TT_SERVICES_GET tt_services
#define TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters
#define TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf
#define TT_SERVICE_PROPERTIES_GET tt_service_properties
#else /* FT_CONFIG_OPTION_PIC */
#include FT_MULTIPLE_MASTERS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#include FT_SERVICE_TRUETYPE_GLYF_H
#include FT_SERVICE_PROPERTIES_H
typedef struct TTModulePIC_
{
FT_ServiceDescRec* tt_services;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Service_MultiMastersRec tt_service_gx_multi_masters;
#endif
FT_Service_TTGlyfRec tt_service_truetype_glyf;
FT_Service_PropertiesRec tt_service_properties;
} TTModulePIC;
#define GET_PIC( lib ) \
( (TTModulePIC*)((lib)->pic_container.truetype) )
#define TT_SERVICES_GET \
( GET_PIC( library )->tt_services )
#define TT_SERVICE_GX_MULTI_MASTERS_GET \
( GET_PIC( library )->tt_service_gx_multi_masters )
#define TT_SERVICE_TRUETYPE_GLYF_GET \
( GET_PIC( library )->tt_service_truetype_glyf )
#define TT_SERVICE_PROPERTIES_GET \
( GET_PIC( library )->tt_service_properties )
/* see ttpic.c for the implementation */
void
tt_driver_class_pic_free( FT_Library library );
FT_Error
tt_driver_class_pic_init( FT_Library library );
#endif /* FT_CONFIG_OPTION_PIC */
/* */
FT_END_HEADER
#endif /* __TTPIC_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttpic.h | C | apache-2.0 | 2,925 |
/***************************************************************************/
/* */
/* ttpload.c */
/* */
/* TrueType-specific tables loader (body). */
/* */
/* Copyright 1996-2002, 2004-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include "ttpload.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include "ttgxvar.h"
#endif
#include "tterrors.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_ttpload
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_loca */
/* */
/* <Description> */
/* Load the locations table. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: The input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_loca( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_ULong table_len;
FT_Int shift;
/* we need the size of the `glyf' table for malformed `loca' tables */
error = face->goto_table( face, TTAG_glyf, stream, &face->glyf_len );
/* it is possible that a font doesn't have a glyf table at all */
/* or its size is zero */
if ( FT_ERR_EQ( error, Table_Missing ) )
face->glyf_len = 0;
else if ( error )
goto Exit;
FT_TRACE2(( "Locations " ));
error = face->goto_table( face, TTAG_loca, stream, &table_len );
if ( error )
{
error = FT_THROW( Locations_Missing );
goto Exit;
}
if ( face->header.Index_To_Loc_Format != 0 )
{
shift = 2;
if ( table_len >= 0x40000L )
{
FT_TRACE2(( "table too large\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
face->num_locations = table_len >> shift;
}
else
{
shift = 1;
if ( table_len >= 0x20000L )
{
FT_TRACE2(( "table too large\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
face->num_locations = table_len >> shift;
}
if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 )
{
FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n",
face->num_locations - 1, face->root.num_glyphs ));
/* we only handle the case where `maxp' gives a larger value */
if ( face->num_locations <= (FT_ULong)face->root.num_glyphs )
{
FT_Long new_loca_len =
( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
TT_Table entry = face->dir_tables;
TT_Table limit = entry + face->num_tables;
FT_Long pos = FT_Stream_Pos( stream );
FT_Long dist = 0x7FFFFFFFL;
/* compute the distance to next table in font file */
for ( ; entry < limit; entry++ )
{
FT_Long diff = entry->Offset - pos;
if ( diff > 0 && diff < dist )
dist = diff;
}
if ( entry == limit )
{
/* `loca' is the last table */
dist = stream->size - pos;
}
if ( new_loca_len <= dist )
{
face->num_locations = face->root.num_glyphs + 1;
table_len = new_loca_len;
FT_TRACE2(( "adjusting num_locations to %d\n",
face->num_locations ));
}
}
}
/*
* Extract the frame. We don't need to decompress it since
* we are able to parse it directly.
*/
if ( FT_FRAME_EXTRACT( table_len, face->glyph_locations ) )
goto Exit;
FT_TRACE2(( "loaded\n" ));
Exit:
return error;
}
FT_LOCAL_DEF( FT_ULong )
tt_face_get_location( TT_Face face,
FT_UInt gindex,
FT_UInt *asize )
{
FT_ULong pos1, pos2;
FT_Byte* p;
FT_Byte* p_limit;
pos1 = pos2 = 0;
if ( gindex < face->num_locations )
{
if ( face->header.Index_To_Loc_Format != 0 )
{
p = face->glyph_locations + gindex * 4;
p_limit = face->glyph_locations + face->num_locations * 4;
pos1 = FT_NEXT_ULONG( p );
pos2 = pos1;
if ( p + 4 <= p_limit )
pos2 = FT_NEXT_ULONG( p );
}
else
{
p = face->glyph_locations + gindex * 2;
p_limit = face->glyph_locations + face->num_locations * 2;
pos1 = FT_NEXT_USHORT( p );
pos2 = pos1;
if ( p + 2 <= p_limit )
pos2 = FT_NEXT_USHORT( p );
pos1 <<= 1;
pos2 <<= 1;
}
}
/* Check broken location data */
if ( pos1 > face->glyf_len )
{
FT_TRACE1(( "tt_face_get_location:"
" too large offset=0x%08lx found for gid=0x%04lx,"
" exceeding the end of glyf table (0x%08lx)\n",
pos1, gindex, face->glyf_len ));
*asize = 0;
return 0;
}
if ( pos2 > face->glyf_len )
{
FT_TRACE1(( "tt_face_get_location:"
" too large offset=0x%08lx found for gid=0x%04lx,"
" truncate at the end of glyf table (0x%08lx)\n",
pos2, gindex + 1, face->glyf_len ));
pos2 = face->glyf_len;
}
/* The `loca' table must be ordered; it refers to the length of */
/* an entry as the difference between the current and the next */
/* position. However, there do exist (malformed) fonts which */
/* don't obey this rule, so we are only able to provide an */
/* upper bound for the size. */
/* */
/* We get (intentionally) a wrong, non-zero result in case the */
/* `glyf' table is missing. */
if ( pos2 >= pos1 )
*asize = (FT_UInt)( pos2 - pos1 );
else
*asize = (FT_UInt)( face->glyf_len - pos1 );
return pos1;
}
FT_LOCAL_DEF( void )
tt_face_done_loca( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_FRAME_RELEASE( face->glyph_locations );
face->num_locations = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_cvt */
/* */
/* <Description> */
/* Load the control value table into a face object. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_cvt( TT_Face face,
FT_Stream stream )
{
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Error error;
FT_Memory memory = stream->memory;
FT_ULong table_len;
FT_TRACE2(( "CVT " ));
error = face->goto_table( face, TTAG_cvt, stream, &table_len );
if ( error )
{
FT_TRACE2(( "is missing\n" ));
face->cvt_size = 0;
face->cvt = NULL;
error = FT_Err_Ok;
goto Exit;
}
face->cvt_size = table_len / 2;
if ( FT_NEW_ARRAY( face->cvt, face->cvt_size ) )
goto Exit;
if ( FT_FRAME_ENTER( face->cvt_size * 2L ) )
goto Exit;
{
FT_Short* cur = face->cvt;
FT_Short* limit = cur + face->cvt_size;
for ( ; cur < limit; cur++ )
*cur = FT_GET_SHORT();
}
FT_FRAME_EXIT();
FT_TRACE2(( "loaded\n" ));
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
if ( face->doblend )
error = tt_face_vary_cvt( face, stream );
#endif
Exit:
return error;
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( face );
FT_UNUSED( stream );
return FT_Err_Ok;
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_fpgm */
/* */
/* <Description> */
/* Load the font program. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_fpgm( TT_Face face,
FT_Stream stream )
{
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Error error;
FT_ULong table_len;
FT_TRACE2(( "Font program " ));
/* The font program is optional */
error = face->goto_table( face, TTAG_fpgm, stream, &table_len );
if ( error )
{
face->font_program = NULL;
face->font_program_size = 0;
error = FT_Err_Ok;
FT_TRACE2(( "is missing\n" ));
}
else
{
face->font_program_size = table_len;
if ( FT_FRAME_EXTRACT( table_len, face->font_program ) )
goto Exit;
FT_TRACE2(( "loaded, %12d bytes\n", face->font_program_size ));
}
Exit:
return error;
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( face );
FT_UNUSED( stream );
return FT_Err_Ok;
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_prep */
/* */
/* <Description> */
/* Load the cvt program. */
/* */
/* <InOut> */
/* face :: A handle to the target face object. */
/* */
/* <Input> */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_prep( TT_Face face,
FT_Stream stream )
{
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Error error;
FT_ULong table_len;
FT_TRACE2(( "Prep program " ));
error = face->goto_table( face, TTAG_prep, stream, &table_len );
if ( error )
{
face->cvt_program = NULL;
face->cvt_program_size = 0;
error = FT_Err_Ok;
FT_TRACE2(( "is missing\n" ));
}
else
{
face->cvt_program_size = table_len;
if ( FT_FRAME_EXTRACT( table_len, face->cvt_program ) )
goto Exit;
FT_TRACE2(( "loaded, %12d bytes\n", face->cvt_program_size ));
}
Exit:
return error;
#else /* !TT_USE_BYTECODE_INTERPRETER */
FT_UNUSED( face );
FT_UNUSED( stream );
return FT_Err_Ok;
#endif
}
/*************************************************************************/
/* */
/* <Function> */
/* tt_face_load_hdmx */
/* */
/* <Description> */
/* Load the `hdmx' table into the face object. */
/* */
/* <Input> */
/* face :: A handle to the target face object. */
/* */
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
tt_face_load_hdmx( TT_Face face,
FT_Stream stream )
{
FT_Error error;
FT_Memory memory = stream->memory;
FT_UInt version, nn, num_records;
FT_ULong table_size, record_size;
FT_Byte* p;
FT_Byte* limit;
/* this table is optional */
error = face->goto_table( face, TTAG_hdmx, stream, &table_size );
if ( error || table_size < 8 )
return FT_Err_Ok;
if ( FT_FRAME_EXTRACT( table_size, face->hdmx_table ) )
goto Exit;
p = face->hdmx_table;
limit = p + table_size;
version = FT_NEXT_USHORT( p );
num_records = FT_NEXT_USHORT( p );
record_size = FT_NEXT_ULONG( p );
/* The maximum number of bytes in an hdmx device record is the */
/* maximum number of glyphs + 2; this is 0xFFFF + 2; this is */
/* the reason why `record_size' is a long (which we read as */
/* unsigned long for convenience). In practice, two bytes */
/* sufficient to hold the size value. */
/* */
/* There are at least two fonts, HANNOM-A and HANNOM-B version */
/* 2.0 (2005), which get this wrong: The upper two bytes of */
/* the size value are set to 0xFF instead of 0x00. We catch */
/* and fix this. */
if ( record_size >= 0xFFFF0000UL )
record_size &= 0xFFFFU;
/* The limit for `num_records' is a heuristic value. */
if ( version != 0 || num_records > 255 || record_size > 0x10001L )
{
error = FT_THROW( Invalid_File_Format );
goto Fail;
}
if ( FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) )
goto Fail;
for ( nn = 0; nn < num_records; nn++ )
{
if ( p + record_size > limit )
break;
face->hdmx_record_sizes[nn] = p[0];
p += record_size;
}
face->hdmx_record_count = nn;
face->hdmx_table_size = table_size;
face->hdmx_record_size = record_size;
Exit:
return error;
Fail:
FT_FRAME_RELEASE( face->hdmx_table );
face->hdmx_table_size = 0;
goto Exit;
}
FT_LOCAL_DEF( void )
tt_face_free_hdmx( TT_Face face )
{
FT_Stream stream = face->root.stream;
FT_Memory memory = stream->memory;
FT_FREE( face->hdmx_record_sizes );
FT_FRAME_RELEASE( face->hdmx_table );
}
/*************************************************************************/
/* */
/* Return the advance width table for a given pixel size if it is found */
/* in the font's `hdmx' table (if any). */
/* */
FT_LOCAL_DEF( FT_Byte* )
tt_face_get_device_metrics( TT_Face face,
FT_UInt ppem,
FT_UInt gindex )
{
FT_UInt nn;
FT_Byte* result = NULL;
FT_ULong record_size = face->hdmx_record_size;
FT_Byte* record = face->hdmx_table + 8;
for ( nn = 0; nn < face->hdmx_record_count; nn++ )
if ( face->hdmx_record_sizes[nn] == ppem )
{
gindex += 2;
if ( gindex < record_size )
result = record + nn * record_size + gindex;
break;
}
return result;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttpload.c | C | apache-2.0 | 20,325 |
/***************************************************************************/
/* */
/* ttpload.h */
/* */
/* TrueType-specific tables loader (specification). */
/* */
/* Copyright 1996-2001, 2002, 2005, 2006 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 __TTPLOAD_H__
#define __TTPLOAD_H__
#include <ft2build.h>
#include FT_INTERNAL_TRUETYPE_TYPES_H
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_load_loca( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_ULong )
tt_face_get_location( TT_Face face,
FT_UInt gindex,
FT_UInt *asize );
FT_LOCAL( void )
tt_face_done_loca( TT_Face face );
FT_LOCAL( FT_Error )
tt_face_load_cvt( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_fpgm( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_prep( TT_Face face,
FT_Stream stream );
FT_LOCAL( FT_Error )
tt_face_load_hdmx( TT_Face face,
FT_Stream stream );
FT_LOCAL( void )
tt_face_free_hdmx( TT_Face face );
FT_LOCAL( FT_Byte* )
tt_face_get_device_metrics( TT_Face face,
FT_UInt ppem,
FT_UInt gindex );
FT_END_HEADER
#endif /* __TTPLOAD_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttpload.h | C | apache-2.0 | 2,386 |
/***************************************************************************/
/* */
/* ttsubpix.c */
/* */
/* TrueType Subpixel Hinting. */
/* */
/* Copyright 2010-2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_TRUETYPE_TAGS_H
#include FT_OUTLINE_H
#include FT_TRUETYPE_DRIVER_H
#include "ttsubpix.h"
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/*************************************************************************/
/* */
/* These rules affect how the TT Interpreter does hinting, with the */
/* goal of doing subpixel hinting by (in general) ignoring x moves. */
/* Some of these rules are fixes that go above and beyond the */
/* stated techniques in the MS whitepaper on Cleartype, due to */
/* artifacts in many glyphs. So, these rules make some glyphs render */
/* better than they do in the MS rasterizer. */
/* */
/* "" string or 0 int/char indicates to apply to all glyphs. */
/* "-" used as dummy placeholders, but any non-matching string works. */
/* */
/* Some of this could arguably be implemented in fontconfig, however: */
/* */
/* - Fontconfig can't set things on a glyph-by-glyph basis. */
/* - The tweaks that happen here are very low-level, from an average */
/* user's point of view and are best implemented in the hinter. */
/* */
/* The goal is to make the subpixel hinting techniques as generalized */
/* as possible across all fonts to prevent the need for extra rules such */
/* as these. */
/* */
/* The rule structure is designed so that entirely new rules can easily */
/* be added when a new compatibility feature is discovered. */
/* */
/* The rule structures could also use some enhancement to handle ranges. */
/* */
/* ****************** WORK IN PROGRESS ******************* */
/* */
/* These are `classes' of fonts that can be grouped together and used in */
/* rules below. A blank entry "" is required at the end of these! */
#define FAMILY_CLASS_RULES_SIZE 7
static const SPH_Font_Class FAMILY_CLASS_Rules
[FAMILY_CLASS_RULES_SIZE] =
{
{ "MS Legacy Fonts",
{ "Aharoni",
"Andale Mono",
"Andalus",
"Angsana New",
"AngsanaUPC",
"Arabic Transparent",
"Arial Black",
"Arial Narrow",
"Arial Unicode MS",
"Arial",
"Batang",
"Browallia New",
"BrowalliaUPC",
"Comic Sans MS",
"Cordia New",
"CordiaUPC",
"Courier New",
"DFKai-SB",
"David Transparent",
"David",
"DilleniaUPC",
"Estrangelo Edessa",
"EucrosiaUPC",
"FangSong_GB2312",
"Fixed Miriam Transparent",
"FrankRuehl",
"Franklin Gothic Medium",
"FreesiaUPC",
"Garamond",
"Gautami",
"Georgia",
"Gulim",
"Impact",
"IrisUPC",
"JasmineUPC",
"KaiTi_GB2312",
"KodchiangUPC",
"Latha",
"Levenim MT",
"LilyUPC",
"Lucida Console",
"Lucida Sans Unicode",
"MS Gothic",
"MS Mincho",
"MV Boli",
"Mangal",
"Marlett",
"Microsoft Sans Serif",
"Mingliu",
"Miriam Fixed",
"Miriam Transparent",
"Miriam",
"Narkisim",
"Palatino Linotype",
"Raavi",
"Rod Transparent",
"Rod",
"Shruti",
"SimHei",
"Simplified Arabic Fixed",
"Simplified Arabic",
"Simsun",
"Sylfaen",
"Symbol",
"Tahoma",
"Times New Roman",
"Traditional Arabic",
"Trebuchet MS",
"Tunga",
"Verdana",
"Webdings",
"Wingdings",
"",
},
},
{ "Core MS Legacy Fonts",
{ "Arial Black",
"Arial Narrow",
"Arial Unicode MS",
"Arial",
"Comic Sans MS",
"Courier New",
"Garamond",
"Georgia",
"Impact",
"Lucida Console",
"Lucida Sans Unicode",
"Microsoft Sans Serif",
"Palatino Linotype",
"Tahoma",
"Times New Roman",
"Trebuchet MS",
"Verdana",
"",
},
},
{ "Apple Legacy Fonts",
{ "Geneva",
"Times",
"Monaco",
"Century",
"Chalkboard",
"Lobster",
"Century Gothic",
"Optima",
"Lucida Grande",
"Gill Sans",
"Baskerville",
"Helvetica",
"Helvetica Neue",
"",
},
},
{ "Legacy Sans Fonts",
{ "Andale Mono",
"Arial Unicode MS",
"Arial",
"Century Gothic",
"Comic Sans MS",
"Franklin Gothic Medium",
"Geneva",
"Lucida Console",
"Lucida Grande",
"Lucida Sans Unicode",
"Lucida Sans Typewriter",
"Microsoft Sans Serif",
"Monaco",
"Tahoma",
"Trebuchet MS",
"Verdana",
"",
},
},
{ "Misc Legacy Fonts",
{ "Dark Courier", "", }, },
{ "Verdana Clones",
{ "DejaVu Sans",
"Bitstream Vera Sans", "", }, },
{ "Verdana and Clones",
{ "DejaVu Sans",
"Bitstream Vera Sans",
"Verdana", "", }, },
};
/* Define this to force natural (i.e. not bitmap-compatible) widths. */
/* The default leans strongly towards natural widths except for a few */
/* legacy fonts where a selective combination produces nicer results. */
/* #define FORCE_NATURAL_WIDTHS */
/* Define `classes' of styles that can be grouped together and used in */
/* rules below. A blank entry "" is required at the end of these! */
#define STYLE_CLASS_RULES_SIZE 5
const SPH_Font_Class STYLE_CLASS_Rules
[STYLE_CLASS_RULES_SIZE] =
{
{ "Regular Class",
{ "Regular",
"Book",
"Medium",
"Roman",
"Normal",
"",
},
},
{ "Regular/Italic Class",
{ "Regular",
"Book",
"Medium",
"Italic",
"Oblique",
"Roman",
"Normal",
"",
},
},
{ "Bold/BoldItalic Class",
{ "Bold",
"Bold Italic",
"Black",
"",
},
},
{ "Bold/Italic/BoldItalic Class",
{ "Bold",
"Bold Italic",
"Black",
"Italic",
"Oblique",
"",
},
},
{ "Regular/Bold Class",
{ "Regular",
"Book",
"Medium",
"Normal",
"Roman",
"Bold",
"Black",
"",
},
},
};
/* Force special legacy fixes for fonts. */
#define COMPATIBILITY_MODE_RULES_SIZE 1
const SPH_TweakRule COMPATIBILITY_MODE_Rules
[COMPATIBILITY_MODE_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Don't do subpixel (ignore_x_mode) hinting; do normal hinting. */
#define PIXEL_HINTING_RULES_SIZE 2
const SPH_TweakRule PIXEL_HINTING_Rules
[PIXEL_HINTING_RULES_SIZE] =
{
/* these characters are almost always safe */
{ "Courier New", 12, "Italic", 'z' },
{ "Courier New", 11, "Italic", 'z' },
};
/* Subpixel hinting ignores SHPIX rules on X. Force SHPIX for these. */
#define DO_SHPIX_RULES_SIZE 1
const SPH_TweakRule DO_SHPIX_Rules
[DO_SHPIX_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Skip Y moves that start with a point that is not on a Y pixel */
/* boundary and don't move that point to a Y pixel boundary. */
#define SKIP_NONPIXEL_Y_MOVES_RULES_SIZE 4
const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules
[SKIP_NONPIXEL_Y_MOVES_RULES_SIZE] =
{
/* fix vwxyz thinness*/
{ "Consolas", 0, "", 0 },
/* Fix thin middle stems */
{ "Core MS Legacy Fonts", 0, "Regular", 0 },
/* Cyrillic small letter I */
{ "Legacy Sans Fonts", 0, "", 0 },
/* Fix artifacts with some Regular & Bold */
{ "Verdana Clones", 0, "", 0 },
};
#define SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_Rules_Exceptions
[SKIP_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
{
/* Fixes < and > */
{ "Courier New", 0, "Regular", 0 },
};
/* Skip Y moves that start with a point that is not on a Y pixel */
/* boundary and don't move that point to a Y pixel boundary. */
#define SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE 2
const SPH_TweakRule SKIP_NONPIXEL_Y_MOVES_DELTAP_Rules
[SKIP_NONPIXEL_Y_MOVES_DELTAP_RULES_SIZE] =
{
/* Maintain thickness of diagonal in 'N' */
{ "Times New Roman", 0, "Regular/Bold Class", 'N' },
{ "Georgia", 0, "Regular/Bold Class", 'N' },
};
/* Skip Y moves that move a point off a Y pixel boundary. */
#define SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE 1
const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules
[SKIP_OFFPIXEL_Y_MOVES_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
#define SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
const SPH_TweakRule SKIP_OFFPIXEL_Y_MOVES_Rules_Exceptions
[SKIP_OFFPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Round moves that don't move a point to a Y pixel boundary. */
#define ROUND_NONPIXEL_Y_MOVES_RULES_SIZE 2
const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules
[ROUND_NONPIXEL_Y_MOVES_RULES_SIZE] =
{
/* Droid font instructions don't snap Y to pixels */
{ "Droid Sans", 0, "Regular/Italic Class", 0 },
{ "Droid Sans Mono", 0, "", 0 },
};
#define ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE 1
const SPH_TweakRule ROUND_NONPIXEL_Y_MOVES_Rules_Exceptions
[ROUND_NONPIXEL_Y_MOVES_RULES_EXCEPTIONS_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Allow a Direct_Move along X freedom vector if matched. */
#define ALLOW_X_DMOVE_RULES_SIZE 1
const SPH_TweakRule ALLOW_X_DMOVE_Rules
[ALLOW_X_DMOVE_RULES_SIZE] =
{
/* Fixes vanishing diagonal in 4 */
{ "Verdana", 0, "Regular", '4' },
};
/* Return MS rasterizer version 35 if matched. */
#define RASTERIZER_35_RULES_SIZE 8
const SPH_TweakRule RASTERIZER_35_Rules
[RASTERIZER_35_RULES_SIZE] =
{
/* This seems to be the only way to make these look good */
{ "Times New Roman", 0, "Regular", 'i' },
{ "Times New Roman", 0, "Regular", 'j' },
{ "Times New Roman", 0, "Regular", 'm' },
{ "Times New Roman", 0, "Regular", 'r' },
{ "Times New Roman", 0, "Regular", 'a' },
{ "Times New Roman", 0, "Regular", 'n' },
{ "Times New Roman", 0, "Regular", 'p' },
{ "Times", 0, "", 0 },
};
/* Don't round to the subpixel grid. Round to pixel grid. */
#define NORMAL_ROUND_RULES_SIZE 1
const SPH_TweakRule NORMAL_ROUND_Rules
[NORMAL_ROUND_RULES_SIZE] =
{
/* Fix serif thickness for certain ppems */
/* Can probably be generalized somehow */
{ "Courier New", 0, "", 0 },
};
/* Skip IUP instructions if matched. */
#define SKIP_IUP_RULES_SIZE 1
const SPH_TweakRule SKIP_IUP_Rules
[SKIP_IUP_RULES_SIZE] =
{
{ "Arial", 13, "Regular", 'a' },
};
/* Skip MIAP Twilight hack if matched. */
#define MIAP_HACK_RULES_SIZE 1
const SPH_TweakRule MIAP_HACK_Rules
[MIAP_HACK_RULES_SIZE] =
{
{ "Geneva", 12, "", 0 },
};
/* Skip DELTAP instructions if matched. */
#define ALWAYS_SKIP_DELTAP_RULES_SIZE 23
const SPH_TweakRule ALWAYS_SKIP_DELTAP_Rules
[ALWAYS_SKIP_DELTAP_RULES_SIZE] =
{
{ "Georgia", 0, "Regular", 'k' },
/* fix various problems with e in different versions */
{ "Trebuchet MS", 14, "Regular", 'e' },
{ "Trebuchet MS", 13, "Regular", 'e' },
{ "Trebuchet MS", 15, "Regular", 'e' },
{ "Trebuchet MS", 0, "Italic", 'v' },
{ "Trebuchet MS", 0, "Italic", 'w' },
{ "Trebuchet MS", 0, "Regular", 'Y' },
{ "Arial", 11, "Regular", 's' },
/* prevent problems with '3' and others */
{ "Verdana", 10, "Regular", 0 },
{ "Verdana", 9, "Regular", 0 },
/* Cyrillic small letter short I */
{ "Legacy Sans Fonts", 0, "", 0x438 },
{ "Legacy Sans Fonts", 0, "", 0x439 },
{ "Arial", 10, "Regular", '6' },
{ "Arial", 0, "Bold/BoldItalic Class", 'a' },
/* Make horizontal stems consistent with the rest */
{ "Arial", 24, "Bold", 'a' },
{ "Arial", 25, "Bold", 'a' },
{ "Arial", 24, "Bold", 's' },
{ "Arial", 25, "Bold", 's' },
{ "Arial", 34, "Bold", 's' },
{ "Arial", 35, "Bold", 's' },
{ "Arial", 36, "Bold", 's' },
{ "Arial", 25, "Regular", 's' },
{ "Arial", 26, "Regular", 's' },
};
/* Always do DELTAP instructions if matched. */
#define ALWAYS_DO_DELTAP_RULES_SIZE 1
const SPH_TweakRule ALWAYS_DO_DELTAP_Rules
[ALWAYS_DO_DELTAP_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Don't allow ALIGNRP after IUP. */
#define NO_ALIGNRP_AFTER_IUP_RULES_SIZE 1
static const SPH_TweakRule NO_ALIGNRP_AFTER_IUP_Rules
[NO_ALIGNRP_AFTER_IUP_RULES_SIZE] =
{
/* Prevent creation of dents in outline */
{ "-", 0, "", 0 },
};
/* Don't allow DELTAP after IUP. */
#define NO_DELTAP_AFTER_IUP_RULES_SIZE 1
static const SPH_TweakRule NO_DELTAP_AFTER_IUP_Rules
[NO_DELTAP_AFTER_IUP_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
/* Don't allow CALL after IUP. */
#define NO_CALL_AFTER_IUP_RULES_SIZE 1
static const SPH_TweakRule NO_CALL_AFTER_IUP_Rules
[NO_CALL_AFTER_IUP_RULES_SIZE] =
{
/* Prevent creation of dents in outline */
{ "-", 0, "", 0 },
};
/* De-embolden these glyphs slightly. */
#define DEEMBOLDEN_RULES_SIZE 9
static const SPH_TweakRule DEEMBOLDEN_Rules
[DEEMBOLDEN_RULES_SIZE] =
{
{ "Courier New", 0, "Bold", 'A' },
{ "Courier New", 0, "Bold", 'W' },
{ "Courier New", 0, "Bold", 'w' },
{ "Courier New", 0, "Bold", 'M' },
{ "Courier New", 0, "Bold", 'X' },
{ "Courier New", 0, "Bold", 'K' },
{ "Courier New", 0, "Bold", 'x' },
{ "Courier New", 0, "Bold", 'z' },
{ "Courier New", 0, "Bold", 'v' },
};
/* Embolden these glyphs slightly. */
#define EMBOLDEN_RULES_SIZE 2
static const SPH_TweakRule EMBOLDEN_Rules
[EMBOLDEN_RULES_SIZE] =
{
{ "Courier New", 0, "Regular", 0 },
{ "Courier New", 0, "Italic", 0 },
};
/* This is a CVT hack that makes thick horizontal stems on 2, 5, 7 */
/* similar to Windows XP. */
#define TIMES_NEW_ROMAN_HACK_RULES_SIZE 12
static const SPH_TweakRule TIMES_NEW_ROMAN_HACK_Rules
[TIMES_NEW_ROMAN_HACK_RULES_SIZE] =
{
{ "Times New Roman", 16, "Italic", '2' },
{ "Times New Roman", 16, "Italic", '5' },
{ "Times New Roman", 16, "Italic", '7' },
{ "Times New Roman", 16, "Regular", '2' },
{ "Times New Roman", 16, "Regular", '5' },
{ "Times New Roman", 16, "Regular", '7' },
{ "Times New Roman", 17, "Italic", '2' },
{ "Times New Roman", 17, "Italic", '5' },
{ "Times New Roman", 17, "Italic", '7' },
{ "Times New Roman", 17, "Regular", '2' },
{ "Times New Roman", 17, "Regular", '5' },
{ "Times New Roman", 17, "Regular", '7' },
};
/* This fudges distance on 2 to get rid of the vanishing stem issue. */
/* A real solution to this is certainly welcome. */
#define COURIER_NEW_2_HACK_RULES_SIZE 15
static const SPH_TweakRule COURIER_NEW_2_HACK_Rules
[COURIER_NEW_2_HACK_RULES_SIZE] =
{
{ "Courier New", 10, "Regular", '2' },
{ "Courier New", 11, "Regular", '2' },
{ "Courier New", 12, "Regular", '2' },
{ "Courier New", 13, "Regular", '2' },
{ "Courier New", 14, "Regular", '2' },
{ "Courier New", 15, "Regular", '2' },
{ "Courier New", 16, "Regular", '2' },
{ "Courier New", 17, "Regular", '2' },
{ "Courier New", 18, "Regular", '2' },
{ "Courier New", 19, "Regular", '2' },
{ "Courier New", 20, "Regular", '2' },
{ "Courier New", 21, "Regular", '2' },
{ "Courier New", 22, "Regular", '2' },
{ "Courier New", 23, "Regular", '2' },
{ "Courier New", 24, "Regular", '2' },
};
#ifndef FORCE_NATURAL_WIDTHS
/* Use compatible widths with these glyphs. Compatible widths is always */
/* on when doing B/W TrueType instructing, but is used selectively here, */
/* typically on glyphs with 3 or more vertical stems. */
#define COMPATIBLE_WIDTHS_RULES_SIZE 38
static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
[COMPATIBLE_WIDTHS_RULES_SIZE] =
{
{ "Arial Unicode MS", 12, "Regular Class", 'm' },
{ "Arial Unicode MS", 14, "Regular Class", 'm' },
/* Cyrillic small letter sha */
{ "Arial", 10, "Regular Class", 0x448 },
{ "Arial", 11, "Regular Class", 'm' },
{ "Arial", 12, "Regular Class", 'm' },
/* Cyrillic small letter sha */
{ "Arial", 12, "Regular Class", 0x448 },
{ "Arial", 13, "Regular Class", 0x448 },
{ "Arial", 14, "Regular Class", 'm' },
/* Cyrillic small letter sha */
{ "Arial", 14, "Regular Class", 0x448 },
{ "Arial", 15, "Regular Class", 0x448 },
{ "Arial", 17, "Regular Class", 'm' },
{ "DejaVu Sans", 15, "Regular Class", 0 },
{ "Microsoft Sans Serif", 11, "Regular Class", 0 },
{ "Microsoft Sans Serif", 12, "Regular Class", 0 },
{ "Segoe UI", 11, "Regular Class", 0 },
{ "Monaco", 0, "Regular Class", 0 },
{ "Segoe UI", 12, "Regular Class", 'm' },
{ "Segoe UI", 14, "Regular Class", 'm' },
{ "Tahoma", 11, "Regular Class", 0 },
{ "Times New Roman", 16, "Regular Class", 'c' },
{ "Times New Roman", 16, "Regular Class", 'm' },
{ "Times New Roman", 16, "Regular Class", 'o' },
{ "Times New Roman", 16, "Regular Class", 'w' },
{ "Trebuchet MS", 11, "Regular Class", 0 },
{ "Trebuchet MS", 12, "Regular Class", 0 },
{ "Trebuchet MS", 14, "Regular Class", 0 },
{ "Trebuchet MS", 15, "Regular Class", 0 },
{ "Ubuntu", 12, "Regular Class", 'm' },
/* Cyrillic small letter sha */
{ "Verdana", 10, "Regular Class", 0x448 },
{ "Verdana", 11, "Regular Class", 0x448 },
{ "Verdana and Clones", 12, "Regular Class", 'i' },
{ "Verdana and Clones", 12, "Regular Class", 'j' },
{ "Verdana and Clones", 12, "Regular Class", 'l' },
{ "Verdana and Clones", 12, "Regular Class", 'm' },
{ "Verdana and Clones", 13, "Regular Class", 'i' },
{ "Verdana and Clones", 13, "Regular Class", 'j' },
{ "Verdana and Clones", 13, "Regular Class", 'l' },
{ "Verdana and Clones", 14, "Regular Class", 'm' },
};
/* Scaling slightly in the x-direction prior to hinting results in */
/* more visually pleasing glyphs in certain cases. */
/* This sometimes needs to be coordinated with compatible width rules. */
/* A value of 1000 corresponds to a scaled value of 1.0. */
#define X_SCALING_RULES_SIZE 50
static const SPH_ScaleRule X_SCALING_Rules[X_SCALING_RULES_SIZE] =
{
{ "DejaVu Sans", 12, "Regular Class", 'm', 950 },
{ "Verdana and Clones", 12, "Regular Class", 'a', 1100 },
{ "Verdana and Clones", 13, "Regular Class", 'a', 1050 },
{ "Arial", 11, "Regular Class", 'm', 975 },
{ "Arial", 12, "Regular Class", 'm', 1050 },
/* Cyrillic small letter el */
{ "Arial", 13, "Regular Class", 0x43B, 950 },
{ "Arial", 13, "Regular Class", 'o', 950 },
{ "Arial", 13, "Regular Class", 'e', 950 },
{ "Arial", 14, "Regular Class", 'm', 950 },
/* Cyrillic small letter el */
{ "Arial", 15, "Regular Class", 0x43B, 925 },
{ "Bitstream Vera Sans", 10, "Regular/Italic Class", 0, 1100 },
{ "Bitstream Vera Sans", 12, "Regular/Italic Class", 0, 1050 },
{ "Bitstream Vera Sans", 16, "Regular Class", 0, 1050 },
{ "Bitstream Vera Sans", 9, "Regular/Italic Class", 0, 1050 },
{ "DejaVu Sans", 12, "Regular Class", 'l', 975 },
{ "DejaVu Sans", 12, "Regular Class", 'i', 975 },
{ "DejaVu Sans", 12, "Regular Class", 'j', 975 },
{ "DejaVu Sans", 13, "Regular Class", 'l', 950 },
{ "DejaVu Sans", 13, "Regular Class", 'i', 950 },
{ "DejaVu Sans", 13, "Regular Class", 'j', 950 },
{ "DejaVu Sans", 10, "Regular/Italic Class", 0, 1100 },
{ "DejaVu Sans", 12, "Regular/Italic Class", 0, 1050 },
{ "Georgia", 10, "", 0, 1050 },
{ "Georgia", 11, "", 0, 1100 },
{ "Georgia", 12, "", 0, 1025 },
{ "Georgia", 13, "", 0, 1050 },
{ "Georgia", 16, "", 0, 1050 },
{ "Georgia", 17, "", 0, 1030 },
{ "Liberation Sans", 12, "Regular Class", 'm', 1100 },
{ "Lucida Grande", 11, "Regular Class", 'm', 1100 },
{ "Microsoft Sans Serif", 11, "Regular Class", 'm', 950 },
{ "Microsoft Sans Serif", 12, "Regular Class", 'm', 1050 },
{ "Segoe UI", 12, "Regular Class", 'H', 1050 },
{ "Segoe UI", 12, "Regular Class", 'm', 1050 },
{ "Segoe UI", 14, "Regular Class", 'm', 1050 },
{ "Tahoma", 11, "Regular Class", 'i', 975 },
{ "Tahoma", 11, "Regular Class", 'l', 975 },
{ "Tahoma", 11, "Regular Class", 'j', 900 },
{ "Tahoma", 11, "Regular Class", 'm', 918 },
{ "Verdana", 10, "Regular/Italic Class", 0, 1100 },
{ "Verdana", 12, "Regular Class", 'm', 975 },
{ "Verdana", 12, "Regular/Italic Class", 0, 1050 },
{ "Verdana", 13, "Regular/Italic Class", 'i', 950 },
{ "Verdana", 13, "Regular/Italic Class", 'j', 950 },
{ "Verdana", 13, "Regular/Italic Class", 'l', 950 },
{ "Verdana", 16, "Regular Class", 0, 1050 },
{ "Verdana", 9, "Regular/Italic Class", 0, 1050 },
{ "Times New Roman", 16, "Regular Class", 'm', 918 },
{ "Trebuchet MS", 11, "Regular Class", 'm', 800 },
{ "Trebuchet MS", 12, "Regular Class", 'm', 800 },
};
#else
#define COMPATIBLE_WIDTHS_RULES_SIZE 1
static const SPH_TweakRule COMPATIBLE_WIDTHS_Rules
[COMPATIBLE_WIDTHS_RULES_SIZE] =
{
{ "-", 0, "", 0 },
};
#define X_SCALING_RULES_SIZE 1
static const SPH_ScaleRule X_SCALING_Rules
[X_SCALING_RULES_SIZE] =
{
{ "-", 0, "", 0, 1000 },
};
#endif /* FORCE_NATURAL_WIDTHS */
FT_LOCAL_DEF( FT_Bool )
is_member_of_family_class( const FT_String* detected_font_name,
const FT_String* rule_font_name )
{
FT_UInt i, j;
/* Does font name match rule family? */
if ( strcmp( detected_font_name, rule_font_name ) == 0 )
return TRUE;
/* Is font name a wildcard ""? */
if ( strcmp( rule_font_name, "" ) == 0 )
return TRUE;
/* Is font name contained in a class list? */
for ( i = 0; i < FAMILY_CLASS_RULES_SIZE; i++ )
{
if ( strcmp( FAMILY_CLASS_Rules[i].name, rule_font_name ) == 0 )
{
for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
{
if ( strcmp( FAMILY_CLASS_Rules[i].member[j], "" ) == 0 )
continue;
if ( strcmp( FAMILY_CLASS_Rules[i].member[j],
detected_font_name ) == 0 )
return TRUE;
}
}
}
return FALSE;
}
FT_LOCAL_DEF( FT_Bool )
is_member_of_style_class( const FT_String* detected_font_style,
const FT_String* rule_font_style )
{
FT_UInt i, j;
/* Does font style match rule style? */
if ( strcmp( detected_font_style, rule_font_style ) == 0 )
return TRUE;
/* Is font style a wildcard ""? */
if ( strcmp( rule_font_style, "" ) == 0 )
return TRUE;
/* Is font style contained in a class list? */
for ( i = 0; i < STYLE_CLASS_RULES_SIZE; i++ )
{
if ( strcmp( STYLE_CLASS_Rules[i].name, rule_font_style ) == 0 )
{
for ( j = 0; j < SPH_MAX_CLASS_MEMBERS; j++ )
{
if ( strcmp( STYLE_CLASS_Rules[i].member[j], "" ) == 0 )
continue;
if ( strcmp( STYLE_CLASS_Rules[i].member[j],
detected_font_style ) == 0 )
return TRUE;
}
}
}
return FALSE;
}
FT_LOCAL_DEF( FT_Bool )
sph_test_tweak( TT_Face face,
const FT_String* family,
FT_UInt ppem,
const FT_String* style,
FT_UInt glyph_index,
const SPH_TweakRule* rule,
FT_UInt num_rules )
{
FT_UInt i;
/* rule checks may be able to be optimized further */
for ( i = 0; i < num_rules; i++ )
{
if ( family &&
( is_member_of_family_class ( family, rule[i].family ) ) )
if ( rule[i].ppem == 0 ||
rule[i].ppem == ppem )
if ( style &&
is_member_of_style_class ( style, rule[i].style ) )
if ( rule[i].glyph == 0 ||
FT_Get_Char_Index( (FT_Face)face,
rule[i].glyph ) == glyph_index )
return TRUE;
}
return FALSE;
}
static FT_UInt
scale_test_tweak( TT_Face face,
const FT_String* family,
FT_UInt ppem,
const FT_String* style,
FT_UInt glyph_index,
const SPH_ScaleRule* rule,
FT_UInt num_rules )
{
FT_UInt i;
/* rule checks may be able to be optimized further */
for ( i = 0; i < num_rules; i++ )
{
if ( family &&
( is_member_of_family_class ( family, rule[i].family ) ) )
if ( rule[i].ppem == 0 ||
rule[i].ppem == ppem )
if ( style &&
is_member_of_style_class( style, rule[i].style ) )
if ( rule[i].glyph == 0 ||
FT_Get_Char_Index( (FT_Face)face,
rule[i].glyph ) == glyph_index )
return rule[i].scale;
}
return 1000;
}
FT_LOCAL_DEF( FT_UInt )
sph_test_tweak_x_scaling( TT_Face face,
const FT_String* family,
FT_UInt ppem,
const FT_String* style,
FT_UInt glyph_index )
{
return scale_test_tweak( face, family, ppem, style, glyph_index,
X_SCALING_Rules, X_SCALING_RULES_SIZE );
}
#define TWEAK_RULES( x ) \
if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
x##_Rules, x##_RULES_SIZE ) ) \
loader->exec->sph_tweak_flags |= SPH_TWEAK_##x;
#define TWEAK_RULES_EXCEPTIONS( x ) \
if ( sph_test_tweak( face, family, ppem, style, glyph_index, \
x##_Rules_Exceptions, x##_RULES_EXCEPTIONS_SIZE ) ) \
loader->exec->sph_tweak_flags &= ~SPH_TWEAK_##x;
FT_LOCAL_DEF( void )
sph_set_tweaks( TT_Loader loader,
FT_UInt glyph_index )
{
TT_Face face = (TT_Face)loader->face;
FT_String* family = face->root.family_name;
int ppem = loader->size->metrics.x_ppem;
FT_String* style = face->root.style_name;
/* don't apply rules if style isn't set */
if ( !face->root.style_name )
return;
#ifdef SPH_DEBUG_MORE_VERBOSE
printf( "%s,%d,%s,%c=%d ",
family, ppem, style, glyph_index, glyph_index );
#endif
TWEAK_RULES( PIXEL_HINTING );
if ( loader->exec->sph_tweak_flags & SPH_TWEAK_PIXEL_HINTING )
{
loader->exec->ignore_x_mode = FALSE;
return;
}
TWEAK_RULES( ALLOW_X_DMOVE );
TWEAK_RULES( ALWAYS_DO_DELTAP );
TWEAK_RULES( ALWAYS_SKIP_DELTAP );
TWEAK_RULES( DEEMBOLDEN );
TWEAK_RULES( DO_SHPIX );
TWEAK_RULES( EMBOLDEN );
TWEAK_RULES( MIAP_HACK );
TWEAK_RULES( NORMAL_ROUND );
TWEAK_RULES( NO_ALIGNRP_AFTER_IUP );
TWEAK_RULES( NO_CALL_AFTER_IUP );
TWEAK_RULES( NO_DELTAP_AFTER_IUP );
TWEAK_RULES( RASTERIZER_35 );
TWEAK_RULES( SKIP_IUP );
TWEAK_RULES( SKIP_OFFPIXEL_Y_MOVES );
TWEAK_RULES_EXCEPTIONS( SKIP_OFFPIXEL_Y_MOVES );
TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES_DELTAP );
TWEAK_RULES( SKIP_NONPIXEL_Y_MOVES );
TWEAK_RULES_EXCEPTIONS( SKIP_NONPIXEL_Y_MOVES );
TWEAK_RULES( ROUND_NONPIXEL_Y_MOVES );
TWEAK_RULES_EXCEPTIONS( ROUND_NONPIXEL_Y_MOVES );
if ( loader->exec->sph_tweak_flags & SPH_TWEAK_RASTERIZER_35 )
{
if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 )
{
loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode(
loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
}
else
loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35;
}
else
{
if ( loader->exec->rasterizer_version !=
SPH_OPTION_SET_RASTERIZER_VERSION )
{
loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
loader->exec->size->cvt_ready = FALSE;
tt_size_ready_bytecode(
loader->exec->size,
FT_BOOL( loader->load_flags & FT_LOAD_PEDANTIC ) );
}
else
loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION;
}
if ( IS_HINTED( loader->load_flags ) )
{
TWEAK_RULES( TIMES_NEW_ROMAN_HACK );
TWEAK_RULES( COURIER_NEW_2_HACK );
}
if ( sph_test_tweak( face, family, ppem, style, glyph_index,
COMPATIBILITY_MODE_Rules, COMPATIBILITY_MODE_RULES_SIZE ) )
loader->exec->face->sph_compatibility_mode = TRUE;
if ( IS_HINTED( loader->load_flags ) )
{
if ( sph_test_tweak( face, family, ppem, style, glyph_index,
COMPATIBLE_WIDTHS_Rules, COMPATIBLE_WIDTHS_RULES_SIZE ) )
loader->exec->compatible_widths |= TRUE;
}
}
#else /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* ANSI C doesn't like empty source files */
typedef int _tt_subpix_dummy;
#endif /* !TT_CONFIG_OPTION_SUBPIXEL_HINTING */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttsubpix.c | C | apache-2.0 | 33,221 |
/***************************************************************************/
/* */
/* ttsubpix.h */
/* */
/* TrueType Subpixel Hinting. */
/* */
/* Copyright 2010-2013 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 __TTSUBPIX_H__
#define __TTSUBPIX_H__
#include <ft2build.h>
#include "ttobjs.h"
#include "ttinterp.h"
FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
/*************************************************************************/
/* */
/* ID flags to identify special functions at FDEF and runtime. */
/* */
/* */
#define SPH_FDEF_INLINE_DELTA_1 0x0000001
#define SPH_FDEF_INLINE_DELTA_2 0x0000002
#define SPH_FDEF_DIAGONAL_STROKE 0x0000004
#define SPH_FDEF_VACUFORM_ROUND_1 0x0000008
#define SPH_FDEF_TTFAUTOHINT_1 0x0000010
#define SPH_FDEF_SPACING_1 0x0000020
#define SPH_FDEF_SPACING_2 0x0000040
#define SPH_FDEF_TYPEMAN_STROKES 0x0000080
#define SPH_FDEF_TYPEMAN_DIAGENDCTRL 0x0000100
/*************************************************************************/
/* */
/* Tweak flags that are set for each glyph by the below rules. */
/* */
/* */
#define SPH_TWEAK_ALLOW_X_DMOVE 0x0000001
#define SPH_TWEAK_ALWAYS_DO_DELTAP 0x0000002
#define SPH_TWEAK_ALWAYS_SKIP_DELTAP 0x0000004
#define SPH_TWEAK_COURIER_NEW_2_HACK 0x0000008
#define SPH_TWEAK_DEEMBOLDEN 0x0000010
#define SPH_TWEAK_DO_SHPIX 0x0000020
#define SPH_TWEAK_EMBOLDEN 0x0000040
#define SPH_TWEAK_MIAP_HACK 0x0000080
#define SPH_TWEAK_NORMAL_ROUND 0x0000100
#define SPH_TWEAK_NO_ALIGNRP_AFTER_IUP 0x0000200
#define SPH_TWEAK_NO_CALL_AFTER_IUP 0x0000400
#define SPH_TWEAK_NO_DELTAP_AFTER_IUP 0x0000800
#define SPH_TWEAK_PIXEL_HINTING 0x0001000
#define SPH_TWEAK_RASTERIZER_35 0x0002000
#define SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES 0x0004000
#define SPH_TWEAK_SKIP_IUP 0x0008000
#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES 0x0010000
#define SPH_TWEAK_SKIP_OFFPIXEL_Y_MOVES 0x0020000
#define SPH_TWEAK_TIMES_NEW_ROMAN_HACK 0x0040000
#define SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP 0x0080000
FT_LOCAL( FT_Bool )
sph_test_tweak( TT_Face face,
const FT_String* family,
FT_UInt ppem,
const FT_String* style,
FT_UInt glyph_index,
const SPH_TweakRule* rule,
FT_UInt num_rules );
FT_LOCAL( FT_UInt )
sph_test_tweak_x_scaling( TT_Face face,
const FT_String* family,
FT_UInt ppem,
const FT_String* style,
FT_UInt glyph_index );
FT_LOCAL( void )
sph_set_tweaks( TT_Loader loader,
FT_UInt glyph_index );
/* These macros are defined absent a method for setting them */
#define SPH_OPTION_BITMAP_WIDTHS FALSE
#define SPH_OPTION_SET_SUBPIXEL TRUE
#define SPH_OPTION_SET_GRAYSCALE FALSE
#define SPH_OPTION_SET_COMPATIBLE_WIDTHS FALSE
#define SPH_OPTION_SET_RASTERIZER_VERSION 38
#endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
FT_END_HEADER
#endif /* __TTSUBPIX_H__ */
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/truetype/ttsubpix.h | C | apache-2.0 | 5,009 |
#
# FreeType 2 Type1 module definition
#
# Copyright 1996-2000, 2006 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.
FTMODULE_H_COMMANDS += TYPE1_DRIVER
define TYPE1_DRIVER
$(OPEN_DRIVER) FT_Driver_ClassRec, t1_driver_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE)
endef
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/type1/module.mk | Makefile | apache-2.0 | 679 |
#
# FreeType 2 Type1 driver configuration rules
#
# Copyright 1996-2000, 2001, 2003 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.
# Type1 driver directory
#
T1_DIR := $(SRC_DIR)/type1
# compilation flags for the driver
#
T1_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(T1_DIR))
# Type1 driver sources (i.e., C files)
#
T1_DRV_SRC := $(T1_DIR)/t1parse.c \
$(T1_DIR)/t1load.c \
$(T1_DIR)/t1driver.c \
$(T1_DIR)/t1afm.c \
$(T1_DIR)/t1gload.c \
$(T1_DIR)/t1objs.c
# Type1 driver headers
#
T1_DRV_H := $(T1_DRV_SRC:%.c=%.h) \
$(T1_DIR)/t1tokens.h \
$(T1_DIR)/t1errors.h
# Type1 driver object(s)
#
# T1_DRV_OBJ_M is used during `multi' builds
# T1_DRV_OBJ_S is used during `single' builds
#
T1_DRV_OBJ_M := $(T1_DRV_SRC:$(T1_DIR)/%.c=$(OBJ_DIR)/%.$O)
T1_DRV_OBJ_S := $(OBJ_DIR)/type1.$O
# Type1 driver source file for single build
#
T1_DRV_SRC_S := $(T1_DIR)/type1.c
# Type1 driver - single object
#
$(T1_DRV_OBJ_S): $(T1_DRV_SRC_S) $(T1_DRV_SRC) $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(T1_DRV_SRC_S))
# Type1 driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(T1_DIR)/%.c $(FREETYPE_H) $(T1_DRV_H)
$(T1_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(T1_DRV_OBJ_S)
DRV_OBJS_M += $(T1_DRV_OBJ_M)
# EOF
| YifuLiu/AliOS-Things | components/freetype/src/type1/rules.mk | Makefile | apache-2.0 | 1,720 |
/***************************************************************************/
/* */
/* t1afm.c */
/* */
/* AFM support for Type 1 fonts (body). */
/* */
/* Copyright 1996-2011, 2013 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include "t1afm.h"
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "t1errors.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_t1afm
FT_LOCAL_DEF( void )
T1_Done_Metrics( FT_Memory memory,
AFM_FontInfo fi )
{
FT_FREE( fi->KernPairs );
fi->NumKernPair = 0;
FT_FREE( fi->TrackKerns );
fi->NumTrackKern = 0;
FT_FREE( fi );
}
/* read a glyph name and return the equivalent glyph index */
static FT_Int
t1_get_index( const char* name,
FT_Offset len,
void* user_data )
{
T1_Font type1 = (T1_Font)user_data;
FT_Int n;
/* PS string/name length must be < 16-bit */
if ( len > 0xFFFFU )
return 0;
for ( n = 0; n < type1->num_glyphs; n++ )
{
char* gname = (char*)type1->glyph_names[n];
if ( gname && gname[0] == name[0] &&
ft_strlen( gname ) == len &&
ft_strncmp( gname, name, len ) == 0 )
return n;
}
return 0;
}
#undef KERN_INDEX
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) )
/* compare two kerning pairs */
FT_CALLBACK_DEF( int )
compare_kern_pairs( const void* a,
const void* b )
{
AFM_KernPair pair1 = (AFM_KernPair)a;
AFM_KernPair pair2 = (AFM_KernPair)b;
FT_ULong index1 = KERN_INDEX( pair1->index1, pair1->index2 );
FT_ULong index2 = KERN_INDEX( pair2->index1, pair2->index2 );
if ( index1 > index2 )
return 1;
else if ( index1 < index2 )
return -1;
else
return 0;
}
/* parse a PFM file -- for now, only read the kerning pairs */
static FT_Error
T1_Read_PFM( FT_Face t1_face,
FT_Stream stream,
AFM_FontInfo fi )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* p;
AFM_KernPair kp;
FT_Int width_table_length;
FT_CharMap oldcharmap;
FT_CharMap charmap;
FT_Int n;
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
/* Figure out how long the width table is. */
/* This info is a little-endian short at offset 99. */
p = start + 99;
if ( p + 2 > limit )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
width_table_length = FT_PEEK_USHORT_LE( p );
p += 18 + width_table_length;
if ( p + 0x12 > limit || FT_PEEK_USHORT_LE( p ) < 0x12 )
/* extension table is probably optional */
goto Exit;
/* Kerning offset is 14 bytes from start of extensions table. */
p += 14;
p = start + FT_PEEK_ULONG_LE( p );
if ( p == start )
/* zero offset means no table */
goto Exit;
if ( p + 2 > limit )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
fi->NumKernPair = FT_PEEK_USHORT_LE( p );
p += 2;
if ( p + 4 * fi->NumKernPair > limit )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
}
/* Actually, kerning pairs are simply optional! */
if ( fi->NumKernPair == 0 )
goto Exit;
/* allocate the pairs */
if ( FT_QNEW_ARRAY( fi->KernPairs, fi->NumKernPair ) )
goto Exit;
/* now, read each kern pair */
kp = fi->KernPairs;
limit = p + 4 * fi->NumKernPair;
/* PFM kerning data are stored by encoding rather than glyph index, */
/* so find the PostScript charmap of this font and install it */
/* temporarily. If we find no PostScript charmap, then just use */
/* the default and hope it is the right one. */
oldcharmap = t1_face->charmap;
charmap = NULL;
for ( n = 0; n < t1_face->num_charmaps; n++ )
{
charmap = t1_face->charmaps[n];
/* check against PostScript pseudo platform */
if ( charmap->platform_id == 7 )
{
error = FT_Set_Charmap( t1_face, charmap );
if ( error )
goto Exit;
break;
}
}
/* Kerning info is stored as: */
/* */
/* encoding of first glyph (1 byte) */
/* encoding of second glyph (1 byte) */
/* offset (little-endian short) */
for ( ; p < limit ; p += 4 )
{
kp->index1 = FT_Get_Char_Index( t1_face, p[0] );
kp->index2 = FT_Get_Char_Index( t1_face, p[1] );
kp->x = (FT_Int)FT_PEEK_SHORT_LE(p + 2);
kp->y = 0;
kp++;
}
if ( oldcharmap != NULL )
error = FT_Set_Charmap( t1_face, oldcharmap );
if ( error )
goto Exit;
/* now, sort the kern pairs according to their glyph indices */
ft_qsort( fi->KernPairs, fi->NumKernPair, sizeof ( AFM_KernPairRec ),
compare_kern_pairs );
Exit:
if ( error )
{
FT_FREE( fi->KernPairs );
fi->NumKernPair = 0;
}
return error;
}
/* parse a metrics file -- either AFM or PFM depending on what */
/* it turns out to be */
FT_LOCAL_DEF( FT_Error )
T1_Read_Metrics( FT_Face t1_face,
FT_Stream stream )
{
PSAux_Service psaux;
FT_Memory memory = stream->memory;
AFM_ParserRec parser;
AFM_FontInfo fi = NULL;
FT_Error error = FT_ERR( Unknown_File_Format );
T1_Font t1_font = &( (T1_Face)t1_face )->type1;
if ( FT_NEW( fi ) ||
FT_FRAME_ENTER( stream->size ) )
goto Exit;
fi->FontBBox = t1_font->font_bbox;
fi->Ascender = t1_font->font_bbox.yMax;
fi->Descender = t1_font->font_bbox.yMin;
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
stream->memory,
stream->cursor,
stream->limit );
if ( !error )
{
parser.FontInfo = fi;
parser.get_index = t1_get_index;
parser.user_data = t1_font;
error = psaux->afm_parser_funcs->parse( &parser );
psaux->afm_parser_funcs->done( &parser );
}
}
if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
FT_Byte* start = stream->cursor;
/* MS Windows allows versions up to 0x3FF without complaining */
if ( stream->size > 6 &&
start[1] < 4 &&
FT_PEEK_ULONG_LE( start + 2 ) == stream->size )
error = T1_Read_PFM( t1_face, stream, fi );
}
if ( !error )
{
t1_font->font_bbox = fi->FontBBox;
t1_face->bbox.xMin = fi->FontBBox.xMin >> 16;
t1_face->bbox.yMin = fi->FontBBox.yMin >> 16;
/* no `U' suffix here to 0xFFFF! */
t1_face->bbox.xMax = ( fi->FontBBox.xMax + 0xFFFF ) >> 16;
t1_face->bbox.yMax = ( fi->FontBBox.yMax + 0xFFFF ) >> 16;
/* no `U' suffix here to 0x8000! */
t1_face->ascender = (FT_Short)( ( fi->Ascender + 0x8000 ) >> 16 );
t1_face->descender = (FT_Short)( ( fi->Descender + 0x8000 ) >> 16 );
if ( fi->NumKernPair )
{
t1_face->face_flags |= FT_FACE_FLAG_KERNING;
( (T1_Face)t1_face )->afm_data = fi;
fi = NULL;
}
}
FT_FRAME_EXIT();
Exit:
if ( fi != NULL )
T1_Done_Metrics( memory, fi );
return error;
}
/* find the kerning for a given glyph pair */
FT_LOCAL_DEF( void )
T1_Get_Kerning( AFM_FontInfo fi,
FT_UInt glyph1,
FT_UInt glyph2,
FT_Vector* kerning )
{
AFM_KernPair min, mid, max;
FT_ULong idx = KERN_INDEX( glyph1, glyph2 );
/* simple binary search */
min = fi->KernPairs;
max = min + fi->NumKernPair - 1;
while ( min <= max )
{
FT_ULong midi;
mid = min + ( max - min ) / 2;
midi = KERN_INDEX( mid->index1, mid->index2 );
if ( midi == idx )
{
kerning->x = mid->x;
kerning->y = mid->y;
return;
}
if ( midi < idx )
min = mid + 1;
else
max = mid - 1;
}
kerning->x = 0;
kerning->y = 0;
}
FT_LOCAL_DEF( FT_Error )
T1_Get_Track_Kerning( FT_Face face,
FT_Fixed ptsize,
FT_Int degree,
FT_Fixed* kerning )
{
AFM_FontInfo fi = (AFM_FontInfo)( (T1_Face)face )->afm_data;
FT_Int i;
if ( !fi )
return FT_THROW( Invalid_Argument );
for ( i = 0; i < fi->NumTrackKern; i++ )
{
AFM_TrackKern tk = fi->TrackKerns + i;
if ( tk->degree != degree )
continue;
if ( ptsize < tk->min_ptsize )
*kerning = tk->min_kern;
else if ( ptsize > tk->max_ptsize )
*kerning = tk->max_kern;
else
{
*kerning = FT_MulDiv( ptsize - tk->min_ptsize,
tk->max_kern - tk->min_kern,
tk->max_ptsize - tk->min_ptsize ) +
tk->min_kern;
}
}
return FT_Err_Ok;
}
/* END */
| YifuLiu/AliOS-Things | components/freetype/src/type1/t1afm.c | C | apache-2.0 | 11,127 |