@@ -407,51 +407,48 @@ def destroy(self):
407
407
408
408
def get_kern (self , font1 , fontclass1 , sym1 , fontsize1 ,
409
409
font2 , fontclass2 , sym2 , fontsize2 , dpi ):
410
- r """
410
+ """
411
411
Get the kerning distance for font between *sym1* and *sym2*.
412
412
413
- *fontX*: one of the TeX font names::
414
-
415
- tt, it, rm, cal, sf, bf or default/regular (non-math)
416
-
417
- *fontclassX*: TODO
418
-
419
- *symX*: a symbol in raw TeX form. e.g., '1', 'x' or '\sigma'
420
-
421
- *fontsizeX*: the fontsize in points
422
-
423
- *dpi*: the current dots-per-inch
413
+ See `get_metrics` for a detailed description of the parameters.
424
414
"""
425
415
return 0.
426
416
427
417
def get_metrics (self , font , font_class , sym , fontsize , dpi , math = True ):
428
418
r"""
429
- *font*: one of the TeX font names::
430
-
431
- tt, it, rm, cal, sf, bf or default/regular (non-math)
432
-
433
- *font_class*: TODO
434
-
435
- *sym*: a symbol in raw TeX form. e.g., '1', 'x' or '\sigma'
436
-
437
- *fontsize*: font size in points
438
-
439
- *dpi*: current dots-per-inch
440
-
441
- *math*: whether sym is a math character
442
-
443
- Returns an object with the following attributes:
444
-
445
- - *advance*: The advance distance (in points) of the glyph.
446
-
447
- - *height*: The height of the glyph in points.
448
-
449
- - *width*: The width of the glyph in points.
450
-
451
- - *xmin*, *xmax*, *ymin*, *ymax* - the ink rectangle of the glyph
419
+ Parameters
420
+ ----------
421
+ font : str
422
+ One of the TeX font names: tt, it, rm, cal, sf, bf, default/regular
423
+ (non-math), bb, frak, scr.
424
+ font_class : str
425
+ One of the TeX font names (as for *font*), but **not** bb, frak, or
426
+ scr. This is used to combine e.g. "frak" with "bf" (the only
427
+ combination that currently actually works).
428
+ sym : str
429
+ A symbol in raw TeX form, e.g., "1", "x", or "\sigma".
430
+ fontsize : float
431
+ Font size in points.
432
+ dpi : float
433
+ Rendering dots-per-inch.
434
+ math : bool
435
+ Whether we are currently in math mode or not.
452
436
453
- - *iceberg* - the distance from the baseline to the top of
454
- the glyph. This corresponds to TeX's definition of "height".
437
+ Returns
438
+ -------
439
+ object
440
+
441
+ The returned object has the following attributes (all floats,
442
+ except *slanted*):
443
+
444
+ - *advance*: The advance distance (in points) of the glyph.
445
+ - *height*: The height of the glyph in points.
446
+ - *width*: The width of the glyph in points.
447
+ - *xmin*, *xmax*, *ymin*, *ymax*: The ink rectangle of the glyph
448
+ - *iceberg*: The distance from the baseline to the top of the
449
+ glyph. (This corresponds to TeX's definition of "height".)
450
+ - *slanted*: Whether the glyph should be considered as "slanted"
451
+ (currently used for kerning sub/superscripts).
455
452
"""
456
453
info = self ._get_info (font , font_class , sym , fontsize , dpi , math )
457
454
return info .metrics
@@ -467,19 +464,8 @@ def set_canvas_size(self, w, h, d):
467
464
468
465
def render_glyph (self , ox , oy , facename , font_class , sym , fontsize , dpi ):
469
466
"""
470
- Draw a glyph at
471
-
472
- - *ox*, *oy*: position
473
-
474
- - *facename*: One of the TeX face names
475
-
476
- - *font_class*:
477
-
478
- - *sym*: TeX symbol name or single character
479
-
480
- - *fontsize*: fontsize in points
481
-
482
- - *dpi*: The dpi to draw at.
467
+ At position (*ox*, *oy*), draw the glyph specified by the remaining
468
+ parameters (see `get_metrics` for their detailed description).
483
469
"""
484
470
info = self ._get_info (facename , font_class , sym , fontsize , dpi )
485
471
self .used_characters .setdefault (info .font .fname , set ()).add (info .num )
@@ -771,12 +757,11 @@ def __init__(self, *args, **kwargs):
771
757
if rcParams ['mathtext.fallback_to_cm' ] is not None :
772
758
fallback_rc = ('cm' if rcParams ['mathtext.fallback_to_cm' ]
773
759
else None )
774
-
775
- font_class = {'stix' : StixFonts ,
776
- 'stixsans' : StixSansFonts ,
777
- 'cm' : BakomaFonts
778
- }.get (fallback_rc )
779
- self .cm_fallback = font_class (* args , ** kwargs ) if font_class else None
760
+ font_cls = {'stix' : StixFonts ,
761
+ 'stixsans' : StixSansFonts ,
762
+ 'cm' : BakomaFonts
763
+ }.get (fallback_rc )
764
+ self .cm_fallback = font_cls (* args , ** kwargs ) if font_cls else None
780
765
781
766
TruetypeFonts .__init__ (self , * args , ** kwargs )
782
767
self .fontmap = {}
0 commit comments