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)
| 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): |
no outgoing calls
no test coverage detected