... |
... |
@@ -241,12 +241,29 @@ |
241
|
241
|
{
|
242
|
242
|
dimension_svg.width = (int)out_width.length; /* XXX rounding? */
|
243
|
243
|
dimension_svg.height = (int)out_height.length;
|
|
244
|
+
|
|
245
|
+ /*
|
|
246
|
+ * librsvg 2.53+ behavior, on SVG doc without explicit width/height.
|
|
247
|
+ * See `rsvg_handle_get_intrinsic_dimensions` section in
|
|
248
|
+ * the `librsvg/rsvg.h` header file.
|
|
249
|
+ */
|
|
250
|
+ if ( out_width.length == 1 &&
|
|
251
|
+ out_height.length == 1 )
|
|
252
|
+ {
|
|
253
|
+ dimension_svg.width = units_per_EM;
|
|
254
|
+ dimension_svg.height = units_per_EM;
|
|
255
|
+ }
|
244
|
256
|
}
|
245
|
257
|
else
|
246
|
258
|
{
|
247
|
|
- /* If neither `ViewBox` nor `width`/`height` are present, the */
|
248
|
|
- /* `units_per_EM` in SVG coordinates must be the same as */
|
249
|
|
- /* `units_per_EM` of the TTF/CFF outlines. */
|
|
259
|
+ /*
|
|
260
|
+ * If neither `ViewBox` nor `width`/`height` are present, the
|
|
261
|
+ * `units_per_EM` in SVG coordinates must be the same as
|
|
262
|
+ * `units_per_EM` of the TTF/CFF outlines.
|
|
263
|
+ *
|
|
264
|
+ * librsvg up to 2.52 behavior, on SVG doc without explicit
|
|
265
|
+ * width/height.
|
|
266
|
+ */
|
250
|
267
|
dimension_svg.width = units_per_EM;
|
251
|
268
|
dimension_svg.height = units_per_EM;
|
252
|
269
|
}
|
... |
... |
@@ -306,7 +323,26 @@ |
306
|
323
|
if ( start_glyph_id == end_glyph_id )
|
307
|
324
|
{
|
308
|
325
|
/* Render the whole document to the recording surface. */
|
309
|
|
- ret = rsvg_handle_render_cairo ( handle, rec_cr );
|
|
326
|
+#if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
|
|
327
|
+ {
|
|
328
|
+ RsvgRectangle viewport =
|
|
329
|
+ {
|
|
330
|
+ .x = 0,
|
|
331
|
+ .y = 0,
|
|
332
|
+ .width = dimension_svg.width,
|
|
333
|
+ .height = dimension_svg.height,
|
|
334
|
+ };
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+ ret = rsvg_handle_render_document( handle,
|
|
338
|
+ rec_cr,
|
|
339
|
+ &viewport,
|
|
340
|
+ NULL );
|
|
341
|
+ }
|
|
342
|
+#else
|
|
343
|
+ ret = rsvg_handle_render_cairo( handle, rec_cr );
|
|
344
|
+#endif
|
|
345
|
+
|
310
|
346
|
if ( ret == FALSE )
|
311
|
347
|
{
|
312
|
348
|
error = FT_Err_Invalid_SVG_Document;
|
... |
... |
@@ -320,7 +356,28 @@ |
320
|
356
|
|
321
|
357
|
/* Render only the element with its ID equal to `glyph<ID>`. */
|
322
|
358
|
sprintf( str + 6, "%u", slot->glyph_index );
|
|
359
|
+
|
|
360
|
+#if LIBRSVG_CHECK_VERSION( 2, 52, 0 )
|
|
361
|
+ {
|
|
362
|
+ RsvgRectangle viewport =
|
|
363
|
+ {
|
|
364
|
+ .x = 0,
|
|
365
|
+ .y = 0,
|
|
366
|
+ .width = dimension_svg.width,
|
|
367
|
+ .height = dimension_svg.height,
|
|
368
|
+ };
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+ ret = rsvg_handle_render_layer( handle,
|
|
372
|
+ rec_cr,
|
|
373
|
+ str,
|
|
374
|
+ &viewport,
|
|
375
|
+ NULL );
|
|
376
|
+ }
|
|
377
|
+#else
|
323
|
378
|
ret = rsvg_handle_render_cairo_sub( handle, rec_cr, str );
|
|
379
|
+#endif
|
|
380
|
+
|
324
|
381
|
if ( ret == FALSE )
|
325
|
382
|
{
|
326
|
383
|
error = FT_Err_Invalid_SVG_Document;
|