mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Port winfonts plugin to build on python2/python3
This commit is contained in:
parent
3acac495d0
commit
aa56c26f71
@ -208,8 +208,9 @@ static PyObject* remove_system_font(PyObject *self, PyObject *args) {
|
||||
return Py_BuildValue("O", ok);
|
||||
}
|
||||
|
||||
static
|
||||
PyMethodDef winfonts_methods[] = {
|
||||
static char winfonts_doc[] = "Windows font API";
|
||||
|
||||
static PyMethodDef winfonts_methods[] = {
|
||||
{"enum_font_families", enum_font_families, METH_VARARGS,
|
||||
"enum_font_families()\n\n"
|
||||
"Enumerate all regular (not italic/bold/etc. variants) font families on the system. Note there will be multiple entries for every family (corresponding to each charset of the font)."
|
||||
@ -239,14 +240,32 @@ PyMethodDef winfonts_methods[] = {
|
||||
};
|
||||
|
||||
|
||||
CALIBRE_MODINIT_FUNC
|
||||
initwinfonts(void) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
#define INITERROR return NULL
|
||||
#define INITMODULE PyModule_Create(&winfonts_module)
|
||||
static struct PyModuleDef winfonts_module = {
|
||||
/* m_base */ PyModuleDef_HEAD_INIT,
|
||||
/* m_name */ "winfonts",
|
||||
/* m_doc */ winfonts_doc,
|
||||
/* m_size */ -1,
|
||||
/* m_methods */ winfonts_methods,
|
||||
/* m_slots */ 0,
|
||||
/* m_traverse */ 0,
|
||||
/* m_clear */ 0,
|
||||
/* m_free */ 0,
|
||||
};
|
||||
CALIBRE_MODINIT_FUNC PyInit_winfonts(void) {
|
||||
#else
|
||||
#define INITERROR return
|
||||
#define INITMODULE Py_InitModule3("winfonts", winfonts_methods, winfonts_doc)
|
||||
CALIBRE_MODINIT_FUNC initwinfonts(void) {
|
||||
#endif
|
||||
|
||||
PyObject *m;
|
||||
m = Py_InitModule3(
|
||||
"winfonts", winfonts_methods,
|
||||
"Windows font API"
|
||||
);
|
||||
if (m == NULL) return;
|
||||
m = INITMODULE;
|
||||
if (m == NULL) {
|
||||
INITERROR;
|
||||
}
|
||||
|
||||
PyModule_AddIntMacro(m, FW_DONTCARE);
|
||||
PyModule_AddIntMacro(m, FW_THIN);
|
||||
@ -263,4 +282,8 @@ initwinfonts(void) {
|
||||
PyModule_AddIntMacro(m, FW_ULTRABOLD);
|
||||
PyModule_AddIntMacro(m, FW_HEAVY);
|
||||
PyModule_AddIntMacro(m, FW_BLACK);
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return m;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user