mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add API to add font resources to windows
This commit is contained in:
parent
8aa1df125e
commit
1ffee5eef8
@ -106,6 +106,7 @@ static PyObject* enum_font_families(PyObject *self, PyObject *args) {
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
// font_data() {{{
|
||||||
static PyObject* font_data(PyObject *self, PyObject *args) {
|
static PyObject* font_data(PyObject *self, PyObject *args) {
|
||||||
PyObject *ans = NULL, *italic, *pyname;
|
PyObject *ans = NULL, *italic, *pyname;
|
||||||
LOGFONTW lf;
|
LOGFONTW lf;
|
||||||
@ -157,6 +158,23 @@ static PyObject* font_data(PyObject *self, PyObject *args) {
|
|||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
static PyObject* add_font(PyObject *self, PyObject *args) {
|
||||||
|
PyObject *pyname, *private_font;
|
||||||
|
LPWSTR path;
|
||||||
|
int num;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "OO", &pyname, &private_font)) return NULL;
|
||||||
|
|
||||||
|
path = unicode_to_wchar(pyname);
|
||||||
|
if (path == NULL) return NULL;
|
||||||
|
|
||||||
|
num = AddFontResourceEx(path, (PyObject_IsTrue(private_font)) ? FR_PRIVATE : 0, 0);
|
||||||
|
free(path);
|
||||||
|
|
||||||
|
return Py_BuildValue("i", num);
|
||||||
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
PyMethodDef winfonts_methods[] = {
|
PyMethodDef winfonts_methods[] = {
|
||||||
@ -170,6 +188,11 @@ PyMethodDef winfonts_methods[] = {
|
|||||||
"Return the raw font data for the specified font."
|
"Return the raw font data for the specified font."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{"add_font", add_font, METH_VARARGS,
|
||||||
|
"add_font(filename, private)\n\n"
|
||||||
|
"Add the font(s) in filename to windows. If private is True, the font will only be available to this process and will not be installed system wide. Reeturns the number of fonts added."
|
||||||
|
},
|
||||||
|
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user