|
| 1 | +{ |
| 2 | + This file is part of: |
| 3 | +
|
| 4 | + SDL3 for Pascal |
| 5 | + (https://github.com/PascalGameDevelopment/SDL3-for-Pascal) |
| 6 | + SPDX-License-Identifier: Zlib |
| 7 | +} |
| 8 | + |
| 9 | +{$DEFINE SDL_TTF_TEXTENGINE} |
| 10 | + |
| 11 | +{* |
| 12 | + * \file SDL_textengine.h |
| 13 | + * |
| 14 | + * Definitions for implementations of the TTF_TextEngine interface. |
| 15 | + } |
| 16 | + |
| 17 | +{* |
| 18 | + * A font atlas draw command. |
| 19 | + * |
| 20 | + * \since This enum is available since SDL_ttf 3.0.0. |
| 21 | + } |
| 22 | +type |
| 23 | + PPTTF_DrawCommand = ^PTTF_DrawCommand; |
| 24 | + PTTF_DrawCommand = ^TTTF_DrawCommand; |
| 25 | + TTTF_DrawCommand = type Integer; |
| 26 | +const |
| 27 | + TTF_DRAW_COMMAND_NOOP = TTTF_DrawCommand(0); |
| 28 | + TTF_DRAW_COMMAND_FILL = TTTF_DrawCommand(1); |
| 29 | + TTF_DRAW_COMMAND_COPY = TTTF_DrawCommand(2); |
| 30 | + |
| 31 | +{* |
| 32 | + * A filled rectangle draw operation. |
| 33 | + * |
| 34 | + * \since This struct is available since SDL_ttf 3.0.0. |
| 35 | + * |
| 36 | + * \sa TTF_DrawOperation |
| 37 | + } |
| 38 | +type |
| 39 | + PPTTF_FillOperation = ^PTTF_FillOperation; |
| 40 | + PTTF_FillOperation = ^TTTF_FillOperation; |
| 41 | + TTTF_FillOperation = record |
| 42 | + cmd: TTTF_DrawCommand; {*< TTF_DRAW_COMMAND_FILL } |
| 43 | + rect: TSDL_Rect; {*< The rectangle to fill, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down. } |
| 44 | + end; |
| 45 | + |
| 46 | +{* |
| 47 | + * A texture copy draw operation. |
| 48 | + * |
| 49 | + * \since This struct is available since SDL_ttf 3.0.0. |
| 50 | + * |
| 51 | + * \sa TTF_DrawOperation |
| 52 | + } |
| 53 | +type |
| 54 | + PPTTF_CopyOperation = ^PTTF_CopyOperation; |
| 55 | + PTTF_CopyOperation = ^TTTF_CopyOperation; |
| 56 | + TTTF_CopyOperation = record |
| 57 | + cmd: TTTF_DrawCommand; {*< TTF_DRAW_COMMAND_COPY } |
| 58 | + text_offset: cint; {*< The offset in the text corresponding to this glyph. |
| 59 | + There may be multiple glyphs with the same text offset |
| 60 | + and the next text offset might be several Unicode codepoints |
| 61 | + later. In this case the glyphs and codepoints are grouped |
| 62 | + together and the group bounding box is the union of the dst |
| 63 | + rectangles for the corresponding glyphs. } |
| 64 | + glyph_font: PTTF_Font; {*< The font containing the glyph to be drawn, can be passed to TTF_GetGlyphImageForIndex() } |
| 65 | + glyph_index: cuint32; {*< The glyph index of the glyph to be drawn, can be passed to TTF_GetGlyphImageForIndex() } |
| 66 | + src: TSDL_Rect; {*< The area within the glyph to be drawn } |
| 67 | + dst: TSDL_Rect; {*< The drawing coordinates of the glyph, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down. } |
| 68 | + reserved: Pointer; |
| 69 | + end; |
| 70 | + |
| 71 | +{* |
| 72 | + * A text engine draw operation. |
| 73 | + * |
| 74 | + * \since This struct is available since SDL_ttf 3.0.0. |
| 75 | + } |
| 76 | +type |
| 77 | + PPTTF_DrawOperation = ^PTTF_DrawOperation; |
| 78 | + PTTF_DrawOperation = ^TTTF_DrawOperation; |
| 79 | + TTTF_DrawOperation = record |
| 80 | + case Integer of |
| 81 | + 0: (cmd: TTTF_DrawCommand); |
| 82 | + 1: (fill: TTTF_FillOperation); |
| 83 | + 2: (copy: TTTF_CopyOperation); |
| 84 | + end; |
| 85 | + |
| 86 | +{ Private data in TTF_Text, to assist in text measurement and layout } |
| 87 | +type |
| 88 | + PPTTF_TextLayout = ^PTTF_TextLayout; |
| 89 | + PTTF_TextLayout = type Pointer; |
| 90 | + |
| 91 | +{ Private data in TTF_Text, available to implementations |
| 92 | +
|
| 93 | + #note : SDL3-for-Pascal: |
| 94 | +
|
| 95 | + In C TTF_TextData is defined in two different namespaces as |
| 96 | + typedef struct (SDL3_ttf.h) and as struct (SDL_textengine.h). |
| 97 | + This is not possible in Pascal; causes "duplicate identifier" |
| 98 | + error. Therefore the struct's name has an underscore added |
| 99 | + here. } |
| 100 | +type |
| 101 | + PPTTF_TextData_ = ^PTTF_TextData_; |
| 102 | + PTTF_TextData_ = ^TTTF_TextData_; |
| 103 | + TTTF_TextData_ = record |
| 104 | + font: PTTF_Font; {*< The font used by this text, read-only. } |
| 105 | + color: TSDL_FColor; {*< The color of the text, read-only. } |
| 106 | + |
| 107 | + needs_layout_update: cbool; {*< True if the layout needs to be updated } |
| 108 | + layout: PTTF_TextLayout; {*< Cached layout information, read-only. } |
| 109 | + x: cint; {*< The x offset of the upper left corner of this text, in pixels, read-only. } |
| 110 | + y: cint; {*< The y offset of the upper left corner of this text, in pixels, read-only. } |
| 111 | + w: cint; {*< The width of this text, in pixels, read-only. } |
| 112 | + h: cint; {*< The height of this text, in pixels, read-only. } |
| 113 | + num_ops: cint; {*< The number of drawing operations to render this text, read-only. } |
| 114 | + ops: PTTF_DrawOperation; {*< The drawing operations used to render this text, read-only. } |
| 115 | + num_clusters: cint; {*< The number of substrings representing clusters of glyphs in the string, read-only } |
| 116 | + clusters: PTTF_SubString; {*< Substrings representing clusters of glyphs in the string, read-only } |
| 117 | + |
| 118 | + props: TSDL_PropertiesID; {*< Custom properties associated with this text, read-only. This field is created as-needed using TTF_GetTextProperties() and the properties may be then set and read normally } |
| 119 | + |
| 120 | + needs_engine_update: cbool; {*< True if the engine text needs to be updated } |
| 121 | + engine: PTTF_TextEngine; {*< The engine used to render this text, read-only. } |
| 122 | + engine_text: Pointer; {*< The implementation-specific representation of this text } |
| 123 | + end; |
| 124 | + |
| 125 | +{* |
| 126 | + * A text engine interface. |
| 127 | + * |
| 128 | + * This structure should be initialized using SDL_INIT_INTERFACE() |
| 129 | + * |
| 130 | + * \since This struct is available since SDL_ttf 3.0.0. |
| 131 | + * |
| 132 | + * \sa SDL_INIT_INTERFACE |
| 133 | +
|
| 134 | +#note : SDL3-for-Pascal: |
| 135 | +
|
| 136 | + In C TTF_TextEngine is defined in two different namespaces as |
| 137 | + typedef struct (SDL3_ttf.h) and as struct (SDL_textengine.h). |
| 138 | + This is not possible in Pascal; causes "duplicate identifier" |
| 139 | + error. Therefore the struct's name has an underscore added |
| 140 | + here. } |
| 141 | +type |
| 142 | + PPTTF_TextEngine_ = ^PTTF_TextEngine_; |
| 143 | + PTTF_TextEngine_ = ^TTTF_TextEngine_; |
| 144 | + TTTF_TextEngine_ = record |
| 145 | + version: cuint32; {*< The version of this interface } |
| 146 | + userdata: Pointer; {*< User data Pointer passed to callbacks } |
| 147 | + |
| 148 | + { Create a text representation from draw instructions. |
| 149 | + * |
| 150 | + * All fields of `text` except `internal->engine_text` will already be filled out. |
| 151 | + * |
| 152 | + * This function should set the `internal->engine_text` field to a non-nil value. |
| 153 | + * |
| 154 | + * \param userdata the userdata Pointer in this interface. |
| 155 | + * \param text the text object being created. |
| 156 | + } |
| 157 | + CreateText: function(userdata: Pointer; text: PTTF_Text): cbool; cdecl; |
| 158 | + |
| 159 | + {* |
| 160 | + * Destroy a text representation. |
| 161 | + } |
| 162 | + DestroyText: procedure(userdata: Pointer; text: PTTF_Text); cdecl; |
| 163 | + end; |
| 164 | + |
| 165 | +{ Check the size of TTF_TextEngine |
| 166 | + * |
| 167 | + * If this assert fails, either the compiler is padding to an unexpected size, |
| 168 | + * or the interface has been updated and this should be updated to match and |
| 169 | + * the code using this interface should be updated to handle the old version. |
| 170 | + } |
| 171 | +{ #todo : SDL3-for-Pascal: Implement } |
| 172 | +// SDL_COMPILE_TIME_ASSERT(TTF_TextEngine_SIZE, ... |
| 173 | + |
| 174 | + |
0 commit comments