From 7ec0aa7b69d32f2a545636f7dfbe31641d97d1fa Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 7 Dec 2014 12:33:26 +0000 Subject: [PATCH] Update README to cover dependancies and core buildsystem Fix various issues with the test target and update the documentation to be more correct. --- COPYING | 19 ++++++++ README | 117 +++++++++++++++++++++++++++++------------------- svgtiny_display | 2 +- 3 files changed, 91 insertions(+), 47 deletions(-) create mode 100644 COPYING diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f2fe5f6 --- /dev/null +++ b/COPYING @@ -0,0 +1,19 @@ +Copyright 2007 James Bursa . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + + * The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README index a728006..3c5095a 100644 --- a/README +++ b/README @@ -1,34 +1,37 @@ Libsvgtiny ========== + http://www.netsurf-browser.org/projects/libsvgtiny/ Libsvgtiny is a library for parsing SVG files for display. -The overall idea of the library is to take some SVG as input, and return a list -of paths and texts which can be rendered easily. The library does not do the -actual rendering. +The overall idea of the library is to take some SVG as input, and +return a list of paths and texts which can be rendered easily. The +library does not do the actual rendering. -All supported SVG objects, for example circles, lines, and gradient filled -shapes, are converted to flat-filled paths or a fragment of text, and all -coordinates are converted, transformed etc. to pixels. +All supported SVG objects, for example circles, lines, and gradient +filled shapes, are converted to flat-filled paths or a fragment of +text, and all coordinates are converted, transformed etc. to pixels. Libsvgtiny is Licensed under the MIT License, http://opensource.org/licenses/mit-license.php Written by James Bursa . + SVG support ----------- + Libsvgtiny is initially aiming to implement SVG Tiny, as defined in http://www.w3.org/TR/SVGMobile/. SVG Tiny elements supported: defs, g, svg, circle, line, path, polygon, polyline, rect, text -SVG Tiny elements not yet supported: desc, metadata, title, use, a, switch, -ellipse, image, font, font-face, font-face-name, font-face-src, glyph, hkern, -missing-glyph, animate, animateColor, animateMotion, animateTransform, mpath, -set, foreignObject +SVG Tiny elements not yet supported: desc, metadata, title, use, a, +switch, ellipse, image, font, font-face, font-face-name, font-face-src, +glyph, hkern, missing-glyph, animate, animateColor, animateMotion, +animateTransform, mpath, set, foreignObject Additional elements supported: linearGradient, stop @@ -36,16 +39,25 @@ Text support is incomplete. The style attribute is supported. + Building libsvgtiny ------------------- + +The library uses the Netsurf core buildsystem which must be available +(usually at the same level as the libsvg source) + +The PREFIX variable can be used to perform builds which do not install +to global system paths. + You will require the following tools: -- a C compiler (some parts of C99 support are required) -- gperf + - a C compiler (some parts of C99 support are required) + - gperf -and the following libraries: +following additional libraries are required: -- libxml2 + - libwapcaplet + - libdom To compile libsvgtiny, use the command @@ -55,18 +67,26 @@ To install libsvgtiny into /usr/local, use make install -To cross-compile for RISC OS, use +The VARIANT variable allows builds for "release" (the default) and "debug" +e.g. + + make VARIANT=debug - make TARGET=riscos - make install TARGET=riscos Testing libsvgtiny ------------------ -The svgtiny_display script uses the library to render an SVG. It requires that -ImageMagick convert is installed. -Get an SVG file, for example -http://www.croczilla.com/svg/samples/tiger/tiger.svg +The core buildsystem provides a test target which performs basic checks + + make test + +For manual testing a svgtiny_display script is available which renders +an svg to a bitmap. This script uses the svgtiny_test program to +render an SVG to an imagemagic MVG. It requires that ImageMagick +convert is installed to convert the MVG into a bitmap. + +Get an suitable SVG file, for example the tiger svg can be found in +the examples directory or downloaded [1] Then use svgtiny_display to parse and render it: @@ -75,8 +95,10 @@ Then use svgtiny_display to parse and render it: The optional 2nd argument is a scale. + Using libsvgtiny ---------------- + The interface is in the header svgtiny.h #include @@ -94,19 +116,20 @@ SVGs are parsed from memory using svgtiny_parse(): svgtiny_code code; code = svgtiny_parse(diagram, buffer, size, url, 1000, 1000); -The arguments are the pointer returned by svgtiny_create(), a buffer containing -the SVG data, the size of the SVG in bytes, the url that the SVG came from, and -the target viewport width and height in pixels. +The arguments are the pointer returned by svgtiny_create(), a buffer +containing the SVG data, the size of the SVG in bytes, the url that +the SVG came from, and the target viewport width and height in pixels. -The function returns svgtiny_OK if there were no problems, and diagram is -updated. The diagram can then be rendered by looping through the array -diagram->shape[0..diagram->shape_count]: +The function returns svgtiny_OK if there were no problems, and diagram +is updated. The diagram can then be rendered by looping through the +array diagram->shape[0..diagram->shape_count]: for (unsigned int i = 0; i != diagram->shape_count; i++) { -Path shapes have a non-NULL path pointer. The path is an array of floats of -length path_length. The array contains segment type codes followed by 0 to 3 -pairs of coordinates (depending on the segment type): +Path shapes have a non-NULL path pointer. The path is an array of +floats of length path_length. The array contains segment type codes +followed by 0 to 3 pairs of coordinates (depending on the segment +type): - svgtiny_PATH_MOVE x y - svgtiny_PATH_CLOSE @@ -116,28 +139,30 @@ pairs of coordinates (depending on the segment type): A path always starts with a MOVE. The fill and stroke attributes give the colors of the path, or -svgtiny_TRANSPARENT if the path is not filled or stroked. Colors are in 0xRRGGBB -format (except when compiled for RISC OS). The macros svgtiny_RED, -svgtiny_GREEN, and svgtiny_BLUE can be used to extract the components. +svgtiny_TRANSPARENT if the path is not filled or stroked. Colors are +in 0xRRGGBB format (except when compiled for RISC OS). The macros +svgtiny_RED, svgtiny_GREEN, and svgtiny_BLUE can be used to extract +the components. The width of the path is in stroke_width. -Text shapes have a NULL path pointer and a non-NULL text pointer. Text is in -UTF-8. The coordinates of the text are in text_x, text_y. Text colors and stroke -width are as for paths. +Text shapes have a NULL path pointer and a non-NULL text pointer. Text +is in UTF-8. The coordinates of the text are in text_x, text_y. Text +colors and stroke width are as for paths. If memory runs out during parsing, svgtiny_parse() returns -svgtiny_OUT_OF_MEMORY, but the diagram is still valid up to the point when -memory was exhausted, and may safely be rendered. +svgtiny_OUT_OF_MEMORY, but the diagram is still valid up to the point +when memory was exhausted, and may safely be rendered. -If there is an error in the SVG (for example, an element is missing an attribute -required by the specification), svgtiny_SVG_ERROR is returned, but the diagram -is still valid up to the point of the error. The error is recorded in -diagram->error_message and the line that caused it in diagram->error_line. +If there is an error in the SVG (for example, an element is missing an +attribute required by the specification), svgtiny_SVG_ERROR is +returned, but the diagram is still valid up to the point of the +error. The error is recorded in diagram->error_message and the line +that caused it in diagram->error_line. -svgtiny_LIBXML_ERROR indicates that parsing the XML failed. The returned diagram -will contain no shapes. svgtiny_NOT_SVG means that the XML did not contain a -top-level element. +svgtiny_LIBXML_ERROR indicates that parsing the XML failed. The +returned diagram will contain no shapes. svgtiny_NOT_SVG means that +the XML did not contain a top-level element. To free memory used by a diagram, use svgtiny_free(): @@ -146,4 +171,4 @@ To free memory used by a diagram, use svgtiny_free(): For an example, see svgtiny_test.c. - +[1] http://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg diff --git a/svgtiny_display b/svgtiny_display index 2b7415d..dbae8e7 100755 --- a/svgtiny_display +++ b/svgtiny_display @@ -1,3 +1,3 @@ set -e -make BUILD=debug test +make VARIANT=debug test build-Linux-Linux-debug-lib-static/test_svgtiny_test $1 $2 | convert mvg:- png:- | display - -- 2.44.2