diff --git a/src/autofit/afadjust.c b/src/autofit/afadjust.c index bf115d2b1..9e15746c9 100644 --- a/src/autofit/afadjust.c +++ b/src/autofit/afadjust.c @@ -24,14 +24,110 @@ adjustment_database[] = {0xC3, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*A with tilde*/ {0xC8, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*E with grave*/ {0xCC, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*I with grave*/ - {0xD9, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*U with grave*/ - {0xE0, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*a with grave*/ - {0xEC, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*i with grave*/ - {0x114, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*E with macron*/ - {0x12A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*I with macron*/ - {0x12B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*i with macron*/ - {0x16A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, /*U with macron*/ - {0x16B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP} /*u with macron*/ + {0xCD, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xCE, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD1, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD2, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD3, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD4, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD5, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD9, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xD1, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xDB, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xDD, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE0, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE1, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE2, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE3, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE8, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xE9, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xEA, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xEC, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xED, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xEE, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF1, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF2, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF3, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF4, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF5, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xF9, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xFA, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xFB, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0xFD, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x100, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x101, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x102, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x103, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x106, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x108, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x109, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x10A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x10B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x10C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x10D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x10E, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x112, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x113, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x114, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x115, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x116, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x117, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x11B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x11C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x11D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x11E, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x11F, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x120, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x121, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x123, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x124, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x125, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x128, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x129, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x12A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x12B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x12C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x12D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x12F, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x130, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x134, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x135, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x139, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x13A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x143, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x144, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x147, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x14C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x14D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x14E, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x14F, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x154, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x155, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x158, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x159, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x15A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x15B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x15C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x15D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x160, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x161, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x164, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x168, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x169, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x16A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x16B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x16C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x16D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x174, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x175, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x176, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x177, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x179, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x17A, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x17B, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x17C, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x17D, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP}, + {0x17E, AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP} }; /*Helper function: get the adjustment database entry for a codepoint*/ @@ -40,7 +136,7 @@ af_adjustment_database_lookup( FT_UInt32 codepoint ) { /* Binary search for database entry */ FT_Int low = 0; FT_Int high = AF_ADJUSTMENT_DATABASE_LENGTH - 1; - while ( high > low ) + while ( high >= low ) { FT_Int mid = ( low + high ) / 2; FT_UInt32 mid_codepoint = adjustment_database[mid].codepoint; @@ -94,7 +190,7 @@ af_reverse_character_map_lookup( AF_ReverseCharacterMap map, FT_Int glyph_index /* Binary search for reverse character map entry */ FT_Int low = 0; FT_Int high = map->length - 1; - while ( high > low ) + while ( high >= low ) { FT_Int mid = ( high + low ) / 2; FT_Int mid_glyph_index = map->entries[mid].glyph_index; diff --git a/src/autofit/afadjust.h b/src/autofit/afadjust.h index 65cdfaa66..797947f42 100644 --- a/src/autofit/afadjust.h +++ b/src/autofit/afadjust.h @@ -9,14 +9,17 @@ FT_BEGIN_HEADER /*stacked vertically merge, even though they should be separate*/ typedef enum AF_VerticalSeparationAdjustmentType_ { - AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP, /*This means that the hinter should find the topmost contour and push it up until its lowest point is 1 pixel*/ /*above the highest point not part of that contour.*/ + AF_VERTICAL_ADJUSTMENT_TOP_CONTOUR_UP, + + /*This is the opposite direction. The hinter should find the bottommost contour*/ + /*And push it down until there is a 1 pixel gap*/ + AF_VERTICAL_ADJUSTMENT_BOTTOM_CONTOUR_DOWN, + AF_VERTICAL_ADJUSTMENT_NONE - /*others will be needed, such as the case where the lower contour should be moved in the adjustment instead of the upper one*/ - /*or umlats, where there are 2 contours which should be moved together*/ - /*and a way of handling A and O, where the letter consists of 2 contours*/ + /*others will be needed, such as umlats, where there are 2 contours which should be moved together*/ } AF_VerticalSeparationAdjustmentType; typedef struct AF_AdjustmentDatabaseEntry_