Also render SVGs with unspecified dimensions
This commit is contained in:
parent
7ef4a06def
commit
ffda836a15
15
fastiv-io.c
15
fastiv-io.c
|
@ -416,11 +416,20 @@ open_librsvg(const gchar *data, gsize len, const gchar *path, GError **error)
|
||||||
|
|
||||||
double w = 0, h = 0;
|
double w = 0, h = 0;
|
||||||
if (!rsvg_handle_get_intrinsic_size_in_pixels(handle, &w, &h)) {
|
if (!rsvg_handle_get_intrinsic_size_in_pixels(handle, &w, &h)) {
|
||||||
|
RsvgRectangle viewbox = {};
|
||||||
|
gboolean has_viewport = FALSE;
|
||||||
|
rsvg_handle_get_intrinsic_dimensions(handle, NULL, NULL, NULL, NULL,
|
||||||
|
&has_viewport, &viewbox);
|
||||||
|
if (!has_viewport) {
|
||||||
set_error(error, "cannot compute pixel dimensions");
|
set_error(error, "cannot compute pixel dimensions");
|
||||||
g_object_unref(handle);
|
g_object_unref(handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w = viewbox.width;
|
||||||
|
h = viewbox.height;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_rectangle_t extents = {
|
cairo_rectangle_t extents = {
|
||||||
.x = 0, .y = 0, .width = ceil(w), .height = ceil(h)};
|
.x = 0, .y = 0, .width = ceil(w), .height = ceil(h)};
|
||||||
cairo_surface_t *surface =
|
cairo_surface_t *surface =
|
||||||
|
@ -526,14 +535,20 @@ fastiv_io_open_from_data(const char *data, size_t len, const gchar *path,
|
||||||
|
|
||||||
// TODO(p): We should try to pass actual processing errors through,
|
// TODO(p): We should try to pass actual processing errors through,
|
||||||
// notably only continue with LIBRAW_FILE_UNSUPPORTED.
|
// notably only continue with LIBRAW_FILE_UNSUPPORTED.
|
||||||
|
if (error) {
|
||||||
|
g_debug("%s", (*error)->message);
|
||||||
g_clear_error(error);
|
g_clear_error(error);
|
||||||
|
}
|
||||||
#endif // HAVE_LIBRAW ---------------------------------------------------------
|
#endif // HAVE_LIBRAW ---------------------------------------------------------
|
||||||
#ifdef HAVE_LIBRSVG // --------------------------------------------------------
|
#ifdef HAVE_LIBRSVG // --------------------------------------------------------
|
||||||
if ((surface = open_librsvg(data, len, path, error)))
|
if ((surface = open_librsvg(data, len, path, error)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// XXX: It doesn't look like librsvg can return sensible errors.
|
// XXX: It doesn't look like librsvg can return sensible errors.
|
||||||
|
if (error) {
|
||||||
|
g_debug("%s", (*error)->message);
|
||||||
g_clear_error(error);
|
g_clear_error(error);
|
||||||
|
}
|
||||||
#endif // HAVE_LIBRSVG --------------------------------------------------------
|
#endif // HAVE_LIBRSVG --------------------------------------------------------
|
||||||
|
|
||||||
// TODO(p): Integrate gdk-pixbuf as a fallback (optional dependency).
|
// TODO(p): Integrate gdk-pixbuf as a fallback (optional dependency).
|
||||||
|
|
Loading…
Reference in New Issue