summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-14 14:38:28 -0600
committerGitHub <noreply@github.com>2022-05-14 14:38:28 -0600
commit3c27fbb4a74636325dee14c6d9e8c7146452e733 (patch)
tree7718efebf1419f6d5f6e1c4215a0a6fb092e081a /spec
parent77393d3459be6a91e118a0e16a37a1d6a414f9ca (diff)
resolves #2163 rename theme suffix with-fallback-font to with-font-fallbacks; add built-in default-sans theme (PR #2168)
Diffstat (limited to 'spec')
-rw-r--r--spec/converter_spec.rb13
-rw-r--r--spec/fixtures/glyph-font-test.adoc2
-rw-r--r--spec/font_spec.rb18
-rw-r--r--spec/image_spec.rb2
-rw-r--r--spec/list_spec.rb4
-rw-r--r--spec/table_spec.rb2
6 files changed, 28 insertions, 13 deletions
diff --git a/spec/converter_spec.rb b/spec/converter_spec.rb
index b2768a2a..d42bf8d1 100644
--- a/spec/converter_spec.rb
+++ b/spec/converter_spec.rb
@@ -264,6 +264,19 @@ describe Asciidoctor::PDF::Converter do
(expect pdf.find_text font_color: '000000').to have_size pdf.text.size
end
+ it 'should set font family to Noto Sans when default-sans themme is specified' do
+ pdf = to_pdf <<~EOS, analyze: true
+ = Document Title
+ :pdf-theme: default-sans
+
+ We don't like those _pesky_ serifs in these here parts.
+ EOS
+
+ text = pdf.text
+ sans_text = text.select {|it| it[:font_name].start_with? 'NotoSans' }
+ (expect sans_text).to have_size text.size
+ end
+
it 'should use theme passed in through :pdf_theme option' do
theme = Asciidoctor::PDF::ThemeLoader.load_theme 'custom', fixtures_dir
theme.base_font_size = 14
diff --git a/spec/fixtures/glyph-font-test.adoc b/spec/fixtures/glyph-font-test.adoc
index 4bea0359..54480a60 100644
--- a/spec/fixtures/glyph-font-test.adoc
+++ b/spec/fixtures/glyph-font-test.adoc
@@ -35,7 +35,7 @@ in&#x2060;divisible
almost&#x200a;touching
// no-break hyphen
fast&#x2011;approaching
-ifeval::["{pdf-theme}"=="default-with-fallback-font"]
+ifeval::["{pdf-theme}"=="default-with-font-fallbacks"]
// check mark
&#x2713; done
// upside down e
diff --git a/spec/font_spec.rb b/spec/font_spec.rb
index 33c2ab51..414b8af1 100644
--- a/spec/font_spec.rb
+++ b/spec/font_spec.rb
@@ -10,6 +10,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
(expect to_file).to visually_match 'font-i18n-default.pdf'
end
+ # intentionally use the deprecated alias for this test
it 'should apply fallback font when using default theme with fallback font', visual: true do
input_file = Pathname.new fixture_file 'i18n-font-test.adoc'
(expect do
@@ -26,24 +27,24 @@ describe 'Asciidoctor::PDF::Converter - Font' do
it 'should include expected glyphs in bundled default font with fallback font', visual: true do
input_file = Pathname.new fixture_file 'glyph-font-test.adoc'
- to_file = to_pdf_file input_file, 'font-glyph-default-with-fallback.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }
+ to_file = to_pdf_file input_file, 'font-glyph-default-with-fallback.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }
(expect to_file).to visually_match 'font-glyph-default-with-fallback.pdf'
end
it 'should include expected glyphs in fallback font', visual: true do
input_file = Pathname.new fixture_file 'glyph-font-test.adoc'
- to_file = to_pdf_file input_file, 'font-glyph-fallback-only.pdf', pdf_theme: { extends: 'default-with-fallback-font', base_font_family: 'M+ 1p Fallback' }, attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }
+ to_file = to_pdf_file input_file, 'font-glyph-fallback-only.pdf', pdf_theme: { extends: 'default-with-font-fallbacks', base_font_family: 'M+ 1p Fallback' }, attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }
(expect to_file).to visually_match 'font-glyph-fallback-only.pdf'
end
it 'should use notdef from original font of glyph not found in any fallback font', visual: true do
input = ?\u0278 * 10
- to_file = to_pdf_file input, 'font-notdef-glyph.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }
+ to_file = to_pdf_file input, 'font-notdef-glyph.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }
(expect to_file).to visually_match 'font-notdef-glyph.pdf'
end
it 'should use glyph from fallback font if not present in primary font', visual: true do
- to_file = to_pdf_file '*を*', 'font-fallback-font.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }
+ to_file = to_pdf_file '*を*', 'font-fallback-font.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }
(expect to_file).to visually_match 'font-fallback-font.pdf'
end
@@ -80,7 +81,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
end
it 'should render emoji when using default theme with fallback font', visual: true do
- to_file = to_pdf_file <<~'EOS', 'font-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }
+ to_file = to_pdf_file <<~'EOS', 'font-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }
Don't 😢 over spilled 🍺.
Asciidoctor is 👍.
@@ -90,7 +91,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
end
it 'should use sans base font when using sans theme with fallback font', visual: true do
- to_file = to_pdf_file <<~'EOS', 'font-sans-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'sans-with-fallback-font' }
+ to_file = to_pdf_file <<~'EOS', 'font-sans-emoji.pdf', attribute_overrides: { 'pdf-theme' => 'default-sans-with-font-fallbacks' }
== Lessons
Don't 😢 over spilled 🍺.
@@ -105,7 +106,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
(expect do
input_lines = [%(Bitcoin (\u20bf) is a cryptocurrency.), %(The currency is represented using the symbol \u20bf.)]
input = input_lines.join %(\n\n)
- pdf = to_pdf input, attribute_overrides: { 'pdf-theme' => 'default-with-fallback-font' }, analyze: true
+ pdf = to_pdf input, attribute_overrides: { 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: true
(expect pdf.lines).to eql input_lines
end).to log_message severity: :WARN, message: %(Could not locate the character `\u20bf' (\\u20bf) in the following fonts: Noto Serif, M+ 1p Fallback, Noto Emoji), using_log_level: :INFO
end
@@ -309,7 +310,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
it 'should break line on any CJK character if value of scripts attribute is cjk' do
pdf = to_pdf <<~'EOS', analyze: true
:scripts: cjk
- :pdf-theme: default-with-fallback-font
+ :pdf-theme: default-with-font-fallbacks
AsciiDoc 是一个人类可读的文件格式,语义上等同于 DocBook 的 XML,但使用纯文本标记了约定。可以使用任何文本编辑器创建文件把 AsciiDoc 和阅读“原样”,或呈现为HTML 或由 DocBook 的工具链支持的任何其他格式,如 PDF,TeX 的,Unix 的手册页,电子书,幻灯片演示等。
@@ -324,6 +325,7 @@ describe 'Asciidoctor::PDF::Converter - Font' do
(expect lines[4]).to start_with 'して'
end
+ # intentionally use the deprecated alias for this test
it 'should not break line immediately before an ideographic full stop' do
pdf = to_pdf <<~'EOS', analyze: true
:scripts: cjk
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index 36299557..c933e086 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -1544,7 +1544,7 @@ describe 'Asciidoctor::PDF::Converter - Image' do
end
it 'should only render inline image once if alt text is chunked to apply a fallback font' do
- pdf = to_pdf <<~'EOS', attribute_overrides: { 'imagesdir' => examples_dir, 'pdf-theme' => 'default-with-fallback-font' }, analyze: :image
+ pdf = to_pdf <<~'EOS', attribute_overrides: { 'imagesdir' => examples_dir, 'pdf-theme' => 'default-with-font-fallbacks' }, analyze: :image
How many wolpertingers do you see? +
image:wolpertinger.jpg[チのデータレプリケーションです。]
EOS
diff --git a/spec/list_spec.rb b/spec/list_spec.rb
index 91d4f865..3b4b9882 100644
--- a/spec/list_spec.rb
+++ b/spec/list_spec.rb
@@ -250,7 +250,7 @@ describe 'Asciidoctor::PDF::Converter - List' do
it 'should reserve enough space for marker that is not found in any font' do
pdf_theme = {
- extends: 'default-with-fallback-font',
+ extends: 'default-with-font-fallbacks',
ulist_marker_disc_content: ?\u2055,
}
pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, analyze: true
@@ -486,7 +486,7 @@ describe 'Asciidoctor::PDF::Converter - List' do
end
it 'should use glyph from fallback font if not present in main font', visual: true do
- pdf_theme = build_pdf_theme({ ulist_marker_checked_content: ?\u303c }, 'default-with-fallback-font')
+ pdf_theme = build_pdf_theme({ ulist_marker_checked_content: ?\u303c }, 'default-with-font-fallbacks')
to_file = to_pdf_file <<~'EOS', 'list-checked-glyph-fallback.pdf', pdf_theme: pdf_theme
* [x] done
diff --git a/spec/table_spec.rb b/spec/table_spec.rb
index ca89aa1d..b3e00aa2 100644
--- a/spec/table_spec.rb
+++ b/spec/table_spec.rb
@@ -2779,7 +2779,7 @@ describe 'Asciidoctor::PDF::Converter - Table' do
it 'should break line on any CJK character if value of scripts attribute is cjk' do
pdf = to_pdf <<~'EOS', analyze: true
:scripts: cjk
- :pdf-theme: default-with-fallback-font
+ :pdf-theme: default-with-font-fallbacks
|===
| AsciiDoc 是一个人类可读的文件格式,语义上等同于 DocBook 的 XML,但使用纯文本标记了约定。可以使用任何文本编辑器创建文件把 AsciiDoc 和阅读“原样”,或呈现为HTML 或由 DocBook 的工具链支持的任何其他格式,如 PDF,TeX 的,Unix 的手册页,电子书,幻灯片演示等。