📄 set_trns.c
字号:
FUNCTION ufix8 FONTFAR *read_oru_table(pointer)GDECLufix8 FONTFAR *pointer; /* Pointer to first byte in controlled coord table *//* * Called by plaid_tcb() to read the controlled coordinate table from the * character data in the font. * Updates the pointer to the byte following the controlled coordinate * data. */{fix15 i, j, k, n;boolean zero_not_in;boolean zero_added;fix15 oru;#if INCL_RULESfix15 pos;#endifi = 0;n = sp_globals.no_X_orus;#if INCL_RULESpos = sp_globals.tcb.xpos;#endiffor (j = 0; ; j++) { zero_not_in = TRUE; zero_added = FALSE; for (k = 0; k < n; k++) { oru = NEXT_WORD(pointer); if (zero_not_in && (oru >= 0)) /* First positive oru value? */ {#if INCL_RULES sp_plaid.pix[i] = pos; /* Insert position in pix array */#endif if (oru != 0) /* Zero oru value omitted? */ { sp_plaid.orus[i++] = 0; /* Insert zero value in oru array */ zero_added = TRUE; /* Remember to increment size of array */ } zero_not_in = FALSE; /* Inhibit further testing for zero ins */ } sp_plaid.orus[i++] = oru; /* Add specified oru value to array */ } if (zero_not_in) /* All specified oru values negative? */ {#if INCL_RULES sp_plaid.pix[i] = pos; /* Insert position in pix array */#endif sp_plaid.orus[i++] = 0; /* Add zero oru value */ zero_added = TRUE; /* Remember to increment size of array */ } if (j) /* Both X and Y orus read? */ break; if (zero_added) sp_globals.no_X_orus++; /* Increment X array size */ n = sp_globals.no_Y_orus; /* Prepare to read Y oru values */#if INCL_RULES pos = sp_globals.tcb.ypos;#endif }if (zero_added) /* Zero Y oru value added to array? */ sp_globals.no_Y_orus++; /* Increment Y array size */#if DEBUGprintf("\nX ORUS\n");n = sp_globals.no_X_orus;for (i = 0; i < n; i++) { printf("%2d %4d\n", i, sp_plaid.orus[i]); }printf("\nY ORUS\n");n = sp_globals.no_Y_orus;for (i = 0; i < n; i++) { printf("%2d %4d\n", i, sp_plaid.orus[i + sp_globals.no_X_orus]); }#endifreturn pointer; /* Update pointer */}#if INCL_SQUEEZING || INCL_ISWFUNCTION static void calculate_x_pix(start_edge, end_edge, constr_nr, x_scale, x_offset, ppo, setwidth_pix)GDECLufix8 start_edge, end_edge;ufix16 constr_nr;fix31 x_scale;fix31 x_offset;fix31 ppo;fix15 setwidth_pix;/* * Called by sp_setup_pix_table() when X squeezing is necessary * to insert the correct edge in the global pix array */{fix15 zone_pix;fix15 start_oru, end_oru;/* compute scaled oru coordinates */start_oru= (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[start_edge], x_scale, x_offset));end_oru = (fix15)(SQUEEZE_X_ORU(sp_plaid.orus[end_edge], x_scale, x_offset));if (!sp_globals.c_act[constr_nr]) /* constraint inactive */ { /* calculate zone width */ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo) / (1<<sp_globals.mpshift)) + sp_globals.pixrnd) & sp_globals.pixfix; /* check for overflow */ if (((end_oru-start_oru) > 0) && (zone_pix < 0)) zone_pix = 0x7ffff; /* check for minimum */ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr]) goto Lx; }/* use the zone size from the constr table - scale it */zone_pix = (fix15)(((SQUEEZE_MULT(x_scale,sp_globals.c_pix[constr_nr])) + sp_globals.pixrnd) & sp_globals.pixfix);/* look for overflow */if ((sp_globals.c_pix[constr_nr] > 0) && (zone_pix < 0)) zone_pix = 0x7fff;if (start_edge > end_edge) { zone_pix = -zone_pix; }Lx:/* assign pixel value to global pix array */sp_plaid.pix[end_edge]=sp_plaid.pix[start_edge] + zone_pix;/* check for overflow */if (((sp_plaid.pix[start_edge] >0) && (zone_pix >0)) && (sp_plaid.pix[end_edge] < 0)) sp_plaid.pix[end_edge] = 0x7fff; /* set it to the max *//* be sure to be in the setwidth !*/#if INCL_ISWif (!sp_globals.import_setwidth_act) /* only check left edge if not isw only */#endifif ((sp_globals.pspecs->flags & SQUEEZE_LEFT) && (sp_plaid.pix[end_edge] < 0)) sp_plaid.pix[end_edge] = 0;if ((sp_globals.pspecs->flags & SQUEEZE_RIGHT) && (sp_plaid.pix[end_edge] > setwidth_pix)) sp_plaid.pix[end_edge] = setwidth_pix;}#endif#if INCL_SQUEEZINGFUNCTION static void calculate_y_pix(start_edge, end_edge,constr_nr, top_scale, bottom_scale,ppo,em_top_pix, em_bot_pix)GDECLufix8 start_edge, end_edge;ufix16 constr_nr;fix31 top_scale, bottom_scale; fix31 ppo;fix15 em_top_pix, em_bot_pix;/* * Called by sp_setup_pix_table() when Y squeezing is necessary * to insert the correct edge in the global pix array */{fix15 zone_pix;fix15 start_oru, end_oru;fix31 zone_width, above_base, below_base;/* check whether edge is above or below the baseline *//* and apply appropriate scale factor to get scaled oru coordinates */if (sp_plaid.orus[start_edge] < 0) start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], bottom_scale));else start_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[start_edge], top_scale));if (sp_plaid.orus[end_edge] < 0) end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], bottom_scale));else end_oru =(fix15)(SQUEEZE_MULT(sp_plaid.orus[end_edge], top_scale));if (!sp_globals.c_act[constr_nr]) /* Constraint inactive? */ { /* calculate zone width */ zone_pix = (fix15)(((((fix31)end_oru - (fix31)start_oru) * ppo) >> sp_globals.mpshift)+ sp_globals.pixrnd) & sp_globals.pixfix; /* check minimum */ if ((ABS(zone_pix)) >= sp_globals.c_pix[constr_nr]) goto Ly; }/* Use zone size from constr table */if ((end_oru >= 0) && (start_oru >=0)) /* all above baseline */ zone_pix = (fix15)(SQUEEZE_MULT(top_scale, sp_globals.c_pix[constr_nr]));else if ((end_oru <= 0) && (start_oru <=0)) /* all below baseline */ zone_pix = (fix15)(SQUEEZE_MULT(bottom_scale, sp_globals.c_pix[constr_nr]));else { /* mixture */ if (start_oru > 0) { zone_width = start_oru - end_oru; /* get % above baseline in 16.16 fixed point */ above_base = (((fix31)start_oru) << 16) / ((fix31)zone_width) ; /* get % below baseline in 16.16 fixed point */ below_base = (((fix31)-end_oru) << 16) / ((fix31)zone_width) ; } else { zone_width = end_oru - start_oru; /* get % above baseline in 16.16 fixed point */ above_base = (((fix31)-start_oru) << 16) / ((fix31)zone_width) ; /* get % below baseline in 16.16 fixed point */ below_base = (((fix31)end_oru) << 16) / ((fix31)zone_width) ; } /* % above baseline * total zone * top_scale + */ /* % below baseline * total zone * bottom_scale */ zone_pix = ((((above_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) * top_scale) + (((below_base * (fix31)sp_globals.c_pix[constr_nr]) >> 16) * bottom_scale)) >> 16; }/* make this zone pix fall on a pixel boundary */zone_pix = (zone_pix + sp_globals.pixrnd) & sp_globals.pixfix;/* if minimum is in effect make the zone one pixel */if ((sp_globals.c_pix[constr_nr] != 0) && (zone_pix < sp_globals.onepix)) zone_pix = sp_globals.onepix; if (start_edge > end_edge) { zone_pix = -zone_pix; /* Use negatve zone size */ }Ly:/* assign global pix value */sp_plaid.pix[end_edge] = sp_plaid.pix[start_edge] + zone_pix; /* Insert end pixels *//* make sure it is in the EM !*/if ((sp_globals.pspecs->flags & SQUEEZE_TOP) && (sp_plaid.pix[end_edge] > em_top_pix)) sp_plaid.pix[end_edge] = em_top_pix;if ((sp_globals.pspecs->flags & SQUEEZE_BOTTOM) && (sp_plaid.pix[end_edge] < em_bot_pix)) sp_plaid.pix[end_edge] = em_bot_pix;}FUNCTION boolean calculate_x_scale(x_factor, x_offset, no_X_ctrl_zones)GDECLfix31 *x_factor;fix31 *x_offset;fix15 no_X_ctrl_zones; /* Number of X control zones *//* * Called by sp_setup_pix_table() when squeezing is included * to determine whether X scaling is necessary. If it is, the * scale factor and offset are computed. This function returns * a boolean value TRUE = X squeezind is necessary, FALSE = no * X squeezing is necessary. */{boolean squeeze_left, squeeze_right;boolean out_on_right, out_on_left;fix15 bbox_width,set_width;fix15 bbox_xmin, bbox_xmax;fix15 x_offset_pix;fix15 i;#if INCL_ISWfix31 isw_scale;fix15 shift;#endif/* set up some flags and common calculations */squeeze_left = (sp_globals.pspecs->flags & SQUEEZE_LEFT)? TRUE:FALSE;squeeze_right = (sp_globals.pspecs->flags & SQUEEZE_RIGHT)? TRUE:FALSE;bbox_xmin = sp_globals.bbox_xmin_orus;bbox_xmax = sp_globals.bbox_xmax_orus;set_width = sp_globals.setwidth_orus;if (bbox_xmax > set_width) out_on_right = TRUE;else out_on_right = FALSE;if (bbox_xmin < 0) out_on_left = TRUE;else out_on_left = FALSE;bbox_width =bbox_xmax - bbox_xmin;/* * don't need X squeezing if: * - X squeezing not enabled * - bbox doesn't violate on left or right * - left squeezing only is enabled and char isn't out on left * - right squeezing only is enabled and char isn't out on right */if ((!squeeze_left && !squeeze_right) || (!out_on_right && !out_on_left) || (squeeze_left && !squeeze_right && !out_on_left) || (squeeze_right && !squeeze_left && !out_on_right)) return FALSE;#if INCL_ISWif (sp_globals.import_setwidth_act) { /* if both isw and squeezing is going on - let the imported */ /* setwidth factor be factored in with the squeeze */ isw_scale = compute_isw_scale(); /*sp_globals.setwidth_orus = sp_globals.imported_width;*/ }else isw_scale = 0x10000L; /* 1 in 16.16 notation */#endif/* squeezing on left and right ? */if (squeeze_left && squeeze_right) { /* calculate scale factor */ if (bbox_width < set_width) *x_factor = 0x10000L; /* 1 in 16.16 notation */ else *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;#if INCL_ISW IMPORT_FACTOR#endif /* calculate offset */ if (out_on_left) /* fall out on left ? */ *x_offset = -(fix31)*x_factor * (fix31)bbox_xmin; /* fall out on right and I am shifting only ? */ else if (out_on_right && (*x_factor == 0x10000L)) *x_offset = -(fix31)*x_factor * (fix31)(bbox_xmax - set_width); else *x_offset = 0x0L; /* 0 in 16.16 notation */ }/* squeezing on left only and violates left */else if (squeeze_left) { if (bbox_width < set_width) /* will it fit if I shift it ? */ *x_factor = 0x10000L; /* 1 in 16.16 notation */ else if (out_on_right) *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width; else *x_factor = ((fix31)set_width<<16)/ (fix31)(bbox_width - (bbox_xmax-set_width));#if INCL_ISW IMPORT_FACTOR#endif *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin; }/* I must be squeezing on right, and violates right */else { if (bbox_width < set_width) /* will it fit if I shift it ? */ { /* just shift it left - it will fit in the bbox */ *x_factor = 0x10000L; /* 1 in 16.16 notation */#if INCL_ISW IMPORT_FACTOR#endif *x_offset = (fix31)-*x_factor * (fix31)bbox_xmin; } else if (out_on_left) { *x_factor = ((fix31)set_width<<16)/(fix31)bbox_width;#if INCL_ISW IMPORT_FACTOR#endif *x_offset = 0x0L; /* 0 in 16.16 notation */ } else { *x_factor = ((fix31)set_width<<16)/(fix31)bbox_xmax;#if INCL_ISW IMPORT_FACTOR#endif *x_offset = 0x0L; /* 0 in 16.16 notation */ } }x_offset_pix = (fix15)(((*x_offset >> 16) * sp_globals.tcb0.xppo) / (1<<sp_globals.mpshift)); if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix)) x_offset_pix = sp_globals.onepix; /* look for the first non-negative oru value, scale and add the offset *//* to the corresponding pixel value - note that the pixel value *//* is set in read_oru_table. *//* look at all the X edges */for (i=0; i < (no_X_ctrl_zones+1); i++) if (sp_plaid.orus[i] >= 0) { sp_plaid.pix[i] = (SQUEEZE_MULT(sp_plaid.pix[i], *x_factor) +sp_globals.pixrnd + x_offset_pix) & sp_globals.pixfix; break; }return TRUE;}FUNCTION boolean calculate_y_scale(top_scale, bottom_scale, first_Y_zone, no_Y_ctrl_zones)GDECLfix31 *top_scale, *bottom_scale;fix15 first_Y_zone;fix15 no_Y_ctrl_zones;/* * Called by sp_setup_pix_table() when squeezing is included * to determine whether Y scaling is necessary. If it is, * two scale factors are computed, one for above the baseline, * and one for below the basline. * This function returns a boolean value TRUE = Y squeezind is necessary, * FALSE = no Y squeezing is necessary. */{boolean squeeze_top, squeeze_bottom;boolean out_on_top, out_on_bottom;fix15 bbox_top, bbox_bottom;fix15 bbox_height;fix15 i;/* set up some flags and common calculations */squeeze_top = (sp_globals.pspecs->flags & SQUEEZE_TOP)? TRUE:FALSE;squeeze_bottom = (sp_globals.pspecs->flags & SQUEEZE_BOTTOM)? TRUE:FALSE;bbox_top = sp_globals.bbox_ymax_orus;bbox_bottom = sp_globals.bbox_ymin_orus;bbox_height = bbox_top - bbox_bottom;if (bbox_top > EM_TOP) out_on_top = TRUE;else out_on_top = FALSE;if (bbox_bottom < EM_BOT) out_on_bottom = TRUE;else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -