Skip to content

Commit

Permalink
Added -s option to tweak output to match format needed for SmartMatri…
Browse files Browse the repository at this point in the history
…x library

Now the .c file can be copied directly to the SmartMatrix library without modification
  • Loading branch information
Louis Beaudoin committed Sep 11, 2014
1 parent f68c238 commit b07deb7
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions bdf2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
//////////////////////////////////////////////////////////////////////////////

int Outline; ///< true generate outlined font
int SmartMatrix; // modify output to be used in the SmartMatrix library

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -128,10 +129,16 @@ void CreateFontHeaderFile(FILE * out)
///
void Header(FILE * out, const char *name)
{
char * headername;
if(!SmartMatrix)
headername = "font";
else
headername = "MatrixFontCommon";

fprintf(out,
"// Created from bdf2c Version %s, (c) 2009, 2010 by Lutz Sammer\n"
"//\tLicense AGPLv3: GNU Affero General Public License version 3\n"
"\n#include \"font.h\"\n\n", VERSION);
"\n#include \"%s.h\"\n\n", VERSION, headername);

fprintf(out,
"\t/// character bitmap for each encoding\n"
Expand Down Expand Up @@ -197,7 +204,12 @@ void Footer(FILE * out, const char *name, int width, int height, int chars)
name);
fprintf(out, "\t.Width = %d, .Height = %d,\n", width, height);
fprintf(out, "\t.Chars = %d,\n", chars);
fprintf(out, "\t.Widths = __%s_widths__,\n", name);

if(!SmartMatrix)
fprintf(out, "\t.Widths = __%s_widths__,\n", name);
else
fprintf(out, "\t.Widths = 0,\n");

fprintf(out, "\t.Index = __%s_index__,\n", name);
fprintf(out, "\t.Bitmap = __%s_bitmap__,\n", name);
fprintf(out, "};\n\n");
Expand Down Expand Up @@ -589,7 +601,8 @@ void ReadBdf(FILE * bdf, FILE * out, const char *name)
}

// Output width table for proportional font.
WidthTable(out, name, width_table, chars);
if(!SmartMatrix)
WidthTable(out, name, width_table, chars);
// FIXME: Output offset table for proportional font.
// OffsetTable(out, name, offset_table, chars);
// Output encoding table for utf-8 support
Expand Down Expand Up @@ -641,7 +654,7 @@ int main(int argc, char *const argv[])
// Parse arguments.
//
for (;;) {
switch (getopt(argc, argv, "bcC:n:hO?-")) {
switch (getopt(argc, argv, "bcC:n:hOs?-")) {
case 'b': // bdf file name
ReadBdf(stdin, stdout, name);
continue;
Expand All @@ -667,6 +680,9 @@ int main(int argc, char *const argv[])
case 'O':
Outline = 1;
continue;
case 's':
SmartMatrix = 1;
continue;

case EOF:
break;
Expand Down

0 comments on commit b07deb7

Please sign in to comment.