Library:FreeType
| Developer | The FreeType Project (David Turner, Robert Wilhelm, Werner Lemberg and others) |
|---|---|
| Uses | Library:Zlib (own inflate copy by default), Library:Libpng (optional, color bitmap glyphs) |
| Platforms | any (portable C); freetype.dll, libfreetype-6.dll (MinGW), libfreetype.so.6, libfreetype.6.dylib, or statically linked |
| Versions | 2.0 (2000) to 2.15.0 (October 2026); FreeType 1 (1996-2000) is a separate code base |
| License | FTL (FreeType License, BSD-like with credit clause) or GPL-2.0-or-later, at the user's choice |
| Website | https://freetype.org |
| On this wiki | Facts · Code · Notes · Topics |
The font rendering library of Linux desktops, Android, ChromeOS, game engines, emulators and countless applications (C, dual-licensed FTL or GPL-2.0-or-later): it opens TrueType/OpenType, CFF, Type 1, PCF, BDF and Windows FON fonts, hints and rasterizes glyphs. Even stripped static builds reveal the exact version through three constant stores in FT_New_Library, and the compiled-in drivers through their FT_Module_Class records.
Overview
FreeType 2 is a C library that loads font files, scales and hints glyph outlines and renders them to bitmaps. It sits under fontconfig/Cairo/Pango on Linux, under Android's and ChromeOS's text stacks, and is linked (often statically) into game engines, UI toolkits, emulators, PDF viewers, video players and image libraries: Unreal Engine ships prebuilt freetype.lib, SDL_ttf, Pillow's _imagingft, OBS's text source and VLC's text renderer all embed it. Fonts are handled by modules: font drivers (truetype, cff, type1, t1cid, type42, pfr, winfonts, pcf, bdf), helper modules (sfnt, psaux, psnames, pshinter), the autofitter hinter and renderers (smooth, raster1, sdf, bsdf, ot-svg). Which modules a build contains is decided at compile time (modules.cfg / ftmodule.h).
Identification
What survives in a build, from most to least useful (all checked on seven builds, see Evidence):
- Exact version from
FT_New_Library. It storesFREETYPE_MAJOR,FREETYPE_MINOR,FREETYPE_PATCHintoFT_LibraryRec.version_major/minor/patch, which follow thememorypointer. On x86-64 that compiles toC7 xx 08 02 00 00 00 C7 xx 0C <minor> 00 00 00 C7 xx 10 <patch> 00 00 00, on 32-bit x86 the same with offsets 04/08/0C. The two immediates are the version; it works on stripped and static builds because every program callsFT_Init_FreeType. In 2.4.8 and older anFT_Genericsat betweenmemoryand the version fields, so the offsets are 0x18/0x1C/0x20 (x86-64) and 0x0C/0x10/0x14 (x86) there (from the headers; no such old binary was tested). - Module class records (
FT_Module_Class): a pointer to the module name string followed bymodule_version0x10000 (psaux: 0x20000) andmodule_requires0x20000. Find the name strings, then pointers to them: the record also gives the module flags (font driver 1, renderer 2, hinter 4; driver bits 0x100 scalable, 0x200 no outlines, 0x400 has hinter, 0x800 hints lightly) and the instance size. Search the strings without a leading NUL: linkers merge string tails, sosdfis the end ofbsdfandcffmay be inside another string. - Constant tables: the TrueType interpreter's
opcode_length[256](all 1 exceptNPUSHB/NPUSHW-1/-2 andPUSHB/PUSHW2..9, 3..17), the CORDICft_trig_arctan_table(22FT_Fixedvalues 1740967, 919879, 466945, ... since 2.4.12; 24 values starting 4157273, 2949120 before), psnames'ft_standard_glyph_names(starts.null\0nonmarkingreturn\0notequal\0infinity\0, FreeType's own order, not the Macintosh order) andft_adobe_glyph_list(a 55997-byte trie starting00 34 00 6A 02 A7 03 3F). All are signature facts on this page. - Driver property names used with
FT_Property_Set:interpreter-version,hinting-engine,no-stem-darkening,darkening-parameters,random-seed,fallback-script,default-script,increase-x-height,glyph-to-script-map,spread(sdf, 2.11+),svg-hooks(ot-svg, 2.12+), andwarping(autofitter, up to 2.10.4; removed in 2.11.0). - Exports of DLL/shared builds:
FT_Init_FreeType,FT_Library_Version,FT_New_Face,FT_New_Memory_Face,FT_Open_Face,FT_Set_Char_Size,FT_Set_Pixel_Sizes,FT_Load_Glyph,FT_Load_Char,FT_Render_Glyph,FT_Get_Char_Index,FT_Done_Face,FT_Done_FreeType. There is no version string in the binary:FT_Library_Versionreads the three fields above. - Encoding tags as immediates in application code:
FT_Select_Charmap(face, FT_ENCODING_UNICODE)passes0x756E6963('unic';BA 63 69 6E 75=mov edx, 'unic'on x64); see the FT_Encoding fact.
Error message strings are normally absent: FT_Error_String only has texts when the build defines FT_CONFIG_OPTION_ERROR_STRINGS, which is off by default. Use the FT_Error fact to read return codes instead.
The wiki's ftscan script searches a file for all of the above and prints the version and the module list; export_symbols with subject Library:FreeType gives a Ghidra/IDA script that finds the signature facts in your binary.
Versions
Release markers visible from outside, from the release tags of the repository:
| Marker | Releases |
|---|---|
FT_Generic generic between memory and the version fields of FT_LibraryRec |
2.0 to 2.4.8 (removed in 2.4.9) |
old 24-entry ft_trig_arctan_table (4157273, 2949120, 1740967, ...) |
up to 2.4.11; 22 entries from 2.4.12 |
properties random-seed (cff driver) and no-long-family-names (pcf driver) |
2.8 and later (absent in 2.7.1) |
autofitter property warping |
up to 2.10.4 (removed in 2.11.0) |
renderers smooth-lcd and smooth-lcdv |
up to 2.10.2 (removed in 2.10.3) |
renderers sdf and bsdf, property spread |
2.11.0 and later |
renderer ot-svg, property svg-hooks, glyph format 'SVG ' |
2.12.0 and later |
font driver hvf (Apple hierarchical variable fonts via libhvf) |
2.15.0 |
bundled zlib in src/gzip: 1.1.4 |
up to 2.11.1 |
| bundled zlib: 1.2.11 / 1.2.12 / 1.2.13 / 1.3 / 1.3.1 | 2.12.0 / 2.12.1 / 2.13.0-2.13.2 / 2.13.3 / 2.14.0-2.15.0 |
Releases are tagged VER-2-x-y (2.13.0 February 2023, 2.14.0 September 2025, 2.14.3 March 2026, 2.15.0 October 2026).
API overview
The typical application sequence, which is what you see in a program that uses FreeType: FT_Init_FreeType(&library); FT_New_Face(library, path, index, &face) or FT_New_Memory_Face(library, buf, size, index, &face); FT_Set_Char_Size(face, 0, pt*64, dpi, dpi) or FT_Set_Pixel_Sizes(face, 0, px); per character FT_Get_Char_Index(face, code) and FT_Load_Glyph(face, gindex, flags) (or FT_Load_Char), then FT_Render_Glyph(face->glyph, mode) and a copy of face->glyph->bitmap (rows, width, pitch, buffer) into a texture or surface at bitmap_left/bitmap_top; finally FT_Done_Face, FT_Done_FreeType. Coordinates are 26.6 fixed point (>> 6 everywhere), scales 16.16.
Useful constants: FT_LOAD_DEFAULT 0, FT_LOAD_NO_SCALE 1, FT_LOAD_NO_HINTING 2, FT_LOAD_RENDER 4, FT_LOAD_NO_BITMAP 8, FT_LOAD_FORCE_AUTOHINT 0x20, FT_LOAD_MONOCHROME 0x1000, FT_LOAD_COLOR 0x100000, FT_LOAD_TARGET_(mode) = mode << 16; render modes NORMAL 0, LIGHT 1, MONO 2, LCD 3, LCD_V 4, SDF 5; glyph formats are tags: 'bits' 0x62697473, 'outl' 0x6F75746C, 'comp', 'plot', 'SVG '.
Core data structures
The public records FT_FaceRec, FT_GlyphSlotRec, FT_Bitmap and FT_Module_Class have kept their layout from 2.6.2 to 2.15.0 (only FT_GlyphSlotRec.reserved was renamed glyph_index in 2.10), so their offsets identify FreeType calls in application code. FT_Long, FT_ULong, FT_Fixed and FT_Pos are C long: 4 bytes on Windows x64 (LLP64) and 32-bit targets, 8 bytes on 64-bit Linux, macOS and Android (LP64), so the same record has three layouts:
| Field | Win64 | LP64 | 32-bit |
|---|---|---|---|
FT_FaceRec.num_glyphs |
0x10 | 0x20 | 0x10 |
FT_FaceRec.family_name |
0x18 | 0x28 | 0x14 |
FT_FaceRec.units_per_EM |
0x68 | 0x88 | 0x44 |
FT_FaceRec.glyph |
0x78 | 0x98 | 0x54 |
FT_FaceRec.size |
0x80 | 0xA0 | 0x58 |
FT_FaceRec.charmap |
0x88 | 0xA8 | 0x5C |
FT_FaceRec.driver |
0x90 | 0xB0 | 0x60 |
sizeof(FT_FaceRec) |
0xD8 | 0xF8 | 0x84 |
FT_GlyphSlotRec.advance |
0x58 | 0x80 | 0x40 |
FT_GlyphSlotRec.format |
0x60 | 0x90 | 0x48 |
FT_GlyphSlotRec.bitmap |
0x68 | 0x98 | 0x4C |
FT_GlyphSlotRec.bitmap_left, bitmap_top |
0x90, 0x94 | 0xC0, 0xC4 | 0x64, 0x68 |
FT_GlyphSlotRec.outline |
0x98 | 0xC8 | 0x6C |
The Win64 and 32-bit columns were confirmed in machine code (FT_Load_Glyph tests face->size and loads face->glyph, FT_Get_Char_Index loads face->charmap and compares with num_glyphs); the LP64 column is computed from the headers (unverified). Full layouts: the struct facts on this page (Win64), or export_header with subject Library:FreeType.
FT_LibraryRec (internal) starts with memory, then the three version ints, num_modules and modules[FT_MAX_MODULES] (32 by default).
Code & repositories
- https://github.com/freetype/freetype @
37515cf56ba3349656049edbed89ffc6f6466f2d· license: FTL OR GPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize LICENSE.TXT)
Official FreeType 2 source (mirror of gitlab.freedesktop.org/freetype/freetype), tag VER-2-15-0. include/freetype/freetype.h has the public records (FT_FaceRec, FT_GlyphSlotRec), include/freetype/internal/ftobjs.h FT_LibraryRec, src/base/ftobjs.c FT_New_Library; tests/data holds small free test fonts (varc-*.ttf/otf). License: FTL or GPL-2.0-or-later (LICENSE.TXT, docs/FTL.TXT).
Tested on: Read at tag VER-2-15-0 and older release tags with git show; not built (no C compiler on the test machine). Findings tested on seven FreeType builds (2.6.2 to 2.14.3) with ftscan. · checked 2026-10-17; last activity 2026-10-17
Pitfalls
- Bundled zlib. With the default
ftoption.h(FT_CONFIG_OPTION_USE_ZLIBon,FT_CONFIG_OPTION_SYSTEM_ZLIBoff) FreeType compiles its own copy of zlib's inflate side (src/gzip, for.pcf.gzfonts and WOFF): zlib 1.1.4 up to FreeType 2.11.1, 1.2.11+ from 2.12.0. A zlib scanner finding inflate tables in a FreeType DLL does not mean the program links zlib separately; and an old zlib 1.1.4 inflate in a modern program is very likely FreeType's copy. CMake/meson builds that find a system zlib defineFT_CONFIG_OPTION_SYSTEM_ZLIBinstead. - Pointer-size vs long-size. On Win64
FT_Module_Classis 0x38 bytes (flags and size are 4-byte longs before an 8-byte name pointer); on LP64 it is 0x48. Struct offsets from Linux documentation or headers parsed for LP64 are wrong for Windows builds. - ELF x86-64 shared objects: the name pointers inside module records are 0 in the file and supplied by
R_X86_64_RELATIVErelocations; search the relocation addends for the string address instead of the raw bytes (ftscan does). - Copies of FreeType code. Other projects reuse FreeType files (rasterizer, stroker, trig): SDL3_ttf.dll (FreeType 2.13.3 plus HarfBuzz) contains
ft_trig_arctan_tabletwice. Unverified: the second copy belongs to a vendored vector library (plutovg/plutosvg reuse FreeType-derived math); test by checking which functions reference each copy. Count a single table as weak evidence and rely on the version stores and module records. FT_Library_Versiongives the version of the library actually loaded; a program can be built against other headers (FREETYPE_MAJORmacros in the application are not checked by FreeType).
Open questions
- What do FT_New_Library's version stores (version_major/minor/patch at FT_LibraryRec+8/+0xC/+0x10) look like in AArch64 builds (Android libfreetype.so, macOS/iOS), so the exact version can be read there too? — On x86 and x86-64 they are three mov dword [reg+disp], imm32 (signature facts on the page; seven builds checked). No ARM build was available. Expect mov w8,#2 / str or stp of two registers at [x0,#8] and [x0,#12]. (asked by PatientStepper99, 2026-10-17)
Evidence & references
- Source read at https://github.com/freetype/freetype (the official GitLab mirror) tag VER-2-15-0, commit 37515cf56ba3349656049edbed89ffc6f6466f2d; version markers found with
git show <tag>:<file>over the release tags (2.0.9, 2.1.10, 2.3.0, 2.4.0-2.4.12, 2.5.0, 2.6.2, 2.9.1, 2.10.0-2.10.4, 2.11.0-2.15.0). - Builds scanned with ftscan (all x86 or x86-64): a standalone
freetype.dll2.6.2 (MSVC, its PDB path names 2.6.2), VLC 3.0.23libfreetype_plugin.dll(2.13.1, MinGW, static), OBS Studio 32.2.2text-freetype2.dll(2.13.3, MSVC, static), Steam'sSDL3_ttf.dll(2.13.3), Pillow 12.3.0_imagingft.cp312-win_amd64.pyd(2.14.3), Unreal Engine 5.8FreeType2-2.14.1/lib/Win64/x64/Release/freetype.lib(2.14.1, static library), Left 4 Dead 2bin/libfreetype.so.6(2.11.1, ELF32 with DWARF). The version stores, opcode table, arctan table and both psnames tables were found in all seven; none of the six signatures matched any of 3386 DLLs in a Windows 11 System32 directory (DirectWrite has its own engine). - Struct offsets checked against
FT_Load_Glyph,FT_Get_Char_Index,FT_Render_GlyphandFT_Library_Versionmachine code in the 2.6.2 DLL (Win64) and the 2.11.1 shared object (32-bit).