@@ -510,75 +510,44 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
510
510
angle : float
511
511
The rotation angle in degrees anti-clockwise.
512
512
ismath : bool or "TeX"
513
- If True, use mathtext parser. If "TeX", use tex for rendering.
513
+ If True, use mathtext parser.
514
514
mtext : `~matplotlib.text.Text`
515
515
The original text object to be rendered.
516
+
517
+ Notes
518
+ -----
519
+ **Notes for backend implementers:**
520
+
521
+ `.RendererBase.draw_text` also supports passing "TeX" to the *ismath*
522
+ parameter to use TeX rendering, but this is not required for actual
523
+ rendering backends, and indeed many builtin backends do not support
524
+ this. Rather, TeX rendering is provided by `~.RendererBase.draw_tex`.
516
525
"""
517
526
self ._draw_text_as_path (gc , x , y , s , prop , angle , ismath )
518
527
519
- def _get_text_path_transform (self , x , y , s , prop , angle , ismath ):
528
+ def _draw_text_as_path (self , gc , x , y , s , prop , angle , ismath ):
520
529
"""
521
- Return the text path and transform .
530
+ Draw the text by converting them to paths using `.TextToPath` .
522
531
523
- Parameters
524
- ----------
525
- x : float
526
- The x location of the text in display coords.
527
- y : float
528
- The y location of the text baseline in display coords.
529
- s : str
530
- The text to be converted.
531
- prop : `~matplotlib.font_manager.FontProperties`
532
- The font property.
533
- angle : float
534
- Angle in degrees to render the text at.
535
- ismath : bool or "TeX"
536
- If True, use mathtext parser. If "TeX", use tex for rendering.
532
+ This private helper supports the same parameters as
533
+ `~.RendererBase.draw_text`; setting *ismath* to "TeX" triggers TeX
534
+ rendering.
537
535
"""
538
-
539
536
text2path = self ._text2path
540
537
fontsize = self .points_to_pixels (prop .get_size_in_points ())
541
538
verts , codes = text2path .get_text_path (prop , s , ismath = ismath )
542
-
543
539
path = Path (verts , codes )
544
- angle = np .deg2rad (angle )
545
540
if self .flipy ():
546
541
width , height = self .get_canvas_width_height ()
547
542
transform = (Affine2D ()
548
543
.scale (fontsize / text2path .FONT_SCALE )
549
- .rotate (angle )
544
+ .rotate_deg (angle )
550
545
.translate (x , height - y ))
551
546
else :
552
547
transform = (Affine2D ()
553
548
.scale (fontsize / text2path .FONT_SCALE )
554
- .rotate (angle )
549
+ .rotate_deg (angle )
555
550
.translate (x , y ))
556
-
557
- return path , transform
558
-
559
- def _draw_text_as_path (self , gc , x , y , s , prop , angle , ismath ):
560
- """
561
- Draw the text by converting them to paths using `.TextToPath`.
562
-
563
- Parameters
564
- ----------
565
- gc : `.GraphicsContextBase`
566
- The graphics context.
567
- x : float
568
- The x location of the text in display coords.
569
- y : float
570
- The y location of the text baseline in display coords.
571
- s : str
572
- The text to be converted.
573
- prop : `~matplotlib.font_manager.FontProperties`
574
- The font property.
575
- angle : float
576
- Angle in degrees to render the text at.
577
- ismath : bool or "TeX"
578
- If True, use mathtext parser. If "TeX", use tex for rendering.
579
- """
580
- path , transform = self ._get_text_path_transform (
581
- x , y , s , prop , angle , ismath )
582
551
color = gc .get_rgb ()
583
552
gc .set_linewidth (0.0 )
584
553
self .draw_path (gc , path , transform , rgbFace = color )
0 commit comments