Skip to content

njmh/bdfparser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BDF Parser

MIT License

BDF (Glyph Bitmap Distribution Format) Bitmap Font File Parser (Python).

Usage

BdfParserObject = BdfParser(<FONT_FILE_PATH>)
BdfParserObject.{getCharBmpByUnicode|getCharHexByUnicode|getCharHexByUnicode|getGlyphInfo}(<UNICODE_DECIMAL>)

Example

(see also example.py)

Import library and instantiation:

import bdfparser as bp
bpo = bp.BdfParser('example_fonts/bdf/SimSun-14.bdf')

Get binary representation string of bitmap of the character "的":

bpo.getCharBmpByUnicode(30340)

Get hex representation string of bitmap of the character "的":

bpo.getCharHexByUnicode(30340)

Get hex representation string in bytes of bitmap of the character "的":

bpo.getCharHexByUnicode(30340).hex()

Get glyph information:

bpo.getGlyphInfo(30340)

The above script returns:

{'dwx0': 14, 'bbW': 12, 'bbH': 14, 'bbXOff': 1, 'bbYOff': -2, 'bitmap': '2100\n2100\n41F0\nFA10\n8C10\n8810\n8910\nF890\n8890\n8810\n8810\n8810\nF810\n8860', 'outputW': 14, 'outputH': 15, 'shadowedOutputW': 15, 'shadowedOutputH': 16, 'glowedOutputW': 16, 'glowedOutputH': 17}

Get binary representation of bitmap of the character " ̄"

bpo.getCharBmpByUnicode(65507)

Get binary representation of bitmap of the character "©" -- "©" does not exist in some font, and does not exist in GBK, therefore it throws an error:

bpo.getCharBmpByUnicode(169)

Get the declared font name:

bpo.getFontName()

Other tools

Projects that use this library

FNT Generator: Might and Magic 6 7 8 and Heroes 3 font File Generator in Python. Another project of mine

License

  • Python code is written by me (Tom CHEN) and is released under the MIT License.
  • otf2bdf: see its page.
  • Example .bdf fonts:

About

BDF (Glyph Bitmap Distribution Format) Bitmap Font File Parser 🔤🔣

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%