44 #include <sys/types.h> 59 printf(
"%s: [-o font_output_file ] [ -l lower_bound ] [ -u upper_bound ] [ -preview ] [ -Preview ] bdf files...\n",
61 printf(
" -o: output file containg C STructures of converted font data\n");
62 printf(
" -u: limit Glyph processing above limit\n");
63 printf(
" -l: limit Glyph processing below limit\n");
64 printf(
" -p 1 Preview font bitmap data - only parts with 1 bits set\n");
65 printf(
" -p 2 Preview Full font bitmap data - everything inside font bounding box\n");
66 printf(
" -p 3 Preview Proportional font bitmap data and fixed - everything inside font bounding box\n");
67 printf(
" -f convert any font to fixed size bitmap - everything inside font bounding box\n");
68 printf(
" -s Compact font to smallest bounding box\n");
69 printf(
" Notes: modifies or creates font specs\n");
70 printf(
" bdf files...: One of more BDF format font files\n");
91 int main(
int argc,
char *
const argv[])
96 char *name, *cfonts, *ptr;;
99 int font_adjust_full = 0;
100 int font_adjust_small = 0;
102 int lower_bound = 32;
104 int upper_bound = 127;
145 lower_bound =
atoi(ptr);
149 lower_bound =
atoi(argv[++i]);
158 upper_bound =
atoi(ptr);
162 upper_bound =
atoi(argv[++i]);
171 font_preview =
atoi(ptr);
175 font_preview =
atoi(argv[++i]);
182 font_adjust_full = 1;
188 font_adjust_small = 1;
196 if(
stat(argv[i], (
struct stat *) &buf) != 0)
206 if(font_adjust_full && font_adjust_small)
208 fprintf(
stderr,
"Can not have -f and -s set at the same time\n");
226 if(
stat(cfonts, (
struct stat *) &buf) == 0)
228 fprintf(
stderr,
"Font file: %s - exists - not overwritting\n", cfonts);
232 FO =
fopen(cfonts,
"w");
247 if(!
ReadBdf(name, &fx, lower_bound, upper_bound))
256 fprintf(
stderr,
"Duplicate font:[%s] in file:[%s], skipping\n", fx.info->STRUCT_NAME, name);
274 if(font_adjust_small)
291 fprintf(FO,
"#ifndef FONTINFO\n");
292 fprintf(FO,
" #define FONTINFO\n");
297 fprintf(FO,
"#ifndef FONTSPECS\n");
298 fprintf(FO,
" #define FONTSPECS\n");
309 fprintf(FO,
"/* All cfonts */\n");
310 fprintf(FO,
"_font *allfonts[%d] = {\n", bdfind+1);
311 for(i=0;i<bdfind;++i)
int ReadBdf(char *name, _font *font, int lower, int upper)
Read and parse a BDF file for specified font and character set range Fills fonts structures.
void FreeFont(_font *font)
Free font data.
par BDF font utils for BDF to C code converter Displays fonts generated by bdffont2c BDF to C code co...
MEMSPACE FILE * fopen(const char *path, const char *mode)
POSIX Open a file with path name and ascii file mode string.
void FontHeaderInfo(FILE *out, _font *font, char *prog, char *target)
Write Font Header Information Copyright, font family, etc.
MEMSPACE int fprintf(FILE *fp, const char *format,...)
fprintf function Example user defined printf function using fputc for I/O This method allows I/O to d...
void WriteFontBitsPreview(FILE *out, _font *font, int preview)
Write all Font characters in a font as ASCII character comments.
int FindFontName(char *str)
Search for a font name.
int main(int argc, char *const argv[])
convert BDF fonts to C structures
void ComputeGapSize(_font *font)
Find a good gap size (inter-character spacing) for any font Currently we searching for the smallest w...
MEMSPACE int fclose(FILE *stream)
POSIX close a file stream.
void FontAdjustSmall(_font *font)
Ajust font to use smallest font bounding box for each font Can be used to converting large fixed font...
MEMSPACE int printf(const char *format,...)
MEMSPACE char * basename(char *str)
POSIX Basename of filename.
void usage(char *prog)
Display Usage.
MEMSPACE char * stralloc(char *str)
Allocate space for string.
void Convert_Font2c(FILE *out, _font *font)
Convert font to C structure Writes header information, font specification, font bitmap.
MEMSPACE int stat(char *name, struct stat *buf)
POSIX stat - get file status of named file.
_bdffile BDFnames[MAXFONTS]
void FontAdjustFull(_font *font)
Adjust font to full size with no offset.
MEMSPACE int atoi(const char *str)
Convert ASCII string to number in base 10.