diff options
author | Steve Chaplin <> | 2010-09-15 09:37:32 +0800 |
---|---|---|
committer | Steve Chaplin <> | 2010-09-15 09:37:32 +0800 |
commit | 30fe91ce1c122f1a2ce5dfb742b7862474db826e (patch) | |
tree | 68ada1b456607177a9b87e1bc96197e2cbc7d776 | |
parent | 04ae0c94d1e73ff39d731a44229a6eb079018666 (diff) |
Add/update tests for unicode filenames and unicode text.
-rwxr-xr-x | test/unicode.py | 28 | ||||
-rwxr-xr-x | test/unicodeFilenames.py | 31 | ||||
-rwxr-xr-x | test/unicodeText.py | 31 |
3 files changed, 62 insertions, 28 deletions
diff --git a/test/unicode.py b/test/unicode.py deleted file mode 100755 index a9c89f3..0000000 --- a/test/unicode.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# test unicode filenames - -import math -import cairo - -WIDTH, HEIGHT = 256, 256 - -#f = open(u"ēxāmple.pdf","w") -#surface = cairo.PDFSurface (f, WIDTH, HEIGHT) - -surface = cairo.PDFSurface (u"a1ēxāmple.pdf", WIDTH, HEIGHT) - -ctx = cairo.Context (surface) -ctx.scale (WIDTH, HEIGHT) -pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0) -pat.add_color_stop_rgba (1, 0.7, 0, 0, 0.5) -pat.add_color_stop_rgba (0, 0.9, 0.7, 0.2, 1) -ctx.rectangle (0, 0, 1, 1) -ctx.set_source (pat) -ctx.fill () -ctx.translate (0.1, 0.1) - -surface.write_to_png (u"a2ēxāmple.png") -surface.show_page() -surface.flush() -surface.finish() diff --git a/test/unicodeFilenames.py b/test/unicodeFilenames.py new file mode 100755 index 0000000..4378449 --- /dev/null +++ b/test/unicodeFilenames.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Test unicode filenames + +Functions/methods using unicode filenames: + cairo.PDFSurface() + cairo.PSSurface() + cairo.SVGSurface() + surface.write_to_png() + surface.create_from_png() +""" + +import cairo + +WIDTH, HEIGHT = 256, 256 + +#f = open(u"a1ēxāmple.pdf","w") +#surface = cairo.PDFSurface (f, WIDTH, HEIGHT) + +surface = cairo.PDFSurface(u"a1ēxāmple.pdf", WIDTH, HEIGHT) + +ctx = cairo.Context(surface) +ctx.set_source_rgb(1,0,0) +ctx.set_operator(cairo.OPERATOR_SOURCE) +ctx.paint() + +surface.write_to_png(u"a2ēxāmple.png") +surface.show_page() +surface.flush() +surface.finish() diff --git a/test/unicodeText.py b/test/unicodeText.py new file mode 100755 index 0000000..5ad50c7 --- /dev/null +++ b/test/unicodeText.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Test unicode text + +Functions/methods which accept unicode text: + Context.select_font_face() + Context.show_text() + Context.text_extents() + Context.text_path() + ToyFontFace() + ScaledFont.text_extents() +""" + +import cairo + +width, height = 300,300 +surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) +ctx = cairo.Context(surface) + +ctx.scale(width, height) +ctx.set_line_width(0.04) + +ctx.select_font_face("Sans", + cairo.FONT_SLANT_NORMAL, + cairo.FONT_WEIGHT_NORMAL) +ctx.set_font_size(0.20) +ctx.move_to(0.05, 0.5) +ctx.show_text("ēxāmple.") + +surface.write_to_png("test-out.png") |