Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement multi-font embedding for PDF Backend#20804

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
aitikgupta wants to merge31 commits intomatplotlib:mainfromaitikgupta:pdf-fallback

Conversation

aitikgupta
Copy link
Contributor

@aitikguptaaitikgupta commentedAug 6, 2021
edited
Loading

PR Summary

Adding on to the changes from the original PR:#20740, this PR modifies the layout of FT2Font to allow multiple fonts to work with the PDF backend.

Agg backend is simpler to work with, since things like kerning are set within FT2Font, and all we really needed was a bitmap from it. However, for the PDF backend, we need to extract each glyph from a (possibly) parent FT2Font.

To tackle this, I've implemented a caching layer for the parent object, allowing us to directly get the relevant FT2Font which has a certain glyph. Bits and pieces behind how PDF backend handles fonts is also modified.

With this, we can successfully generate Type 3 and Type 42 subsetted multi-font PDFs:
type3_fallback.pdf
type42_fallback.pdf

image

Test Script:

importmatplotlib.pyplotaspltFONTTYPE=42# or 3plt.rcParams['font.family']= ['Authentic','SimHei']plt.rcParams['pdf.fonttype']=FONTTYPEplt.rcParams['font.size']=30plt.rcParams['pdf.compression']=0plt.figtext(0.18,0.45,"There are 多个汉字 in between!")plt.savefig(f"type{FONTTYPE}_fallback.pdf")

Builds on:#20740,Fixes#18883,#15260

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@aitikguptaaitikguptaforce-pushed thepdf-fallback branch 3 times, most recently fromac118a7 tod43551fCompareAugust 7, 2021 08:11
@aitikguptaaitikgupta changed the titleImplement Font Fallback for PDF backendImplement multi-font embedding for PDF BackendAug 13, 2021
@tacaswell
Copy link
Member

I'm going to try and do this one next.

@tacaswell
Copy link
Member

Both this and#20832 have been rebased and it looks like this PR has received some additional fixes so I will start here and then do#20832

@tacaswell
Copy link
Member

Included in#23559

@QuLogicQuLogic added this to thev3.6.0 milestoneAug 12, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
v3.6.0
Development

Successfully merging this pull request may close these issues.

Matplotlib would not try to apply all the font in font list to draw all characters in the given string.
4 participants
@aitikgupta@tacaswell@QuLogic@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp