Skip to content

[Bug]: Wheel's freetype binding can conflict with system library #32208

Closed

Description

@wshanks

Bug summary

When using the matplotlib wheel from PyPI on Linux, the freetype symbols can conflict with the system freetype library. I think this might be a longstanding issue, but I can't find a previously opened issue about it and I think it only became salient when the bundled version of freetype started being updated (first in #29816).

Code for reproduction

To trigger the conflict, an older system freetype and recent version of matplotlib are needed.
One possible example of an older system is the UBI 9 container from Red Hat (registry.access.redhat.com/ubi9/ubi).
Here is a set of commands that triggers the conflict inside of that container:

dnf -y install pip freetype
python3 -m venv venv
./venv/bin/python -m pip install uv
./venv/bin/uv venv --python=3.13
./venv/bin/uv pip install matplotlib
./venv/bin/uv run python -c "import ctypes; ctypes.CDLL('/usr/lib64/libfreetype.so.6', mode=ctypes.RTLD_GLOBAL); \
import matplotlib; matplotlib.use('Agg'); import matplotlib.pyplot as p, io; \
f=p.subplots(figsize=(20,7))[0]; f.savefig(io.BytesIO(), format='png')"

Actual outcome

The end of the traceback from the example code is:

  File "/.venv/lib/python3.13/site-packages/matplotlib/backends/backend_agg.py", line 189, in _draw_text_glyphs_and_boxes
    bitmap = font._render_glyph(
        glyph_index, load_flags,
        RenderMode.NORMAL if gc.get_antialiased() else RenderMode.MONO)
RuntimeError: FT_Render_Glyph (ft2font_wrapper.cpp line 1943) failed with error 0x62: raster overflow

Expected outcome

No error from example code

Additional information

Adding import matplotlib.ft2font to the front of the Python code avoids the error because matplotlib binds to its freetype symbols instead of the system ones.

I open this issue partly just so somoene else searching for "raster overflow" or something similar gets a result explaining the problem. Perhaps it is possible to build the wheel so that matplotlib always binds to the bundled freetype symbols rather than possibly to the system versions? I don't know all the subtleties involved with binding to C library symbols so I don't suggest a solution strongly.

The ctypes.CDLL() call in the example code is a simplification of the original code that triggered this error which was using ROOT, in particular a system installation of ROOT and calling from ROOT import TCanvas (which loads the system freetype) before importing matplotlib.

Operating system

Linux (ubi 9 in the example)

Matplotlib Version

3.11.1

Matplotlib Backend

No response

Python version

3.13.15

Jupyter version

No response

Installation

uv

Activity

  1. changed the title [-][Bug]: Wheel's freetype binding can conflict system library[/-] [+][Bug]: Wheel's freetype binding can conflict with system library[/+] on Aug 13, 2026
  2. Bhoomi-jain commented on Aug 13, 2026

    @Bhoomi-jain

    Hi, I’d like to work on this issue.

    I’m currently setting up a Linux environment to reproduce the bug and better understand how Matplotlib is binding to freetype symbols in this scenario. I’ll share my findings once I’m able to consistently reproduce it and dig into the root cause.

    Please let me know if there’s any prior context or constraints I should be aware of before proceeding.

  3. added this to the v3.11.2 milestone on Aug 14, 2026
  4. QuLogic commented on Aug 20, 2026

    @QuLogic
    Member

    I've already checked that this should work using the container you mentioned, but you can try out the wheels generated by #32209.

    @Bhoomi-jain sorry, I already had the work for this done before you commented.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions