Skip to content

Instantly share code, notes, and snippets.

@ldd
Created February 26, 2020 01:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldd/1c6eee5a3d2849a8b62ff7789c659b52 to your computer and use it in GitHub Desktop.
Save ldd/1c6eee5a3d2849a8b62ff7789c659b52 to your computer and use it in GitHub Desktop.
Convert ttf to png

steps

  • get a valid ttf file, or assets like this one

  • get alphabet, for example:

     const s = "";
     for(let i=0; i < 76; i++1){
     if(i % 16 === 0) s += "\n";
     s += String.fromCharCode(47 + i);
     }
  • write the output to file alphabet.txt

  • convert using imagemagick

    convert -background none -fill white -font SDS_8x8.ttf -size 256x80 -pointsize 16 label:"@alphabet.txt" font.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment