-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically link libraqm #2753
Dynamically link libraqm #2753
Conversation
_imagingft.c
Outdated
@@ -75,6 +78,32 @@ typedef struct { | |||
|
|||
static PyTypeObject Font_Type; | |||
|
|||
typedef struct { | |||
void* raqm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs to spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'm on a new vm and the emacs isn't setup right yet.
p_raqm.raqm = NULL; | ||
|
||
/* Microsoft needs a totally different system */ | ||
#if !defined(_MSC_VER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of:
#if !something
a
#else
b
#endif
How about this?
#if something
b
#else
a
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows is the weird one. Everyone else follows the posix path, even people on msys2.
(and frankly, unless I can actually test with windows, I'm potentially going to drop the second clause. I was ok with shipping code if it was compiled and staticly linked, but doing it at runtime has a much larger chance of doing something bad)
((and to test with windows, I'm going to have to find precompiled raqm, harfbuzz and fribidi, which is reported to be tricky))
return 1; | ||
} | ||
|
||
#if !defined(_MSC_VER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
Windows: Can't just assign the pointers, need to cast them from FARPROC to a typedef'd version of the function pointer. Annoying but fixable.
Fedora is interesting, it's running but I'm getting corruption from one of the function calls. I'm getting what look like totally reasonable pointers to the functions, but I'm getting some garbage back from
|
Ok, so Fedora's (old) version had a different definition of the Leaving aside the (current) messy code duplication and lack of having run on Windows, This is now in the state where it's been shown that it's possible to do this. We now need to ask the question: Is this a good idea? On the plus side, it means that we can distribute support for raqm in the binaries, and people will (hopefully) be able to add libraqm and the dependencies and get text rendering that works for complex languages. On the downside, we're more sensitive to releases of raqm changing the interface on us, and we're opening up a new can of support worms about finding the libraries at runtime. We've not done a dlopen/LoadLibrary before, and I'm guessing that there's going to be at least a few support requests here. |
The GPL issue is with FriBiDi, right? Would it be any help if we used a bidi implementation with a non-copyleft license? |
Maybe, but we've tested this set of libraries. We're not going to do it in this release, so I'll revisit it in a few days. I'm thinking that some sort of versioning symbol would be useful for making sure that we're not interpreting the return value incorrectly. |
98ba699
to
8605b7a
Compare
We've now got equivalent support for libraqm on windows as before -- unsupported but may work. I've tested on freebsd, and we're good there. I think this is a good approach to getting this code distributed in a manner that is license compatible, and should be included in the next release. @homm Comments? |
We can't currently distribute a binary of Pillow with support for raqm due to license incompatibility, because while libraqm is MIT licensed, it links to GPL libraries. Unfortunately, this means that nearly no one gets support for complex text, as we're providing binaries on the big three platforms now.
This PR replaces the build dependency on libraqm with an attempt to dynamically load the dll, should it be installed by the user. To do this, we're shipping the header from the libraqm project (which is MIT licensed), using this for types, and then dynamically resolving the function addresses at runtime.
To Do: