def get_text_width_height(self, s, prop, ismath): """ get the width and height in display coords of the string s with FontPropertry prop """ if rcParams['ps.useafm']: if ismath: s = s[1:-1] font = self._get_font_afm(prop) l,b,w,h = font.get_str_bbox(s) fontsize = prop.get_size_in_points() w *= 0.001*fontsize h *= 0.001*fontsize return w, h if ismath: width, height, pswriter = math_parse_s_ps( s, 72, prop.get_size_in_points()) return width, height font = self._get_font_ttf(prop) font.set_text(s, 0.0) w, h = font.get_width_height() w /= 64.0 # convert from subpixels h /= 64.0 return w, h
def draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw the math text using matplotlib.mathtext """ fontsize = prop.get_size_in_points() width, height, pswriter = math_parse_s_ps(s, 72, fontsize) thetext = pswriter.getvalue() ps = """gsave %(x)f %(y)f translate %(angle)f rotate %(thetext)s grestore """ % locals() self.draw_postscript(ps)
def get_text_width_height(self, s, prop, ismath): """ get the width and height in display coords of the string s with FontPropertry prop """ if ismath: width, height, pswriter = math_parse_s_ps( s, 72, prop.get_size_in_points()) return width, height font = self._get_font(prop) font.set_text(s, 0.0) w, h = font.get_width_height() w /= 64.0 # convert from subpixels h /= 64.0 return w, h
def draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw the math text using matplotlib.mathtext """ if debugPS: self._pswriter.write("% mathtext\n") fontsize = prop.get_size_in_points() width, height, pswriter = math_parse_s_ps(s, 72, fontsize) thetext = pswriter.getvalue() ps = """gsave %(x)f %(y)f translate %(angle)f rotate %(thetext)s grestore """ % locals() self._pswriter.write(ps)
def draw_mathtext(self, gc, x, y, s, prop, angle): """ Draw the math text using matplotlib.mathtext """ if debugPS: self._pswriter.write("% mathtext\n") fontsize = prop.get_size_in_points() width, height, pswriter = math_parse_s_ps(s, 72, fontsize) self.set_color(*gc.get_rgb()) thetext = pswriter.getvalue() ps = """gsave %(x)f %(y)f translate %(angle)f rotate %(thetext)s grestore """ % locals() self._pswriter.write(ps)
def get_text_width_height(self, s, prop, ismath): """ get the width and height in display coords of the string s with FontPropertry prop """ if rcParams['text.usetex']: fontsize = prop.get_size_in_points() l, b, r, t = self.texmanager.get_ps_bbox(s) w = (r - l) * fontsize / 10. h = (t - b) * fontsize / 10. #print s, w, h return w, h if rcParams['ps.useafm']: if ismath: s = s[1:-1] font = self._get_font_afm(prop) l, b, w, h = font.get_str_bbox(s) fontsize = prop.get_size_in_points() w *= 0.001 * fontsize h *= 0.001 * fontsize return w, h if ismath: width, height, pswriter = math_parse_s_ps( s, 72, prop.get_size_in_points()) return width, height font = self._get_font_ttf(prop) font.set_text(s, 0.0) w, h = font.get_width_height() w /= 64.0 # convert from subpixels h /= 64.0 #print s, w, h return w, h