Restore the old '/W' and '/DW' in subsetted font. If either parameter is None or evaluates to False, the corresponding dictionary key will be set to null.
(xref, widths, dwidths)
| 5195 | return widths, dwidths |
| 5196 | |
| 5197 | def set_old_widths(xref, widths, dwidths): |
| 5198 | """Restore the old '/W' and '/DW' in subsetted font. |
| 5199 | |
| 5200 | If either parameter is None or evaluates to False, the corresponding |
| 5201 | dictionary key will be set to null. |
| 5202 | """ |
| 5203 | df = doc.xref_get_key(xref, "DescendantFonts") |
| 5204 | if df[0] != "array": # only handle xref specs |
| 5205 | return None |
| 5206 | df_xref = int(df[1][1:-1].replace("0 R", "")) |
| 5207 | if (type(widths) is not str or not widths) and doc.xref_get_key(df_xref, "W")[ |
| 5208 | 0 |
| 5209 | ] != "null": |
| 5210 | doc.xref_set_key(df_xref, "W", "null") |
| 5211 | else: |
| 5212 | doc.xref_set_key(df_xref, "W", widths) |
| 5213 | if (type(dwidths) is not str or not dwidths) and doc.xref_get_key( |
| 5214 | df_xref, "DW" |
| 5215 | )[0] != "null": |
| 5216 | doc.xref_set_key(df_xref, "DW", "null") |
| 5217 | else: |
| 5218 | doc.xref_set_key(df_xref, "DW", dwidths) |
| 5219 | return None |
| 5220 | |
| 5221 | def set_subset_fontname(new_xref): |
| 5222 | """Generate a name prefix to tag a font as subset. |
no test coverage detected
searching dependent graphs…