diff options
author | Kurt Jung <kurt.w.jung@gmail.com> | 2015-04-28 17:41:15 -0400 |
---|---|---|
committer | Kurt Jung <kurt.w.jung@gmail.com> | 2015-04-28 17:41:15 -0400 |
commit | ad688ac0bc2ed930398cee2ceae9ac5b9cb5d60e (patch) | |
tree | 0ed8b3c86fa6221f6275032963d16bb9ad2787ac | |
parent | 75c3f0d8ec9463d9f5cc3034ab0103862a4a1aaa (diff) |
Cyrillic and Greek font example
-rw-r--r-- | fpdf_test.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fpdf_test.go b/fpdf_test.go index 0cf7ce0..f8df0c3 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -1168,7 +1168,10 @@ func ExampleFpdf_tutorial22() { // This example demonstrates the conversion of UTF-8 strings to an 8-bit font // encoding. func ExampleFpdf_tutorial23() { - pdf := gofpdf.New("P", "mm", "A4", "") // A4 210.0 x 297.0 + pdf := gofpdf.New("P", "mm", "A4", cnFontDir) // A4 210.0 x 297.0 + // See documentation for details on how to generate fonts + pdf.AddFont("Helvetica-1251", "", "helvetica_1251.json") + pdf.AddFont("Helvetica-1253", "", "helvetica_1253.json") fontSize := 16.0 pdf.SetFont("Helvetica", "", fontSize) ht := pdf.PointConvert(fontSize) @@ -1186,6 +1189,15 @@ func ExampleFpdf_tutorial23() { write("Falsches Üben von Xylophonmusik quält jeden größeren Zwerg.") write("Heizölrückstoßabdämpfung") write("Forårsjævndøgn / Efterårsjævndøgn") + + pdf.SetFont("Helvetica-1251", "", fontSize) // Name matches one specified in AddFont() + tr = pdf.UnicodeTranslatorFromDescriptor("cp1251") + write("Съешь же ещё этих мягких французских булок, да выпей чаю.") + + pdf.SetFont("Helvetica-1253", "", fontSize) + tr = pdf.UnicodeTranslatorFromDescriptor("cp1253") + write("Θέλει αρετή και τόλμη η ελευθερία. (Ανδρέας Κάλβος)") + pdf.OutputAndClose(docWriter(pdf, 23)) // Output: // Successfully generated pdf/tutorial23.pdf |