Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/deprecations/30512-ES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``PdfFile.multi_byte_charprocs``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is deprecated with no replacement.
10 changes: 10 additions & 0 deletions doc/release/next_whats_new/pdf_fonts.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Improved font embedding in PDF
------------------------------

Both Type 3 and Type 42 fonts (see :ref:`fonts` for more details) are now
embedded into PDFs without limitation. Fonts may be split into multiple
embedded subsets in order to satisfy format limits. Additionally, a corrected
Unicode mapping is added for each.

This means that *all* text should now be selectable and copyable in PDF viewers
that support doing so.
19 changes: 19 additions & 0 deletions lib/matplotlib/backends/_backend_pdf_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,25 @@ def track_glyph(
self.used.setdefault((font.fname, subset), {})[subset_charcode] = glyph
return (subset, subset_charcode)

def subset_to_unicode(self, index: int,
charcode: CharacterCodeType) -> CharacterCodeType:
"""
Map a subset index and character code to a Unicode character code.

Parameters
----------
index : int
The subset index within a font.
charcode : CharacterCodeType
The character code within a subset to map back.

Returns
-------
CharacterCodeType
The Unicode character code corresponding to the subsetted one.
"""
return index * self.subset_size + charcode


class RendererPDFPSBase(RendererBase):
# The following attributes must be defined by the subclasses:
Expand Down
Loading
Loading