freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][gsoc-anurag-2023] Work on preloading font outli


From: Anurag Thakur (@AdbhutDev)
Subject: [Git][freetype/freetype][gsoc-anurag-2023] Work on preloading font outlines
Date: Mon, 14 Aug 2023 19:40:00 +0000

Anurag Thakur pushed to branch gsoc-anurag-2023 at FreeType / FreeType

Commits:

  • afea57b0
    by Anurag Thakur at 2023-08-15T01:09:26+05:30
    Work on preloading font outlines
    

2 changed files:

Changes:

  • include/freetype/freetype.h
    ... ... @@ -2399,6 +2399,9 @@ FT_BEGIN_HEADER
    2399 2399
        *   FT_OPEN_PARAMS ::
    
    2400 2400
        *     Use the `num_params` and `params` fields.
    
    2401 2401
        *
    
    2402
    +   *   FT_OPEN_PRELOAD ::
    
    2403
    +   *     Preprocess the font outline to save cpu time later.
    
    2404
    +   *
    
    2402 2405
        * @note:
    
    2403 2406
        *   The `FT_OPEN_MEMORY`, `FT_OPEN_STREAM`, and `FT_OPEN_PATHNAME` flags
    
    2404 2407
        *   are mutually exclusive.
    
    ... ... @@ -2408,7 +2411,7 @@ FT_BEGIN_HEADER
    2408 2411
     #define FT_OPEN_PATHNAME  0x4
    
    2409 2412
     #define FT_OPEN_DRIVER    0x8
    
    2410 2413
     #define FT_OPEN_PARAMS    0x10
    
    2411
    -
    
    2414
    +#define FT_OPEN_PRELOAD   0x20
    
    2412 2415
     
    
    2413 2416
       /* these constants are deprecated; use the corresponding `FT_OPEN_XXX` */
    
    2414 2417
       /* values instead                                                      */
    
    ... ... @@ -2572,6 +2575,12 @@ FT_BEGIN_HEADER
    2572 2575
                    FT_Long      face_index,
    
    2573 2576
                    FT_Face     *aface );
    
    2574 2577
     
    
    2578
    +  FT_EXPORT( FT_Error )
    
    2579
    +  FT_New_Face2( FT_Library   library,
    
    2580
    +               const char*  filepathname,
    
    2581
    +               FT_Long      face_index,
    
    2582
    +               FT_Face     *aface,
    
    2583
    +               FT_UInt      flags);
    
    2575 2584
     
    
    2576 2585
       /**************************************************************************
    
    2577 2586
        *
    

  • src/base/ftobjs.c
    ... ... @@ -1610,18 +1610,40 @@
    1610 1610
       {
    
    1611 1611
         FT_Open_Args  args;
    
    1612 1612
     
    
    1613
    +    /* test for valid `library' and `aface' delayed to `FT_Open_Face' */
    
    1614
    +    if ( !pathname )
    
    1615
    +      return FT_THROW( Invalid_Argument );
    
    1616
    +
    
    1617
    +    args.flags    = FT_OPEN_PATHNAME;
    
    1618
    +    args.pathname = (char*)pathname;
    
    1619
    +    args.stream   = NULL;
    
    1620
    +
    
    1621
    +    return ft_open_face_internal( library, &args, face_index, aface, 1 );
    
    1622
    +  }
    
    1623
    +
    
    1624
    +
    
    1625
    +  FT_EXPORT_DEF( FT_Error )
    
    1626
    +  FT_New_Face2( FT_Library   library,
    
    1627
    +                const char*  pathname,
    
    1628
    +                FT_Long      face_index,
    
    1629
    +                FT_Face     *aface,
    
    1630
    +                FT_UInt      flags)
    
    1631
    +  {
    
    1632
    +    FT_Open_Args  args;
    
    1613 1633
     
    
    1614 1634
         /* test for valid `library' and `aface' delayed to `FT_Open_Face' */
    
    1615 1635
         if ( !pathname )
    
    1616 1636
           return FT_THROW( Invalid_Argument );
    
    1617 1637
     
    
    1618 1638
         args.flags    = FT_OPEN_PATHNAME;
    
    1639
    +    args.flags   |= flags;
    
    1619 1640
         args.pathname = (char*)pathname;
    
    1620 1641
         args.stream   = NULL;
    
    1621 1642
     
    
    1622 1643
         return ft_open_face_internal( library, &args, face_index, aface, 1 );
    
    1623 1644
       }
    
    1624 1645
     
    
    1646
    +
    
    1625 1647
     #endif
    
    1626 1648
     
    
    1627 1649
     
    
    ... ... @@ -2540,7 +2562,11 @@
    2540 2562
         FT_UNUSED( test_mac_fonts );
    
    2541 2563
     #endif
    
    2542 2564
     
    
    2543
    -
    
    2565
    +    if (args->flags & FT_OPEN_PRELOAD)
    
    2566
    +    {
    
    2567
    +      FT_TRACE0(("Requested Preload\n"));
    
    2568
    +    }
    
    2569
    +    
    
    2544 2570
         /* only use lower 31 bits together with sign bit */
    
    2545 2571
         if ( face_index > 0 )
    
    2546 2572
           face_index &= 0x7FFFFFFFL;
    
    ... ... @@ -2636,7 +2662,6 @@
    2636 2662
     
    
    2637 2663
               driver = FT_DRIVER( cur[0] );
    
    2638 2664
     
    
    2639
    -          // TODO: Check the args for a "preload" flag and act accordingly
    
    2640 2665
               if ( args->flags & FT_OPEN_PARAMS )
    
    2641 2666
               {
    
    2642 2667
                 num_params = args->num_params;
    
    ... ... @@ -2727,7 +2752,12 @@
    2727 2752
         /* face->driver instead.                                   */
    
    2728 2753
         FT_List_Add( &face->driver->faces_list, node );
    
    2729 2754
     
    
    2730
    -    // TODO: The preload logic should be performed here
    
    2755
    +    if (args->flags & FT_OPEN_PRELOAD)
    
    2756
    +    {
    
    2757
    +      /* Preload the font here */
    
    2758
    +    }
    
    2759
    +    
    
    2760
    +
    
    2731 2761
         /* now allocate a glyph slot object for the face */
    
    2732 2762
         FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
    
    2733 2763
     
    
    ... ... @@ -2749,6 +2779,7 @@
    2749 2779
               goto Fail;
    
    2750 2780
     
    
    2751 2781
             face->size = size;
    
    2782
    +
    
    2752 2783
           }
    
    2753 2784
         }
    
    2754 2785
     
    


  • reply via email to

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