{"id":13574604,"url":"https://github.com/adobe/svg-native-viewer","last_synced_at":"2025-04-04T15:31:29.774Z","repository":{"id":37390655,"uuid":"180366596","full_name":"adobe/svg-native-viewer","owner":"adobe","description":"SVG Native viewer is a library that parses and renders SVG Native documents","archived":false,"fork":false,"pushed_at":"2024-10-13T19:07:11.000Z","size":485,"stargazers_count":153,"open_issues_count":28,"forks_count":37,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-11-05T09:44:54.991Z","etag":null,"topics":["cpp","opentype-svg-fonts","svg","svg-icons","svg-native"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adobe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-09T12:55:01.000Z","updated_at":"2024-09-10T18:19:52.000Z","dependencies_parsed_at":"2023-12-26T06:23:55.213Z","dependency_job_id":"41152a4f-33c1-4468-8e3b-f28f8dd47708","html_url":"https://github.com/adobe/svg-native-viewer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Fsvg-native-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Fsvg-native-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Fsvg-native-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adobe%2Fsvg-native-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adobe","download_url":"https://codeload.github.com/adobe/svg-native-viewer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247202783,"owners_count":20900840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","opentype-svg-fonts","svg","svg-icons","svg-native"],"created_at":"2024-08-01T15:00:52.926Z","updated_at":"2025-04-04T15:31:24.767Z","avatar_url":"https://github.com/adobe.png","language":"C++","readme":"# SVG Native Viewer\n\n[![CircleCI](https://circleci.com/gh/adobe/svg-native-viewer.svg?style=svg)](https://circleci.com/gh/adobe/svg-native-viewer)\n\nSVG Native viewer is a library that parses and renders SVG Native\ndocuments.\n\n## SVG Native\nSVG Native is an upcoming specification of the SVG WG based on [SVG\nOpenType](https://docs.microsoft.com/en-us/typography/opentype/spec/svg)\n. SVG Native will be a strict subset of SVG 1.1 and SVG 2.0.\n\n### Supported features in SVG Native (in comparison to SVG1.1/SVG2)\n* No stylesheet support (CSS/XSL) with the exception of the basic\ninheritance model and the following presentation attributes:\n    * `clip-path`\n    * `clip-rule`\n    * `color`\n    * `display`\n    * `fill`\n    * `fill-opacity`\n    * `fill-rule`\n    * `opacity`\n    * `stroke`\n    * `stroke-dasharray`\n    * `stroke-dashoffset`\n    * `stroke-linecap`\n    * `stroke-linejoin`\n    * `stroke-miterlimit`\n    * `stroke-opacity`\n    * `stroke-width`\n    * `stop-color`\n    * `stop-opacity`\n    * `visibility`\n* CSS properties do not support any default property values like\n  `inherit`, `initial`, `unset`, or `revert`.\n* No support for scripting, interactions, events, animations, filters,\n  masks, patterns, texts.\n* No support for inner `\u003csvg\u003e` or `\u003csymbol\u003e` elements.\n* No support for XML namespaces with the exception of the SVG namespace\n  and the Xlink namespace.\n* No support of `objectBoundingBox` on `gradientUnits` or\n  `clipPathUnits`.\n* The `var()` CSS value function is limited to the CSS properties\n  `fill`, `stroke`, `stop-color` and `color`. Only color values are\n  allowed. `currentColor` is supported.\n\nA valid SVG Native document is always a valid SVG1.1/2.0 document.\n\n## SVG Native Viewer Library\n\nSVG Native Viewer is a C++11 based project and can either be included\nin the source code of a client directly or linked statically or\ndynamically.\n\nFor rendering, SVG Native Viewer requires a rendering port. Already\nexisting ports include:\n* **StringSVGRenderer** for testing purposes,\n* **CGSVGRenderer** a rendering port using CoreGraphics (Quartz 2D).\n* **SkiaSVGRenderer** a rendering port using Skia. (**Skia requires a C++14 compatible compiler!**)\n* **CairoSVGRenderer** a rendering port using Cairo Graphics.\n* **GDIPlusSVGRenderer** a rendering port using GDI+.\n* **D2DSVGRenderer** a rendering port using Direct2D.\n\nNew ports need to inherit from **SVGRenderer** and implement the\nvirtual functions.\n\nHere an example how to use SVG Native Viewer with Skia\n**SkiaSVGRenderer**:\n\n```cpp\n// Create the renderer object\nauto renderer = std::make_shared\u003cSVGNative::SkiaSVGRenderer\u003e();\n\n// Create SVGDocument object and parse the passed SVG string.\nauto doc = std::unique_ptr\u003cSVGNative::SVGDocument\u003e\n(SVGNative::SVGDocument::CreateSVGDocument(svgInput.c_str(), renderer));\n\n// Setup SkSurface for drawing\nauto skRasterSurface = SkSurface::MakeRasterN32Premul(doc-\u003eWidth(),\n                                                      doc-\u003eHeight());\nauto skRasterCanvas = skRasterSurface-\u003egetCanvas();\n\n// Pass SkCanvas to renderer object\nrenderer-\u003eSetSkCanvas(skRasterCanvas);\n\n// Pass drawing commands for SVG document to renderer.\ndoc-\u003eRender();\n\n// Pass drawing commands for SVG document to renderer the element (and\n// its descendants)\n// with the XML ID \"ref1\".\nstd::string id1{\"ref1\"}\ndoc-\u003eRender(id1);\n\n// The Render() function may get called multiple times. This can be\n// used to render a combination of glyphs specified in the same SVG\n// document.\nstd::string id2{\"ref2\"}\ndoc-\u003eRender(id2);\n```\n\nRefer to the examples in the `example/` directory for other port\nexamples.\n\n## Requirements\n### Submodules\n\nThis repository uses submodules. To initiate and keep submodules\nup-to-date run the following command:\n\n```\ngit submodule update --init\n```\n\nSubmodules are located in the `third_party/` directory. Used submodules:\n* [stylesheet](https://github.com/adobe/stylesheet/tree/modifications)\n  **(optional)** Needed if compiled with limited CSS style support\n(deprecated).\n* [cpp-base64](https://github.com/ReneNyffenegger/cpp-base64)\n  **(optional)** Needed by some ports for decoding base64 encoded raster\nimage support.\n* [boost_variant_property_tree](https://github.com/dirkschulze/boost_variant_property_tree)\n  **(optional)** Minimal version of Boost stripped down to the\n  requirements of `variant` and `property_tree`. Used if Boost was not\n  installed on the system.\n\n\n### Windows\n\nInstall:\n* [CMake](https://cmake.org) Download and run the installer\n* [Boost](https://www.boost.org) Download the ZIP-package and extract\n  the package into `C:\u003e\\Program Files\\boost_x.y.z\\` (See below how to\n  specify a different Boost installation directory by a CMake option.)\n* [MS Visual Studio 2017 or\n  up](https://visualstudio.microsoft.com/vs/whatsnew/) Download and\n  install with the installer. Make sure Visual C++ gets installed. (You\n  maybe be able to use the \"Community\" version for free for\n  non-commercial/enterprise use. See the website from MS for license\n  details.)\n\n### OSX\nWith Homebrew:\n```\nbrew install cmake\nbrew install llvm\nbrew install boost\n```\n\n### LINUX\n\n* Apt\n```\nsudo apt-get install build-essential libboost-system-dev cmake\n```\n\n## Building\n\n### Create project files\n\nFor Windows 64 bit:\n```\ncmake -Bbuild/win64 -H. -G \"Visual Studio 15 2017 Win64\"\n```\n\nFor Windows 32 bit:\n```\ncmake -Bbuild/win32 -H. -G \"Visual Studio 15 2017\"\n```\n_Omit `-H` when running in PowerShell._\n\nFor macOS\n```\ncmake -Bbuild/mac -H. -G \"Xcode\"\n```\n\nFor Linux\n```\ncmake -Bbuild/linux -H.\n```\nOn Linux you may choose to use GCC or Clang/LLVM. Add the following to\nthe command above to choose between one and the other:\n* `-DCMAKE_CXX_COMPILER=g++` for GCC\n* `-DCMAKE_CXX_COMPILER=clang` for Clang/LLVM\n\nOn Windows you may choose to use Clang/LLVM as compiler. For help,\nfollow the instructions of the linked MS Visual Studio [LLVM\nExtension](https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.llvm-toolchain). \nAdd ` -T \"LLVM\"` to the project generation command above.\n\nTo specify a different Boost installation directory on Windows use the\nfollowing command:\n* `-DBOOST_ROOT=X:\\path\\to\\boost`\n\nThe following arguments can be passed with the `-D` flag and the\noptions `ON` or `OFF`:\n* `LIB_ONLY` Only compile the library without examples. Default `OFF`.\n* `SHARED` If `ON`, builds a dynamic library. Static otherwise. Default\n  `OFF`.\n* `PLATFORM_XML` If `ON`, uses libxml2 or Epat if provided by the\n  system. Otherwise RapidXML via boost. Default `OFF`.\n* `TEXT` adds the _Text_ port to the library. Default `ON`.\n* `CG` adds the _CoreGraphics/Quartz2D_ port to the library. Default\n  `OFF`.\n* `SKIA` adds the _Skia_ port to the library. Default `OFF`.\n* `GDIPLUS` adds the _GDI+_ port to the library. Default `OFF`.\n* `D2D` adds the _Direct2D_ port to the library. Default `OFF`.\n* `CAIRO` adds the _Cairo Graphics_ port to the library. Default `OFF`.\n* `TESTING` enables automated testing using Google Tests. Default `ON`.\n\nTo enable the deprecated CSS styling support:\n* `STYLE` adds limited, deprecated support for `\u003cstyle\u003e` element and\n  `style` attribute. Default `OFF`. _(This option will get removed\n  eventually.)_\n\nThe following example creates project files for the library with the\nText, CoreGraphics/Quartz2D and Skia port and the example applications.\n**Example:**\n```\ncmake -Bbuild/mac -H. -G \"Xcode\" -DCG=ON -DSKIA=ON\n```\n\n**Note:** For testing, build with the `TEXT` option set to `ON` and\n `LIB_ONLY` option set to `OFF`. (The default for both.)\n\n### Build\n\nReplace `win64` with your platform (`mac` for Xcode on macOS)\n```\ncmake --build build/win64 --config Release\n```\n\n## Boost requirements\n\nOnly the header version of Boost is required. The following Boost\nfeatures are used:\n* Boost RapidXML _(Can be replaced by libxml2.)_\n* `boost::variant` to handle different SVG paint types of `fill` and\n `stroke` as well as different color value types.\n* Boost string functions like `boost::tokenizer`, `boost::trim`. _(Only\nused by deprecated CSS `\u003cstyle\u003e` element parsing.)_\n\n## Tests\nSVG Native Viewer has two testing mechanisms. A python script that performs the renderings on the *Text* port and compares the renderings with the existing ones and automated software testing using Google Tests framework. \n\n### *Text* port testing\nTo use the python script:\n1. Make sure your system has Python installed.\n2. By default, CMake creates the project files for\n**SVGNativeViewerLib** and **testSVGNative**. Follow the steps above to\nbuild the test app.\n3. Run\n  ```\n  python script/runTest.py --tests=test/\n  ```\n  Here the argument list of **runTest.py**:\n  * `--test` the folder with the test files.\n  * `--program` the path to **testSVGNative**. If not provided uses the\n    default, relative build path.\n  * `--debug` Debug build or Release build of **testSVGNative**. Only\n    relevant if `--program` was not set and defaults to `--debug`.\n### Google Test based testing\nIn order to build and run the tests, pass the argument `-DTESTING=ON` when running Cmake. Cmake will automatically download and build Google Tests and compile the tests. In order to run the tests you can run `make test` or just use `ctest` in the build folder.\n\nUltimately, we aim to improve software unit testing as well as add rendering tests to ensure that SVG Native Viewer's renderings are accurate.\n\n## Known limitations in SVG Native Viewer\n* `preserveAspectRatio` is not supported on the `\u003csvg\u003e` element yet.\n* Furthermore, there might be limitations on certain platforms. (E.g.\n  missing gradient spread-method support on CoreGraphics.)\n\n## Contributing\n\nContributions are welcomed! Read the [Contributing\nGuide](./.github/CONTRIBUTING.md) for more information.\n\n## Licensing\n\nThis project is licensed under the Apache V2 License. See\n[LICENSE](LICENSE) for more information.\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadobe%2Fsvg-native-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadobe%2Fsvg-native-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadobe%2Fsvg-native-viewer/lists"}