summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-09-06 09:34:53 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-09-06 09:34:53 +0000
commitb7b8d6da07309da4e16397f662a4e2db46c0869a (patch)
treea76a982bef0844f6d3d0eeb7089a7e8a5dfb2ee0 /tests
parent4e50ab6291dc2430ef9ce4cc42c100c021e1a3b0 (diff)
downloadzetacomponents-graph-b7b8d6da07309da4e16397f662a4e2db46c0869a.zip
zetacomponents-graph-b7b8d6da07309da4e16397f662a4e2db46c0869a.tar.gz
- Enhanced font configuration
- Use Free Type 2 by default now, fallback to native ttf, if not available - Use t1lib for PostScript Type1 fonts - Throw an exception, if some texts could not be rendered with minimum font size
Diffstat (limited to 'tests')
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawFreeTypeTTFText.pngbin0 -> 2014 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawNativeTTFText.pngbin0 -> 2014 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawPSText.pngbin0 -> 775 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawSmallFreeTypeStringWithSpecialChars.pngbin0 -> 1928 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawSmallNativeTTFStringWithSpecialChars.pngbin0 -> 1928 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawSmallPsStringWithSpecialChars.pngbin0 -> 746 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawStringWithSpecialChars.pngbin7754 -> 0 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenter.pngbin4170 -> 4174 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.pngbin4169 -> 4173 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRight.pngbin4119 -> 4115 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.pngbin4119 -> 4113 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRight.pngbin1966 -> 1970 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRightBottom.pngbin1967 -> 1971 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testSupersamplingDrawTextBoxShortString.pngbin8412 -> 8404 bytes
-rw-r--r--tests/data/ps_font.pfbbin0 -> 19280 bytes
-rw-r--r--tests/driver_gd_test.php188
-rw-r--r--tests/font_test.php40
17 files changed, 226 insertions, 2 deletions
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawFreeTypeTTFText.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawFreeTypeTTFText.png
new file mode 100644
index 0000000..65b89f5
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawFreeTypeTTFText.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawNativeTTFText.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawNativeTTFText.png
new file mode 100644
index 0000000..65b89f5
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawNativeTTFText.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawPSText.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawPSText.png
new file mode 100644
index 0000000..85f9755
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawPSText.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallFreeTypeStringWithSpecialChars.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallFreeTypeStringWithSpecialChars.png
new file mode 100644
index 0000000..66a593a
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallFreeTypeStringWithSpecialChars.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallNativeTTFStringWithSpecialChars.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallNativeTTFStringWithSpecialChars.png
new file mode 100644
index 0000000..66a593a
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallNativeTTFStringWithSpecialChars.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallPsStringWithSpecialChars.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallPsStringWithSpecialChars.png
new file mode 100644
index 0000000..81fc503
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawSmallPsStringWithSpecialChars.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawStringWithSpecialChars.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawStringWithSpecialChars.png
deleted file mode 100644
index 41847bd..0000000
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawStringWithSpecialChars.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenter.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenter.png
index 597c6ca..a53a6f7 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenter.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenter.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.png
index 9946a1e..288594b 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringCenterBottom.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRight.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRight.png
index 96ba490..424d3cd 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRight.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRight.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.png
index 8bb1c2c..f823653 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxLongSpacedStringRightMiddle.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRight.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRight.png
index 392c830..86882e7 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRight.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRight.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRightBottom.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRightBottom.png
index a304be2..9c1590e 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRightBottom.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTextBoxStringRightBottom.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testSupersamplingDrawTextBoxShortString.png b/tests/data/compare/ezcGraphGdDriverTest_testSupersamplingDrawTextBoxShortString.png
index 89d772b..0ebd2ba 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testSupersamplingDrawTextBoxShortString.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testSupersamplingDrawTextBoxShortString.png
Binary files differ
diff --git a/tests/data/ps_font.pfb b/tests/data/ps_font.pfb
new file mode 100644
index 0000000..130fac0
--- /dev/null
+++ b/tests/data/ps_font.pfb
Binary files differ
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index 30c4f22..0be109c 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -1271,10 +1271,47 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
);
}
- public function testDrawStringWithSpecialChars()
+ public function testDrawSmallNativeTTFStringWithSpecialChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $this->driver->options->forceNativeTTF = true;
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 47, 54 ),
+ new ezcGraphCoordinate( 47, 84 ),
+ new ezcGraphCoordinate( 99, 84 ),
+ new ezcGraphCoordinate( 99, 54 ),
+ ),
+ ezcGraphColor::fromHex( '#DDDDDD' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'Safari (13.8%)',
+ new ezcGraphCoordinate( 47, 54 ),
+ 52,
+ 30,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testDrawSmallFreeTypeStringWithSpecialChars()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
- $this->driver->options->supersampling = 2;
$this->driver->drawPolygon(
array(
@@ -1305,9 +1342,156 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$filename,
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testDrawSmallPsStringWithSpecialChars()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $this->driver->options->font->path = $this->basePath . 'ps_font.pfb';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 47, 54 ),
+ new ezcGraphCoordinate( 47, 84 ),
+ new ezcGraphCoordinate( 99, 84 ),
+ new ezcGraphCoordinate( 99, 54 ),
+ ),
+ ezcGraphColor::fromHex( '#DDDDDD' ),
+ true
+ );
+ $this->driver->drawTextBox(
+ 'Safari (13.8%)',
+ new ezcGraphCoordinate( 47, 54 ),
+ 52,
+ 30,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testDrawNativeTTFText()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $this->driver->options->font->path = $this->basePath . 'font.ttf';
+ $this->driver->options->forceNativeTTF = true;
+
+ $this->driver->drawTextBox(
+ 'Fontfiletest',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
+ public function testDrawFreeTypeTTFText()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $this->driver->options->font->path = $this->basePath . 'font.ttf';
+
+ $this->driver->drawTextBox(
+ 'Fontfiletest',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
2000
);
}
+
+ public function testDrawPSText()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+ $this->driver->options->font->path = $this->basePath . 'ps_font.pfb';
+
+ $this->driver->drawTextBox(
+ 'Fontfiletest',
+ new ezcGraphCoordinate( 10, 10 ),
+ 150,
+ 70,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 2000
+ );
+ }
+
+ public function testDrawTooLongTextException()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ try
+ {
+ $this->driver->drawTextBox(
+ 'This is very long text which is not supposed to fit in the bounding box.',
+ new ezcGraphCoordinate( 10, 10 ),
+ 50,
+ 20,
+ ezcGraph::LEFT
+ );
+
+ $this->driver->render( $filename );
+ }
+ catch ( ezcGraphFontRenderingException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphFontRenderingException.' );
+ }
}
?>
diff --git a/tests/font_test.php b/tests/font_test.php
index 3e6ee6d..00a13df 100644
--- a/tests/font_test.php
+++ b/tests/font_test.php
@@ -145,6 +145,46 @@ class ezcGraphFontTest extends ezcTestCase
'Font face for legend has not changed.'
);
}
+
+ public function testTTFFontType()
+ {
+ $chart = new ezcGraphLineChart();
+ $chart->options->font->path = $this->basePath . 'font.ttf';
+
+ $this->assertSame(
+ $chart->options->font->type,
+ ezcGraph::TTF_FONT,
+ 'Font type is not TTF.'
+ );
+ }
+
+ public function testPSFontType()
+ {
+ $chart = new ezcGraphLineChart();
+ $chart->options->font->path = $this->basePath . 'ps_font.pfb';
+
+ $this->assertSame(
+ $chart->options->font->type,
+ ezcGraph::PS_FONT,
+ 'Font type is not TTF.'
+ );
+ }
+
+ public function testUnknownFontType()
+ {
+ $chart = new ezcGraphLineChart();
+
+ try
+ {
+ $chart->options->font->path = $this->basePath . 'ez.png';
+ }
+ catch ( ezcGraphUnknownFontTypeException $e )
+ {
+ return true;
+ }
+
+ $this->fail( 'Expected ezcGraphUnknownFontTypeException.' );
+ }
}
?>
OpenPOWER on IntegriCloud