freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][master] * src/base/ftsynth.c (FT_GlyphSlot_Adju


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] * src/base/ftsynth.c (FT_GlyphSlot_AdjustWeight): New API.
Date: Thu, 16 Mar 2023 03:29:01 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

  • dd78d4a7
    by Alexei Podtelezhnikov at 2023-03-16T03:28:59+00:00
    * src/base/ftsynth.c (FT_GlyphSlot_AdjustWeight): New API.
    

2 changed files:

Changes:

  • include/freetype/ftsynth.h
    ... ... @@ -68,6 +68,18 @@ FT_BEGIN_HEADER
    68 68
       FT_EXPORT( void )
    
    69 69
       FT_GlyphSlot_Embolden( FT_GlyphSlot  slot );
    
    70 70
     
    
    71
    +  /* Precisely adjust the glyph weight either horizontally or vertically.  */
    
    72
    +  /* The `xdelta` and `ydelta` values are fractions of the face Em size    */
    
    73
    +  /* (in fixed-point format).  Considering that a regular face would have  */
    
    74
    +  /* stem widths on the order of 0.1 Em, a delta of 0.05 (0x0CCC) should   */
    
    75
    +  /* be very noticeable.  To increase or decrease the weight, use positive */
    
    76
    +  /* or negative values, respectively.                                     */
    
    77
    +  FT_EXPORT( void )
    
    78
    +  FT_GlyphSlot_AdjustWeight( FT_GlyphSlot  slot,
    
    79
    +                             FT_Fixed      xdelta,
    
    80
    +                             FT_Fixed      ydelta );
    
    81
    +
    
    82
    +
    
    71 83
       /* Slant an outline glyph to the right by about 12 degrees.              */
    
    72 84
       FT_EXPORT( void )
    
    73 85
       FT_GlyphSlot_Oblique( FT_GlyphSlot  slot );
    

  • src/base/ftsynth.c
    ... ... @@ -97,9 +97,18 @@
    97 97
     
    
    98 98
       FT_EXPORT_DEF( void )
    
    99 99
       FT_GlyphSlot_Embolden( FT_GlyphSlot  slot )
    
    100
    +  {
    
    101
    +    FT_GlyphSlot_AdjustWeight( slot, 0x0AAA, 0x0AAA );
    
    102
    +  }
    
    103
    +
    
    104
    +
    
    105
    +  FT_EXPORT_DEF( void )
    
    106
    +  FT_GlyphSlot_AdjustWeight( FT_GlyphSlot  slot,
    
    107
    +                             FT_Fixed      xdelta,
    
    108
    +                             FT_Fixed      ydelta )
    
    100 109
       {
    
    101 110
         FT_Library  library;
    
    102
    -    FT_Face     face;
    
    111
    +    FT_Size     size;
    
    103 112
         FT_Error    error;
    
    104 113
         FT_Pos      xstr, ystr;
    
    105 114
     
    
    ... ... @@ -108,16 +117,15 @@
    108 117
           return;
    
    109 118
     
    
    110 119
         library = slot->library;
    
    111
    -    face    = slot->face;
    
    120
    +    size    = slot->face->size;
    
    112 121
     
    
    113 122
         if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
    
    114 123
              slot->format != FT_GLYPH_FORMAT_BITMAP  )
    
    115 124
           return;
    
    116 125
     
    
    117
    -    /* some reasonable strength */
    
    118
    -    xstr = FT_MulFix( face->units_per_EM,
    
    119
    -                      face->size->metrics.y_scale ) / 24;
    
    120
    -    ystr = xstr;
    
    126
    +    /* express deltas in pixels in 26.6 format */
    
    127
    +    xstr = (FT_Pos)size->metrics.x_ppem * xdelta / 1024;
    
    128
    +    ystr = (FT_Pos)size->metrics.y_ppem * ydelta / 1024;
    
    121 129
     
    
    122 130
         if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
    
    123 131
           FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
    


  • reply via email to

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