Hash :
8f43c714
Author :
Date :
2000-02-02T12:16:19
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 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 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
/***************************************************************************/
/* */
/* ttobjs.h */
/* */
/* Objects manager (specification). */
/* */
/* 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 <ftobjs.h>
#include <tttypes.h>
#include <ttconfig.h>
#include <tterrors.h>
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************/
/* */
/* <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_
{
TT_UShort rp0;
TT_UShort rp1;
TT_UShort rp2;
TT_UnitVector dualVector;
TT_UnitVector projVector;
TT_UnitVector freeVector;
TT_Long loop;
TT_F26Dot6 minimum_distance;
TT_Int round_state;
TT_Bool auto_flip;
TT_F26Dot6 control_value_cutin;
TT_F26Dot6 single_width_cutin;
TT_F26Dot6 single_width_value;
TT_Short delta_base;
TT_Short delta_shift;
TT_Byte instruct_control;
TT_Bool scan_control;
TT_Int scan_type;
TT_UShort gep0;
TT_UShort gep1;
TT_UShort gep2;
} TT_GraphicsState;
/*************************************************************************/
/* */
/* 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_
{
TT_Byte* base;
TT_ULong size;
} TT_CodeRange;
typedef TT_CodeRange TT_CodeRangeTable[TT_MAX_CODE_RANGES];
/*************************************************************************/
/* */
/* Defines a function/instruction definition record. */
/* */
typedef struct TT_DefRecord_
{
TT_Int range; /* in which code range is it located? */
TT_Long start; /* where does it start? */
TT_UInt opc; /* function #, or instruction code */
TT_Bool active; /* is it active? */
} TT_DefRecord, *TT_DefArray;
/*************************************************************************/
/* */
/* This type defining a set of glyph points will be used to represent */
/* each zone (regular and twilight) during instructions decoding. */
/* */
typedef struct TT_GlyphZone_
{
TT_UShort n_points; /* number of points in zone */
TT_Short n_contours; /* number of contours */
TT_Vector* org; /* original point coordinates */
TT_Vector* cur; /* current point coordinates */
TT_Byte* touch; /* current touch flags */
TT_UShort* contours; /* contour end points */
} TT_GlyphZone;
/*************************************************************************/
/* */
/* Subglyph transformation record. */
/* */
typedef struct TT_Transform_
{
TT_Fixed xx, xy; /* transformation matrix coefficients */
TT_Fixed yx, yy;
TT_F26Dot6 ox, oy; /* offsets */
} TT_Transform;
/*************************************************************************/
/* */
/* Subglyph loading record. Used to load composite components. */
/* */
typedef struct TT_SubglyphRec_
{
TT_Long index; /* subglyph index; initialized with -1 */
TT_Bool is_scaled; /* is the subglyph scaled? */
TT_Bool is_hinted; /* should it be hinted? */
TT_Bool preserve_pps; /* preserve phantom points? */
TT_Long file_offset;
TT_BBox bbox;
TT_Pos left_bearing;
TT_Pos advance;
TT_GlyphZone zone;
TT_Long arg1; /* first argument */
TT_Long arg2; /* second argument */
TT_UShort element_flag; /* current load element flag */
TT_Transform transform; /* transformation matrix */
TT_Vector pp1, pp2; /* phantom points */
} TT_SubGlyphRec, *TT_SubGlyph_Stack;
/*************************************************************************/
/* */
/* 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 TIns_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 */
TT_Long x_ratio;
TT_Long y_ratio;
TT_UShort ppem; /* maximum ppem size */
TT_Long ratio; /* current ratio */
TT_Fixed scale;
TT_F26Dot6 compensations[4]; /* device-specific compensations */
TT_Bool valid;
TT_Bool rotated; /* `is the glyph rotated?'-flag */
TT_Bool stretched; /* `is the glyph stretched?'-flag */
} TT_Size_Metrics;
/*************************************************************************/
/* */
/* FreeType execution context type. */
/* */
/* This is a forward declaration; the full specification is in the file */
/* `ttinterp.h'. */
/* */
typedef struct TT_ExecContextRec_* TT_ExecContext;
/***********************************************************************/
/* */
/* TrueType size class. */
/* */
typedef struct TT_SizeRec_
{
FT_SizeRec root;
TT_Size_Metrics ttmetrics;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
TT_UInt num_function_defs; /* number of function definitions */
TT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */
TT_UInt num_instruction_defs; /* number of ins. definitions */
TT_UInt max_instruction_defs;
TT_DefArray instruction_defs; /* table of ins. definitions */
TT_UInt max_func;
TT_UInt max_ins;
TT_CodeRangeTable codeRangeTable;
TT_GraphicsState GS;
TT_ULong cvt_size; /* the scaled control value table */
TT_Long* cvt;
TT_UShort storage_size; /* The storage area is now part of */
TT_Long* storage; /* the instance */
TT_GlyphZone 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. */
TT_Bool debug;
TT_ExecContext context;
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
} TT_SizeRec;
/***********************************************************************/
/* */
/* TrueType driver class. */
/* */
typedef struct TT_DriverRec_
{
FT_DriverRec root;
TT_ExecContext context; /* execution context */
void* extension_component;
} TT_DriverRec;
/*************************************************************************/
/* */
/* <Function> */
/* TT_New_GlyphZone */
/* */
/* <Description> */
/* Allocates 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. */
/* */
/* <InOut> */
/* pts :: A pointer to the target glyph zone record. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_New_GlyphZone( FT_Memory memory,
TT_GlyphZone* pts,
TT_UShort maxPoints,
TT_Short maxContours );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_GlyphZone */
/* */
/* <Description> */
/* Deallocates a glyph zone. */
/* */
/* <Input> */
/* memory :: A handle to the current memory object. */
/* */
/* pts :: A pointer to the target glyph zone record. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_FUNC
TT_Error TT_Done_GlyphZone( FT_Memory memory,
TT_GlyphZone* pts );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Face */
/* */
/* <Description> */
/* Initializes a given TrueType face object. */
/* */
/* <Input> */
/* resource :: The source font resource. */
/* face_index :: The index of the font face in the resource. */
/* face :: The newly built face object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Init_Face( FT_Stream stream,
TT_Long face_index,
TT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Face */
/* */
/* <Description> */
/* Finalizes a given face object. */
/* */
/* <Input> */
/* face :: The target face object to finalize. */
/* */
LOCAL_DEF
void TT_Done_Face( TT_Face face );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Size */
/* */
/* <Description> */
/* Initializes a new TrueType size object. */
/* */
/* <Input> */
/* size :: A handle to the size object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Init_Size( TT_Size size );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Size */
/* */
/* <Description> */
/* The TrueType size object finalizer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_DEF
void TT_Done_Size( TT_Size size );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Reset_Size */
/* */
/* <Description> */
/* Resets a TrueType size when resolutions and character dimensions */
/* have been changed. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Reset_Size( TT_Size size );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_GlyphSlot */
/* */
/* <Description> */
/* The TrueType glyph slot initializer. */
/* */
/* <Input> */
/* glyph :: The glyph record to build. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Init_GlyphSlot( TT_GlyphSlot slot );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_GlyphSlot */
/* */
/* <Description> */
/* The TrueType glyph slot finalizer. */
/* */
/* <Input> */
/* glyph :: A handle to the glyph slot object. */
/* */
LOCAL_DEF
void TT_Done_GlyphSlot( TT_GlyphSlot slot );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Init_Driver */
/* */
/* <Description> */
/* Initializes a given TrueType driver object. */
/* */
/* <Input> */
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
/* TrueType error code. 0 means success. */
/* */
LOCAL_DEF
TT_Error TT_Init_Driver( TT_Driver driver );
/*************************************************************************/
/* */
/* <Function> */
/* TT_Done_Driver */
/* */
/* <Description> */
/* Finalizes a given TrueType driver. */
/* */
/* <Input> */
/* driver :: A handle to the target TrueType driver. */
/* */
LOCAL_DEF
void TT_Done_Driver( TT_Driver driver );
#ifdef __cplusplus
}
#endif
#endif /* TTOBJS_H */
/* END */