summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/cfx_systemhandler.cpp3
-rw-r--r--testing/SUPPRESSIONS6
-rw-r--r--testing/resources/fonts/Ahem.ttfbin0 -> 21768 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/use_ahem/xfa_example.in (renamed from testing/resources/pixel/xfa_specific/xfa_example.in)3
-rw-r--r--testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected.pdf.0.png (renamed from testing/resources/pixel/xfa_specific/xfa_example_expected_mac.pdf.0.png)bin4806 -> 3700 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.evt (renamed from testing/resources/pixel/xfa_specific/xfa_textfield.evt)2
-rw-r--r--testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.in (renamed from testing/resources/pixel/xfa_specific/xfa_textfield.in)26
-rw-r--r--testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected.pdf.0.png (renamed from testing/resources/pixel/xfa_specific/xfa_textfield_expected_mac.pdf.0.png)bin4496 -> 3919 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/xfa_example_expected.pdf.0.pngbin5073 -> 0 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/xfa_example_expected_win.pdf.0.pngbin4806 -> 0 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/xfa_textfield_expected.pdf.0.pngbin4510 -> 0 bytes
-rw-r--r--testing/resources/pixel/xfa_specific/xfa_textfield_expected_win.pdf.0.pngbin4496 -> 0 bytes
-rwxr-xr-xtesting/tools/fixup_pdf_template.py8
-rw-r--r--testing/tools/test_runner.py12
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp3
15 files changed, 48 insertions, 15 deletions
diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp
index 62d7c735b0..99aff8c6f8 100644
--- a/fpdfsdk/cfx_systemhandler.cpp
+++ b/fpdfsdk/cfx_systemhandler.cpp
@@ -83,8 +83,7 @@ bool CFX_SystemHandler::FindNativeTrueTypeFont(ByteString sFontFaceName) {
if (!pFontMapper)
return false;
- if (pFontMapper->m_InstalledTTFonts.empty())
- pFontMapper->LoadInstalledFonts();
+ pFontMapper->LoadInstalledFonts();
for (const auto& font : pFontMapper->m_InstalledTTFonts) {
if (font.Compare(sFontFaceName.AsStringView()))
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index 7633e04a48..cb6b9bfbe3 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -330,6 +330,8 @@ dynamic_list_box_allow_multiple_selection.pdf * * *
dynamic_password_field_background_fill.pdf * * *
resolve_nodes.pdf * * *
standard_symbols.pdf * * *
-xfa_example.in * * *
+# TODO(rharrison): Remove after pdfium:1095 is fixed
+xfa_example.in win * *
xfa_node_caption.pdf * * *
-xfa_textfield.in * * *
+# TODO(rharrison): Remove after pdfium:1095 is fixed
+xfa_textfield.in win * *
diff --git a/testing/resources/fonts/Ahem.ttf b/testing/resources/fonts/Ahem.ttf
new file mode 100644
index 0000000000..4d4785a412
--- /dev/null
+++ b/testing/resources/fonts/Ahem.ttf
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_example.in b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example.in
index d8be96f305..0e9ac151d5 100644
--- a/testing/resources/pixel/xfa_specific/xfa_example.in
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example.in
@@ -1,6 +1,5 @@
{{header}}
-%% Original object ID: 24 0
{{object 1 0}}
<<
/AcroForm 2 0 R
@@ -15,7 +14,6 @@
>>
endobj
-%% Original object ID: 32 0
{{object 2 0}}
<<
/XFA [
@@ -51,6 +49,7 @@ stream
</pageSet>
<subform w="576pt" h="756pt" name="Page1">
<draw name="HelloWorld" y="0.5in" x="0.5in" w="5in" h="2in">
+ <font typeface="Ahem" size="20pt"/>
<value>
<text>Hello, world.</text>
</value>
diff --git a/testing/resources/pixel/xfa_specific/xfa_example_expected_mac.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected.pdf.0.png
index 9a682f7186..e1e62cce18 100644
--- a/testing/resources/pixel/xfa_specific/xfa_example_expected_mac.pdf.0.png
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_example_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_textfield.evt b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.evt
index 3d110568ec..1279468006 100644
--- a/testing/resources/pixel/xfa_specific/xfa_textfield.evt
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.evt
@@ -1,4 +1,3 @@
-mousemove,20,20
mousedown,left,20,20
charcode,72
charcode,101
@@ -6,3 +5,4 @@ charcode,108
charcode,108
charcode,111
charcode,33
+mousedown,left,20,60
diff --git a/testing/resources/pixel/xfa_specific/xfa_textfield.in b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.in
index bdd685009f..218dbcec96 100644
--- a/testing/resources/pixel/xfa_specific/xfa_textfield.in
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield.in
@@ -50,12 +50,30 @@ stream
</pageArea>
</pageSet>
<subform w="576pt" h="756pt" name="Page1">
- <field name="TextField1" y="0pt" x="0pt" w="425pt" h="20pt">
+ <field name="TextField1" y="0pt" x="0pt" w="200pt" h="32pt">
+ <font typeface="Ahem" size="20pt"/>
<ui>
- <textEdit>
- <font typeface="Helvetica" size="16pt"/>
- </textEdit>
+ <textEdit/>
</ui>
+ <para vAlign="middle"/>
+ </field>
+ <field name="Button1" y="42pt" x="0pt" w="100pt" h="32pt">
+ <ui>
+ <button highlight="inverted"/>
+ </ui>
+ <font typeface="Ahem" size="20pt"/>
+ <caption>
+ <value>
+ <text>Dummy</text>
+ </value>
+ <para vAlign="middle" hAlign="center"/>
+ </caption>
+ <border hand="right">
+ <edge stroke="raised"/>
+ <fill>
+ <color value="212,208,200"/>
+ </fill>
+ </border>
</field>
</subform>
</subform>
diff --git a/testing/resources/pixel/xfa_specific/xfa_textfield_expected_mac.pdf.0.png b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected.pdf.0.png
index c4d4ce5a22..4d9a934c11 100644
--- a/testing/resources/pixel/xfa_specific/xfa_textfield_expected_mac.pdf.0.png
+++ b/testing/resources/pixel/xfa_specific/use_ahem/xfa_textfield_expected.pdf.0.png
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_example_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_example_expected.pdf.0.png
deleted file mode 100644
index 81c317a1e7..0000000000
--- a/testing/resources/pixel/xfa_specific/xfa_example_expected.pdf.0.png
+++ /dev/null
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_example_expected_win.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_example_expected_win.pdf.0.png
deleted file mode 100644
index 9a682f7186..0000000000
--- a/testing/resources/pixel/xfa_specific/xfa_example_expected_win.pdf.0.png
+++ /dev/null
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_textfield_expected.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_textfield_expected.pdf.0.png
deleted file mode 100644
index e5ad5012cd..0000000000
--- a/testing/resources/pixel/xfa_specific/xfa_textfield_expected.pdf.0.png
+++ /dev/null
Binary files differ
diff --git a/testing/resources/pixel/xfa_specific/xfa_textfield_expected_win.pdf.0.png b/testing/resources/pixel/xfa_specific/xfa_textfield_expected_win.pdf.0.png
deleted file mode 100644
index c4d4ce5a22..0000000000
--- a/testing/resources/pixel/xfa_specific/xfa_textfield_expected_win.pdf.0.png
+++ /dev/null
Binary files differ
diff --git a/testing/tools/fixup_pdf_template.py b/testing/tools/fixup_pdf_template.py
index bee7a3d002..0f536785c1 100755
--- a/testing/tools/fixup_pdf_template.py
+++ b/testing/tools/fixup_pdf_template.py
@@ -30,11 +30,15 @@ import os
import re
import sys
+SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
+
+
class StreamLenState:
START = 1
FIND_STREAM = 2
FIND_ENDSTREAM = 3
+
class TemplateProcessor:
HEADER_TOKEN = '{{header}}'
HEADER_REPLACEMENT = '%PDF-1.7\n%\xa0\xf2\xa4\xf4'
@@ -45,7 +49,7 @@ class TemplateProcessor:
XREF_REPLACEMENT_N = '%010d %05d n \n'
XREF_REPLACEMENT_F = '0000000000 65535 f \n'
# XREF rows must be exactly 20 bytes - space required.
- assert(len(XREF_REPLACEMENT_F) == 20)
+ assert len(XREF_REPLACEMENT_F) == 20
TRAILER_TOKEN = '{{trailer}}'
TRAILER_REPLACEMENT = 'trailer <<\n /Root 1 0 R\n /Size %d\n>>'
@@ -230,7 +234,7 @@ class TemplateProcessor:
def preprocess_line(self, line):
if self.STREAMLEN_TOKEN in line:
- assert(self.streamlen_state == StreamLenState.START)
+ assert self.streamlen_state == StreamLenState.START
self.streamlen_state = StreamLenState.FIND_STREAM
self.streamlens.append(0)
return
diff --git a/testing/tools/test_runner.py b/testing/tools/test_runner.py
index 3fa1c79e04..3737969fb2 100644
--- a/testing/tools/test_runner.py
+++ b/testing/tools/test_runner.py
@@ -51,6 +51,8 @@ class TestRunner:
# tests and outputfiles is a list tuples:
# (path_to_image, md5_hash_of_pixelbuffer)
def GenerateAndTest(self, input_filename, source_dir):
+ use_ahem = 'use_ahem' in source_dir
+
input_root, _ = os.path.splitext(input_filename)
expected_txt_path = os.path.join(source_dir, input_root + '_expected.txt')
@@ -76,7 +78,7 @@ class TestRunner:
if os.path.exists(expected_txt_path):
raised_exception = self.TestText(input_root, expected_txt_path, pdf_path)
else:
- raised_exception, results = self.TestPixel(input_root, pdf_path)
+ raised_exception, results = self.TestPixel(input_root, pdf_path, use_ahem)
if raised_exception is not None:
print 'FAILURE: %s; %s' % (input_filename, raised_exception)
@@ -136,10 +138,15 @@ class TestRunner:
cmd = [sys.executable, self.text_diff_path, expected_txt_path, txt_path]
return common.RunCommand(cmd)
- def TestPixel(self, input_root, pdf_path):
+ def TestPixel(self, input_root, pdf_path, use_ahem):
cmd_to_run = [self.pdfium_test_path, '--send-events', '--png', '--md5']
+
if self.oneshot_renderer:
cmd_to_run.append('--render-oneshot')
+
+ if use_ahem:
+ cmd_to_run.append('--font-dir=%s' % self.font_dir)
+
cmd_to_run.append(pdf_path)
return common.RunCommandExtractHashedFiles(cmd_to_run)
@@ -219,6 +226,7 @@ class TestRunner:
finder = common.DirectoryFinder(self.options.build_dir)
self.fixup_path = finder.ScriptPath('fixup_pdf_template.py')
self.text_diff_path = finder.ScriptPath('text_diff.py')
+ self.font_dir = os.path.join(finder.TestingDir(), 'resources', 'fonts')
self.source_dir = finder.TestingDir()
if self.test_dir != 'corpus':
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 354db0be43..abd5aa716a 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -478,6 +478,8 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
if (!pFontMapper)
return false;
+ pFontMapper->LoadInstalledFonts();
+
SystemFontInfoIface* pSystemFontInfo = pFontMapper->GetSystemFontInfo();
if (!pSystemFontInfo)
return false;
@@ -493,6 +495,7 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
WideString::FromLocal(pFontMapper->GetFaceName(i).c_str());
RegisterFaces(pFontStream, &wsFaceName);
}
+
return !m_InstalledFonts.empty();
}