📄 cacfff.c
字号:
for (i=0; i<numrows; i++) { fprintf (fout, "\n"); for (j=0; j<numcols; j++) fprintf (fout, "%c", chardump [i][j]); }#endif}/*----------*/VOID substitute_blob_for_char (thischar, idx)DLL_FONT_CHAR *thischar;LONG idx;{thischar->bitmap_ptr = BLOB_BITMAP;/* The following is a signal for certain code below that this glyph is not * represented by a NULL_BITMAP. */ thischar->numrows = 2;thischar->numcols = 2;/* substituted blob for char., flag for device */thischar->substitute_flag = MAX_CSET_SIZE; dll_font.dll_l_bearing_tbl [idx] = dll_font.blob_l_bearing;dll_font.dll_r_bearing_tbl [idx] = dll_font.blob_r_bearing;dll_font.dll_width_tbl [idx] = dll_font.blob_width; }/*----------*//* analyze_font_file (bufptr, buflen) -- This routine interprets the font * data stored in the DCS storage area * and supplies values for all of the * following variables: * new_font_file_id * dll_char_set_id * dll_spacing * dll_first_char * dll_last_char * dll_ul_font_flag * dll_ul_offset * dll_ul_thickness * dll_strikethru_flag * dll_strikethru_offset * dll_strikethru_thickness * dll_ol_offset * dll_ol_thickness * dll_shadow_flag * dll_shadow_vertical * dll_shadow_horizontal * dll_italic_flag * dll_font_weight * dll_monospacing_flag * dll_type_size * dll_type_size_whole * dll_type_size_fraction * dll_total_vertical_size * dll_average_char_width * dll_font_horiz_prop * dll_font_horiz_prop_numerator * dll_font_horiz_prop_demoninator * dll_superscript_vert * dll_subscript_vert * dll_space_max * dll_space_min * dll_space_width * dll_above_baseline_dist * dll_below_baseline_dist * dll_scale_factor_code * dll_num_char_defs * dll_num_char_defs * dll_char [] * dll_width_tbl [] * dll_l_bearing_tbl [] * dll_r_bearing_tbl [] * dll_even_blob_bitmap_size * dll_odd_blob_bitmap_size * dll_horiz_prop_denominator * * * Analyze_font_file () returns a value of 0 if the font file is "good" * and a non-zero error code if the file is rejected due to an error * condition. */ /*----------*/BYTE analyze_font_file ( bufptr, buflen )UBYTE *bufptr;LONG buflen;{#ifdef WITHOUTPUT FILE *fptr;#endifLONG number_of_bytes_in_bitmap_port, number_of_bytes_in_bitmap_land, number_of_bytes_in_bitmap_mixed;BYTE cset_id [32];UBYTE temp_spacing, temp_spacing_fraction; /* chars so UBYTE */LONG temp_long;LONG temp, org_flags, char_dir_idx, current_locator;LONG cset_idlen, cset_idptr, temploc;LONG font_attr_flags, i, start_idx, end_idx, fontsegaddr;WORD no_dll_error_char_defined, size_of_char_params, j;LONG default_blob_l_bearing;LONG default_blob_r_bearing;LONG default_blob_width;LONG blob_bitmap_size, dll_even_blob_bitmap_size, dll_odd_blob_bitmap_size;LONG dll_even_blob_bitmap_size_land, dll_odd_blob_bitmap_size_land;LONG dll_even_blob_bitmap_size_mixed, dll_odd_blob_bitmap_size_mixed;DLL_FONT_CHAR default_blob, blob;/* LONG blob_bitmap_size_land, blob_bitmap_size_mixed; */#ifdef WITHOUTPUT printf("\nEntering Analyze\n"); dumpdcs (); printf("DCS string dumped to file DUMP1.DCS"); dump_number [5]+=1; fptr = fopen (dump_number, "w"); fprintf (fptr, "\n bufptr= %xH, buflen= %xH (%d)", bufptr,buflen,buflen); printf("\nAnalyze Log File %s opened\n",dump_number );#endif dll_font.total_portrait_bytes = dll_font.total_landscape_bytes = 0;dll_font.total_mixed_bytes = 0;no_dll_error_char_defined = FALSE;dll_font.number_of_odd_words_in_bitmaps = 0;dll_font.number_of_odd_words_in_bm_land = 0;dll_font.number_of_odd_words_in_bm_mixed = 0;/* Init the tables to zero, as blank chars (No raster) are skipped, as are * characters that character replacement is done on */for (i=0; i< MAX_CSET_SIZE; i++) { dll_font.dll_char[i].baseline=0; dll_font.dll_char[i].no_underlining=0; dll_font.dll_char[i].numrows=0; dll_font.dll_char[i].numcols=0 ; dll_font.dll_char[i].bitmap_ptr=0; dll_font.dll_char[i].substitute_flag= MAX_CSET_SIZE + 1; dll_font.dll_width_tbl[i] = 0; dll_font.dll_l_bearing_tbl[i] = 0; dll_font.dll_r_bearing_tbl[i] = 0; }/* Initialize "default blob" (default error character) */for (i=0; i < MAX_BITMAP_SIZE; i++) dll_font.default_blob_bitmap [i] = 0xff;default_blob.baseline = 0;default_blob.no_underlining = TRUE;default_blob.numrows = NUMBER_OF_BLOB_ROWS;default_blob.numcols = NUMBER_OF_BLOB_COLUMNS;default_blob.bitmap_ptr = dll_font.default_blob_bitmap;default_blob_l_bearing = 0;default_blob_r_bearing = 0;default_blob_width = 0;/* Do as much ERROR CHECKING as possible on the font file first. * * Since the program which "makes" fonts pads font files * with nulls to the nearest block (512 bytes), our only * check on font file length can be that the length stored * in the first longword of the font file must be <= the * number of bytes in the DCS buffer (buflen). */temp_long = GET_LONG(bufptr + OFFSET_TOTAL_FONT_FILE_LENGTH);if ( temp_long > buflen) {#ifdef WITHOUTPUT fprintf (fptr, "( file len stored in font file is %xH.)\n", temp_long);#endif ABORT_MACRO(41); /* Stored font file length does not match buffer len */ return (TRUE); }/* If the length of the incoming font file is less than the * offset of the character directory region, then it is too short * to even contain a full header. */if (buflen < OFFSET_CHAR_DIR_REGION) { ABORT_MACRO(42); /* font file too short to contain full header */ return (TRUE); }temp_long = GET_LONG(bufptr + OFFSET_FONT_FILE_ID_DESCRIP+4);if ( ( *((WORD *)(bufptr + OFFSET_FONT_FILE_ID_DESCRIP))!= FONT_FILE_ID_SIZE ) || ( temp_long != OFFSET_FONT_FILE_ID_STRING ) ) { ABORT_MACRO(43); /* Invalid font_file_id ptr in CFF */ return (TRUE); }/* Pick out the part that gives us the escape sequence required * to select the proper cset. */cset_idlen = *((WORD *)(bufptr + OFFSET_CHAR_SET_DES_DESCRIP));cset_idptr = GET_LONG(bufptr + OFFSET_CHAR_SET_DES_DESCRIP+4);if (cset_idlen > 32) { ABORT_MACRO(44); /* Length of cset ID in CFF too big */ return (TRUE); }for (i=0; i < cset_idlen; i++) cset_id [i] = *((BYTE *)(bufptr + cset_idptr + i));if (i < 32) cset_id [i] = 0; /* null terminate the cset ID */#ifdef WITHOUTPUT fprintf (fptr, "\n Length of charset ID string: %xH.", cset_idlen); fprintf (fptr, "\n Ptr to charset ID string: %xH.", cset_idptr); fprintf (fptr, "\n Charset ID string: %s", cset_id); if (cset_id [0] == '0') fprintf (fptr, "\n [As intermediate, use '(', ')', '*' or '+'.]"); else if (cset_id [0] == '1') fprintf (fptr, "\n [As intermediate, use '-', '.' or '/'.]");#endif/* Check for multiple font segments (anything > 1 in the * font segment table). */if ( ( fontsegaddr = GET_LONG(bufptr + OFFSET_FONTSEGLIST_REG_ADDR)) && GET_LONG(bufptr + OFFSET_FONTSEGLIST_REG_SIZE) && ((GET_LONG(bufptr + fontsegaddr)) > 1 ) ) {#ifdef WITHOUTPUT fprintf (fptr, "\nWARNING: Multiple font segments (%xH) detected ...\n", GET_LONG(bufptr + fontsegaddr) );#endif ABORT_MACRO(45); /* Multiple font segments detected */ return (TRUE); }if ( GET_LONG(bufptr + OFFSET_STRING_POOL_REGION_SIZE) && (GET_LONG(bufptr + OFFSET_STRING_POOL_REGION_ADDR) > buflen ) ) { ABORT_MACRO(46); /* STRING_POOL_REGION ptr points out of range */ return (TRUE); }if ( GET_LONG(bufptr + OFFSET_CHAR_DEF_REGION_SIZE) && ( GET_LONG(bufptr + OFFSET_CHAR_DEF_REGION_ADDR) > buflen ) ) { ABORT_MACRO(47); /* CHAR_DEF_REGION ptr points out of range */ return (TRUE); } /* End of integrity check on pointers *//* * DEC Common Font File Format Appendix G, "Imaging Device Specifics", * lists several file conditions that cause rejection of the downloaded * font file. These are: * * Multiple font segments * Compressed rasters * Characters not portrait oriented (i.e., rotated) * Parameters larger than 16 bits * More/less than 16 bytes of character parameters * Font design resolution other than 300 DPI * Pixel aspect ratio other than 1:1 * * In addition, the translator handles only binary font encoding * and standard character subsets. * * Read in the font file ID, and then check for these conditions. */strncpy (dll_font.new_font_file_id, bufptr + OFFSET_FONT_FILE_ID_STRING, FONT_FILE_ID_SIZE);/* Mark end of font_file_id with a null */ dll_font.new_font_file_id [FONT_FILE_ID_SIZE] = 0;/* Check that all chars in ID string are valid */ for (i=0; i < FONT_FILE_ID_SIZE; i++) if ( ( (dll_font.new_font_file_id [i] < '0') || (dll_font.new_font_file_id [i] > '9') ) && ( (dll_font.new_font_file_id [i] < 'A') || (dll_font.new_font_file_id [i] > 'Z') ) ) { ABORT_MACRO(48); /* Illegal char in font file ID */ return (TRUE); }/* Get the 3-byte base-36 character set ID from Bytes 19-21 of the * font file ID and convert it to a 16-bit hex value. */dll_font.dll_char_set_id = 0;for (i=20, j=1; i>=18; i--, j *= 36) { temp = dll_font.new_font_file_id [i]; if ( ('A' <= temp) && (temp <= 'Z') ) temp = (temp - 'A') + 10; else temp -= '0'; dll_font.dll_char_set_id += temp * j; }/* If the character set id, in its 16 bit form, of a font file == 0x3c * reassign it as 0xab5 (the id for DEC supplemental). [ 0x3c was the old * 'user preference' id which was supposedly synonymous with DEC * supplemental. Now 'user preference' is an indirect way of specifying a * character set; as such there theoretically no way of there being a 0x3c * character set. */if (dll_font.dll_char_set_id == USER_PREFERENCE) dll_font.dll_char_set_id = DEC_SUPPLEMENTAL;/* Check for compressed rasters. */org_flags = GET_LONG(bufptr + OFFSET_ORGANIZATION_FLAGS);if (org_flags & COMPRESSED_RASTERS_FLAG) { ABORT_MACRO(49); /* Compressed rasters detected */ return (TRUE); }/* Check if font is rotated. The 17th and 18th bytes of the font ID * (indexes 16 & 17) contain rotation data; they must contain "00". * Otherwise, return error. */#ifdef WITHOUTPUT fprintf (fptr, "\ndll_ff_id: %s\n", dll_font.new_font_file_id);#endif if ( (dll_font.new_font_file_id [16] != '0') || (dll_font.new_font_file_id [17] != '0') ) { ABORT_MACRO(50); /* Rotated font detected; not supported */ return (TRUE); }/* Check for parameters > 16 bits (i.e., "large values"). * (Also, check length of the parameters region of the font file.) */if ( GET_LONG(bufptr + OFFSET_FONT_PARAMS_REGION_SIZE) != 124 ) { ABORT_MACRO(51); /* Font parameters region size is invalid */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -