Building 32-bit FreeType libraries for OpenJDK 6 on Windows

The majority of fonts used in modern software are encoded in vector format for proper scaling support. There are multiple standards for vector fonts, for example, Metafont from Professor Donald E. Knuth, Type1 from Adobe, TrueType from Apple and Microsoft, and OpenType from Adobe and Microsoft.

Rasterization of vector fonts is a remarkably complex task and most desktop software (such as web browsers or text processors) use third-party libraries to work with fonts.

Sun Microsystems licensed a third-party closed-source font library for use in Sun Java implementations. Sources of this library could not be released to public along with the initial release of OpenJDK. The Font Scaler Replacement Project was launched in the early days of OpenJDK to adopt an open source font library instead.

FreeType is a free and open source (under permissive license) font rasterization library. It is used widely in open source desktop software. FreeType was chosen by the OpenJDK team as a replacement for the closed-source font library and is now used by OpenJDK on all supported platforms. Prebuilt static and dynamic FreeType libraries are required for OpenJDK builds on Windows.

Getting ready

For this recipe we should have Windows 7 SP1 i586 running.

How to do it...

The following steps will help us in building FreeType:

  1. Install Visual Studio.NET 2003 to the default installation path. Only Prerequisites and Visual C++ components are required.
  2. Download the FreeType 2.5.2 source tarball from http://freetype.org/ and decompress it.
  3. Open the file include\config\ftoption.h and uncomment:
    #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
  4. Change lines /* #define FT_EXPORT(x) extern x */ and /* #define FT_EXPORT_DEF(x) x */ to:
    #define FT_EXPORT(x) __declspec(dllexport) x
    #define FT_EXPORT_DEF(x) __declspec(dllexport) x
  5. Open the project file builds\windows\visualc\freetype.dsw in Visual Studio.NET 2003.
  6. Change Solution Configuration to Release Multithreaded and build the solution. The freetype252MT.lib file will be placed into the objs directory.
  7. Rename the file freetype.lib and save it for OpenJDK builds.
  8. In Project Properties change Configuration Type to Dynamic Library (.dll) and build the solution. The freetype.dll and freetype.exp files will be placed into the objs\release_mt directory.

The directory with three result files will be denoted by the ALT_FREETYPE_LIB_PATH environment variable during OpenJDK builds.

How it works...

The FT_CONFIG_OPTION_SUBPIXEL_RENDERING macro enables subpixel rendering functionality in FreeType implementation.

The FT_EXPORT and FT_EXPORT_DEF macros should be adjusted with the calling conventions for the current platform. We changed them to use Windows-specific calling conventions.

FreeType has no predefined project file for Visual Studio.NET 2003. Instead, we are using the project file created for Visual Studio 6.

See also