Skip to content

Commit c6faa4d

Browse files
Merge pull request #37 from Setasign/development
Development
2 parents 08dfb4a + b3faa91 commit c6faa4d

File tree

9 files changed

+60
-21
lines changed

9 files changed

+60
-21
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ vendor/
33
local-tests/SetaFpdf/pdfs/
44
local-tests/SetaFpdi/pdfs/
55
.idea
6-
composer.phar
6+
composer.phar
7+
auth.json

assets/text/20k_c1.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public mind even far inland, it must be said that professional seamen were especially alarmed. Traders, shipowners, captains of vessels, skippers, and master mariners from Europe and America, naval officers from every country, and at their heels the various national governments on these two continents, were all extremely disturbed by the business.
22
In essence, over a period of time several ships had encountered "an enormous thing" at sea, a long spindle-shaped object, sometimes giving off a phosphorescent glow, infinitely bigger and faster than any whale.
3-
The relevant data on this apparition, as recorded in various logbooks, agreed pretty closely as to the structure of the object or creature in question, its unprecedented speed of movement, its startling locomotive power, and the unique vitality with which it seemed to be gifted. If it was a cetacean, it exceeded in bulk any whale previously classified by science. No naturalist, neither Cuvier nor Lacepede, neither Professor Dumeril nor Professor de Quatrefages, would have accepted the existence of such a monster sight unseen -- specifically, unseen by their own scientific eyes.
3+
The relevant data on this apparition, as recorded in various logbooks, agreed pretty closely as to the structure of the object or creature in question, its unprecedented speed of movement, its startling locomotive power, and the unique vitality with which it seemed to be gifted. If it was a cetacean, it exceeded in bulk any whale previously classified by science. No naturalist, neither Cuvier nor Lacepede, neither Professor Dumeril nor Professor de Quatrefages, would have accepted the existence of such a monster sight unseen -- specifically, unseen by their own scientific eyes.
44
Striking an average of observations taken at different times -- rejecting those timid estimates that gave the object a length of 200 feet, and ignoring those exaggerated views that saw it as a mile wide and three long--you could still assert that this phenomenal creature greatly exceeded the dimensions of anything then known to ichthyologists, if it existed at all.
55
Now then, it did exist, this was an undeniable fact; and since the human mind dotes on objects of wonder, you can understand the worldwide excitement caused by this unearthly apparition. As for relegating it to the realm of fiction, that charge had to be dropped.
6-
In essence, on July 20, 1866, the steamer Governor Higginson, from the Calcutta & Burnach Steam Navigation Co., encountered this moving mass five miles off the eastern shores of Australia. Captain Baker at first thought he was in the presence of an unknown reef; he was even about to fix its exact position when two waterspouts shot out of this inexplicable object and sprang hissing into the air some 150 feet. So, unless this reef was subject to the intermittent eruptions of a geyser, the Governor Higginson had fair and honest dealings with some aquatic mammal, until then unknown, that could spurt from its blowholes waterspouts mixed with air and steam.
7-
Similar events were likewise observed in Pacific seas, on July 23 of the same year, by the Christopher Columbus from the West India & Pacific Steam Navigation Co. Consequently, this extraordinary cetacean could transfer itself from one locality to another with startling swiftness, since within an interval of just three days, the Governor Higginson and the Christopher Columbus had observed it at two positions on the charts separated by a distance of more than 700 nautical leagues.
8-
Fifteen days later and 2,000 leagues farther, the Helvetia from the Compagnie Nationale and the Shannon from the Royal Mail line, running on opposite tacks in that part of the Atlantic lying between the United States and Europe, respectively signaled each other that the monster had been sighted in latitude 42 degrees 15' north and longitude 60 degrees 35' west of the meridian of Greenwich. From their simultaneous observations, they were able to estimate the mammal's minimum length at more than 350 English feet; this was because both the Shannon and the Helvetia were of smaller dimensions, although each measured 100 meters stem to stern. Now then, the biggest whales, those rorqual whales that frequent the waterways of the Aleutian Islands, have never exceeded a length of 56 meters--if they reach even that.
9-
One after another, reports arrived that would profoundly affect public opinion: new observations taken by the transatlantic liner Pereire, the Inman line's Etna running afoul of the monster, an official report drawn up by officers on the French frigate Normandy, dead-earnest reckonings obtained by the general staff of Commodore Fitz-James aboard the Lord Clyde. In lighthearted countries, people joked about this phenomenon, but such serious, practical countries as England, America, and Germany were deeply concerned.
10-
In every big city the monster was the latest rage; they sang about it in the coffee houses, they ridiculed it in the newspapers, they dramatized it in the theaters. The tabloids found it a fine opportunity for hatching all sorts of hoaxes. In those newspapers short of copy, you saw the reappearance of every gigantic imaginary creature, from "Moby Dick," that dreadful white whale from the High Arctic regions, to the stupendous kraken whose tentacles could entwine a 500-ton craft and drag it into the ocean depths. They even reprinted reports from ancient times: the views of Aristotle and Pliny accepting the existence of such monsters, then the Norwegian stories of Bishop Pontoppidan, the narratives of Paul Egede, and finally the reports of Captain Harrington -- whose good faith is above suspicion--in which he claims he saw, while aboard the Castilian in 1857, one of those enormous serpents that, until then, had frequented only the seas of France's old extremist newspaper, The Constitutionalist.
6+
In essence, on July 20, 1866, the steamer Governor Higginson, from the Calcutta & Burnach Steam Navigation Co., encountered this moving mass five miles off the eastern shores of Australia. Captain Baker at first thought he was in the presence of an unknown reef; he was even about to fix its exact position when two waterspouts shot out of this inexplicable object and sprang hissing into the air some 150 feet. So, unless this reef was subject to the intermittent eruptions of a geyser, the Governor Higginson had fair and honest dealings with some aquatic mammal, until then unknown, that could spurt from its blowholes waterspouts mixed with air and steam.
7+
Similar events were likewise observed in Pacific seas, on July 23 of the same year, by the Christopher Columbus from the West India & Pacific Steam Navigation Co. Consequently, this extraordinary cetacean could transfer itself from one locality to another with startling swiftness, since within an interval of just three days, the Governor Higginson and the Christopher Columbus had observed it at two positions on the charts separated by a distance of more than 700 nautical leagues.
8+
Fifteen days later and 2,000 leagues farther, the Helvetia from the Compagnie Nationale and the Shannon from the Royal Mail line, running on opposite tacks in that part of the Atlantic lying between the United States and Europe, respectively signaled each other that the monster had been sighted in latitude 42 degrees 15' north and longitude 60 degrees 35' west of the meridian of Greenwich. From their simultaneous observations, they were able to estimate the mammal's minimum length at more than 350 English feet; this was because both the Shannon and the Helvetia were of smaller dimensions, although each measured 100 meters stem to stern. Now then, the biggest whales, those rorqual whales that frequent the waterways of the Aleutian Islands, have never exceeded a length of 56 meters--if they reach even that.
9+
One after another, reports arrived that would profoundly affect public opinion: new observations taken by the transatlantic liner Pereire, the Inman line's Etna running afoul of the monster, an official report drawn up by officers on the French frigate Normandy, dead-earnest reckonings obtained by the general staff of Commodore Fitz-James aboard the Lord Clyde. In lighthearted countries, people joked about this phenomenon, but such serious, practical countries as England, America, and Germany were deeply concerned.
10+
In every big city the monster was the latest rage; they sang about it in the coffee houses, they ridiculed it in the newspapers, they dramatized it in the theaters. The tabloids found it a fine opportunity for hatching all sorts of hoaxes. In those newspapers short of copy, you saw the reappearance of every gigantic imaginary creature, from "Moby Dick," that dreadful white whale from the High Arctic regions, to the stupendous kraken whose tentacles could entwine a 500-ton craft and drag it into the ocean depths. They even reprinted reports from ancient times: the views of Aristotle and Pliny accepting the existence of such monsters, then the Norwegian stories of Bishop Pontoppidan, the narratives of Paul Egede, and finally the reports of Captain Harrington -- whose good faith is above suspicion--in which he claims he saw, while aboard the Castilian in 1857, one of those enormous serpents that, until then, had frequented only the seas of France's old extremist newspaper, The Constitutionalist.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
"require-dev": {
3737
"phpunit/phpunit": "~7.5",
38-
"setasign/fpdi": "^2.3",
38+
"setasign/fpdi": "dev-master",
3939
"setasign/fpdf": "^1.8"
4040
},
4141

composer.lock

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Modules/Font.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace setasign\SetaFpdf\Modules;
1111

1212
use setasign\SetaFpdf\Manager;
13+
use setasign\SetaPDF2\Core\Document\Page\Annotation\FreeTextAnnotation;
1314

1415
class Font
1516
{
@@ -43,7 +44,7 @@ class Font
4344
*
4445
* @var \SetaPDF_Core_Font[]
4546
*/
46-
protected $fonts;
47+
protected $fonts = [];
4748

4849

4950
/**
@@ -194,9 +195,9 @@ public function add($family, $style, $pathOrInstance)
194195
}
195196

196197
/**
197-
* Tries to draw a underline.
198+
* Tries to draw an underline.
198199
*
199-
* This function draws a underline when its enabled, otherwise it will do nothing.
200+
* This function draws an underline when its enabled, otherwise it will do nothing.
200201
*
201202
* @param int|float $x
202203
* @param int|float $y
@@ -226,4 +227,12 @@ public function doUnderline($x, $y, $width)
226227
$this->manager->getCanvas()->draw()->setStrokingColor($strokingColor);
227228
}
228229
}
230+
231+
/**
232+
* @return \SetaPDF_Core_Font[]
233+
*/
234+
public function getFonts()
235+
{
236+
return $this->fonts;
237+
}
229238
}

src/SetaFpdf.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use setasign\SetaFpdf\Modules\Document;
1313
use setasign\SetaFpdf\Position\Converter;
14+
use setasign\SetaPDF2\Core\Font\TrueType\Subset;
1415

1516
/**
1617
* @property-read int $page
@@ -459,6 +460,12 @@ public function Output($dest = '', $name = '')
459460
$name = 'doc.pdf';
460461
}
461462

463+
foreach ($this->manager->getFont()->getFonts() as $font) {
464+
if ($font instanceof Subset) {
465+
$font->createSubset();
466+
}
467+
}
468+
462469
return $this->manager->getDocument()->output($dest, $name, $this->displayMode);
463470
}
464471

tests/functional/SetaFpdf/OutputTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHPUnit\Framework\TestCase;
66
use setasign\SetaFpdf\Modules\Document;
77
use setasign\SetaFpdf\SetaFpdf;
8+
use setasign\SetaPDF2\Core\Document\ObjectStreamCompressor;
89

910
class OutputTest extends TestCase
1011
{
@@ -46,4 +47,22 @@ public function testFont()
4647
$pdf->SetFont('testen', 'b', 120);
4748
$this->assertInstanceOf(SetaFpdf::class, $pdf);
4849
}
50+
51+
public function testCompressedObjectStreams()
52+
{
53+
$pdf = new SetaFpdf();
54+
$pdf->AddPage();
55+
$pdf->AddFont('DejaVuSans', 'B', __DIR__ . '/../../../assets/fonts/DejaVu/DejaVuSans-Bold.ttf');
56+
$pdf->SetFont('DejaVuSans', 'B', 20);
57+
$pdf->Cell(0, 10, 'TESTING FONT SUBSETTING');
58+
59+
$document = $pdf->getManager()->getDocument()->get();
60+
$compressor = new ObjectStreamCompressor($document);
61+
$compressor->register();
62+
63+
$pdfString = $pdf->Output('S');
64+
65+
$this->assertStringNotContainsString('/Font', $pdfString);
66+
$this->assertStringNotContainsString('/Page ', $pdfString);
67+
}
4968
}

tests/visual/SetaFpdf/Tutorial/Three/TutorialTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function testTutorial()
2929
$pdf->PrintChapter(2,'THE PROS AND CONS',__DIR__ . '/20k_c2.txt');
3030
// $pdf->Output(); // REPLACED BY ASSERTION
3131

32-
$this->assertProxySame($pdf, 80);
32+
$this->assertProxySame($pdf, 108);
3333
}
3434
}

tests/visual/SetaFpdfTpl/One/SimpleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public function testSimple()
3838
$proxy->AddPage();
3939
$proxy->useTemplate($templateId, 20, 20, $proxy->GetPageWidth() - 40);
4040

41-
$this->assertProxySame($proxy, 1.6, self::DPI);
41+
$this->assertProxySame($proxy, 1.85, self::DPI);
4242
}
4343
}

0 commit comments

Comments
 (0)