fix freetype and raqm on MSYS

This commit is contained in:
nulano 2020-05-23 21:24:11 +02:00
parent a212225b37
commit d2f90d6cac
4 changed files with 18 additions and 4 deletions

View File

@ -288,6 +288,12 @@ def is_pypy():
return hasattr(sys, "pypy_translation_info") return hasattr(sys, "pypy_translation_info")
def is_mingw():
import sysconfig
return sysconfig.get_platform() == "mingw"
if sys.platform == "win32": if sys.platform == "win32":
IMCONVERT = os.environ.get("MAGICK_HOME", "") IMCONVERT = os.environ.get("MAGICK_HOME", "")
if IMCONVERT: if IMCONVERT:

View File

@ -13,6 +13,7 @@ from .helper import (
assert_image_equal, assert_image_equal,
assert_image_similar, assert_image_similar,
assert_image_similar_tofile, assert_image_similar_tofile,
is_mingw,
is_pypy, is_pypy,
is_win32, is_win32,
skip_unless_feature, skip_unless_feature,
@ -660,6 +661,7 @@ class TestImageFont:
{"name": b"Size", "minimum": 0, "maximum": 300, "default": 0} {"name": b"Size", "minimum": 0, "maximum": 300, "default": 0}
] ]
@pytest.mark.skipif(is_mingw(), reason="epsilon too high for meaningful test")
def test_variation_set_by_name(self): def test_variation_set_by_name(self):
font = self.get_font() font = self.get_font()
@ -692,6 +694,7 @@ class TestImageFont:
font.set_variation_by_name(name) font.set_variation_by_name(name)
_check_text(font, "Tests/images/variation_tiny_name.png", 40) _check_text(font, "Tests/images/variation_tiny_name.png", 40)
@pytest.mark.skipif(is_mingw(), reason="epsilon too high for meaningful test")
def test_variation_set_by_axes(self): def test_variation_set_by_axes(self):
font = self.get_font() font = self.get_font()

View File

@ -60,7 +60,7 @@ def test_complex_unicode_text():
target = "Tests/images/test_complex_unicode_text2.png" target = "Tests/images/test_complex_unicode_text2.png"
with Image.open(target) as target_img: with Image.open(target) as target_img:
assert_image_similar(im, target_img, 2.3) assert_image_similar(im, target_img, 2.33)
def test_text_direction_rtl(): def test_text_direction_rtl():

View File

@ -31,7 +31,7 @@
#define KEEP_PY_UNICODE #define KEEP_PY_UNICODE
#if !defined(_MSC_VER) #ifndef _WIN32
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -155,20 +155,25 @@ setraqm(void)
p_raqm.raqm = NULL; p_raqm.raqm = NULL;
/* Microsoft needs a totally different system */ /* Microsoft needs a totally different system */
#if !defined(_MSC_VER) #ifndef _WIN32
p_raqm.raqm = dlopen("libraqm.so.0", RTLD_LAZY); p_raqm.raqm = dlopen("libraqm.so.0", RTLD_LAZY);
if (!p_raqm.raqm) { if (!p_raqm.raqm) {
p_raqm.raqm = dlopen("libraqm.dylib", RTLD_LAZY); p_raqm.raqm = dlopen("libraqm.dylib", RTLD_LAZY);
} }
#else #else
p_raqm.raqm = LoadLibrary("libraqm"); p_raqm.raqm = LoadLibrary("libraqm");
/* Cygwin / MinGW */
if (!p_raqm.raqm) {
p_raqm.raqm = LoadLibrary("libraqm-0");
}
#endif #endif
if (!p_raqm.raqm) { if (!p_raqm.raqm) {
return 1; return 1;
} }
#if !defined(_MSC_VER) #ifndef _WIN32
p_raqm.version_atleast = (t_raqm_version_atleast)dlsym(p_raqm.raqm, "raqm_version_atleast"); p_raqm.version_atleast = (t_raqm_version_atleast)dlsym(p_raqm.raqm, "raqm_version_atleast");
p_raqm.create = (t_raqm_create)dlsym(p_raqm.raqm, "raqm_create"); p_raqm.create = (t_raqm_create)dlsym(p_raqm.raqm, "raqm_create");
p_raqm.set_text = (t_raqm_set_text)dlsym(p_raqm.raqm, "raqm_set_text"); p_raqm.set_text = (t_raqm_set_text)dlsym(p_raqm.raqm, "raqm_set_text");