0.2.0-dev Download ZIP
772 lines ·23.9 KB Raw
| 1 | /**************************************************************************** |
| 2 | * |
| 3 | * ttdriver.c |
| 4 | * |
| 5 | * TrueType font driver implementation (body). |
| 6 | * |
| 7 | * Copyright (C) 1996-2026 by |
| 8 | * David Turner, Robert Wilhelm, and Werner Lemberg. |
| 9 | * |
| 10 | * This file is part of the FreeType project, and may only be used, |
| 11 | * modified, and distributed under the terms of the FreeType project |
| 12 | * license, LICENSE.TXT. By continuing to use, modify, or distribute |
| 13 | * this file you indicate that you have read the license and |
| 14 | * understand and accept it fully. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | #include <freetype/internal/ftdebug.h> |
| 20 | #include <freetype/internal/ftstream.h> |
| 21 | #include <freetype/internal/sfnt.h> |
| 22 | #include <freetype/internal/services/svfntfmt.h> |
| 23 | |
| 24 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 25 | #include <freetype/ftmm.h> |
| 26 | #include <freetype/internal/services/svmm.h> |
| 27 | #include <freetype/internal/services/svmetric.h> |
| 28 | #endif |
| 29 | |
| 30 | #include <freetype/internal/services/svtteng.h> |
| 31 | #include <freetype/internal/services/svttglyf.h> |
| 32 | #include <freetype/internal/services/svprop.h> |
| 33 | #include <freetype/ftdriver.h> |
| 34 | |
| 35 | #ifdef TT_CONFIG_OPTION_VARC |
| 36 | #include <freetype/internal/services/svvarc.h> |
| 37 | #endif |
| 38 | |
| 39 | #include "ttdriver.h" |
| 40 | #include "ttgload.h" |
| 41 | #include "ttpload.h" |
| 42 | |
| 43 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 44 | #include "ttgxvar.h" |
| 45 | #endif |
| 46 | |
| 47 | #ifdef TT_CONFIG_OPTION_VARC |
| 48 | #include "ttvarc.h" |
| 49 | #endif |
| 50 | |
| 51 | #include "tterrors.h" |
| 52 | |
| 53 | |
| 54 | /************************************************************************** |
| 55 | * |
| 56 | * The macro FT_COMPONENT is used in trace mode. It is an implicit |
| 57 | * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log |
| 58 | * messages during execution. |
| 59 | */ |
| 60 | #undef FT_COMPONENT |
| 61 | #define FT_COMPONENT ttdriver |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | * PROPERTY SERVICE |
| 66 | * |
| 67 | */ |
| 68 | FT_CALLBACK_DEF( FT_Error ) |
| 69 | tt_property_set( FT_Module module, /* TT_Driver */ |
| 70 | const char* property_name, |
| 71 | const void* value, |
| 72 | FT_Bool value_is_string ) |
| 73 | { |
| 74 | FT_Error error = FT_Err_Ok; |
| 75 | TT_Driver driver = (TT_Driver)module; |
| 76 | |
| 77 | #ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES |
| 78 | FT_UNUSED( value_is_string ); |
| 79 | #endif |
| 80 | |
| 81 | |
| 82 | if ( !ft_strcmp( property_name, "interpreter-version" ) ) |
| 83 | { |
| 84 | FT_UInt interpreter_version; |
| 85 | |
| 86 | |
| 87 | #ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES |
| 88 | if ( value_is_string ) |
| 89 | { |
| 90 | const char* s = (const char*)value; |
| 91 | |
| 92 | |
| 93 | interpreter_version = (FT_UInt)ft_strtol( s, NULL, 10 ); |
| 94 | } |
| 95 | else |
| 96 | #endif |
| 97 | { |
| 98 | FT_UInt* iv = (FT_UInt*)value; |
| 99 | |
| 100 | |
| 101 | interpreter_version = *iv; |
| 102 | } |
| 103 | |
| 104 | switch ( interpreter_version ) |
| 105 | { |
| 106 | case TT_INTERPRETER_VERSION_35: |
| 107 | driver->interpreter_version = TT_INTERPRETER_VERSION_35; |
| 108 | break; |
| 109 | |
| 110 | case TT_INTERPRETER_VERSION_38: |
| 111 | case TT_INTERPRETER_VERSION_40: |
| 112 | #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL |
| 113 | driver->interpreter_version = TT_INTERPRETER_VERSION_40; |
| 114 | break; |
| 115 | #endif |
| 116 | |
| 117 | default: |
| 118 | error = FT_ERR( Unimplemented_Feature ); |
| 119 | } |
| 120 | |
| 121 | return error; |
| 122 | } |
| 123 | |
| 124 | FT_TRACE2(( "tt_property_set: missing property `%s'\n", |
| 125 | property_name )); |
| 126 | return FT_THROW( Missing_Property ); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | FT_CALLBACK_DEF( FT_Error ) |
| 131 | tt_property_get( FT_Module module, /* TT_Driver */ |
| 132 | const char* property_name, |
| 133 | void* value ) |
| 134 | { |
| 135 | FT_Error error = FT_Err_Ok; |
| 136 | TT_Driver driver = (TT_Driver)module; |
| 137 | |
| 138 | FT_UInt interpreter_version = driver->interpreter_version; |
| 139 | |
| 140 | |
| 141 | if ( !ft_strcmp( property_name, "interpreter-version" ) ) |
| 142 | { |
| 143 | FT_UInt* val = (FT_UInt*)value; |
| 144 | |
| 145 | |
| 146 | *val = interpreter_version; |
| 147 | |
| 148 | return error; |
| 149 | } |
| 150 | |
| 151 | FT_TRACE2(( "tt_property_get: missing property `%s'\n", |
| 152 | property_name )); |
| 153 | return FT_THROW( Missing_Property ); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | FT_DEFINE_SERVICE_PROPERTIESREC( |
| 158 | tt_service_properties, |
| 159 | |
| 160 | tt_property_set, /* FT_Properties_SetFunc set_property */ |
| 161 | tt_property_get /* FT_Properties_GetFunc get_property */ |
| 162 | ) |
| 163 | |
| 164 | |
| 165 | /*************************************************************************/ |
| 166 | /*************************************************************************/ |
| 167 | /*************************************************************************/ |
| 168 | /**** ****/ |
| 169 | /**** ****/ |
| 170 | /**** F A C E S ****/ |
| 171 | /**** ****/ |
| 172 | /**** ****/ |
| 173 | /*************************************************************************/ |
| 174 | /*************************************************************************/ |
| 175 | /*************************************************************************/ |
| 176 | |
| 177 | |
| 178 | /************************************************************************** |
| 179 | * |
| 180 | * @Function: |
| 181 | * tt_get_kerning |
| 182 | * |
| 183 | * @Description: |
| 184 | * A driver method used to return the kerning vector between two |
| 185 | * glyphs of the same face. |
| 186 | * |
| 187 | * @Input: |
| 188 | * face :: |
| 189 | * A handle to the source face object. |
| 190 | * |
| 191 | * left_glyph :: |
| 192 | * The index of the left glyph in the kern pair. |
| 193 | * |
| 194 | * right_glyph :: |
| 195 | * The index of the right glyph in the kern pair. |
| 196 | * |
| 197 | * @Output: |
| 198 | * kerning :: |
| 199 | * The kerning vector. This is in font units for |
| 200 | * scalable formats, and in pixels for fixed-sizes |
| 201 | * formats. |
| 202 | * |
| 203 | * @Return: |
| 204 | * FreeType error code. 0 means success. |
| 205 | * |
| 206 | * @Note: |
| 207 | * Only horizontal layouts (left-to-right & right-to-left) are |
| 208 | * supported by this function. Other layouts, or more sophisticated |
| 209 | * kernings, are out of scope of this method (the basic driver |
| 210 | * interface is meant to be simple). |
| 211 | * |
| 212 | * They can be implemented by format-specific interfaces. |
| 213 | */ |
| 214 | FT_CALLBACK_DEF( FT_Error ) |
| 215 | tt_get_kerning( FT_Face face, /* TT_Face */ |
| 216 | FT_UInt left_glyph, |
| 217 | FT_UInt right_glyph, |
| 218 | FT_Vector* kerning ) |
| 219 | { |
| 220 | TT_Face ttface = (TT_Face)face; |
| 221 | SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; |
| 222 | |
| 223 | |
| 224 | kerning->x = 0; |
| 225 | kerning->y = 0; |
| 226 | |
| 227 | if ( sfnt ) |
| 228 | { |
| 229 | /* Use 'kern' table if available since that can be faster; otherwise */ |
| 230 | /* use GPOS kerning pairs if available. */ |
| 231 | if ( ttface->kern_avail_bits ) |
| 232 | kerning->x = sfnt->get_kerning( ttface, |
| 233 | left_glyph, |
| 234 | right_glyph ); |
| 235 | #ifdef TT_CONFIG_OPTION_GPOS_KERNING |
| 236 | else if ( ttface->num_gpos_lookups_kerning ) |
| 237 | kerning->x = sfnt->get_gpos_kerning( ttface, |
| 238 | left_glyph, |
| 239 | right_glyph ); |
| 240 | #endif |
| 241 | } |
| 242 | |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | |
| 247 | FT_CALLBACK_DEF( FT_Error ) |
| 248 | tt_get_advances( FT_Face face, /* TT_Face */ |
| 249 | FT_UInt start, |
| 250 | FT_UInt count, |
| 251 | FT_Int32 flags, |
| 252 | FT_Fixed *advances ) |
| 253 | { |
| 254 | FT_UInt nn; |
| 255 | TT_Face ttface = (TT_Face)face; |
| 256 | |
| 257 | |
| 258 | /* XXX: TODO: check for sbits */ |
| 259 | |
| 260 | if ( flags & FT_LOAD_VERTICAL_LAYOUT ) |
| 261 | { |
| 262 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 263 | /* no fast retrieval for blended MM fonts without VVAR table */ |
| 264 | if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && |
| 265 | !( ttface->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) |
| 266 | return FT_THROW( Unimplemented_Feature ); |
| 267 | #endif |
| 268 | |
| 269 | for ( nn = 0; nn < count; nn++ ) |
| 270 | { |
| 271 | FT_Short tsb; |
| 272 | FT_UShort ah; |
| 273 | |
| 274 | |
| 275 | /* since we don't need `tsb', we use zero for `yMax' parameter */ |
| 276 | TT_Get_VMetrics( ttface, start + nn, 0, &tsb, &ah ); |
| 277 | advances[nn] = ah; |
| 278 | } |
| 279 | } |
| 280 | else |
| 281 | { |
| 282 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 283 | /* no fast retrieval for blended MM fonts without HVAR table */ |
| 284 | if ( ( FT_IS_NAMED_INSTANCE( face ) || FT_IS_VARIATION( face ) ) && |
| 285 | !( ttface->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) |
| 286 | return FT_THROW( Unimplemented_Feature ); |
| 287 | #endif |
| 288 | |
| 289 | for ( nn = 0; nn < count; nn++ ) |
| 290 | { |
| 291 | FT_Short lsb; |
| 292 | FT_UShort aw; |
| 293 | |
| 294 | |
| 295 | TT_Get_HMetrics( ttface, start + nn, &lsb, &aw ); |
| 296 | advances[nn] = aw; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return FT_Err_Ok; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | /*************************************************************************/ |
| 305 | /*************************************************************************/ |
| 306 | /*************************************************************************/ |
| 307 | /**** ****/ |
| 308 | /**** ****/ |
| 309 | /**** S I Z E S ****/ |
| 310 | /**** ****/ |
| 311 | /**** ****/ |
| 312 | /*************************************************************************/ |
| 313 | /*************************************************************************/ |
| 314 | /*************************************************************************/ |
| 315 | |
| 316 | |
| 317 | #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS |
| 318 | |
| 319 | FT_CALLBACK_DEF( FT_Error ) |
| 320 | tt_size_select( FT_Size size, |
| 321 | FT_ULong strike_index ) |
| 322 | { |
| 323 | TT_Face ttface = (TT_Face)size->face; |
| 324 | TT_Size ttsize = (TT_Size)size; |
| 325 | FT_Error error = FT_Err_Ok; |
| 326 | |
| 327 | |
| 328 | ttsize->strike_index = strike_index; |
| 329 | |
| 330 | if ( FT_IS_SCALABLE( size->face ) ) |
| 331 | { |
| 332 | /* use the scaled metrics, even when tt_size_reset fails */ |
| 333 | FT_Select_Metrics( size->face, strike_index ); |
| 334 | |
| 335 | tt_size_reset( ttsize ); /* ignore return value */ |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; |
| 340 | FT_Size_Metrics* size_metrics = &size->metrics; |
| 341 | |
| 342 | |
| 343 | error = sfnt->load_strike_metrics( ttface, |
| 344 | strike_index, |
| 345 | size_metrics ); |
| 346 | if ( error ) |
| 347 | ttsize->strike_index = 0xFFFFFFFFUL; |
| 348 | } |
| 349 | |
| 350 | return error; |
| 351 | } |
| 352 | |
| 353 | #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ |
| 354 | |
| 355 | |
| 356 | FT_CALLBACK_DEF( FT_Error ) |
| 357 | tt_size_request( FT_Size size, |
| 358 | FT_Size_Request req ) |
| 359 | { |
| 360 | TT_Size ttsize = (TT_Size)size; |
| 361 | FT_Error error = FT_Err_Ok; |
| 362 | |
| 363 | |
| 364 | #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS |
| 365 | |
| 366 | if ( FT_HAS_FIXED_SIZES( size->face ) ) |
| 367 | { |
| 368 | TT_Face ttface = (TT_Face)size->face; |
| 369 | SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; |
| 370 | FT_ULong strike_index; |
| 371 | |
| 372 | |
| 373 | error = sfnt->set_sbit_strike( ttface, req, &strike_index ); |
| 374 | |
| 375 | if ( error ) |
| 376 | ttsize->strike_index = 0xFFFFFFFFUL; |
| 377 | else |
| 378 | return tt_size_select( size, strike_index ); |
| 379 | } |
| 380 | |
| 381 | #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ |
| 382 | |
| 383 | { |
| 384 | FT_Error err = FT_Request_Metrics( size->face, req ); |
| 385 | |
| 386 | |
| 387 | if ( err ) |
| 388 | { |
| 389 | error = err; |
| 390 | goto Exit; |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | if ( FT_IS_SCALABLE( size->face ) ) |
| 395 | { |
| 396 | error = tt_size_reset( ttsize ); |
| 397 | |
| 398 | #ifdef TT_USE_BYTECODE_INTERPRETER |
| 399 | /* for the `MPS' bytecode instruction we need the point size */ |
| 400 | if ( !error ) |
| 401 | { |
| 402 | FT_UInt resolution = |
| 403 | ttsize->metrics->x_ppem > ttsize->metrics->y_ppem |
| 404 | ? req->horiResolution |
| 405 | : req->vertResolution; |
| 406 | |
| 407 | |
| 408 | /* if we don't have a resolution value, assume 72dpi */ |
| 409 | if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES || |
| 410 | !resolution ) |
| 411 | resolution = 72; |
| 412 | |
| 413 | ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem, |
| 414 | 64 * 72, |
| 415 | resolution ); |
| 416 | } |
| 417 | #endif |
| 418 | } |
| 419 | |
| 420 | Exit: |
| 421 | return error; |
| 422 | } |
| 423 | |
| 424 | |
| 425 | /************************************************************************** |
| 426 | * |
| 427 | * @Function: |
| 428 | * tt_glyph_load |
| 429 | * |
| 430 | * @Description: |
| 431 | * A driver method used to load a glyph within a given glyph slot. |
| 432 | * |
| 433 | * @Input: |
| 434 | * slot :: |
| 435 | * A handle to the target slot object where the glyph |
| 436 | * will be loaded. |
| 437 | * |
| 438 | * size :: |
| 439 | * A handle to the source face size at which the glyph |
| 440 | * must be scaled, loaded, etc. |
| 441 | * |
| 442 | * glyph_index :: |
| 443 | * The index of the glyph in the font file. |
| 444 | * |
| 445 | * load_flags :: |
| 446 | * A flag indicating what to load for this glyph. The |
| 447 | * FT_LOAD_XXX constants can be used to control the |
| 448 | * glyph loading process (e.g., whether the outline |
| 449 | * should be scaled, whether to load bitmaps or not, |
| 450 | * whether to hint the outline, etc). |
| 451 | * |
| 452 | * @Return: |
| 453 | * FreeType error code. 0 means success. |
| 454 | */ |
| 455 | FT_CALLBACK_DEF( FT_Error ) |
| 456 | tt_glyph_load( FT_GlyphSlot slot, /* TT_GlyphSlot */ |
| 457 | FT_Size size, /* TT_Size */ |
| 458 | FT_UInt glyph_index, |
| 459 | FT_Int32 load_flags ) |
| 460 | { |
| 461 | TT_GlyphSlot ttslot = (TT_GlyphSlot)slot; |
| 462 | TT_Size ttsize = (TT_Size)size; |
| 463 | FT_Face face = ttslot->face; |
| 464 | FT_Error error; |
| 465 | |
| 466 | |
| 467 | #ifdef FT_CONFIG_OPTION_INCREMENTAL |
| 468 | if ( glyph_index >= (FT_UInt)face->num_glyphs && |
| 469 | !face->internal->incremental_interface ) |
| 470 | #else |
| 471 | if ( glyph_index >= (FT_UInt)face->num_glyphs ) |
| 472 | #endif |
| 473 | return FT_THROW( Invalid_Argument ); |
| 474 | |
| 475 | if ( load_flags & FT_LOAD_NO_HINTING ) |
| 476 | { |
| 477 | /* both FT_LOAD_NO_HINTING and FT_LOAD_NO_AUTOHINT */ |
| 478 | /* are necessary to disable hinting for tricky fonts */ |
| 479 | |
| 480 | if ( FT_IS_TRICKY( face ) ) |
| 481 | load_flags &= ~FT_LOAD_NO_HINTING; |
| 482 | |
| 483 | if ( load_flags & FT_LOAD_NO_AUTOHINT ) |
| 484 | load_flags |= FT_LOAD_NO_HINTING; |
| 485 | } |
| 486 | |
| 487 | if ( load_flags & ( FT_LOAD_NO_RECURSE | FT_LOAD_NO_SCALE ) ) |
| 488 | { |
| 489 | load_flags |= FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE; |
| 490 | |
| 491 | if ( !FT_IS_TRICKY( face ) ) |
| 492 | load_flags |= FT_LOAD_NO_HINTING; |
| 493 | } |
| 494 | |
| 495 | #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL |
| 496 | /* |
| 497 | * DirectWrite treats ClearType symmetric grid fitting independently |
| 498 | * from symmetric smoothing. Resolve the grid-fitting decision from the |
| 499 | * same policy source that GETINFO uses for symmetric smoothing. |
| 500 | * |
| 501 | * Only native v40 horizontal-LCD hinting participates. Caller-disabled |
| 502 | * native hinting and the other interpreter/rendering modes are left |
| 503 | * alone. |
| 504 | */ |
| 505 | if ( FT_LOAD_TARGET_MODE( load_flags ) == FT_RENDER_MODE_LCD && |
| 506 | !( load_flags & FT_LOAD_NO_HINTING ) && |
| 507 | !FT_IS_TRICKY( face ) ) |
| 508 | { |
| 509 | TT_Driver driver = (TT_Driver)FT_FACE_DRIVER( face ); |
| 510 | |
| 511 | |
| 512 | if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 ) |
| 513 | { |
| 514 | FT_Bool grid_fit; |
| 515 | |
| 516 | |
| 517 | tt_face_get_cleartype_policy( (TT_Face)face, |
| 518 | size->metrics.y_ppem, |
| 519 | NULL, |
| 520 | &grid_fit ); |
| 521 | |
| 522 | if ( !grid_fit ) |
| 523 | load_flags |= FT_LOAD_NO_HINTING; |
| 524 | } |
| 525 | } |
| 526 | #endif |
| 527 | |
| 528 | /* use hinted metrics only if we load a glyph with hinting */ |
| 529 | ttsize->metrics = ( load_flags & FT_LOAD_NO_HINTING ) |
| 530 | ? &size->metrics |
| 531 | : &ttsize->hinted_metrics; |
| 532 | |
| 533 | /* now fill in the glyph slot with outline/bitmap/layered */ |
| 534 | error = TT_Load_Glyph( ttsize, ttslot, glyph_index, load_flags ); |
| 535 | |
| 536 | /* force drop-out mode to 2 - irrelevant now */ |
| 537 | /* slot->outline.dropout_mode = 2; */ |
| 538 | |
| 539 | return error; |
| 540 | } |
| 541 | |
| 542 | |
| 543 | /*************************************************************************/ |
| 544 | /*************************************************************************/ |
| 545 | /*************************************************************************/ |
| 546 | /**** ****/ |
| 547 | /**** ****/ |
| 548 | /**** D R I V E R I N T E R F A C E ****/ |
| 549 | /**** ****/ |
| 550 | /**** ****/ |
| 551 | /*************************************************************************/ |
| 552 | /*************************************************************************/ |
| 553 | /*************************************************************************/ |
| 554 | |
| 555 | #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT |
| 556 | |
| 557 | FT_DEFINE_SERVICE_MULTIMASTERSREC( |
| 558 | tt_service_gx_multi_masters, |
| 559 | |
| 560 | NULL, /* FT_Get_MM_Func get_mm */ |
| 561 | NULL, /* FT_Set_MM_Design_Func set_mm_design */ |
| 562 | TT_Set_MM_Blend, /* FT_Set_MM_Blend_Func set_mm_blend */ |
| 563 | TT_Get_MM_Blend, /* FT_Get_MM_Blend_Func get_mm_blend */ |
| 564 | TT_Get_MM_Var, /* FT_Get_MM_Var_Func get_mm_var */ |
| 565 | TT_Set_Var_Design, /* FT_Set_Var_Design_Func set_var_design */ |
| 566 | TT_Get_Var_Design, /* FT_Get_Var_Design_Func get_var_design */ |
| 567 | TT_Set_Named_Instance, /* FT_Set_Named_Instance_Func set_named_instance */ |
| 568 | TT_Get_Default_Named_Instance, |
| 569 | /* FT_Get_Default_Named_Instance_Func get_default_named_instance */ |
| 570 | NULL, /* FT_Set_MM_WeightVector_Func set_mm_weightvector */ |
| 571 | NULL, /* FT_Get_MM_WeightVector_Func get_mm_weightvector */ |
| 572 | |
| 573 | tt_construct_ps_name, /* FT_Construct_PS_Name_Func construct_ps_name */ |
| 574 | tt_var_load_delta_set_index_mapping, |
| 575 | /* FT_Var_Load_Delta_Set_Idx_Map_Func load_delta_set_idx_map */ |
| 576 | tt_var_load_item_variation_store, |
| 577 | /* FT_Var_Load_Item_Var_Store_Func load_item_variation_store */ |
| 578 | tt_var_get_item_delta, /* FT_Var_Get_Item_Delta_Func get_item_delta */ |
| 579 | tt_var_done_item_variation_store, |
| 580 | /* FT_Var_Done_Item_Var_Store_Func done_item_variation_store */ |
| 581 | tt_var_done_delta_set_index_map, |
| 582 | /* FT_Var_Done_Delta_Set_Idx_Map_Func done_delta_set_index_map */ |
| 583 | tt_get_var_blend, /* FT_Get_Var_Blend_Func get_var_blend */ |
| 584 | tt_done_blend /* FT_Done_Blend_Func done_blend */ |
| 585 | ) |
| 586 | |
| 587 | FT_DEFINE_SERVICE_METRICSVARIATIONSREC( |
| 588 | tt_service_metrics_variations, |
| 589 | |
| 590 | tt_hadvance_adjust, /* FT_HAdvance_Adjust_Func hadvance_adjust */ |
| 591 | NULL, /* FT_LSB_Adjust_Func lsb_adjust */ |
| 592 | NULL, /* FT_RSB_Adjust_Func rsb_adjust */ |
| 593 | |
| 594 | tt_vadvance_adjust, /* FT_VAdvance_Adjust_Func vadvance_adjust */ |
| 595 | NULL, /* FT_TSB_Adjust_Func tsb_adjust */ |
| 596 | NULL, /* FT_BSB_Adjust_Func bsb_adjust */ |
| 597 | NULL, /* FT_VOrg_Adjust_Func vorg_adjust */ |
| 598 | |
| 599 | tt_apply_mvar, /* FT_Metrics_Adjust_Func metrics_adjust */ |
| 600 | tt_size_reset_height /* FT_Size_Reset_Func size_reset */ |
| 601 | ) |
| 602 | |
| 603 | #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ |
| 604 | |
| 605 | |
| 606 | #ifdef TT_CONFIG_OPTION_VARC |
| 607 | |
| 608 | FT_DEFINE_SERVICE_VARCREC( |
| 609 | tt_service_varc, |
| 610 | |
| 611 | tt_face_init_varc_axes, |
| 612 | tt_face_load_varc, |
| 613 | tt_face_free_varc, |
| 614 | tt_face_has_varc_glyph, |
| 615 | tt_face_load_varc_glyph |
| 616 | ) |
| 617 | |
| 618 | #endif /* TT_CONFIG_OPTION_VARC */ |
| 619 | |
| 620 | |
| 621 | static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine = |
| 622 | { |
| 623 | #ifdef TT_USE_BYTECODE_INTERPRETER |
| 624 | |
| 625 | FT_TRUETYPE_ENGINE_TYPE_PATENTED |
| 626 | |
| 627 | #else /* !TT_USE_BYTECODE_INTERPRETER */ |
| 628 | |
| 629 | FT_TRUETYPE_ENGINE_TYPE_NONE |
| 630 | |
| 631 | #endif /* TT_USE_BYTECODE_INTERPRETER */ |
| 632 | }; |
| 633 | |
| 634 | |
| 635 | FT_DEFINE_SERVICE_TTGLYFREC( |
| 636 | tt_service_truetype_glyf, |
| 637 | |
| 638 | (TT_Glyf_GetLocationFunc)tt_face_get_location /* get_location */ |
| 639 | ) |
| 640 | |
| 641 | |
| 642 | #if defined( TT_CONFIG_OPTION_GX_VAR_SUPPORT ) && \ |
| 643 | defined( TT_CONFIG_OPTION_VARC ) |
| 644 | FT_DEFINE_SERVICEDESCREC7( |
| 645 | tt_services, |
| 646 | |
| 647 | FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, |
| 648 | FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters, |
| 649 | FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations, |
| 650 | FT_SERVICE_ID_VARC, &tt_service_varc, |
| 651 | FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, |
| 652 | FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, |
| 653 | FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) |
| 654 | #elif defined( TT_CONFIG_OPTION_GX_VAR_SUPPORT ) |
| 655 | FT_DEFINE_SERVICEDESCREC6( |
| 656 | tt_services, |
| 657 | |
| 658 | FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, |
| 659 | FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters, |
| 660 | FT_SERVICE_ID_METRICS_VARIATIONS, &tt_service_metrics_variations, |
| 661 | FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, |
| 662 | FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, |
| 663 | FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) |
| 664 | #elif defined( TT_CONFIG_OPTION_VARC ) |
| 665 | FT_DEFINE_SERVICEDESCREC5( |
| 666 | tt_services, |
| 667 | |
| 668 | FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, |
| 669 | FT_SERVICE_ID_VARC, &tt_service_varc, |
| 670 | FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, |
| 671 | FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, |
| 672 | FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) |
| 673 | #else |
| 674 | FT_DEFINE_SERVICEDESCREC4( |
| 675 | tt_services, |
| 676 | |
| 677 | FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_TRUETYPE, |
| 678 | FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, |
| 679 | FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf, |
| 680 | FT_SERVICE_ID_PROPERTIES, &tt_service_properties ) |
| 681 | #endif |
| 682 | |
| 683 | |
| 684 | FT_CALLBACK_DEF( FT_Module_Interface ) |
| 685 | tt_get_interface( FT_Module driver, /* TT_Driver */ |
| 686 | const char* tt_interface ) |
| 687 | { |
| 688 | FT_Library library; |
| 689 | FT_Module_Interface result; |
| 690 | FT_Module sfntd; |
| 691 | SFNT_Service sfnt; |
| 692 | |
| 693 | |
| 694 | result = ft_service_list_lookup( tt_services, tt_interface ); |
| 695 | if ( result ) |
| 696 | return result; |
| 697 | |
| 698 | if ( !driver ) |
| 699 | return NULL; |
| 700 | library = driver->library; |
| 701 | if ( !library ) |
| 702 | return NULL; |
| 703 | |
| 704 | /* only return the default interface from the SFNT module */ |
| 705 | sfntd = FT_Get_Module( library, "sfnt" ); |
| 706 | if ( sfntd ) |
| 707 | { |
| 708 | sfnt = (SFNT_Service)( sfntd->clazz->module_interface ); |
| 709 | if ( sfnt ) |
| 710 | return sfnt->get_interface( driver, tt_interface ); |
| 711 | } |
| 712 | |
| 713 | return 0; |
| 714 | } |
| 715 | |
| 716 | |
| 717 | /* The FT_DriverInterface structure is defined in ftdriver.h. */ |
| 718 | |
| 719 | #ifdef TT_USE_BYTECODE_INTERPRETER |
| 720 | #define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER |
| 721 | #else |
| 722 | #define TT_HINTER_FLAG 0 |
| 723 | #endif |
| 724 | |
| 725 | #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS |
| 726 | #define TT_SIZE_SELECT tt_size_select |
| 727 | #else |
| 728 | #define TT_SIZE_SELECT 0 |
| 729 | #endif |
| 730 | |
| 731 | FT_DEFINE_DRIVER( |
| 732 | tt_driver_class, |
| 733 | |
| 734 | FT_MODULE_FONT_DRIVER | |
| 735 | FT_MODULE_DRIVER_SCALABLE | |
| 736 | TT_HINTER_FLAG, |
| 737 | |
| 738 | sizeof ( TT_DriverRec ), |
| 739 | |
| 740 | "truetype", /* driver name */ |
| 741 | 0x10000L, /* driver version == 1.0 */ |
| 742 | 0x20000L, /* driver requires FreeType 2.0 or above */ |
| 743 | |
| 744 | NULL, /* module-specific interface */ |
| 745 | |
| 746 | tt_driver_init, /* FT_Module_Constructor module_init */ |
| 747 | tt_driver_done, /* FT_Module_Destructor module_done */ |
| 748 | tt_get_interface, /* FT_Module_Requester get_interface */ |
| 749 | |
| 750 | sizeof ( TT_FaceRec ), |
| 751 | sizeof ( TT_SizeRec ), |
| 752 | sizeof ( FT_GlyphSlotRec ), |
| 753 | |
| 754 | tt_face_init, /* FT_Face_InitFunc init_face */ |
| 755 | tt_face_done, /* FT_Face_DoneFunc done_face */ |
| 756 | tt_size_init, /* FT_Size_InitFunc init_size */ |
| 757 | tt_size_done, /* FT_Size_DoneFunc done_size */ |
| 758 | tt_slot_init, /* FT_Slot_InitFunc init_slot */ |
| 759 | NULL, /* FT_Slot_DoneFunc done_slot */ |
| 760 | |
| 761 | tt_glyph_load, /* FT_Slot_LoadFunc load_glyph */ |
| 762 | |
| 763 | tt_get_kerning, /* FT_Face_GetKerningFunc get_kerning */ |
| 764 | NULL, /* FT_Face_AttachFunc attach_file */ |
| 765 | tt_get_advances, /* FT_Face_GetAdvancesFunc get_advances */ |
| 766 | |
| 767 | tt_size_request, /* FT_Size_RequestFunc request_size */ |
| 768 | TT_SIZE_SELECT /* FT_Size_SelectFunc select_size */ |
| 769 | ) |
| 770 | |
| 771 | |
| 772 | /* END */ |