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

Function _get_pdf_charprocs

lib/matplotlib/backends/backend_pdf.py:599–620  ·  view source on GitHub ↗
(font_path, glyph_indices)

Source from the content-addressed store, hash-verified

597
598
599def _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
623class PdfFile:

Callers 1

embedTTFType3Method · 0.85

Calls 5

get_fontFunction · 0.90
PathClass · 0.90
get_glyph_nameMethod · 0.80
joinMethod · 0.80
get_pathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…