freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] master ec9b6c3 02/30: Add data types required for the forthc


From: Werner LEMBERG
Subject: [freetype2] master ec9b6c3 02/30: Add data types required for the forthcoming 'sdf' module.
Date: Thu, 24 Dec 2020 01:27:04 -0500 (EST)

branch: master
commit ec9b6c314dc018bbf0af4ff657fa5ff56a5bf9f7
Author: Anuj Verma <anujv@iitbhilai.ac.in>
Commit: Werner Lemberg <wl@gnu.org>

    Add data types required for the forthcoming 'sdf' module.
    
    * include/freetype/freetype.h (FT_Render_Mode): Add new render mode
    `FT_RENDER_MODE_SDF`, which will be used to generate SDF.
    
    * include/freetype/ftimage.h (FT_Pixel_Mode): Add new pixel mode
    `FT_PIXEL_MODE_GRAY16`, which will be the output of the 'sdf'
    module.
    (FT_RASTER_FLAG_SDF): New raster flag to be used internally by the
    'sdf' module.
    
    * include/freetype/fttypes.h (FT_F6Dot10): New data type.
---
 ChangeLog                   | 15 +++++++++++++++
 include/freetype/freetype.h | 24 +++++++++++++++++++-----
 include/freetype/ftimage.h  | 14 ++++++++++++++
 include/freetype/fttypes.h  | 12 ++++++++++++
 4 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 007d833..465869f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
 2020-08-16  Anuj Verma  <anujv@iitbhilai.ac.in>
 
+       Add data types required for the forthcoming 'sdf' module.
+
+       * include/freetype/freetype.h (FT_Render_Mode): Add new render mode
+       `FT_RENDER_MODE_SDF`, which will be used to generate SDF.
+
+       * include/freetype/ftimage.h (FT_Pixel_Mode): Add new pixel mode
+       `FT_PIXEL_MODE_GRAY16`, which will be the output of the 'sdf'
+       module.
+       (FT_RASTER_FLAG_SDF): New raster flag to be used internally by the
+       'sdf' module.
+
+       * include/freetype/fttypes.h (FT_F6Dot10): New data type.
+
+2020-08-16  Anuj Verma  <anujv@iitbhilai.ac.in>
+
        [base] Allow renderers of different formats.
 
        * src/base/ftobjs.c (FT_Render_Glyph_Internal): Do not return if the
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index b19a1b7..8a44174 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3204,7 +3204,7 @@ FT_BEGIN_HEADER
    *
    * @note:
    *   This function is provided as a convenience, but keep in mind that
-   *   @FT_Matrix coefficients are only 16.16 fixed point values, which can
+   *   @FT_Matrix coefficients are only 16.16 fixed-point values, which can
    *   limit the accuracy of the results.  Using floating-point computations
    *   to perform the transform directly in client code instead will always
    *   yield better numbers.
@@ -3236,10 +3236,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 a special render mode that uses up to
+   *   65536 distance values, indicating the signed distance from the grid
+   *   position to the nearest outline.
    *
    * @values:
    *   FT_RENDER_MODE_NORMAL ::
@@ -3266,6 +3270,15 @@ 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 (SDF)
+   *     bitmaps.  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.  The
+   *     output bitmap buffer is represented as 6.10 fixed-point values; use
+   *     @FT_6Dot10 and convert accordingly.
+   *
    * @note:
    *   The selected render mode only affects vector glyphs of a font.
    *   Embedded bitmaps often have a different pixel mode like
@@ -3279,6 +3292,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 5e2257f..8cf8a48 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -157,6 +157,13 @@ 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 as needed by @FT_RENDER_MODE_SDF.
+   *     Values are represented in a 6.10 fixed-point format; this means
+   *     that you have to divide by 1024 to get the actual data generated by
+   *     the SDF rasterizers.
+   *
    *   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 +191,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,
@@ -959,11 +967,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
+   *     the @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                   */
diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h
index aaeb9e8..8200ba0 100644
--- a/include/freetype/fttypes.h
+++ b/include/freetype/fttypes.h
@@ -78,6 +78,7 @@ FT_BEGIN_HEADER
    *   FT_FWord
    *   FT_UFWord
    *   FT_F2Dot14
+   *   FT_F6Dot10
    *   FT_UnitVector
    *   FT_F26Dot6
    *   FT_Data
@@ -267,6 +268,17 @@ FT_BEGIN_HEADER
   /**************************************************************************
    *
    * @type:
+   *   FT_F6Dot10
+   *
+   * @description:
+   *   A signed 6.10 fixed-point type used for signed distance values.
+   */
+  typedef signed short  FT_F6Dot10;
+
+
+  /**************************************************************************
+   *
+   * @type:
    *   FT_F26Dot6
    *
    * @description:



reply via email to

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