Python bindings for Fontconfig library
- Fontconfig Required
- Cython (if you want to regenerate C source)
Python 2.7.2
(32-bit, 64-bit)Python 3.2.2
(32-bit, 64-bit)Python 3.3.2
(64-bit)
From PyPI:
>>> pip install Python-fontconfig
or
>>> easy_install Python-fontconfig
From GitHub:
>>> git clone git://github.com/Vayn/python-fontconfig.git
>>> cd python-fontconfig/
>>> python setup.py install
>>> python setup.py build_ext -i
>>> cd test/ >>> python test.py
>>> import fontconfig
>>> fonts = fontconfig.query(family='ubuntu', lang='en')
>>> fonts ['/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-L.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-LI.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf', '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf']
>>> font = fontconfig.FcFont(fonts[0])
>>> font <FcFont: Ubuntu>
>>> font. font.bestname font.capability font.fullname font.slant font.count_chars font.get_languages font.spacing font.decorative font.has_char font.style font.family font.index font.weight font.file font.outline font.width font.fontformat font.print_pattern font.foundry font.scalable
>>> font.family {'en': 'Ubuntu'}
>>> font.bestname {'en': 'Ubuntu'}
>>> font.foundry 'unknown'
>>> font.fontformat 'TrueType'
>>> font.has_char('A') True
>>> font.file '/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf'
>>> fontconfig.fromName('Ubuntu') <FcFont: Ubuntu>
>>> font = fontconfig.FcFont(font.file)
>>> font.family {'en': 'Ubuntu'}
This program is released under GPLv3
license, see LICENSE
for more detail.