From a10b062df0c8958d69377aa04ea6554a9961a111 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 2 Nov 2018 11:15:21 -0700 Subject: [PATCH] Remove support for uncommon/outdated font formats 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 --- BUILD.gn | 21 ++------------------- include/freetype-fuchsia-config/ftmodule.h | 21 +++++++++++++-------- include/freetype-fuchsia-config/ftoption.h | 4 ++-- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index af6c1e5726117..f09e82adb966f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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", @@ -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 = [ @@ -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", diff --git a/include/freetype-fuchsia-config/ftmodule.h b/include/freetype-fuchsia-config/ftmodule.h index 696277197573d..6ff8b05360376 100644 --- a/include/freetype-fuchsia-config/ftmodule.h +++ b/include/freetype-fuchsia-config/ftmodule.h @@ -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 ) diff --git a/include/freetype-fuchsia-config/ftoption.h b/include/freetype-fuchsia-config/ftoption.h index 312eafbda22ae..b3b60e022bdcd 100644 --- a/include/freetype-fuchsia-config/ftoption.h +++ b/include/freetype-fuchsia-config/ftoption.h @@ -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 /*************************************************************************/ @@ -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 /*************************************************************************/