- OpenJDK Cookbook
- Alex Kasko Stanislav Kobylyanskiy Alexey Mironchenko
- 458字
- 2025-04-04 21:12:25
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:
- Install Visual Studio.NET 2003 to the default installation path. Only Prerequisites and Visual C++ components are required.
- Download the FreeType 2.5.2 source tarball from http://freetype.org/ and decompress it.
- Open the file
include\config\ftoption.h
and uncomment:#define FT_CONFIG_OPTION_SUBPIXEL_RENDERING
- 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
- Open the project file
builds\windows\visualc\freetype.dsw
in Visual Studio.NET 2003. - Change
Solution Configuration
toRelease Multithreaded
and build the solution. Thefreetype252MT.lib
file will be placed into theobjs
directory. - Rename the file
freetype.lib
and save it for OpenJDK builds. - In Project Properties change Configuration Type to Dynamic Library (.dll) and build the solution. The
freetype.dll
andfreetype.exp
files will be placed into theobjs\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
- The Building 64-bit FreeType libraries for OpenJDK 6 on Windows recipe
- The FreeType official website http://freetype.org/
- Professor Donald E. Knuth's interview covering Metafont and TrueType at http://www.advogato.org/article/28.html
- The OpenJDK: Font Scaler Replacement Project page at http://openjdk.java.net/projects/font-sc