MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _get_subset_prefix

Method _get_subset_prefix

lib/matplotlib/backends/backend_pdf.py:794–814  ·  view source on GitHub ↗

Get a prefix for a subsetted font name. The prefix is six uppercase letters followed by a plus sign; see PDF reference section 5.5.3 Font Subsets.

(charset)

Source from the content-addressed store, hash-verified

792
793 @staticmethod
794 def _get_subset_prefix(charset):
795 """
796 Get a prefix for a subsetted font name.
797
798 The prefix is six uppercase letters followed by a plus sign;
799 see PDF reference section 5.5.3 Font Subsets.
800 """
801 def toStr(n, base):
802 if n < base:
803 return string.ascii_uppercase[n]
804 else:
805 return (
806 toStr(n // base, base) + string.ascii_uppercase[n % base]
807 )
808
809 # encode to string using base 26
810 hashed = hash(charset) % ((sys.maxsize + 1) * 2)
811 prefix = toStr(hashed, 26)
812
813 # get first 6 characters from prefix
814 return prefix[:6] + "+"
815
816 @staticmethod
817 def _get_subsetted_psname(ps_name, charmap):

Callers 2

_embedTeXFontMethod · 0.95
_get_subsetted_psnameMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected