freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] [sdf] Correct handling of empty glyphs.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] [sdf] Correct handling of empty glyphs.
Date: Fri, 09 Jun 2023 03:42:36 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

  • 86d0ca24
    by Werner Lemberg at 2023-06-09T05:38:49+02:00
    [sdf] Correct handling of empty glyphs.
    
    This is a refinement of commit 7b3ebb9.
    
    * src/sdf/ftsdfrend.c (ft_sdf_render): Goto 'Exit' instead of directly
    returning.
    (fd_bsdf_render): Ditto, also taking care of setting `FT_GLYPH_OWN_BITMAP`
    correctly.
    

1 changed file:

Changes:

  • src/sdf/ftsdfrend.c
    ... ... @@ -300,7 +300,7 @@
    300 300
     
    
    301 301
         /* nothing to render */
    
    302 302
         if ( !bitmap->rows || !bitmap->pitch )
    
    303
    -      return FT_Err_Ok;
    
    303
    +      goto Exit;
    
    304 304
     
    
    305 305
         /* the padding will simply be equal to the `spread' */
    
    306 306
         x_pad = sdf_module->spread;
    
    ... ... @@ -508,6 +508,10 @@
    508 508
           goto Exit;
    
    509 509
         }
    
    510 510
     
    
    511
    +    /* nothing to render */
    
    512
    +    if ( !bitmap->rows || !bitmap->pitch )
    
    513
    +      goto Exit;
    
    514
    +
    
    511 515
         /* Do not generate SDF if the bitmap is not owned by the       */
    
    512 516
         /* glyph: it might be that the source buffer is already freed. */
    
    513 517
         if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
    
    ... ... @@ -519,10 +523,6 @@
    519 523
           goto Exit;
    
    520 524
         }
    
    521 525
     
    
    522
    -    /* nothing to render */
    
    523
    -    if ( !bitmap->rows || !bitmap->pitch )
    
    524
    -      return FT_Err_Ok;
    
    525
    -
    
    526 526
         FT_Bitmap_New( &target );
    
    527 527
     
    
    528 528
         /* padding will simply be equal to `spread` */
    
    ... ... @@ -557,15 +557,14 @@
    557 557
         {
    
    558 558
           /* the glyph is successfully converted to a SDF */
    
    559 559
           if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
    
    560
    -      {
    
    561 560
             FT_FREE( bitmap->buffer );
    
    562
    -        slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
    
    563
    -      }
    
    564 561
     
    
    565
    -      slot->bitmap           = target;
    
    566
    -      slot->bitmap_top      += y_pad;
    
    567
    -      slot->bitmap_left     -= x_pad;
    
    568
    -      slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
    
    562
    +      slot->bitmap       = target;
    
    563
    +      slot->bitmap_top  += y_pad;
    
    564
    +      slot->bitmap_left -= x_pad;
    
    565
    +
    
    566
    +      if ( target.buffer )
    
    567
    +        slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
    
    569 568
         }
    
    570 569
         else if ( target.buffer )
    
    571 570
           FT_FREE( target.buffer );
    


  • reply via email to

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