freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][master] 2 commits: Fix 'librsvg' deprecat


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype-demos][master] 2 commits: Fix 'librsvg' deprecation warnings.
Date: Sat, 03 Jun 2023 04:27:43 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType Demo Programs

Commits:

  • 73c2159b
    by Hin-Tak Leung at 2023-06-03T06:26:39+02:00
    Fix 'librsvg' deprecation warnings.
    
    * 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: Hin-Tak Leung <htl10@users.sourceforge.net>
    
  • 626b43db
    by Hin-Tak Leung at 2023-06-03T06:26:39+02:00
    Fix out-of-memory conditions with newer 'librsvg'.
    
    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: Hin-Tak Leung <htl10@users.sourceforge.net>
    

1 changed file:

Changes:

  • src/rsvg-port.c
    ... ... @@ -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;
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]