1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
|
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: 2021-11-22
--- a/spec/prawn/text/formatted/line_wrap_spec.rb
+++ b/spec/prawn/text/formatted/line_wrap_spec.rb
@@ -104,7 +104,7 @@ describe Prawn::Text::Formatted::LineWra
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(
@@ -116,7 +116,7 @@ describe Prawn::Text::Formatted::LineWra
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(
@@ -128,7 +128,7 @@ describe Prawn::Text::Formatted::LineWra
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 @@ describe Prawn::Text::Formatted::LineWra
)
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"
@@ -263,7 +263,7 @@ describe Prawn::Text::Formatted::LineWra
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 ")
@@ -299,7 +299,7 @@ describe Prawn::Text::Formatted::LineWra
)
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
@@ -343,7 +343,7 @@ describe Prawn::Text::Formatted::LineWra
)
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}-"
@@ -384,7 +384,7 @@ describe Prawn::Text::Formatted::LineWra
array = [{ text: 'Test' }]
arranger.format_array = array
- pdf.font(Pathname.new("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"))
+ pdf.font(Pathname.new("/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
@@ -260,7 +260,7 @@ describe Prawn::Text do
end
it 'does not raise an exception when providing Pathname instance as font' do
- expect { pdf.font(Pathname.new("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf")) }
+ expect { pdf.font(Pathname.new("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf")) }
.to_not raise_error
end
@@ -275,7 +275,7 @@ describe Prawn::Text do
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
@@ -285,7 +285,7 @@ describe Prawn::Text do
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)
@@ -323,7 +323,7 @@ describe Prawn::Text do
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
expect { pdf.text(sjis_str) }.to_not raise_error
@@ -598,7 +598,7 @@ describe Prawn::Text do
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
@@ -42,7 +42,7 @@ describe Prawn::Text do
# 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
@@ -311,7 +311,7 @@ describe Prawn::Document do
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 @@ describe Prawn::Font do
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'))
end
@@ -80,8 +80,8 @@ describe Prawn::Font do
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
@@ -197,7 +197,7 @@ describe Prawn::Font do
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,
}
@@ -212,7 +212,7 @@ describe Prawn::Font do
end
it 'accepts IO objects for font files' do
- File.open("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf") do |io|
+ File.open("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf") do |io|
pdf.font_families['DejaVu Sans'] = {
normal: described_class.load(pdf, io),
}
@@ -361,21 +361,21 @@ describe Prawn::Font do
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 be 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 be 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 be 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 font.compute_width_of('e', size: 12)
@@ -452,7 +452,7 @@ describe Prawn::Font do
end
describe 'full font embedding' do
- let(:font) { pdf.find_font("#{Prawn::DATADIR}/fonts/DejaVuSans.ttf", subset: false) }
+ let(:font) { pdf.find_font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", subset: false) }
let(:ref) { pdf.ref!({}).tap { |ref| font.__send__(:embed, ref, nil) } }
it 'is a composite font' do
@@ -612,7 +612,7 @@ describe Prawn::Font do
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
@@ -625,13 +625,13 @@ describe Prawn::Font do
it 'properly caches fonts' 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",
},
'Dustismo' => {
# This has to be the same font file as in the other family.
- normal: "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf",
- bold: "#{Prawn::DATADIR}/fonts/Dustismo_Roman.ttf",
+ normal: "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
+ bold: "/usr/share/fonts/truetype/dustin/Dustismo_Roman.ttf",
},
)
@@ -668,8 +668,8 @@ describe Prawn::Font do
Prawn::Document.new do
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",
},
)
--- a/spec/prawn/text/box_spec.rb
+++ b/spec/prawn/text/box_spec.rb
@@ -37,7 +37,7 @@ describe Prawn::Text::Box do
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)
@@ -866,7 +866,7 @@ describe Prawn::Text::Box do
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
@@ -22,7 +22,7 @@ describe Prawn::Text::Formatted::Box do
end
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 Prawn::Text::Formatted::Box do
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 Prawn::Text::Formatted::Box do
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' },
}
@@ -184,12 +184,12 @@ describe Prawn::Text::Formatted::Box do
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 },
}
@@ -216,9 +216,9 @@ describe Prawn::Text::Formatted::Box do
end
it 'considers style when looking for glyph in font' do
- dustismo_file = "#{Prawn::DATADIR}/fonts/Dustismo_Roman.ttf"
- dejavu_sans_file = "#{Prawn::DATADIR}/fonts/DejaVuSans.ttf"
- dejavu_sans_bold_file = "#{Prawn::DATADIR}/fonts/DejaVuSans-Bold.ttf"
+ dustismo_file = "/usr/share/fonts/truetype/dustin/Dustismo_Roman.ttf"
+ dejavu_sans_file = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
+ dejavu_sans_bold_file = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
pdf.font_families['Dustismo'] = {
normal: { file: dustismo_file },
@@ -246,12 +246,12 @@ describe Prawn::Text::Formatted::Box do
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
@@ -139,7 +139,7 @@ describe Prawn::Text do
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 { pdf.draw_text(sjis_str, at: [0, 0]) }.to_not raise_error
end
|