summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2008-08-14 09:59:13 -0500
committerJonathon Jongsma <jonathon.jongsma@collabora.co.uk>2008-08-14 09:59:13 -0500
commitfdda3cf2c56d8b06a89a4233166dd27c8ec9fa2e (patch)
tree573dea55bb01c61cc49da83c23787442940c3640 /examples
parentc8f07e579c84af18b93f504614f7c903afe4749d (diff)
Implement the ToyFontFace class
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am2
-rw-r--r--examples/text-rotate/.cvsignore6
-rw-r--r--examples/text/Makefile.am (renamed from examples/text-rotate/Makefile.am)6
-rw-r--r--examples/text/text-rotate.cc (renamed from examples/text-rotate/text-rotate.cc)0
-rw-r--r--examples/text/toy-text.cc35
5 files changed, 40 insertions, 9 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 0c42e94..b361432 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = png_file pdf-surface ps-surface svg-surface text-rotate
+SUBDIRS = png_file pdf-surface ps-surface svg-surface text
EXTRA_DIST = README Makefile.am_fragment
diff --git a/examples/text-rotate/.cvsignore b/examples/text-rotate/.cvsignore
deleted file mode 100644
index c64b95d..0000000
--- a/examples/text-rotate/.cvsignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-text_rotate
-text-rotate.png
diff --git a/examples/text-rotate/Makefile.am b/examples/text/Makefile.am
index 9809f5f..adb68b0 100644
--- a/examples/text-rotate/Makefile.am
+++ b/examples/text/Makefile.am
@@ -1,7 +1,9 @@
include $(top_srcdir)/examples/Makefile.am_fragment
# build the executable but don't install it
-noinst_PROGRAMS = text_rotate
+noinst_PROGRAMS = text_rotate toy-text
+
text_rotate_SOURCES = text-rotate.cc
+toy_text_SOURCES=toy-text.cc
-CLEANFILES = text-rotate.png
+CLEANFILES = text-rotate.png toy-text.png
diff --git a/examples/text-rotate/text-rotate.cc b/examples/text/text-rotate.cc
index 4a78829..4a78829 100644
--- a/examples/text-rotate/text-rotate.cc
+++ b/examples/text/text-rotate.cc
diff --git a/examples/text/toy-text.cc b/examples/text/toy-text.cc
new file mode 100644
index 0000000..1f22521
--- /dev/null
+++ b/examples/text/toy-text.cc
@@ -0,0 +1,35 @@
+#include <cairomm/cairomm.h>
+
+const double HEIGHT = 200.0;
+const double WIDTH = 400.0;
+const double FONT_SIZE = 64.0;
+const double TEXT_ORIGIN_Y = (HEIGHT / 2.0) + (FONT_SIZE / 2.0);
+const double TEXT_ORIGIN_X = 50.0; // arbitrary
+
+int main(int, char**)
+{
+ Cairo::RefPtr<Cairo::ImageSurface> surface =
+ Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, WIDTH, HEIGHT);
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
+ // fill background in white
+ cr->set_source_rgb(1.0, 1.0, 1.0);
+ cr->paint();
+
+ // draw a little dot at the point where text will be drawn
+ cr->arc(TEXT_ORIGIN_X, TEXT_ORIGIN_Y, FONT_SIZE / 4.0, 0, 2*M_PI);
+ cr->set_source_rgba(0.0, 1.0, 0.0, 0.5);
+ cr->fill();
+
+ // draw the text
+ cr->move_to(TEXT_ORIGIN_X, TEXT_ORIGIN_Y);
+ cr->set_source_rgb(0.8, 0.2, 0.2);
+ Cairo::RefPtr<Cairo::ToyFontFace> font =
+ Cairo::ToyFontFace::create("Bitstream Charter",
+ Cairo::FONT_SLANT_ITALIC,
+ Cairo::FONT_WEIGHT_BOLD);
+ cr->set_font_face(font);
+ cr->set_font_size(FONT_SIZE);
+ cr->show_text("cairomm!");
+ surface->write_to_png("toy-text.png");
+ return 0;
+}