Last active
June 12, 2018 18:23
-
-
Save hibariya/5b59a62d9995360ccfc4f060a13ddbcf to your computer and use it in GitHub Desktop.
Convert font (bdf) file to c file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File.write 'font.c', "const UINTN[][16] = {\n" + (Array.new(31) + File.read('u_vga16.bdf').split(/\nENCODING\s+/).tap(&:shift))[32..126].map {|char| " {\n" + char.match(/BITMAP[0-9A-F\n]+ENDCHAR/)[0].scan(/\n[0-9A-F]{2}+/).map(&:strip).map {|e| r = e.each_char.map {|a| "%04d" % Integer("0x#{a}").to_s(2) }.join; " 0b#{r}" }.join(",\n") + "\n }" }.join(",\n") + "\n};" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment