TUGboat, Volume 22 (2001), No. 4 269 LATEX, SVG, Fonts ous XML vocabularies, thus saving as much semantic information as possible.1 Such a modular approach Michel Goossens and Vesa Sivunen makes optimal document reuse possible. Abstract 2 SVG for portable graphics on the Web After giving a short overview of SVG, pointing out As the Web has grown in popularity and complexity, its advantages for describing in a portable way the users and content providers wanted ever better and graphics content of electronic documents, we show more precise graphical rendering, as well as dynamic how we converted T X font outlines (the Type 1 E Web sites. Today, only drop shadows, rudimentary variant) into SVG outlines and explain how these animations, and low-resolution GIF or PNG images SVG font glyphs can be used in SVG instances of are commonly used in Web pages. Moreover, that documents typeset with T X. E technology is not really scalable. 1 Introduction The publication of the SVG Recommendation was the result of more than two years of collabo- The increasing affordability of the personal com- rative effort by major players in the computer in- puter drastically reduces the production cost of elec- dustry2 to find a workable cross-platform solution tronic documents. The World Wide Web makes dis- to Web imaging. Version 1.0 of the SVG specifica- tributing these documents worldwide cheap, easy, tion was published as a W3C Recommendation on and fast. Taken together, these two developments 4 September 2001 and it represents a genuine ad- have considerably changed the economic factors con- vance for portable graphics on the Web. The cur- trolling the generation, maintenance, and dissemi- rent version of SVG is 1.1, and it became a W3C nation of electronic documents. More recently, the Recommendation on 14 January 2003.3 development of the XML family of standards and the Nowadays many software vendors support SVG ubiquity of the platform-independent Java language in their products, while more and more free viewing make it possible to have a unified approach to han- and editing tools capable of handling SVG become dle the huge amount of information stored electron- available. ically and to transform it into various customizable SVG is an open-standard vector graphics lan- presentation forms. guage for describing two-dimensional graphics using Given the severe financial constraints in many XML syntax. It lets you produce Web pages con- parts of the world, where it is often out of the taining high-resolution computer graphics. question to even consider printing multiple copies SVG has the usual vector graphics functions. Its of a (highly technical) document, electronic dissem- fundamental primitive is the graphics object, whose ination via the Web is the only way to publish. model contains the following: Thus, the Web is not only an additional medium for the traditional publishing industry, but a necessary • graphics paths consisting of polylines, B´ezier complement in large parts of the world to partici- curves, etc.: pate in sharing scientific and technical information – simple or compound, closed or open; and benefit from the wealth and progress it creates. – (gradient) filled, (gradient) stroked; Various techniques are now available to trans- – can be used for clipping; form LATEX documents into PDF, HTML (XHTML), – can be used for building common geomet- or XML so that the information can be made avail- ric shapes; able on the Web. Thus, LAT X will continue to play E • patterns and markers; a major role in the integrated worldwide cyberspace, especially in the area of scientific documents. How- • templates and symbol libraries; ever, it is clear that LATEX’s greatest impact will 1 For instance, the hierarchical structure of the document remain in the area of typesetting, with TEX remain- is encoded in XML by using one of DocBook, TEI or, to a cer- ing an important intermediate format for generating tain extent, XHTML, while other specific XML vocabularies are used for their given application domain, such as MathML high-quality printable PDF output. for mathematics, SVG for two-dimensional graphics, CML for The present article explores ways of transform- chemistry, BSML for bioinformatics, GeneXML or GEML for ing LAT X-encoded information globally into a Scal- gene expression, and many others. E 2 able Vector Graphics (SVG) format, in particular by Among the companies represented on W3C’s SVG com- mittee were IBM, Microsoft, Apple, Xerox, Sun Microsys- exploiting the use of the SVG font machinery. A fur- tems, Hewlett-Packard, Netscape, Corel, Adobe, Quark, and ther step, to be described in a forthcoming article, Macromedia. 3 will be to transform the LATEX document into vari- Scalable Vector Graphics (SVG) 1.1 Specification, avail- able at http://www.w3.org/TR/SVG11/. 270 TUGboat, Volume 22 (2001), No. 4 • transformations: graphics possibilities of SVG. After the comment on – default coordinate system: x is right, y is line 1 we declare that we work in the SVG namespace down, one unit is one pixel; (line 2) and define the size of the display area (line – viewport maps an area in world coordi- 3). We write a title (lines 5 and 6), draw a row of nates to an area on screen; four rectangles (lines 7–14), followed by a row of four – transformations alter the coordinate sys- rectangles with rounded corners (lines 17–23), and tem (2 × 3 transformation matrix for com- finally a row of four ellipses (lines 25–29). The ori- puters; translate, rotate, scale, skew for gin of SVG’s x-y coordinate system is the upper left humans); hand side of the display area. The semantics of the various arguments of the SVG elements should be – can be nested; rather easy to guess (the SVG Specification contains • inclusion of bitmap or raster images; detailed definitions). Notice the similarity between • clipping, filter and raster effects, alpha masks; the PostScript and SVG languages. • animations, scripts, and extensions; If we want to view our file svgexa.svg we must • groupings and styles; use an application that understands the SVG lan- • SVG fonts (independent from fonts installed on guage, such as Apache’s Batik6 or Adobe’s Browser the system). plugin svgview.7 W3C’s browser Amaya,8 which SVG consists of Unicode text in any XML name- provides an interesting development environment for space.4 The use of Unicode throughout enhances viewing and editing MathML and HTML code, also searchability and accessibility of the SVG graphics. supports part of SVG. The recent default distri- 9 SVG drawings can be dynamic and interactive. butions (1.3 or later) of the Mozilla browser have The Document Object Model (DOM) for SVG allows built-in support for presentation MathML but to be for efficient vector graphics animation via scripting, able to interpret SVG natively you need to down- 10 which can be performed on SVG elements and other load a special SVG-enabled executable. The mid- XML elements from different namespaces simulta- dle row of Figure 1 represents at the left our example neously within the same Web page. Event handlers file as displayed by Batik, with a zoom on part of can be assigned to any SVG graphical object. the graphics at its right. This shows that regions of A major source of information on SVG is the an image can be magnified without loss of quality W3C SVG site, which describes the latest develop- (this is because of the vector nature of SVG’s graph- 11 ments in the area of SVG, the status of current im- ics model). The bottom row of Figure 1 shows plementations. It also has a reference list of arti- at the left the same file as displayed by Microsoft’s cles, books, software announcements, and pointers Internet Explorer using Adobe’s svgview plugin in- to other interesting SVG sites.5 stalled (left) and at the right as shown by the Amaya browser. 2.1 Inside an SVG document 3 Generating SVG instances from TEX As described earlier, the basis of SVG is a Uni- fonts code text document, usually identified with a file extension .svg and a mime-type (for the server) Many scientific documents, especially in physics and image/svg-xml. Thus it is rather straightforward mathematics, are marked up with LATEX. On the to create and edit SVG documents with your favorite other hand XML has become a lingua franca of the text editor. Internet and XML-aware tools are becoming ubiqui- The top part of Figure 1 shows a small SVG tous. Therefore, it becomes important to integrate file svgexa.svg, which is an example of the static LATEX and XML in an optimal way. 4 The target application must be able to interpret the specific XML vocabulary to make this useful. A forthcoming article will show how one can use XHTML, MathML and SVG 6 See http://xml.apache.org/batik. together. 7 Available from http://www.adobe.com/svg. 5 The W3C SVG site is at http://www.w3.org/Graphics/ 8 See http://www.w3.org/Amaya/. SVG/. An SVG Tutorial site is at http://www.svgtutorial. 9 See http://www.mozilla.org. com/. The Batik distribution (http://xml.apache.org/ 10 Details at http://www.mozilla.org/projects/svg/. batik) comes with many SVG examples, including quasi 3D 11 The Batik Squiggle SVG viewer and Adobe’s Browser scenes, animations, complex languages, such as Arabic, etc. plugin svgview offer convenient ways to navigate an image. The Adobe SVG site (http://www.adobe.com/svg) features You can zoom in and out, move in the two-dimensional plane some interesting SVG files. Interactive geometry, statistical (in svgview hold down the Alt or in Squiggle the Shift key charts, cartographic material and much more is at Michel and move the mouse with the left button pressed) or rotate Pilat’s site (http://pilat.free.fr/english).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-