/** *Parsedprogramarguments
*/ struct program_args
{ constchar *font_file; enum program_mode mode; int ucode; /* Unicode character to display in 'c' mode */
};
/**************************************************************************//**
* Parses the program args
*
* @param argc Passed to main
* @param @argv Passed to main
* @param pa program_pargs structure for resulting values
* @return !=0for success
*/ staticint
parse_program_args(int argc, char *argv[], struct program_args *pa)
{ int params_ok = 1; int opt;
if (fv1->glyphs->count == 0)
{
g_printf("\nFile contains no glyphs\n");
} else
{
g_printf("Min glyph index : U+%04X\n", FV1_MIN_CHAR);
g_printf("Max glyph index : U+%04X\n", FV1_GLYPH_END(fv1) - 1);
/* Work out the statistics */ unsignedshort max_width = 0; int max_width_ucode = 0; unsignedshort max_height = 0; int max_height_ucode = 0; short min_baseline = 0; int min_baseline_ucode = 0; short min_offset = 0; int min_offset_ucode = 0; short max_offset = 0; int max_offset_ucode = 0; unsignedshort max_inc_by = 0; int max_inc_by_ucode = 0;
/* Derived quantities */ short min_y_descender = SHRT_MAX; int min_y_descender_ucode = 0; int max_datasize = -1; int max_datasize_ucode = 0;
/* Loop and output macros */ #define SET_MIN(ucode,field,val) \ if ((field) < (val)) \
{ \
val = (field); \
val##_ucode = (ucode); \
}
#define SET_MAX(ucode,field,val) \ if ((field) > (val)) \
{ \
val = (field); \
val##_ucode = (ucode); \
}
#define OUTPUT_INFO(string, val) \ if (val##_ucode > 0) \
{ \
g_printf(string, val, val##_ucode); \
} int u; for (u = FV1_MIN_CHAR ; u < FV1_GLYPH_END(fv1); ++u)
{ conststruct fv1_glyph *g = FV1_GET_GLYPH(fv1, u); if (g != NULL)
{ short y_descender = - (g->baseline + g->height); int datasize = FONT_DATASIZE(g);
/**************************************************************************//**
* Display info in a table about all the glyphs
* @param fv1 font file
*/ staticvoid
display_glyph_info_table(conststruct fv1_file *fv1)
{ int u;
g_printf("character,width,height,baseline,offset,inc_by,datasize\n");
for (u = FV1_MIN_CHAR; u < FV1_GLYPH_END(fv1); ++u)
{ conststruct fv1_glyph *g = FV1_GET_GLYPH(fv1, u); if (g != NULL)
{ int datasize = FONT_DATASIZE(g);
g_printf("%d,%hu,%hu,%hd,%hd,%hu,%d\n",
u, g->width, g->height, g->baseline,
g->offset, g->inc_by, datasize);
}
}
}
/**************************************************************************//**
* Converts a font data row to a printable string
*
* @param rowdata Pointer to the first byte of the row data
* @param width Number of pixels in the row
* @param out Output buffer. Must be sized by the caller to be at
* least width+1 bytes
*/ staticvoid
row_to_str(constunsignedchar *rowdata, int width, char *out)
{ int x; int mask = 1 << 7; for (x = 0 ; x < width ; ++x)
{
out[x] = ((*rowdata & mask) != 0) ? 'X' : '.';
mask >>= 1; if (mask == 0)
{
mask = 1 << 7;
++rowdata;
}
}
out[width] = '\0';
}
/**************************************************************************//**
* Display info about a specific glyph
* @param ucode Unicode character value
* @param g Glyph
*/ staticvoid
display_glyph_info(int ucode, conststruct fv1_glyph *g)
{
case PM_GLYPH_INFO_TABLE:
display_glyph_info_table(fv1);
rv = 0; break;
case PM_SHOW_CHAR: if (pa.ucode < FV1_MIN_CHAR)
{
LOG(LOG_LEVEL_ERROR, "Value for -c must be at least U+%04X",
FV1_MIN_CHAR);
} elseif (pa.ucode >= FV1_GLYPH_END(fv1))
{
LOG(LOG_LEVEL_ERROR, "Value for -c must be less than U+%04X",
FV1_GLYPH_END(fv1));
} else
{ conststruct fv1_glyph *g =
(conststruct fv1_glyph *)
list_get_item(fv1->glyphs, pa.ucode - FV1_MIN_CHAR);
display_glyph_info(pa.ucode, g);
rv = 0;
} break;
default:
LOG(LOG_LEVEL_ERROR, "Specify one of '-i' or '-c'"); break;
}
}
fv1_file_free(fv1);
log_end();
return rv;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-07-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.