Minor cleanups.
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
diff --git a/ChangeLog b/ChangeLog
index e38f749..d919942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,30 +17,64 @@
2003-04-25: Graham Asher <graham.asher@btinternet.com>
- Added the optional unpatented hinting system for TrueType. It
+ Added the optional unpatented hinting system for TrueType. It
allows typefaces which need hinting to produce correct glyph forms
(e.g., Chinese typefaces from Dynalab) to work acceptably without
- infringing Apple patents. This system is compiled only if
+ infringing Apple patents. This system is compiled only if
TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING is defined in
ftoption.h.
- * include/freetype/ttunpat.h: added header file ttunpat.h defining
+ * include/freetype/ttunpat.h: New file. Defines
FT_PARAM_TAG_UNPATENTED_HINTING.
- * include/freetype/config/ftheader.h: Added macro FT_UNPATENTED_H
- to use when including new header ttunpat.h.
+ * include/freetype/config/ftheader.h (FT_TRUETYPE_UNPATENTED_H): New
+ macro to use when including ttunpat.h.
- * include/freetype/config/ftoption.h: Added configuration macros
+ * include/freetype/config/ftoption.h
+ (TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING,
+ TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING): New configuration macros
(not defined, but in comments) for the unpatented hinting system.
- * include/freetype/internal/tttypes.h: If unpatented hinting is
- compiled the TrueType face object acquires a new element,
- "FT_Bool unpatented_hinting".
+ * include/freetype/internal/tttypes.h (TT_FaceRec)
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: New element "FT_Bool
+ unpatented_hinting".
- * src/truetype/ttinterp.c, ttobjs.c, ttobjs.h: Added the unpatented
- hinting system, which is compiled only if
- TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING is defined in
- ftoption.h.
+ * src/truetype/ttinterp.c (NO_APPLE_PATENT, APPLE_THRESHOLD):
+ Removed.
+ (GUESS_VECTOR): New macro.
+ (TT_Run_Context) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
+ Set `both_x_axis'.
+ (tt_default_graphics_state)
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Updated.
+ (Current_Ratio) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
+ Handle `unpatented_hinting'.
+ (Direct_Move) [NO_APPLE_PATENT]: Removed.
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Insert assertion.
+ (Project, FreeProject)
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Insert assertion.
+ (Compute_Funcs) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
+ Implement unpatented hinting.
+ (DO_SPVTCA, DO_SFVTCA, DO_SPVTL, DO_SFVTL, DO_SPVFS, DO_SFVFS,
+ Ins_SDPVTL): Call `GUESS_VECTOR'.
+ (DO_GPV, DO_GFV) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]:
+ Handle `unpatented_hinting'.
+ (Compute_Point_Displacement) [NO_APPLE_PATENT]: Removed.
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Implement unpatented
+ hinting.
+ (Move_Zp2_Point, Ins_SHPIX, Ins_DELTAP, Ins_DELTAC)
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Implement unpatented
+ hinting.
+ (TT_RunIns): Updated.
+
+ * src/truetype/ttobjs.c
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Include
+ FT_TRUETYPE_UNPATENTED_H.
+ (tt_face_init) [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING,
+ TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING]: Check
+ FT_PARAM_TAG_UNPATENTED_HINTING.
+
+ * src/truetype/ttobjs.h (TT_GraphicsState)
+ [TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING]: Add `both_x_axis'.
2003-04-25 Werner Lemberg <wl@gnu.org>
diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h
index 6b4ae8f..dcf526e 100644
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -392,7 +392,7 @@ FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING to compile the */
- /* unpatented work-around hinting system. You must define this if you */
+ /* unpatented work-around hinting system. You must define this if you */
/* want either to force the use of the unpatented hinting system by also */
/* defining TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING, or if you want to */
/* select it at run time using the FT_PARAM_TAG_UNPATENTED_HINTING tag. */
@@ -405,7 +405,7 @@ FT_BEGIN_HEADER
/* Define TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING to restrict the */
/* TrueType bytecode interpreter to actions not protected by patents. */
/* This enables some fonts, for example mingliu.ttc from Dynalab, to */
- /* work properly. They use hinting to make large changes to the glyph */
+ /* work properly. They use hinting to make large changes to the glyph */
/* shape, without which the glyph is unrecognisable. */
/* For this to work you must also define */
/* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING. */
diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h
index 0bcd201..cdb2972 100644
--- a/include/freetype/internal/tttypes.h
+++ b/include/freetype/internal/tttypes.h
@@ -1564,7 +1564,7 @@ FT_BEGIN_HEADER
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Use unpatented hinting only. */
- FT_Bool unpatented_hinting;
+ FT_Bool unpatented_hinting;
#endif
/***********************************************************************/
diff --git a/include/freetype/ttunpat.h b/include/freetype/ttunpat.h
index a3590ad..4902001 100644
--- a/include/freetype/ttunpat.h
+++ b/include/freetype/ttunpat.h
@@ -4,9 +4,11 @@
/* */
/* Definitions for the unpatented TrueType hinting system */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
+/* Written by Graham Asher <graham.asher@btinternet.com> */
+/* */
/* 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 */
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index b4a25e1..b305ce6 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -225,11 +225,11 @@
#define FAILURE 1
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
-#define GUESS_VECTOR( V ) \
- if ( CUR.face->unpatented_hinting ) \
- { \
- CUR.GS.V.x = (FT_F2Dot14)(CUR.GS.both_x_axis ? 0x4000 : 0); \
- CUR.GS.V.y = (FT_F2Dot14)(CUR.GS.both_x_axis ? 0 : 0x4000); \
+#define GUESS_VECTOR( V ) \
+ if ( CUR.face->unpatented_hinting ) \
+ { \
+ CUR.GS.V.x = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0x4000 : 0 ); \
+ CUR.GS.V.y = (FT_F2Dot14)( CUR.GS.both_x_axis ? 0 : 0x4000 ); \
}
#else
#define GUESS_VECTOR( V )
@@ -758,7 +758,7 @@
{ 0x4000, 0 },
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- TRUE,
+ TRUE,
#endif
1, 64, 1,
@@ -1371,7 +1371,7 @@
}
else
#endif
- {
+ {
if ( CUR.GS.projVector.y == 0 )
CUR.tt_metrics.ratio = CUR.tt_metrics.x_ratio;
@@ -1382,12 +1382,15 @@
{
FT_Long x, y;
- x = TT_MULDIV( CUR.GS.projVector.x, CUR.tt_metrics.x_ratio, 0x4000 );
- y = TT_MULDIV( CUR.GS.projVector.y, CUR.tt_metrics.y_ratio, 0x4000 );
+
+ x = TT_MULDIV( CUR.GS.projVector.x,
+ CUR.tt_metrics.x_ratio, 0x4000 );
+ y = TT_MULDIV( CUR.GS.projVector.y,
+ CUR.tt_metrics.y_ratio, 0x4000 );
CUR.tt_metrics.ratio = TT_VecLen( x, y );
}
- }
- }
+ }
+ }
return CUR.tt_metrics.ratio;
}
@@ -1555,11 +1558,11 @@
FT_UShort point,
FT_F26Dot6 distance )
{
-
FT_F26Dot6 v;
+
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- FT_ASSERT(!CUR.face->unpatented_hinting);
+ FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
v = CUR.GS.freeVector.x;
@@ -1585,7 +1588,6 @@
zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y;
}
-
}
@@ -2124,8 +2126,9 @@
FT_Vector* v2 )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- FT_ASSERT(!CUR.face->unpatented_hinting);
+ FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
+
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
CUR.GS.projVector.x,
@@ -2180,7 +2183,7 @@
FT_Vector* v2 )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- FT_ASSERT(!CUR.face->unpatented_hinting);
+ FT_ASSERT( !CUR.face->unpatented_hinting );
#endif
return TT_DotFix14( v1->x - v2->x,
v1->y - v2->y,
@@ -2188,6 +2191,7 @@
CUR.GS.freeVector.y );
}
+
/*************************************************************************/
/* */
/* <Function> */
@@ -2254,16 +2258,17 @@
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
if ( CUR.face->unpatented_hinting )
- {
+ {
/* If both vectors point rightwards along the x axis, set */
- /* 'both-x-axis' true, otherwise set it false. The x values only */
- /* need be tested because the vector has been normalised to a unit */
- /* vector of length 0x4000 = unity. */
- CUR.GS.both_x_axis = (FT_Bool)(CUR.GS.projVector.x == 0x4000 && CUR.GS.freeVector.x == 0x4000);
-
- /* Throw away projection and freedom vector information */
- /* because the patents don't allow them to be stored. */
- /* The relevant US Patents are 5155805 and 5325479. */
+ /* `both-x-axis' true, otherwise set it false. The x values only */
+ /* need be tested because the vector has been normalised to a unit */
+ /* vector of length 0x4000 = unity. */
+ CUR.GS.both_x_axis = (FT_Bool)( CUR.GS.projVector.x == 0x4000 &&
+ CUR.GS.freeVector.x == 0x4000 );
+
+ /* Throw away projection and freedom vector information */
+ /* because the patents don't allow them to be stored. */
+ /* The relevant US Patents are 5155805 and 5325479. */
CUR.GS.projVector.x = 0;
CUR.GS.projVector.y = 0;
CUR.GS.freeVector.x = 0;
@@ -2271,15 +2276,15 @@
if ( CUR.GS.both_x_axis )
{
- CUR.func_project = Project_x;
- CUR.func_freeProj = Project_x;
- CUR.func_move = Direct_Move_X;
+ CUR.func_project = Project_x;
+ CUR.func_freeProj = Project_x;
+ CUR.func_move = Direct_Move_X;
}
- else
+ else
{
- CUR.func_project = Project_y;
- CUR.func_freeProj = Project_y;
- CUR.func_move = Direct_Move_Y;
+ CUR.func_project = Project_y;
+ CUR.func_freeProj = Project_y;
+ CUR.func_move = Direct_Move_Y;
}
if ( CUR.GS.dualVector.x == 0x4000 )
@@ -2287,7 +2292,7 @@
else
{
if ( CUR.GS.dualVector.y == 0x4000 )
- CUR.func_dualproj = Project_y;
+ CUR.func_dualproj = Project_y;
else
CUR.func_dualproj = Dual_Project;
}
@@ -2295,9 +2300,9 @@
/* Force recalculation of cached aspect ratio */
CUR.tt_metrics.ratio = 0;
- return;
- }
-#endif
+ return;
+ }
+#endif /* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING */
if ( CUR.GS.freeVector.x == 0x4000 )
{
@@ -2656,39 +2661,39 @@
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
-#define DO_GPV \
- if ( CUR.face->unpatented_hinting ) \
- { \
- args[0] = CUR.GS.both_x_axis ? 0x4000 : 0;\
- args[1] = CUR.GS.both_x_axis ? 0 : 0x4000;\
- } \
- else \
- { \
- args[0] = CUR.GS.projVector.x; \
- args[1] = CUR.GS.projVector.y; \
+#define DO_GPV \
+ if ( CUR.face->unpatented_hinting ) \
+ { \
+ args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
+ args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
+ } \
+ else \
+ { \
+ args[0] = CUR.GS.projVector.x; \
+ args[1] = CUR.GS.projVector.y; \
}
#else
-#define DO_GPV \
- args[0] = CUR.GS.projVector.x; \
+#define DO_GPV \
+ args[0] = CUR.GS.projVector.x; \
args[1] = CUR.GS.projVector.y;
#endif
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
-#define DO_GFV \
- if ( CUR.face->unpatented_hinting ) \
- { \
- args[0] = CUR.GS.both_x_axis ? 0x4000 : 0;\
- args[1] = CUR.GS.both_x_axis ? 0 : 0x4000;\
- } \
- else \
- { \
- args[0] = CUR.GS.freeVector.x; \
- args[1] = CUR.GS.freeVector.y; \
+#define DO_GFV \
+ if ( CUR.face->unpatented_hinting ) \
+ { \
+ args[0] = CUR.GS.both_x_axis ? 0x4000 : 0; \
+ args[1] = CUR.GS.both_x_axis ? 0 : 0x4000; \
+ } \
+ else \
+ { \
+ args[0] = CUR.GS.freeVector.x; \
+ args[1] = CUR.GS.freeVector.y; \
}
#else
-#define DO_GFV \
- args[0] = CUR.GS.freeVector.x; \
+#define DO_GFV \
+ args[0] = CUR.GS.freeVector.x; \
args[1] = CUR.GS.freeVector.y;
#endif
@@ -5262,7 +5267,7 @@
FT_Bool touch )
{
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- if (CUR.face->unpatented_hinting)
+ if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
@@ -5466,16 +5471,16 @@
}
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- if ( CUR.face->unpatented_hinting)
+ if ( CUR.face->unpatented_hinting )
{
if ( CUR.GS.both_x_axis )
{
dx = TT_MulFix14( args[0], 0x4000 );
- dy = 0;
+ dy = 0;
}
else
{
- dx = 0;
+ dx = 0;
dy = TT_MulFix14( args[0], 0x4000 );
}
}
@@ -6383,7 +6388,7 @@
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
- {
+ {
FT_Long n = args[0] * 2;
if ( CUR.args < n )
{
@@ -6391,7 +6396,7 @@
return;
}
- CUR.args -= n;
+ CUR.args -= n;
CUR.new_top = CUR.args;
return;
}
@@ -6471,18 +6476,21 @@
FT_ULong A, C;
FT_Long B;
+
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
/* Delta hinting is covered by US Patent 5159668. */
if ( CUR.face->unpatented_hinting )
- {
- FT_Long n = args[0] * 2;
+ {
+ FT_Long n = args[0] * 2;
+
+
if ( CUR.args < n )
{
CUR.error = TT_Err_Too_Few_Arguments;
return;
}
- CUR.args -= n;
+ CUR.args -= n;
CUR.new_top = CUR.args;
return;
}
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index eabbdf7..b6869b0 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -204,46 +204,46 @@
goto Exit;
if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE )
- {
+ {
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- if ( !face->root.internal->incremental_interface )
- error = tt_face_load_loca( face, stream );
- if ( !error )
- error = tt_face_load_cvt ( face, stream ) ||
- tt_face_load_fpgm ( face, stream );
+ if ( !face->root.internal->incremental_interface )
+ error = tt_face_load_loca( face, stream );
+ if ( !error )
+ error = tt_face_load_cvt( face, stream ) ||
+ tt_face_load_fpgm( face, stream );
#else
- if ( !error )
- error = tt_face_load_loca( face, stream ) ||
- tt_face_load_cvt ( face, stream ) ||
- tt_face_load_fpgm ( face, stream );
+ if ( !error )
+ error = tt_face_load_loca( face, stream ) ||
+ tt_face_load_cvt( face, stream ) ||
+ tt_face_load_fpgm( face, stream );
#endif
- }
+ }
#ifdef TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING
- /* Determine whether unpatented hinting is to be used for this face. */
+ /* Determine whether unpatented hinting is to be used for this face. */
#ifdef TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING
- face->unpatented_hinting = TRUE;
+ face->unpatented_hinting = TRUE;
#else
- face->unpatented_hinting = FALSE;
+ face->unpatented_hinting = FALSE;
{
- int i;
+ int i;
+
- for ( i = 0; i < num_params && !face->unpatented_hinting;
- i++ )
- if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
- face->unpatented_hinting = TRUE;
+ for ( i = 0; i < num_params && !face->unpatented_hinting; i++ )
+ if ( params[i].tag == FT_PARAM_TAG_UNPATENTED_HINTING )
+ face->unpatented_hinting = TRUE;
}
-#endif
+#endif /* TT_CONFIG_OPTION_FORCE_UNPATENTED_HINTING */
-#endif
+#endif /* TT_CONFIG_OPTION_COMPILE_UNPATENTED_HINTING */
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );