Documentation and release cleanups.

This commit is contained in:
Johns 2010-09-24 16:55:01 +02:00
parent df59514df6
commit 3214f24205
10 changed files with 1808 additions and 94 deletions

3
.gitattributes vendored
View File

@ -1,3 +1,4 @@
# gitattributes(5) file
*.[ch] ident
*.[ch1] ident
Makefile ident
README.txt ident

1
.gitignore vendored
View File

@ -7,4 +7,5 @@
bdf2c
font.h
html
chaos

4
Changelog.txt Normal file
View File

@ -0,0 +1,4 @@
User johns
Date Fri Sep 24 15:55:08 CEST 2010
Initial official release.

View File

@ -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):
#
@ -26,26 +26,44 @@ LDFLAGS =
OBJS = bdf2c.o
HDRS =
MISC = font.h Makefile agpl-3.0.txt readme.txt
FILES = Makefile AGPL-3.0.txt README.txt Changlog.txt
all: bdf2c
$(OBJS): $(HDRS)
$(OBJS): $(HDRS) Makefile
utv: $(OBJS)
bdf2c: $(OBJS)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^ $(LIBS)
clean:
-rm *.o *~
#----------------------------------------------------------------------------
# Developer tools
doc: $(SRCS) $(HDRS) bdf2c.doxyfile
(cat bdf2c.doxyfile; \
echo 'PROJECT_NUMBER=${VERSION} $(if $(GIT_REV), (GIT-$(GIT_REV)))') \
| doxygen -
indent:
for i in $(OBJS:.o=.c) $(HDRS); do \
indent $$i; unexpand -a $$i > $$i.up; mv $$i.up $$i; \
done
commit:
git commit $(OBJS:.o=.c) $(HDRS) $(MISC)
clean:
-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
View 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
View File

@ -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):
.\"
@ -17,51 +17,48 @@
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU Affero General Public License for more details.
.\"
.\" $Id: $
.\" $Id$
.\" ------------------------------------------------------------------------
.pc
.TH "bdf2c" 1 "2009-03-19" "1" "bdf2c Manual"
.TH "bdf2c" 1 "2010-24-10" "1" "bdf2c Manual"
.SH NAME
bdf2c \- converts bdf font files into C include files
.SH SYNOPSIS
.B bdf2c
.I [-?|-h]
.I [-b file]
.I [-c]
.I [-C file]
.I [-n name]
.I [-O]
.BI [\-?|\-h]
.BI [\-b]
.BI [\-c]
.BI [\-C \ file]
.BI [\-n \ name]
.BI [\-O]
.SH DESCRIPTION
bdf2c creates C source and C header file from bdf font files. Which can be
used to embed fonts into the executable.
.SH OPTIONS
.TP
.B -?|-h
Show short help and exit.
.B \-?|\-h
Show short help and exit. The help is printed to stdout. A note to all
developers: please print to stdout!
.TP
.B -c
.BI \-c
Create C header file on stdout.
.TP
.B -C file
.BI \-C \ file
Creates C header file 'file'.
.TP
.B -b file
Read and convert bdf font 'file'.
.BI \-b
Read and convert bdf font from stdin to stdout.
.TP
.B -n name
Name of the C font structure. 'name' should contain only valid identifier characters. f.e. font9x15b
.BI \-n \ name
Name of the C font structure. 'name' should contain only valid identifier
characters. f.e. font9x15b
.TP
.B -O
.BI \-O
Create outline of the font.
.SH AUTHOR
Johns (2009) <johns98@gmx.net>.
.SH COPYRIGHT
Copyright (C) 2009 Johns. License: AGPLv3
Copyright (C) 2009, 2010 Lutz Sammer. License: AGPLv3

109
bdf2c.c
View File

@ -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):
///
@ -47,14 +47,14 @@ int Outline; ///< true generate outlined font
///
/// Create our header file.
///
/// @param out File handle for output
/// @param out file stream for output
///
void CreateFontHeaderFile(FILE * out)
{
register int i;
fprintf(out, "// (c) 2009 Johns, License: AGPLv3\n\n");
fprintf(out,
"// (c) 2009, 2010 Lutz Sammer, License: AGPLv3\n\n"
"\t/// bitmap font structure\n" "struct bitmap_font {\n"
"\tunsigned char Width;\t\t///< max. character width\n"
"\tunsigned char Height;\t\t///< character height\n"
@ -80,13 +80,13 @@ void CreateFontHeaderFile(FILE * out)
///
/// Print header for c file.
///
/// @param out File handle for output
/// @param name Font variable name in C source file
/// @param out file stream for output
/// @param name font variable name in C source file
///
void Header(FILE * out, const char *name)
{
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"
"\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);
}
//
// 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,
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,
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)
{
fprintf(out, "};\n\n");
@ -147,6 +163,11 @@ void Footer(FILE * out, const char *name, int width, int height, int chars)
///
/// 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)
{
int x;
@ -207,6 +228,10 @@ void DumpCharacter(FILE * out, unsigned char *bitmap, int width, int height)
///
/// Hex ascii to integer
///
/// @param p hex input character (0-9a-fA-F)
///
/// @returns converted integer
///
static inline int Hex2Int(const char *p)
{
if (*p <= '9') {
@ -221,6 +246,11 @@ static inline int Hex2Int(const char *p)
///
/// 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)
{
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)
{
@ -288,6 +322,9 @@ void OutlineCharacter(unsigned char *bitmap, int width, int height)
///
/// 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
///
@ -508,49 +545,55 @@ void ReadBdf(FILE * bdf, FILE * out, const char *name)
//////////////////////////////////////////////////////////////////////////////
//
// Print version
//
///
/// Print version
///
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",
VERSION);
}
//
// Print usage
//
///
/// Print usage
///
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 file\tCreate font header file\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");
}
//
// 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[])
{
const char *name;
name = "font";
name = "font"; // default variable name
//
// Parse arguments.
//
for (;;) {
switch (getopt(argc, argv, "bcC:n:hO?-")) {
case 'b':
case 'b': // bdf file name
ReadBdf(stdin, stdout, name);
continue;
case 'c':
case 'c': // create header file
CreateFontHeaderFile(stdout);
break;
case 'C':
case 'C': // create header file
{
FILE *out;

1630
bdf2c.doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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.