freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype-demos][master] [ftview] Handle foreground COLR.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype-demos][master] [ftview] Handle foreground COLR.
Date: Sat, 19 Feb 2022 06:38:19 +0000

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

Commits:

1 changed file:

Changes:

  • src/ftview.c
    ... ... @@ -410,12 +410,16 @@
    410 410
       Render_All( int  num_indices,
    
    411 411
                   int  offset )
    
    412 412
       {
    
    413
    -    int           start_x, start_y, step_y, x, y, width;
    
    414
    -    int           i, have_topleft;
    
    413
    +    int  start_x, start_y, step_y, x, y, width;
    
    414
    +    int  i, have_topleft;
    
    415
    +
    
    415 416
         FT_Size       size;
    
    416 417
         FT_Face       face;
    
    417 418
         FT_GlyphSlot  slot;
    
    418
    -    FT_Color*     palette;
    
    419
    +
    
    420
    +    FT_Color*        palette;
    
    421
    +    FT_Palette_Data  palette_data;
    
    422
    +    FT_UShort        palette_index;
    
    419 423
     
    
    420 424
     
    
    421 425
         error = FTDemo_Get_Size( handle, &size );
    
    ... ... @@ -429,11 +433,11 @@
    429 433
         face = size->face;
    
    430 434
         slot = face->glyph;
    
    431 435
     
    
    432
    -    error = FT_Palette_Select( face,
    
    433
    -                               (FT_UShort)handle->current_font->palette_index,
    
    434
    -                               &palette );
    
    435
    -    if ( error )
    
    436
    +    palette_index = (FT_UShort)handle->current_font->palette_index;
    
    437
    +    if ( FT_Palette_Select( face, palette_index, &palette ) )
    
    436 438
           palette = NULL;
    
    439
    +    if ( FT_Palette_Data_Get( face, &palette_data ) )
    
    440
    +      return -1;
    
    437 441
     
    
    438 442
         have_topleft = 0;
    
    439 443
     
    
    ... ... @@ -480,6 +484,7 @@
    480 484
             do
    
    481 485
             {
    
    482 486
               FT_Vector  slot_offset;
    
    487
    +          FT_Color   color;
    
    483 488
     
    
    484 489
     
    
    485 490
               error = FT_Load_Glyph( face, layer_glyph_idx, load_flags );
    
    ... ... @@ -489,12 +494,39 @@
    489 494
               slot_offset.x = slot->bitmap_left * 64;
    
    490 495
               slot_offset.y = slot->bitmap_top * 64;
    
    491 496
     
    
    497
    +          if ( layer_color_idx == 0xFFFF )
    
    498
    +          {
    
    499
    +            // TODO: FT_Palette_Get_Foreground_Color
    
    500
    +            if ( palette_data.palette_flags                  &&
    
    501
    +               ( palette_data.palette_flags[palette_index] &
    
    502
    +                   FT_PALETTE_FOR_DARK_BACKGROUND          ) )
    
    503
    +            {
    
    504
    +              /* white opaque */
    
    505
    +              color.blue  = 0xFF;
    
    506
    +              color.green = 0xFF;
    
    507
    +              color.red   = 0xFF;
    
    508
    +              color.alpha = 0xFF;
    
    509
    +            }
    
    510
    +            else
    
    511
    +            {
    
    512
    +              /* black opaque */
    
    513
    +              color.blue  = 0x00;
    
    514
    +              color.green = 0x00;
    
    515
    +              color.red   = 0x00;
    
    516
    +              color.alpha = 0xFF;
    
    517
    +            }
    
    518
    +          }
    
    519
    +          else if ( layer_color_idx < palette_data.num_palette_entries )
    
    520
    +            color = palette[layer_color_idx];
    
    521
    +          else
    
    522
    +            continue;
    
    523
    +
    
    492 524
               error = FT_Bitmap_Blend( handle->library,
    
    493 525
                                        &slot->bitmap,
    
    494 526
                                        slot_offset,
    
    495 527
                                        &bitmap,
    
    496 528
                                        &bitmap_offset,
    
    497
    -                                   palette[layer_color_idx] );
    
    529
    +                                   color );
    
    498 530
     
    
    499 531
             } while ( FT_Get_Color_Glyph_Layer( face,
    
    500 532
                                                 glyph_idx,
    


  • reply via email to

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