📄 nsample.c
字号:
#if DEBUGprintf("\nCharacter data(%d, %d, %d) requested\n", file_offset, no_bytes, cb_offset);#endifif (fseek(fdescr, (long)file_offset, (int)0) != 0) { printf("****** Error in seeking character\n"); fclose(fdescr); exit(1); }if ((no_bytes + cb_offset) > minchrsz) { printf("****** Character buffer overflow\n"); fclose(fdescr); exit(3); }bytes_read = fread((char_buffer + cb_offset), sizeof(ufix8), no_bytes, fdescr);if (bytes_read != no_bytes) { printf("****** Error on reading character data\n"); fclose(fdescr); exit(2); }#if DEBUGprintf("Character data loaded\n");#endifchar_data.org = (ufix8 FONTFAR *)char_buffer + cb_offset;char_data.no_bytes = no_bytes;return &char_data;}#endif#if REENTRANT_ALLOCFUNCTION void sp_report_error(sp_global_ptr,n)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_report_error(n)#endiffix15 n; /* Error identification number *//* * Called by Speedo character generator to report an error. * * Since character data not available is one of those errors * that happens many times, don't report it to user */{switch(n) {case 1: printf("Insufficient font data loaded\n"); break;case 3: printf("Transformation matrix out of range\n"); break;case 4: printf("Font format error\n"); break; case 5: printf("Requested specs not compatible with output module\n"); break;case 7: printf("Intelligent transformation requested but not supported\n"); break;case 8: printf("Unsupported output mode requested\n"); break;case 9: printf("Extended font loaded but only compact fonts supported\n"); break;case 10: printf("Font specs not set prior to use of font\n"); break;case 12: break;case 13: printf("Track kerning data not available()\n"); break;case 14: printf("Pair kerning data not available()\n"); break;default: printf("report_error(%d)\n", n); break; }}#if REENTRANT_ALLOCFUNCTION void sp_open_bitmap(sp_global_ptr, x_set_width, y_set_width, xorg, yorg, xsize, ysize)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_open_bitmap(x_set_width, y_set_width, xorg, yorg, xsize, ysize)#endiffix31 x_set_width;fix31 y_set_width; /* Set width vector */fix31 xorg; /* Pixel boundary at left extent of bitmap character */fix31 yorg; /* Pixel boundary at right extent of bitmap character */fix15 xsize; /* Pixel boundary of bottom extent of bitmap character */fix15 ysize; /* Pixel boundary of top extent of bitmap character *//* * Called by Speedo character generator to initialize a buffer prior * to receiving bitmap data. */{fix15 i;#if DEBUGprintf("open_bitmap(%3.1f, %3.1f, %3.1f, %3.1f, %d, %d)\n", (real)x_set_width / 65536.0, (real)y_set_width / 65536.0, (real)xorg / 65536.0, (real)yorg / 65536.0, (int)xsize, (int)ysize);#endifraswid = xsize;rashgt = ysize;offhor = (fix15)(xorg >> 16);offver = (fix15)(yorg >> 16);if (raswid > MAX_BITS) raswid = MAX_BITS;printf("\nCharacter index = %d, ID = %d\n", char_index, char_id);printf("set width = %3.1f, %3.1f\n", (real)x_set_width / 65536.0, (real)y_set_width / 65536.0);printf("X offset = %d\n", offhor);printf("Y offset = %d\n\n", offver);for (i = 0; i < raswid; i++) { line_of_bits[i << 1] = '.'; line_of_bits[(i << 1) + 1] = ' '; }line_of_bits[raswid << 1] = '\0';y_cur = 0;}#if REENTRANT_ALLOCFUNCTION void sp_set_bitmap_bits (sp_global_ptr, y, xbit1, xbit2)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_set_bitmap_bits (y, xbit1, xbit2)#endif fix15 y; /* Scan line (0 = first row above baseline) */ fix15 xbit1; /* Pixel boundary where run starts */ fix15 xbit2; /* Pixel boundary where run ends *//* * Called by Speedo character generator to write one row of pixels * into the generated bitmap character. */{fix15 i;#if DEBUGprintf("set_bitmap_bits(%d, %d, %d)\n", (int)y, (int)xbit1, (int)xbit2);#endif/* Clip runs beyond end of buffer */if (xbit1 > MAX_BITS) xbit1 = MAX_BITS;if (xbit2 > MAX_BITS) xbit2 = MAX_BITS;/* Output backlog lines if any */while (y_cur != y) { printf(" %s\n", line_of_bits); for (i = 0; i < raswid; i++) { line_of_bits[i << 1] = '.'; } y_cur++; }/* Add bits to current line */for (i = xbit1; i < xbit2; i++) { line_of_bits[i << 1] = 'X'; }}#if REENTRANT_ALLOCFUNCTION void sp_close_bitmap(sp_global_ptr)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_close_bitmap()#endif/* * Called by Speedo character generator to indicate all bitmap data * has been generated. */{#if DEBUGprintf("close_bitmap()\n");#endifprintf(" %s\n", line_of_bits);}#if INCL_OUTLINE#if REENTRANT_ALLOCFUNCTION void sp_open_outline(sp_global_ptr, x_set_width, y_set_width, xmin, xmax, ymin, ymax)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_open_outline(x_set_width, y_set_width, xmin, xmax, ymin, ymax)#endiffix31 x_set_width;fix31 y_set_width; /* Transformed escapement vector */fix31 xmin; /* Minimum X value in outline */fix31 xmax; /* Maximum X value in outline */fix31 ymin; /* Minimum Y value in outline */fix31 ymax; /* Maximum Y value in outline *//* * Called by Speedo character generator to initialize prior to * outputting scaled outline data. */{printf("\nopen_outline(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n", (real)x_set_width / 65536.0, (real)y_set_width / 65536.0, (real)xmin / 65536.0, (real)xmax / 65536.0, (real)ymin / 65536.0, (real)ymax / 65536.0);}#if REENTRANT_ALLOCFUNCTION void sp_start_new_char(sp_global_ptr)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_start_new_char()#endif/* * Called by Speedo character generator to initialize prior to * outputting scaled outline data for a sub-character in a compound * character. */{printf("start_new_char()\n");}#if REENTRANT_ALLOCFUNCTION void sp_start_contour(sp_global_ptr, x, y, outside)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_start_contour(x, y, outside)#endiffix31 x; /* X coordinate of start point in 1/65536 pixels */fix31 y; /* Y coordinate of start point in 1/65536 pixels */boolean outside; /* TRUE if curve encloses ink (Counter-clockwise) *//* * Called by Speedo character generator at the start of each contour * in the outline data of the character. */{printf("start_contour(%3.1f, %3.1f, %s)\n", (real)x / 65536.0, (real)y / 65536.0, outside? "outside": "inside");}#if REENTRANT_ALLOCFUNCTION void sp_curve_to(sp_global_ptr, x1, y1, x2, y2, x3, y3)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_curve_to(x1, y1, x2, y2, x3, y3)#endiffix31 x1; /* X coordinate of first control point in 1/65536 pixels */fix31 y1; /* Y coordinate of first control point in 1/65536 pixels */fix31 x2; /* X coordinate of second control point in 1/65536 pixels */fix31 y2; /* Y coordinate of second control point in 1/65536 pixels */fix31 x3; /* X coordinate of curve end point in 1/65536 pixels */fix31 y3; /* Y coordinate of curve end point in 1/65536 pixels *//* * Called by Speedo character generator onece for each curve in the * scaled outline data of the character. This function is only called if curve * output is enabled in the set_specs() call. */{printf("curve_to(%3.1f, %3.1f, %3.1f, %3.1f, %3.1f, %3.1f)\n", (real)x1 / 65536.0, (real)y1 / 65536.0, (real)x2 / 65536.0, (real)y2 / 65536.0, (real)x3 / 65536.0, (real)y3 / 65536.0);}#if REENTRANT_ALLOCFUNCTION void sp_line_to(sp_global_ptr, x, y)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_line_to(x, y)#endiffix31 x; /* X coordinate of vector end point in 1/65536 pixels */fix31 y; /* Y coordinate of vector end point in 1/65536 pixels *//* * Called by Speedo character generator onece for each vector in the * scaled outline data for the character. This include curve data that has * been sub-divided into vectors if curve output has not been enabled * in the set_specs() call. */{printf("line_to(%3.1f, %3.1f)\n", (real)x / 65536.0, (real)y / 65536.0);}#if REENTRANT_ALLOCFUNCTION void sp_close_contour(sp_global_ptr)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_close_contour()#endif/* * Called by Speedo character generator at the end of each contour * in the outline data of the character. */{printf("close_contour()\n");}#if REENTRANT_ALLOCFUNCTION void sp_close_outline(sp_global_ptr)SPEEDO_GLOBALS *sp_global_ptr;#elseFUNCTION void sp_close_outline()#endif/* * Called by Speedo character generator at the end of output of the * scaled outline of the character. */{printf("close_outline()\n");}#endifFUNCTION fix15 read_2b(pointer)ufix8 FONTFAR *pointer;/* * Reads 2-byte field from font buffer */{fix15 temp;temp = *pointer++;temp = (temp << 8) + *(pointer);return temp;}FUNCTION fix31 read_4b(pointer)ufix8 FONTFAR *pointer;/* * Reads 4-byte field from font buffer */{fix31 temp;temp = *pointer++;temp = (temp << 8) + *(pointer++);temp = (temp << 8) + *(pointer++);temp = (temp << 8) + *(pointer);return temp;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -