Class SvgProcessor
- Namespace
- EncDotNet.S100.Portrayals
- Assembly
- EncDotNet.S100.Portrayals.dll
Processes S-100 SVG symbols by resolving CSS class-based styling to inline attributes, removing layout/metadata elements, and stripping processing instructions that reference external CSS stylesheets.
public static class SvgProcessor
- Inheritance
-
SvgProcessor
- Inherited Members
Remarks
S-100 Part 9 defines SVG symbols using CSS classes that reference colour tokens from the active colour palette. This processor converts those classes to inline attributes so the SVG can be rendered without external CSS resources.
CSS class conventions:
fTOKEN— fill colour (e.g.fCHBLK→fill:#000000)sTOKEN— stroke colour (e.g.sOUTLW→stroke:#464646)f0— fill:nonesl— round line caps and joinslayout— layout-only elements (not rendered)
Methods
Process(string, ColorPalette?, double?)
Processes an S-100 SVG symbol by:
- Removing
<?xml-stylesheet?>processing instructions - Removing layout elements (symbolBox, svgBox, pivotPoint)
- Resolving CSS class names to inline style attributes using the given palette
- Optionally scaling
stroke-widthvalues by a given factor - Removing metadata, title, and desc elements
public static string Process(string svgContent, ColorPalette? palette, double? strokeWidthScale = null)
Parameters
svgContentstringThe raw SVG content string.
paletteColorPaletteThe colour palette to resolve tokens against. When
null, tokens are resolved to black as a fallback.strokeWidthScaledouble?Optional multiplier applied to all
stroke-widthattribute values. Passnullto leave stroke widths in their original mm units. For example, pass3.78to convert mm to pixels at 96 DPI.
Returns
- string
The processed SVG content string with inline styles and no external dependencies.