Difference between revisions of "SVG"

From Wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
SVG (Scalable Vector Graphics, a [[XML]] based format) can be converted to the PDF format at runtime by ConTeXt MkIV (LuaTeX), provided you have Inkscape installed as below.
 
SVG (Scalable Vector Graphics, a [[XML]] based format) can be converted to the PDF format at runtime by ConTeXt MkIV (LuaTeX), provided you have Inkscape installed as below.
  
Supported vector graphics formats of MkII/MKIV are [[MetaPost]] (and [[MetaFun]]).
+
Supported vector graphics formats of MkII/MKIV are [[MetaPost]] (and [[MetaFun - MetaPost in ConTeXt|MetaFun]]).
  
 
There is a workaround, though, using Inkscape to convert SVG to PDF. Inkscape must be installed and callable (i.e. in your PATH):
 
There is a workaround, though, using Inkscape to convert SVG to PDF. Inkscape must be installed and callable (i.e. in your PATH):
Line 22: Line 22:
 
As a consequence, if you use an old version of ConTeXt and you have Inkscape 1.0 or newer installed, the conversion from SVG to PDF fails.
 
As a consequence, if you use an old version of ConTeXt and you have Inkscape 1.0 or newer installed, the conversion from SVG to PDF fails.
  
Newer versions of ConTeXt (since the second half of May 2020) will detect Inkscape's version and manage to convert SVG to PDF anyway.
+
Newer versions of ConTeXt (since May 7th, 2020) will detect Inkscape's version and manage to convert SVG to PDF anyway.
 
But it's a temporary workaround, until version 1.0 of Inkscape gets widespread, because version detection has a performance cost.
 
But it's a temporary workaround, until version 1.0 of Inkscape gets widespread, because version detection has a performance cost.
  
 
== LMTX and SVG ==
 
== LMTX and SVG ==
  
LMTX has a direct support for SVG. It uses MetaPost (MetaFun) to process SVG, so you don't need an external tool like Inkscape.
+
LMTX uses MetaPost (MetaFun) to process SVG directly; a third-party tool, such as Inkscape, is no longer needed. Using MetaPost to process SVG opens many opportunities. It's a work in progress and not every SVG feature is supported. If you encounter issues, send a question to the mailing list.
  
Using MetaPost to process SVG opens many opportunities to work on it.
+
See the LMTX distribution documentation, svg-lmtx.pdf and luametafun.pdf, for more details.
  
Anyway it's a work in progress, not every feature (or inconsistency) of SVG is supported, though many are.
+
=== Text Rendering ===
Just try and ask in the mailing list.
 
  
You can find more in the docs that come with LMTX distribution, in particular in svg-lmtx.pdf and luametafun.pdf.
+
Pixel-perfect rendering of SVG text elements may not align as desired in all cases. To work around any layout issues, convert the text to a path. This can be accomplished in Inkscape as follows:
 +
 
 +
# Open the SVG file.
 +
# Select all text elements.
 +
# Click '''Path > Object to Path'''.
 +
# Save the SVG file.
 +
 
 +
Rebuild the document again, the text elements will now be placed correctly.
  
 
==General information on SVG:==
 
==General information on SVG:==
Line 49: Line 55:
  
 
===Community===
 
===Community===
* [http://wiki.svg.org/Main_Page SVG Wiki]
+
* [https://web.archive.org/web/20100212202713/http://wiki.svg.org/Main_Page SVG Wiki]
* [http://svg.org/ SVG.org community]
+
* [https://web.archive.org/web/20100208221439/http://www.svg.org/SVG.org community]
 +
 
 +
Note: The original links no longer work so the above are from the Wayback Machine. It may be better to remove this section completely.
  
 
===Libraries and Tools===
 
===Libraries and Tools===

Latest revision as of 15:58, 2 March 2024

< Graphics | Using_Graphics | MetaPost | File_Formats | Inkscape >

SVG (Scalable Vector Graphics, a XML based format) can be converted to the PDF format at runtime by ConTeXt MkIV (LuaTeX), provided you have Inkscape installed as below.

Supported vector graphics formats of MkII/MKIV are MetaPost (and MetaFun).

There is a workaround, though, using Inkscape to convert SVG to PDF. Inkscape must be installed and callable (i.e. in your PATH):

\setupexternalfigures[location=local,directory=.,conversion=pdf] % lowres,prefix=lowres/]

\starttext

\externalfigure[svg/sample.svg][frame=on]

\stoptext

ConTeXt and Inkscape

Inkscape changed its command line interface in version 1.0. As a consequence, if you use an old version of ConTeXt and you have Inkscape 1.0 or newer installed, the conversion from SVG to PDF fails.

Newer versions of ConTeXt (since May 7th, 2020) will detect Inkscape's version and manage to convert SVG to PDF anyway. But it's a temporary workaround, until version 1.0 of Inkscape gets widespread, because version detection has a performance cost.

LMTX and SVG

LMTX uses MetaPost (MetaFun) to process SVG directly; a third-party tool, such as Inkscape, is no longer needed. Using MetaPost to process SVG opens many opportunities. It's a work in progress and not every SVG feature is supported. If you encounter issues, send a question to the mailing list.

See the LMTX distribution documentation, svg-lmtx.pdf and luametafun.pdf, for more details.

Text Rendering

Pixel-perfect rendering of SVG text elements may not align as desired in all cases. To work around any layout issues, convert the text to a path. This can be accomplished in Inkscape as follows:

  1. Open the SVG file.
  2. Select all text elements.
  3. Click Path > Object to Path.
  4. Save the SVG file.

Rebuild the document again, the text elements will now be placed correctly.

General information on SVG:

Specs and References

Tutorials and Examples

Community

Note: The original links no longer work so the above are from the Wayback Machine. It may be better to remove this section completely.

Libraries and Tools