1 /* 2 * Distributed under the Boost Software License, Version 1.0. 3 * (See accompanying file LICENSE_1_0.txt or copy at 4 * http://www.boost.org/LICENSE_1_0.txt) 5 */ 6 module pango.c.engine; 7 8 import pango.c.types; 9 import pango.c.item; 10 import pango.c.font; 11 import pango.c.glyph; 12 import pango.c.script; 13 import pango.c.coverage; 14 import pango.c.break_; 15 16 import glib; 17 import gobject; 18 19 version (Backend) {} 20 else { 21 struct PangoEngineLang; 22 struct PangoEngineShape; 23 } 24 25 26 version (Backend) { 27 /* Module API */ 28 29 //#include <gmodule.h> 30 31 /** 32 * PangoEngine: 33 * 34 * #PangoEngine is the base class for all types of language and 35 * script specific engines. It has no functionality by itself. 36 **/ 37 struct PangoEngine 38 { 39 /*< private >*/ 40 GObject parent_instance; 41 }; 42 43 /** 44 * PangoEngineClass: 45 * 46 * Class structure for #PangoEngine 47 **/ 48 struct PangoEngineClass 49 { 50 /*< private >*/ 51 GObjectClass parent_class; 52 }; 53 54 pure GType pango_engine_get_type (); 55 56 57 /** 58 * PangoEngineLang: 59 * 60 * The #PangoEngineLang class is implemented by engines that 61 * customize the rendering-system independent part of the 62 * Pango pipeline for a particular script or language. For 63 * instance, a custom #PangoEngineLang could be provided for 64 * Thai to implement the dictionary-based word boundary 65 * lookups needed for that language. 66 **/ 67 struct PangoEngineLang 68 { 69 /*< private >*/ 70 PangoEngine parent_instance; 71 }; 72 73 /** 74 * PangoEngineLangClass: 75 * @script_break: Provides a custom implementation of pango_break(). 76 * If %NULL, pango_default_break() is used instead. If not %NULL, for 77 * Pango versions before 1.16 (module interface version before 1.6.0), 78 * this was called instead of pango_default_break(), but in newer versions, 79 * pango_default_break() is always called and this is called after that to 80 * allow tailoring the breaking results. 81 * 82 * Class structure for #PangoEngineLang 83 **/ 84 struct PangoEngineLangClass 85 { 86 /*< private >*/ 87 PangoEngineClass parent_class; 88 89 /*< public >*/ 90 void function (PangoEngineLang *engine, 91 const(char) *text, 92 int len, 93 PangoAnalysis *analysis, 94 PangoLogAttr *attrs, 95 int attrs_len) script_break; 96 }; 97 98 pure GType pango_engine_lang_get_type (); 99 100 101 /** 102 * PangoEngineShape 103 * 104 * The #PangoEngineShape class is implemented by engines that 105 * customize the rendering-system dependent part of the 106 * Pango pipeline for a particular script or language. 107 * A #PangoEngineShape implementation is then specific to both 108 * a particular rendering system or group of rendering systems 109 * and to a particular script. For instance, there is one 110 * #PangoEngineShape implementation to handle shaping Arabic 111 * for Fontconfig-based backends. 112 **/ 113 struct PangoEngineShape 114 { 115 PangoEngine parent_instance; 116 } 117 118 /** 119 * PangoEngineShapeClass: 120 * @script_shape: Given a font, a piece of text, and a #PangoAnalysis 121 * structure, converts characters to glyphs and positions the 122 * resulting glyphs. The results are stored in the #PangoGlyphString 123 * that is passed in. (The implementation should resize it 124 * appropriately using pango_glyph_string_set_size()). All fields 125 * of the @log_clusters and @glyphs array must be filled in, with 126 * the exception that Pango will automatically generate 127 * <literal>glyphs->glyphs[i].attr.is_cluster_start</literal> 128 * using the @log_clusters array. Each input character must occur in one 129 * of the output logical clusters; 130 * if no rendering is desired for a character, this may involve 131 * inserting glyphs with the #PangoGlyph ID #PANGO_GLYPH_EMPTY, which 132 * is guaranteed never to render. If the shaping fails for any reason, 133 * the shaper should return with an empty (zero-size) glyph string. 134 * If the shaper has not set the size on the glyph string yet, simply 135 * returning signals the failure too. 136 * @covers: Returns the characters that this engine can cover 137 * with a given font for a given language. If not overridden, the default 138 * implementation simply returns the coverage information for the 139 * font itself unmodified. 140 * 141 * Class structure for #PangoEngineShape 142 **/ 143 struct PangoEngineShapeClass 144 { 145 /*< private >*/ 146 PangoEngineClass parent_class; 147 148 /*< public >*/ 149 void function (PangoEngineShape *engine, 150 PangoFont *font, 151 const(char) *item_text, 152 uint item_length, 153 const(PangoAnalysis) *analysis, 154 PangoGlyphString *glyphs, 155 const(char) *paragraph_text, 156 uint paragraph_length) script_shape; 157 PangoCoverageLevel function (PangoEngineShape *engine, 158 PangoFont *font, 159 PangoLanguage *language, 160 gunichar wc) covers; 161 } 162 163 GType pango_engine_shape_get_type (); 164 165 166 /** 167 * PangoEngineScriptInfo 168 * @script: a #PangoScript. The value %PANGO_SCRIPT_COMMON has 169 * the special meaning here of "all scripts" 170 * @langs: a semicolon separated list of languages that this 171 * engine handles for this script. This may be empty, 172 * in which case the engine is saying that it is a 173 * fallback choice for all languages for this range, 174 * but should not be used if another engine 175 * indicates that it is specific for the language for 176 * a given code point. An entry in this list of "*" 177 * indicates that this engine is specific to all 178 * languages for this range. 179 * 180 * The #PangoEngineScriptInfo structure contains 181 * information about how the shaper covers a particular script. 182 */ 183 struct PangoEngineScriptInfo 184 { 185 PangoScript script; 186 const(gchar) *langs; 187 } 188 189 /** 190 * PangoEngineInfo: 191 * @id: a unique string ID for the engine. 192 * @engine_type: a string identifying the engine type. 193 * @render_type: a string identifying the render type. 194 * @scripts: array of scripts this engine supports. 195 * @n_scripts: number of items in @scripts. 196 * 197 * The #PangoEngineInfo structure contains information about a particular 198 * engine. It contains the following fields: 199 */ 200 struct PangoEngineInfo 201 { 202 const(gchar) *id; 203 const(gchar) *engine_type; 204 const(gchar) *render_type; 205 PangoEngineScriptInfo *scripts; 206 gint n_scripts; 207 } 208 209 /** 210 * script_engine_list: 211 * @engines: location to store a pointer to an array of engines. 212 * @n_engines: location to store the number of elements in @engines. 213 * 214 * Function to be provided by a module to list the engines that the 215 * module supplies. The function stores a pointer to an array 216 * of #PangoEngineInfo structures and the length of that array in 217 * the given location. 218 * 219 * Note that script_engine_init() will not be called before this 220 * function. 221 **/ 222 void script_engine_list (PangoEngineInfo **engines, 223 int *n_engines); 224 225 /** 226 * script_engine_init: 227 * @module: a #GTypeModule structure used to associate any 228 * GObject types created in this module with the module. 229 * 230 * Function to be provided by a module to register any 231 * GObject types in the module. 232 **/ 233 void script_engine_init (GTypeModule *mod); 234 235 236 /** 237 * script_engine_exit: 238 * 239 * Function to be provided by the module that is called 240 * when the module is unloading. Frequently does nothing. 241 **/ 242 void script_engine_exit (); 243 244 /** 245 * script_engine_create: 246 * @id: the ID of an engine as reported by script_engine_list. 247 * 248 * Function to be provided by the module to create an instance 249 * of one of the engines implemented by the module. 250 * 251 * Return value: a newly created #PangoEngine of the specified 252 * type, or %NULL if an error occurred. (In normal operation, 253 * a module should not return %NULL. A %NULL return is only 254 * acceptable in the case where system misconfiguration or 255 * bugs in the driver routine are encountered.) 256 **/ 257 PangoEngine *script_engine_create (const(char) *id); 258 259 /* Utility macro used by PANGO_ENGINE_LANG_DEFINE_TYPE and 260 * PANGO_ENGINE_LANG_DEFINE_TYPE 261 */ 262 // #define PANGO_ENGINE_DEFINE_TYPE(name, prefix, class_init, instance_init, parent_type) \ 263 // static GType prefix ## _type; \ 264 // static void \ 265 // prefix ## _register_type (GTypeModule *module) \ 266 // { \ 267 // const GTypeInfo object_info = \ 268 // { \ 269 // sizeof (name ## Class), \ 270 // (GBaseInitFunc) NULL, \ 271 // (GBaseFinalizeFunc) NULL, \ 272 // (GClassInitFunc) class_init, \ 273 // (GClassFinalizeFunc) NULL, \ 274 // NULL, /* class_data */ \ 275 // sizeof (name), \ 276 // 0, /* n_prelocs */ \ 277 // (GInstanceInitFunc) instance_init, \ 278 // NULL /* value_table */ \ 279 // }; \ 280 // \ 281 // prefix ## _type = g_type_module_register_type (module, parent_type, \ 282 // # name, \ 283 // &object_info, 0); \ 284 // } 285 286 /** 287 * PANGO_ENGINE_LANG_DEFINE_TYPE: 288 * @name: Name of the the type to register (for example:, <literal>ArabicEngineFc</literal> 289 * @prefix: Prefix for symbols that will be defined (for example:, <literal>arabic_engine_fc</literal> 290 * @class_init: Class initialization function for the new type, or %NULL 291 * @instance_init: Instance initialization function for the new type, or %NULL 292 * 293 * Outputs the necessary code for GObject type registration for a 294 * #PangoEngineLang class defined in a module. Two static symbols 295 * are defined. 296 * 297 * <programlisting> 298 * static GType <replaceable>prefix</replaceable>_type; 299 * static void <replaceable>prefix</replaceable>_register_type (GTypeModule module); 300 * </programlisting> 301 * 302 * The <function><replaceable>prefix</replaceable>_register_type()</function> 303 * function should be called in your script_engine_init() function for 304 * each type that your module implements, and then your script_engine_create() 305 * function can create instances of the object as follows: 306 * 307 * <informalexample><programlisting> 308 * PangoEngine *engine = g_object_new (<replaceable>prefix</replaceable>_type, NULL); 309 * </programlisting></informalexample> 310 **/ 311 // #define PANGO_ENGINE_LANG_DEFINE_TYPE(name, prefix, class_init, instance_init) \ 312 // PANGO_ENGINE_DEFINE_TYPE (name, prefix, \ 313 // class_init, instance_init, \ 314 // PANGO_TYPE_ENGINE_LANG) 315 316 /** 317 * PANGO_ENGINE_SHAPE_DEFINE_TYPE: 318 * @name: Name of the the type to register (for example:, <literal>ArabicEngineFc</literal> 319 * @prefix: Prefix for symbols that will be defined (for example:, <literal>arabic_engine_fc</literal> 320 * @class_init: Class initialization function for the new type, or %NULL 321 * @instance_init: Instance initialization function for the new type, or %NULL 322 * 323 * Outputs the necessary code for GObject type registration for a 324 * #PangoEngineShape class defined in a module. Two static symbols 325 * are defined. 326 * 327 * <programlisting> 328 * static GType <replaceable>prefix</replaceable>_type; 329 * static void <replaceable>prefix</replaceable>_register_type (GTypeModule module); 330 * </programlisting> 331 * 332 * The <function><replaceable>prefix</replaceable>_register_type()</function> 333 * function should be called in your script_engine_init() function for 334 * each type that your module implements, and then your script_engine_create() 335 * function can create instances of the object as follows: 336 * 337 * <informalexample><programlisting> 338 * PangoEngine *engine = g_object_new (<replaceable>prefix</replaceable>_type, NULL); 339 * </programlisting></informalexample> 340 **/ 341 // #define PANGO_ENGINE_SHAPE_DEFINE_TYPE(name, prefix, class_init, instance_init) \ 342 // PANGO_ENGINE_DEFINE_TYPE (name, prefix, \ 343 // class_init, instance_init, \ 344 // PANGO_TYPE_ENGINE_SHAPE) 345 346 /* Macro used for possibly builtin Pango modules. Not useful 347 * for externally build modules. If we are compiling a module standalone, 348 * then we name the entry points script_engine_list, etc. But if we 349 * are compiling it for inclusion directly in Pango, then we need them to 350 * to have distinct names for this module, so we prepend a prefix. 351 * 352 * The two intermediate macros are to deal with details of the C 353 * preprocessor; token pasting tokens must be function arguments, 354 * and macro substitution isn't used on function arguments that 355 * are used for token pasting. 356 */ 357 // #ifdef PANGO_MODULE_PREFIX 358 // #define PANGO_MODULE_ENTRY(func) _PANGO_MODULE_ENTRY2(PANGO_MODULE_PREFIX,func) 359 // #define _PANGO_MODULE_ENTRY2(prefix,func) _PANGO_MODULE_ENTRY3(prefix,func) 360 // #define _PANGO_MODULE_ENTRY3(prefix,func) prefix##_script_engine_##func 361 // #else 362 // #define PANGO_MODULE_ENTRY(func) script_engine_##func 363 // #endif 364 365 }