Summary
Text widgets currently expose only four "styles" — regular, bold, italic, narrow — which map to the four bundled Carlito faces in labelle. There's no way to pick an actual font family. We'd like to let users choose real fonts.
Motivation / bug that surfaced this
While reviewing the style options we noticed the "Narrow" option is mislabeled — in labelle's font_config.py the narrow style is wired to Carlito-BoldItalic.ttf:
_DEFAULT_STYLES_TO_FONT_PATH = {
"regular": ".../Carlito-Regular.ttf",
"bold": ".../Carlito-Bold.ttf",
"italic": ".../Carlito-Italic.ttf",
"narrow": ".../Carlito-BoldItalic.ttf", # <-- not narrow at all
}
Carlito ships only those four faces (no condensed/narrow variant), so "Narrow" renders bold-italic. Quick mitigation in labelle-web: relabel the dropdown option to "Bold Italic" (keep value="narrow", which is the key labelle expects). The real fix — actual font choice — is this feature.
What labelle already gives us
labelle.lib.font_config.get_font_path() accepts either:
font= — a font name (resolved from get_available_fonts() = bundled Carlito + matplotlib.findSystemFonts()) or a path to a .ttf, or
style= — one of the four named styles above.
So the print engine already supports arbitrary fonts; labelle-web simply doesn't surface it.
Proposed work
Backend (server/)
Frontend (client/)
Constraints to decide up front
- font OR style, not both:
get_font_path can't express "Arial + bold" — bold/italic only work if that face is its own file. Combining a chosen family with bold/italic would need an upstream labelle change or per-face selection.
- Fonts in the container: the Docker image ships almost no system fonts, so on the Pi
findSystemFonts() will return little. To be genuinely useful this likely needs bundling more fonts and/or a .ttf upload flow (mirroring the existing image-upload path).
Related
- Upstream naming: the
narrow style name is a labelle-library misnomer — worth a separate upstream note to labelle-org/labelle.
Summary
Text widgets currently expose only four "styles" —
regular,bold,italic,narrow— which map to the four bundled Carlito faces in labelle. There's no way to pick an actual font family. We'd like to let users choose real fonts.Motivation / bug that surfaced this
While reviewing the style options we noticed the "Narrow" option is mislabeled — in labelle's
font_config.pythenarrowstyle is wired toCarlito-BoldItalic.ttf:Carlito ships only those four faces (no condensed/narrow variant), so "Narrow" renders bold-italic. Quick mitigation in labelle-web: relabel the dropdown option to "Bold Italic" (keep
value="narrow", which is the key labelle expects). The real fix — actual font choice — is this feature.What labelle already gives us
labelle.lib.font_config.get_font_path()accepts either:font=— a font name (resolved fromget_available_fonts()= bundled Carlito +matplotlib.findSystemFonts()) or a path to a.ttf, orstyle=— one of the four named styles above.So the print engine already supports arbitrary fonts; labelle-web simply doesn't surface it.
Proposed work
Backend (
server/)GET /api/fontswrappingget_available_fonts()(return display names / stems).label_builder.py, when a widget has a font name/path, callget_font_path(font=...)instead ofget_font_path(style=...). Define precedence (explicit font overrides style).Frontend (
client/)fontName?: stringtoTextWidgetintypes/label.ts.TextWidgetEditor.tsxpopulated from/api/fonts..jsonround-trip.Constraints to decide up front
get_font_pathcan't express "Arial + bold" — bold/italic only work if that face is its own file. Combining a chosen family with bold/italic would need an upstream labelle change or per-face selection.findSystemFonts()will return little. To be genuinely useful this likely needs bundling more fonts and/or a.ttfupload flow (mirroring the existing image-upload path).Related
narrowstyle name is a labelle-library misnomer — worth a separate upstream note to labelle-org/labelle.