NovaSVG 0.10.0
A header-only SVG library
Loading...
Searching...
No Matches
svgelement.h File Reference
#include <string>
#include <forward_list>
#include <list>
#include <map>
#include <unordered_map>
#include <optional>
#include <vector>
#include <cmath>
#include <cctype>
#include <set>
#include <cassert>
#include "svgparserutils.h"
Include dependency graph for svgelement.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  novasvg::SVGProperty
 
class  novasvg::SVGString
 
class  novasvg::Paint
 
class  novasvg::SVGEnumeration< Enum >
 
class  novasvg::SVGAngle
 
class  novasvg::Length
 
class  novasvg::SVGLength
 
class  novasvg::LengthContext
 
class  novasvg::SVGLengthList
 
class  novasvg::BaselineShift
 
class  novasvg::SVGNumber
 
class  novasvg::SVGNumberPercentage
 
class  novasvg::SVGNumberList
 
class  novasvg::SVGPath
 
class  novasvg::SVGPoint
 
class  novasvg::SVGPointList
 
class  novasvg::SVGRect
 
class  novasvg::SVGTransform
 
class  novasvg::SVGTransformBox
 
class  novasvg::SVGTransformOrigin
 
class  novasvg::SVGPreserveAspectRatio
 
class  novasvg::SVGNode
 
class  novasvg::SVGTextNode
 
class  novasvg::Attribute
 
class  novasvg::SVGElement
 
class  novasvg::SVGStyleElement
 
class  novasvg::SVGFitToViewBox
 
class  novasvg::SVGURIReference
 
class  novasvg::SVGPaintServer
 
class  novasvg::SVGGraphicsElement
 
class  novasvg::SVGSVGElement
 
class  novasvg::SVGRootElement
 
class  novasvg::SVGUseElement
 
class  novasvg::SVGImageElement
 
class  novasvg::ForeignObjectRenderer
 Renders the (HTML-ish) content captured inside a <foreignObject>. More...
 
class  novasvg::ForeignObjectSimple
 Default ForeignObjectRenderer: tag-stripped plain text, centered. More...
 
struct  novasvg::ForeignObjectFonts
 The faces a <foreignObject> can paint with: its own font plus the bold / italic variants of it that , , , and inline font-weight / font-style ask for. More...
 
class  novasvg::SVGForeignObjectElement
 
class  novasvg::SVGSymbolElement
 
class  novasvg::SVGGElement
 
class  novasvg::SVGSwitchElement
 
class  novasvg::SVGDefsElement
 
class  novasvg::SVGMarkerElement
 
class  novasvg::SVGClipPathElement
 
class  novasvg::SVGMaskElement
 
class  novasvg::SVGFilterContext
 
class  novasvg::SVGFEGaussianBlurElement
 
class  novasvg::SVGFEOffsetElement
 
class  novasvg::SVGFEFloodElement
 
class  novasvg::SVGFEMergeElement
 
class  novasvg::SVGFECompositeElement
 
class  novasvg::SVGFEDropShadowElement
 
class  novasvg::SVGFilterElement
 
class  novasvg::SVGBlendInfo
 
class  novasvg::SVGRenderState
 
class  novasvg::SVGPaintElement
 
class  novasvg::SVGStopElement
 
class  novasvg::SVGGradientElement
 
class  novasvg::SVGGradientAttributes
 
class  novasvg::SVGLinearGradientElement
 
class  novasvg::SVGLinearGradientAttributes
 
class  novasvg::SVGRadialGradientElement
 
class  novasvg::SVGRadialGradientAttributes
 
class  novasvg::SVGPatternElement
 
class  novasvg::SVGPatternAttributes
 
class  novasvg::SVGMarkerPosition
 
class  novasvg::SVGGeometryElement
 
class  novasvg::SVGLineElement
 
class  novasvg::SVGRectElement
 
class  novasvg::SVGEllipseElement
 
class  novasvg::SVGCircleElement
 
class  novasvg::SVGPolyElement
 
class  novasvg::SVGPathElement
 
struct  novasvg::SVGCharacterPosition
 
struct  novasvg::SVGTextPosition
 
struct  novasvg::SVGTextFragment
 
class  novasvg::SVGTextFragmentsBuilder
 
class  novasvg::SVGTextPositioningElement
 
class  novasvg::SVGTSpanElement
 
class  novasvg::SVGTextElement
 
class  novasvg::SVGLayoutState
 
struct  novasvg::ForeignObjectMetrics
 Metrics for how ForeignObjectSimple::render() will lay out and size a <foreignObject>'s content, computed WITHOUT actually rendering it. More...
 

Namespaces

namespace  novasvg
 Main namespace for the NovaSVG library.
 
namespace  novasvg::Specificity
 

Typedefs

template<typename Enum >
using novasvg::SVGEnumerationEntry = std::pair< Enum, std::string_view >
 
using novasvg::LengthList = std::vector< Length >
 
using novasvg::NumberList = std::vector< float >
 
using novasvg::PointList = std::vector< Point >
 
using novasvg::AttributeList = std::forward_list< Attribute >
 
using novasvg::SVGNodeList = std::list< std::unique_ptr< SVGNode > >
 
using novasvg::SVGPropertyList = std::forward_list< SVGProperty * >
 
using novasvg::SVGMarkerPositionList = std::vector< SVGMarkerPosition >
 
using novasvg::SVGCharacterPositions = std::map< size_t, SVGCharacterPosition >
 
using novasvg::SVGTextPositionList = std::vector< SVGTextPosition >
 
using novasvg::SVGTextFragmentList = std::vector< SVGTextFragment >
 
using novasvg::SVGTextFragmentIterator = SVGTextFragmentList::iterator
 

Enumerations

enum class  novasvg::PropertyID : uint8_t {
  novasvg::Unknown = 0 , novasvg::Alignment_Baseline , novasvg::Background_Color , novasvg::Baseline_Shift ,
  novasvg::Class , novasvg::Clip_Path , novasvg::Clip_Rule , novasvg::ClipPathUnits ,
  novasvg::Color , novasvg::Cx , novasvg::Cy , novasvg::D ,
  novasvg::Direction , novasvg::Display , novasvg::Dominant_Baseline , novasvg::Dx ,
  novasvg::Dy , novasvg::Fill , novasvg::Fill_Opacity , novasvg::Fill_Rule ,
  novasvg::Filter , novasvg::Flood_Color , novasvg::Flood_Opacity , novasvg::Font_Family ,
  novasvg::Font_Size , novasvg::Font_Style , novasvg::Font_Weight , novasvg::Fx ,
  novasvg::Fy , novasvg::GradientTransform , novasvg::GradientUnits , novasvg::Height ,
  novasvg::Href , novasvg::Id , novasvg::In , novasvg::In2 ,
  novasvg::K1 , novasvg::K2 , novasvg::K3 , novasvg::K4 ,
  novasvg::LengthAdjust , novasvg::Letter_Spacing , novasvg::Marker_End , novasvg::Marker_Mid ,
  novasvg::Marker_Start , novasvg::MarkerHeight , novasvg::MarkerUnits , novasvg::MarkerWidth ,
  novasvg::Mask , novasvg::Mask_Type , novasvg::MaskContentUnits , novasvg::MaskUnits ,
  novasvg::Mix_Blend_Mode , novasvg::Offset , novasvg::Opacity , novasvg::Operator ,
  novasvg::Orient , novasvg::Overflow , novasvg::PatternContentUnits , novasvg::PatternTransform ,
  novasvg::PatternUnits , novasvg::Pointer_Events , novasvg::Points , novasvg::PreserveAspectRatio ,
  novasvg::R , novasvg::RefX , novasvg::RefY , novasvg::RequiredExtensions ,
  novasvg::Result , novasvg::Rotate , novasvg::Rx , novasvg::Ry ,
  novasvg::SpreadMethod , novasvg::StdDeviation , novasvg::Stop_Color , novasvg::Stop_Opacity ,
  novasvg::Stroke , novasvg::Stroke_Dasharray , novasvg::Stroke_Dashoffset , novasvg::Stroke_Linecap ,
  novasvg::Stroke_Linejoin , novasvg::Stroke_Miterlimit , novasvg::Stroke_Opacity , novasvg::Stroke_Width ,
  novasvg::Style , novasvg::SystemLanguage , novasvg::Text_Anchor , novasvg::Text_Orientation ,
  novasvg::TextLength , novasvg::Transform , novasvg::Transform_Box , novasvg::Transform_Origin ,
  novasvg::ViewBox , novasvg::Visibility , novasvg::White_Space , novasvg::Width ,
  novasvg::Word_Spacing , novasvg::Writing_Mode , novasvg::X , novasvg::X1 ,
  novasvg::X2 , novasvg::Y , novasvg::Y1 , novasvg::Y2
}
 
enum class  novasvg::Display : uint8_t { novasvg::Inline , novasvg::None }
 
enum class  novasvg::Visibility : uint8_t { novasvg::Visible , novasvg::Hidden , novasvg::Collapse }
 
enum class  novasvg::Overflow : uint8_t { novasvg::Visible , novasvg::Hidden }
 
enum class  novasvg::MixBlendMode : uint8_t {
  novasvg::Normal , novasvg::Multiply , novasvg::Screen , novasvg::Darken ,
  novasvg::Lighten , novasvg::Difference , novasvg::Exclusion
}
 
enum class  novasvg::PointerEvents : uint8_t {
  novasvg::None , novasvg::Auto , novasvg::Stroke , novasvg::Fill ,
  novasvg::Painted , novasvg::Visible , novasvg::VisibleStroke , novasvg::VisibleFill ,
  novasvg::VisiblePainted , novasvg::BoundingBox , novasvg::All
}
 
enum class  novasvg::FontStyle : uint8_t { novasvg::Normal , novasvg::Italic }
 
enum class  novasvg::FontWeight : uint8_t { novasvg::Normal , novasvg::Bold }
 
enum class  novasvg::AlignmentBaseline : uint8_t {
  novasvg::Auto , novasvg::Baseline , novasvg::BeforeEdge , novasvg::TextBeforeEdge ,
  novasvg::Middle , novasvg::Central , novasvg::AfterEdge , novasvg::TextAfterEdge ,
  novasvg::Ideographic , novasvg::Alphabetic , novasvg::Hanging , novasvg::Mathematical
}
 
enum class  novasvg::DominantBaseline : uint8_t {
  novasvg::Auto , novasvg::UseScript , novasvg::NoChange , novasvg::ResetSize ,
  novasvg::Ideographic , novasvg::Alphabetic , novasvg::Hanging , novasvg::Mathematical ,
  novasvg::Central , novasvg::Middle , novasvg::TextAfterEdge , novasvg::TextBeforeEdge
}
 
enum class  novasvg::TextAnchor : uint8_t { novasvg::Start , novasvg::Middle , novasvg::End }
 
enum class  novasvg::WhiteSpace : uint8_t { novasvg::Default , novasvg::Preserve }
 
enum class  novasvg::WritingMode : uint8_t { novasvg::Horizontal , novasvg::Vertical }
 
enum class  novasvg::TextOrientation : uint8_t { novasvg::Mixed , novasvg::Upright }
 
enum class  novasvg::Direction : uint8_t { novasvg::Ltr , novasvg::Rtl }
 
enum class  novasvg::MaskType : uint8_t { novasvg::Luminance , novasvg::Alpha }
 
enum class  novasvg::Units : uint8_t { novasvg::UserSpaceOnUse , novasvg::ObjectBoundingBox }
 
enum class  novasvg::MarkerUnits : uint8_t { novasvg::StrokeWidth , novasvg::UserSpaceOnUse }
 
enum class  novasvg::LengthAdjust : uint8_t { novasvg::Spacing , novasvg::SpacingAndGlyphs }
 
enum class  novasvg::LengthUnits : uint8_t {
  novasvg::None , novasvg::Percent , novasvg::Px , novasvg::Em ,
  novasvg::Ex
}
 
enum class  novasvg::LengthDirection : uint8_t { novasvg::Horizontal , novasvg::Vertical , novasvg::Diagonal }
 
enum class  novasvg::LengthNegativeMode : uint8_t { novasvg::Allow , novasvg::Forbid }
 
enum class  novasvg::TransformBoxType : uint8_t { novasvg::ViewBox , novasvg::FillBox }
 
enum class  novasvg::ElementID : uint8_t {
  novasvg::Unknown = 0 , novasvg::Star , novasvg::Circle , novasvg::ClipPath ,
  novasvg::Defs , novasvg::Ellipse , novasvg::FeComposite , novasvg::FeDropShadow ,
  novasvg::FeFlood , novasvg::FeGaussianBlur , novasvg::FeMerge , novasvg::FeMergeNode ,
  novasvg::FeOffset , novasvg::Filter , novasvg::ForeignObject , novasvg::G ,
  novasvg::Image , novasvg::Line , novasvg::LinearGradient , novasvg::Marker ,
  novasvg::Mask , novasvg::Path , novasvg::Pattern , novasvg::Polygon ,
  novasvg::Polyline , novasvg::RadialGradient , novasvg::Rect , novasvg::Stop ,
  novasvg::Style , novasvg::Svg , novasvg::Switch , novasvg::Symbol ,
  novasvg::Text , novasvg::Tspan , novasvg::Use
}
 
enum class  novasvg::SVGRenderMode { novasvg::Painting , novasvg::Clipping }
 

Functions

PropertyID novasvg::propertyid (std::string_view name)
 
PropertyID novasvg::csspropertyid (std::string_view name)
 
ElementID novasvg::elementid (std::string_view name)
 
const SVGElement * novasvg::toSVGElement (const SVGNode *node)
 
SVGElement * novasvg::toSVGElement (SVGNode *node)
 
SVGElement * novasvg::toSVGElement (const std::unique_ptr< SVGNode > &node)
 
NOVASVG_INLINE GradientStops novasvg::buildGradientStops (const SVGGradientElement *element, float opacity)
 
const SVGTextNode * novasvg::toSVGTextNode (const SVGNode *node)
 
const SVGTextPositioningElement * novasvg::toSVGTextPositioningElement (const SVGNode *node)
 
NOVASVG_INLINE AlignmentBaseline novasvg::resolveDominantBaseline (const SVGTextPositioningElement *element)
 
NOVASVG_INLINE float novasvg::calculateBaselineOffset (const SVGTextPositioningElement *element)
 
NOVASVG_INLINE bool novasvg::needsTextAnchorAdjustment (const SVGTextPositioningElement *element)
 
NOVASVG_INLINE float novasvg::calculateTextAnchorOffset (const SVGTextPositioningElement *element, float width)
 
NOVASVG_INLINE float novasvg::calculateTextChunkLength (SVGTextFragmentIterator begin, SVGTextFragmentIterator end, bool isVerticalText)
 
NOVASVG_INLINE void novasvg::handleTextChunk (SVGTextFragmentIterator begin, SVGTextFragmentIterator end)
 
NOVASVG_INLINE std::optional< Color > novasvg::parseColorValue (std::string_view &input, const SVGLayoutState *state)
 
NOVASVG_INLINE Color novasvg::parseColor (std::string_view input, const SVGLayoutState *state, const Color &defaultValue)
 
NOVASVG_INLINE Color novasvg::parseColorOrNone (std::string_view input, const SVGLayoutState *state, const Color &defaultValue)
 
NOVASVG_INLINE bool novasvg::parseUrlValue (std::string_view &input, std::string &value)
 
NOVASVG_INLINE std::string novasvg::parseUrl (std::string_view input)
 
NOVASVG_INLINE Paint novasvg::parsePaint (std::string_view input, const SVGLayoutState *state, const Color &defaultValue)
 
NOVASVG_INLINE float novasvg::parseNumberOrPercentage (std::string_view input, bool allowPercentage, float defaultValue)
 
NOVASVG_INLINE Length novasvg::parseLength (std::string_view input, LengthNegativeMode mode, const Length &defaultValue)
 
NOVASVG_INLINE BaselineShift novasvg::parseBaselineShift (std::string_view input)
 
NOVASVG_INLINE LengthList novasvg::parseDashArray (std::string_view input)
 
NOVASVG_INLINE Length novasvg::parseLengthOrNormal (std::string_view input)
 
NOVASVG_INLINE float novasvg::parseFontSize (std::string_view input, const SVGLayoutState *state)
 
template<typename Enum , unsigned int N>
NOVASVG_INLINE Enum novasvg::parseEnumValue (std::string_view input, const SVGEnumerationEntry< Enum >(&entries)[N], Enum defaultValue)
 
NOVASVG_INLINE Display novasvg::parseDisplay (std::string_view input)
 
NOVASVG_INLINE Visibility novasvg::parseVisibility (std::string_view input)
 
NOVASVG_INLINE Overflow novasvg::parseOverflow (std::string_view input)
 
NOVASVG_INLINE PointerEvents novasvg::parsePointerEvents (std::string_view input)
 
NOVASVG_INLINE FontWeight novasvg::parseFontWeight (std::string_view input)
 
NOVASVG_INLINE FontStyle novasvg::parseFontStyle (std::string_view input)
 
NOVASVG_INLINE AlignmentBaseline novasvg::parseAlignmentBaseline (std::string_view input)
 
NOVASVG_INLINE DominantBaseline novasvg::parseDominantBaseline (std::string_view input)
 
NOVASVG_INLINE Direction novasvg::parseDirection (std::string_view input)
 
NOVASVG_INLINE WritingMode novasvg::parseWritingMode (std::string_view input)
 
NOVASVG_INLINE TextOrientation novasvg::parseTextOrientation (std::string_view input)
 
NOVASVG_INLINE TextAnchor novasvg::parseTextAnchor (std::string_view input)
 
NOVASVG_INLINE WhiteSpace novasvg::parseWhiteSpace (std::string_view input)
 
NOVASVG_INLINE MixBlendMode novasvg::parseMixBlendMode (std::string_view input)
 
NOVASVG_INLINE MaskType novasvg::parseMaskType (std::string_view input)
 
NOVASVG_INLINE FillRule novasvg::parseFillRule (std::string_view input)
 
NOVASVG_INLINE LineCap novasvg::parseLineCap (std::string_view input)
 
NOVASVG_INLINE LineJoin novasvg::parseLineJoin (std::string_view input)
 
NOVASVG_INLINE Font novasvg::makeFont (const std::string &family, float size, bool bold, bool italic)
 
bool novasvg::isDisallowedElement (const SVGElement *element)
 
NOVASVG_INLINE Bitmap novasvg::loadImageResource (const std::string &href)
 
ForeignObjectMetrics novasvg::measureForeignObjectSegments (std::string_view rawHtml, const std::vector< ForeignObjectSegment > &segments, const ForeignObjectFonts &fonts, unsigned char baseStyle, float maxWidth)
 Measures what ForeignObjectMetrics::height (etc.) will be for rawHtml painted with font, using the exact same foreignObjectPlainText() / wrapForeignObjectText() / foreignObjectLineHeight() logic ForeignObjectSimple::render() itself calls – so a value computed here and a box later painted by novasvg with the same (rawHtml, font) can never disagree, short of a bug in this shared logic itself.
 
ForeignObjectMetrics novasvg::measureForeignObjectContent (std::string_view rawHtml, const ForeignObjectFonts &fonts, float maxWidth=-1.f, unsigned char baseStyle=0)
 measureForeignObjectContent() for text that may carry bold and italic: fonts supplies the face for each style (see ForeignObjectFonts; SVGForeignObjectElement::fontsFor() builds it the way painting does), baseStyle is the style the foreignObject itself has. This is exactly what painting does, so the metrics and the painted box cannot disagree about a bold label being wider than a regular one.
 
ForeignObjectMetrics novasvg::measureForeignObjectContent (std::string_view rawHtml, const Font &font, float maxWidth=-1.f)
 measureForeignObjectContent() with a single face: every style is measured with font, i.e. as if the text had no bold or italic in it. Line breaks and heights are unaffected by bold or italic; only the widths of styled stretches can differ from what painting produces, by however much the real bold/italic faces differ from font. Use the ForeignObjectFonts overload when that matters.
 
bool novasvg::switchChildPasses (const SVGElement *child)
 
const SVGGeometryElement * novasvg::toSVGGeometryElement (const SVGNode *node)
 

Variables

const std::string novasvg::emptyString
 

Variable Documentation

◆ isPixels

bool isPixels

Definition at line 6257 of file svgelement.h.

◆ raw

float raw

Definition at line 6256 of file svgelement.h.

◆ style

◆ text