cleanup in _imagingft

This commit is contained in:
nulano 2023-03-31 02:08:58 +02:00
parent b18efc775d
commit e971674011
No known key found for this signature in database
GPG Key ID: B650CDF63B705766

View File

@ -33,12 +33,6 @@
#include FT_COLOR_H #include FT_COLOR_H
#endif #endif
#define KEEP_PY_UNICODE
#if !defined(FT_LOAD_TARGET_MONO)
#define FT_LOAD_TARGET_MONO FT_LOAD_MONOCHROME
#endif
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* error table */ /* error table */
@ -420,11 +414,9 @@ text_layout_fallback(
if (mask) { if (mask) {
load_flags |= FT_LOAD_TARGET_MONO; load_flags |= FT_LOAD_TARGET_MONO;
} }
#ifdef FT_LOAD_COLOR
if (color) { if (color) {
load_flags |= FT_LOAD_COLOR; load_flags |= FT_LOAD_COLOR;
} }
#endif
for (i = 0; font_getchar(string, i, &ch); i++) { for (i = 0; font_getchar(string, i, &ch); i++) {
(*glyph_info)[i].index = FT_Get_Char_Index(self->face, ch); (*glyph_info)[i].index = FT_Get_Char_Index(self->face, ch);
error = FT_Load_Glyph(self->face, (*glyph_info)[i].index, load_flags); error = FT_Load_Glyph(self->face, (*glyph_info)[i].index, load_flags);
@ -581,11 +573,9 @@ font_getsize(FontObject *self, PyObject *args) {
if (mask) { if (mask) {
load_flags |= FT_LOAD_TARGET_MONO; load_flags |= FT_LOAD_TARGET_MONO;
} }
#ifdef FT_LOAD_COLOR
if (color) { if (color) {
load_flags |= FT_LOAD_COLOR; load_flags |= FT_LOAD_COLOR;
} }
#endif
/* /*
* text bounds are given by: * text bounds are given by:
@ -844,11 +834,9 @@ font_render(FontObject *self, PyObject *args) {
if (mask) { if (mask) {
load_flags |= FT_LOAD_TARGET_MONO; load_flags |= FT_LOAD_TARGET_MONO;
} }
#ifdef FT_LOAD_COLOR
if (color) { if (color) {
load_flags |= FT_LOAD_COLOR; load_flags |= FT_LOAD_COLOR;
} }
#endif
/* /*
* calculate x_min and y_max * calculate x_min and y_max
@ -958,13 +946,11 @@ font_render(FontObject *self, PyObject *args) {
/* bitmap is now FT_PIXEL_MODE_GRAY, fall through */ /* bitmap is now FT_PIXEL_MODE_GRAY, fall through */
case FT_PIXEL_MODE_GRAY: case FT_PIXEL_MODE_GRAY:
break; break;
#ifdef FT_LOAD_COLOR
case FT_PIXEL_MODE_BGRA: case FT_PIXEL_MODE_BGRA:
if (color) { if (color) {
break; break;
} }
/* we didn't ask for color, fall through to default */ /* we didn't ask for color, fall through to default */
#endif
default: default:
PyErr_SetString(PyExc_OSError, "unsupported bitmap pixel mode"); PyErr_SetString(PyExc_OSError, "unsupported bitmap pixel mode");
goto glyph_error; goto glyph_error;
@ -995,7 +981,6 @@ font_render(FontObject *self, PyObject *args) {
} else { } else {
target = im->image8[yy] + xx; target = im->image8[yy] + xx;
} }
#ifdef FT_LOAD_COLOR
if (color && bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) { if (color && bitmap.pixel_mode == FT_PIXEL_MODE_BGRA) {
/* paste color glyph */ /* paste color glyph */
for (k = x0; k < x1; k++) { for (k = x0; k < x1; k++) {
@ -1010,9 +995,7 @@ font_render(FontObject *self, PyObject *args) {
target[k * 4 + 3] = source[k * 4 + 3]; target[k * 4 + 3] = source[k * 4 + 3];
} }
} }
} else } else if (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) {
#endif
if (bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) {
if (color) { if (color) {
unsigned char *ink = (unsigned char *)&foreground_ink; unsigned char *ink = (unsigned char *)&foreground_ink;
for (k = x0; k < x1; k++) { for (k = x0; k < x1; k++) {