freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] GSoC-2020-anuj 6b81c53 2/3: Added render mode and data type


From: Anuj Verma
Subject: [freetype2] GSoC-2020-anuj 6b81c53 2/3: Added render mode and data type required for the `sdf' module.
Date: Sun, 16 Aug 2020 07:39:31 -0400 (EDT)

branch: GSoC-2020-anuj
commit 6b81c538ed9ede81dd9f2901137d61313c36f808
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Anuj Verma <anujv@iitbhilai.ac.in>

    Added render mode and data type required for the `sdf' module.
    
    * include/freetype/freetype.h (FT_Render_Mode): Added a new render mode
      `FT_RENDER_MODE_SDF', which will be used to generate SDF.
    
    * include/freetype/ftimage.h (FT_Pixel_Mode): Added a new pixel mode
      `FT_PIXEL_MODE_GRAY16', which will be the output of the `sdf' module.
    
    * include/freetype/ftimage.h (FT_RASTER_FLAG_SDF): Added a new raster flag
      to be used internally by the `sdf' module.
---
 include/freetype/freetype.h | 20 ++++++++++++++++----
 include/freetype/ftimage.h  | 13 +++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index b1f4ed5..aca7fcf 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3208,10 +3208,14 @@ FT_BEGIN_HEADER
    *   in the @FT_GlyphSlotRec structure gives the format of the returned
    *   bitmap.
    *
-   *   All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity,
-   *   indicating pixel coverage.  Use linear alpha blending and gamma
-   *   correction to correctly render non-monochrome glyph bitmaps onto a
-   *   surface; see @FT_Render_Glyph.
+   *   All modes except @FT_RENDER_MODE_MONO and @FT_RENDER_MODE_SDF use
+   *   256 levels of opacity, indicating pixel coverage.  Use linear alpha
+   *   blending and gamma correction to correctly render non-monochrome glyph
+   *   bitmaps onto a surface; see @FT_Render_Glyph.
+   *
+   *   The @FT_RENDER_MODE_SDF is s special render mode which uses as much
+   *   65536 distance values, indicating the signed distance from the grid
+   *   position to the nearest outline.
    *
    * @values:
    *   FT_RENDER_MODE_NORMAL ::
@@ -3238,6 +3242,13 @@ FT_BEGIN_HEADER
    *     bitmaps that are 3~times the height of the original glyph outline in
    *     pixels and use the @FT_PIXEL_MODE_LCD_V mode.
    *
+   *   FT_RENDER_MODE_SDF ::
+   *     This mode corresponds to 16-bit signed distance fields bitmap.  Each
+   *     pixel in a SDF bitmap contains information about the nearest edge of
+   *     the glyph outline.  The distances are calculated from the center of
+   *     the pixel and are positive if they are filled by the outline (i.e.
+   *     inside the outline) and negative otherwise.
+   *
    * @note:
    *   The selected render mode only affects vector glyphs of a font.
    *   Embedded bitmaps often have a different pixel mode like
@@ -3251,6 +3262,7 @@ FT_BEGIN_HEADER
     FT_RENDER_MODE_MONO,
     FT_RENDER_MODE_LCD,
     FT_RENDER_MODE_LCD_V,
+    FT_RENDER_MODE_SDF,
 
     FT_RENDER_MODE_MAX
 
diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h
index 105e09d..5b41ca2 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -157,6 +157,12 @@ FT_BEGIN_HEADER
    *     in font files according to the OpenType specification.  We haven't
    *     found a single font using this format, however.
    *
+   *   FT_PIXEL_MODE_GRAY16 ::
+   *     A 16-bit per pixel bitmap used to represent signed distances in a
+   *     signed distance field bitmap.  This is currently only used while
+   *     rendering using @FT_RENDER_MODE_SDF.  Note that this is a 2.14
+   *     fixed-point fractional value.
+   *
    *   FT_PIXEL_MODE_LCD ::
    *     An 8-bit bitmap, representing RGB or BGR decimated glyph images used
    *     for display on LCD displays; the bitmap is three times wider than
@@ -184,6 +190,7 @@ FT_BEGIN_HEADER
     FT_PIXEL_MODE_GRAY,
     FT_PIXEL_MODE_GRAY2,
     FT_PIXEL_MODE_GRAY4,
+    FT_PIXEL_MODE_GRAY16,
     FT_PIXEL_MODE_LCD,
     FT_PIXEL_MODE_LCD_V,
     FT_PIXEL_MODE_BGRA,
@@ -962,11 +969,17 @@ FT_BEGIN_HEADER
    *     will be clipped to a box specified in the `clip_box` field of the
    *     @FT_Raster_Params structure.  Otherwise, the `clip_box` is
    *     effectively set to the bounding box and all spans are generated.
+   *
+   *   FT_RASTER_FLAG_SDF ::
+   *     This flag is set to indicate that a signed distance field glyph
+   *     image should be generated.  This is only used while rendering with
+   *     `FT_RENDER_MODE_SDF' render mode.
    */
 #define FT_RASTER_FLAG_DEFAULT  0x0
 #define FT_RASTER_FLAG_AA       0x1
 #define FT_RASTER_FLAG_DIRECT   0x2
 #define FT_RASTER_FLAG_CLIP     0x4
+#define FT_RASTER_FLAG_SDF      0x8
 
   /* these constants are deprecated; use the corresponding */
   /* `FT_RASTER_FLAG_XXX` values instead                   */



reply via email to

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