Utensil's Zettelkasten-style forest of evergreen notes on math and tech. utensil.tngl.sh/forest/
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(dvisvgm): iter 74 — refactor FontManager fix to capture resolved path inside the lambda

iter 73's fix (re-call lookup with *it) didn't actually fix the
'can't read font file otf' error — patch applied at source level
(verified) but the deployed binary still hits the bug. Likely a
subtle side-effect issue: _pathbuf is a static class member, so
re-calling lookup may interact with intermediate calls in unexpected
ways. Refactor: capture the path inside the find_if lambda via a
reference variable, so the path returned is exactly the one that
caused the lambda to return true.

[AGENT: kael]

+14 -4
+14 -4
nix-patches/dvisvgm-fontengine-substr-fix.patch
··· 5 5 fontFormats[] array of extension *strings*; dereferencing `*it` 6 6 returns the literal "otf"/"ttf", not the resolved font path. The 7 7 NativeFontImpl is then constructed with path="otf" (or "ttf"). 8 - Re-call FileFinder::lookup with the same args to get the real path. 8 + Refactor: capture the lookup result inside the lambda via a 9 + captured-by-reference local so the loop carries the real path. 9 10 10 11 (2) src/FontEngine.cpp:93 — setFont's sys:// gate is `||` where it 11 12 should be `&&`. Any fname with size <= 6 enters the branch and ··· 21 22 22 23 --- a/src/FontManager.cpp 23 24 +++ b/src/FontManager.cpp 24 - @@ -310,7 +310,7 @@ 25 + @@ -307,11 +307,15 @@ 26 + } 27 + else { 28 + if (!FileSystem::exists(path)) { 29 + + // iter74_FontManager_PatchedV2_marker — capture the resolved 30 + + // path inside the lambda; the upstream `*it` returns the 31 + + // fontFormats[] extension literal, not the lookup result. 32 + const char *fontFormats[] = {nullptr, "otf", "ttf"}; 33 + + const char *resolved = nullptr; 25 34 auto it = algo::find_if(fontFormats, [&](const char *format) { 26 - return FileFinder::instance().lookup(filename, format, false) != nullptr; 35 + - return FileFinder::instance().lookup(filename, format, false) != nullptr; 36 + + return (resolved = FileFinder::instance().lookup(filename, format, false)) != nullptr; 27 37 }); 28 38 - path = it != end(fontFormats) ? *it : nullptr; 29 - + path = it != end(fontFormats) ? FileFinder::instance().lookup(filename, *it, false) : nullptr; 39 + + path = it != end(fontFormats) ? resolved : nullptr; 30 40 } 31 41 if (path) { 32 42 newfont.reset(new NativeFontImpl(path, fontIndex, ptsize, style, color));