Skip to content

Conversation

@longtran2904
Copy link

Overview

  • Update to the latest version (2.13.3)
  • Add support for OTF files
  • Only build and include necessary files
  • Add a build script: build_freetype.bat

Details

FreeType is configured and built following this video. The old 4coder build only included the font driver for TTF fonts (truetype.c). I’ve added an additional driver for OTF fonts (cff.c). After that, you need to include a renderer to rasterize the glyphs. For this, I use the smooth.c renderer.

  • src/truetype/truetype.c needs sfnt.c and psnames.c
  • src/cff/cff.c needs sfnt.c, psaux.c, and psnames.c. INSTALL.ANY says pshinter.c is required and doesn't mention psaux.c. This is incorrect. The latter is mandatory, while the former is only needed for hinting. I include both.
  • All the source folders (src/cff/, src/psaux/, src/truetype/, etc.) are copied as-is, except that I removed all mk files. The only exception is src/base/, where I deleted several unnecessary files.

You need to put all these source folders inside non-source/foreign/freetype2/src/. Next to the src directory, add the freetype folder copied from freetype-x.x.x/include/freetype. This folder contains all the header files required to use the library.

The ft2build.h, long_ftmodule.h, and long_ftoption.h files are configured the same way as shown in the previous video. The main difference from the old 4coder setup is that I disable file stream support that relies on the CRT by defining FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT. As a result, FT_New_Face cannot be used—you must use FT_Open_Face instead. If you don’t want this behavior, simply comment out the #define.

- Update to the latest version (`2.13.3`)
- Add a build script (`build_freetype.bat`)
- Add support for OTF files
- Only build and include necessary files
The build script now detects the platform (`x64` vs `x86`) of `cl` and builds into the appropriate folder. This only works when `cl` is set up via `setup_cl_xxx.bat`. If `cl` is added directly to `PATH`, the detection will likely fail because it relies on the `%Platform%` variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant