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
|
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: 'Test' }]
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
|