- introduced FT_Get_Glyph_Name (see freetype.h) to access individual glyph names. Changed some drivers to support it through a new interface named "glyph_name". - introduced FT_Get_Sfnt_Name (see ftnames.h) to access the SFNT name table in a TrueType/OpenType file..
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 598 599 600 601 602 603 604 605 606 607 608 609 610 611
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index dbc8e36..4439983 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -182,25 +182,6 @@
/*************************************************************************/
/* */
- /* 5-levels Anti Aliasing support */
- /* */
- /* FreeType 2 provides a new `smooth' renderer that is capable of */
- /* producing anti-aliased glyph bitmaps with up to 256 gray-levels. */
- /* */
- /* However, for compatibility purposes with FreeType 1.x, the standard */
- /* raster is still capable of generating anti-aliased bitmaps with */
- /* 5 gray levels. */
- /* */
- /* If you do not need this capability (i.e., if you always use the */
- /* `smooth' renderer for anti-aliased glyphs), we suggest you to */
- /* undefine this configuration macro, as it will save both code and */
- /* memory. */
- /* */
-#undef FT_CONFIG_OPTION_5_GRAY_LEVELS
-
-
- /*************************************************************************/
- /* */
/* Debug level */
/* */
/* FreeType can be compiled in debug or trace mode. In debug mode, */
@@ -294,6 +275,19 @@
/*************************************************************************/
+ /* */
+ /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */
+ /* access the internal name table in a SFNT-based format like TrueType */
+ /* or OpenType. The name table contains various strings used to */
+ /* describe the font, like family name, copyright, version, etc.. */
+ /* It does not contain any glyph name though.. */
+ /* */
+ /* Accessing sfnt names is done through the functions declared in */
+ /* <freetype/ftnames.h> */
+ /* */
+#define TT_CONFIG_OPTION_SFNT_NAMES
+
+ /*************************************************************************/
/*************************************************************************/
/**** ****/
/**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
@@ -365,7 +359,6 @@
/* */
#define T1_MAX_CHARSTRINGS_OPERANDS 32
-
/*************************************************************************/
/* */
/* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate a */
@@ -383,7 +376,6 @@
/* */
#undef T1_CONFIG_OPTION_NO_AFM
-
/*************************************************************************/
/* */
/* Define this configuration macro if you want to prevent the */
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index e5f4bd2..14953a8 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -768,6 +768,16 @@
/* */
#define FT_FACE_FLAG_MULTIPLE_MASTERS 0x100
+ /*************************************************************************/
+ /* */
+ /* <Constant> */
+ /* FT_FACE_FLAG_GLYPH_NAMES */
+ /* */
+ /* <Description> */
+ /* A bit-field constant, used to indicate that the font contains */
+ /* glyph names that can be retrieved through FT_Get_Glyph_Name. */
+ /* */
+#define FT_FACE_FLAG_GLYPH_NAMES 0x200
/*************************************************************************/
/* */
@@ -798,6 +808,8 @@
( face->face_flags & FT_FACE_FLAG_FIXED_SIZES )
#define FT_HAS_FAST_GLYPHS( face ) \
( face->face_flags & FT_FACE_FLAG_FAST_GLYPHS )
+#define FT_HAS_GLYPH_NAMES( face ) \
+ ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
#define FT_HAS_MULTIPLE_MASTERS( face ) \
( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
@@ -2039,6 +2051,47 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Get_Glyph_Name */
+ /* */
+ /* <Description> */
+ /* Retrieves the ASCII name of a given glyph in a face. This only */
+ /* works for those faces where FT_HAS_GLYPH_NAME(face) returns */
+ /* true. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a source face object. */
+ /* glyph_index :: the glyph index. */
+ /* */
+ /* buffer :: pointer to a target buffer where the name will be */
+ /* copied.. */
+ /* */
+ /* buffer_max :: the maximal number of bytes available in the buffer */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* An error is returned when the face doesn't provide glyph names */
+ /* or when the glyph index is invalid. In all cases of failure, the */
+ /* first byte of "buffer" will be set to 0 to indicate an empty */
+ /* name. */
+ /* */
+ /* The glyph name is truncated to fit within the buffer if it's too */
+ /* long. The returned string is always zero-terminated */
+ /* */
+ /* This function is not compiled within the library if the config */
+ /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
+ /* <freetype/config/ftoptions.h> */
+ /* */
+ FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph_Name( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max );
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Select_Charmap */
/* */
/* <Description> */
diff --git a/include/freetype/ftnames.h b/include/freetype/ftnames.h
new file mode 100644
index 0000000..394943c
--- /dev/null
+++ b/include/freetype/ftnames.h
@@ -0,0 +1,46 @@
+/***************************************************************************/
+/* */
+/* ftnames.h */
+/* */
+/* Simple interface to access SFNT name tables (which are used */
+/* to hold font names, copyright info, notices, etc..) */
+/* */
+/* This is _not_ used to retrieve glyph names !! */
+/* */
+/* Copyright 1996-2000 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 FTNAMES_H
+#define FTNAMES_H
+
+#include <freetype/freetype.h>
+
+ typedef struct FT_SfntName_
+ {
+ FT_UShort platform_id;
+ FT_UShort encoding_id;
+ FT_UShort language_id;
+ FT_UShort name_id;
+
+ FT_Byte* string;
+ FT_UInt string_len; /* in bytes */
+
+ } FT_SfntName;
+
+
+ FT_EXPORT_DEF(FT_UInt) FT_Get_Sfnt_Name_Count( FT_Face face );
+
+ FT_EXPORT_DEF(FT_Error) FT_Get_Sfnt_Name( FT_Face face,
+ FT_UInt index,
+ FT_SfntName* aname );
+
+
+#endif /* FTNAMES_H */
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index e08ea6e..912ed1e 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -372,7 +372,7 @@
/* managing and loading font files of a given format. */
/* */
/* <Fields> */
- /* root :: Contains the fields of the root module class. */
+ /* root :: contains the fields of the root module class */
/* */
/* clazz :: A pointer to the font driver's class. Note that */
/* this is NOT root.clazz. `class' wasn't used */
@@ -454,11 +454,14 @@
/* handle to the current renderer for the */
/* ft_glyph_format_outline format. */
/* */
+ /* raster_pool_size :: size of the render pool in bytes */
+ /* */
/* raster_pool :: The raster object's render pool. This can */
/* ideally be changed dynamically at run-time. */
/* */
- /* raster_pool_size :: The size of the render pool in bytes. */
/* */
+ /* */
+
typedef struct FT_LibraryRec_
{
FT_Memory memory; /* library's memory manager */
@@ -489,6 +492,11 @@
FT_GlyphSlot slot,
FT_UInt render_mode );
+ typedef FT_Error (*FT_Glyph_Name_Requester)( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max );
+
#ifndef FT_CONFIG_OPTION_NO_DEFAULT_SYSTEM
diff --git a/src/base/ftbase.c b/src/base/ftbase.c
index f9d9bbf..a110af4 100644
--- a/src/base/ftbase.c
+++ b/src/base/ftbase.c
@@ -24,17 +24,19 @@
#include "ftlist.c"
#include "ftoutln.c"
#include "ftextend.c"
+#include "ftnames.c"
-#else
+#else /* FT_FLAT_COMPILE */
-#include <ftcalc.c>
-#include <ftobjs.c>
-#include <ftstream.c>
-#include <ftlist.c>
-#include <ftoutln.c>
-#include <ftextend.c>
+#include <base/ftcalc.c>
+#include <base/ftobjs.c>
+#include <base/ftstream.c>
+#include <base/ftlist.c>
+#include <base/ftoutln.c>
+#include <base/ftextend.c>
+#include <base/ftnames.c>
-#endif
+#endif /* FT_FLAT_COMPILE */
/* END */
diff --git a/src/base/ftnames.c b/src/base/ftnames.c
new file mode 100644
index 0000000..b7f80df
--- /dev/null
+++ b/src/base/ftnames.c
@@ -0,0 +1,44 @@
+#include <freetype/ftnames.h>
+#include <freetype/internal/tttypes.h>
+
+#ifdef FT_CONFIG_OPTION_GLYPH_NAMES
+#endif /* FT_CONFIG_OPTION_GLYPH_NAMES */
+
+
+
+
+#ifdef FT_CONFIG_OPTION_SFNT_NAMES
+ FT_EXPORT_FUNC(FT_UInt) FT_Get_Sfnt_Name_Count( FT_Face face )
+ {
+ return ( face && FT_IS_SFNT(face) ? ((TT_Face)face)->num_names : 0 );
+ }
+
+
+ FT_EXPORT_FUNC(FT_Error) FT_Get_Sfnt_Name( FT_Face face,
+ FT_UInt index,
+ FT_SfntName* aname )
+ {
+ FT_Error error = FT_Err_Invalid_Argument;
+
+ if ( face && FT_IS_SFNT(face) )
+ {
+ TT_Face ttface = (TT_Face)face;
+
+ if (index < ttface->num_names)
+ {
+ TT_NameRec* name = ttface->name_table.names + index;
+
+ aname->platform_id = name->platformID;
+ aname->encoding_id = name->encodingID;
+ aname->language_id = name->languageID;
+ aname->name_id = name->nameID;
+ aname->string = (FT_Byte*)name->string;
+ aname->string_len = name->stringLength;
+
+ error = FT_Err_Ok;
+ }
+ }
+
+ return error;
+ }
+#endif /* FT_CONFIG_OPTION_SFNT_NAMES */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index bbfb362..84d2ca0 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2253,6 +2253,72 @@
/*************************************************************************/
/* */
/* <Function> */
+ /* FT_Get_Glyph_Name */
+ /* */
+ /* <Description> */
+ /* Retrieves the ASCII name of a given glyph in a face. This only */
+ /* works for those faces where FT_HAS_GLYPH_NAME(face) returns */
+ /* true. */
+ /* */
+ /* <Input> */
+ /* face :: A handle to a source face object. */
+ /* glyph_index :: the glyph index. */
+ /* */
+ /* buffer :: pointer to a target buffer where the name will be */
+ /* copied.. */
+ /* */
+ /* buffer_max :: the maximal number of bytes available in the buffer */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* An error is returned when the face doesn't provide glyph names */
+ /* or when the glyph index is invalid. In all cases of failure, the */
+ /* first byte of "buffer" will be set to 0 to indicate an empty */
+ /* name. */
+ /* */
+ /* The glyph name is truncated to fit within the buffer if it's too */
+ /* long. The returned string is always zero-terminated */
+ /* */
+ /* This function is not compiled within the library if the config */
+ /* macro FT_CONFIG_OPTION_NO_GLYPH_NAMES is defined in */
+ /* <freetype/config/ftoptions.h> */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Get_Glyph_Name( FT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max )
+ {
+ FT_Error error = FT_Err_Invalid_Argument;
+
+ /* clean up buffer */
+ if (buffer && buffer_max > 0)
+ ((FT_Byte*)buffer)[0] = 0;
+
+ if ( face && glyph_index < (FT_UInt)face->num_glyphs && FT_HAS_GLYPH_NAMES(face) )
+ {
+ /* now, lookup for glyph name */
+ FT_Driver driver = face->driver;
+ FT_Module_Class* clazz = FT_MODULE_CLASS(driver);
+
+ if (clazz->get_interface)
+ {
+ FT_Glyph_Name_Requester requester;
+
+ requester = (FT_Glyph_Name_Requester)
+ clazz->get_interface( FT_MODULE(driver), "glyph_name" );
+ if (requester)
+ error = requester( face, glyph_index, buffer, buffer_max );
+ }
+ }
+ return error;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
/* FT_Get_Sfnt_Table */
/* */
/* <Description> */
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 60e6045..ce7745b 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -89,6 +89,32 @@
}
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+ static
+ FT_Error get_sfnt_glyph_name( TT_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max )
+ {
+ FT_String* gname;
+ FT_Error error;
+
+ error = TT_Get_PS_Name( face, glyph_index, &gname );
+ if (!error && buffer_max > 0)
+ {
+ FT_UInt len = strlen( gname );
+
+ if (len >= buffer_max)
+ len = buffer_max-1;
+
+ MEM_Copy( buffer, gname, len );
+ ((FT_Byte*)buffer)[len] = 0;
+ }
+
+ return error;
+ }
+#endif
+
static
FT_Module_Interface SFNT_Get_Interface( FT_Module module,
const char* interface )
@@ -98,6 +124,10 @@
if ( strcmp( interface, "get_sfnt" ) == 0 )
return (FT_Module_Interface)get_sfnt_table;
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+ if ( strcmp( interface, "glyph_name" ) == 0 )
+ return (FT_Module_Interface)get_sfnt_glyph_name;
+#endif
return 0;
}
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 3557ffb..1f79db9 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -318,6 +318,12 @@
FT_FACE_FLAG_SFNT | /* SFNT file format */
FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
+#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
+ /* might need more polish to detect the presence of a Postscript name */
+ /* table in the font.. */
+ flags |= FT_FACE_FLAG_GLYPH_NAMES;
+#endif
+
/* fixed width font? */
if ( face->postscript.isFixedPitch )
flags |= FT_FACE_FLAG_FIXED_WIDTH;
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index 4aef164..3634399 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -106,6 +106,44 @@
#endif /* T1_CONFIG_OPTION_NO_AFM */
+ static
+ FT_Error get_t1_glyph_name( T1_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max )
+ {
+ FT_String* gname;
+
+ gname = face->type1.glyph_names[glyph_index];
+ if (buffer_max > 0)
+ {
+ FT_UInt len = strlen( gname );
+
+ if (len >= buffer_max)
+ len = buffer_max-1;
+
+ MEM_Copy( buffer, gname, len );
+ ((FT_Byte*)buffer)[len] = 0;
+ }
+
+ return 0;
+ }
+
+
+ static
+ FT_Module_Interface T1_Get_Interface( FT_Module module,
+ const char* interface )
+ {
+ FT_UNUSED( module );
+
+ if ( strcmp( interface, "glyph_name" ) == 0 )
+ return (FT_Module_Interface)get_t1_glyph_name;
+
+ return 0;
+ }
+
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -282,6 +320,7 @@
}
+
const FT_Driver_Class t1_driver_class =
{
{
@@ -296,11 +335,7 @@
(FT_Module_Constructor)0,
(FT_Module_Destructor) 0,
-#ifdef T1_CONFIG_OPTION_NO_AFM
- (FT_Module_Requester) Get_Interface
-#else
- (FT_Module_Requester) 0
-#endif
+ (FT_Module_Requester) T1_Get_Interface
},
sizeof( T1_FaceRec ),
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 0eeef8a..1e6f9ca 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -337,6 +337,8 @@
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+ root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
+
if ( type1->font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
diff --git a/src/type1z/z1driver.c b/src/type1z/z1driver.c
index 6d25b3c..ec854f9 100644
--- a/src/type1z/z1driver.c
+++ b/src/type1z/z1driver.c
@@ -50,6 +50,31 @@
#define FT_COMPONENT trace_z1driver
+
+ static
+ FT_Error get_z1_glyph_name( T1_Face face,
+ FT_UInt glyph_index,
+ FT_Pointer buffer,
+ FT_UInt buffer_max )
+ {
+ FT_String* gname;
+
+ gname = face->type1.glyph_names[glyph_index];
+ if (buffer_max > 0)
+ {
+ FT_UInt len = strlen( gname );
+
+ if (len >= buffer_max)
+ len = buffer_max-1;
+
+ MEM_Copy( buffer, gname, len );
+ ((FT_Byte*)buffer)[len] = 0;
+ }
+
+ return 0;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -84,6 +109,9 @@
FT_UNUSED( driver );
FT_UNUSED( interface );
+ if ( strcmp( (const char*)interface, "glyph_name" ) == 0 )
+ return (FT_Module_Interface)get_z1_glyph_name;
+
#ifndef Z1_CONFIG_OPTION_NO_MM_SUPPORT
if ( strcmp( (const char*)interface, "get_mm" ) == 0 )
return (FT_Module_Interface)Z1_Get_Multi_Master;
@@ -100,7 +128,6 @@
#ifndef Z1_CONFIG_OPTION_NO_AFM
-
/*************************************************************************/
/* */
/* <Function> */
diff --git a/src/type1z/z1objs.c b/src/type1z/z1objs.c
index 7e2f786..e452bb5 100644
--- a/src/type1z/z1objs.c
+++ b/src/type1z/z1objs.c
@@ -209,6 +209,8 @@
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
+ root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
+
if ( face->type1.font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;