DRYer fontconfig module

This commit is contained in:
Kovid Goyal 2017-09-09 11:44:39 +05:30
parent b8678871df
commit 5ed4b29e4b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 8 additions and 6 deletions

View File

@ -74,8 +74,6 @@ static PyMethodDef module_methods[] = {
{"change_wcwidth", (PyCFunction)change_wcwidth_wrap, METH_O, ""},
#ifdef __APPLE__
CORE_TEXT_FUNC_WRAPPERS
#else
{"get_fontconfig_font", (PyCFunction)get_fontconfig_font, METH_VARARGS, ""},
#endif
GLFW_FUNC_WRAPPERS
SPRITE_FUNC_WRAPPERS

View File

@ -402,5 +402,3 @@ DECLARE_CH_SCREEN_HANDLER(backspace)
DECLARE_CH_SCREEN_HANDLER(tab)
DECLARE_CH_SCREEN_HANDLER(linefeed)
DECLARE_CH_SCREEN_HANDLER(carriage_return)
PyObject *get_fontconfig_font(PyObject *self, PyObject *args);

View File

@ -8,7 +8,7 @@
#include "data-types.h"
#include <fontconfig/fontconfig.h>
PyObject*
static PyObject*
get_fontconfig_font(PyObject UNUSED *self, PyObject *args) {
char *family;
int bold, italic, allow_bitmapped_fonts, index = 0, hint_style=0, weight=0, slant=0;
@ -74,11 +74,17 @@ end:
return ans;
}
static PyMethodDef module_methods[] = {
{"get_fontconfig_font", (PyCFunction)get_fontconfig_font, METH_VARARGS, ""},
{NULL, NULL, 0, NULL} /* Sentinel */
};
bool
init_fontconfig_library(PyObject UNUSED *m) {
init_fontconfig_library(PyObject *module) {
if (!FcInit()) {
PyErr_SetString(PyExc_RuntimeError, "Failed to initialize the fontconfig library");
return false;
}
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
return true;
}