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