Skip to content

Check font extension on both original and canonicalized paths#84

Open
wmedrano wants to merge 1 commit intoRazrFalcon:masterfrom
wmedrano:wmedrano
Open

Check font extension on both original and canonicalized paths#84
wmedrano wants to merge 1 commit intoRazrFalcon:masterfrom
wmedrano:wmedrano

Conversation

@wmedrano
Copy link

Checking both paths ensures that symlinks with font extensions are correctly identified even if their targets have non-standard names.

@wmedrano wmedrano marked this pull request as draft February 11, 2026 20:21
@wmedrano wmedrano force-pushed the wmedrano branch 5 times, most recently from 3d08173 to b630380 Compare February 11, 2026 23:12
@RazrFalcon
Copy link
Owner

Hello. Can you prove an example of what exactly this change does/fixes?

Also, this project is currently has no maintainers, so no releases are planned.

@wmedrano
Copy link
Author

Issue

I ran into this when trying to upgrade some uses of resvg within my company. In some test setups, the system uses uuid-like file names and constructs the environment from symlinks.

Reproduction

61921a4

  • print_fonts is a simple wrapper that prints the fonts from a directory
  • 0c4c8f45-69ce-44f5-b509-6e7831f1d479 is a font file at a root directory
  • repro_symlink_bug/myfont.ttf is a symlink to the bug
  • This allows myfont.ttf to be detected when runningprint_fonts repro_symlink_bug
wmedrano@wmedrano:~/src/fontdb$ jj edit x
Working copy  (@) now at: xsytrzqk 8831faf2 Recreate symlink issue
Parent commit (@-)      : nvvorpzu 62cfd966 master | Version bump.
Added 0 files, modified 1 files, removed 0 files
wmedrano@wmedrano:~/src/fontdb$ cargo build --examples && target/debug/examples/print_fonts repro_symlink_bug/
   Compiling fontdb v0.23.0 (/usr/local/google/home/wmedrano/src/fontdb)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s
Loaded 0 font faces in 0ms.
wmedrano@wmedrano:~/src/fontdb$ jj edit y
Working copy  (@) now at: yxpvzsym 61921a41 wmedrano2 | Recreate symlink issue
Parent commit (@-)      : qonuyplv b6303809 wmedrano | Check font extension on both original and canonicalized paths
Added 0 files, modified 1 files, removed 0 files
wmedrano@wmedrano:~/src/fontdb$ cargo build --examples && target/debug/examples/print_fonts repro_symlink_bug/
   Compiling fontdb v0.23.0 (/usr/local/google/home/wmedrano/src/fontdb)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.32s
Loaded 1 font faces in 0ms.
Family: Noto Color Emoji, Style: Normal, Weight: Weight(400), Stretch: Normal, Path: /usr/local/google/home/wmedrano/src/fontdb/0c4c8f45-69ce-44f5-b509-6e7831f1d479
wmedrano@wmedrano:~/src/fontdb$

No releases

Ack, I can do some manual stuff for my usage of this package.

@RazrFalcon
Copy link
Owner

So the issue is that we always check the file extension?
The fix seems to be overly complicated. Can't we resolve the symlink first and then check for the file extension?

Also, I guess checking the file's magic would be a more correct approach, but I'm not sure how much it would affect performance.

Checking both paths ensures that symlinks with font extensions are
correctly identified even if their targets have non-standard names.
@wmedrano
Copy link
Author

wmedrano commented Feb 13, 2026

Oh, yeah, that's simpler and still fixes my issue. Done.

Reading the magic bytes seems like it could be bad for performance on systems with slow IO.

@wmedrano wmedrano marked this pull request as ready for review February 13, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants