Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* pshglob.c */ |
| 4 | /* */ |
| 5 | /* PostScript hinter global hinting management (body). */ |
| 6 | /* Inspired by the new auto-hinter module. */ |
| 7 | /* */ |
| 8 | /* Copyright 2001 by */ |
| 9 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 10 | /* */ |
| 11 | /* This file is part of the FreeType project, and may only be used */ |
| 12 | /* modified and distributed under the terms of the FreeType project */ |
| 13 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 14 | /* this file you indicate that you have read the license and */ |
| 15 | /* understand and accept it fully. */ |
| 16 | /* */ |
| 17 | /***************************************************************************/ |
| 18 | |
| 19 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 20 | #include <ft2build.h> |
| 21 | #include FT_FREETYPE_H |
| 22 | #include FT_INTERNAL_OBJECTS_H |
| 23 | #include "pshglob.h" |
| 24 | |
| 25 | #ifdef DEBUG_HINTER |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 26 | extern PSH_Globals ps_debug_globals = 0; |
| 27 | #endif |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 28 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 29 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 30 | /*************************************************************************/ |
| 31 | /*************************************************************************/ |
| 32 | /***** *****/ |
| 33 | /***** STANDARD WIDTHS *****/ |
| 34 | /***** *****/ |
| 35 | /*************************************************************************/ |
| 36 | /*************************************************************************/ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 37 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 38 | |
| 39 | /* scale the widths/heights table */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 40 | static void |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 41 | psh_globals_scale_widths( PSH_Globals globals, |
| 42 | FT_UInt direction ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 43 | { |
| 44 | PSH_Dimension dim = &globals->dimension[direction]; |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 45 | PSH_Widths stdw = &dim->stdw; |
| 46 | FT_UInt count = stdw->count; |
| 47 | PSH_Width width = stdw->widths; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 48 | FT_Fixed scale = dim->scale_mult; |
| 49 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 50 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 51 | for ( ; count > 0; count--, width++ ) |
| 52 | { |
| 53 | width->cur = FT_MulFix( width->org, scale ); |
| 54 | width->fit = FT_RoundFix( width->cur ); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 59 | /* org_width is is font units, result in device pixels, 26.6 format */ |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 60 | FT_LOCAL_DEF( FT_Pos ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 61 | psh_dimension_snap_width( PSH_Dimension dimension, |
| 62 | FT_Int org_width ) |
| 63 | { |
| 64 | FT_UInt n; |
| 65 | FT_Pos width = FT_MulFix( org_width, dimension->scale_mult ); |
| 66 | FT_Pos best = 64 + 32 + 2; |
| 67 | FT_Pos reference = width; |
| 68 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 69 | |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 70 | for ( n = 0; n < dimension->stdw.count; n++ ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 71 | { |
| 72 | FT_Pos w; |
| 73 | FT_Pos dist; |
| 74 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 75 | |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 76 | w = dimension->stdw.widths[n].cur; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 77 | dist = width - w; |
| 78 | if ( dist < 0 ) |
| 79 | dist = -dist; |
| 80 | if ( dist < best ) |
| 81 | { |
| 82 | best = dist; |
| 83 | reference = w; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if ( width >= reference ) |
| 88 | { |
| 89 | width -= 0x21; |
| 90 | if ( width < reference ) |
| 91 | width = reference; |
| 92 | } |
| 93 | else |
| 94 | { |
| 95 | width += 0x21; |
| 96 | if ( width > reference ) |
| 97 | width = reference; |
| 98 | } |
| 99 | |
| 100 | return width; |
| 101 | } |
| 102 | |
| 103 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 104 | /*************************************************************************/ |
| 105 | /*************************************************************************/ |
| 106 | /***** *****/ |
| 107 | /***** BLUE ZONES *****/ |
| 108 | /***** *****/ |
| 109 | /*************************************************************************/ |
| 110 | /*************************************************************************/ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 111 | |
| 112 | static void |
| 113 | psh_blues_set_zones_0( PSH_Blues target, |
| 114 | FT_Bool is_others, |
| 115 | FT_UInt read_count, |
| 116 | FT_Short* read, |
| 117 | PSH_Blue_Table top_table, |
| 118 | PSH_Blue_Table bot_table ) |
| 119 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 120 | FT_UInt count_top = top_table->count; |
| 121 | FT_UInt count_bot = bot_table->count; |
| 122 | FT_Bool first = 1; |
David Turner | 12d40da | 2001-10-21 15:41:11 +0000 | [diff] [blame] | 123 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 124 | FT_UNUSED( target ); |
| 125 | |
| 126 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 127 | for ( ; read_count > 0; read_count -= 2 ) |
| 128 | { |
| 129 | FT_Int reference, delta; |
| 130 | FT_UInt count; |
| 131 | PSH_Blue_Zone zones, zone; |
| 132 | FT_Bool top; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 133 | |
| 134 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 135 | /* read blue zone entry, and select target top/bottom zone */ |
| 136 | top = 0; |
| 137 | if ( first || is_others ) |
| 138 | { |
| 139 | reference = read[1]; |
| 140 | delta = read[0] - reference; |
| 141 | |
| 142 | zones = bot_table->zones; |
| 143 | count = count_bot; |
| 144 | first = 0; |
| 145 | } |
| 146 | else |
| 147 | { |
| 148 | reference = read[0]; |
| 149 | delta = read[1] - reference; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 150 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 151 | zones = top_table->zones; |
| 152 | count = count_top; |
| 153 | top = 1; |
| 154 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 155 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 156 | /* insert into sorted table */ |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 157 | zone = zones; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 158 | for ( ; count > 0; count--, zone++ ) |
| 159 | { |
| 160 | if ( reference < zone->org_ref ) |
| 161 | break; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 162 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 163 | if ( reference == zone->org_ref ) |
| 164 | { |
| 165 | FT_Int delta0 = zone->org_delta; |
| 166 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 167 | |
| 168 | /* we have two zones on the same reference position -- */ |
| 169 | /* only keep the largest one */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 170 | if ( delta < 0 ) |
| 171 | { |
| 172 | if ( delta < delta0 ) |
| 173 | zone->org_delta = delta; |
| 174 | } |
| 175 | else |
| 176 | { |
| 177 | if ( delta > delta0 ) |
| 178 | zone->org_delta = delta; |
| 179 | } |
| 180 | goto Skip; |
| 181 | } |
| 182 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 183 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 184 | for ( ; count > 0; count-- ) |
| 185 | zone[count] = zone[count-1]; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 186 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 187 | zone->org_ref = reference; |
| 188 | zone->org_delta = delta; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 189 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 190 | if ( top ) |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 191 | count_top++; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 192 | else |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 193 | count_bot++; |
| 194 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 195 | Skip: |
| 196 | read += 2; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 197 | } |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 198 | |
| 199 | top_table->count = count_top; |
| 200 | bot_table->count = count_bot; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 201 | } |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 202 | |
| 203 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 204 | /* Re-read blue zones from the original fonts and store them into out */ |
| 205 | /* private structure. This function re-orders, sanitizes and */ |
| 206 | /* fuzz-expands the zones as well. */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 207 | static void |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 208 | psh_blues_set_zones( PSH_Blues target, |
| 209 | FT_UInt count, |
| 210 | FT_Short* blues, |
| 211 | FT_UInt count_others, |
| 212 | FT_Short* other_blues, |
| 213 | FT_Int fuzz, |
| 214 | FT_Int family ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 215 | { |
| 216 | PSH_Blue_Table top_table, bot_table; |
| 217 | FT_Int count_top, count_bot; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 218 | |
| 219 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 220 | if ( family ) |
| 221 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 222 | top_table = &target->family_top; |
| 223 | bot_table = &target->family_bottom; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 224 | } |
| 225 | else |
| 226 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 227 | top_table = &target->normal_top; |
| 228 | bot_table = &target->normal_bottom; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 229 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 230 | |
| 231 | /* read the input blue zones, and build two sorted tables */ |
| 232 | /* (one for the top zones, the other for the bottom zones) */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 233 | top_table->count = 0; |
| 234 | bot_table->count = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 235 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 236 | /* first, the blues */ |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 237 | psh_blues_set_zones_0( target, 0, |
| 238 | count, blues, top_table, bot_table ); |
| 239 | psh_blues_set_zones_0( target, 1, |
| 240 | count_others, other_blues, top_table, bot_table ); |
| 241 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 242 | count_top = top_table->count; |
| 243 | count_bot = bot_table->count; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 244 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 245 | /* sanitize top table */ |
| 246 | if ( count_top > 0 ) |
| 247 | { |
| 248 | PSH_Blue_Zone zone = top_table->zones; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 249 | |
| 250 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 251 | for ( count = count_top; count > 0; count--, zone++ ) |
| 252 | { |
| 253 | FT_Int delta; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 254 | |
| 255 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 256 | if ( count > 1 ) |
| 257 | { |
| 258 | delta = zone[1].org_ref - zone[0].org_ref; |
| 259 | if ( zone->org_delta > delta ) |
| 260 | zone->org_delta = delta; |
| 261 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 262 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 263 | zone->org_bottom = zone->org_ref; |
| 264 | zone->org_top = zone->org_delta + zone->org_ref; |
| 265 | } |
| 266 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 267 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 268 | /* sanitize bottom table */ |
| 269 | if ( count_bot > 0 ) |
| 270 | { |
| 271 | PSH_Blue_Zone zone = bot_table->zones; |
| 272 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 273 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 274 | for ( count = count_bot; count > 0; count--, zone++ ) |
| 275 | { |
| 276 | FT_Int delta; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 277 | |
| 278 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 279 | if ( count > 1 ) |
| 280 | { |
| 281 | delta = zone[0].org_ref - zone[1].org_ref; |
| 282 | if ( zone->org_delta < delta ) |
| 283 | zone->org_delta = delta; |
| 284 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 285 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 286 | zone->org_top = zone->org_ref; |
| 287 | zone->org_bottom = zone->org_delta + zone->org_ref; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | /* expand top and bottom tables with blue fuzz */ |
| 292 | { |
| 293 | FT_Int dim, top, bot, delta; |
| 294 | PSH_Blue_Zone zone; |
| 295 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 296 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 297 | zone = top_table->zones; |
| 298 | count = count_top; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 299 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 300 | for ( dim = 1; dim >= 0; dim-- ) |
| 301 | { |
| 302 | if ( count > 0 ) |
| 303 | { |
| 304 | /* expand the bottom of the lowest zone normally */ |
| 305 | zone->org_bottom -= fuzz; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 306 | |
| 307 | /* expand the top and bottom of intermediate zones; */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 308 | /* checking that the interval is smaller than the fuzz */ |
| 309 | top = zone->org_top; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 310 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 311 | for ( count--; count > 0; count-- ) |
| 312 | { |
| 313 | bot = zone[1].org_bottom; |
| 314 | delta = bot - top; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 315 | |
| 316 | if ( delta < 2 * fuzz ) |
| 317 | zone[0].org_top = zone[1].org_bottom = top + delta / 2; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 318 | else |
| 319 | { |
| 320 | zone[0].org_top = top + fuzz; |
| 321 | zone[1].org_bottom = bot - fuzz; |
| 322 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 323 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 324 | zone++; |
| 325 | top = zone->org_top; |
| 326 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 327 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 328 | /* expand the top of the highest zone normally */ |
| 329 | zone->org_top = top + fuzz; |
| 330 | } |
| 331 | zone = bot_table->zones; |
| 332 | count = count_bot; |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 338 | /* reset the blues table when the device transform changes */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 339 | static void |
| 340 | psh_blues_scale_zones( PSH_Blues blues, |
| 341 | FT_Fixed scale, |
| 342 | FT_Pos delta ) |
| 343 | { |
| 344 | FT_UInt count; |
| 345 | FT_UInt num; |
| 346 | PSH_Blue_Table table = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 347 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 348 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 349 | /* Determine whether we need to suppress overshoots or */ |
| 350 | /* not. We simply need to compare the vertical scale */ |
| 351 | /* parameter to the raw bluescale value. Here is why: */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 352 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 353 | /* We need to suppress overshoots for all pointsizes. */ |
| 354 | /* At 300dpi that satisfy: */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 355 | /* */ |
| 356 | /* pointsize < 240*bluescale + 0.49 */ |
| 357 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 358 | /* This corresponds to: */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 359 | /* */ |
| 360 | /* pixelsize < 1000*bluescale + 49/24 */ |
| 361 | /* */ |
| 362 | /* scale*EM_Size < 1000*bluescale + 49/24 */ |
| 363 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 364 | /* However, for normal Type 1 fonts, EM_Size is 1000! */ |
| 365 | /* We thus only check: */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 366 | /* */ |
| 367 | /* scale < bluescale + 49/24000 */ |
| 368 | /* */ |
| 369 | /* which we shorten to */ |
| 370 | /* */ |
| 371 | /* "scale < bluescale" */ |
| 372 | /* */ |
| 373 | blues->no_overshoots = FT_BOOL( scale < blues->blue_scale ); |
| 374 | |
| 375 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 376 | /* The blue threshold is the font units distance under */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 377 | /* which overshoots are suppressed due to the BlueShift */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 378 | /* even if the scale is greater than BlueScale. */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 379 | /* */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 380 | /* It is the smallest distance such that */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 381 | /* */ |
| 382 | /* dist <= BlueShift && dist*scale <= 0.5 pixels */ |
| 383 | /* */ |
| 384 | { |
| 385 | FT_Int threshold = blues->blue_shift; |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 386 | |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 387 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 388 | while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 ) |
| 389 | threshold --; |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 390 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 391 | blues->blue_threshold = threshold; |
| 392 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 393 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 394 | for ( num = 0; num < 4; num++ ) |
| 395 | { |
| 396 | PSH_Blue_Zone zone; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 397 | |
| 398 | |
| 399 | switch ( num ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 400 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 401 | case 0: |
| 402 | table = &blues->normal_top; |
| 403 | break; |
| 404 | case 1: |
| 405 | table = &blues->normal_bottom; |
| 406 | break; |
| 407 | case 2: |
| 408 | table = &blues->family_top; |
| 409 | break; |
| 410 | default: |
| 411 | table = &blues->family_bottom; |
| 412 | break; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 413 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 414 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 415 | zone = table->zones; |
| 416 | count = table->count; |
| 417 | for ( ; count > 0; count--, zone++ ) |
| 418 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 419 | zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 420 | zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 421 | zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta; |
| 422 | zone->cur_delta = FT_MulFix( zone->org_delta, scale ); |
| 423 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 424 | /* round scaled reference position */ |
| 425 | zone->cur_ref = ( zone->cur_ref + 32 ) & -64; |
| 426 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 427 | #if 0 |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 428 | if ( zone->cur_ref > zone->cur_top ) |
| 429 | zone->cur_ref -= 64; |
| 430 | else if ( zone->cur_ref < zone->cur_bottom ) |
| 431 | zone->cur_ref += 64; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 432 | #endif |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 433 | } |
| 434 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 435 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 436 | /* process the families now */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 437 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 438 | for ( num = 0; num < 2; num++ ) |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 439 | { |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 440 | PSH_Blue_Zone zone1, zone2; |
| 441 | FT_UInt count1, count2; |
| 442 | PSH_Blue_Table normal, family; |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 443 | |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 444 | |
| 445 | switch ( num ) |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 446 | { |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 447 | case 0: |
| 448 | normal = &blues->normal_top; |
| 449 | family = &blues->family_top; |
| 450 | break; |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 451 | |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 452 | default: |
| 453 | normal = &blues->normal_bottom; |
| 454 | family = &blues->family_bottom; |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 455 | } |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 456 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 457 | zone1 = normal->zones; |
| 458 | count1 = normal->count; |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 459 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 460 | for ( ; count1 > 0; count1--, zone1++ ) |
| 461 | { |
| 462 | /* try to find a family zone whose reference position is less */ |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 463 | /* than 1 pixel far from the current zone */ |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 464 | zone2 = family->zones; |
| 465 | count2 = family->count; |
Werner Lemberg | 5da9dd7 | 2001-12-16 08:17:33 +0000 | [diff] [blame] | 466 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 467 | for ( ; count2 > 0; count2--, zone2++ ) |
| 468 | { |
| 469 | if ( FT_MulFix( zone1->org_ref - zone2->org_ref, scale ) < 64 ) |
| 470 | { |
| 471 | zone1->cur_top = zone2->cur_top; |
| 472 | zone1->cur_bottom = zone2->cur_bottom; |
| 473 | zone1->cur_ref = zone2->cur_ref; |
| 474 | zone1->cur_delta = zone2->cur_delta; |
| 475 | break; |
| 476 | } |
| 477 | } |
| 478 | } |
| 479 | } |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 483 | FT_LOCAL_DEF( void ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 484 | psh_blues_snap_stem( PSH_Blues blues, |
| 485 | FT_Int stem_top, |
| 486 | FT_Int stem_bot, |
| 487 | PSH_Alignment alignment ) |
| 488 | { |
| 489 | PSH_Blue_Table table; |
| 490 | FT_UInt count; |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 491 | FT_Pos delta; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 492 | PSH_Blue_Zone zone; |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 493 | FT_Int no_shoots; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 494 | |
| 495 | |
Werner Lemberg | a7d2f5e | 2002-02-19 01:12:23 +0000 | [diff] [blame] | 496 | alignment->align = PSH_BLUE_ALIGN_NONE; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 497 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 498 | no_shoots = blues->no_overshoots; |
| 499 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 500 | /* lookup stem top in top zones table */ |
| 501 | table = &blues->normal_top; |
| 502 | count = table->count; |
| 503 | zone = table->zones; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 504 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 505 | for ( ; count > 0; count--, zone++ ) |
| 506 | { |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 507 | delta = stem_top - zone->org_bottom; |
| 508 | if ( delta < 0 ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 509 | break; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 510 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 511 | if ( stem_top <= zone->org_top ) |
| 512 | { |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 513 | if ( no_shoots || delta <= blues->blue_threshold ) |
| 514 | { |
| 515 | alignment->align |= PSH_BLUE_ALIGN_TOP; |
| 516 | alignment->align_top = zone->cur_ref; |
| 517 | } |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 518 | break; |
| 519 | } |
| 520 | } |
| 521 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 522 | /* look up stem bottom in bottom zones table */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 523 | table = &blues->normal_bottom; |
| 524 | count = table->count; |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 525 | zone = table->zones + count-1; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 526 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 527 | for ( ; count > 0; count--, zone-- ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 528 | { |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 529 | delta = zone->org_top - stem_bot; |
| 530 | if ( delta < 0 ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 531 | break; |
| 532 | |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 533 | if ( stem_bot >= zone->org_bottom ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 534 | { |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 535 | if ( no_shoots || delta < blues->blue_shift ) |
| 536 | { |
| 537 | alignment->align |= PSH_BLUE_ALIGN_BOT; |
| 538 | alignment->align_bot = zone->cur_ref; |
| 539 | } |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 540 | break; |
| 541 | } |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 546 | /*************************************************************************/ |
| 547 | /*************************************************************************/ |
| 548 | /***** *****/ |
| 549 | /***** GLOBAL HINTS *****/ |
| 550 | /***** *****/ |
| 551 | /*************************************************************************/ |
| 552 | /*************************************************************************/ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 553 | |
| 554 | static void |
| 555 | psh_globals_destroy( PSH_Globals globals ) |
| 556 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 557 | if ( globals ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 558 | { |
| 559 | FT_Memory memory; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 560 | |
| 561 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 562 | memory = globals->memory; |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 563 | globals->dimension[0].stdw.count = 0; |
| 564 | globals->dimension[1].stdw.count = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 565 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 566 | globals->blues.normal_top.count = 0; |
| 567 | globals->blues.normal_bottom.count = 0; |
| 568 | globals->blues.family_top.count = 0; |
| 569 | globals->blues.family_bottom.count = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 570 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 571 | FT_FREE( globals ); |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 572 | |
| 573 | #ifdef DEBUG_HINTER |
| 574 | ps_debug_globals = 0; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 575 | #endif |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 576 | } |
| 577 | } |
| 578 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 579 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 580 | static FT_Error |
| 581 | psh_globals_new( FT_Memory memory, |
| 582 | T1_Private* priv, |
| 583 | PSH_Globals *aglobals ) |
| 584 | { |
| 585 | PSH_Globals globals; |
| 586 | FT_Error error; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 587 | |
| 588 | |
David Turner | e459d74 | 2002-03-22 13:52:37 +0000 | [diff] [blame^] | 589 | if ( !FT_NEW( globals ) ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 590 | { |
| 591 | FT_UInt count; |
| 592 | FT_Short* read; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 593 | |
| 594 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 595 | globals->memory = memory; |
| 596 | |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 597 | /* copy standard widths */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 598 | { |
| 599 | PSH_Dimension dim = &globals->dimension[1]; |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 600 | PSH_Width write = dim->stdw.widths; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 601 | |
| 602 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 603 | write->org = priv->standard_width[1]; |
| 604 | write++; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 605 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 606 | read = priv->snap_widths; |
| 607 | for ( count = priv->num_snap_widths; count > 0; count-- ) |
| 608 | { |
| 609 | write->org = *read; |
| 610 | write++; |
| 611 | read++; |
| 612 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 613 | |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 614 | dim->stdw.count = write - dim->stdw.widths; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | /* copy standard heights */ |
| 618 | { |
| 619 | PSH_Dimension dim = &globals->dimension[0]; |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 620 | PSH_Width write = dim->stdw.widths; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 621 | |
| 622 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 623 | write->org = priv->standard_height[1]; |
| 624 | write++; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 625 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 626 | read = priv->snap_heights; |
| 627 | for ( count = priv->num_snap_heights; count > 0; count-- ) |
| 628 | { |
| 629 | write->org = *read; |
| 630 | write++; |
| 631 | read++; |
| 632 | } |
| 633 | |
Werner Lemberg | 49bcf78 | 2002-03-06 06:05:56 +0000 | [diff] [blame] | 634 | dim->stdw.count = write - dim->stdw.widths; |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 635 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 636 | |
| 637 | /* copy blue zones */ |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 638 | psh_blues_set_zones( &globals->blues, priv->num_blue_values, |
| 639 | priv->blue_values, priv->num_other_blues, |
| 640 | priv->other_blues, priv->blue_fuzz, 0 ); |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 641 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 642 | psh_blues_set_zones( &globals->blues, priv->num_family_blues, |
| 643 | priv->family_blues, priv->num_family_other_blues, |
| 644 | priv->family_other_blues, priv->blue_fuzz, 1 ); |
| 645 | |
David Turner | 0515c09 | 2001-12-21 04:16:42 +0000 | [diff] [blame] | 646 | globals->blues.blue_scale = priv->blue_scale |
Werner Lemberg | f05003d | 2001-12-21 10:57:09 +0000 | [diff] [blame] | 647 | ? priv->blue_scale |
| 648 | : 0x28937L; /* 0.039625 * 0x400000L */ |
David Turner | bce2986 | 2001-12-14 14:52:58 +0000 | [diff] [blame] | 649 | |
David Turner | 0515c09 | 2001-12-21 04:16:42 +0000 | [diff] [blame] | 650 | globals->blues.blue_shift = priv->blue_shift |
Werner Lemberg | f05003d | 2001-12-21 10:57:09 +0000 | [diff] [blame] | 651 | ? priv->blue_shift |
| 652 | : 7; |
David Turner | 2b30c17 | 2001-12-12 16:07:29 +0000 | [diff] [blame] | 653 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 654 | globals->dimension[0].scale_mult = 0; |
| 655 | globals->dimension[0].scale_delta = 0; |
| 656 | globals->dimension[1].scale_mult = 0; |
| 657 | globals->dimension[1].scale_delta = 0; |
| 658 | |
| 659 | #ifdef DEBUG_HINTER |
| 660 | ps_debug_globals = globals; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 661 | #endif |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 662 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 663 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 664 | *aglobals = globals; |
| 665 | return error; |
| 666 | } |
| 667 | |
| 668 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 669 | static FT_Error |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 670 | psh_globals_set_scale( PSH_Globals globals, |
| 671 | FT_Fixed x_scale, |
| 672 | FT_Fixed y_scale, |
| 673 | FT_Fixed x_delta, |
| 674 | FT_Fixed y_delta ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 675 | { |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 676 | PSH_Dimension dim = &globals->dimension[0]; |
| 677 | |
| 678 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 679 | dim = &globals->dimension[0]; |
| 680 | if ( x_scale != dim->scale_mult || |
| 681 | x_delta != dim->scale_delta ) |
| 682 | { |
| 683 | dim->scale_mult = x_scale; |
| 684 | dim->scale_delta = x_delta; |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 685 | |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 686 | psh_globals_scale_widths( globals, 0 ); |
| 687 | } |
| 688 | |
| 689 | dim = &globals->dimension[1]; |
| 690 | if ( y_scale != dim->scale_mult || |
| 691 | y_delta != dim->scale_delta ) |
| 692 | { |
| 693 | dim->scale_mult = y_scale; |
| 694 | dim->scale_delta = y_delta; |
| 695 | |
| 696 | psh_globals_scale_widths( globals, 1 ); |
| 697 | psh_blues_scale_zones( &globals->blues, y_scale, y_delta ); |
| 698 | } |
| 699 | |
| 700 | return 0; |
| 701 | } |
| 702 | |
| 703 | |
David Turner | bc82f1b | 2002-03-01 02:26:22 +0000 | [diff] [blame] | 704 | FT_LOCAL_DEF( void ) |
David Turner | a83bc08 | 2001-10-18 11:38:43 +0000 | [diff] [blame] | 705 | psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ) |
| 706 | { |
| 707 | funcs->create = psh_globals_new; |
| 708 | funcs->set_scale = psh_globals_set_scale; |
| 709 | funcs->destroy = psh_globals_destroy; |
| 710 | } |
Werner Lemberg | c3b2160 | 2001-12-05 01:22:05 +0000 | [diff] [blame] | 711 | |
| 712 | |
| 713 | /* END */ |