| 1 | # Librsvg |
| 2 | |
| 3 | This is librsvg - A small library to render Scalable Vector Graphics |
| 4 | ([SVG][svg]), associated with the [GNOME Project][gnome]. It renders |
| 5 | SVG files to [Cairo][cairo] surfaces. Cairo is the 2D, antialiased |
| 6 | drawing library that GNOME uses to draw things to the screen or to |
| 7 | generate output for printing. |
| 8 | |
| 9 | Do you want to render non-animated SVGs to a Cairo surface with a |
| 10 | minimal API? Librsvg may be adequate for you. |
| 11 | |
| 12 | **Supported SVG/CSS features:** Please see the chapter for [supported |
| 13 | features][features] in the development guide. |
| 14 | |
| 15 | This is the `README.md` file for the Rust crate; you may want to see |
| 16 | the [main |
| 17 | README.md](https://gitlab.gnome.org/GNOME/librsvg/-/blob/main/README.md) |
| 18 | for the whole project. |
| 19 | |
| 20 | ## Using librsvg |
| 21 | |
| 22 | * [Rust API documentation][rust-docs] |
| 23 | * [Release notes][release-notes] |
| 24 | |
| 25 | **Non-Rust dependencies:** |
| 26 | |
| 27 | Librsvg depends on a number of non-Rust libraries that must be installed on your |
| 28 | system. They need to have a pkg-config `.pc` file installed so that librsvg's |
| 29 | compilation can find them via [system-deps][system-deps]: |
| 30 | |
| 31 | * Cairo - used for the main rendering |
| 32 | * FreeType2 - font renderer |
| 33 | * gio/glib - I/O primitives and streams |
| 34 | * Harfbuzz - text shaping |
| 35 | * libxml2 - XML parser |
| 36 | * Pangocairo - text rendering |
| 37 | * PangoFT2 - render text via Pango and FreeType2 |
| 38 | * Fontconfig - system fonts and rules for using them |
| 39 | |
| 40 | There are some [security considerations][sec-libs] for these non-Rust |
| 41 | libraries, which you may want to read. |
| 42 | |
| 43 | [system-deps]: https://github.com/gdesmott/system-deps |
| 44 | [sec-libs]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/security.html#librsvgs-dependencies |
| 45 | |
| 46 | **Rust dependencies:** Librsvg uses a bunch of Rust crates to handle |
| 47 | the many aspects of SVG and CSS. Of particular interest are the |
| 48 | [image-rs][image-rs] crate and its dependencies, which librsvg uses to |
| 49 | load raster images. |
| 50 | |
| 51 | **Bug tracking:** If you have found a bug, take a look at [our bug |
| 52 | tracker][bugs]. Please see the "[reporting bugs][reporting-bugs]" |
| 53 | page in the development guide to see how to provide a good bug report. |
| 54 | |
| 55 | **Asking questions:** Feel free to ask questions about using librsvg |
| 56 | in the "Platform" category of [GNOME's Discourse][discourse]. You can |
| 57 | also ask via chat in the Matrix room for [GNOME Rust][gnome-rust]. |
| 58 | |
| 59 | **Security:** For a list of releases with security issues, |
| 60 | instructions on reporting security-related bugs, and the security |
| 61 | considerations for librsvg's dependencies, see the [Security |
| 62 | chapter][security] in the development guide. |
| 63 | |
| 64 | [rust-docs]: https://gnome.pages.gitlab.gnome.org/librsvg/doc/rsvg/index.html |
| 65 | [release-notes]: https://gitlab.gnome.org/GNOME/librsvg/-/blob/main/NEWS |
| 66 | |
| 67 | ## Contributing to librsvg's development |
| 68 | |
| 69 | There is a code of conduct for contributors to librsvg; please see the |
| 70 | [GNOME Code of Conduct][coc]. |
| 71 | |
| 72 | Please see the [Development Guide for librsvg][devel-guide] on how to |
| 73 | contribute to librsvg, how to report bugs, how set up your development |
| 74 | environment, and for a description of librsvg's architecture. |
| 75 | |
| 76 | ## Goals of librsvg |
| 77 | |
| 78 | Librsvg aims to be a low-footprint library for rendering SVG1.1 and SVG2 images. |
| 79 | It is used primarily in the [GNOME project](https://www.gnome.org) to |
| 80 | render SVG icons and vector images that appear on the desktop. It is |
| 81 | also used in Wikimedia to render the SVG images that appear in |
| 82 | Wikipedia, so that even old web browsers can display them. Many |
| 83 | projects which casually need to render static SVG images use librsvg. |
| 84 | |
| 85 | We aim to be a "render this SVG for me, quickly, and with a minimal |
| 86 | API" kind of library. |
| 87 | |
| 88 | Feature additions will be considered on a case-by-case basis. |
| 89 | |
| 90 | You can read about librsvg's [supported SVG and CSS features][features] in the |
| 91 | development guide. |
| 92 | |
| 93 | ## Non-goals of librsvg |
| 94 | |
| 95 | We don't aim to: |
| 96 | |
| 97 | * Implement every single SVG feature that is in the spec. |
| 98 | |
| 99 | * Implement scripting or external access to the SVG's DOM. |
| 100 | |
| 101 | * Implement support for CSS-based animations (but if you can think of a nice API |
| 102 | to do this, we would be glad to know!) |
| 103 | |
| 104 | * Replace the industrial-strength SVG rendering machinery in modern web |
| 105 | browsers. |
| 106 | |
| 107 | Of course, [contributions are welcome][contributing]. In particular, |
| 108 | if you find nice ways of doing the above while still maintaining the |
| 109 | existing API of librsvg, we would love to know about it! |
| 110 | |
| 111 | ## Who uses librsvg? |
| 112 | |
| 113 | Librsvg is part of the [GNOME platform][platform]. Inside GNOME, |
| 114 | librsvg takes multiple roles: |
| 115 | |
| 116 | * Loads SVGs from the generic gdk-pixbuf loader infrastructure, so any |
| 117 | application which uses gdk-pixbuf can load SVGs as if they were raster images. |
| 118 | |
| 119 | * Loads SVG icons for the desktop. |
| 120 | |
| 121 | * Creates SVG thumbnails for the file manager. |
| 122 | |
| 123 | * Loads SVGs within GNOME's default image viewer, Eye of Gnome. |
| 124 | |
| 125 | Outside of GNOME's core: |
| 126 | |
| 127 | * GNOME games (chess, five-or-more, etc. to draw game pieces) |
| 128 | |
| 129 | * GIMP |
| 130 | |
| 131 | * GCompris |
| 132 | |
| 133 | * Claws-mail |
| 134 | |
| 135 | * Darktable |
| 136 | |
| 137 | * Mate-panel |
| 138 | |
| 139 | * Evas/Enlightenment |
| 140 | |
| 141 | * Emacs |
| 142 | |
| 143 | * ImageMagick |
| 144 | |
| 145 | * Wikipedia, to render SVGs as raster images for old browsers. |
| 146 | *Special thanks to Wikimedia for providing excellent bug reports.* |
| 147 | |
| 148 | ## Presentations on librsvg |
| 149 | |
| 150 | "[Replacing C library code with Rust: What I learned with |
| 151 | librsvg][guadec-presentation-1]" was presented at GUADEC 2017. It gives |
| 152 | a little history of librsvg, and how/why it is being ported to Rust |
| 153 | from C. |
| 154 | |
| 155 | "[Patterns of refactoring C to Rust: the case of |
| 156 | librsvg][guadec-presentation-2]" was presented at GUADEC 2018. It |
| 157 | describes ways in which librsvg's C code was refactored to allow |
| 158 | porting it to Rust. |
| 159 | |
| 160 | ## Maintainers |
| 161 | |
| 162 | The maintainer of librsvg is [Federico Mena Quintero][federico]. Feel |
| 163 | free to contact me for any questions you may have about librsvg, both |
| 164 | its usage and its development. You can contact me in the following |
| 165 | ways: |
| 166 | |
| 167 | * [Mail me][mail] at <[email protected]>. |
| 168 | |
| 169 | * Matrix: I am `@federico` on the [GNOME Hackers][gnome-hackers] and |
| 170 | [Rust ❤️ GNOME][gnome-rust] channels on gnome.org's Matrix. I'm there most |
| 171 | weekdays (Mon-Fri) starting at about UTC 14:00 (that's 08:00 my time; I am in |
| 172 | the UTC-6 timezone). If this is not a convenient time for you, feel free to |
| 173 | [mail me][mail] and we can arrange a time. |
| 174 | |
| 175 | * I frequently [blog about librsvg][blog]. You may be interested in the articles |
| 176 | about porting librsvg from C to Rust, which happened between 2016 and 2020. |
| 177 | |
| 178 | [svg]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics |
| 179 | [gnome]: https://www.gnome.org/ |
| 180 | [cairo]: https://www.cairographics.org/ |
| 181 | [contributing]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/contributing.html |
| 182 | [coc]: https://conduct.gnome.org |
| 183 | [devel-guide]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/index.html |
| 184 | [features]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/features.html |
| 185 | [security]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/security.html |
| 186 | [bugs]: https://gitlab.gnome.org/GNOME/librsvg/issues |
| 187 | [reporting-bugs]: https://gnome.pages.gitlab.gnome.org/librsvg/devel-docs/bugs.html |
| 188 | [discourse]: https://discourse.gnome.org/c/platform/5 |
| 189 | [gnome-rust]: https://matrix.to/#/#rust:gnome.org |
| 190 | [platform]: https://developer.gnome.org/ |
| 191 | [guadec-presentation-1]: https://viruta.org/docs/fmq-porting-c-to-rust.pdf |
| 192 | [guadec-presentation-2]: https://viruta.org/docs/fmq-refactoring-c-to-rust.pdf |
| 193 | [federico]: https://viruta.org/ |
| 194 | <!-- rumdl doesn't like mailto: --> |
| 195 | <!-- rumdl-disable-next-line md034 --> |
| 196 | [mail]: mailto:[email protected] |
| 197 | [gnome-hackers]: https://matrix.to/#/#gnome-hackers:gnome.org |
| 198 | [blog]: https://viruta.org/tag/librsvg.html |
| 199 | [image-rs]: https://github.com/image-rs/image |