Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e836f9a

Browse files
committed
DOC: add ft2font to API docs
1 parent 56acc97 commit e836f9a

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

doc/api/ft2font.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**********************
2+
``matplotlib.ft2font``
3+
**********************
4+
5+
.. automodule:: matplotlib.ft2font
6+
:members:
7+
:undoc-members:
8+
:show-inheritance:

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Alphabetical list of modules:
120120
figure_api.rst
121121
font_manager_api.rst
122122
fontconfig_pattern_api.rst
123+
ft2font.rst
123124
gridspec_api.rst
124125
hatch_api.rst
125126
image_api.rst

lib/matplotlib/font_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@ def _cached_realpath(path):
15791579
@_api.rename_parameter('3.6', "filepath", "font_filepaths")
15801580
def get_font(font_filepaths, hinting_factor=None):
15811581
"""
1582-
Get an ``ft2font.FT2Font`` object given a list of file paths.
1582+
Get an `.ft2font.FT2Font` object given a list of file paths.
15831583
15841584
Parameters
15851585
----------
@@ -1595,7 +1595,7 @@ def get_font(font_filepaths, hinting_factor=None):
15951595
15961596
Returns
15971597
-------
1598-
``ft2font.FT2Font``
1598+
`.ft2font.FT2Font`
15991599
16001600
"""
16011601
if isinstance(font_filepaths, (str, Path, bytes)):

src/ft2font_wrapper.cpp

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,24 @@ static PyObject *PyFT2Font_new(PyTypeObject *type, PyObject *args, PyObject *kwd
310310
}
311311

312312
const char *PyFT2Font_init__doc__ =
313-
"FT2Font(ttffile)\n"
313+
"FT2Font(filename, hinting_factor=8, *, _fallback_list=None, _kerning_factor=0)\n"
314314
"--\n\n"
315315
"Create a new FT2Font object.\n"
316316
"\n"
317+
"Parameters\n"
318+
"----------\n"
319+
"filename : str or file-like\n"
320+
" The source of the font data in a format (ttf or ttc) that FreeType can read\n\n"
321+
"hinting_factor : int, optional\n"
322+
" Must be positive. Used to scale the hinting in the x-direction\n"
323+
"_fallback_list : list of FT2Font, optional\n"
324+
" A list of FT2Font objects used to find missing glyphs.\n\n"
325+
" .. warning ::\n"
326+
" This API is both private and provisional: do not use it directly\n\n"
327+
"_kerning_factor : int, optional\n"
328+
" Used to adjust the degree of kerning.\n\n"
329+
" .. warning ::\n"
330+
" This API is private: do not use it directly\n\n"
317331
"Attributes\n"
318332
"----------\n"
319333
"num_faces\n"
@@ -518,10 +532,10 @@ const char *PyFT2Font_get_kerning__doc__ =
518532
"get_kerning(self, left, right, mode)\n"
519533
"--\n\n"
520534
"Get the kerning between *left* and *right* glyph indices.\n"
521-
"*mode* is a kerning mode constant:\n"
522-
" KERNING_DEFAULT - Return scaled and grid-fitted kerning distances\n"
523-
" KERNING_UNFITTED - Return scaled but un-grid-fitted kerning distances\n"
524-
" KERNING_UNSCALED - Return the kerning vector in original font units\n";
535+
"*mode* is a kerning mode constant:\n\n"
536+
" - KERNING_DEFAULT - Return scaled and grid-fitted kerning distances\n"
537+
" - KERNING_UNFITTED - Return scaled but un-grid-fitted kerning distances\n"
538+
" - KERNING_UNSCALED - Return the kerning vector in original font units\n";
525539

526540
static PyObject *PyFT2Font_get_kerning(PyFT2Font *self, PyObject *args)
527541
{
@@ -626,16 +640,16 @@ const char *PyFT2Font_load_char__doc__ =
626640
"Load character with *charcode* in current fontfile and set glyph.\n"
627641
"*flags* can be a bitwise-or of the LOAD_XXX constants;\n"
628642
"the default value is LOAD_FORCE_AUTOHINT.\n"
629-
"Return value is a Glyph object, with attributes\n"
630-
" width # glyph width\n"
631-
" height # glyph height\n"
632-
" bbox # the glyph bbox (xmin, ymin, xmax, ymax)\n"
633-
" horiBearingX # left side bearing in horizontal layouts\n"
634-
" horiBearingY # top side bearing in horizontal layouts\n"
635-
" horiAdvance # advance width for horizontal layout\n"
636-
" vertBearingX # left side bearing in vertical layouts\n"
637-
" vertBearingY # top side bearing in vertical layouts\n"
638-
" vertAdvance # advance height for vertical layout\n";
643+
"Return value is a Glyph object, with attributes\n\n"
644+
"- width # glyph width\n"
645+
"- height # glyph height\n"
646+
"- bbox # the glyph bbox (xmin, ymin, xmax, ymax)\n"
647+
"- horiBearingX # left side bearing in horizontal layouts\n"
648+
"- horiBearingY # top side bearing in horizontal layouts\n"
649+
"- horiAdvance # advance width for horizontal layout\n"
650+
"- vertBearingX # left side bearing in vertical layouts\n"
651+
"- vertBearingY # top side bearing in vertical layouts\n"
652+
"- vertAdvance # advance height for vertical layout\n";
639653

640654
static PyObject *PyFT2Font_load_char(PyFT2Font *self, PyObject *args, PyObject *kwds)
641655
{
@@ -664,16 +678,16 @@ const char *PyFT2Font_load_glyph__doc__ =
664678
"Load character with *glyphindex* in current fontfile and set glyph.\n"
665679
"*flags* can be a bitwise-or of the LOAD_XXX constants;\n"
666680
"the default value is LOAD_FORCE_AUTOHINT.\n"
667-
"Return value is a Glyph object, with attributes\n"
668-
" width # glyph width\n"
669-
" height # glyph height\n"
670-
" bbox # the glyph bbox (xmin, ymin, xmax, ymax)\n"
671-
" horiBearingX # left side bearing in horizontal layouts\n"
672-
" horiBearingY # top side bearing in horizontal layouts\n"
673-
" horiAdvance # advance width for horizontal layout\n"
674-
" vertBearingX # left side bearing in vertical layouts\n"
675-
" vertBearingY # top side bearing in vertical layouts\n"
676-
" vertAdvance # advance height for vertical layout\n";
681+
"Return value is a Glyph object, with attributes\n\n"
682+
"- width # glyph width\n"
683+
"- height # glyph height\n"
684+
"- bbox # the glyph bbox (xmin, ymin, xmax, ymax)\n"
685+
"- horiBearingX # left side bearing in horizontal layouts\n"
686+
"- horiBearingY # top side bearing in horizontal layouts\n"
687+
"- horiAdvance # advance width for horizontal layout\n"
688+
"- vertBearingX # left side bearing in vertical layouts\n"
689+
"- vertBearingY # top side bearing in vertical layouts\n"
690+
"- vertAdvance # advance height for vertical layout\n";
677691

678692
static PyObject *PyFT2Font_load_glyph(PyFT2Font *self, PyObject *args, PyObject *kwds)
679693
{

0 commit comments

Comments
 (0)