... |
... |
@@ -3368,6 +3368,40 @@ FT_BEGIN_HEADER |
3368
|
3368
|
* }
|
3369
|
3369
|
*
|
3370
|
3370
|
* ```
|
|
3371
|
+ *
|
|
3372
|
+ * FreeType has two rasterizers for generating SDF, namely:
|
|
3373
|
+ *
|
|
3374
|
+ * 1. `sdf` - For generating SDF directly from glyph's outline.
|
|
3375
|
+ *
|
|
3376
|
+ * 2. `bsdf` - For generating SDF from rasterized bitmaps.
|
|
3377
|
+ *
|
|
3378
|
+ * Depending on the glyph type (i.e. outline or bitmap), one of the two
|
|
3379
|
+ * rasterizer is chosen at runtime and used for generating SDF. To
|
|
3380
|
+ * force use `bsdf` you can simply render the glyph using any of the
|
|
3381
|
+ * FreeType's other rendering modes (e.g. `FT_RENDER_MODE_NORMAL`) and
|
|
3382
|
+ * then re-render using `FT_RENDER_MODE_SDF`.
|
|
3383
|
+ *
|
|
3384
|
+ * Now, a few notes on the stability and point of failures for the SDF
|
|
3385
|
+ * renderers (specifically `sdf`):
|
|
3386
|
+ *
|
|
3387
|
+ * 1. The `sdf` rasterizer is sensitive to really small features (e.g.
|
|
3388
|
+ * sharp turns which are less than 1 pixel) and imperfections in the
|
|
3389
|
+ * glyph's outline. Having these in the outline can cause artifats
|
|
3390
|
+ * in the final output.
|
|
3391
|
+ *
|
|
3392
|
+ * 2. The `sdf` rasterizer has limited support for handling intersecting
|
|
3393
|
+ * contours and *cannot* handle self-intersecting contours whatsoever.
|
|
3394
|
+ * Self intersection happens when a single connected contour intersect
|
|
3395
|
+ * itself at some point and having these in your font will definately
|
|
3396
|
+ * pose a problem to the rasterizer and cause artifacts.
|
|
3397
|
+ *
|
|
3398
|
+ * 3. Generating SDF for really small glyphs may result in undesirable
|
|
3399
|
+ * output due to limited availability of pixel grid to store distance
|
|
3400
|
+ * information.
|
|
3401
|
+ *
|
|
3402
|
+ * Point (1) and (2) can be avoided by using `bsdf` and overall it is
|
|
3403
|
+ * more stable than the `sdf` rasterizer.
|
|
3404
|
+ *
|
3371
|
3405
|
*/
|
3372
|
3406
|
typedef enum FT_Render_Mode_
|
3373
|
3407
|
{
|