fix support for old versions of Raqm

This commit is contained in:
nulano 2021-03-25 00:04:41 +01:00
parent e4cc42265d
commit 5e61c1842f

View File

@ -236,7 +236,6 @@ text_layout_raqm(
size_t i = 0, count = 0, start = 0; size_t i = 0, count = 0, start = 0;
raqm_t *rq; raqm_t *rq;
raqm_glyph_t *glyphs = NULL; raqm_glyph_t *glyphs = NULL;
// raqm_glyph_t_01 *glyphs_01 = NULL;
raqm_direction_t direction; raqm_direction_t direction;
rq = raqm_create(); rq = raqm_create();
@ -278,12 +277,12 @@ text_layout_raqm(
direction = RAQM_DIRECTION_LTR; direction = RAQM_DIRECTION_LTR;
} else if (strcmp(dir, "ttb") == 0) { } else if (strcmp(dir, "ttb") == 0) {
direction = RAQM_DIRECTION_TTB; direction = RAQM_DIRECTION_TTB;
// if (p_raqm.version_atleast == NULL || !(*p_raqm.version_atleast)(0, 7, 0)) { #if !defined(RAQM_VERSION_ATLEAST) || !RAQM_VERSION_ATLEAST(0, 7, 0)
// PyErr_SetString( PyErr_SetString(
// PyExc_ValueError, PyExc_ValueError,
// "libraqm 0.7 or greater required for 'ttb' direction"); "libraqm 0.7 or greater required for 'ttb' direction");
// goto failed; goto failed;
// } #endif
} else { } else {
PyErr_SetString( PyErr_SetString(
PyExc_ValueError, "direction must be either 'rtl', 'ltr' or 'ttb'"); PyExc_ValueError, "direction must be either 'rtl', 'ltr' or 'ttb'");
@ -340,21 +339,12 @@ text_layout_raqm(
goto failed; goto failed;
} }
// if (p_raqm.version == 1) {
// glyphs_01 = raqm_get_glyphs_01(rq, &count);
// if (glyphs_01 == NULL) {
// PyErr_SetString(PyExc_ValueError, "raqm_get_glyphs() failed.");
// count = 0;
// goto failed;
// }
// } else { /* version == 2 */
glyphs = raqm_get_glyphs(rq, &count); glyphs = raqm_get_glyphs(rq, &count);
if (glyphs == NULL) { if (glyphs == NULL) {
PyErr_SetString(PyExc_ValueError, "raqm_get_glyphs() failed."); PyErr_SetString(PyExc_ValueError, "raqm_get_glyphs() failed.");
count = 0; count = 0;
goto failed; goto failed;
} }
// }
(*glyph_info) = PyMem_New(GlyphInfo, count); (*glyph_info) = PyMem_New(GlyphInfo, count);
if ((*glyph_info) == NULL) { if ((*glyph_info) == NULL) {
@ -363,16 +353,6 @@ text_layout_raqm(
goto failed; goto failed;
} }
// if (p_raqm.version == 1) {
// for (i = 0; i < count; i++) {
// (*glyph_info)[i].index = glyphs_01[i].index;
// (*glyph_info)[i].x_offset = glyphs_01[i].x_offset;
// (*glyph_info)[i].x_advance = glyphs_01[i].x_advance;
// (*glyph_info)[i].y_offset = glyphs_01[i].y_offset;
// (*glyph_info)[i].y_advance = glyphs_01[i].y_advance;
// (*glyph_info)[i].cluster = glyphs_01[i].cluster;
// }
// } else {
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
(*glyph_info)[i].index = glyphs[i].index; (*glyph_info)[i].index = glyphs[i].index;
(*glyph_info)[i].x_offset = glyphs[i].x_offset; (*glyph_info)[i].x_offset = glyphs[i].x_offset;
@ -381,7 +361,6 @@ text_layout_raqm(
(*glyph_info)[i].y_advance = glyphs[i].y_advance; (*glyph_info)[i].y_advance = glyphs[i].y_advance;
(*glyph_info)[i].cluster = glyphs[i].cluster; (*glyph_info)[i].cluster = glyphs[i].cluster;
} }
// }
failed: failed:
raqm_destroy(rq); raqm_destroy(rq);