-
Notifications
You must be signed in to change notification settings - Fork 22
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
Poor on-screen font antialiasing/smoothing in mplcairo #55
Comments
Unfortunately I cannot reproduce the issue. What is the value of diff --git i/ext/_util.cpp w/ext/_util.cpp
index 55ed9d2..57da84d 100644
--- i/ext/_util.cpp
+++ w/ext/_util.cpp
@@ -856,6 +856,7 @@ void adjust_font_options(cairo_t* cr)
// The hint style is not set here: it is passed directly as load_flags to
// cairo_ft_font_face_create_for_ft_face.
cairo_set_font_options(cr, options);
+ py::print(cairo_font_options_get_antialias(options));
cairo_font_options_destroy(options);
}
Also, can you try with cairo 1.18? |
from matplotlib import pyplot as plt
plt.rcParams['text.antialiased']
True I would be happy to apply the patch you mentioned, but could you tell me how? Due to this issue, I can't install from a source tarball. Instead, I do
So where/how do I apply that patch? OK, I will try updating |
To test the patch: Clone the repository, apply the patch, then Also, perhaps try the module://mplcairo.qt or module://mplcairo.tk backends? (I think you're on the mplcairo.macosx backend right now; perhaps there are some issues with HiDPI.) |
Do you have anything special in your matplotlibrc? Does the issue remain if you remove all its contents except for the backend setting, or if you call matplotlib.rcdefaults() first? |
Do you also have the problem with mathtext? ( |
Hmm, that is interesting. What happens if you try to force loading raqm with |
OK, this is interesting and slightly puzzling. I have $ ls -l /Users/sbasu1/packages/macports/lib/libraqm.dylib
lrwxr-xr-x 1 sbasu1 staff 15 2024 Jan 04 01:32:15 /Users/sbasu1/packages/macports/lib/libraqm.dylib -> libraqm.0.dylib and that path is both in $ env | grep LD_
LD_LIBRARY_PATH=/Users/sbasu1/packages/lib:/Users/sbasu1/packages/macports/lib:
LD_RUN_PATH=/Users/sbasu1/packages/lib:/Users/sbasu1/packages/macports/lib: Yet, when I try to force load as follows, In [1]: import mplcairo
In [2]: mplcairo.set_options(raqm=True)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[2], line 1
----> 1 mplcairo.set_options(raqm=True)
OSError: dlopen(libraqm.dylib, 0x0001): tried: '/opt/intel/compilers_and_libraries_2019.5.281/mac/compiler/lib/libraqm.dylib' (no such file), '/opt/intel/compilers_and_libraries_2019.5.281/mac/compiler/lib/intel64/libraqm.dylib' (no such file), '/opt/intel/compilers_and_libraries_2019.5.281/mac/tbb/lib/libraqm.dylib' (no such file), '/opt/intel/compilers_and_libraries_2019.5.281/mac/compiler/lib/libraqm.dylib' (no such file), '/opt/intel/compilers_and_libraries_2019.5.281/mac/mkl/lib/libraqm.dylib' (no such file), 'libraqm.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibraqm.dylib' (no such file), '/usr/lib/libraqm.dylib' (no such file, not in dyld cache), 'libraqm.dylib' (no such file), '/usr/local/lib/libraqm.dylib' (no such file), '/usr/lib/libraqm.dylib' (no such file, not in dyld cache) It's not even looking in |
So, I hardcoded the path to In [1]: import mplcairo
In [2]: mplcairo.get_versions()
Out[2]:
{'python': '3.11.7 (main, Jan 3 2024, 08:15:29) [Clang 15.0.0 (clang-1500.1.0.2.5)]',
'mplcairo': '0.5.post32+ge771c74',
'matplotlib': '3.8.2',
'cairo': '1.17.6 @ /Users/sbasu1/packages/macports/lib/libcairo.2.dylib',
'freetype': '2.13.2 @ /Users/sbasu1/packages/macports/lib/libfreetype.6.dylib',
'pybind11': '2.11.1',
'raqm': '0.10.1 @ /Users/sbasu1/packages/macports/lib/libraqm.0.dylib',
'harfbuzz': '8.3.0 @ /Users/sbasu1/packages/macports/lib/libharfbuzz.0.dylib'} |
Thanks for trying. Not any bright idea right now... |
My silly guess is that
... I think there's something in fontconfig that might turn off embeddedbitmaps -- if it works, my hunch would be in the right direction. |
Thanks for the suggestion. Do you know how to test the hypothesis? |
Having a bit of an issue reproducing on my end (but don't worry, anntzer also failed to repro). Probably something to do with how homebrew cairo and the whole stack below is configured differently compared to macports. You should be able to (hopefully) turn off those bitmaps with a new file. Write the following into a new file called <?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
<match target="font">
<edit name="embeddedbitmap" mode="assign">
<bool>false</bool>
</edit>
</match>
</fontconfig> |
@Artoria2e5 I tried your |
I'm trying to switch to using the
mplcairo
backend because it does certain things better than theMacOSX
backend, especially when colormaps have transparency. However, I've noticed that the font smoothing, at least for plots displayed on the screen, is noticeably poorer. The code below offers a MWE:With the
mplcairo
backend, the tick labels look jagged and not smooth, as below.Whereas with the
MacOSX
backend gives me noticeably smoother fonts.Everything is identical for the production of the two figures except the backend, which I switch in
.matplotlibrc
. Am I missing something? Is there a way to getmplcairo
to render fonts with proper smoothing?The text was updated successfully, but these errors were encountered: