1 2 // Copyright 2019 - 2021 Michael D. Parker 3 // Distributed under the Boost Software License, Version 1.0. 4 // (See accompanying file LICENSE_1_0.txt or copy at 5 // http://www.boost.org/LICENSE_1_0.txt) 6 7 module bindbc.freetype.bind.ftimage; 8 9 import core.stdc.config; 10 import bindbc.freetype.config; 11 import bindbc.freetype.bind.fttypes; 12 13 alias FT_Pos = c_long; 14 15 struct FT_Vector { 16 FT_Pos x; 17 FT_Pos y; 18 } 19 20 struct FT_BBox { 21 FT_Pos xMin, yMin; 22 FT_Pos xMax, yMax; 23 } 24 25 alias FT_Pixel_Mode = int; 26 enum { 27 FT_PIXEL_MODE_NONE = 0, 28 FT_PIXEL_MODE_MONO, 29 FT_PIXEL_MODE_GRAY, 30 FT_PIXEL_MODE_GRAY2, 31 FT_PIXEL_MODE_GRAY4, 32 FT_PIXEL_MODE_LCD, 33 FT_PIXEL_MODE_LCD_V, 34 FT_PIXEL_MODE_MAX 35 } 36 37 struct FT_Bitmap { 38 uint rows; 39 uint width; 40 int pitch; 41 ubyte* buffer; 42 ushort num_grays; 43 ubyte pixel_mode; 44 ubyte palette_mode; 45 void* palette; 46 } 47 48 struct FT_Outline { 49 short n_contours; 50 short n_points; 51 FT_Vector* points; 52 byte* tags; 53 short* contours; 54 int flags; 55 } 56 57 enum FT_OUTLINE_CONTOURS_MAX = short.max; 58 enum FT_OUTLINE_POINTS_MAX = short.max; 59 60 static if(ftSupport >= FTSupport.ft211) { 61 enum : uint { 62 FT_OUTLINE_NONE = 0x0, 63 FT_OUTLINE_OWNER = 0x1, 64 FT_OUTLINE_EVEN_ODD_FILL = 0x2, 65 FT_OUTLINE_REVERSE_FILL = 0x4, 66 FT_OUTLINE_IGNORE_DROPOUTS = 0x8, 67 FT_OUTLINE_SMART_DROPOUTS = 0x10, 68 FT_OUTLINE_INCLUDE_STUBS = 0x20, 69 FT_OUTLINE_OVERLAP = 0x40, 70 FT_OUTLINE_HIGH_PRECISION = 0x100, 71 FT_OUTLINE_SINGLE_PASS = 0x200, 72 } 73 } 74 else { 75 enum : uint { 76 FT_OUTLINE_NONE = 0x0, 77 FT_OUTLINE_OWNER = 0x1, 78 FT_OUTLINE_EVEN_ODD_FILL = 0x2, 79 FT_OUTLINE_REVERSE_FILL = 0x4, 80 FT_OUTLINE_IGNORE_DROPOUTS = 0x8, 81 FT_OUTLINE_SMART_DROPOUTS = 0x10, 82 FT_OUTLINE_INCLUDE_STUBS = 0x20, 83 FT_OUTLINE_HIGH_PRECISION = 0x100, 84 FT_OUTLINE_SINGLE_PASS = 0x200, 85 } 86 } 87 88 enum { 89 FT_CURVE_TAG_ON = 1, 90 FT_CURVE_TAG_CONIC = 0, 91 FT_CURVE_TAG_CUBIC = 2, 92 FT_CURVE_TAG_TOUCH_X = 8, 93 FT_CURVE_TAG_TOUCH_Y = 16, 94 FT_CURVE_TAG_TOUCH_BOTH = FT_CURVE_TAG_TOUCH_X | FT_CURVE_TAG_TOUCH_Y, 95 } 96 97 extern(C) nothrow { 98 alias FT_Outline_MoveToFunc = int function(const(FT_Vector)*, void*); 99 alias FT_Outline_LineToFunc = int function(const(FT_Vector)*, void*); 100 alias FT_Outline_ConicToFunc = int function(const(FT_Vector)*, const(FT_Vector)*, void*); 101 alias FT_Outline_CubicToFunc = int function(const(FT_Vector)*, const(FT_Vector)*, const(FT_Vector)*, void*); 102 } 103 104 struct FT_Outline_Funcs { 105 FT_Outline_MoveToFunc move_to; 106 FT_Outline_LineToFunc line_to; 107 FT_Outline_ConicToFunc conic_to; 108 FT_Outline_CubicToFunc cubic_to; 109 int shift; 110 FT_Pos delta; 111 } 112 113 alias FT_Glyph_Format = FT_Tag; 114 enum : FT_Tag { 115 FT_GLYPH_FORMAT_NONE = 0, 116 FT_GLYPH_FORMAT_COMPOSITE = FT_MAKE_TAG('c','o','m','p'), 117 FT_GLYPH_FORMAT_BITMAP = FT_MAKE_TAG('b','i','t','s'), 118 FT_GLYPH_FORMAT_OUTLINE = FT_MAKE_TAG('o','u','t','l'), 119 FT_GLYPH_FORMAT_PLOTTER = FT_MAKE_TAG('p','l','o','t'), 120 } 121 122 struct FT_RasterRec; 123 alias FT_Raster = FT_RasterRec*; 124 125 struct FT_Span { 126 short x; 127 ushort len; 128 ubyte coverage; 129 } 130 131 extern(C) nothrow alias FT_SpanFunc = void function(int, int, FT_Span*, void*); 132 133 static if(ftSupport >= FTSupport.ft211) { 134 enum { 135 FT_RASTER_FLAG_DEFAULT = 0x0, 136 FT_RASTER_FLAG_AA = 0x1, 137 FT_RASTER_FLAG_DIRECT = 0x2, 138 FT_RASTER_FLAG_CLIP = 0x4, 139 FT_RASTER_FLAG_SDF = 0x8, 140 } 141 } 142 else { 143 enum { 144 FT_RASTER_FLAG_DEFAULT = 0x0, 145 FT_RASTER_FLAG_AA = 0x1, 146 FT_RASTER_FLAG_DIRECT = 0x2, 147 FT_RASTER_FLAG_CLIP = 0x4, 148 } 149 } 150 151 struct FT_Raster_Params { 152 const(FT_Bitmap)* target; 153 const(void)* source; 154 int flags; 155 FT_SpanFunc gray_spans; 156 void* black_spans; 157 void* bit_test; 158 void* bit_set; 159 void* user; 160 FT_BBox clip_box; 161 } 162 163 extern(C) nothrow { 164 alias FT_Raster_NewFunc = int function(void*, FT_Raster*); 165 alias FT_Raster_DoneFunc = void function(FT_Raster); 166 alias FT_Raster_ResetFunc = void function(FT_Raster, ubyte*, uint); 167 alias FT_Raster_SetModeFunc = int function(FT_Raster, uint, void*); 168 alias FT_Raster_RenderFunc = int function(FT_Raster, FT_Raster_Params*); 169 } 170 171 172 struct FT_Raster_Funcs { 173 FT_Glyph_Format glyph_format; 174 FT_Raster_NewFunc raster_new; 175 FT_Raster_ResetFunc raster_reset; 176 FT_Raster_SetModeFunc raster_set_mode; 177 FT_Raster_RenderFunc raster_render; 178 FT_Raster_DoneFunc raster_done; 179 }