mirror of https://github.com/GNOME/gimp.git
tools: update the build-only tool compute-svg-viewbox.
It now uses rsvg_handle_get_geometry_for_layer() instead of rsvg_handle_get_(position|dimensions)_sub() which have been deprecated in favor of the new function which returns accurate (double) positioning and size. Back when I first made this build tool, librsvg had several blocking bugs to make icon extraction work properly. This seems to improve nicely. Nevertheless I still don't build this tool because after testing, more bugs remain and icon extraction is still not right. Just updating the code to undeprecate it but leave the build commented out for now. ;-( See librsvg#134, librsvg#128 and librsvg#250 for bug reports following these issues.
This commit is contained in:
parent
05de70e002
commit
cb1f01a42b
|
@ -58,6 +58,8 @@ if ENABLE_VECTOR_ICONS
|
|||
# Build tools which must be built for the host platform.
|
||||
#all-local: compute-svg-viewbox$(BUILD_EXEEXT)
|
||||
|
||||
#noinst_PROGRAMS = compute-svg-viewbox
|
||||
|
||||
#DISTCLEANFILES = compute-svg-viewbox$(BUILD_EXEEXT)
|
||||
endif
|
||||
|
||||
|
|
|
@ -21,15 +21,16 @@
|
|||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
RsvgHandle *handle;
|
||||
RsvgPositionData position_data;
|
||||
RsvgDimensionData dimension;
|
||||
RsvgHandle *handle;
|
||||
RsvgRectangle viewport = { 0.0, 0.0, 16.0, 16.0 };
|
||||
RsvgRectangle out_ink_rect;
|
||||
RsvgRectangle out_logical_rect;
|
||||
|
||||
gchar *endptr;
|
||||
gchar *path;
|
||||
gchar *id;
|
||||
gint prev_x;
|
||||
gint prev_y;
|
||||
gchar *endptr;
|
||||
gchar *path;
|
||||
gchar *id;
|
||||
gint prev_x;
|
||||
gint prev_y;
|
||||
|
||||
if (argc != 5)
|
||||
{
|
||||
|
@ -66,18 +67,18 @@ int main (int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
rsvg_handle_get_position_sub (handle, &position_data, id);
|
||||
rsvg_handle_get_dimensions_sub (handle, &dimension, id);
|
||||
if (dimension.width != dimension.height)
|
||||
rsvg_handle_get_geometry_for_layer (handle, id, &viewport, &out_ink_rect, &out_logical_rect, NULL);
|
||||
|
||||
if (out_ink_rect.width != out_ink_rect.height)
|
||||
{
|
||||
/* Right now, we are constraining all objects into square objects. */
|
||||
fprintf (stderr, "WARNING: object \"%s\" has unexpected size %dx%d [pos: (%d, %d)].\n",
|
||||
id, dimension.width, dimension.height,
|
||||
position_data.x, position_data.y);
|
||||
fprintf (stderr, "WARNING: object \"%s\" has unexpected size %fx%f [pos: (%f, %f)].\n",
|
||||
id, out_ink_rect.width, out_ink_rect.height,
|
||||
out_ink_rect.x, out_ink_rect.y);
|
||||
}
|
||||
printf ("viewBox=\"%d %d %d %d\"",
|
||||
position_data.x + prev_x, position_data.y + prev_y,
|
||||
dimension.width, dimension.height);
|
||||
printf ("viewBox=\"%f %f %f %f\"",
|
||||
out_ink_rect.x + prev_x, out_ink_rect.y + prev_y,
|
||||
out_ink_rect.width, out_ink_rect.height);
|
||||
|
||||
g_object_unref (handle);
|
||||
g_free (id);
|
||||
|
|
|
@ -31,7 +31,7 @@ if [ "$#" != 2 ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# The script is run from $(top_builddir)/icons/Symbolic/
|
||||
# The script is run from $(top_builddir)/icons/*/
|
||||
compute_viewbox="$(pwd)/../../tools/compute-svg-viewbox"
|
||||
source="$1"
|
||||
id="$2"
|
||||
|
|
Loading…
Reference in New Issue