freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] Add new load flag `FT_LOAD_NO_SVG`.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] Add new load flag `FT_LOAD_NO_SVG`.
Date: Mon, 15 May 2023 14:04:55 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 416d4c25
    by Werner Lemberg at 2023-05-15T16:04:15+02:00
    Add new load flag `FT_LOAD_NO_SVG`.
    
    Modern color fonts often contain both an 'SVG' and 'COLR' table.  FreeType
    always preferred 'SVG' over 'COLR' (this was a design decision), however,
    this might not be the right choice for the user.  The new flags makes
    FreeType ignore the 'SVG' table while loading a glyph.
    
    Fixes #1229.
    
    * include/freetype/freetype.h (FT_LOAD_NO_SVG): New macro.
    
    * src/base/ftobjs.c (FT_Load_Glyph), src/cff/cffgload.c (cff_slot_load),
    src/truetype/ttgload.c (TT_Load_Glyph): Use it.
    

5 changed files:

Changes:

  • docs/CHANGES
    ... ... @@ -5,6 +5,9 @@ CHANGES BETWEEN 2.13.0 and 2.13.1 (2023-XXX-XX)
    5 5
       - New function  `FT_Get_Default_Named_Instance` to get the  index of
    
    6 6
         the default named instance of an OpenType Variation Font.
    
    7 7
     
    
    8
    +  - A new load flag `FT_LOAD_NO_SVG` to make FreeType ignore glyphs in
    
    9
    +    an 'SVG ' table.
    
    10
    +
    
    8 11
     
    
    9 12
     ======================================================================
    
    10 13
     
    

  • include/freetype/freetype.h
    ... ... @@ -3425,10 +3425,11 @@ FT_BEGIN_HEADER
    3425 3425
        *
    
    3426 3426
        *     [Since 2.12] If the glyph index maps to an entry in the face's
    
    3427 3427
        *     'SVG~' table, load the associated SVG document from this table and
    
    3428
    -   *     set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG.
    
    3429
    -   *     Note that FreeType itself can't render SVG documents; however, the
    
    3430
    -   *     library provides hooks to seamlessly integrate an external renderer.
    
    3431
    -   *     See sections @ot_svg_driver and @svg_fonts for more.
    
    3428
    +   *     set the `format` field of @FT_GlyphSlotRec to @FT_GLYPH_FORMAT_SVG
    
    3429
    +   *     ([since 2.13.1] provided @FT_LOAD_NO_SVG is not set).  Note that
    
    3430
    +   *     FreeType itself can't render SVG documents; however, the library
    
    3431
    +   *     provides hooks to seamlessly integrate an external renderer.  See
    
    3432
    +   *     sections @ot_svg_driver and @svg_fonts for more.
    
    3432 3433
        *
    
    3433 3434
        *     [Since 2.10, experimental] If the glyph index maps to an entry in
    
    3434 3435
        *     the face's 'COLR' table with a 'CPAL' palette table (as defined in
    
    ... ... @@ -3442,6 +3443,9 @@ FT_BEGIN_HEADER
    3442 3443
        *     @FT_Palette_Select instead of setting @FT_LOAD_COLOR for rendering
    
    3443 3444
        *     so that the client application can handle blending by itself.
    
    3444 3445
        *
    
    3446
    +   *   FT_LOAD_NO_SVG ::
    
    3447
    +   *     [Since 2.13.1] Ignore SVG glyph data when loading.
    
    3448
    +   *
    
    3445 3449
        *   FT_LOAD_COMPUTE_METRICS ::
    
    3446 3450
        *     [Since 2.6.1] Compute glyph metrics from the glyph data, without the
    
    3447 3451
        *     use of bundled metrics tables (for example, the 'hdmx' table in
    
    ... ... @@ -3507,6 +3511,7 @@ FT_BEGIN_HEADER
    3507 3511
     #define FT_LOAD_COLOR                        ( 1L << 20 )
    
    3508 3512
     #define FT_LOAD_COMPUTE_METRICS              ( 1L << 21 )
    
    3509 3513
     #define FT_LOAD_BITMAP_METRICS_ONLY          ( 1L << 22 )
    
    3514
    +#define FT_LOAD_NO_SVG                       ( 1L << 24 )
    
    3510 3515
     
    
    3511 3516
       /* */
    
    3512 3517
     
    

  • src/base/ftobjs.c
    ... ... @@ -1019,7 +1019,8 @@
    1019 1019
           /*      elegant.                                            */
    
    1020 1020
     
    
    1021 1021
           /* try to load SVG documents if available */
    
    1022
    -      if ( FT_HAS_SVG( face ) )
    
    1022
    +      if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
    
    1023
    +           FT_HAS_SVG( face )                   )
    
    1023 1024
           {
    
    1024 1025
             error = driver->clazz->load_glyph( slot, face->size,
    
    1025 1026
                                                glyph_index,
    

  • src/cff/cffgload.c
    ... ... @@ -356,14 +356,16 @@
    356 356
     
    
    357 357
     #ifdef FT_CONFIG_OPTION_SVG
    
    358 358
         /* check for OT-SVG */
    
    359
    -    if ( ( load_flags & FT_LOAD_COLOR ) && face->svg )
    
    359
    +    if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
    
    360
    +         ( load_flags & FT_LOAD_COLOR )       &&
    
    361
    +         face->svg                            )
    
    360 362
         {
    
    361 363
           /*
    
    362 364
            * We load the SVG document and try to grab the advances from the
    
    363 365
            * table.  For the bearings we rely on the presetting hook to do that.
    
    364 366
            */
    
    365 367
     
    
    366
    -      SFNT_Service  sfnt  = (SFNT_Service)face->sfnt;
    
    368
    +      SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
    
    367 369
     
    
    368 370
     
    
    369 371
           if ( size && (size->root.metrics.x_ppem < 1 ||
    

  • src/truetype/ttgload.c
    ... ... @@ -2802,7 +2802,9 @@
    2802 2802
     #ifdef FT_CONFIG_OPTION_SVG
    
    2803 2803
     
    
    2804 2804
         /* check for OT-SVG */
    
    2805
    -    if ( ( load_flags & FT_LOAD_COLOR ) && face->svg )
    
    2805
    +    if ( ( load_flags & FT_LOAD_NO_SVG ) == 0 &&
    
    2806
    +         ( load_flags & FT_LOAD_COLOR )       &&
    
    2807
    +         face->svg                            )
    
    2806 2808
         {
    
    2807 2809
           SFNT_Service  sfnt = (SFNT_Service)face->sfnt;
    
    2808 2810
     
    


  • reply via email to

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