[Skia/SkiaPaths] Fix text rendering when font data is missing.
CFX_SkiaDeviceDriver relies on font data to build SkTextBlob for drawing
text. When the font data is missing, these blobs will have the bounds of
zero area and eventually be rejected by Skia for drawing.
This CL makes text rendering fall back on drawing glyph bitmaps when the
font data is missing.
Bug: pdfium:1354, pdfium:1743
Change-Id: Iaedaab137671399955bffc04dc29c23571c73b2f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/92930
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nigi <nigi@chromium.org>
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 3b3229a..97e50b5 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1723,6 +1723,13 @@
float font_size,
uint32_t color,
const CFX_TextRenderOptions& options) {
+ // `SkTextBlob` is built from `pFont`'s font data. If `pFont` doesn't contain
+ // any font data, each text blob will have zero area to be drawn and the
+ // drawing command will be rejected. In this case, we fall back to drawing
+ // characters by their glyph bitmaps.
+ if (pFont->GetFontSpan().empty())
+ return false;
+
// If a glyph's default width is larger than its width defined in the PDF,
// draw the glyph with path since it can be scaled to avoid overlapping with
// the adjacent glyphs (if there are any). Otherwise, use the device driver
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 54fce8d..d4b9ec8 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -366,19 +366,11 @@
# TODO(pdfium:1095): Remove after associated bug is fixed
bug_997412.in win * * *
-# TODO(pdfium:1354): Remove after associated bug is fixed
-bug_997412.in * * * skia,skiapaths
# TODO(pdfium:1107): Remove after associated bug is fixed
standard_symbols.pdf * * * *
# TODO(pdfium:1168): Remove after associated bug is fixed
xfa_bmp_image.in * * * *
# TODO(pdfium:1095): Remove after associated bug is fixed
xfa_example.in win * * *
-# TODO(pdfium:1354): Remove after associated bug is fixed
-xfa_example.in * * * skia,skiapaths
-# TODO(pdfium:1743): Remove after associated bug is fixed
-xfa_node_caption.pdf * * * skia,skiapaths
# TODO(pdfium:1095): Remove after associated bug is fixed
xfa_textfield.in win * * *
-# TODO(pdfium:1354): Remove after associated bug is fixed
-xfa_textfield.in * * * skia,skiapaths
diff --git a/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.0.png
new file mode 100644
index 0000000..08c11b0
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.1.png b/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.1.png
new file mode 100644
index 0000000..d4da28c
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/use_ahem/bug_997412_expected_skia.pdf.1.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected_skia.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected_skia.pdf.0.png
new file mode 100644
index 0000000..5a3eb9f
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skia.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skia.pdf.0.png
new file mode 100644
index 0000000..ad18d26
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skiapaths.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skiapaths.pdf.0.png
new file mode 100644
index 0000000..afa8871
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected_skiapaths.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.0.png
new file mode 100644
index 0000000..389f4a5
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.1.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.1.png
new file mode 100644
index 0000000..0a86fad
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia.pdf.1.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.0.png
new file mode 100644
index 0000000..154841c
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.1.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.1.png
new file mode 100644
index 0000000..4dc7a80
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skia_win.pdf.1.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.0.png
new file mode 100644
index 0000000..eb7bfbb
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.1.png b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.1.png
new file mode 100644
index 0000000..701c277
--- /dev/null
+++ b/testing/resources/pixel/xfa_specific/xfa_node_caption_expected_skiapaths.pdf.1.png
Binary files differ