-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
graphviz v12.1.0 breaks theme's custom graphviz ext #383
Comments
@jbms Was this helpful? Can I provide more details about something (env or FS)? |
I think the issue may be that the newer graphviz Windows build compiles in support for LibGD (which is good) and Fontconfig for LibGD, but then no default configuration file for fontconfig can be found which makes it fail. I think fontconfig is not actually used by LibGD when we specify a path to a TTF file but graphviz still attempts to initialize it which fails. I am trying to see if specifying a minimal fontconfig config fixes the problem. |
Actually I think the issue is that graphviz checks if the font path contains a forward slash to determine if it is a path to a font file. On Windows that fails because the paths we supply use backslashes. I haven't checked yet but normalizing to forward slashes in the font path may fix it and a fontconfig config may not even be required. |
yep. posix path seperators fixed it: diff --git a/sphinx_immaterial/graphviz.py b/sphinx_immaterial/graphviz.py
index 895a0f9c..0d7d96b6 100644
--- a/sphinx_immaterial/graphviz.py
+++ b/sphinx_immaterial/graphviz.py
@@ -244,7 +244,7 @@ def render_dot_html(
if ttf_font_paths and font is not None:
try:
# can only support the chosen font if cache exists and a Google font is used
- ttf_font = ttf_font_paths[(font, "400")]
+ ttf_font = ttf_font_paths[(font, "400")].replace("\\", "/")
except KeyError as exc:
# weight `400` might not exist for the specified font
all_font_keys = [i for i in ttf_font_paths.keys() if i[0] == font]
@@ -253,7 +253,7 @@ def render_dot_html(
f"Font file for {font} could not be found in cache"
) from exc
# just use first weight for the specified font
- ttf_font = ttf_font_paths[all_font_keys[0]]
+ ttf_font = ttf_font_paths[all_font_keys[0]].replace("\\", "/")
code = _replace_resolved_xrefs(node, code)
and additionally using the patch in #390. |
The Ci is failing due to an error that I can reproduce on Windows using graphviz v12.1.0:
Apparently the graphviz build for windows changed/updated the dependencies. The
graphviz_ignore_incorrect_font_metrics
flag is no longer relevant with graphviz v12.1.0. Commenting it out in our conf.py file yielded no warning about not finding LibGD support. I was able to confirm this by inspectingthe config file shipped with graphviz v12.1.0
Although, I think the default fonts.conf file that it is looking for is intentionally excluded from the release assets.
I don't have a proposal yet, but I'm opening this to track it. I think we can generate a conf file for the theme's font being used, but that doesn't compensate for when a system font is used instead of a google font.
The text was updated successfully, but these errors were encountered: