[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[freetype2] 1100-sdf-improvements 5f9bc4b85 1/3: * include/freetype/free
From: |
Werner Lemberg |
Subject: |
[freetype2] 1100-sdf-improvements 5f9bc4b85 1/3: * include/freetype/freetype.h (FT_RENDER_MODE_SDF): Improve documentation. |
Date: |
Fri, 4 Mar 2022 06:30:26 -0500 (EST) |
branch: 1100-sdf-improvements
commit 5f9bc4b8594c7051ce700eb52fb593da924314cb
Author: Anuj Verma <anuj@womp.xyz>
Commit: Anuj Verma <anuj@womp.xyz>
* include/freetype/freetype.h (FT_RENDER_MODE_SDF): Improve documentation.
* include/freetype/freetype.h (FT_RENDER_MODE_SDF): Added more
documentation for the render mode regarding the stability and point
where artifacts are expected to occur. Also added more information
for both `sdf`, `bsdf` and when they are used.
---
include/freetype/freetype.h | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 0489c8448..40a4dc215 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -3409,6 +3409,45 @@ FT_BEGIN_HEADER
* }
*
* ```
+ *
+ * FreeType has two rasterizers for generating SDF, namely:
+ *
+ * 1. `sdf` - For generating SDF directly from glyph's outline.
+ *
+ * 2. `bsdf` - For generating SDF from rasterized bitmaps.
+ *
+ * Depending on the glyph type (i.e. outline or bitmap), one of the two
+ * rasterizer is chosen at runtime and used for generating SDF. To
+ * force use `bsdf` you can simply render the glyph using any of the
+ * FreeType's other rendering modes (e.g. `FT_RENDER_MODE_NORMAL`) and
+ * then re-render using `FT_RENDER_MODE_SDF`.
+ *
+ * Now, a few notes on the stability and point of failures for the SDF
+ * renderers (specifically `sdf`):
+ *
+ * 1. The `sdf` rasterizer is sensitive to really small features (e.g.
+ * sharp turns which are less than 1 pixel) and imperfections in the
+ * glyph's outline. Having these in the outline can cause artifats
+ * in the final output.
+ *
+ * 2. The `sdf` rasterizer has limited support for handling intersecting
+ * contours and *cannot* handle self-intersecting contours whatsoever.
+ * Self intersection happens when a single connected contour intersect
+ * itself at some point and having these in your font will definately
+ * pose a problem to the rasterizer and cause artifacts.
+ *
+ * 3. Generating SDF for really small glyphs may result in undesirable
+ * output due to limited availability of pixel grid to store distance
+ * information.
+ *
+ * 4. Since the output buffer is normalized, precision at smaller spread
+ * will be greater than precision at larger spread values, because the
+ * output range of [0 .. 255] will be mapped to a smaller sdf range.
+ * A spread of 2 should be sufficient in most cases.
+ *
+ * Point (1) and (2) can be avoided by using `bsdf` and overall it is
+ * more stable than the `sdf` rasterizer.
+ *
*/
typedef enum FT_Render_Mode_
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [freetype2] 1100-sdf-improvements 5f9bc4b85 1/3: * include/freetype/freetype.h (FT_RENDER_MODE_SDF): Improve documentation.,
Werner Lemberg <=