Repository: matplotlib/matplotlib
File: src/ft2font_wrapper.cpp (C++)

Code before:
            return self->get_face()->height;
          }, "Height in 26.6 units; used to compute a default line spacing "
             "(baseline-to-baseline distance).")
        .def_property_readonly(
          "max_advance_width", [](PyFT2Font *self) {
            return self->get_face()->max_advance_width;
          }, "Maximum horizontal cursor advance for all glyphs.")
        .def_property_readonly(
          "max_advance_height", [](PyFT2Font *self) {
            return self->get_face()->max_advance_height;
          }, "Maximum vertical cursor advance for all glyphs.")
        .def_property_readonly(
          "underline_position", [](PyFT2Font *self) {
            return self->get_face()->underline_position;
          }, "Vertical position of the underline bar.")
        .def_property_readonly(
          "underline_thickness", [](PyFT2Font *self) {
            return self->get_face()->underline_thickness;
          }, "Thickness of the underline bar.")
        .def_property_readonly(
          "fname", &PyFT2Font_fname,
          "The original filename for this object.")
        .def_property_readonly(
          "_hinting_factor", [](PyFT2Font *self) {
            return self->get_hinting_factor();
          }, "The hinting factor.")

        .def_buffer([](PyFT2Font &self) -> py::buffer_info {
            return self.get_image().request();
        })

        .def("_render_glyph",
             [](PyFT2Font *self, FT_UInt idx, LoadFlags flags, FT_Render_Mode render_mode) {
                auto face = self->get_face();
                FT_CHECK(FT_Load_Glyph, face, idx, static_cast<FT_Int32>(flags));
                FT_CHECK(FT_Render_Glyph, face->glyph, render_mode);
                return PyPositionedBitmap{face->glyph};
            })
        .def("_render_glyphs",
             [](PyFT2Font *self, double x, double y, FT_Render_Mode render_mode) {
                auto origin = FT_Vector{std::lround(x * 64), std::lround(y * 64)};
                auto pbs = std::vector<PyPositionedBitmap>{};
                for (auto &g: self->get_glyphs()) {
                    FT_CHECK(FT_Glyph_To_Bitmap, &g, render_mode, &origin, 1);
                    pbs.emplace_back(reinterpret_cast<FT_BitmapGlyph>(g));
                }
                return pbs;
            })
        ;

    m.attr("__freetype_version__") = version_string;

Review comment (suggestion):
Don't need the lambda?
```suggestion
          "_hinting_factor", &PyFT2Font::get_hinting_factor,
          "The hinting factor.")
```

Code after:
            py::options options{};
            options.disable_function_signatures();
            cls
            .def("draw_glyph_to_bitmap", &PyFT2Font_draw_glyph_to_bitmap,
                "image"_a, "x"_a, "y"_a, "glyph"_a, py::kw_only(), "antialiased"_a=true,
                PyFT2Font_draw_glyph_to_bitmap__doc__);
        }
        cls
        .def("get_glyph_name", &PyFT2Font::get_glyph_name, "index"_a,
             PyFT2Font_get_glyph_name__doc__)
        .def("get_charmap", &PyFT2Font_get_charmap, PyFT2Font_get_charmap__doc__)
        .def("get_char_index", &PyFT2Font::get_char_index,
             "codepoint"_a, py::kw_only(), "_fallback"_a=true,
             PyFT2Font_get_char_index__doc__)
        .def("get_sfnt", &PyFT2Font_get_sfnt, PyFT2Font_get_sfnt__doc__)
        .def("get_name_index", &PyFT2Font::get_name_index, "name"_a,
             PyFT2Font_get_name_index__doc__)
        .def("get_ps_font_info", &PyFT2Font_get_ps_font_info,
             PyFT2Font_get_ps_font_info__doc__)
        .def("get_sfnt_table", &PyFT2Font_get_sfnt_table, "name"_a,
             PyFT2Font_get_sfnt_table__doc__)
        .def("get_path", &PyFT2Font_get_path, PyFT2Font_get_path__doc__)
        .def("get_image", &PyFT2Font::get_image, PyFT2Font_get_image__doc__)
        .def("_get_type1_encoding_vector", &PyFT2Font__get_type1_encoding_vector,
             PyFT2Font__get_type1_encoding_vector__doc__)

        .def_property_readonly(
          "postscript_name", [](PyFT2Font *self) {
            if (const char *name = FT_Get_Postscript_Name(self->get_face())) {
              return name;
            } else {
              return "UNAVAILABLE";
            }
          }, "PostScript name of the font.")
        .def_property_readonly(
          "num_faces", [](PyFT2Font *self) {
            return self->get_face()->num_faces & 0xffff;
          }, "Number of faces in file.")
        .def_property_readonly(
          "face_index", [](PyFT2Font *self) {
            return self->get_face()->face_index;
          }, "The index of the font in the file.")
        .def_property_readonly(
          "family_name", [](PyFT2Font *self) {
            if (const char *name = self->get_face()->family_name) {
              return name;
            } else {
              return "UNAVAILABLE";
            }
          }, "Face family name.")
        .def_property_readonly(