Add pdf_enable_fontations GN flag
Set up a pdf_enable_fontations GN flag for future use.
- Define PDF_ENABLE_FONTATIONS for use in C++ code when enabled.
- Add the override hook, so PDFium embedders that use GN can choose the
default via the override mechanism.
- Add GN assertion to make sure Rust and Skia are enabled.
Bug: pdfium:2107
Change-Id: I9ed504ebd5cbeaf922fe1da280cd20a08c260803
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/114834
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 0695615..2b1f97f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -42,6 +42,10 @@
if (pdf_use_skia) {
defines += [ "PDF_USE_SKIA" ]
+
+ if (pdf_enable_fontations) {
+ defines += [ "PDF_ENABLE_FONTATIONS" ]
+ }
}
if (pdf_use_partition_alloc) {
diff --git a/README.md b/README.md
index 10cef8b..9434470 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,9 @@
# Set true to enable experimental Skia backend.
pdf_use_skia = false
+# Set true to enable experimental Fontations backend.
+pdf_enable_fontations = false
+
pdf_enable_xfa = true # Set false to remove XFA support (implies JS support).
pdf_enable_v8 = true # Set false to remove Javascript support.
pdf_is_standalone = true # Set for a non-embedded build.
diff --git a/build_overrides/pdfium.gni b/build_overrides/pdfium.gni
index b7dc9e0..aae45b1 100644
--- a/build_overrides/pdfium.gni
+++ b/build_overrides/pdfium.gni
@@ -25,5 +25,11 @@
# Build PDFium to use Skia (experimental) for all PDFium graphics.
# If enabled, coexists in build with AGG graphics and the default
# renderer is selectable at runtime.
-# The default is to use AGG only when `pdf_use_skia_override` is false.
+# The default is to use AGG when `pdf_use_skia_override` is false.
pdf_use_skia_override = false
+
+# Build PDFium with experimental Fontations library support.
+# If enabled, coexists in build with FreeType library and the default font
+# library is selectable at runtime.
+# The default is to use FreeType when `pdf_enable_fontations_override` is false.
+pdf_enable_fontations_override = false
diff --git a/pdfium.gni b/pdfium.gni
index ae5c5a5..693fae7 100644
--- a/pdfium.gni
+++ b/pdfium.gni
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/rust.gni")
import("//build_overrides/pdfium.gni")
# This file contains PDFium-related build flags.
@@ -48,6 +49,12 @@
# renderer is selectable at runtime.
pdf_use_skia = pdf_use_skia_override
+ # Build PDFium with experimental Fontations library support.
+ # If enabled, coexists in build with FreeType library and the default font
+ # library is selectable at runtime.
+ # Note that Fontations requires Skia and Rust support.
+ pdf_enable_fontations = pdf_enable_fontations_override
+
# Build PDFium standalone. Now only controls whether the test binaries
# are built. Most logic is conditioned by build_with_chromium.
pdf_is_standalone = false
@@ -79,3 +86,7 @@
assert(!pdf_is_complete_lib || !is_component_build,
"pdf_is_complete_lib=true requires is_component_build=false")
+
+assert(
+ !pdf_enable_fontations || (enable_rust && pdf_use_skia),
+ "pdf_enable_fontations=true requires enable_rust=true and pdf_use_skia=true")