📄 ttobjs.h
字号:
/******************************************************************* * * ttobjs.h 1.0 * * Objects definition unit. * * Copyright 1996-1999 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 "ttconfig.h"#include "ttengine.h"#include "ttmutex.h"#include "ttcache.h"#include "tttables.h"#include "ttcmap.h"#ifdef __cplusplus extern "C" {#endif/* *//* This file contains the definitions and methods of the four *//* kinds of objects managed by the FreeType engine. These are: *//* *//* *//* Face objects: *//* *//* There is always one face object per opened TrueType font *//* file, and only one. The face object contains data that is *//* independent of current transform/scaling/rotation and *//* pointsize, or glyph index. This data is made of several *//* critical tables that are loaded on face object creation. *//* *//* A face object tracks all active and recycled objects of *//* the instance and execution context classes. Destroying a face *//* object will automatically destroy all associated instances. *//* *//* *//* Instance objects: *//* *//* An instance object always relates to a given face object, *//* known as its 'parent' or 'owner', and contains only the *//* data that is specific to one given pointsize/transform of *//* the face. You can only create an instance from a face object. *//* *//* An instance's current transform/pointsize can be changed *//* at any time using a single high-level API call, *//* TT_Reset_Instance(). *//* *//* Execution Context objects: *//* *//* An execution context (or context in short) relates to a face. *//* It contains the data and tables that are necessary to load *//* and hint (i.e. execute the glyph instructions of) one glyph. *//* A context is a transient object that is queried/created on *//* the fly: client applications never deal with them directly. *//* *//* *//* Glyph objects: *//* *//* A glyph object contains only the minimal glyph information *//* needed to render one glyph correctly. This means that a glyph *//* object really contains tables that are sized to hold the *//* contents of _any_ glyph of a given face. A client application *//* can usually create one glyph object for a given face, then use *//* it for all subsequent loads. *//* *//* Here is an example of a client application : *//* (NOTE: No error checking performed here!) *//* *//* *//* TT_Face face; -- face handle *//* TT_Instance ins1, ins2; -- two instance handles *//* TT_Glyph glyph; -- glyph handle *//* *//* TT_Init_FreeType(); *//* *//* -- Initialize the engine. This must be done prior to _any_ *//* operation. *//* *//* TT_Open_Face( "/some/face/name.ttf", &face ); *//* *//* -- create the face object. This call opens the font file *//* *//* TT_New_Instance( face, &ins1 ); *//* TT_New_Instance( face, &ins2 ); *//* *//* TT_Set_Instance_PointSize( ins1, 8 ); *//* TT_Set_Instance_PointSize( ins2, 12 ); *//* *//* -- create two distinct instances of the same face *//* -- ins1 is pointsize 8 at resolution 96 dpi *//* -- ins2 is pointsize 12 at resolution 96 dpi *//* *//* TT_New_Glyph( face, &glyph ); *//* *//* -- create a new glyph object which will receive the contents *//* of any glyph of 'face' *//* *//* TT_Load_Glyph( ins1, glyph, 64, DEFAULT_GLYPH_LOAD ); *//* *//* -- load glyph indexed 64 at pointsize 8 in the 'glyph' object *//* -- NOTE: This call will fail if the instance and the glyph *//* do not relate to the same face object. *//* *//* TT_Get_Outline( glyph, &outline ); *//* *//* -- extract the glyph outline from the object and copies it *//* to the 'outline' record *//* *//* TT_Get_Metrics( glyph, &metrics ); *//* *//* -- extract the glyph metrics and put them into the 'metrics' *//* record *//* *//* TT_Load_Glyph( ins2, glyph, 64, DEFAULT_GLYPH_LOAD ); *//* *//* -- load the same glyph at pointsize 12 in the 'glyph' object *//* *//* *//* TT_Close_Face( &face ); *//* *//* -- destroy the face object. This will destroy 'ins1' and *//* 'ins2'. However, the glyph object will still be available *//* *//* TT_Done_FreeType(); *//* *//* -- Finalize the engine. This will also destroy all pending *//* glyph objects (here 'glyph'). */ struct TFace_; struct TInstance_; struct TExecution_Context_; struct TGlyph_; typedef struct TFace_ TFace; typedef TFace* PFace; typedef struct TInstance_ TInstance; typedef TInstance* PInstance; typedef struct TExecution_Context_ TExecution_Context; typedef TExecution_Context* PExecution_Context; typedef struct TGlyph_ TGlyph; typedef TGlyph* PGlyph; /*************************************************************/ /* */ /* ADDITIONAL SUBTABLES */ /* */ /* These tables are not precisely defined by the specs */ /* but their structures is implied by the TrueType font */ /* file layout. */ /* */ /*************************************************************/ /* Graphics State */ /* */ /* The Graphics State (GS) is managed by the */ /* instruction field, but does not come from */ /* the font file. Thus, we can use 'int's */ /* where needed. */ struct TGraphicsState_ { UShort rp0; UShort rp1; UShort rp2; TT_UnitVector dualVector; TT_UnitVector projVector; TT_UnitVector freeVector; Long loop; TT_F26Dot6 minimum_distance; Int round_state; Bool auto_flip; TT_F26Dot6 control_value_cutin; TT_F26Dot6 single_width_cutin; TT_F26Dot6 single_width_value; Short delta_base; Short delta_shift; Byte instruct_control; Bool scan_control; Int scan_type; UShort gep0; UShort gep1; UShort gep2; }; typedef struct TGraphicsState_ TGraphicsState; LOCAL_DEF const TGraphicsState Default_GraphicsState; /*************************************************************/ /* */ /* EXECUTION SUBTABLES */ /* */ /* These sub-tables relate to instruction execution. */ /* */ /*************************************************************/#define 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 */#define TT_CodeRange_Font 1#define TT_CodeRange_Cvt 2#define TT_CodeRange_Glyph 3 struct TCodeRange_ { PByte Base; ULong Size; }; typedef struct TCodeRange_ TCodeRange; typedef TCodeRange* PCodeRange; /* Defintion of a code range */ /* */ /* Code ranges can be resident to a glyph (i.e. the Font Program) */ /* while some others are volatile (Glyph instructions). */ /* Tracking the state and presence of code ranges allows function */ /* and instruction definitions within a code range to be forgotten */ /* when the range is discarded. */ typedef TCodeRange TCodeRangeTable[MAX_CODE_RANGES]; /* defines a function/instruction definition record */ struct TDefRecord_ { Int Range; /* in which code range is it located ? */ ULong Start; /* where does it start ? */ Int Opc; /* function #, or instruction code */ Bool Active; /* is it active ? */ }; typedef struct TDefRecord_ TDefRecord; typedef TDefRecord* PDefRecord; typedef TDefRecord* PDefArray; /* defines a call record, used to manage function calls. */ struct TCallRecord_ { Int Caller_Range; ULong Caller_IP; Long Cur_Count; ULong Cur_Restart; }; typedef struct TCallRecord_ TCallRecord; typedef TCallRecord* PCallRecord; typedef TCallRecord* PCallStack; /* defines a simple call stack */ /* This type defining a set of glyph points will be used to represent */ /* each zone (regular and twilight) during instructions decoding. */ struct TGlyph_Zone_ { UShort n_points; /* number of points in zone */ Short n_contours; /* number of contours */ TT_Vector* org; /* original points coordinates */ TT_Vector* cur; /* current points coordinates */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -