CFFI binding for fontconfig
This package try to be a complete python binding for fontconfig.
This package contains two modules: the low level _fontconfig, that matches the C APIs, and fc, that is an higher abstraction over it.
The C API:
int FcGetVersion(void);
in _fontconfig:
_fontconfig.FcGetVersion()
in fc:
fc.get_version()
Installation
This package requires the enum34 package. Install it via pypi:
$ pip install enum34
or use your distribution’s package:
$ apt-get install python-enum34
To compile the _fontconfig extension, the following C headers are required:
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>
#include <ft2build.h>
#include FT_FREETYPE_H // usually <freetype/freetype.h>
and the package cffi. In Debian the following packages are enough:
$ apt-get install python-cffi libfontconfig1-dev libfreetype6-dev
Finally, to install the package itself:
$ pip install fontconfig
_fontconfig module
The module _fontconfig exports few simbols to test the capabilities of the underlying library. These are:
PYFC_HAS_DirCacheRescan
PYFC_HAS_FcRange
Usage:
>>> import _fontconfig
>>> print _fontconfig.lib.FcGetVersion()
21100
>>> _fontconfig.lib.FcInit() # init the library
1
>>> config = _fontconfig.lib.FcConfigGetCurrent()
>>> sl = _fontconfig.lib.FcConfigGetConfigDirs(config)
>>> while True:
... s = _fontconfig.lib.FcStrListNext(sl)
... if not s:
... break
... print _fontconfig.ffi.string(s) # doctest: +ELLIPSIS
...
/usr/share/fonts
/usr/X11R6/lib/X11/fonts
/usr/local/share/fonts
...
>>> _fontconfig.lib.FcStrListDone(sl)
fc module
The fc module would be an higher abstraction moudule but it is still uncomplete.
Usage:
The same snippet as above:
>>> import fc
>>> fc.get_version() # fontconfig's version
(2, 11, 0)
>>> fc.init()
>>> config = fc.FcConfig.get_current()
>>> config.get_config_dirs() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
['/usr/share/fonts', '/usr/X11R6/lib/X11/fonts',
'/usr/local/share/fonts', ...]
Few more examples:
>>> fc.__version__ # python library's version
'0.1'
>>> pattern = config.get_fonts(fc.SetName.system)[0]
>>> pattern.name_unparse() # doctest: +ELLIPSIS
'21 Kilobyte Salute:...'
>>> config.get_font_dirs() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
['/usr/share/fonts', '/usr/X11R6/lib/X11/fonts',
'/usr/local/share/fonts', ...]
>>> pat = fc.FcPattern.name_parse("dejavu serif")
>>> for font in config.font_list(pat, [fc.PropertyName.file]):
... print(font.name_unparse()) # doctest: +ELLIPSIS
...
:file=/usr/share/fonts/truetype/dejavu/DejaVuSerif-BoldItalic.ttf
:file=/usr/share/fonts/truetype/dejavu/DejaVuSerifCondensed.ttf
...
Metadata
Release files for fontconfig 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fontconfig-0.1.zip | 122.0 kB | Without provenance | Details for fontconfig-0.1.zip |
Release files / fontconfig-0.1.zip
| Download URL | fontconfig-0.1.zip |
|---|---|
| Size | 122.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35bebcee549445497f3f5b21893f4901739a56ac4209df33c9e1df450efcce98
|
|
BLAKE2b-256 checksum How to use checksums |
d1010a1ce055ab89acd13050fe9b0833be3ce8a0a07ec5450ddf1d1812016a3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for fontconfig 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.