• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2  *
3  * ftsdfrend.h
4  *
5  *   Signed Distance Field renderer interface (specification).
6  *
7  * Copyright (C) 2020-2023 by
8  * David Turner, Robert Wilhelm, and Werner Lemberg.
9  *
10  * Written by Anuj Verma.
11  *
12  * This file is part of the FreeType project, and may only be used,
13  * modified, and distributed under the terms of the FreeType project
14  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
15  * this file you indicate that you have read the license and
16  * understand and accept it fully.
17  *
18  */
19 
20 
21 #ifndef FTSDFREND_H_
22 #define FTSDFREND_H_
23 
24 #include <freetype/ftrender.h>
25 #include <freetype/ftmodapi.h>
26 #include <freetype/internal/ftobjs.h>
27 
28 FT_BEGIN_HEADER
29 
30 
31   /**************************************************************************
32    *
33    * @struct:
34    *   SDF_Renderer_Module
35    *
36    * @description:
37    *   This struct extends the native renderer struct `FT_RendererRec`.  It
38    *   is basically used to store various parameters required by the
39    *   renderer and some additional parameters that can be used to tweak the
40    *   output of the renderer.
41    *
42    * @fields:
43    *   root ::
44    *     The native rendere struct.
45    *
46    *   spread ::
47    *     This is an essential parameter/property required by the renderer.
48    *     `spread` defines the maximum unsigned value that is present in the
49    *     final SDF output.  For the default value check file
50    *     `ftsdfcommon.h`.
51    *
52    *   flip_sign ::
53    *     By default positive values indicate positions inside of contours,
54    *     i.e., filled by a contour.  If this property is true then that
55    *     output will be the opposite of the default, i.e., negative values
56    *     indicate positions inside of contours.
57    *
58    *   flip_y ::
59    *     Setting this parameter to true makes the output image flipped
60    *     along the y-axis.
61    *
62    *   overlaps ::
63    *     Set this to true to generate SDF for glyphs having overlapping
64    *     contours.  The overlapping support is limited to glyphs that do not
65    *     have self-intersecting contours.  Also, removing overlaps require a
66    *     considerable amount of extra memory; additionally, it will not work
67    *     if generating SDF from bitmap.
68    *
69    * @note:
70    *   All properties except `overlaps` are valid for both the 'sdf' and
71    *   'bsdf' renderers.
72    *
73    */
74   typedef struct  SDF_Renderer_Module_
75   {
76     FT_RendererRec  root;
77     FT_UInt         spread;
78     FT_Bool         flip_sign;
79     FT_Bool         flip_y;
80     FT_Bool         overlaps;
81 
82   } SDF_Renderer_Module, *SDF_Renderer;
83 
84 
85   /**************************************************************************
86    *
87    * @renderer:
88    *   ft_sdf_renderer_class
89    *
90    * @description:
91    *   Renderer to convert @FT_Outline to signed distance fields.
92    *
93    */
94   FT_DECLARE_RENDERER( ft_sdf_renderer_class )
95 
96 
97   /**************************************************************************
98    *
99    * @renderer:
100    *   ft_bitmap_sdf_renderer_class
101    *
102    * @description:
103    *   This is not exactly a renderer; it is just a converter that
104    *   transforms bitmaps to signed distance fields.
105    *
106    * @note:
107    *   This is not a separate module, it is part of the 'sdf' module.
108    *
109    */
110   FT_DECLARE_RENDERER( ft_bitmap_sdf_renderer_class )
111 
112 
113 FT_END_HEADER
114 
115 #endif /* FTSDFREND_H_ */
116 
117 
118 /* END */
119