Description: use system fonts when possible
 Upstream ships embedded copies of several truetype fonts. Some of them are
 available in Debian. These copies have been removed from the Debian source
 package, and system fonts are used instead.
 Skip a test expecting to not find € in gkai00mp.ttf
Author: Cédric Boutillier <boutil@debian.org>
Last-Update: 2019-01-07

--- a/spec/prawn/text/formatted/line_wrap_spec.rb
+++ b/spec/prawn/text/formatted/line_wrap_spec.rb
@@ -105,7 +105,7 @@
     end
 
     it 'breaks on zero-width space' do
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       array = [{ text: "hello#{Prawn::Text::ZWSP}world" }]
       arranger.format_array = array
       string = line_wrap.wrap_line(
@@ -117,7 +117,7 @@
     end
 
     it 'does not display zero-width space' do
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       array = [{ text: "hello#{Prawn::Text::ZWSP}world" }]
       arranger.format_array = array
       string = line_wrap.wrap_line(
@@ -129,7 +129,7 @@
     end
 
     it 'does not raise CannotFit if first fragment is a zero-width space' do
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       array = [{ text: Prawn::Text::ZWSP }, { text: 'stringofchars' }]
       arranger.format_array = array
       string = line_wrap.wrap_line(
@@ -218,7 +218,7 @@
       )
       expect(string).to eq("hello#{Prawn::Text::SHY}")
 
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       line_wrap = described_class.new
 
       string = "hello#{Prawn::Text::SHY}world"
@@ -264,7 +264,7 @@
 
     it 'does not display soft hyphens except at the end of a line ' \
       'for more than one element in format_array', issue: 347 do
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       line_wrap = described_class.new
 
       string1 = pdf.font.normalize_encoding("hello#{Prawn::Text::SHY}world ")
@@ -300,7 +300,7 @@
       )
       expect(string).to eq('hello')
 
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       line_wrap = described_class.new
       enough_width_for_hello_world = 68
 
@@ -345,7 +345,7 @@
       )
       expect(string).to eq("hello#{Prawn::Text::SHY}")
 
-      pdf.font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       line_wrap = described_class.new
 
       string = "hello#{Prawn::Text::SHY}-"
@@ -386,7 +386,7 @@
       array = [{ text: 'Ｔｅｓｔ' }]
       arranger.format_array = array
 
-      pdf.font Pathname.new("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       string = line_wrap.wrap_line(
         arranger: arranger,
         width: 300,
--- a/spec/prawn/text_spec.rb
+++ b/spec/prawn/text_spec.rb
@@ -269,7 +269,7 @@
     end
 
     it 'does not raise an exception when providing Pathname instance as font' do
-      pdf.font Pathname.new("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      pdf.font Pathname.new("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
     end
 
     it 'correctlies render a utf-8 string when using a built-in font' do
@@ -283,7 +283,7 @@
 
     it 'correctlies render a utf-8 string when using a TTF font' do
       str = '©' # copyright symbol
-      pdf.font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+      pdf.font "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.text str
 
       # grab the text from the rendered PDF and ensure it matches
@@ -294,7 +294,7 @@
     it 'subsets mixed low-ASCII and non-ASCII characters when they can '\
       'be subsetted together' do
       str = 'It’s super effective!'
-      pdf.font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+      pdf.font "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.text str
 
       text = PDF::Inspector::Text.analyze(pdf.render)
@@ -335,7 +335,7 @@
     it 'does not raise an exception when a shift-jis string is rendered' do
       datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
       sjis_str = File.open(datafile, 'r:shift_jis', &:gets)
-      pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
 
       # Expect that the call to text will not raise an encoding error
       pdf.text(sjis_str)
@@ -570,7 +570,7 @@
     end
 
     def add_unicode_fonts(pdf)
-      dejavu = "#{::Prawn::BASEDIR}/data/fonts/DejaVuSans.ttf"
+      dejavu = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.font_families.update(
         'dejavu' => {
           normal: dejavu,
--- a/spec/prawn/text_spacing_spec.rb
+++ b/spec/prawn/text_spacing_spec.rb
@@ -43,7 +43,7 @@
     # in a string, not the number of bytes, to insert character spaces
     #
     it 'calculates character spacing widths by characters, not bytes' do
-      pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
 
       str = 'こんにちは世界'
       raw_width = nil
--- a/spec/prawn/document_spec.rb
+++ b/spec/prawn/document_spec.rb
@@ -310,7 +310,7 @@
       doc_uncompressed = described_class.new
       doc_compressed = described_class.new(compress: true)
       [doc_compressed, doc_uncompressed].each do |pdf|
-        pdf.font "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+        pdf.font "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
         pdf.text '更可怕的是，同质化竞争对手可以按照URL中后面这个ID来遍历' * 10
       end
 
--- a/spec/prawn/font_spec.rb
+++ b/spec/prawn/font_spec.rb
@@ -47,7 +47,7 @@
 
     it 'excludes newlines' do
       # Use a TTF font that has a non-zero width for \n
-      pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
 
       expect(pdf.width_of("\nhello world\n")).to eq(
         pdf.width_of('hello world')
@@ -82,8 +82,8 @@
     it 'calculates styled widths correctly using TTFs' do
       pdf.font_families.update(
         'DejaVu Sans' => {
-          normal: "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf",
-          bold: "#{Prawn::DATADIR}/fonts/DejaVuSans-Bold.ttf"
+          normal: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
+          bold: "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
         }
       )
       styled_bold_hello = nil
@@ -169,8 +169,8 @@
       expect(name).to eq('subset+PanicSans-Italic')
     end
 
-    it 'allows font familes to be defined in a single ttc' do
-      file = "#{Prawn::DATADIR}/fonts/DejaVuSans.ttc"
+    xit 'allows font familes to be defined in a single ttc' do
+      file = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttc"
       pdf.font_families['DejaVu Sans'] = {
         normal: { file: file, font: 0 },
         bold: { file: file, font: 1 }
@@ -185,8 +185,8 @@
       expect(name).to eq('subset+DejaVuSans-Bold')
     end
 
-    it 'allows fonts to be indexed by name in a ttc file' do
-      file = "#{Prawn::DATADIR}/fonts/DejaVuSans.ttc"
+    xit 'allows fonts to be indexed by name in a ttc file' do
+      file = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttc"
       pdf.font_families['DejaVu Sans'] = {
         normal: { file: file, font: 'DejaVu Sans' },
         bold: { file: file, font: 'DejaVu Sans Bold' }
@@ -202,7 +202,7 @@
     end
 
     it 'accepts Pathname objects for font files' do
-      file = Pathname.new("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      file = Pathname.new("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       pdf.font_families['DejaVu Sans'] = {
         normal: file
       }
@@ -217,7 +217,7 @@
     end
 
     it 'accepts IO objects for font files' do
-      io = File.open "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+      io = File.open "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.font_families['DejaVu Sans'] = {
         normal: described_class.load(pdf, io)
       }
@@ -373,21 +373,21 @@
     end
 
     it 'returns true when present in a TTF font' do
-      font = pdf.find_font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      font = pdf.find_font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       expect(font.glyph_present?('H')).to eq true
     end
 
     it 'returns false when absent in a TTF font' do
-      font = pdf.find_font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")
+      font = pdf.find_font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")
       expect(font.glyph_present?('再')).to eq false
 
-      font = pdf.find_font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      font = pdf.find_font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
       expect(font.glyph_present?('€')).to eq false
     end
   end
 
   describe 'TTF fonts' do
-    let(:font) { pdf.find_font "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf" }
+    let(:font) { pdf.find_font "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" }
 
     it 'calculates string width taking into account accented characters' do
       expect(font.compute_width_of('é', size: 12)).to eq(
@@ -530,7 +530,7 @@
 
   describe '#character_count(text)' do
     it 'works on TTF fonts' do
-      pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
       expect(pdf.font.character_count('こんにちは世界')).to eq(7)
       expect(pdf.font.character_count('Hello, world!')).to eq(13)
     end
--- a/spec/prawn/text/box_spec.rb
+++ b/spec/prawn/text/box_spec.rb
@@ -37,7 +37,7 @@
     pdf.text_direction(:rtl)
     pdf.text_direction = :rtl
     pdf.text_direction = :rtl
-    pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf", size: 16) do
+    pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf", size: 16) do
       pdf.text '写个小'
     end
     text = PDF::Inspector::Text.analyze(pdf.render)
@@ -860,7 +860,7 @@
         document: pdf,
         overflow: :truncate
       }
-      pdf.font "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      pdf.font "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
       text_box = described_class.new(text, options)
       text_box.render
       expect(text_box.text.delete("\n")).to eq(text)
--- a/spec/prawn/text/formatted/box_spec.rb
+++ b/spec/prawn/text/formatted/box_spec.rb
@@ -23,7 +23,7 @@
 
     it 'does not raise an Encoding::CompatibilityError when keeping a TTF and '\
       'an AFM font together' do
-      file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      file = "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
 
       pdf.font_families['Kai'] = {
         normal: { file: file, font: 'Kai' }
@@ -126,7 +126,7 @@
   describe 'Text::Formatted::Box with :fallback_fonts option that includes' \
     'a Chinese font and set of Chinese glyphs not in the current font' do
     it 'changes the font to the Chinese font for the Chinese glyphs' do
-      file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      file = "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
       pdf.font_families['Kai'] = {
         normal: { file: file, font: 'Kai' }
       }
@@ -155,7 +155,7 @@
   describe 'Text::Formatted::Box with :fallback_fonts option that includes' \
     'an AFM font and Win-Ansi glyph not in the current Chinese font' do
     it 'changes the font to the AFM font for the Win-Ansi glyph' do
-      file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      file = "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
       pdf.font_families['Kai'] = {
         normal: { file: file, font: 'Kai' }
       }
@@ -185,12 +185,12 @@
   describe 'Text::Formatted::Box with :fallback_fonts option and fragment ' \
     'level font' do
     it 'uses the fragment level font except for glyphs not in that font' do
-      file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      file = "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
       pdf.font_families['Kai'] = {
         normal: { file: file, font: 'Kai' }
       }
 
-      file = "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+      file = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.font_families['DejaVu Sans'] = {
         normal: { file: file }
       }
@@ -221,12 +221,12 @@
     let(:formatted_text) { [{ text: 'hello你好' }] }
 
     before do
-      file = "#{Prawn::DATADIR}/fonts/gkai00mp.ttf"
+      file = "/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf"
       pdf.font_families['Kai'] = {
         normal: { file: file, font: 'Kai' }
       }
 
-      file = "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
+      file = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
       pdf.font_families['DejaVu Sans'] = {
         normal: { file: file }
       }
--- a/spec/prawn/text_draw_text_spec.rb
+++ b/spec/prawn/text_draw_text_spec.rb
@@ -141,7 +141,7 @@
     it 'does not raise an exception when a shift-jis string is rendered' do
       datafile = "#{Prawn::DATADIR}/shift_jis_text.txt"
       sjis_str = File.open(datafile, 'r:shift_jis', &:gets)
-      pdf.font("#{Prawn::DATADIR}/fonts/gkai00mp.ttf")
+      pdf.font("/usr/share/fonts/truetype/arphic-gkai00mp/gkai00mp.ttf")
 
       pdf.draw_text(sjis_str, at: [0, 0])
     end
