Re: [INTERNALS-WIN] imagettftext with UTF-8 and long paths in PHP 7.1

[email protected] (Pierre Joye) Sat, 16 Jul 2016 16:28:25 +0700
Newsgroups php.internals.win
Message-ID <CAEZPtU64EMpvKQU97Tr99WYfxBxpk1z0J7+12NM=3JzQbPrSuw@mail.gmail.com>
Hi

On Jul 16, 2016 7:44 AM, "Christoph Becker" <[email protected]> wrote:
>
> Hi!
>
> While running the ext/gd tests on Windows I've stumbled upon
> bug48732-mb.phpt[1].  The test is marked as XFAIL "seems freetype issue,
> to investigate".  I've tried to solve the issue, but I'm stuck.
>
> The first issue is that libgd uses the macro access() to check whether
> the given filename can be accessed[2].  In the bundled libgd, access is
> defined as _access[3], what obviously can't work.  As quick workaround,
> I changed that to tsrm_win32_access, and that lets the check succeed.
> Of course, it's not possible for libgd to depend on a PHP API, so that
> would require another solution.  Anyhow, the system libgd[4] includes
> <unistd.h> and uses access (what presumably maps to _waccess).  (I'm
> deliberately ignoring the Windows Mobile/CE fallback library, at least
> for now).  If we'd use _waccess also for the bundled libgd (which might
> happen anyway, as synchronizing the bundled and the system libgd is work
> in progress), it *might* be possible to do the conversion in the PHP
> binding and pass the UTF-16 filename to gdImageStringFT().  I don't know
> if there is a simple way to convert from default_charset to UTF-16,
though.
>

For gd 3, the plan is to support UTF-8 paths. But that won't solve the
problem with external libraries like freetype.

Anything else using gd can pass a ctx instance, no path required.

> The next issue is that FT_New_Face()[5] is called to retrieve a face.
> However, freetype seems to use fopen(), which also won't work.  On
> StackOverflow[6] I found the suggestion to load the file into memory,
> and then to use FT_New_Memory_Face().  That appears to be a viable
> solution, but I wouldn't know how to implement it.
>
> Anyway, I consider supporting arbitrary default_charset for font
> filenames to be rather low priority (at least ASCII names should work
> fine, mostly), but perhaps someone may want to solve this issue, and
> hopefully my findings would be helpful in this case.
>
> [1]
> <
https://github.com/php/php-src/blob/php-7.1.0alpha3/ext/gd/tests/bug48732-mb.phpt
>
> [2]
> <
https://github.com/php/php-src/blob/php-7.1.0alpha3/ext/gd/libgd/gdft.c#L407
>
> [3] <https://msdn.microsoft.com/en-us/library/1w06ktdy.aspx>
> [4] <https://github.com/libgd/libgd/blob/gd-2.2.2/src/gdft.c#L24-L26>
> [5]
> <
https://github.com/php/php-src/blob/php-7.1.0alpha3/ext/gd/libgd/gdft.c#L458
>
> [6]
> <
http://stackoverflow.com/questions/10075032/can-freetype-functions-accept-unicode-filenames
>
>
> --
> Christoph M. Becker
>
> --
> Windows Internals Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>