Skip to content
Commits on Source (2)
  • HinTak's avatar
    Fix 'librsvg' deprecation warnings. · 73c2159b
    HinTak authored and Werner Lemberg's avatar Werner Lemberg committed
    
    
    * src/rsvg-port.c (rsvg_port_preset_slot): Use `rsvg_handle_render_document`
    instead of `rsvg_handle_render_cairo`, and `rsvg_handle_render_layer`
    instead of `rsvg_handle_render_cairo_sub`, as suggested by the warning,
    conditionally on newer librsvg 2.52+.
    
    Signed-off-by: default avatarHin-Tak Leung <htl10@users.sourceforge.net>
    73c2159b
  • HinTak's avatar
    Fix out-of-memory conditions with newer 'librsvg'. · 626b43db
    HinTak authored and Werner Lemberg's avatar Werner Lemberg committed
    Excerpts from `rsvg_handle_get_intrinsic_dimensions` section in
    `librsvg/rsvg.h`:
    
    ```
    Before librsvg 2.54.0, the `out_has_width` and `out_has_height` arguments
    would be set to true or false depending on whether the SVG document actually
    had `width` and `height` attributes, respectively.
    
    However, since librsvg 2.54.0, `width` and `height` are now [geometry
    properties](https://www.w3.org/TR/SVG2/geometry.html
    
    ) per the SVG2
    specification; they are not plain attributes.  SVG2 made it so that the
    initial value of those properties is `auto`, which is equivalent to
    specifying a value of `100%`.  In this sense, even SVG documents which lack
    `width` or `height` attributes semantically have to make them default to
    `100%`.  This is why since librsvg 2.54.0, `out_has_width` and
    `out_has_heigth` are always returned as `TRUE`, since with SVG2 all
    documents *have* a default width and height of `100%`.
    ```
    
    * src/rsvg-port.c (rsvg_port_preset_slot): Adjust for change of behavior of
    `rsvg_handle_get_intrinsic_dimensions` in librsvg 2.53+.  We avoid
    `LIBRSVG_CHECK_VERSION` as it is possible to build against one version but
    run against another version.
    
    Signed-off-by: default avatarHin-Tak Leung <htl10@users.sourceforge.net>
    626b43db
......@@ -241,12 +241,29 @@
{
dimension_svg.width = (int)out_width.length; /* XXX rounding? */
dimension_svg.height = (int)out_height.length;
/*
* librsvg 2.53+ behavior, on SVG doc without explicit width/height.
* See `rsvg_handle_get_intrinsic_dimensions` section in
* the `librsvg/rsvg.h` header file.
*/
if ( out_width.length == 1 &&
out_height.length == 1 )
{
dimension_svg.width = units_per_EM;
dimension_svg.height = units_per_EM;
}
}
else
{
/* If neither `ViewBox` nor `width`/`height` are present, the */
/* `units_per_EM` in SVG coordinates must be the same as */
/* `units_per_EM` of the TTF/CFF outlines. */
/*
* If neither `ViewBox` nor `width`/`height` are present, the
* `units_per_EM` in SVG coordinates must be the same as
* `units_per_EM` of the TTF/CFF outlines.
*
* librsvg up to 2.52 behavior, on SVG doc without explicit
* width/height.
*/
dimension_svg.width = units_per_EM;
dimension_svg.height = units_per_EM;
}
......@@ -306,7 +323,26 @@
if ( start_glyph_id == end_glyph_id )
{
/* Render the whole document to the recording surface. */
ret = rsvg_handle_render_cairo ( handle, rec_cr );
#if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
{
RsvgRectangle viewport =
{
.x = 0,
.y = 0,
.width = dimension_svg.width,
.height = dimension_svg.height,
};
ret = rsvg_handle_render_document( handle,
rec_cr,
&viewport,
NULL );
}
#else
ret = rsvg_handle_render_cairo( handle, rec_cr );
#endif
if ( ret == FALSE )
{
error = FT_Err_Invalid_SVG_Document;
......@@ -320,7 +356,28 @@
/* Render only the element with its ID equal to `glyph<ID>`. */
sprintf( str + 6, "%u", slot->glyph_index );
#if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
{
RsvgRectangle viewport =
{
.x = 0,
.y = 0,
.width = dimension_svg.width,
.height = dimension_svg.height,
};
ret = rsvg_handle_render_layer( handle,
rec_cr,
str,
&viewport,
NULL );
}
#else
ret = rsvg_handle_render_cairo_sub( handle, rec_cr, str );
#endif
if ( ret == FALSE )
{
error = FT_Err_Invalid_SVG_Document;
......