What is the new syntax for SVG fonts? - svg

I was browsing SVG fonts in MDN, where it is mentioned that <font-face>, <missing-glyph>, <hkern> and <vkern> are depreciated. Only <glyph> is not depreciated. It does not mention anything about a recommended way of specifying the font face properties.
The W3C SVG recommendation also does not say anything about an alternative way of specifying SVG fonts, apart from noting that everything in the <font-face> can be done equivalently in CSS. It does not provide any alternative for <hkern> or <vkern>. I intend to create a standalone SVG file, not to be modified by the site CSS, so I would like to keep the whole font definition in the SVG.
So, what is this obscure new way of specifying SVG fonts?

"SVG fonts" as a data file that uses SVG markup to define a font resource has been deprecated; it turned out to be a bad idea, and ended up not addressing the issues that typography on the web needed addressing. It was added in SVG 1.1 but removed again in SVG 2.0, and almost all browsers that did end up adding support for it removed that support again since.
Instead, all browsers now support "webfonts": regular OpenType fonts packed for the web using the "Web Open Font Format", aka WOFF/WOFF2, based on the OpenType format, which supports several different outline types:
TrueType (quadratic curves and compound glyphs, often with ttf extension, but the extension is literally irrelevant)
Type2 in CFF/CFF2 (cubic curves and arbitrary subroutines, often with otf extension, but again: the extension is wholly irrelevant)
Embedded bitmaps (yes, OpenType fonts can indeed be true bitmap fonts, with as many different bitmaps as necessary to cover as many pixel sizes as necessary)
SVG (that might be surprising, but SVG is the exact same kind of vector graphics language as TT and CFF/CFF2 are, so it made sense to allow glyph outline data to be specified using SVG as well, particularly for fonts that need explicit colour palettes, like emoji fonts)
So if you absolutely need to keep your SVG data around, then make yourself an OpenType-with-SVG-outlines font, and then pack that for the web as a modern WOFF2 (or older WOFF) and you're good to go. There are plenty of online tools to do that for you, but you can also just use something like the open source FontForge application if you want a font that only includes what you need, instead of what online tools foist into them.

Related

Do svg fonts have ligature tables?

Do svg fonts use ligature tables? If so, can you point me to an example of what one would look like (it doesn't have to have glyph data)?
I just wanted to make sure before I go changing font data that I exported from out of font forge.
Thank you!
I'm going to assume you are referring to the type of font with an .svg extension. And not OpenType fonts that contain SVG-based glyphs.
Information on the capabilities of SVG fonts can be found in the SVG Specification.
The answer is no. SVG fonts are very primitive. They support kerning, and that's about it.
It's also worth pointing out that SVG fonts are deprecated now. It has been removed from the draft SVG 2 specification. And support is gradually being removed from browsers.

imagemagick.net embedded fonts

Does anyone have experience or insights into how to convert SVG to PNG using ImageMagick.NET where the SVG has custom embedded fonts?
I've seen similar posts about this, but I'm specifically interested in ImageMagick.net and I would like to avoid calling anything from command line. I currently use Batik, but I want to move this to Azure and I don't want to go through starting the JVM so that the JAR file can be executed.
Note additionally, my problem is that I am getting the SVG from another party and most fonts are not freely available, so I can't just pre-install all potential fonts.
Many thanks for any insight.
I don't know anything about azure platform, but I can share some insight on the SVG process within ImageMagick. This is more of a long-winded comment than an answer
ImageMagick (of which Magick.net sets on top of) performs tasks on raster images, so any vector input must be "decoded" into a raster image before any additional work be be done. For SVG images, I'm aware of three ways ImageMagick can render vector graphics into authenticated pixels.
Use a primitive internal MSVG coder to draw each shape.
Pass the rendering work to librsvg if compiled with delegate library support. (Usually on *NIX systems)
Call an external command-line application. Identical to the suggestions referenced in the links you provided.
If I would map it out, I would imagine it would look something like this.
SVG Fonts with MSVG (option #1)
I believe this is the option your asking about as it would be the default configuration for must ImageMagick installs. For a font to be rendered, the typeface must be found on the system, and supported by freetype (.ttf or .otf files). Embedded fonts are usually base64 ttf files attached inline under the #font-face CSS at-rule. If this is true, you should be able to preprocess the document, extract the font-file to a local/temporary filesystem, and assign it with MagickReadSettings.FontFamily before reading the SVG document. Although I'm not sure if this would work with multiple fonts.
SVG Fonts with RSVG (option #2)
The librsvg offers a lot more support for SVG specs then the internal renderer, but also enforces more restricted approach for external resources. There's also an open issue with adding support to #font-face, so you might be forced to do option #1 anyway.
External Command-line (option #3)
This would be your best option. ImageMagick's delegate.xml file can be altered to call other utilities. Inkscape, for example, can be called by ImageMagick with the following rule..
<delegate decode="svg" command="inkscape.exe -e %o %i"/>
Although I'm not sure if inkscape is a good example as support for CSS fonts are still listed on a wishlist.
TL;DR
... convert SVG to PNG using ImageMagick.NET where the SVG has custom embedded fonts?
All-n-all, it boils down to the right tool for the right job. If your only use-case is converting SVG+CSS to PNG, and you have no additional raster manipulation tasks, a direct utility like batik is more appropriate than ImageMagick. Like it or not, installing a JRE to execute a JAR file might be the best option. Magick.net by itself doesn't meet your requirements.

How to force conversion of glyphs to embedded vector paths in Inkscape

I have created an SVG document with Inkscape. It contains text in a non-standard font. The svg xml references the font. So, the vector has a dependency on the font being available on the users machine (or by using web fonts in a web scenario). I want to remove this dependency. I know how to do it manually, but it would be time consuming.
Does Inkscape provide a way to include the required glyphs as pure vectors instead of referencing the font?
You can transform all glyphs to vectors by selecting them and using the object to path function (Path->Object to Path).
Select the text(s) you want to convert to paths, then select "Path > Object to Path".
If the font license allows it you could also use it as a webfont, by adding some css to the svg file, see this example. Inkscape doesn't support webfonts AFAIK, but for editing I guess it might still work if you have the same font installed on your system.

TextRenderer.DrawText using GDI to render OTF Fonts?

I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString in the least bit.
First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly?
Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It looks like I have to use the System.Drawing.Font class, but I don't think those support the fonts and that's the issue, correct?
How do I get the fonts to render clearly like the TTF fonts using GDI+ (Graphics.DrawString)
Using Graphics.DrawString I was able to use a RectangleF (with specified width, 0 height) as a boundary for my text, and the text wrapped correctly. With TextRenderer.DrawText, the ability to use RectangleF disappears and only allows Rectangle which doesn't seem to allow 0 height, while still allowing text to display (ie. text must be within the rectangle, and text wrapping does not work). Am I doing it wrong?
Any help would be greatly appreciated. If this cannot be done, is there a way to convert the OTF fonts, or find the Gotham font family online in TTF version? I really need these fonts!

Any advantage to using SVG font in #font-face instead of TTF/EOT?

I am investigating the usage of SVG fonts in #font-face declaration. So far, only Safari 4 and Opera 10 seem to support it. Firefox 3.5 does not support it but there is a bug report but no fix has been supplied yet (though there are patches).
I am wondering, with #font-face support in major browsers, what is the advantage of using SVG font format in lieu of TTF/OTF/EOT formats? The only advantage I can glean from the discussion linked above was that you can add your own missing gylphs to fonts that do not support them yet.
Is there any other reason to specify SVG fonts in CSS?
It seems to be the only way to use web fonts on Mobile Safari. So that's a pretty big advantage if you're developing for iPhones and iPads. Font Squirrel's #font-face generator can create the appropriate SVG file and CSS syntax from any OpenType font.
The W3C states these advantages:
One disadvantage to the WebFont facility to date is that specifications such as [CSS2] do not require support of particular font formats. The result is that different implementations support different Web font formats, thereby making it difficult for Web site creators to post a single Web site using WebFonts that work across all user agents.
To provide a common font format for SVG that is guaranteed to be supported by all conforming SVG viewers, SVG provides a facility to define fonts in SVG. This facility is called SVG fonts.
SVG fonts can improve the semantic richness of graphics that represent text. For example, many company logos consist of the company name drawn artistically. In some cases, accessibility may be enhanced by expressing the logo as a series of glyphs in an SVG font and then rendering the logo as a 'text' element which references this font.
But the point of a common format doesn't really count because of the lacking browser support.
svg webfonts cannot work within an offline webapp. You can see an example here: http://straathof.acadnet.ca/beta2.2 Save this file to an idevice homepage, turn on airplane mode and open it. The svg fonts and the naming system used cause the font url to fail.
hopefully Apple fixes that soon.

Resources