Weblate Fonts Collection
Weblate Fonts Collection is a Python package bundling a subset of fonts, including Source Code Pro, Source Sans 3, and Kurinto. It is primarily developed for Weblate's internal needs, specifically for rendering checks within the localization system. It is not intended as a general-purpose font bundle, and the package explicitly states that compatibility between releases is not guaranteed as Weblate itself pins exact versions of this library. The current version is 2026.1, requiring Python >=3.11.
Common errors
-
Font change does not update rendered image in the MaxSizeCheck
cause Weblate caches rendered output for performance. The cache key often only considers text and flag changes, not changes to the underlying font files or font group definitions directly.fixMake a minor edit to the problematic translation string or its associated flags (e.g., `font-size`) to force a cache invalidation and re-rendering of the preview. -
Rendered font size is bigger than it should be
cause This often occurs because a different font is being used for rendering than expected, or there's a mismatch in font group names or `font-family` flags. Slight variations in font metrics can also cause this.fixDouble-check the exact font group name configured in Weblate and ensure it precisely matches the `font-family` flag used (e.g., `font-family:segoeui` vs. `font-family:segoe ui`). Verify the correct font `.ttf` or `.otf` file is uploaded and active for the specified family and language. Also ensure system-level font rendering dependencies (Pango/Cairo) are correctly installed and configured.
Warnings
- breaking Compatibility between releases is not guaranteed. The package is developed for Weblate's internal needs, and Weblate itself pins exact versions. Relying on specific font versions or internal file paths for external projects may lead to unexpected breakages on upgrade.
- gotcha This package is explicitly not intended to be a general-purpose font bundle. Its scope is limited to Weblate's specific requirements, meaning it may not contain a comprehensive set of fonts or weights, and its internal structure might change without broader consideration.
- gotcha When using fonts for rendering checks within Weblate, changes to fonts or font groups might not immediately reflect in the rendered images due to aggressive caching.
Install
-
pip install weblate-fonts
Quickstart
import importlib.resources
import os
# The weblate-fonts package primarily provides font files as assets.
# This example shows how to locate the path to one of the bundled fonts.
# Assuming 'Source Code Pro Regular' is located under 'weblate_fonts.sourcecodepro'
try:
# Using importlib.resources.files for Python 3.9+
font_resource_path = importlib.resources.files('weblate_fonts.sourcecodepro')
source_code_pro_ttf = font_resource_path / 'SourceCodePro-Regular.ttf'
print(f"Attempting to locate: {source_code_pro_ttf}")
if os.path.exists(source_code_pro_ttf):
print(f"Found Source Code Pro Regular font at: {source_code_pro_ttf}")
# In a real application, you would pass this path to a font rendering library
# For example, to a library like Pillow, or for use within Weblate's Pango/Cairo backend.
else:
print(f"Error: Font file not found at {source_code_pro_ttf}. Check package integrity.")
except ModuleNotFoundError:
print("Error: 'weblate_fonts' package not found. Ensure it is installed.")
except Exception as e:
print(f"An unexpected error occurred: {e}")