Skip to content

Make PyFT2Font a subclass of FT2Font #30324

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

Open
wants to merge 2 commits into
base: text-overhaul
Choose a base branch
from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jul 17, 2025

PR summary

This avoids a level of indirection, and also means that a FT2Font is a PyFT2Font (since there are no other subclasses), which helps with some future work. The only downside is that the constructor/destructor order is fixed and slightly different, so we need to split the open/close stages for the FT_Face and explicitly call them in PyFT2Font.

There are currently still two copies of the fallback list, one on each level. The one on FT2Font is what's actually used, but the one on PyFT2Font is the actual owner (because pybind11 owns the objects, so we need a Python object to own them). I think it may be possible to drop that extra copy by switching to std::shared_ptr, but that will likely require the smart holders that are new in pybind11 v3, and I haven't fully tested that out yet.

This PR is based on/waiting for #30322.

PR checklist

@QuLogic
Copy link
Member Author

QuLogic commented Jul 18, 2025

The goal here is to avoid having to this whole set_parent thing: https://github.com/matplotlib/matplotlib/pull/30000/files#diff-c8ef50e596f5bb461a98e5c60d0061276d773c260b206290ee71c63817242c08R174-R183 for which we have to map FT_Face -> FT2Font -> PyFT2Font but with this PR, the latter two are the same.

@QuLogic QuLogic force-pushed the ft2font-subcless branch from b3d0b19 to d725cf9 Compare July 24, 2025 19:05
@github-actions github-actions bot removed topic: rcparams Documentation: user guide files in galleries/users_explain or doc/users labels Jul 24, 2025
@QuLogic QuLogic marked this pull request as ready for review July 24, 2025 19:06
@QuLogic QuLogic moved this from Waiting for other PR to Ready for Review in Font and text overhaul Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy