File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
296328Working with Character Sets
297329----------------------------
298330
You can’t perform that action at this time.
0 commit comments