@@ -407,51 +407,50 @@ 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 `~.Fonts.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",
423
+ "default", "regular", "bb", "frak", "scr". "default" and "regular"
424
+ are synonyms and use the non-math font.
425
+ font_class : str
426
+ One of the TeX font names (as for *font*), but **not** "bb",
427
+ "frak", or "scr". This is used to combine two font classes. The
428
+ only supported combination currently is ``get_metrics("frak", "bf",
429
+ ...)``.
430
+ sym : str
431
+ A symbol in raw TeX form, e.g., "1", "x", or "\sigma".
432
+ fontsize : float
433
+ Font size in points.
434
+ dpi : float
435
+ Rendering dots-per-inch.
436
+ math : bool
437
+ Whether we are currently in math mode or not.
452
438
453
- - *iceberg* - the distance from the baseline to the top of
454
- the glyph. This corresponds to TeX's definition of "height".
439
+ Returns
440
+ -------
441
+ object
442
+
443
+ The returned object has the following attributes (all floats,
444
+ except *slanted*):
445
+
446
+ - *advance*: The advance distance (in points) of the glyph.
447
+ - *height*: The height of the glyph in points.
448
+ - *width*: The width of the glyph in points.
449
+ - *xmin*, *xmax*, *ymin*, *ymax*: The ink rectangle of the glyph
450
+ - *iceberg*: The distance from the baseline to the top of the
451
+ glyph. (This corresponds to TeX's definition of "height".)
452
+ - *slanted*: Whether the glyph should be considered as "slanted"
453
+ (currently used for kerning sub/superscripts).
455
454
"""
456
455
info = self ._get_info (font , font_class , sym , fontsize , dpi , math )
457
456
return info .metrics
@@ -467,19 +466,8 @@ def set_canvas_size(self, w, h, d):
467
466
468
467
def render_glyph (self , ox , oy , facename , font_class , sym , fontsize , dpi ):
469
468
"""
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.
469
+ At position (*ox*, *oy*), draw the glyph specified by the remaining
470
+ parameters (see `get_metrics` for their detailed description).
483
471
"""
484
472
info = self ._get_info (facename , font_class , sym , fontsize , dpi )
485
473
self .used_characters .setdefault (info .font .fname , set ()).add (info .num )
@@ -771,12 +759,11 @@ def __init__(self, *args, **kwargs):
771
759
if rcParams ['mathtext.fallback_to_cm' ] is not None :
772
760
fallback_rc = ('cm' if rcParams ['mathtext.fallback_to_cm' ]
773
761
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
762
+ font_cls = {'stix' : StixFonts ,
763
+ 'stixsans' : StixSansFonts ,
764
+ 'cm' : BakomaFonts
765
+ }.get (fallback_rc )
766
+ self .cm_fallback = font_cls (* args , ** kwargs ) if font_cls else None
780
767
781
768
TruetypeFonts .__init__ (self , * args , ** kwargs )
782
769
self .fontmap = {}
0 commit comments