Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bdf2cpp

bdfcpp is a tool used to convert bdf font file to C++ code file.

Code generation

Run following command to generate C++ source code.

> bdf2cpp myfont.bdf -o myfont.cpp -r myfont.h

It 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>

Using the generated code

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;
}

How to build this tool

1, Install cmake.
2, Goto bdf2cpp source code directory.
3, Run following command:

> cmake -S . -B build
> cmake --build build

License

This source code is MIT license, and the code generated by it has no license(copyright belongs to the user).

About

bdfcpp is a tool used to convert bdf font file to C++ code file.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages