From 8cce50b9b8d770f03d32abf260a8602c220c5e02 Mon Sep 17 00:00:00 2001 From: Anuj Verma Date: Sun, 23 Aug 2020 05:35:46 +0530 Subject: [PATCH] Be more explicit about the output of the SDF rasterizers. * include/freetype/fttypes.h (FT_F6Dot10): Add a new data type which can be\ used to convert the output buffer appropriately. * include/freetype/freetype.h (FT_Render_Mode): Add information about the output while using `FT_RENDER_MODE_SDF'. * include/freetype/ftimage.h (FT_Pixel_Mode): Add more information about the `FT_PIXEL_MODE_GRAY16' pixel mode. --- include/freetype/freetype.h | 4 +++- include/freetype/ftimage.h | 6 ++++-- include/freetype/fttypes.h | 12 ++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index aca7fcf2d..4b7da64df 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -3247,7 +3247,9 @@ FT_BEGIN_HEADER * 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. + * 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. diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index 5b41ca280..b2b9f78d4 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -160,8 +160,10 @@ FT_BEGIN_HEADER * 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. + * rendering using @FT_RENDER_MODE_SDF. One Impotant Note: + * This pixel format is represented as 6.10 fixed point format. That + * means you have to divide the values by 1024.0F in order to get + * actual data that is outputted by the SDF rasterizers. * * FT_PIXEL_MODE_LCD :: * An 8-bit bitmap, representing RGB or BGR decimated glyph images used diff --git a/include/freetype/fttypes.h b/include/freetype/fttypes.h index aaeb9e878..8200ba066 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 @@ -264,6 +265,17 @@ FT_BEGIN_HEADER typedef signed short FT_F2Dot14; + /************************************************************************** + * + * @type: + * FT_F6Dot10 + * + * @description: + * A signed 6.10 fixed-point type used for signed distance values. + */ + typedef signed short FT_F6Dot10; + + /************************************************************************** * * @type: