[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/spha-code/matplotlib/main/src/ft2font_wrapper.cpp [Back]  [Original]

#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include 
#include 
#include 

#include "ft2font.h"
#include "_enums.h"

#include 
#include 
#include 

namespace py = pybind11;
using namespace pybind11::literals;

template 
using double_or_ = std::variant;

template 
static T
_double_to_(const char *name, double_or_ &var)
{
    if (auto value = std::get_if(&var)) {
        auto api = py::module_::import("matplotlib._api");
        auto warn = api.attr("warn_deprecated");
        warn("since"_a="3.10", "name"_a=name, "obj_type"_a="parameter as float",
             "alternative"_a="int({})"_s.format(name));
        return static_cast(*value);
    } else if (auto value = std::get_if(&var)) {
        return *value;
    } else {
        // pybind11 will have only allowed types that match the variant, so this `else`
        // can't happen. We only have this case because older macOS doesn't support
        // `std::get` and using the conditional `std::get_if` means an `else` to silence
        // compiler warnings about "unhandled" cases.
        throw std::runtime_error("Should not happen");
    }
}

/**********************************************************************
 * Enumerations
 * */

const char *Kerning__doc__ = R"""(
    Kerning modes for `.FT2Font.get_kerning`.

    For more information, see `the FreeType documentation
    `_.

    .. versionadded:: 3.10
)""";

P11X_DECLARE_ENUM(
    "Kerning", "Enum",
    {"DEFAULT", FT_KERNING_DEFAULT},
    {"UNFITTED", FT_KERNING_UNFITTED},
    {"UNSCALED", FT_KERNING_UNSCALED},
);

const char *FaceFlags__doc__ = R"""(
    Flags returned by `FT2Font.face_flags`.

    For more information, see `the FreeType documentation
    `_.

    .. versionadded:: 3.10
)""";

#ifndef FT_FACE_FLAG_VARIATION  // backcompat: ft 2.9.0.
#define FT_FACE_FLAG_VARIATION (1L 

Web Proxy Viewer  |  New URL  |  Original Page