Skip to content

Commit

Permalink
Move FreeType to match Chromium
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlstrom-g committed Apr 17, 2024
3 parents 28a3998 + 84d4132 + b301c6c commit a5341c9
Show file tree
Hide file tree
Showing 746 changed files with 1,467 additions and 67 deletions.
4 changes: 2 additions & 2 deletions cobalt/renderer/rasterizer/skia/skia/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ skia_common("skia_library") {
":skia_library_no_asan",
"//base",
"//starboard/common",
"//third_party/freetype2",
"//third_party/freetype",
"//third_party/libpng",
"//third_party/skia/third_party/skcms",
"//third_party/zlib",
Expand Down Expand Up @@ -161,7 +161,7 @@ skia_common("skia") {
"//cobalt/renderer:renderer_headers_only",
"//starboard:starboard_headers_only",
"//starboard/common",
"//third_party/freetype2",
"//third_party/freetype",
"//third_party/libxml",
]

Expand Down
1 change: 1 addition & 0 deletions third_party/freetype/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
150 changes: 150 additions & 0 deletions third_party/freetype/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chromecast_build.gni")
import("//build/config/freetype/freetype.gni")

assert(!use_system_freetype, "Not used when using system freetype.")

config("freetype_component_config") {
include_dirs = [
"include",
"src/builds/starboard/include",
"src/include",
]

defines = [
"FT_CONFIG_OPTION_SYSTEM_ZLIB",
"FT_CONFIG_CONFIG_H=\"freetype/config/ftconfig.h\"",
"FT_CONFIG_MODULES_H=<config/ftmodule.h>",
"FT_CONFIG_OPTIONS_H=<config/ftoption.h>",
]

if (!is_android) {
# Selects type1cid.c and type1.c modules in
# freetype-custom-include/freetype/config/ftmodule.h.
defines += [ "PDFIUM_REQUIRED_MODULES" ]
} else {
# Using HarfBuzz assisted autohinting has a performance impact that we do
# not want to take on Android, see crbug.com/724095.
defines += [ "WITHOUT_HARFBUZZ" ]
}

if (!is_component_build) {
defines += [ "CHROMIUM_RESTRICT_VISIBILITY" ]
}
}

config("freetype_config") {
configs = [ ":freetype_component_config" ]

if (is_win && is_component_build) {
# Used for managing declspec(dllimport/export) visibility.
defines = [ "FT2_BUILD_DLL" ]
}
}

config("freetype-warnings") {
cflags = []

if (is_clang) {
# The reduction of FreeType files to a minimum triggers -Wunused-function
# warnings in ftbase.c
cflags += [
# TODO(drott): Remove once we can roll past a commit that fixes:
# https://savannah.nongnu.org/bugs/index.php?54852
"-Wno-deprecated-declarations",

"-Wno-unused-function",
]
}
}

static_library("freetype") {
defines = []

# FreeType only exposes ft2build.h, all other FreeType headers are accessed by macro names.
# gn check does not expand macros, so list only this header.
public = [ "src/include/ft2build.h" ]

sources = [
"src/src/autofit/autofit.c",
"src/src/base/ftbase.c",
"src/src/base/ftbbox.c",
"src/src/base/ftbitmap.c",
"src/src/base/ftdebug.c",
"src/src/base/ftfstype.c",
"src/src/base/ftgasp.c",
"src/src/base/ftglyph.c",
"src/src/base/ftinit.c",
"src/src/base/ftmm.c",
"src/src/base/ftstroke.c",
"src/src/base/fttype1.c",
"src/src/cff/cff.c",
"src/src/gzip/ftgzip.c",
"src/src/psaux/psaux.c",
"src/src/pshinter/pshinter.c",
"src/src/psnames/psnames.c",
"src/src/raster/raster.c",
"src/src/sfnt/sfnt.c",
"src/src/smooth/smooth.c",
"src/src/truetype/truetype.c",
]

include_dirs = [ "//third_party/brotli/include" ]

# ftsystem.c provides implementations of FT_Memory and FT_Stream_Open.
# While Chromium itself avoids using this code, any build of Chromium which
# depends on //third_party/fontconfig:fontconfig with use_bundled_fontconfig
# will make heavy use of these implementations, so use the best available.
if (is_fuchsia) {
sources += [ "src/builds/unix/ftsystem.c" ]

# builds/unix/ftsystem.c directly includes <ftconfig.h> instead of using
# FT_CONFIG_CONFIG_H. The includes/freetype/config directory should not be
# on the include path to avoid accidentally using the ftoption or ftmodule
# from there.
include_dirs += [ "src/include/freetype/config" ]

# builds/unix/ftsystem.c requires the following defines to be set.
defines += [
"HAVE_UNISTD_H",
"HAVE_FCNTL_H",
]
} else {
sources += [ "src/src/base/ftsystem.c" ]
}

if (!is_android) {
sources += [
"src/src/base/ftcid.c",
"src/src/cid/type1cid.c",
"src/src/type1/type1.c",
]
}

if (is_linux || is_chromeos || is_cast_android) {
# Needed for content_shell on Linux and Chromecast, since fontconfig
# requires FT_Get_BDF_Property.
sources += [ "src/src/base/ftbdf.c" ]

# Needed on Fedora whose libfreetype builds ftsynth.c containing
# FT_GlyphSlot_Embolden, which we need to replace in content_shell if
# we are linking against our own FreeType.
sources += [ "src/src/base/ftsynth.c" ]
}

defines += [ "FT2_BUILD_LIBRARY" ]

configs += [ "//build/config/compiler:no_chromium_code" ]
configs += [ "//build/config/sanitizers:cfi_icall_generalize_pointers" ]
configs += [ ":freetype-warnings" ]

public_configs = [ ":freetype_config" ]

deps = [
"//third_party/libpng",
"//third_party/zlib",
]
}
3 changes: 3 additions & 0 deletions third_party/freetype/DIR_METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
monorail {
component: "Blink>Fonts"
}
15 changes: 15 additions & 0 deletions third_party/freetype/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
third_party {
identifier {
type: "ChromiumVersion"
value: "112.0.5615.134" # from https://chromereleases.googleblog.com/2023/04/stable-channel-update-for-chromeos_19.html
}
identifier {
type: "Git"
value: "https://chromium.googlesource.com/chromium/src.git"
version: "53b87ba394bbdcf2f9d63e985ca5385a5b420ca9"
}
identifier {
type: "UpstreamSubdir"
value: "third_party/freetype"
}
}
6 changes: 6 additions & 0 deletions third_party/freetype/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[email protected]
[email protected]

# To ease rolling.
per-file README.chromium=file://skia/OWNERS
per-file README.chromium=file://third_party/blink/renderer/platform/OWNERS
32 changes: 32 additions & 0 deletions third_party/freetype/README.chromium
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Name: FreeType
URL: http://www.freetype.org/
Version: VER-2-13-0-69
Revision: e78e2d29a95baf6053e30cc9422aa20319259803
CPEPrefix: cpe:/a:freetype:freetype:2.13.0
License: Custom license "inspired by the BSD, Artistic, and IJG (Independent
JPEG Group) licenses"
License File: src/docs/FTL.TXT
Security Critical: yes
License Android Compatible: yes

Description:
This package tracks upstream FreeType. It is shipped as part of Chrome on all
platforms. FreeType is needed on Windows and Mac for PDFium as well for enabling
font format support for OpenType Variations on older OS versions.

How to update:
1. Find the desired commit in
https://chromium.googlesource.com/chromium/src/third_party/freetype2/ .
If such a commit does not yet exist, branch from the appropriate point with
a branch name like "chromium/android/VER-X-X-X-updates" depending on the
FreeType tag being branched and commit changes there.
2. Update BUILD.gn to reflect any changes.
3. Merge the new src/include/freetype/config/ftoption.h into
include/freetype-custom-config/ftoption.h .
4. Merge the new src/include/freetype/config/ftconfig.h into
include/freetype-custom-config/ftconfig.h .
5. Update this file.
6. Commit build changes while rolling Chromium's freetype DEPS to the
new commit.

Most of the updating can be automated will roll-freetype.sh.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/***************************************************************************/
/* */
/* ftmodule.h */
/* */
/* User-selectable module macros. */
/* */
/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/

FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
FT_USE_MODULE( FT_Module_Class, autofit_module_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 )

#if defined(PDFIUM_REQUIRED_MODULES)
FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
#endif

/*
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 )
FT_USE_MODULE( FT_Renderer_Class, ft_sdf_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_bitmap_sdf_renderer_class )
FT_USE_MODULE( FT_Renderer_Class, ft_svg_renderer_class )
*/
Loading

0 comments on commit a5341c9

Please sign in to comment.