* src/smooth/ftsmooth.c, src/base/ftobjs.c, include/freetype/config/ftmodule.h: updated to correctly support sub-pixel rendering * include/freetype/cache/ftcimage.h, include/freetype/cache/ftcsbits.h, src/cache/ftcimage.c, src/cache/ftcsbit.c: updated to support sub-pixel rendering correctly. Definition of FTC_ImageTypeRec that replaces the obsolete FTC_ImageDesc, and has slightly different fields. The image type is now determined directly by "load_flags" values. * src/autohint/ahtypes.h, src/autohint/ahhint.c, src/pshinter/pshalgo3.c, src/pshinter/pshalgo3.h: various enhancements to the automatic and Postscript hinters !! and sub-pixel hinting now works correctly (see demo programs)
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 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555
diff --git a/ChangeLog b/ChangeLog
index 91bc0a4..7e5821f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-09-08 David Turner <david@freetype.org>
+
+ * src/smooth/ftsmooth.c, src/base/ftobjs.c,
+ include/freetype/config/ftmodule.h: updated to correctly support
+ sub-pixel rendering
+
+ * include/freetype/cache/ftcimage.h, include/freetype/cache/ftcsbits.h,
+ src/cache/ftcimage.c, src/cache/ftcsbit.c: updated to support sub-pixel
+ rendering correctly. Definition of FTC_ImageTypeRec that replaces the
+ obsolete FTC_ImageDesc, and has slightly different fields. The
+ image type is now determined directly by "load_flags" values.
+
+ * src/autohint/ahtypes.h, src/autohint/ahhint.c,
+ src/pshinter/pshalgo3.c, src/pshinter/pshalgo3.h: various enhancements
+ to the automatic and Postscript hinters !! and sub-pixel hinting now
+ works correctly (see demo programs)
+
2002-09-05 Werner Lemberg <wl@gnu.org>
* src/cid/cidobjs.c (CID_Size_Init): Renamed to...
diff --git a/include/freetype/cache/ftcimage.h b/include/freetype/cache/ftcimage.h
index e3a4009..041084a 100644
--- a/include/freetype/cache/ftcimage.h
+++ b/include/freetype/cache/ftcimage.h
@@ -53,65 +53,43 @@ FT_BEGIN_HEADER
/*************************************************************************/
-#define FTC_IMAGE_FORMAT( x ) ( (x) & 7 )
-#define ftc_image_format_bitmap 0x0000
-#define ftc_image_format_outline 0x0001
-
-#define ftc_image_format_mask 0x000F
-
-#define ftc_image_flag_monochrome 0x0010
-#define ftc_image_flag_unhinted 0x0020
-#define ftc_image_flag_autohinted 0x0040
-#define ftc_image_flag_unscaled 0x0080
-#define ftc_image_flag_no_sbits 0x0100
-
- /* monochrome bitmap */
-#define ftc_image_mono ftc_image_format_bitmap | \
- ftc_image_flag_monochrome
-
- /* anti-aliased bitmap */
-#define ftc_image_grays ftc_image_format_bitmap
-
- /* scaled outline */
-#define ftc_image_outline ftc_image_format_outline
-
-
- /*************************************************************************/
- /* */
- /* <Struct> */
- /* FTC_ImageDesc */
- /* */
- /* <Description> */
- /* A simple structure used to describe a given glyph image category. */
- /* Note that this is different from @FTC_Image_Desc. */
- /* */
- /* <Fields> */
- /* size :: An @FTC_SizeRec used to describe the glyph's face and */
- /* size. */
- /* */
- /* type :: The glyph image's type. Note that it is a 32-bit uint. */
- /* */
- /* <Note> */
- /* This type deprecates @FTC_Image_Desc. */
- /* */
- typedef struct FTC_ImageDesc_
+ /**************************************************************************
+ *
+ * @struct: FTC_ImageTypeRec
+ *
+ * @description:
+ * a simple structure used to describe the type of glyph image to be
+ * loaded into the cache
+ *
+ * @fields:
+ * font :: An @FTC_FontRec used to describe the glyph's face and size
+ * flags :: the load flags to be applied when loading the glyph, see
+ * the @FT_LOAD_XXX constants for details
+ *
+ * @note:
+ * this type completely replaces the @FTC_Image_Desc structure which is
+ * now obsolete..
+ */
+ typedef struct FTC_ImageTypeRec_
{
FTC_FontRec font;
- FT_UInt32 type;
+ FT_Int32 flags;
+
+ } FTC_ImageTypeRec;
- } FTC_ImageDesc;
+ typedef struct FTC_ImageTypeRec_* FTC_ImageType;
/* */
-#define FTC_IMAGE_DESC_COMPARE( d1, d2 ) \
+#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
( FTC_FONT_COMPARE( &(d1)->font, &(d2)->font ) && \
- (d1)->type == (d2)->type )
+ (d1)->flags == (d2)->flags )
-#define FTC_IMAGE_DESC_HASH( d ) \
+#define FTC_IMAGE_TYPE_HASH( d ) \
(FT_UFast)( FTC_FONT_HASH( &(d)->font ) ^ \
- ( (d)->type << 4 ) )
+ ( (d)->flags << 4 ) )
/*************************************************************************/
@@ -160,7 +138,7 @@ FT_BEGIN_HEADER
/* <Input> */
/* cache :: A handle to the source glyph image cache. */
/* */
- /* desc :: A pointer to a glyph image descriptor. */
+ /* type :: A pointer to a glyph image type descriptor. */
/* */
/* gindex :: The glyph index to retrieve. */
/* */
@@ -193,13 +171,36 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache,
- FTC_ImageDesc* desc,
+ FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode );
/* */
+#define ftc_image_format( x ) ( (x) & 7 )
+
+
+#define ftc_image_format_bitmap 0x0000
+#define ftc_image_format_outline 0x0001
+
+#define ftc_image_format_mask 0x000F
+
+#define ftc_image_flag_monochrome 0x0010
+#define ftc_image_flag_unhinted 0x0020
+#define ftc_image_flag_autohinted 0x0040
+#define ftc_image_flag_unscaled 0x0080
+#define ftc_image_flag_no_sbits 0x0100
+
+ /* monochrome bitmap */
+#define ftc_image_mono ftc_image_format_bitmap | \
+ ftc_image_flag_monochrome
+
+ /* anti-aliased bitmap */
+#define ftc_image_grays ftc_image_format_bitmap
+
+ /* scaled outline */
+#define ftc_image_outline ftc_image_format_outline
/*************************************************************************/
/* */
diff --git a/include/freetype/cache/ftcsbits.h b/include/freetype/cache/ftcsbits.h
index 4e5ab1d..a7f739e 100644
--- a/include/freetype/cache/ftcsbits.h
+++ b/include/freetype/cache/ftcsbits.h
@@ -72,7 +72,7 @@ FT_BEGIN_HEADER
/* */
/* format :: The format of the glyph bitmap (monochrome or gray). */
/* */
- /* num_grays :: The number of gray levels. */
+ /* max_grays :: maximum gray level value, from 1 to 255 */
/* */
/* pitch :: The number of bytes per bitmap line. May be positive */
/* or negative. */
@@ -91,8 +91,8 @@ FT_BEGIN_HEADER
FT_Char top;
FT_Byte format;
- FT_Short num_grays; /* XXX: Should be FT_Byte. See ftcsbits.c */
- FT_Char pitch;
+ FT_Byte max_grays;
+ FT_Short pitch;
FT_Char xadvance;
FT_Char yadvance;
@@ -113,7 +113,7 @@ FT_BEGIN_HEADER
/* implemented by @FTC_ImageCache. */
/* */
typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
-
+
/*************************************************************************/
/* */
@@ -160,7 +160,7 @@ FT_BEGIN_HEADER
/* <Input> */
/* cache :: A handle to the source sbit cache. */
/* */
- /* desc :: A pointer to the glyph image descriptor. */
+ /* type :: A pointer to the glyph image type descriptor. */
/* */
/* gindex :: The glyph index. */
/* */
@@ -195,7 +195,7 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache,
- FTC_ImageDesc* desc,
+ FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *sbit,
FTC_Node *anode );
diff --git a/include/freetype/config/ftmodule.h b/include/freetype/config/ftmodule.h
index 589e920..6e36a25 100644
--- a/include/freetype/config/ftmodule.h
+++ b/include/freetype/config/ftmodule.h
@@ -9,6 +9,8 @@ FT_USE_MODULE(pshinter_module_class)
FT_USE_MODULE(ft_raster1_renderer_class)
FT_USE_MODULE(sfnt_module_class)
FT_USE_MODULE(ft_smooth_renderer_class)
+FT_USE_MODULE(ft_smooth_lcd_renderer_class)
+FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
FT_USE_MODULE(tt_driver_class)
FT_USE_MODULE(t1_driver_class)
FT_USE_MODULE(t42_driver_class)
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index c95dfca..32f03c0 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -2009,202 +2009,147 @@ FT_BEGIN_HEADER
FT_Int32 load_flags );
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_NO_SCALE */
- /* */
- /* <Description> */
- /* A bit field constant, used with @FT_Load_Glyph to indicate that */
- /* the vector outline being loaded should not be scaled to 26.6 */
- /* fractional pixels, but kept in notional units. */
- /* */
-#define FT_LOAD_NO_SCALE 0x1
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_NO_HINTING */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the vector outline being loaded should not be fitted to the pixel */
- /* grid but simply scaled to 26.6 fractional pixels. */
- /* */
- /* This flag is ignored if FT_LOAD_NO_SCALE is set. */
- /* */
-#define FT_LOAD_NO_HINTING 0x2
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_RENDER */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the function should load the glyph and immediately convert it into */
- /* a bitmap, if necessary, by calling @FT_Render_Glyph. */
- /* */
- /* Note that by default, @FT_Load_Glyph loads the glyph image in its */
- /* native format. */
- /* */
-#define FT_LOAD_RENDER 0x4
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_NO_BITMAP */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the function should not load the bitmap or pixmap of a given */
- /* glyph. This is useful when you do not want to load the embedded */
- /* bitmaps of scalable formats, as the native glyph image will be */
- /* loaded, and can then be rendered through @FT_Render_Glyph. */
- /* */
-#define FT_LOAD_NO_BITMAP 0x8
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_VERTICAL_LAYOUT */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the glyph image should be prepared for vertical layout. This */
- /* basically means that `face.glyph.advance' will correspond to the */
- /* vertical advance height (instead of the default horizontal */
- /* advance width), and that the glyph image will translated to match */
- /* the vertical bearings positions. */
- /* */
-#define FT_LOAD_VERTICAL_LAYOUT 0x10
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_FORCE_AUTOHINT */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the function should try to auto-hint the glyphs, even if a driver */
- /* specific hinter is available. */
- /* */
- /* Note that it is ignored if @FT_LOAD_NO_AUTOHINT is also set. */
- /* */
-#define FT_LOAD_FORCE_AUTOHINT 0x20
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_CROP_BITMAP */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the font driver should try to crop the bitmap (i.e. remove all */
- /* space around its black bits) when loading it. For now, this */
- /* really only works with embedded bitmaps in TrueType fonts. */
- /* */
-#define FT_LOAD_CROP_BITMAP 0x40
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_PEDANTIC */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the glyph loader should perform a pedantic bytecode */
- /* interpretation. Many popular fonts come with broken glyph */
- /* programs. When this flag is set, loading them will return an */
- /* error. Otherwise, errors are ignored by the loader, sometimes */
- /* resulting in ugly glyphs. */
- /* */
-#define FT_LOAD_PEDANTIC 0x80
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the glyph loader should ignore the global advance width defined */
- /* in the font. As far as we know, this is only used by the */
- /* X-TrueType font server, in order to deal correctly with the */
- /* incorrect metrics contained in DynaLab's TrueType CJK fonts. */
- /* */
+/****************************************************************************
+ *
+ * @enum: FT_LOAD_XXX
+ *
+ * @description:
+ * a list of bit-field constants, used with @FT_Load_Glyph to indicate
+ * what kind of operations to perform during glyph loading
+ *
+ * @values:
+ * FT_LOAD_DEFAULT ::
+ * corresponding to 0, this value is used a default glyph load. In this
+ * case, the following will happen:
+ *
+ * 1/ FreeType will look for a bitmap for the glyph corresponding to
+ * the face's current size. If one is found, the function returns.
+ * the bitmap data can be accessed from the glyph slot (see note
+ * below)
+ *
+ * 2/ If no embedded bitmap is searched or found, FreeType looks for
+ * a scalable outline. If one is found, it is loaded from the font
+ * file, scaled to device pixels, then "hinted" to the pixel grid
+ * in order to optimize it. the outline data can be accessed from
+ * the glyph slot (see note below)
+ *
+ * Note that by default, the glyph loader doesn't render outlines into
+ * bitmaps. the following flags are used to modify this default behaviour
+ * to more specific and useful cases.
+ *
+ * FT_LOAD_NO_SCALE ::
+ * indicates that the vector outline being loaded should not be scaled
+ * to 26.6 fractional pixels, but kept in font units. Note that this
+ * also disables hinting and the loading of embedded bitmaps. You should
+ * only use it when you want to retrieve the original glyph outlines
+ * in font units.
+ *
+ * FT_LOAD_NO_HINTING ::
+ * indicates that the glyph outlines should not be hinted after their
+ * scaling to device pixels. This generally generates "blurrier" glyphs
+ * in anti-aliased modes.
+ *
+ * this flag is ignored if @FT_LOAD_NO_SCALE is set
+ *
+ * FT_LOAD_RENDER ::
+ * indicates that the glyph outline should be rendered immediately into
+ * a bitmap before the glyph loader returns. By default, the glyph is
+ * rendered for the @FT_RENDER_MODE_NORMAL mode, which corresponds to
+ * 8-bit anti-aliased bitmaps using 256 opacity levels. You can use
+ * either @FT_LOAD_TARGET_MONO or @FT_LOAD_MONOCHROME to render
+ * 1-bit monochrome bitmaps
+ *
+ * This flag is ignored if @FT_LOAD_NO_SCALE is set
+ *
+ *
+ * FT_LOAD_NO_BITMAP ::
+ * indicates that you do not want to look for bitmaps when loading
+ * the glyph. Only scalable outlines will be loaded when available,
+ * and scaled/hinted/rendered depending on other bit flags
+ *
+ * this does not prevent you from rendering outlines to bitmaps
+ * with @FT_LOAD_RENDER however.
+ *
+ * FT_LOAD_VERTICAL_LAYOUT:
+ * indicates that the glyph image should be prepared for vertical
+ * text layout. This basically means that 'face.glyph.advance' will
+ * correspond to the vertical advance height (instead of the default
+ * horizontal advance width), and that the glyph image will be
+ * translated to match the vertical bearings positions
+ *
+ * FT_LOAD_FORCE_AUTOHINT ::
+ * indicates that you want to force the use of the FreeType auto-hinter
+ * when a glyph outline is loaded. You shouldn't need this in a typical
+ * application, since it's mostly used to experiment with its algorithm
+ *
+ * FT_LOAD_CROP_BITMAP ::
+ * indicates that the glyph loader should try to crop the bitmap (i.e.
+ * remove all space around its black bits) when loading it. This is
+ * only useful when loading embedded bitmaps in certain fonts, since
+ * bitmaps rendered with @FT_LOAD_RENDER are always cropped by default
+ *
+ * FT_LOAD_PEDANTIC ::
+ * indicates that the glyph loader should perform pedantic verifications
+ * during glyph loading. This is mostly used to detect broken glyphs in
+ * fonts. By default, FreeType will always try to deal with such cases.
+ *
+ * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
+ * indicates that the glyph loader should ignore the global advance
+ * width defined in the font. As far as we know, this is only used by the
+ * X-TrueType font server, in order to deal correctly with the incorrect
+ * metrics contained in DynaLab's TrueType CJK fonts.
+ *
+ * FT_LOAD_NO_RECURSE ::
+ * this flag is only used internally. It merely indicates that the glyph
+ * loader should not load composite glyphs recursively. Instead, it should
+ * set the 'num_subglyph' and 'subglyphs' values of the glyph slot
+ * accordingly, and set "glyph->format" to @FT_GLYPH_FORMAT_COMPOSITE
+ *
+ * the description of sub-glyphs is not available to client applications
+ * for now
+ *
+ * FT_LOAD_IGNORE_TRANSFORM ::
+ * indicates that the glyph loader should not try to transform the
+ * loaded glyph image. This doesn't prevent scaling/hinting/rendering
+ *
+ * FT_LOAD_MONOCHROME ::
+ * this flag is used with @FT_LOAD_RENDER to indicate that you want
+ * to render a 1-bit monochrome glyph bitmap from a vectorial outline.
+ *
+ * note that this has no effect on the hinting algorithm used by the
+ * glyph loader. You'd better use @FT_LOAD_TARGET_MONO if you want to
+ * render monochrome-optimized glyph images instead.
+ *
+ * FT_LOAD_LINEAR_DESIGN ::
+ * indicates that the function should return the linearly scaled metrics
+ * expressed in original font units, instead of the default 16.16 pixel
+ * values
+ *
+ * FT_LOAD_NO_AUTOHINT ::
+ * indicates that the auto-hinter should never be used to hint glyph
+ * outlines. This doesn't prevent native format-specific hinters from
+ * being used. This can be important for certain fonts where un-hinted
+ * output is better than auto-hinted one.
+ *
+ *
+ *
+ *
+ *
+ */
+#define FT_LOAD_NO_SCALE 0x1
+#define FT_LOAD_NO_HINTING 0x2
+#define FT_LOAD_RENDER 0x4
+#define FT_LOAD_NO_BITMAP 0x8
+#define FT_LOAD_VERTICAL_LAYOUT 0x10
+#define FT_LOAD_FORCE_AUTOHINT 0x20
+#define FT_LOAD_CROP_BITMAP 0x40
+#define FT_LOAD_PEDANTIC 0x80
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH 0x200
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_NO_RECURSE */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the glyph loader should not load composite glyph recursively. */
- /* Rather, when a composite glyph is encountered, it should set */
- /* the values of `num_subglyphs' and `subglyphs', as well as set */
- /* `face->glyph.format' to FT_GLYPH_FORMAT_COMPOSITE. */
- /* */
- /* This is for use by the auto-hinter and possibly other tools. */
- /* For nearly all applications, this flags should be left unset */
- /* when invoking @FT_Load_Glyph. */
- /* */
- /* Note that the flag forces the load of unscaled glyphs. */
- /* */
-#define FT_LOAD_NO_RECURSE 0x400
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_IGNORE_TRANSFORM */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the glyph loader should not try to transform the loaded glyph */
- /* image. */
- /* */
-#define FT_LOAD_IGNORE_TRANSFORM 0x800
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_MONOCHROME */
- /* */
- /* <Description> */
- /* Only used with FT_LOAD_RENDER set, it indicates that the returned */
- /* glyph image should be 1-bit monochrome. This really tells the */
- /* glyph loader to use `FT_RENDER_MODE_MONO' when calling */
- /* @FT_Render_Glyph. */
- /* */
+#define FT_LOAD_NO_RECURSE 0x400
+#define FT_LOAD_IGNORE_TRANSFORM 0x800
#define FT_LOAD_MONOCHROME 0x1000
-
-
- /*************************************************************************/
- /* */
- /* <Constant> */
- /* FT_LOAD_LINEAR_DESIGN */
- /* */
- /* <Description> */
- /* A bit-field constant, used with @FT_Load_Glyph to indicate that */
- /* the function should return the linearly scaled metrics expressed */
- /* in original font units, instead of the default 16.16 pixel values. */
- /* */
#define FT_LOAD_LINEAR_DESIGN 0x2000
-
/* temporary hack! */
#define FT_LOAD_SBITS_ONLY 0x4000
diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c
index 7e967af..1498112 100644
--- a/src/autohint/ahhint.c
+++ b/src/autohint/ahhint.c
@@ -104,42 +104,42 @@
sign = 1;
}
- if ( ( vertical && hinter->no_vert_snapping ) ||
- ( !vertical && hinter->no_horz_snapping ) )
+ if ( ( vertical && !hinter->do_vert_snapping ) ||
+ ( !vertical && !hinter->do_horz_snapping ) )
{
/* smooth hinting process, very lightly quantize the stem width */
/* */
if ( dist < 64 )
dist = 64;
-
+
{
FT_Pos delta = dist - globals->stds[vertical];
-
-
+
+
if ( delta < 0 )
delta = -delta;
-
+
if ( delta < 40 )
{
dist = globals->stds[vertical];
- if ( dist < 32 )
- dist = 32;
+ if ( dist < 48 )
+ dist = 48;
}
-
+
if ( dist < 3 * 64 )
{
delta = ( dist & 63 );
dist &= -64;
-
+
if ( delta < 10 )
dist += delta;
-
+
else if ( delta < 32 )
dist += 10;
-
+
else if ( delta < 54 )
dist += 54;
-
+
else
dist += delta;
}
@@ -154,7 +154,7 @@
if ( vertical )
{
dist = ah_snap_width( globals->heights, globals->num_heights, dist );
-
+
/* in the case of vertical hinting, always round */
/* the stem heights to integer pixels */
if ( dist >= 64 )
@@ -165,7 +165,7 @@
else
{
dist = ah_snap_width( globals->widths, globals->num_widths, dist );
-
+
if ( hinter->flags & AH_HINTER_MONOCHROME )
{
/* monochrome horizontal hinting: snap widths to integer pixels */
@@ -182,7 +182,7 @@
/* is between 1 and 2 pixels to an integer, otherwise nothing */
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
-
+
else if ( dist < 128 )
dist = ( dist + 22 ) & -64;
else
@@ -285,10 +285,10 @@
int has_serifs = 0;
- if ( hinter->no_horz_hints && !dimension )
+ if ( !hinter->do_horz_hints && !dimension )
goto Next_Dimension;
- if ( hinter->no_vert_hints && dimension )
+ if ( !hinter->do_vert_hints && dimension )
goto Next_Dimension;
/* we begin by aligning all stems relative to the blue zone */
@@ -1169,7 +1169,7 @@
/* perform feature detection */
ah_outline_detect_features( outline );
- if ( !hinter->no_vert_hints )
+ if ( hinter->do_vert_hints )
{
ah_outline_compute_blue_edges( outline, hinter->globals );
ah_outline_scale_blue_edges( outline, hinter->globals );
@@ -1439,23 +1439,23 @@
ah_loader_rewind( hinter->loader );
/* reset hinting flags according to load flags and current render target */
- hinter->no_horz_hints = FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
- hinter->no_vert_hints = FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
-
+ hinter->do_horz_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
+ hinter->do_vert_hints = !FT_BOOL( load_flags & FT_LOAD_NO_AUTOHINT );
+
#ifdef DEBUG_HINTER
- hinter->no_horz_hints = ah_debug_disable_vert; /* not a bug, the meaning */
- hinter->no_vert_hints = ah_debug_disable_horz; /* of h/v is inverted! */
-#endif
+ hinter->do_horz_hints = !ah_debug_disable_vert; /* not a bug, the meaning */
+ hinter->do_vert_hints = !ah_debug_disable_horz; /* of h/v is inverted! */
+#endif
/* we snap the width of vertical stems for the monochrome and */
/* horizontal LCD rendering targets only. Corresponds to X snapping. */
- hinter->no_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_NORMAL ||
- hint_mode == FT_RENDER_MODE_LCD_V );
+ hinter->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
+ hint_mode == FT_RENDER_MODE_LCD );
/* we snap the width of horizontal stems for the monochrome and */
/* vertical LCD rendering targets only. Corresponds to Y snapping. */
- hinter->no_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_NORMAL ||
- hint_mode == FT_RENDER_MODE_LCD );
+ hinter->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
+ hint_mode == FT_RENDER_MODE_LCD_V );
#if 1
load_flags = FT_LOAD_NO_SCALE
diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h
index c967975..a893e84 100644
--- a/src/autohint/ahtypes.h
+++ b/src/autohint/ahtypes.h
@@ -492,10 +492,10 @@ FT_BEGIN_HEADER
FT_Vector trans_delta;
FT_Matrix trans_matrix;
- FT_Bool no_horz_hints; /* disable X hinting */
- FT_Bool no_vert_hints; /* disable Y hinting */
- FT_Bool no_horz_snapping; /* disable X stem size snapping */
- FT_Bool no_vert_snapping; /* disable Y stem size snapping */
+ FT_Bool do_horz_hints; /* disable X hinting */
+ FT_Bool do_vert_hints; /* disable Y hinting */
+ FT_Bool do_horz_snapping; /* disable X stem size snapping */
+ FT_Bool do_vert_snapping; /* disable Y stem size snapping */
} AH_HinterRec, *AH_Hinter;
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index bb9fbcb..dce6847 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -444,8 +444,8 @@
hinter = library->auto_hinter;
autohint =
FT_BOOL( hinter &&
- !( load_flags & ( FT_LOAD_NO_SCALE |
- FT_LOAD_NO_HINTING |
+ !( load_flags & ( FT_LOAD_NO_SCALE |
+ FT_LOAD_NO_HINTING |
FT_LOAD_NO_AUTOHINT ) ) &&
FT_DRIVER_IS_SCALABLE( driver ) &&
FT_DRIVER_USES_OUTLINES( driver ) );
@@ -553,10 +553,13 @@
slot->format != FT_GLYPH_FORMAT_COMPOSITE &&
load_flags & FT_LOAD_RENDER )
{
- error = FT_Render_Glyph( slot,
- ( load_flags & FT_LOAD_MONOCHROME )
- ? FT_RENDER_MODE_MONO
- : FT_RENDER_MODE_NORMAL );
+ FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
+
+ if ( mode == FT_RENDER_MODE_NORMAL &&
+ (load_flags & FT_LOAD_MONOCHROME ) )
+ mode = FT_RENDER_MODE_MONO;
+
+ error = FT_Render_Glyph( slot, mode );
}
Exit:
diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c
index 57915dd..26c9e57 100644
--- a/src/cache/ftcimage.c
+++ b/src/cache/ftcimage.c
@@ -42,7 +42,7 @@
typedef struct FTC_ImageQueryRec_
{
FTC_GlyphQueryRec gquery;
- FTC_ImageDesc desc;
+ FTC_ImageTypeRec type;
} FTC_ImageQueryRec, *FTC_ImageQuery;
@@ -54,7 +54,7 @@
typedef struct FTC_ImageFamilyRec_
{
FTC_GlyphFamilyRec gfam;
- FTC_ImageDesc desc;
+ FTC_ImageTypeRec type;
} FTC_ImageFamilyRec, *FTC_ImageFamily;
@@ -106,41 +106,13 @@
/* we will now load the glyph image */
error = FTC_Manager_Lookup_Size( FTC_FAMILY( ifam )->cache->manager,
- &ifam->desc.font,
+ &ifam->type.font,
&face, &size );
if ( !error )
{
FT_UInt gindex = FTC_GLYPH_NODE_GINDEX( inode );
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = ifam->desc.type;
-
-
- if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
- {
- load_flags |= FT_LOAD_RENDER;
- if ( type & ftc_image_flag_monochrome )
- load_flags |= FT_LOAD_MONOCHROME;
-
- /* disable embedded bitmaps loading if necessary */
- if ( type & ftc_image_flag_no_sbits )
- load_flags |= FT_LOAD_NO_BITMAP;
- }
- else if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_outline )
- {
- /* disable embedded bitmaps loading */
- load_flags |= FT_LOAD_NO_BITMAP;
- if ( type & ftc_image_flag_unscaled )
- load_flags |= FT_LOAD_NO_SCALE;
- }
-
- if ( type & ftc_image_flag_unhinted )
- load_flags |= FT_LOAD_NO_HINTING;
-
- if ( type & ftc_image_flag_autohinted )
- load_flags |= FT_LOAD_FORCE_AUTOHINT;
-
- error = FT_Load_Glyph( face, gindex, load_flags );
+ error = FT_Load_Glyph( face, gindex, ifam->type.flags );
if ( !error )
{
if ( face->glyph->format == FT_GLYPH_FORMAT_BITMAP ||
@@ -231,16 +203,16 @@
FT_Face face;
- ifam->desc = iquery->desc;
+ ifam->type = iquery->type;
/* we need to compute "iquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager,
- iquery->desc.font.face_id,
+ iquery->type.font.face_id,
&face );
if ( !error )
{
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( ifam ),
- FTC_IMAGE_DESC_HASH( &ifam->desc ),
+ FTC_IMAGE_TYPE_HASH( &ifam->type ),
1,
face->num_glyphs,
FTC_GLYPH_QUERY( iquery ),
@@ -258,7 +230,7 @@
FT_Bool result;
- result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &ifam->desc, &iquery->desc ) );
+ result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &ifam->type, &iquery->type ) );
if ( result )
FTC_GLYPH_FAMILY_FOUND( ifam, iquery );
@@ -314,7 +286,7 @@
FT_EXPORT_DEF( FT_Error )
FTC_ImageCache_Lookup( FTC_ImageCache cache,
- FTC_ImageDesc* desc,
+ FTC_ImageType type,
FT_UInt gindex,
FT_Glyph *aglyph,
FTC_Node *anode )
@@ -332,7 +304,7 @@
*anode = NULL;
iquery.gquery.gindex = gindex;
- iquery.desc = *desc;
+ iquery.type = *type;
error = ftc_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &iquery ),
@@ -368,17 +340,55 @@
FT_UInt gindex,
FT_Glyph *aglyph )
{
- FTC_ImageDesc desc0;
+ FTC_ImageTypeRec type0;
if ( !desc )
return FTC_Err_Invalid_Argument;
- desc0.font = desc->font;
- desc0.type = (FT_UInt32)desc->image_type;
+ type0.font = desc->font;
+
+ /* convert image type flags to load flags */
+ {
+ FT_UInt load_flags = FT_LOAD_DEFAULT;
+ FT_UInt type = desc->image_type;
+
+
+ /* determine load flags, depending on the font description's */
+ /* image type */
+
+ if ( ftc_image_format( type ) == ftc_image_format_bitmap )
+ {
+ if ( type & ftc_image_flag_monochrome )
+ load_flags |= FT_LOAD_MONOCHROME;
+
+ /* disable embedded bitmaps loading if necessary */
+ if ( type & ftc_image_flag_no_sbits )
+ load_flags |= FT_LOAD_NO_BITMAP;
+ }
+ else
+ {
+ /* we want an outline, don't load embedded bitmaps */
+ load_flags |= FT_LOAD_NO_BITMAP;
+
+ if ( type & ftc_image_flag_unscaled )
+ load_flags |= FT_LOAD_NO_SCALE;
+ }
+
+ /* always render glyphs to bitmaps */
+ load_flags |= FT_LOAD_RENDER;
+
+ if ( type & ftc_image_flag_unhinted )
+ load_flags |= FT_LOAD_NO_HINTING;
+
+ if ( type & ftc_image_flag_autohinted )
+ load_flags |= FT_LOAD_FORCE_AUTOHINT;
+
+ type0.flags = load_flags;
+ }
return FTC_ImageCache_Lookup( (FTC_ImageCache)icache,
- &desc0,
+ &type0,
gindex,
aglyph,
NULL );
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 5b8ff1e..b93d777 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -46,7 +46,7 @@
typedef struct FTC_SBitQueryRec_
{
FTC_GlyphQueryRec gquery;
- FTC_ImageDesc desc;
+ FTC_ImageTypeRec type;
} FTC_SBitQueryRec, *FTC_SBitQuery;
@@ -60,7 +60,7 @@
typedef struct FTC_SBitFamilyRec_
{
FTC_GlyphFamilyRec gfam;
- FTC_ImageDesc desc;
+ FTC_ImageTypeRec type;
} FTC_SBitFamilyRec;
@@ -104,8 +104,8 @@
ftc_sbit_node_done( FTC_SBitNode snode,
FTC_Cache cache )
{
- FTC_SBit sbit = snode->sbits;
- FT_UInt count = FTC_GLYPH_NODE( snode )->item_count;
+ FTC_SBit sbit = snode->sbits;
+ FT_UInt count = FTC_GLYPH_NODE( snode )->item_count;
FT_Memory memory = cache->memory;
@@ -142,48 +142,14 @@
sbit = snode->sbits + ( gindex - gnode->item_start );
- error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font,
+ error = FTC_Manager_Lookup_Size( manager, &sfam->type.font,
&face, &size );
if ( !error )
{
- FT_UInt load_flags = FT_LOAD_DEFAULT;
- FT_UInt type = sfam->desc.type;
-
-
- /* determine load flags, depending on the font description's */
- /* image type */
-
- if ( FTC_IMAGE_FORMAT( type ) == ftc_image_format_bitmap )
- {
- if ( type & ftc_image_flag_monochrome )
- load_flags |= FT_LOAD_MONOCHROME;
-
- /* disable embedded bitmaps loading if necessary */
- if ( type & ftc_image_flag_no_sbits )
- load_flags |= FT_LOAD_NO_BITMAP;
- }
- else
- {
- FT_ERROR((
- "ftc_sbit_node_load: cannot load scalable glyphs in an"
- " sbit cache, please check your arguments!\n" ));
- error = FTC_Err_Invalid_Argument;
- goto Exit;
- }
-
- /* always render glyphs to bitmaps */
- load_flags |= FT_LOAD_RENDER;
-
- if ( type & ftc_image_flag_unhinted )
- load_flags |= FT_LOAD_NO_HINTING;
-
- if ( type & ftc_image_flag_autohinted )
- load_flags |= FT_LOAD_FORCE_AUTOHINT;
-
/* by default, indicates a `missing' glyph */
sbit->buffer = 0;
- error = FT_Load_Glyph( face, gindex, load_flags );
+ error = FT_Load_Glyph( face, gindex, sfam->type.flags | FT_LOAD_RENDER );
if ( !error )
{
FT_Int temp;
@@ -221,13 +187,7 @@
sbit->xadvance = (FT_Char)xadvance;
sbit->yadvance = (FT_Char)yadvance;
sbit->format = (FT_Byte)bitmap->pixel_mode;
- /* XXX: Fixme: We don't handle the number of gray levels */
- /* consistently -- we say num_grays == 1 for */
- /* monochrome but num_grays == 256 for gray. It */
- /* would be better to make this variable hold the */
- /* highest possible value so that it fits into */
- /* a single byte. */
- sbit->num_grays = bitmap->num_grays;
+ sbit->max_grays = (FT_Byte)(bitmap->num_grays - 1);
/* grab the bitmap when possible - this is a hack! */
if ( slot->flags & FT_GLYPH_OWN_BITMAP )
@@ -380,16 +340,16 @@
FT_Face face;
- sfam->desc = squery->desc;
+ sfam->type = squery->type;
/* we need to compute "cquery.item_total" now */
error = FTC_Manager_Lookup_Face( manager,
- squery->desc.font.face_id,
+ squery->type.font.face_id,
&face );
if ( !error )
{
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ),
- FTC_IMAGE_DESC_HASH( &sfam->desc ),
+ FTC_IMAGE_TYPE_HASH( &sfam->type ),
FTC_SBIT_ITEMS_PER_NODE,
face->num_glyphs,
FTC_GLYPH_QUERY( squery ),
@@ -410,7 +370,7 @@
/* we need to set the "cquery.cset" field or our query for */
/* faster glyph comparisons in ftc_sbit_node_compare */
/* */
- result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) );
+ result = FT_BOOL( FTC_IMAGE_TYPE_COMPARE( &sfam->type, &squery->type ) );
if ( result )
FTC_GLYPH_FAMILY_FOUND( sfam, squery );
@@ -481,7 +441,7 @@
FT_EXPORT_DEF( FT_Error )
FTC_SBitCache_Lookup( FTC_SBitCache cache,
- FTC_ImageDesc* desc,
+ FTC_ImageType type,
FT_UInt gindex,
FTC_SBit *ansbit,
FTC_Node *anode )
@@ -501,7 +461,7 @@
*anode = NULL;
squery.gquery.gindex = gindex;
- squery.desc = *desc;
+ squery.type = *type;
error = ftc_sbit_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &squery ),
@@ -536,17 +496,56 @@
FT_UInt gindex,
FTC_SBit *ansbit )
{
- FTC_ImageDesc desc0;
+ FTC_ImageTypeRec type0;
if ( !desc )
return FTC_Err_Invalid_Argument;
- desc0.font = desc->font;
- desc0.type = (FT_UInt32)desc->image_type;
+ type0.font = desc->font;
+ type0.flags = 0;
+
+ /* convert image type flags to load flags */
+ {
+ FT_UInt load_flags = FT_LOAD_DEFAULT;
+ FT_UInt type = desc->image_type;
+
+
+ /* determine load flags, depending on the font description's */
+ /* image type */
+
+ if ( ftc_image_format( type ) == ftc_image_format_bitmap )
+ {
+ if ( type & ftc_image_flag_monochrome )
+ load_flags |= FT_LOAD_MONOCHROME;
+
+ /* disable embedded bitmaps loading if necessary */
+ if ( type & ftc_image_flag_no_sbits )
+ load_flags |= FT_LOAD_NO_BITMAP;
+ }
+ else
+ {
+ /* we want an outline, don't load embedded bitmaps */
+ load_flags |= FT_LOAD_NO_BITMAP;
+
+ if ( type & ftc_image_flag_unscaled )
+ load_flags |= FT_LOAD_NO_SCALE;
+ }
+
+ /* always render glyphs to bitmaps */
+ load_flags |= FT_LOAD_RENDER;
+
+ if ( type & ftc_image_flag_unhinted )
+ load_flags |= FT_LOAD_NO_HINTING;
+
+ if ( type & ftc_image_flag_autohinted )
+ load_flags |= FT_LOAD_FORCE_AUTOHINT;
+
+ type0.flags = load_flags;
+ }
return FTC_SBitCache_Lookup( (FTC_SBitCache)cache,
- &desc0,
+ &type0,
gindex,
ansbit,
NULL );
diff --git a/src/pshinter/pshalgo3.c b/src/pshinter/pshalgo3.c
index db23505..bd65068 100644
--- a/src/pshinter/pshalgo3.c
+++ b/src/pshinter/pshalgo3.c
@@ -332,6 +332,56 @@
/*************************************************************************/
/*************************************************************************/
+ static FT_Pos
+ psh3_dimension_quantize_len( PSH_Dimension dim,
+ FT_Pos len,
+ FT_Bool do_snapping )
+ {
+ if ( len <= 64 )
+ len = 64;
+ else
+ {
+ FT_Pos delta = len - dim->stdw.widths[0].cur;
+
+
+ if ( delta < 0 )
+ delta = -delta;
+
+ if ( delta < 40 )
+ {
+ len = dim->stdw.widths[0].cur;
+ if ( len < 48 )
+ len = 48;
+ }
+
+ if ( len < 3 * 64 )
+ {
+ delta = ( len & 63 );
+ len &= -64;
+
+ if ( delta < 10 )
+ len += delta;
+
+ else if ( delta < 32 )
+ len += 10;
+
+ else if ( delta < 54 )
+ len += 54;
+
+ else
+ len += delta;
+ }
+ else
+ len = ( len + 32 ) & -64;
+ }
+
+ if ( do_snapping )
+ len = ( len + 32 ) & -64;
+
+ return len;
+ }
+
+
#ifdef DEBUG_HINTER
static void
@@ -390,15 +440,15 @@
FT_Pos pos = FT_MulFix( hint->org_pos, scale ) + delta;
FT_Pos len = FT_MulFix( hint->org_len, scale );
- FT_Int no_snapping;
+ FT_Int do_snapping;
FT_Pos fit_center;
FT_Pos fit_len;
PSH_AlignmentRec align;
/* ignore stem alignments when requested through the hint flags */
- if ( ( dimension == 0 && glyph->no_horz_hints ) ||
- ( dimension == 1 && glyph->no_vert_hints ) )
+ if ( ( dimension == 0 && !glyph->do_horz_hints ) ||
+ ( dimension == 1 && !glyph->do_vert_hints ) )
{
hint->cur_pos = pos;
hint->cur_len = len;
@@ -408,26 +458,10 @@
}
/* perform stem snapping when requested */
- no_snapping = ( dimension == 0 && !glyph->no_horz_snapping ) ||
- ( dimension == 1 && !glyph->no_vert_snapping );
-
- if ( !no_snapping )
- {
- /* compute fitted width/height */
- fit_len = 0;
- if ( hint->org_len )
- {
- fit_len = psh_dimension_snap_width( dim, hint->org_len );
- if ( fit_len < 64 )
- fit_len = 64;
- else
- fit_len = ( fit_len + 32 ) & -64;
- }
- }
- else
- fit_len = len;
+ do_snapping = ( dimension == 0 && glyph->do_horz_snapping ) ||
+ ( dimension == 1 && glyph->do_vert_snapping );
- hint->cur_len = fit_len;
+ hint->cur_len = fit_len = len;
/* check blue zones for horizontal stems */
align.align = PSH_BLUE_ALIGN_NONE;
@@ -480,151 +514,64 @@
pos = par_cur_center + cur_delta - ( len >> 1 );
}
- if ( !no_snapping )
+ hint->cur_pos = pos;
+ hint->cur_len = fit_len;
+
+ if ( len <= 64 )
{
- /* normal processing */
- if ( fit_len & 64 )
- {
- /* odd number of pixels */
- fit_center = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
- }
- else
- {
- /* even number of pixels */
- fit_center = ( pos + ( len >> 1 ) + 32 ) & -64;
- }
- hint->cur_pos = fit_center - ( fit_len >> 1 );
+ /* the stem is less than one pixel, we will center it */
+ /* around the nearest pixel center */
+ /* */
+ pos = ( pos + ( (len >> 1) & -64 ) );
+ len = 64;
}
else
{
-#ifdef STRONGER
- if ( len <= 64 )
- {
- /* the stem is less than one pixel, we will center it */
- /* around the nearest pixel center */
- /* */
- pos = ( pos + ( (len >> 1) & -64 ) );
- len = 64;
- }
- else
- {
- FT_Pos Delta = len - dim->stdw.widths[0].cur;
-
+ len = psh3_dimension_quantize_len( dim, len, 0 );
+ }
- if ( Delta < 0 )
- Delta = -Delta;
+ /* now that we have a good hinted stem width, try to position */
+ /* the stem along a pixel grid integer coordinate */
+ hint->cur_pos = pos + psh3_hint_snap_stem_side_delta( pos, len );
+ hint->cur_len = len;
+ }
+ }
- if ( Delta < 40 )
- {
- len = dim->stdw.widths[0].cur;
- if ( len < 32 )
- len = 32;
- }
+ if ( do_snapping )
+ {
+ pos = hint->cur_pos;
+ len = hint->cur_len;
- if ( len < 3 * 64 )
- {
- Delta = ( len & 63 );
- len &= -64;
+ if ( len < 64 )
+ len = 64;
+ else
+ len = ( len + 32 ) & -64;
- if ( Delta < 10 )
- len += Delta;
+ switch ( align.align )
+ {
+ case PSH_BLUE_ALIGN_TOP:
+ hint->cur_pos = align.align_top - len;
+ hint->cur_len = len;
+ break;
- else if ( Delta < 32 )
- len += 10;
+ case PSH_BLUE_ALIGN_BOT:
+ hint->cur_len = len;
+ break;
- else if ( Delta < 54 )
- len += 54;
+ case PSH_BLUE_ALIGN_BOT | PSH_BLUE_ALIGN_TOP:
+ /* don't touch */
+ break;
- else
- len += Delta;
- }
- else
- len = ( len + 32 ) & -64;
- }
- /* now that we have a good hinted stem width, try to position */
- /* the stem along a pixel grid integer coordinate */
- hint->cur_pos = pos + psh3_hint_snap_stem_side_delta( pos, len );
+ default:
hint->cur_len = len;
-
-#else /* !STRONGER */
-
- /* Stems less than one pixel wide are easy - we want to
- * make them as dark as possible, so they must fall within
- * one pixel. If the stem is split between two pixels
- * then snap the edge that is nearer to the pixel boundary
- * to the pixel boundary
- */
- if (len <= 64)
- {
- if ( ( pos + len + 63 ) / 64 != pos / 64 + 1 )
- pos += psh3_hint_snap_stem_side_delta ( pos, len );
- }
- /* Position stems other to minimize the amount of mid-grays.
- * There are, in general, two positions that do this,
- * illustrated as A) and B) below.
- *
- * + + + +
- *
- * A) |--------------------------------|
- * B) |--------------------------------|
- * C) |--------------------------------|
- *
- * Position A) (split the excess stem equally) should be better
- * for stems of width N + f where f < 0.5.
- *
- * Position B) (split the deficiency equally) should be better
- * for stems of width N + f where f > 0.5.
- *
- * It turns out though that minimizing the total number of touched
- * pixels is also important, so position C), with one edge
- * aligned with a pixel boundary is actually preferable
- * to A). There are also more possible positions for C) than
- * for A) or B), so there will be less distortion of the overall
- * character shape.
- */
+ if ( len & 64 )
+ pos = ( ( pos + ( len >> 1 ) ) & -64 ) + 32;
else
- {
- FT_Fixed frac_len = len & 63;
- FT_Fixed center = pos + ( len >> 1 );
-
- FT_Fixed delta_a, delta_b;
-
-
- if ( len & 64 )
- {
- delta_a = ( center & -64 ) + 32 - center;
- delta_b = ( ( center + 32 ) & - 64 ) - center;
- }
- else
- {
- delta_a = ( ( center + 32 ) & - 64 ) - center;
- delta_b = ( center & -64 ) + 32 - center;
- }
-
- /* We choose between B) and C) above based on the amount
- * of fractional stem width: for small amounts, choose
- * C) always; for large amounts, B) always; inbetween,
- * pick whichever one involves less stem movement.
- */
- if ( frac_len < 32 )
- pos += psh3_hint_snap_stem_side_delta ( pos, len );
- else if ( frac_len < 48 )
- {
- FT_Fixed side_delta =
- psh3_hint_snap_stem_side_delta( pos, len );
+ pos = ( pos + ( len >> 1 ) + 32 ) & -64;
- if ( ABS( side_delta ) < ABS( delta_b ) )
- pos += side_delta;
- else
- pos += delta_b;
- }
- else
- pos += delta_b;
- }
- hint->cur_pos = pos;
-#endif /* !STRONGER */
- }
+ hint->cur_pos = pos - ( len >> 1 );
+ hint->cur_len = len;
}
}
@@ -1761,19 +1708,19 @@
#endif /* DEBUG_HINTER */
- glyph->no_horz_hints = 0;
- glyph->no_vert_hints = 0;
-
- glyph->no_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_NORMAL ||
- hint_mode == FT_RENDER_MODE_LCD_V );
-
- glyph->no_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_NORMAL ||
- hint_mode == FT_RENDER_MODE_LCD );
-
error = psh3_glyph_init( glyph, outline, ps_hints, globals );
if ( error )
goto Exit;
+ glyph->do_horz_hints = 1;
+ glyph->do_vert_hints = 1;
+
+ glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
+ hint_mode == FT_RENDER_MODE_LCD );
+
+ glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
+ hint_mode == FT_RENDER_MODE_LCD_V );
+
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
diff --git a/src/pshinter/pshalgo3.h b/src/pshinter/pshalgo3.h
index a1a01db..18f5374 100644
--- a/src/pshinter/pshalgo3.h
+++ b/src/pshinter/pshalgo3.h
@@ -30,7 +30,7 @@ FT_BEGIN_HEADER
/* handle to Hint structure */
typedef struct PSH3_HintRec_* PSH3_Hint;
-
+
/* hint bit-flags */
typedef enum
{
@@ -217,10 +217,10 @@ FT_BEGIN_HEADER
FT_Int major_dir;
FT_Int minor_dir;
- FT_Bool no_horz_hints;
- FT_Bool no_vert_hints;
- FT_Bool no_horz_snapping;
- FT_Bool no_vert_snapping;
+ FT_Bool do_horz_hints;
+ FT_Bool do_vert_hints;
+ FT_Bool do_horz_snapping;
+ FT_Bool do_vert_snapping;
} PSH3_GlyphRec, *PSH3_Glyph;
diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c
index 0e34c4e..c871b55 100644
--- a/src/smooth/ftsmooth.c
+++ b/src/smooth/ftsmooth.c
@@ -249,9 +249,15 @@
FT_UInt mode,
FT_Vector* origin )
{
- return ft_smooth_render_generic( render, slot, mode, origin,
- FT_RENDER_MODE_LCD,
- 3, 0 );
+ FT_Error error;
+
+ error = ft_smooth_render_generic( render, slot, mode, origin,
+ FT_RENDER_MODE_LCD,
+ 3, 0 );
+ if ( !error )
+ slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
+
+ return error;
}
@@ -262,9 +268,15 @@
FT_UInt mode,
FT_Vector* origin )
{
- return ft_smooth_render_generic( render, slot, mode, origin,
- FT_RENDER_MODE_LCD_V,
- 0, 3 );
+ FT_Error error;
+
+ error = ft_smooth_render_generic( render, slot, mode, origin,
+ FT_RENDER_MODE_LCD_V,
+ 0, 3 );
+ if ( !error )
+ slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
+
+ return error;
}