/***************************************************************************/
/* */
/* ttobjs.c */
/* */
/* Objects manager (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_TAGS_H
#include FT_INTERNAL_SFNT_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 16
#define TRICK_NAMES_COUNT 8
static const char trick_names[TRICK_NAMES_COUNT]
[TRICK_NAMES_MAX_CHARACTERS + 1] =
{
"DFKaiSho-SB", /* dfkaisb.ttf */
"DFKaiShu",
"DFKai-SB", <