#!/usr/bin/perl -w # # Example 7-5. Unicode in SVG use strict; use XML::Writer; # Used to write the SVG output use IO::Scalar; # Used to buffer the XML::Writer output my $output = new IO::Scalar; my $writer = XML::Writer->new(OUTPUT => $output); $writer->setDataIndent(2); $writer->xmlDecl("UTF-8"); $writer->startTag('svg', width => 200, height => 100, 'xmlns:xlink' => 'http://www.w3.org/1999/Xlink'); $writer->startTag('text', x => 100, y => 50, 'font-family' => 'Arial', 'font-size' => 40, 'text-anchor' => 'middle', fill => '#000000'); $writer->characters("O'Reilly"); $writer->startTag('tspan', 'font-family' => 'Gothic MS', 'font-size' => 24, x => 100, dy => 24); # Add Katakana glyphs print $output "オライリー"; $writer->endTag('tspan'); $writer->endTag('text'); $writer->endTag('svg'); print $output;