mirror of
https://github.com/zyphlar/bdf2c.git
synced 2024-03-08 13:47:46 +00:00
Documentation and release cleanups.
This commit is contained in:
parent
df59514df6
commit
3214f24205
3
.gitattributes
vendored
3
.gitattributes
vendored
|
@ -1,3 +1,4 @@
|
||||||
# gitattributes(5) file
|
# gitattributes(5) file
|
||||||
*.[ch] ident
|
*.[ch1] ident
|
||||||
Makefile ident
|
Makefile ident
|
||||||
|
README.txt ident
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,4 +7,5 @@
|
||||||
bdf2c
|
bdf2c
|
||||||
font.h
|
font.h
|
||||||
|
|
||||||
|
html
|
||||||
chaos
|
chaos
|
||||||
|
|
4
Changelog.txt
Normal file
4
Changelog.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
User johns
|
||||||
|
Date Fri Sep 24 15:55:08 CEST 2010
|
||||||
|
|
||||||
|
Initial official release.
|
38
Makefile
38
Makefile
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# @file Makefile bdf2c
|
# @file Makefile @brief bdf2c - converts bdf font files into C files
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 by Johns. All Rights Reserved.
|
# Copyright (c) 2009, 2010 by Lutz Sammer. All Rights Reserved.
|
||||||
#
|
#
|
||||||
# Contributor(s):
|
# Contributor(s):
|
||||||
#
|
#
|
||||||
|
@ -26,26 +26,44 @@ LDFLAGS =
|
||||||
|
|
||||||
OBJS = bdf2c.o
|
OBJS = bdf2c.o
|
||||||
HDRS =
|
HDRS =
|
||||||
MISC = font.h Makefile agpl-3.0.txt readme.txt
|
FILES = Makefile AGPL-3.0.txt README.txt Changlog.txt
|
||||||
|
|
||||||
all: bdf2c
|
all: bdf2c
|
||||||
|
|
||||||
$(OBJS): $(HDRS)
|
$(OBJS): $(HDRS) Makefile
|
||||||
|
|
||||||
utv: $(OBJS)
|
bdf2c: $(OBJS)
|
||||||
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)
|
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm *.o *~
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Developer tools
|
# Developer tools
|
||||||
|
|
||||||
|
doc: $(SRCS) $(HDRS) bdf2c.doxyfile
|
||||||
|
(cat bdf2c.doxyfile; \
|
||||||
|
echo 'PROJECT_NUMBER=${VERSION} $(if $(GIT_REV), (GIT-$(GIT_REV)))') \
|
||||||
|
| doxygen -
|
||||||
|
|
||||||
indent:
|
indent:
|
||||||
for i in $(OBJS:.o=.c) $(HDRS); do \
|
for i in $(OBJS:.o=.c) $(HDRS); do \
|
||||||
indent $$i; unexpand -a $$i > $$i.up; mv $$i.up $$i; \
|
indent $$i; unexpand -a $$i > $$i.up; mv $$i.up $$i; \
|
||||||
done
|
done
|
||||||
|
|
||||||
commit:
|
clean:
|
||||||
git commit $(OBJS:.o=.c) $(HDRS) $(MISC)
|
-rm *.o *~
|
||||||
|
|
||||||
|
clobber: clean
|
||||||
|
-rm bdf2c
|
||||||
|
|
||||||
|
dist:
|
||||||
|
tar cjCf .. bdf2c-`date +%F-%H`.tar.bz2 \
|
||||||
|
$(addprefix bdf2c/, $(FILES) $(OBJS:.o=.c))
|
||||||
|
|
||||||
|
install:
|
||||||
|
strip --strip-unneeded -R .comment bdf2c
|
||||||
|
install -s bdf2c /usr/local/bin/
|
||||||
|
|
||||||
|
commit:
|
||||||
|
git commit $(OBJS:.o=.c) $(HDRS) $(FILES)
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "make all|doc|indent|clean|clobber|dist|install|help"
|
||||||
|
|
45
README.txt
Normal file
45
README.txt
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
@file README @brief BDF Font to C source convertor readme
|
||||||
|
|
||||||
|
Copyright (c) 2009, 2010 by Lutz Sammer. All Rights Reserved.
|
||||||
|
|
||||||
|
Contributor(s):
|
||||||
|
|
||||||
|
License: AGPLv3
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
|
||||||
|
My version of BDF fonts convertor to C includes, which can be used to
|
||||||
|
embed fonts into the executable.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
./bdf2c -c
|
||||||
|
|
||||||
|
Print #defines for font files to stdout.
|
||||||
|
|
||||||
|
./bdf2c -C font.h
|
||||||
|
|
||||||
|
Create font.h, which contains #defines for fonts.
|
||||||
|
|
||||||
|
./bdf2c -b < font.bdf > font.c
|
||||||
|
|
||||||
|
Create font.c which contains the converted bdf font.
|
||||||
|
|
||||||
|
The C file contains:
|
||||||
|
|
||||||
|
Bitmap data for the characters.
|
||||||
|
Character width table for proportional font
|
||||||
|
Character codes table for utf-8 font
|
||||||
|
|
||||||
|
TODO:
|
||||||
|
Proportional fonts (f.e. generated from ttf2bdf) aren't yet supported.
|
||||||
|
Example how to use the created font file.
|
47
bdf2c.1
47
bdf2c.1
|
@ -1,7 +1,7 @@
|
||||||
.\"
|
.\"
|
||||||
.\" bdf2c.1 bdf2c man page
|
.\" bdf2c.1 bdf2c - bdf to c convertor man page
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 2009 by Johns. All Rights Reserved.
|
.\" Copyright (c) 2009, 2010 by Lutz Sammer. All Rights Reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Contributor(s):
|
.\" Contributor(s):
|
||||||
.\"
|
.\"
|
||||||
|
@ -17,51 +17,48 @@
|
||||||
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
.\" GNU Affero General Public License for more details.
|
.\" GNU Affero General Public License for more details.
|
||||||
.\"
|
.\"
|
||||||
.\" $Id: $
|
.\" $Id$
|
||||||
.\" ------------------------------------------------------------------------
|
.\" ------------------------------------------------------------------------
|
||||||
.pc
|
.TH "bdf2c" 1 "2010-24-10" "1" "bdf2c Manual"
|
||||||
.TH "bdf2c" 1 "2009-03-19" "1" "bdf2c Manual"
|
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
bdf2c \- converts bdf font files into C include files
|
bdf2c \- converts bdf font files into C include files
|
||||||
|
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B bdf2c
|
.B bdf2c
|
||||||
.I [-?|-h]
|
.BI [\-?|\-h]
|
||||||
.I [-b file]
|
.BI [\-b]
|
||||||
.I [-c]
|
.BI [\-c]
|
||||||
.I [-C file]
|
.BI [\-C \ file]
|
||||||
.I [-n name]
|
.BI [\-n \ name]
|
||||||
.I [-O]
|
.BI [\-O]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|
||||||
bdf2c creates C source and C header file from bdf font files. Which can be
|
bdf2c creates C source and C header file from bdf font files. Which can be
|
||||||
used to embed fonts into the executable.
|
used to embed fonts into the executable.
|
||||||
|
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B -?|-h
|
.B \-?|\-h
|
||||||
Show short help and exit.
|
Show short help and exit. The help is printed to stdout. A note to all
|
||||||
|
developers: please print to stdout!
|
||||||
.TP
|
.TP
|
||||||
.B -c
|
.BI \-c
|
||||||
Create C header file on stdout.
|
Create C header file on stdout.
|
||||||
.TP
|
.TP
|
||||||
.B -C file
|
.BI \-C \ file
|
||||||
Creates C header file 'file'.
|
Creates C header file 'file'.
|
||||||
.TP
|
.TP
|
||||||
.B -b file
|
.BI \-b
|
||||||
Read and convert bdf font 'file'.
|
Read and convert bdf font from stdin to stdout.
|
||||||
.TP
|
.TP
|
||||||
.B -n name
|
.BI \-n \ name
|
||||||
Name of the C font structure. 'name' should contain only valid identifier characters. f.e. font9x15b
|
Name of the C font structure. 'name' should contain only valid identifier
|
||||||
|
characters. f.e. font9x15b
|
||||||
.TP
|
.TP
|
||||||
.B -O
|
.BI \-O
|
||||||
Create outline of the font.
|
Create outline of the font.
|
||||||
|
|
||||||
.SH AUTHOR
|
.SH AUTHOR
|
||||||
Johns (2009) <johns98@gmx.net>.
|
Copyright (C) 2009, 2010 Lutz Sammer. License: AGPLv3
|
||||||
|
|
||||||
.SH COPYRIGHT
|
|
||||||
Copyright (C) 2009 Johns. License: AGPLv3
|
|
||||||
|
|
109
bdf2c.c
109
bdf2c.c
|
@ -1,7 +1,7 @@
|
||||||
///
|
///
|
||||||
/// @file bdf2c.c BDF Font to C source convertor
|
/// @file bdf2c.c @brief BDF Font to C source convertor
|
||||||
///
|
///
|
||||||
/// Copyright (c) 2009 by Johns. All Rights Reserved.
|
/// Copyright (c) 2009, 2010 by Lutz Sammer. All Rights Reserved.
|
||||||
///
|
///
|
||||||
/// Contributor(s):
|
/// Contributor(s):
|
||||||
///
|
///
|
||||||
|
@ -47,14 +47,14 @@ int Outline; ///< true generate outlined font
|
||||||
///
|
///
|
||||||
/// Create our header file.
|
/// Create our header file.
|
||||||
///
|
///
|
||||||
/// @param out File handle for output
|
/// @param out file stream for output
|
||||||
///
|
///
|
||||||
void CreateFontHeaderFile(FILE * out)
|
void CreateFontHeaderFile(FILE * out)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
fprintf(out, "// (c) 2009 Johns, License: AGPLv3\n\n");
|
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
|
"// (c) 2009, 2010 Lutz Sammer, License: AGPLv3\n\n"
|
||||||
"\t/// bitmap font structure\n" "struct bitmap_font {\n"
|
"\t/// bitmap font structure\n" "struct bitmap_font {\n"
|
||||||
"\tunsigned char Width;\t\t///< max. character width\n"
|
"\tunsigned char Width;\t\t///< max. character width\n"
|
||||||
"\tunsigned char Height;\t\t///< character height\n"
|
"\tunsigned char Height;\t\t///< character height\n"
|
||||||
|
@ -80,13 +80,13 @@ void CreateFontHeaderFile(FILE * out)
|
||||||
///
|
///
|
||||||
/// Print header for c file.
|
/// Print header for c file.
|
||||||
///
|
///
|
||||||
/// @param out File handle for output
|
/// @param out file stream for output
|
||||||
/// @param name Font variable name in C source file
|
/// @param name font variable name in C source file
|
||||||
///
|
///
|
||||||
void Header(FILE * out, const char *name)
|
void Header(FILE * out, const char *name)
|
||||||
{
|
{
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"// Created from bdf2c Version %s, (c) 2009 by Johns\n"
|
"// Created from bdf2c Version %s, (c) 2009, 2010 by Lutz Sammer\n"
|
||||||
"//\tLicense AGPLv3: GNU Affero General Public License version 3\n"
|
"//\tLicense AGPLv3: GNU Affero General Public License version 3\n"
|
||||||
"\n#include \"font.h\"\n\n", VERSION);
|
"\n#include \"font.h\"\n\n", VERSION);
|
||||||
|
|
||||||
|
@ -95,9 +95,14 @@ void Header(FILE * out, const char *name)
|
||||||
"static const unsigned char __%s_bitmap__[] = {\n", name);
|
"static const unsigned char __%s_bitmap__[] = {\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///
|
||||||
// Print width table for c file
|
/// Print width table for c file
|
||||||
//
|
///
|
||||||
|
/// @param out file stream for output
|
||||||
|
/// @param name font variable name in C source file
|
||||||
|
/// @param width_table width table read from BDF file
|
||||||
|
/// @param chars number of characters in width table
|
||||||
|
///
|
||||||
void WidthTable(FILE * out, const char *name, const unsigned *width_table,
|
void WidthTable(FILE * out, const char *name, const unsigned *width_table,
|
||||||
int chars)
|
int chars)
|
||||||
{
|
{
|
||||||
|
@ -111,9 +116,14 @@ void WidthTable(FILE * out, const char *name, const unsigned *width_table,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///
|
||||||
// Print encoding table for c file
|
/// Print encoding table for c file
|
||||||
//
|
///
|
||||||
|
/// @param out file stream for output
|
||||||
|
/// @param name font variable name in C source file
|
||||||
|
/// @param encoding_table encoding table read from BDF file
|
||||||
|
/// @param chars number of characters in encoding table
|
||||||
|
///
|
||||||
void EncodingTable(FILE * out, const char *name,
|
void EncodingTable(FILE * out, const char *name,
|
||||||
const unsigned *encoding_table, int chars)
|
const unsigned *encoding_table, int chars)
|
||||||
{
|
{
|
||||||
|
@ -127,9 +137,15 @@ void EncodingTable(FILE * out, const char *name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///
|
||||||
// Print footer for c file.
|
/// Print footer for c file.
|
||||||
//
|
///
|
||||||
|
/// @param out file stream for output
|
||||||
|
/// @param name font variable name in C source file
|
||||||
|
/// @param width character width of font
|
||||||
|
/// @param height character height of font
|
||||||
|
/// @param chars number of characters in font
|
||||||
|
///
|
||||||
void Footer(FILE * out, const char *name, int width, int height, int chars)
|
void Footer(FILE * out, const char *name, int width, int height, int chars)
|
||||||
{
|
{
|
||||||
fprintf(out, "};\n\n");
|
fprintf(out, "};\n\n");
|
||||||
|
@ -147,6 +163,11 @@ void Footer(FILE * out, const char *name, int width, int height, int chars)
|
||||||
///
|
///
|
||||||
/// Dump character.
|
/// Dump character.
|
||||||
///
|
///
|
||||||
|
/// @param out file stream for output
|
||||||
|
/// @param bitmap input bitmap
|
||||||
|
/// @param width character width
|
||||||
|
/// @param height character height
|
||||||
|
///
|
||||||
void DumpCharacter(FILE * out, unsigned char *bitmap, int width, int height)
|
void DumpCharacter(FILE * out, unsigned char *bitmap, int width, int height)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
@ -207,6 +228,10 @@ void DumpCharacter(FILE * out, unsigned char *bitmap, int width, int height)
|
||||||
///
|
///
|
||||||
/// Hex ascii to integer
|
/// Hex ascii to integer
|
||||||
///
|
///
|
||||||
|
/// @param p hex input character (0-9a-fA-F)
|
||||||
|
///
|
||||||
|
/// @returns converted integer
|
||||||
|
///
|
||||||
static inline int Hex2Int(const char *p)
|
static inline int Hex2Int(const char *p)
|
||||||
{
|
{
|
||||||
if (*p <= '9') {
|
if (*p <= '9') {
|
||||||
|
@ -221,6 +246,11 @@ static inline int Hex2Int(const char *p)
|
||||||
///
|
///
|
||||||
/// Rotate bitmap.
|
/// Rotate bitmap.
|
||||||
///
|
///
|
||||||
|
/// @param bitmap input bitmap
|
||||||
|
/// @param shift rotate counter (0-7)
|
||||||
|
/// @param width character width
|
||||||
|
/// @param height character height
|
||||||
|
///
|
||||||
void RotateBitmap(unsigned char *bitmap, int shift, int width, int height)
|
void RotateBitmap(unsigned char *bitmap, int shift, int width, int height)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
@ -244,7 +274,11 @@ void RotateBitmap(unsigned char *bitmap, int shift, int width, int height)
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Outline character.
|
/// Outline character. Create an outline font from normal fonts.
|
||||||
|
///
|
||||||
|
/// @param bitmap input bitmap
|
||||||
|
/// @param width character width
|
||||||
|
/// @param height character height
|
||||||
///
|
///
|
||||||
void OutlineCharacter(unsigned char *bitmap, int width, int height)
|
void OutlineCharacter(unsigned char *bitmap, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -288,6 +322,9 @@ void OutlineCharacter(unsigned char *bitmap, int width, int height)
|
||||||
///
|
///
|
||||||
/// Read BDF font file.
|
/// Read BDF font file.
|
||||||
///
|
///
|
||||||
|
/// @paran bdf file stream for input (bdf file)
|
||||||
|
/// @param out file stream for output (C source file)
|
||||||
|
/// @param name font variable name in C source file
|
||||||
///
|
///
|
||||||
/// @todo bbx isn't used to correct character position in bitmap
|
/// @todo bbx isn't used to correct character position in bitmap
|
||||||
///
|
///
|
||||||
|
@ -508,49 +545,55 @@ void ReadBdf(FILE * bdf, FILE * out, const char *name)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//
|
///
|
||||||
// Print version
|
/// Print version
|
||||||
//
|
///
|
||||||
void PrintVersion(void)
|
void PrintVersion(void)
|
||||||
{
|
{
|
||||||
printf("bdf2c Version %s, (c) 2009 by Johns\n"
|
printf("bdf2c Version %s, (c) 2009, 2010 by Lutz Sammer\n"
|
||||||
"\tLicense AGPLv3: GNU Affero General Public License version 3\n",
|
"\tLicense AGPLv3: GNU Affero General Public License version 3\n",
|
||||||
VERSION);
|
VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///
|
||||||
// Print usage
|
/// Print usage
|
||||||
//
|
///
|
||||||
void PrintUsage(void)
|
void PrintUsage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: bdf2c [OPTIONs]\n" "\t-b\tRead bdf file from stdin\n"
|
printf("Usage: bdf2c [OPTIONs]\n"
|
||||||
|
"\t-h or -?\tPrints this short page on stdout\n"
|
||||||
|
"\t-b\tRead bdf file from stdin, write to stdout\n"
|
||||||
"\t-c\tCreate font header on stdout\n"
|
"\t-c\tCreate font header on stdout\n"
|
||||||
"\t-C file\tCreate font header file\n"
|
"\t-C file\tCreate font header file\n"
|
||||||
"\t-n name\tName of c font variable (place it before -b)\n"
|
"\t-n name\tName of c font variable (place it before -b)\n"
|
||||||
"-t-O\tCreate outline for the font.\n");
|
"\t-O\tCreate outline for the font.\n");
|
||||||
printf("\n\tOnly idiots print usage on stderr\n");
|
printf("\n\tOnly idiots print usage on stderr\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
///
|
||||||
// Main test program for bdf2c.
|
/// Main test program for bdf2c.
|
||||||
//
|
///
|
||||||
|
///
|
||||||
|
/// @param argc number of arguments
|
||||||
|
/// @param argv arguments vector
|
||||||
|
///
|
||||||
int main(int argc, char *const argv[])
|
int main(int argc, char *const argv[])
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
name = "font";
|
name = "font"; // default variable name
|
||||||
//
|
//
|
||||||
// Parse arguments.
|
// Parse arguments.
|
||||||
//
|
//
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (getopt(argc, argv, "bcC:n:hO?-")) {
|
switch (getopt(argc, argv, "bcC:n:hO?-")) {
|
||||||
case 'b':
|
case 'b': // bdf file name
|
||||||
ReadBdf(stdin, stdout, name);
|
ReadBdf(stdin, stdout, name);
|
||||||
continue;
|
continue;
|
||||||
case 'c':
|
case 'c': // create header file
|
||||||
CreateFontHeaderFile(stdout);
|
CreateFontHeaderFile(stdout);
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C': // create header file
|
||||||
{
|
{
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
|
||||||
|
|
1630
bdf2c.doxyfile
Normal file
1630
bdf2c.doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
25
readme.txt
25
readme.txt
|
@ -1,25 +0,0 @@
|
||||||
|
|
||||||
My version of BDF fonts convertor to C includes, which can be used to
|
|
||||||
embed fonts into the executable.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
./bdf2c -c
|
|
||||||
|
|
||||||
Print #defines for font files to stdout.
|
|
||||||
|
|
||||||
./bdf2c -C font.h
|
|
||||||
|
|
||||||
Create font.h, which contains #defines for fonts.
|
|
||||||
|
|
||||||
./bdf2c -b < font.bdf > font.c
|
|
||||||
|
|
||||||
Create font.c which contains the converted bdf font.
|
|
||||||
|
|
||||||
The C file contains:
|
|
||||||
|
|
||||||
Bitmap data for the characters.
|
|
||||||
Character width table for proportional font
|
|
||||||
Character codes table for utf-8 font
|
|
||||||
|
|
||||||
TODO:
|
|
||||||
Proportional fonts (f.e. generated from ttf2bdf) aren't yet supported.
|
|
Loading…
Reference in New Issue
Block a user