mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'py3' of https://github.com/eli-schwartz/calibre
This commit is contained in:
commit
9695a6e1cc
@ -111,8 +111,8 @@ def get_sip_dir():
|
|||||||
pyqt['pyqt_sip_dir'] = get_sip_dir()
|
pyqt['pyqt_sip_dir'] = get_sip_dir()
|
||||||
pyqt['sip_inc_dir'] = os.environ.get('SIP_INC_DIR', sysconfig.get_path('include'))
|
pyqt['sip_inc_dir'] = os.environ.get('SIP_INC_DIR', sysconfig.get_path('include'))
|
||||||
|
|
||||||
glib_flags = subprocess.check_output([PKGCONFIG, '--libs', 'glib-2.0']).strip() if islinux or ishaiku else ''
|
glib_flags = subprocess.check_output([PKGCONFIG, '--libs', 'glib-2.0']).decode('utf-8').strip() if islinux or ishaiku else ''
|
||||||
fontconfig_flags = subprocess.check_output([PKGCONFIG, '--libs', 'fontconfig']).strip() if islinux or ishaiku else ''
|
fontconfig_flags = subprocess.check_output([PKGCONFIG, '--libs', 'fontconfig']).decode('utf-8').strip() if islinux or ishaiku else ''
|
||||||
qt_inc = pyqt['inc']
|
qt_inc = pyqt['inc']
|
||||||
qt_lib = pyqt['lib']
|
qt_lib = pyqt['lib']
|
||||||
ft_lib_dirs = []
|
ft_lib_dirs = []
|
||||||
|
@ -87,7 +87,7 @@ else:
|
|||||||
filesystem_encoding = 'utf-8'
|
filesystem_encoding = 'utf-8'
|
||||||
|
|
||||||
|
|
||||||
DEBUG = b'CALIBRE_DEBUG' in os.environ
|
DEBUG = 'CALIBRE_DEBUG' in os.environ
|
||||||
|
|
||||||
|
|
||||||
def debug():
|
def debug():
|
||||||
|
@ -184,7 +184,7 @@ Device_dealloc(Device* self)
|
|||||||
Py_XDECREF(self->serial_number); self->serial_number = NULL;
|
Py_XDECREF(self->serial_number); self->serial_number = NULL;
|
||||||
Py_XDECREF(self->device_version); self->device_version = NULL;
|
Py_XDECREF(self->device_version); self->device_version = NULL;
|
||||||
|
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -32,7 +32,7 @@ dealloc(Device* self)
|
|||||||
|
|
||||||
Py_XDECREF(self->device_information); self->device_information = NULL;
|
Py_XDECREF(self->device_information); self->device_information = NULL;
|
||||||
|
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -244,4 +244,3 @@ PyTypeObject wpd::DeviceType = { // {{{
|
|||||||
0, /* tp_alloc */
|
0, /* tp_alloc */
|
||||||
0, /* tp_new */
|
0, /* tp_new */
|
||||||
}; // }}}
|
}; // }}}
|
||||||
|
|
||||||
|
@ -48,7 +48,11 @@ PyObject* get_glyphs(const QPointF &p, const QTextItem &text_item) {
|
|||||||
indices = PyTuple_New(glyphs.count());
|
indices = PyTuple_New(glyphs.count());
|
||||||
if (indices == NULL) { Py_DECREF(points); return PyErr_NoMemory(); }
|
if (indices == NULL) { Py_DECREF(points); return PyErr_NoMemory(); }
|
||||||
for (int i = 0; i < glyphs.count(); i++) {
|
for (int i = 0; i < glyphs.count(); i++) {
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
temp = PyLong_FromLong((long)glyphs[i]);
|
||||||
|
#else
|
||||||
temp = PyInt_FromLong((long)glyphs[i]);
|
temp = PyInt_FromLong((long)glyphs[i]);
|
||||||
|
#endif
|
||||||
if (temp == NULL) { Py_DECREF(indices); Py_DECREF(points); return PyErr_NoMemory(); }
|
if (temp == NULL) { Py_DECREF(indices); Py_DECREF(points); return PyErr_NoMemory(); }
|
||||||
PyTuple_SET_ITEM(indices, i, temp); temp = NULL;
|
PyTuple_SET_ITEM(indices, i, temp); temp = NULL;
|
||||||
}
|
}
|
||||||
@ -74,10 +78,13 @@ PyObject* get_glyph_map(const QTextItem &text_item) {
|
|||||||
for (uint uc = 0; uc < 0x10000; ++uc) {
|
for (uint uc = 0; uc < 0x10000; ++uc) {
|
||||||
QChar ch(uc);
|
QChar ch(uc);
|
||||||
ti.fontEngine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
|
ti.fontEngine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
t = PyLong_FromLong(glyphs.glyphs[0]);
|
||||||
|
#else
|
||||||
t = PyInt_FromLong(glyphs.glyphs[0]);
|
t = PyInt_FromLong(glyphs.glyphs[0]);
|
||||||
|
#endif
|
||||||
if (t == NULL) { Py_DECREF(ans); return PyErr_NoMemory(); }
|
if (t == NULL) { Py_DECREF(ans); return PyErr_NoMemory(); }
|
||||||
PyTuple_SET_ITEM(ans, uc, t); t = NULL;
|
PyTuple_SET_ITEM(ans, uc, t); t = NULL;
|
||||||
}
|
}
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// Per python C-API docs, Python.h must always be the first header
|
||||||
|
#include <Python.h>
|
||||||
#include <QGlyphRun>
|
#include <QGlyphRun>
|
||||||
#include <QTextItem>
|
#include <QTextItem>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <Python.h>
|
|
||||||
|
|
||||||
PyObject* get_glyphs(const QPointF &p, const QTextItem &text_item);
|
PyObject* get_glyphs(const QPointF &p, const QTextItem &text_item);
|
||||||
|
|
||||||
PyObject* get_sfnt_table(const QTextItem &text_item, const char* tag_name);
|
PyObject* get_sfnt_table(const QTextItem &text_item, const char* tag_name);
|
||||||
|
|
||||||
PyObject* get_glyph_map(const QTextItem &text_item);
|
PyObject* get_glyph_map(const QTextItem &text_item);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Face_dealloc(Face* self)
|
|||||||
Py_XDECREF(self->data);
|
Py_XDECREF(self->data);
|
||||||
self->data = NULL;
|
self->data = NULL;
|
||||||
|
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -160,7 +160,7 @@ dealloc(FreeType* self)
|
|||||||
}
|
}
|
||||||
self->library = NULL;
|
self->library = NULL;
|
||||||
|
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -319,4 +319,3 @@ initfreetype(void) {
|
|||||||
PyModule_AddObject(m, "FreeType", (PyObject *)&FreeTypeType);
|
PyModule_AddObject(m, "FreeType", (PyObject *)&FreeTypeType);
|
||||||
PyModule_AddObject(m, "Face", (PyObject *)&FaceType);
|
PyModule_AddObject(m, "Face", (PyObject *)&FaceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ static void
|
|||||||
PDFDoc_dealloc(PDFDoc* self)
|
PDFDoc_dealloc(PDFDoc* self)
|
||||||
{
|
{
|
||||||
if (self->doc != NULL) delete self->doc;
|
if (self->doc != NULL) delete self->doc;
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -13,7 +13,7 @@ using namespace pdf;
|
|||||||
static void
|
static void
|
||||||
dealloc(PDFOutlineItem* self)
|
dealloc(PDFOutlineItem* self)
|
||||||
{
|
{
|
||||||
self->ob_type->tp_free((PyObject*)self);
|
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
@ -138,5 +138,3 @@ PyTypeObject pdf::PDFOutlineItemType = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user