@@ -1467,144 +1467,6 @@ PyFT2Font__get_type1_encoding_vector(PyFT2Font *self)
14671467 return indices;
14681468}
14691469
1470- static const char *
1471- PyFT2Font_postscript_name (PyFT2Font *self)
1472- {
1473- const char *ps_name = FT_Get_Postscript_Name (self->x ->get_face ());
1474- if (ps_name == nullptr ) {
1475- ps_name = " UNAVAILABLE" ;
1476- }
1477-
1478- return ps_name;
1479- }
1480-
1481- static FT_Long
1482- PyFT2Font_num_faces (PyFT2Font *self)
1483- {
1484- return self->x ->get_face ()->num_faces ;
1485- }
1486-
1487- static const char *
1488- PyFT2Font_family_name (PyFT2Font *self)
1489- {
1490- const char *name = self->x ->get_face ()->family_name ;
1491- if (name == nullptr ) {
1492- name = " UNAVAILABLE" ;
1493- }
1494- return name;
1495- }
1496-
1497- static const char *
1498- PyFT2Font_style_name (PyFT2Font *self)
1499- {
1500- const char *name = self->x ->get_face ()->style_name ;
1501- if (name == nullptr ) {
1502- name = " UNAVAILABLE" ;
1503- }
1504- return name;
1505- }
1506-
1507- static FaceFlags
1508- PyFT2Font_face_flags (PyFT2Font *self)
1509- {
1510- return static_cast <FaceFlags>(self->x ->get_face ()->face_flags );
1511- }
1512-
1513- static StyleFlags
1514- PyFT2Font_style_flags (PyFT2Font *self)
1515- {
1516- return static_cast <StyleFlags>(self->x ->get_face ()->style_flags & 0xffff );
1517- }
1518-
1519- static FT_Long
1520- PyFT2Font_num_named_instances (PyFT2Font *self)
1521- {
1522- return (self->x ->get_face ()->style_flags & 0x7fff0000 ) >> 16 ;
1523- }
1524-
1525- static FT_Long
1526- PyFT2Font_num_glyphs (PyFT2Font *self)
1527- {
1528- return self->x ->get_face ()->num_glyphs ;
1529- }
1530-
1531- static FT_Int
1532- PyFT2Font_num_fixed_sizes (PyFT2Font *self)
1533- {
1534- return self->x ->get_face ()->num_fixed_sizes ;
1535- }
1536-
1537- static FT_Int
1538- PyFT2Font_num_charmaps (PyFT2Font *self)
1539- {
1540- return self->x ->get_face ()->num_charmaps ;
1541- }
1542-
1543- static bool
1544- PyFT2Font_scalable (PyFT2Font *self)
1545- {
1546- if (FT_IS_SCALABLE (self->x ->get_face ())) {
1547- return true ;
1548- }
1549- return false ;
1550- }
1551-
1552- static FT_UShort
1553- PyFT2Font_units_per_EM (PyFT2Font *self)
1554- {
1555- return self->x ->get_face ()->units_per_EM ;
1556- }
1557-
1558- static py::tuple
1559- PyFT2Font_get_bbox (PyFT2Font *self)
1560- {
1561- FT_BBox *bbox = &(self->x ->get_face ()->bbox );
1562-
1563- return py::make_tuple (bbox->xMin , bbox->yMin , bbox->xMax , bbox->yMax );
1564- }
1565-
1566- static FT_Short
1567- PyFT2Font_ascender (PyFT2Font *self)
1568- {
1569- return self->x ->get_face ()->ascender ;
1570- }
1571-
1572- static FT_Short
1573- PyFT2Font_descender (PyFT2Font *self)
1574- {
1575- return self->x ->get_face ()->descender ;
1576- }
1577-
1578- static FT_Short
1579- PyFT2Font_height (PyFT2Font *self)
1580- {
1581- return self->x ->get_face ()->height ;
1582- }
1583-
1584- static FT_Short
1585- PyFT2Font_max_advance_width (PyFT2Font *self)
1586- {
1587- return self->x ->get_face ()->max_advance_width ;
1588- }
1589-
1590- static FT_Short
1591- PyFT2Font_max_advance_height (PyFT2Font *self)
1592- {
1593- return self->x ->get_face ()->max_advance_height ;
1594- }
1595-
1596- static FT_Short
1597- PyFT2Font_underline_position (PyFT2Font *self)
1598- {
1599- return self->x ->get_face ()->underline_position ;
1600- }
1601-
1602- static FT_Short
1603- PyFT2Font_underline_thickness (PyFT2Font *self)
1604- {
1605- return self->x ->get_face ()->underline_thickness ;
1606- }
1607-
16081470static py::object
16091471ft2font__getattr__ (std::string name) {
16101472 auto api = py::module_::import (" matplotlib._api" );
@@ -1790,50 +1652,104 @@ PYBIND11_MODULE(ft2font, m, py::mod_gil_not_used())
17901652 .def (" _get_type1_encoding_vector" , &PyFT2Font__get_type1_encoding_vector,
17911653 PyFT2Font__get_type1_encoding_vector__doc__)
17921654
1793- .def_property_readonly (" postscript_name" , &PyFT2Font_postscript_name,
1794- " PostScript name of the font." )
1795- .def_property_readonly (" num_faces" , &PyFT2Font_num_faces,
1796- " Number of faces in file." )
1797- .def_property_readonly (" family_name" , &PyFT2Font_family_name,
1798- " Face family name." )
1799- .def_property_readonly (" style_name" , &PyFT2Font_style_name,
1800- " Style name." )
1801- .def_property_readonly (" face_flags" , &PyFT2Font_face_flags,
1802- " Face flags; see `.FaceFlags`." )
1803- .def_property_readonly (" style_flags" , &PyFT2Font_style_flags,
1804- " Style flags; see `.StyleFlags`." )
1805- .def_property_readonly (" num_named_instances" , &PyFT2Font_num_named_instances,
1806- " Number of named instances in the face." )
1807- .def_property_readonly (" num_glyphs" , &PyFT2Font_num_glyphs,
1808- " Number of glyphs in the face." )
1809- .def_property_readonly (" num_fixed_sizes" , &PyFT2Font_num_fixed_sizes,
1810- " Number of bitmap in the face." )
1811- .def_property_readonly (" num_charmaps" , &PyFT2Font_num_charmaps,
1812- " Number of charmaps in the face." )
1813- .def_property_readonly (" scalable" , &PyFT2Font_scalable,
1814- " Whether face is scalable; attributes after this one "
1815- " are only defined for scalable faces." )
1816- .def_property_readonly (" units_per_EM" , &PyFT2Font_units_per_EM,
1817- " Number of font units covered by the EM." )
1818- .def_property_readonly (" bbox" , &PyFT2Font_get_bbox,
1819- " Face global bounding box (xmin, ymin, xmax, ymax)." )
1820- .def_property_readonly (" ascender" , &PyFT2Font_ascender,
1821- " Ascender in 26.6 units." )
1822- .def_property_readonly (" descender" , &PyFT2Font_descender,
1823- " Descender in 26.6 units." )
1824<
8090
span class="diff-text-marker">- .def_property_readonly (" height" , &PyFT2Font_height,
1825- " Height in 26.6 units; used to compute a default line "
1826- " spacing (baseline-to-baseline distance)." )
1827- .def_property_readonly (" max_advance_width" , &PyFT2Font_max_advance_width,
1828- " Maximum horizontal cursor advance for all glyphs." )
1829- .def_property_readonly (" max_advance_height" , &PyFT2Font_max_advance_height,
1830- " Maximum vertical cursor advance for all glyphs." )
1831- .def_property_readonly (" underline_position" , &PyFT2Font_underline_position,
1832- " Vertical position of the underline bar." )
1833- .def_property_readonly (" underline_thickness" , &PyFT2Font_underline_thickness,
1834- " Thickness of the underline bar." )
1835- .def_property_readonly (" fname" , &PyFT2Font_fname,
1836- " The original filename for this object." )
1655+ .def_property_readonly (
1656+ " postscript_name" , [](PyFT2Font *self) {
1657+ if (const char *name = FT_Get_Postscript_Name (self->x ->get_face ())) {
1658+ return name;
1659+ } else {
1660+ return " UNAVAILABLE" ;
1661+ }
1662+ }, " PostScript name of the font." )
1663+ .def_property_readonly (
1664+ " num_faces" , [](PyFT2Font *self) {
1665+ return self->x ->get_face ()->num_faces ;
1666+ }, " Number of faces in file." )
1667+ .def_property_readonly (
1668+ " family_name" , [](PyFT2Font *self) {
1669+ if (const char *name = self->
E875
x ->get_face ()->family_name ) {
1670+ return name;
1671+ } else {
1672+ return " UNAVAILABLE" ;
1673+ }
1674+ }, " Face family name." )
1675+ .def_property_readonly (
1676+ " style_name" , [](PyFT2Font *self) {
1677+ if (const char *name = self->x ->get_face ()->style_name ) {
1678+ return name;
1679+ } else {
1680+ return " UNAVAILABLE" ;
1681+ }
1682+ }, " Style name." )
1683+ .def_property_readonly (
1684+ " face_flags" , [](PyFT2Font *self) {
1685+ return static_cast <FaceFlags>(self->x ->get_face ()->face_flags );
1686+ }, " Face flags; see `.FaceFlags`." )
1687+ .def_property_readonly (
1688+ " style_flags" , [](PyFT2Font *self) {
1689+ return static_cast <StyleFlags>(self->x ->get_face ()->style_flags & 0xffff );
1690+ }, " Style flags; see `.StyleFlags`." )
1691+ .def_property_readonly (
1692+ " num_named_instances" , [](PyFT2Font *self) {
1693+ return (self->x ->get_face ()->style_flags & 0x7fff0000 ) >> 16 ;
1694+ }, " Number of named instances in the face." )
1695+ .def_property_readonly (
1696+ " num_glyphs" , [](PyFT2Font *self) {
1697+ return self->x ->get_face ()->num_glyphs ;
1698+ }, " Number of glyphs in the face." )
1699+ .def_property_readonly (
1700+ " num_fixed_sizes" , [](PyFT2Font *self) {
1701+ return self->x ->get_face ()->num_fixed_sizes ;
1702+ }, " Number of bitmap in the face." )
1703+ .def_property_readonly (
1704+ " num_charmaps" , [](PyFT2Font *self) {
1705+ return self->x ->get_face ()->num_charmaps ;
1706+ }, " Number of charmaps in the face." )
1707+ .def_property_readonly (
1708+ " scalable" , [](PyFT2Font *self) {
1709+ return bool (FT_IS_SCALABLE (self->x ->get_face ()));
1710+ }, " Whether face is scalable; attributes after this one "
1711+ " are only defined for scalable faces." )
1712+ .def_property_readonly (
1713+ " units_per_EM" , [](PyFT2Font *self) {
1714+ return self->x ->get_face ()->units_per_EM ;
1715+ }, " Number of font units covered by the EM." )
1716+ .def_property_readonly (
1717+ " bbox" , [](PyFT2Font *self) {
1718+ FT_BBox bbox = self->x ->get_face ()->bbox ;
1719+ return py::make_tuple (bbox.xMin , bbox.yMin , bbox.xMax , bbox.yMax );
1720+ }, " Face global bounding box (xmin, ymin, xmax, ymax)." )
1721+ .def_property_readonly (
1722+ " ascender" , [](PyFT2Font *self) {
1723+ return self->x ->get_face ()->ascender ;
1724+ }, " Ascender in 26.6 units." )
1725+ .def_property_readonly (
1726+ " descender" , [](PyFT2Font *self) {
1727+ return self->x ->get_face ()->descender ;
1728+ }, " Descender in 26.6 units." )
1729+ .def_property_readonly (
1730+ " height" , [](PyFT2Font *self) {
1731+ return self->x ->get_face ()->height ;
1732+ }, " Height in 26.6 units; used to compute a default line spacing "
1733+ " (baseline-to-baseline distance)." )
1734+ .def_property_readonly (
1735+ " max_advance_width" , [](PyFT2Font *self) {
1736+ return self->x ->get_face ()->max_advance_width ;
1737+ }, " Maximum horizontal cursor advance for all glyphs." )
1738+ .def_property_readonly (
1739+ " max_advance_height" , [](PyFT2Font *self) {
1740+ return self->x ->get_face ()->max_advance_height ;
1741+ }, " Maximum vertical cursor advance for all glyphs." )
1742+ .def_property_readonly (
1743+ " underline_position" , [](PyFT2Font *self) {
1744+ return self->x ->get_face ()->underline_position ;
1745+ }, " Vertical position of the underline bar." )
1746+ .def_property_readonly (
1747+ " underline_thickness" , [](PyFT2Font *self) {
1748+ return self->x ->get_face ()->underline_thickness ;
1749+ }, " Thickness of the underline bar." )
1750+ .def_property_readonly (
1751+ " fname" , &PyFT2Font_fname,
1752+ " The original filename for this object." )
18371753
18381754 .def_buffer ([](PyFT2Font &self) -> py::buffer_info {
18391755 FT2Image &im = self.x ->get_image ();
0 commit comments