

The above example states that if the renderer has a local font available named "Super Sans Bold", it should use this instead.įollowing is a element. You can point to external sources for font declarations by means of its children and. Its child, the element, corresponds to CSS' src descriptor in declarations. All following attributes are rendering instructions for the font layout engine, for example, how much of the glyphs' overall heights are ascenders. The font-weight and font-style attributes have the same purpose as the equivalent descriptors in CSS. In the example above the first and most important to be defined is font-family, the value of which can then be referenced in CSS and SVG font-family properties. It defines basic properties of the final font such as weight, style, etc. The element is the SVG equivalent of the CSS declaration. There are several accompanying attributes that help further define the basic glyph-box layout. The value 1000 sets a reasonable value to work with. The horiz-adv-x attribute determines how wide a character is on average compared to the path definitions of the single glyphs. This bears an id attribute, to enable it to be referenced via a URI (see below). This implementation can be seen live in Wildbit’s Good & Bad section or as a CodePen.We start with the element. Considering the outlines are the same color as backgrounds, it’s hard to even say that they are there, but the text is much easier to read. That’s it! The text now scales based on media queries just as any other title in the project, only with nice outlines. Window.addEventListener('resize', svgTitles) Window.addEventListener('DOMContentLoaded', svgTitles)


Var svgs = document.querySelectorAll('svg')
Font color boxy svg update#
Wish I could avoid this, but I had to add a few lines of JS to update the viewBox value based on the size of the element: function resizeTitle (el) `) I could easily scale it as an image, but I’d rather keep the font size consistent with other titles and media queries in the projects. The only problem is that SVG has a fixed size (see viewBox) and doesn’t scale well.
