• Stars
    star
    142
  • Rank 249,196 (Top 6 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SVG Native viewer is a library that parses and renders SVG Native documents

SVG Native Viewer

CircleCI

SVG Native viewer is a library that parses and renders SVG Native documents.

SVG Native

SVG Native is an upcoming specification of the SVG WG based on SVG OpenType . SVG Native will be a strict subset of SVG 1.1 and SVG 2.0.

Supported features in SVG Native (in comparison to SVG1.1/SVG2)

  • No stylesheet support (CSS/XSL) with the exception of the basic inheritance model and the following presentation attributes:
    • clip-path
    • clip-rule
    • color
    • display
    • fill
    • fill-opacity
    • fill-rule
    • opacity
    • stroke
    • stroke-dasharray
    • stroke-dashoffset
    • stroke-linecap
    • stroke-linejoin
    • stroke-miterlimit
    • stroke-opacity
    • stroke-width
    • stop-color
    • stop-opacity
    • visibility
  • CSS properties do not support any default property values like inherit, initial, unset, or revert.
  • No support for scripting, interactions, events, animations, filters, masks, patterns, texts.
  • No support for inner <svg> or <symbol> elements.
  • No support for XML namespaces with the exception of the SVG namespace and the Xlink namespace.
  • No support of objectBoundingBox on gradientUnits or clipPathUnits.
  • The var() CSS value function is limited to the CSS properties fill, stroke, stop-color and color. Only color values are allowed. currentColor is supported.

A valid SVG Native document is always a valid SVG1.1/2.0 document.

SVG Native Viewer Library

SVG Native Viewer is a C++11 based project and can either be included in the source code of a client directly or linked statically or dynamically.

For rendering, SVG Native Viewer requires a rendering port. Already existing ports include:

  • StringSVGRenderer for testing purposes,
  • CGSVGRenderer a rendering port using CoreGraphics (Quartz 2D).
  • SkiaSVGRenderer a rendering port using Skia. (Skia requires a C++14 compatible compiler!)
  • CairoSVGRenderer a rendering port using Cairo Graphics.
  • GDIPlusSVGRenderer a rendering port using GDI+.
  • D2DSVGRenderer a rendering port using Direct2D.

New ports need to inherit from SVGRenderer and implement the virtual functions.

Here an example how to use SVG Native Viewer with Skia SkiaSVGRenderer:

// Create the renderer object
auto renderer = std::make_shared<SVGNative::SkiaSVGRenderer>();

// Create SVGDocument object and parse the passed SVG string.
auto doc = std::unique_ptr<SVGNative::SVGDocument>
(SVGNative::SVGDocument::CreateSVGDocument(svgInput.c_str(), renderer));

// Setup SkSurface for drawing
auto skRasterSurface = SkSurface::MakeRasterN32Premul(doc->Width(),
                                                      doc->Height());
auto skRasterCanvas = skRasterSurface->getCanvas();

// Pass SkCanvas to renderer object
renderer->SetSkCanvas(skRasterCanvas);

// Pass drawing commands for SVG document to renderer.
doc->Render();

// Pass drawing commands for SVG document to renderer the element (and
// its descendants)
// with the XML ID "ref1".
std::string id1{"ref1"}
doc->Render(id1);

// The Render() function may get called multiple times. This can be
// used to render a combination of glyphs specified in the same SVG
// document.
std::string id2{"ref2"}
doc->Render(id2);

Refer to the examples in the example/ directory for other port examples.

Requirements

Submodules

This repository uses submodules. To initiate and keep submodules up-to-date run the following command:

git submodule update --init

Submodules are located in the third_party/ directory. Used submodules:

  • stylesheet (optional) Needed if compiled with limited CSS style support (deprecated).
  • cpp-base64 (optional) Needed by some ports for decoding base64 encoded raster image support.
  • boost_variant_property_tree (optional) Minimal version of Boost stripped down to the requirements of variant and property_tree. Used if Boost was not installed on the system.

Windows

Install:

  • CMake Download and run the installer
  • Boost Download the ZIP-package and extract the package into C:>\Program Files\boost_x.y.z\ (See below how to specify a different Boost installation directory by a CMake option.)
  • MS Visual Studio 2017 or up Download and install with the installer. Make sure Visual C++ gets installed. (You maybe be able to use the "Community" version for free for non-commercial/enterprise use. See the website from MS for license details.)

OSX

With Homebrew:

brew install cmake
brew install llvm
brew install boost

LINUX

  • Apt
sudo apt-get install build-essential libboost-system-dev cmake

Building

Create project files

For Windows 64 bit:

cmake -Bbuild/win64 -H. -G "Visual Studio 15 2017 Win64"

For Windows 32 bit:

cmake -Bbuild/win32 -H. -G "Visual Studio 15 2017"

Omit -H when running in PowerShell.

For macOS

cmake -Bbuild/mac -H. -G "Xcode"

For Linux

cmake -Bbuild/linux -H.

On Linux you may choose to use GCC or Clang/LLVM. Add the following to the command above to choose between one and the other:

  • -DCMAKE_CXX_COMPILER=g++ for GCC
  • -DCMAKE_CXX_COMPILER=clang for Clang/LLVM

On Windows you may choose to use Clang/LLVM as compiler. For help, follow the instructions of the linked MS Visual Studio LLVM Extension. Add -T "LLVM" to the project generation command above.

To specify a different Boost installation directory on Windows use the following command:

  • -DBOOST_ROOT=X:\path\to\boost

The following arguments can be passed with the -D flag and the options ON or OFF:

  • LIB_ONLY Only compile the library without examples. Default OFF.
  • SHARED If ON, builds a dynamic library. Static otherwise. Default OFF.
  • PLATFORM_XML If ON, uses libxml2 or Epat if provided by the system. Otherwise RapidXML via boost. Default OFF.
  • TEXT adds the Text port to the library. Default ON.
  • CG adds the CoreGraphics/Quartz2D port to the library. Default OFF.
  • SKIA adds the Skia port to the library. Default OFF.
  • GDIPLUS adds the GDI+ port to the library. Default OFF.
  • D2D adds the Direct2D port to the library. Default OFF.
  • CAIRO adds the Cairo Graphics port to the library. Default OFF.

To enable the deprecated CSS styling support:

  • STYLE adds limited, deprecated support for <style> element and style attribute. Default OFF. (This option will get removed eventually.)

The following example creates project files for the library with the Text, CoreGraphics/Quartz2D and Skia port and the example applications. Example:

cmake -Bbuild/mac -H. -G "Xcode" -DCG=ON -DSKIA=ON

Note: For testing, build with the TEXT option set to ON and LIB_ONLY option set to OFF. (The default for both.)

Build

Replace win64 with your platform (mac for Xcode on macOS)

cmake --build build/win64 --config Release

Boost requirements

Only the header version of Boost is required. The following Boost features are used:

  • Boost RapidXML (Can be replaced by libxml2.)
  • boost::variant to handle different SVG paint types of fill and stroke as well as different color value types.
  • Boost string functions like boost::tokenizer, boost::trim. (Only used by deprecated CSS <style> element parsing.)

Tests

SVG 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.

Text port testing

To use the python script:

  1. Make sure your system has Python installed.
  2. By default, CMake creates the project files for SVGNativeViewerLib and testSVGNative. Follow the steps above to build the test app.
  3. Run
python script/runTest.py --tests=test/

Here the argument list of runTest.py:

  • --test the folder with the test files.
  • --program the path to testSVGNative. If not provided uses the default, relative build path.
  • --debug Debug build or Release build of testSVGNative. Only relevant if --program was not set and defaults to --debug.

Google Test based testing

In 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.

Ultimately, we aim to improve software unit testing as well as add rendering tests to ensure that SVG Native Viewer's renderings are accurate.

Known limitations in SVG Native Viewer

  • preserveAspectRatio is not supported on the <svg> element yet.
  • Furthermore, there might be limitations on certain platforms. (E.g. missing gradient spread-method support on CoreGraphics.)

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

More Repositories

1

brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
JavaScript
33,300
star
2

react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
TypeScript
11,538
star
3

leonardo

Generate colors based on a desired contrast ratio
JavaScript
1,853
star
4

antialiased-cnns

pip install antialiased-cnns to improve stability and accuracy
Python
1,611
star
5

balance-text

A plugin for implementing balancing of wrapping text in a web page
JavaScript
1,362
star
6

adobe.github.com

Adobe central hub for open source
CSS
1,290
star
7

spectrum-web-components

Spectrum Web Components
TypeScript
1,177
star
8

brackets-shell

CEF3-based application shell for Brackets.
Python
1,176
star
9

spectrum-css

The standard CSS implementation of the Spectrum design language.
CSS
1,154
star
10

aem-core-wcm-components

Standardized components to build websites with AEM.
Java
709
star
11

S3Mock

A simple mock implementation of the AWS S3 API startable as Docker image, TestContainer, JUnit 4 rule, JUnit Jupiter extension or TestNG listener
Java
699
star
12

jsonschema2md

Convert Complex JSON Schemas into Markdown Documentation
JavaScript
563
star
13

NLP-Cube

Natural Language Processing Pipeline - Sentence Splitting, Tokenization, Lemmatization, Part-of-speech Tagging and Dependency Parsing
HTML
549
star
14

aem-project-archetype

Maven template to create best-practice websites on AEM.
JavaScript
519
star
15

ferrum

Features from the rust language in javascript: Provides Traits/Type classes & a hashing infrastructure and an advanced library for working with sequences/iterators in js
JavaScript
496
star
16

brackets-app

Deprecated CEF1-based app shell for Brackets. Use https://github.com/adobe/brackets-shell instead.
C++
490
star
17

cryptr

Cryptr: a GUI for Hashicorp's Vault
HTML
487
star
18

cssfilterlab

CSS FilterLab
JavaScript
348
star
19

hyde

A front-end to Jekyll that parses C++ sources to produce and enforce out-of-line documentation
C++
303
star
20

node-smb-server

A 100% JavaScript implementation of the SMB file sharing protocol.
JavaScript
276
star
21

htl-spec

HTML Template Language Specification
275
star
22

aem-guides-wknd

Tutorial Code companion for Getting Started Developing with AEM Sites WKND Tutorial
JavaScript
261
star
23

lit-mobx

Mixin and base class for using mobx with lit-element
TypeScript
260
star
24

xdm

Experience Data Model
JavaScript
235
star
25

lagrange

A Robust Geometry Processing Library
C++
215
star
26

webkit

Experiments and contributions to WebKit. Tracks git://git.webkit.org/WebKit.git
213
star
27

chromium

Experiments and contributions to Chromium project
C++
207
star
28

elixir-styler

An @elixir-lang code-style enforcer that will just FIFY instead of complaining
Elixir
207
star
29

avmplus

Source code for the Actionscript virtual machine
ActionScript
194
star
30

ops-cli

Ops - cli wrapper for Terraform, Ansible, Helmfile and SSH for cloud automation
Python
186
star
31

pdf-embed-api-samples

Samples for Adobe Document Services PDF Embed API
JavaScript
155
star
32

Deep-Audio-Prior

Audio Source Separation Without Any Training Data.
Python
154
star
33

rules_gitops

This repository contains rules for continuous, GitOps driven Kubernetes deployments.
Starlark
151
star
34

aem-htl-repl

Readโ€“Evalโ€“Print Loop environment for HTL.
JavaScript
151
star
35

OSAS

One Stop Anomaly Shop: Anomaly detection using two-phase approach: (a) pre-labeling using statistics, Natural Language Processing and static rules; (b) anomaly scoring using supervised and unsupervised machine learning.
Python
150
star
36

stringlifier

Stringlifier is on Opensource ML Library for detecting random strings in raw text. It can be used in sanitising logs, detecting accidentally exposed credentials and as a pre-processing step in unsupervised ML-based analysis of application text data.
Python
148
star
37

Spry

Spry is a JavaScript-based framework that enables the rapid development of Ajax-powered web pages.
HTML
140
star
38

XMP-Toolkit-SDK

The XMP Toolkit allows you to integrate XMP functionality into your product or solution
C++
135
star
39

brackets-phonegap

A brackets extension for PhoneGap development.
JavaScript
112
star
40

brackets.io

brackets.io website
HTML
111
star
41

tf-manage

Shell
110
star
42

aem-component-generator

AEM Component Generator is a java project that enables developers to generate the base structure of an AEM component using a JSON configuration file specifying component and dialog properties and other configuration options.
Java
109
star
43

himl

A hierarchical yaml config in Python
Python
107
star
44

adobe-client-data-layer

An event-driven store for all trackable data of your site.
JavaScript
107
star
45

GLS3D

An implementation of OpenGL for Stage3D that can run inside Flash Player 11+
C
105
star
46

coral-spectrum

A JavaScript library of Web Components following Spectrum design patterns.
JavaScript
104
star
47

aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Java
101
star
48

aem-boilerplate

Use this repository template for new AEM projects.
JavaScript
99
star
49

react-webcomponent

This projects automates the wrapping of a React component in a CustomElement.
JavaScript
95
star
50

web-platform

JavaScript
90
star
51

ride

REST API Automation framework for functional, integration, fuzzing, and performance testing
Java
90
star
52

alloy

Alloy is the web SDK for the Adobe Experience Platform.
JavaScript
85
star
53

go-starter

Bootstrap a new project from a template.
Go
83
star
54

asset-share-commons

A modern, open-source asset share reference implementation built on Adobe Experience Manager (AEM)
Java
83
star
55

orc

ORC is a tool for finding violations of C++'s One Definition Rule on the OSX toolchain.
C++
79
star
56

experience-platform-postman-samples

77
star
57

pdfservices-node-sdk-samples

Samples for the Adobe Document Services PDF Tools Node SDK
HTML
77
star
58

sbmc

Sample-based Monte Carlo Denoising using a Kernel-Splatting Network [Siggraph 2019]
Python
76
star
59

git-server

A GitHub Protocol & API emulation
JavaScript
75
star
60

spectrum-tokens

Tokens used by Spectrum, Adobe's design system.
JavaScript
74
star
61

aio-theme

The Adobe I/O theme for building markdown powered sites
JavaScript
70
star
62

aem-sample-we-retail-journal

We.Retail Journal is a sample showcasing SPA Editing capabilities in AEM using React and Angular
CSS
69
star
63

aem-guides-wknd-spa

69
star
64

frontend-regression-validator

Visual regression tool used to compare baseline and updated instances of a website in a deployment pipeline.
Python
67
star
65

blackhole

An HTTP sink (for testing) with optional recording and playback ability
Go
65
star
66

aem-spa-project-archetype

Maven Archetype for creating new AEM SPA projects
CSS
63
star
67

aio-cli

Adobe I/O Extensible CLI
JavaScript
60
star
68

aem-upload

Makes uploading to AEM easier, and can be used as a command line executable or required as a Node.js module.
JavaScript
59
star
69

aem-modernize-tools

A suite of tools to modernize your AEM Sites implementations off legacy features.
Java
58
star
70

dds2atf

Tool for converting DDS files into ATF files suitable for use with the Flash Stage3D API
C++
58
star
71

redux-saga-promise

Create actions that return promises, which are resolved/rejected by a redux saga
JavaScript
58
star
72

aem-react-editable-components

SPA React Editable Components for Adobe Experience Manager
TypeScript
55
star
73

xmp-docs

XMP documentation
52
star
74

adobe-photoshop-api-sdk

Adobe Photoshop API SDK
JavaScript
50
star
75

aem-enablement

Content required for AEM Enablement
Java
50
star
76

brackets-edge-web-fonts

Edge Web Fonts extension for Brackets. Simply unzip and drop into your Brackets extension folder to browse and include Edge Web Fonts.
JavaScript
50
star
77

aem-brackets-extension

Brackets extension for Adobe Experience Manager (AEM) front-end developers with auto-sync and HTL support.
JavaScript
50
star
78

helix-home

The home of Project Helix
HTML
49
star
79

aem-testing-clients

Testing tools for Adobe Experience Manager
Java
49
star
80

aem-guides-wknd-graphql

JavaScript
47
star
81

brackets-registry

A registry system for hosting Brackets extensions powered by node.js
JavaScript
46
star
82

helix-cli

Command-line tools for developing with AEM
JavaScript
46
star
83

htlengine

An HTL (Sightly) Interpreter/Compiler for Node.js
HTML
45
star
84

aem-dispatcher-experiments

Experiments to demonstrate the impact of the Dispatcher and it's configuration parameters.
HTML
44
star
85

pdfservices-python-sdk-samples

Adobe PDFServices python SDK Samples
Python
44
star
86

node-fetch-retry

Node Module for performing retries using node-fetch
JavaScript
42
star
87

commerce-cif-connector

AEM Commerce connector for Magento and GraphQL
Java
42
star
88

aem-react-core-wcm-components

41
star
89

behavior_tree_editor

A visual editor for building behavior trees for the bots
JavaScript
41
star
90

libLOL

Python
40
star
91

starter-repo

Documentation templates for use in open source and open development projects
40
star
92

commerce-cif-magento

Adobe Commerce Integration Framework (CIF) Magento Integration
JavaScript
40
star
93

bin2c

Convert to/Embed binary files in C source files, quickly and efficiently.
C
38
star
94

graphicalweb-keynote

Keynote for Graphical Web Conference
JavaScript
37
star
95

aem-site-template-standard

Basic site template for AEM that allows non-Java experts to create new sites by customizing CSS and JS only.
SCSS
37
star
96

aio-cli-plugin-cloudmanager

Cloud Manager plugin for the Adobe I/O CLI
JavaScript
37
star
97

oss-contributors

How do tech companies rank amongst themselves when it comes to github.com activity?
JavaScript
35
star
98

aem-eclipse-developer-tools

The Eclipse plugin that brings you the full connection to the Adobe Experience Manager, with auto-sync and project creation wizard.
Java
35
star
99

fetch

Simplified HTTP/1(.1) and HTTP/2 requests with Server Push Support
JavaScript
34
star
100

PDFServices.NET.SDK.Samples

This .NET sample solution helps you get started with the Adobe PDF Services SDK.
HTML
33
star