Skip to content

Fonts: search for fonts in system/user paths#2424

Open
muesli wants to merge 1 commit intoInfiniTimeOrg:mainfrom
muesli:fontpaths
Open

Fonts: search for fonts in system/user paths#2424
muesli wants to merge 1 commit intoInfiniTimeOrg:mainfrom
muesli:fontpaths

Conversation

@muesli
Copy link
Contributor

@muesli muesli commented Mar 11, 2026

Local copies of fonts will still be prioritized, but this fallback allows us to eventually remove a few TrueType fonts from the repo and rely on system packages for fonts instead.

Local copies of fonts will still be prioritized, but this fallback
allows us to eventually remove a few TrueType fonts from the repo
and rely on system packages for fonts instead.
@github-actions
Copy link

Build size and comparison to main:

Section Size Difference
text 385232B 0B
data 944B 0B
bss 22640B 0B

Run in InfiniEmu

@mark9064
Copy link
Member

I'm bit hesitant on this change. Relying on systems from providing the required fonts seems like potential for problems. What if they're not there (e.g. in minimal build environments). What if they get updated or otherwise change?

Basically I feel relying on resources outside of the repository is a unwise in terms of build stability and reproduceability

I get that it makes prototyping much more convenient, but I'm just not sure it's a worthwhile change for fonts since we almost never want to change them

@mark9064 mark9064 added enhancement Enhancement to an existing app/feature maintenance Background work and removed enhancement Enhancement to an existing app/feature labels Mar 19, 2026
@muesli
Copy link
Contributor Author

muesli commented Mar 19, 2026

I totally respect that and therefore didn't dare to propose removing the fonts from the repo just yet. I entertained the thought however, as I suspected the Docker build to be the official source of release builds, in which case the fonts could still be pinned to a specific version by the Dockerfile.

If we just keep the existing fonts in the repo this change won't affect common builds or releases.

It still has the added convenience of wider font availability during development however, which might be worth considering. It actually only exists because I was playing with various fonts while I was working on my own custom watch face and it became a bit tedious to copy fonts back and forth.

@mark9064
Copy link
Member

I think you're right about the docker, but also if someone installs the same toolchain/sdk on any linux we also support that as an "official" build configuration.

It'd be a waste not to have this as an option though. Maybe some CMake flag like -DALLOW_SYSTEM_FONTS or something? That way external fonts can't creep into the build accidentally but can be enabled for development?

for root, _, files in os.walk(font_dir):
for f in files:
if f.lower() == name.lower():
found = os.path.join(root, f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested function that you return from might be nicer than this break pattern

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be nested really actually, see what works

Also breaking out the font search to another function or method is probably a good idea structurally

import argparse
import subprocess

# Common system font locations to try when a font file is not found locally
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ideal that these files are so similar. Might not be worth refactoring though

@muesli
Copy link
Contributor Author

muesli commented Mar 19, 2026

It'd be a waste not to have this as an option though. Maybe some CMake flag like -DALLOW_SYSTEM_FONTS or something? That way external fonts can't creep into the build accidentally but can be enabled for development?

Sounds good to me, I like that. I'll update the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Background work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants