def _setPyartFont(self, fontInstance): # accounts for "None" option # does not act on self.defaultFont at all fontsize = fontInstance.size self._pycan.gstate.font_size = fontsize # map pid name for font to Pyart name pyartname = Fontmapping.getPyartName(fontInstance) self._pycan.gstate.setfont(pyartname)
def fontDescent(self, font=None): if not font: font = self.defaultFont fontname = Fontmapping.getPdfName(font) return -pdfmetrics.ascent_descent[fontname][1] * 0.001 * font.size
def stringWidth(self, s, font=None): if not font: font = self.defaultFont fontname = Fontmapping.getPdfName(font) return pdfmetrics.stringwidth(s, fontname) * font.size * 0.001