Hi,

I need to do dynamic text rendering using the GD library, without hinting (for smoother antialiasing).

A comment at the end of the PHP imagefttext() doc explains how to do this:

If you're interested in turning off FreeType hinting, search for the following line in the gd source (gdft.c):
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT);
and replace it with
err = FT_Load_Glyph (face, glyph_index, FT_LOAD_NO_HINTING);
Recompile GD, and vo�la: beauteous antialiasing.

I managed to make the change and recompile the GD .dll using the source code from the GD project, but it wound up not being very compatible with PHP (they don't recommend using it anyways) -- specifically the imageftbbox() function was not present, which I need.

So I downloaded the PHP source code to try to compile php_gd2.dll from the original source code, but after two hours there will still just libraries that were not found, that needed to be compiled, that wouldn't compile, etc... and I think it's impossible for me.

Does anyone have any advice on how to do this, or even better, happen to have a version of the GD .dll already compiled with this change, or is able to easily do it?

I don't need to compile all of PHP, just this one library!

Thanks
Michael

    Which php version do you have ?

      I'm using the newest version of PHP, and trying to compile the GD library .dll using Microsoft Visual C++ 6.0, using the included project files.

      But first some "iconv" .lib was missing, and when I managed to comment that out, then it was some PHP .lib was missing, and trying to compile that led to errors when it included winsock2, and the whole thing turned into a mess.

      Please, does anyone know of a fairly turn-key way of compiling the GD .dll under windows?

        Ok,

        I think it is by far less complicated to compile PHP in a UNIX/linux way than trying to do this with Visual Studio.

        A way to do this is using cygwin which is some kind of linux environment for windows with a port of the stuff you need to compile php on Windows (including gcc and other software).

        I have an installation of cygwin running on my computer. I'm now testing if compiling php works like I think. I'll post more info or the resulting php_gd2.dll as soon as I get any further. So far the configuration went through and php is compiling.

        The steps so far:

        1. download and install cygwin (www.cygwin.com, install packages needed to compile php)
        2. download the php sources
        3. run configure (without cgi, pear, mysql... since I want the gd extension)
        4. compile php
        5. install php
        6. look for php_gd2.dll and gd library dlls.

        I'm not sure if that works but it's worth a try ...

          Thanks so much for looking into this, I didn't think that a cygwin compilation would produce .dll's and all that, I'm experienced in Win32 but know zero about unix.

          I'm downloading cygwin now to check it out and see if I can get it to work, please let me know if you do as well. The instructions for disabling font hinting above aren't quite exactly right, but it's easy to figure out..

            yes, it's a constant earlier in the file.

            I did the following prior to configuring/compiling to make sure that any generated executable doesn't depend on the cygwin dll.

            export CFLAGS="-mno-cygwin"
            export CPPFLAGS="-mno-cygwin"
            export CXXFLAGS="-mno-cygwin"
            export LDFLAGS="-mno-cygwin -mwindows"

            cygwin is a little bit slow in my case (don't know why), so it's still compiling...

              Hmm, I will wait for you to tell me if the cygwin process works.

              In the meantime, I discovered how to link all the right libraries using Visual C, but at the very end of compiling I get this message:

              Generating Code...
              Linking...
              Creating library Release_TS/php_gd2.lib and object Release_TS/php_gd2.exp
              gd.obj : error LNK2001: unresolved external symbol overflow2
              wbmp.obj : error LNK2001: unresolved external symbol
              overflow2
              ....\Release_TS/php_gd2.dll : fatal error LNK1120: 1 unresolved externals
              Error executing link.exe.
              php_gd2.dll - 3 error(s), 32 warning(s)

              I've search the GD library for _overflow2 and can't find anything; and Google has nothing. I haven't got the slightest idea how to fix something like this... Ideas?

                Ok,

                I finally compiled the dll the "official" way using Visual Studio ... I have the dll but it's size is over 900kB. I can't test it right now. I can send it per mail (pm me).

                fyi:
                I compiled it with VS2005 on the commandline (which means that you need the msvcr80.dll, the dll depends on it ... not on msvcrt.dll).

                I downloaded and installed the libraries neccessary for the gd-lib. The most difficult one to find (because of corrupted projectfile in the official release) was the static t1 lib (search for cairo build windows on google, the package contains that library and some other useful libraries).

                The commands after after having set up win32build, php-5.2.5 and bindlib_32:

                1. open vs2005 command prompt
                2. cd to php-5.2.5
                3. cscript /nologo configure.js --with-cygwin=D:\cygwin --disable-debug --disable-cgi --without-wddx --without-xml --disable-xmlreader --disable-xmlwriter --with-gd=shared --without-libxml --disable-zlib --disable-zip --disable-bcmath --disable-hash --without-iconv --disable-com-dotnet --disable-calendar--disable-ctype --disable-filter --disable-ftp --disable-json --disable-odbc --disable-reflection --disable-tokenizer
                4. nmake

                Afterwards you should have at least the php_gd2.dll. You can search/download the dependency walker (depends.exe) to check which dlls php_gd2.dll depends on. Dependency Walker will show some missing dlls that are not critical because they are part of Windows Vista (that exception will be catched on load of the php_gd2.dll).

                  Hmm, the system is not letting me sent a pm to anybody, saying I don't have permission! My email is (removed), as soon as you can send me the dll I will edit this message to remove the address..

                  Thank you so much for figuring out how to do this, I'm amazed that it is all this complicated. I really appreciate this. It seems like they don't really want us doing this??

                  I never even saw any references to a t1 lib, just freetype, libpng, libjpeg, a zip library, and then some iconv thing. Wow..

                    Thanks! Unfortunately it crashes Apache as soon as I try to use it in a PHP script....

                    Do you think it's the threading model? I'm just using the standard Apache2.2 here on Win32 without any special settings...

                      I think that the mixture of the different crt dlls might be the problem.
                      I'll try to compile a complete php package as replacement. I found a zip package containing nearly all libs and includes you need to compile php yourself.
                      I'll use Visual Studio 6 to compile PHP because that is the official release's build environment.

                      The zip file (zip.zip) with the libraries is here.

                        Write a Reply...