Skip to content

Commit b66e358

Browse files
authored
Merge pull request #60 from CyberAgent/docs/configuring-fontconfig
docs: add section on configuring fontconfig search paths
2 parents 70645ce + 98c8bf9 commit b66e358

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

docs/source/advanced_topics.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,38 @@ Access fontconfig configuration directories and files::
293293
print(f"System fonts: {len(system_fonts)}")
294294
print(f"Application fonts: {len(app_fonts)}")
295295

296+
Configuring fontconfig
297+
----------------------
298+
299+
If fontconfig does not return a font you expect, it may not be in any of the
300+
configured font search paths. fontconfig is configured via XML files, typically
301+
located in:
302+
303+
- ``~/.config/fontconfig/fonts.conf`` (user-level, Linux/macOS)
304+
- ``/etc/fonts/local.conf`` or ``/etc/fonts/conf.d/`` (system-level)
305+
306+
To add a custom font directory, create or edit ``~/.config/fontconfig/fonts.conf``::
307+
308+
<?xml version="1.0"?>
309+
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
310+
<fontconfig>
311+
<dir>/path/to/your/fonts</dir>
312+
</fontconfig>
313+
314+
After editing the configuration, rebuild the font cache::
315+
316+
fc-cache -f
317+
318+
You can verify the new directory is scanned by checking ``get_font_dirs()``::
319+
320+
import fontconfig
321+
config = fontconfig.Config.get_current()
322+
print(config.get_font_dirs())
323+
324+
For the full reference on fontconfig configuration — including aliases, rules,
325+
substitutions, and per-application settings — see the
326+
`fontconfig user documentation <https://www.freedesktop.org/software/fontconfig/fontconfig-user.html>`_.
327+
296328
Working with Character Sets
297329
----------------------------
298330

0 commit comments

Comments
 (0)