Skip to content

Commit

Permalink
Remove support for uncommon/outdated font formats
Browse files Browse the repository at this point in the history
This reduces Flutter's binary size by ~127 KB uncompressed or 80 KB compressed.

Going forward, we intent to only support the following formats:

* TrueType fonts (TTF) and TrueType collections (TTC)
* CFF fonts
* OpenType fonts (OTF, both TrueType and CFF variants) and OpenType collections (OTC)
* SFNT-based bitmap fonts, including color Emoji

Support for all other formats (including mac dfont) has been removed.

Change-Id: I5932cbfb9a450c97c911de55f505bd228e593a69
  • Loading branch information
goderbauer committed Nov 2, 2018
1 parent 312d4e9 commit a10b062
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 29 deletions.
21 changes: 2 additions & 19 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,7 @@ group("freetype") {
]
}

# Shared libs are disabled in host toolchain.
shared_lib = (current_toolchain != host_toolchain)

if (shared_lib) {
library_type = "shared_library"
} else {
library_type = "source_set"
}

target(library_type, "freetype2") {
target(default_library_type, "freetype2") {
sources = [
"src/autofit/autofit.c",
"src/base/ftbase.c",
Expand All @@ -77,20 +68,12 @@ target(library_type, "freetype2") {
"src/psaux/psaux.c",
"src/pshinter/pshinter.c",
"src/psnames/psnames.c",
"src/raster/raster.c",
"src/sfnt/sfnt.c",
"src/smooth/smooth.c",

# Font Drivers. Drivers need to be enabled in ftmodule.h explicitly.
"src/bdf/bdf.c", # Glyph Bitmap Distribution Format
"src/cff/cff.c", # OpenType, (.cff, .cef)
"src/cid/type1cid.c", # Postscript CID-keyed (.pfb, .pfa)
"src/pcf/pcf.c", # Portable Compiled Format
"src/pfr/pfr.c", # Portable Font Resource
"src/truetype/truetype.c", # TrueType
"src/type1/type1.c", # Postscript Type 1 (.pfb, .pfa)
"src/type42/type42.c", # Postscript Type 42
"src/winfonts/winfnt.c", # Windows Bitmap Fonts, (.fon, .fnt)
]

defines = [
Expand All @@ -103,7 +86,7 @@ target(library_type, "freetype2") {
"FT_EXPORT(x)=x",
]

if (shared_lib) {
if (default_library_type == "shared_library") {
defines += [
"FT_EXPORT(x)=extern __attribute__(( visibility( \"default\" ) )) x",
"FT_EXPORT_DEF(x)=extern __attribute__(( visibility( \"default\" ) )) x",
Expand Down
21 changes: 13 additions & 8 deletions include/freetype-fuchsia-config/ftmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@

FT_USE_MODULE( FT_Module_Class, autofit_module_class )
FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
FT_USE_MODULE( FT_Module_Class, psaux_module_class )
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )


// Outdated or bitmap-based font format unsupported by Flutter.
// FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
// FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )

// Flutter doesn't render non-anti-aliased text.
// FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
4 changes: 2 additions & 2 deletions include/freetype-fuchsia-config/ftoption.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ FT_BEGIN_HEADER
/* able to synthesize a Unicode charmap out of the glyphs found in the */
/* fonts. */
/* */
#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
// #define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST


/*************************************************************************/
Expand All @@ -336,7 +336,7 @@ FT_BEGIN_HEADER
/* */
/* Note that the `FOND' resource isn't checked. */
/* */
#define FT_CONFIG_OPTION_MAC_FONTS
// #define FT_CONFIG_OPTION_MAC_FONTS


/*************************************************************************/
Expand Down

0 comments on commit a10b062

Please sign in to comment.