📄 do_char.c
字号:
#endif#if INCL_SQUEEZING || INCL_ISWfix15 x_offset_pix;#endif#if INCL_ISWfix31 char_width;fix31 isw_scale;#endif#if INCL_SQUEEZINGsp_globals.squeezing_compound = TRUE;#endifpointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding box data */pix_adj = sp_globals.onepix << 1; /* Allow 2 pixel expansion ... */Pmin.x -= pix_adj; /* ... of components of ... */Pmin.y -= pix_adj; /* ... compound ... */Pmax.x += pix_adj; /* ... character ... */Pmax.y += pix_adj; /* ... bounding box. */#if INCL_SQUEEZING/* scale the bounding box if necessary before calling begin_char */squeezed_x = calculate_x_scale(&x_factor, &x_offset, 0);squeezed_y = calculate_y_scale(&top_scale, &bottom_scale,0,0);if (squeezed_x) { /* scale the x coordinates of the bbox */ x_offset_pix = (fix15)(((x_offset >> 16) * sp_globals.tcb0.xppo) >> sp_globals.mpshift); if ((x_offset_pix >0) && (x_offset_pix < sp_globals.onepix)) x_offset_pix = sp_globals.onepix; Pmin.x = SQUEEZE_MULT (x_factor, Pmin.x) + x_offset_pix - pix_adj; Pmax.x = SQUEEZE_MULT (x_factor, Pmax.x) + x_offset_pix + pix_adj; }if (squeezed_y) { /* scale the y coordinates of the bbox */ if ((Pmin.y) < 0) Pmin.y = SQUEEZE_MULT (bottom_scale, Pmin.y) - pix_adj; else Pmin.y = SQUEEZE_MULT (top_scale, Pmin.y) - pix_adj; if ((Pmax.y) < 0) Pmax.y = SQUEEZE_MULT (bottom_scale, Pmax.y) + pix_adj; else Pmax.y = SQUEEZE_MULT (top_scale, Pmax.y) + pix_adj; }#endif#if (INCL_ISW)if (sp_globals.import_setwidth_act) { /* make sure I'm not going to get fixed point overflow */ isw_scale = ((fix31)sp_globals.imported_width << 16)/ (fix31)sp_globals.setwidth_orus; char_width = SQUEEZE_MULT((sp_globals.bbox_xmax_orus - sp_globals.bbox_xmin_orus),isw_scale); if (char_width >= sp_globals.isw_xmax) if (!reset_xmax(char_width)) return FALSE; }#endifif (fn_begin_char(sp_globals.Psw, Pmin, Pmax)) /* Signal start of character data */ { pointer_sav = pointer; do { pointer = pointer_sav; /* Point to next DOCH or END instruction */ while (format = NEXT_BYTE(pointer)) /* DOCH instruction? */ { init_tcb(); /* Initialize transformation control block */ x_posn = sp_get_posn_arg(&pointer, format); y_posn = sp_get_posn_arg(&pointer, (ufix8)(format >> 2)); x_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT4)); y_scale = sp_get_scale_arg(&pointer, (ufix8)(format & BIT5)); scale_tcb(&sp_globals.tcb, x_posn, y_posn, x_scale, y_scale); /* Scale for sub-char */ sub_char_index = (format & BIT6)? /* Read sub-char index */ 0xffff & NEXT_WORD(pointer): 0xffff & NEXT_BYTE(pointer); sub_pointer = sp_get_char_org(sub_char_index, FALSE); /* Point to start of sub-char */ if (sub_pointer == NULL) /* Character data not available? */ { return FALSE; /* Abort character output */ } sub_pointer += 2; /* Skip over character id */ x_orus = NEXT_WORD(sub_pointer); /* Read set_width of sub-character */ Pssw.x = (fix15)( (fix31)( ((fix31)x_orus * (sp_globals.specs.xxmult>>16) + ( ((fix31)x_orus * (sp_globals.specs.xxmult&0xffffL) )>>16) ) << sp_globals.pixshift) / sp_globals.metric_resolution); Pssw.y = (fix15)( (fix31)( ((fix31)x_orus * (sp_globals.specs.yxmult>>16) + ( ((fix31)x_orus * (sp_globals.specs.yxmult&0xffffL) )>>16) ) << sp_globals.pixshift) / sp_globals.metric_resolution); format = NEXT_BYTE(sub_pointer); /* Read sub-character format */ if (format & BIT1) /* Optional data in header? */ { tmpfix15 = (ufix8)NEXT_BYTE(sub_pointer); /* Read size of optional data */ sub_pointer += tmpfix15; /* Skip optional data */ } sub_pointer = plaid_tcb(sub_pointer, format); /* Process sub-character plaid data */ sub_pointer = read_bbox(sub_pointer, &Pmin, &Pmax, FALSE); /* Read bounding box */ fn_begin_sub_char(Pssw, Pmin, Pmax); /* Signal start of sub-character data */ proc_outl_data(sub_pointer); /* Process sub-character data */ fn_end_sub_char(); /* Signal end of sub-character data */ } } while (!fn_end_char()); /* Signal end of character; repeat if required */ }return TRUE;}#if INCL_LCD /* Dynamic load character data supported? */FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)GDECLufix16 char_index; /* Index of character to be accessed */boolean top_level; /* Not a compound character element *//* * Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and * sp_make_comp_char() to get a pointer to the start of the character data * for the specified character index. * Version for configuration supporting dynamic character data loading. * Calls load_char_data() to load character data if not already loaded * as part of the original font buffer. * Returns NULL if character data not available */{buff_t *pchar_data; /* Buffer descriptor requested */ufix8 FONTFAR *pointer; /* Pointer into character directory */ufix8 format; /* Character directory format byte */fix31 char_offset; /* Offset of char data from start of font file */fix31 next_char_offset; /* Offset of char data from start of font file */fix15 no_bytes; /* Number of bytes required for char data */if (top_level) /* Not element of compound char? */ { if (char_index < sp_globals.first_char_idx) /* Before start of character set? */ return NULL; char_index -= sp_globals.first_char_idx; if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */ return NULL; sp_globals.cb_offset = 0; /* Reset char buffer offset */ }pointer = sp_globals.pchar_dir;format = NEXT_BYTE(pointer); /* Read character directory format byte */pointer += char_index << 1; /* Point to indexed character entry */if (format) /* 3-byte entries in char directory? */ { pointer += char_index; /* Adjust for 3-byte entries */ char_offset = read_long(pointer); /* Read file offset to char data */ next_char_offset = read_long(pointer + 3); /* Read offset to next char */ }else { char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */ }no_bytes = next_char_offset - char_offset;if (no_bytes == 0) /* Character not in directory? */ return NULL;if (next_char_offset <= sp_globals.font_buff_size)/* Character data already in font buffer? */ return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */pchar_data = load_char_data(char_offset, no_bytes, sp_globals.cb_offset); /* Request char data load */if (pchar_data->no_bytes < no_bytes) /* Correct number of bytes loaded? */ return NULL;if (top_level) /* Not element of compound char? */ { sp_globals.cb_offset = no_bytes; }return pchar_data->org; /* Return pointer into character data buffer */}#endif#if INCL_LCD#else /* Dynamic load character data not supported? */FUNCTION static ufix8 FONTFAR *sp_get_char_org(char_index, top_level)GDECLufix16 char_index; /* Index of character to be accessed */boolean top_level; /* Not a compound character element *//* * Called by sp_get_char_id(), sp_get_char_width(), sp_make_char() and * sp_make_comp_char() to get a pointer to the start of the character data * for the specified character index. * Version for configuration not supporting dynamic character data loading. * Returns NULL if character data not available */{ufix8 FONTFAR *pointer; /* Pointer into character directory */ufix8 format; /* Character directory format byte */fix31 char_offset; /* Offset of char data from start of font file */fix31 next_char_offset; /* Offset of char data from start of font file */fix15 no_bytes; /* Number of bytes required for char data */if (top_level) /* Not element of compound char? */ { if (char_index < sp_globals.first_char_idx) /* Before start of character set? */ return NULL; char_index -= sp_globals.first_char_idx; if (char_index >= sp_globals.no_chars_avail) /* Beyond end of character set? */ return NULL; }pointer = sp_globals.pchar_dir;format = NEXT_BYTE(pointer); /* Read character directory format byte */pointer += char_index << 1; /* Point to indexed character entry */if (format) /* 3-byte entries in char directory? */ { pointer += char_index; /* Adjust for 3-byte entries */ char_offset = read_long(pointer); /* Read file offset to char data */ next_char_offset = read_long(pointer + 3); /* Read offset to next char */ }else { char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read file offset to char data */ next_char_offset = (fix31)(0xffff & NEXT_WORD(pointer)); /* Read offset to next char */ }no_bytes = next_char_offset - char_offset;if (no_bytes == 0) /* Character not in directory? */ return NULL;return sp_globals.pfont->org + char_offset; /* Return pointer into font buffer */}#endifFUNCTION static fix15 sp_get_posn_arg(ppointer, format)GDECLufix8 FONTFAR * STACKFAR *ppointer; /* Pointer to first byte of position argument */ufix8 format; /* Format of DOCH arguments *//* * Called by sp_make_comp_char() to read a position argument from the * specified point in the font/char buffer. * Updates pointer to byte following position argument. * Returns value of position argument in outline resolution units */{switch (format & 0x03) {case 1: return NEXT_WORD(*ppointer);case 2: return (fix15)((fix7)NEXT_BYTE(*ppointer));default: return (fix15)0; }}FUNCTION static fix15 sp_get_scale_arg(ppointer, format)GDECLufix8 FONTFAR *STACKFAR *ppointer; /* Pointer to first byte of position argument */ufix8 format; /* Format of DOCH arguments *//* * Called by sp_make_comp_char() to read a scale argument from the * specified point in the font/char buffer. * Updates pointer to byte following scale argument. * Returns value of scale argument in scale units (normally 1/4096) */{if (format) return NEXT_WORD(*ppointer);else return (fix15)ONE_SCALE;}#if INCL_ISW || INCL_SQUEEZINGFUNCTION static void preview_bounding_box(pointer,format)GDECLufix8 FONTFAR *pointer; /* Pointer to first byte of position argument */ufix8 format; /* Character format byte */{point_t Pmin, Pmax; /* Transformed corners of bounding box */ sp_globals.no_X_orus = (format & BIT2)? (fix15)NEXT_BYTE(pointer): 0; sp_globals.no_Y_orus = (format & BIT3)? (fix15)NEXT_BYTE(pointer): 0; pointer = read_oru_table(pointer); /* Skip over control zone table */ pointer = skip_control_zone(pointer,format); /* Skip over interpolation table */ pointer = skip_interpolation_table(pointer,format); /* get_args has a pathological need for this value to be set */ sp_globals.Y_edge_org = sp_globals.no_X_orus; pointer = read_bbox(pointer, &Pmin, &Pmax, TRUE); /* Read bounding box */}#endif#if INCL_ISWFUNCTION static boolean reset_xmax(xmax)GDECLfix31 xmax;{fix15 xmin; /* Minimum X ORU value in font */fix15 ymin; /* Minimum Y ORU value in font */fix15 ymax; /* Maximum Y ORU value in font */sp_globals.isw_modified_constants = TRUE;xmin = read_word_u(sp_globals.font_org + FH_FXMIN);ymin = read_word_u(sp_globals.font_org + FH_FYMIN);ymax = read_word_u(sp_globals.font_org + FH_FYMAX);if (!setup_consts(xmin,xmax,ymin,ymax)) { report_error(3); /* Requested specs out of range */ return FALSE; }sp_globals.constr.data_valid = FALSE;/* recompute setwidth */sp_globals.Psw.x = (fix15)((fix31)( ((fix31)sp_globals.imported_width * (sp_globals.specs.xxmult>>16) + ( ((fix31)sp_globals.imported_width * (sp_globals.specs.xxmult&0xffffL) )>>16) ) << sp_globals.pixshift) / sp_globals.metric_resolution);sp_globals.Psw.y = (fix15)( (fix31)( ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult>>16) + ( ((fix31)sp_globals.imported_width * (sp_globals.specs.yxmult&0xffffL) )>>16) ) << sp_globals.pixshift) / sp_globals.metric_resolution); return TRUE;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -