fix finding raqm deps

This commit is contained in:
nulano 2020-11-25 16:27:12 +00:00 committed by Andrew Murray
parent 3386a9ce02
commit be0d0a3a48
3 changed files with 41 additions and 11 deletions

View File

@ -123,7 +123,7 @@ _LIB_IMAGING = (
"codec_fd",
)
DEBUG = False
DEBUG = True
class DependencyException(Exception):
@ -228,6 +228,19 @@ def _find_library_file(self, library):
return ret
def _find_include_dir(self, dirname, include):
for directory in self.compiler.include_dirs:
_dbg("Checking for include file %s in %s", (include, directory))
if os.path.isfile(os.path.join(directory, include)):
_dbg("Found %s in %s", (include, directory))
return True
subdir = os.path.join(directory, dirname)
_dbg("Checking for include file %s in %s", (include, subdir))
if os.path.isfile(os.path.join(subdir, include)):
_dbg("Found %s in %s", (include, subdir))
return subdir
def _cmd_exists(cmd):
return any(
os.access(os.path.join(path, cmd), os.X_OK)
@ -689,25 +702,36 @@ class pil_build_ext(build_ext):
if subdir:
_add_directory(self.compiler.include_dirs, subdir, 0)
if feature.want("raqm"):
if feature.freetype and feature.want("raqm"):
if feature.want_system("raqm"): # want system Raqm
_dbg("Looking for Raqm")
if _find_include_file(self, "raqm.h"):
if _find_library_file(self, "raqm"):
feature.harfbuzz = "raqm"
feature.raqm = "raqm"
elif _find_library_file(self, "libraqm"):
feature.harfbuzz = "libraqm"
feature.raqm = "libraqm"
else: # want to build Raqm
_dbg("Looking for HarfBuzz")
if _find_include_file(self, "hb.h"):
feature.harfbuzz = None
hb_dir = _find_include_dir(self, "harfbuzz", "hb.h")
if hb_dir:
if isinstance(hb_dir, str):
_add_directory(self.compiler.include_dirs, hb_dir, 0)
if _find_library_file(self, "harfbuzz"):
feature.harfbuzz = "harfbuzz"
if feature.harfbuzz:
if feature.want_system("fribidi"): # want system FriBiDi
_dbg("Looking for FriBiDi")
if _find_include_file(self, "fribidi.h"):
feature.fribidi = None
fribidi_dir = _find_include_dir(self, "fribidi", "fribidi.h")
if fribidi_dir:
if isinstance(fribidi_dir, str):
_add_directory(
self.compiler.include_dirs, fribidi_dir, 0
)
if _find_library_file(self, "fribidi"):
feature.harfbuzz = "fribidi"
feature.fribidi = "fribidi"
feature.raqm = True
else: # want to build FriBiDi shim
feature.raqm = True

View File

@ -221,6 +221,8 @@ font_getchar(PyObject *string, int index, FT_ULong *char_out) {
return 0;
}
#ifdef HAVE_RAQM
static size_t
text_layout_raqm(
PyObject *string,
@ -386,6 +388,8 @@ failed:
return count;
}
#endif
static size_t
text_layout_fallback(
PyObject *string,
@ -481,11 +485,13 @@ text_layout(
int mask,
int color) {
size_t count;
#ifdef HAVE_RAQM
if (have_raqm && self->layout_engine == LAYOUT_RAQM) {
count = text_layout_raqm(
string, self, dir, features, lang, glyph_info, mask, color);
} else {
} else
#endif
{
count = text_layout_fallback(
string, self, dir, features, lang, glyph_info, mask, color);
}
@ -1366,7 +1372,7 @@ setup_module(PyObject *m) {
PyDict_SetItemString(d, "freetype2_version", v);
#ifdef HAVE_RAQM
#ifdef HAVE_FRIBIDI_SYSTEM
#if defined(HAVE_RAQM_SYSTEM) || defined(HAVE_FRIBIDI_SYSTEM)
have_raqm = 1;
#else
load_fribidi();

View File

@ -25,7 +25,7 @@ int load_fribidi(void) {
p_fribidi = LoadLibrary("fribidi");
/* MSYS2 */
if (!p_fribidi) {
p_fribidi = LoadLibrary("libfribidi-1");
p_fribidi = LoadLibrary("libfribidi-0");
}
#endif