summaryrefslogtreecommitdiff
path: root/ttfparser_test.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@code.google.com>2013-09-04 15:06:56 -0400
committerKurt Jung <kurt.w.jung@code.google.com>2013-09-04 15:06:56 -0400
commit845888136482c81fd76860b57e254c0e8fa6c149 (patch)
tree0cb49ce1cf0de4875ee103495490b63b8bccd22c /ttfparser_test.go
parent9b78fbbf6a97869fca10d53e11a52b2d2a9c37a2 (diff)
Set error condition if out-of-range Unicode rune is encountered in GetStringWidth
Diffstat (limited to 'ttfparser_test.go')
-rw-r--r--ttfparser_test.go20
1 files changed, 18 insertions, 2 deletions
diff --git a/ttfparser_test.go b/ttfparser_test.go
index 00f4030..9bb3d71 100644
--- a/ttfparser_test.go
+++ b/ttfparser_test.go
@@ -19,8 +19,7 @@ package gofpdf_test
import (
"code.google.com/p/gofpdf"
"fmt"
-
-// "testing"
+ // "testing"
)
func ExampleTtfParse() {
@@ -67,3 +66,20 @@ func ExampleTtfParse() {
// }
// }
// }
+
+func ExampleFpdf_GetStringWidth() {
+ pdf := gofpdf.New("", "", "", FONT_DIR)
+ pdf.SetFont("Helvetica", "", 12)
+ pdf.AddPage()
+ for _, s := range []string{"Hello", "世界"} {
+ fmt.Printf("Width of \"%s\" is %.2f\n", s, pdf.GetStringWidth(s))
+ if pdf.Err() {
+ fmt.Println(pdf.Error())
+ }
+ }
+ pdf.Close()
+ // Output:
+ // Width of "Hello" is 9.64
+ // Width of "世界" is 0.00
+ // Unicode strings not supported
+}