bdfcpp is a tool used to convert bdf font file to C++ code file.
Run following command to generate C++ source code.
> bdf2cpp myfont.bdf -o myfont.cpp -r myfont.hIt will generate C++ source code with random hash table, and the time complexity of the query might not be very good. If you want to generate code with better query time complexity, use the following command instead, and this may take some time to compute:
> bdf2cpp myfont.bdf --get-best-hash
Then using following command to generate the best code:
> bdf2cpp myfont.bdf -o myfont.cpp -r myfont.h -t <n> -m <n> -s <n>
Here is a minimal example showing how to use the generated C++ code.
#include <stdio.h>
#include "myfont.h"
int main() {
// Print some ASCII characters.
for(uint32_t i = '0'; i < '9'; ++i){
auto& glyph = bdf::getGlyphById(i);
bdf::printGlyph(glyph);
}
// To print non-ASCII characters, you may need a utf8 or other decoder.
return 0;
}
1, Install cmake.
2, Goto bdf2cpp source code directory.
3, Run following command:
> cmake -S . -B build
> cmake --build build
This source code is MIT license, and the code generated by it has no license(copyright belongs to the user).