(font_path, glyph_indices)
| 597 | |
| 598 | |
| 599 | def _get_pdf_charprocs(font_path, glyph_indices): |
| 600 | font = get_font(font_path) |
| 601 | conv = 1000 / font.units_per_EM # Conversion to PS units (1/1000's). |
| 602 | procs = {} |
| 603 | for glyph_index in glyph_indices: |
| 604 | g = font.load_glyph(glyph_index, LoadFlags.NO_SCALE) |
| 605 | d1 = [ |
| 606 | round(g.horiAdvance * conv), 0, |
| 607 | # Round bbox corners *outwards*, so that they indeed bound the glyph. |
| 608 | math.floor(g.bbox[0] * conv), math.floor(g.bbox[1] * conv), |
| 609 | math.ceil(g.bbox[2] * conv), math.ceil(g.bbox[3] * conv), |
| 610 | ] |
| 611 | v, c = font.get_path() |
| 612 | v = (v * 64 * conv).round() # Back to TrueType's internal units (1/64's). |
| 613 | procs[font.get_glyph_name(glyph_index)] = ( |
| 614 | " ".join(map(str, d1)).encode("ascii") + b" d1\n" |
| 615 | + _path.convert_to_string( |
| 616 | Path(v, c), None, None, False, None, 0, |
| 617 | # no code for quad Beziers triggers auto-conversion to cubics. |
| 618 | [b"m", b"l", b"", b"c", b"h"], True) |
| 619 | + b"f") |
| 620 | return procs |
| 621 | |
| 622 | |
| 623 | class PdfFile: |
no test coverage detected
searching dependent graphs…