pango-engine.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /* Pango
  2. * pango-engine.h: Engines for script and language specific processing
  3. *
  4. * Copyright (C) 2000,2003 Red Hat Software
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef __PANGO_ENGINE_H__
  22. #define __PANGO_ENGINE_H__
  23. #include <pango/pango-types.h>
  24. #include <pango/pango-item.h>
  25. #include <pango/pango-font.h>
  26. #include <pango/pango-glyph.h>
  27. #include <pango/pango-script.h>
  28. G_BEGIN_DECLS
  29. /* All of this is deprecated and entirely useless for bindings.
  30. * Leave it out of the gir file.
  31. */
  32. #ifndef __GI_SCANNER__
  33. #ifndef PANGO_DISABLE_DEPRECATED
  34. /**
  35. * PANGO_RENDER_TYPE_NONE:
  36. *
  37. * A string constant defining the render type
  38. * for engines that are not rendering-system specific.
  39. *
  40. * Deprecated: 1.38
  41. */
  42. #define PANGO_RENDER_TYPE_NONE "PangoRenderNone"
  43. #define PANGO_TYPE_ENGINE (pango_engine_get_type ())
  44. #define PANGO_ENGINE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE, PangoEngine))
  45. #define PANGO_IS_ENGINE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE))
  46. #define PANGO_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE, PangoEngineClass))
  47. #define PANGO_IS_ENGINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE))
  48. #define PANGO_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE, PangoEngineClass))
  49. typedef struct _PangoEngine PangoEngine;
  50. typedef struct _PangoEngineClass PangoEngineClass;
  51. /**
  52. * PangoEngine:
  53. *
  54. * `PangoEngine` is the base class for all types of language and
  55. * script specific engines. It has no functionality by itself.
  56. *
  57. * Deprecated: 1.38
  58. **/
  59. struct _PangoEngine
  60. {
  61. /*< private >*/
  62. GObject parent_instance;
  63. };
  64. /**
  65. * PangoEngineClass:
  66. *
  67. * Class structure for `PangoEngine`
  68. *
  69. * Deprecated: 1.38
  70. **/
  71. struct _PangoEngineClass
  72. {
  73. /*< private >*/
  74. GObjectClass parent_class;
  75. };
  76. PANGO_DEPRECATED_IN_1_38
  77. GType pango_engine_get_type (void) G_GNUC_CONST;
  78. /**
  79. * PANGO_ENGINE_TYPE_LANG:
  80. *
  81. * A string constant defining the engine type for language engines.
  82. * These engines derive from `PangoEngineLang`.
  83. *
  84. * Deprecated: 1.38
  85. */
  86. #define PANGO_ENGINE_TYPE_LANG "PangoEngineLang"
  87. #define PANGO_TYPE_ENGINE_LANG (pango_engine_lang_get_type ())
  88. #define PANGO_ENGINE_LANG(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE_LANG, PangoEngineLang))
  89. #define PANGO_IS_ENGINE_LANG(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE_LANG))
  90. #define PANGO_ENGINE_LANG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE_LANG, PangoEngineLangClass))
  91. #define PANGO_IS_ENGINE_LANG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE_LANG))
  92. #define PANGO_ENGINE_LANG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE_LANG, PangoEngineLangClass))
  93. typedef struct _PangoEngineLangClass PangoEngineLangClass;
  94. /**
  95. * PangoEngineLang:
  96. *
  97. * The `PangoEngineLang` class is implemented by engines that
  98. * customize the rendering-system independent part of the
  99. * Pango pipeline for a particular script or language. For
  100. * instance, a custom `PangoEngineLang` could be provided for
  101. * Thai to implement the dictionary-based word boundary
  102. * lookups needed for that language.
  103. *
  104. * Deprecated: 1.38
  105. **/
  106. struct _PangoEngineLang
  107. {
  108. /*< private >*/
  109. PangoEngine parent_instance;
  110. };
  111. /**
  112. * PangoEngineLangClass:
  113. * @script_break: (nullable): Provides a custom implementation of
  114. * pango_break(). If %NULL, pango_default_break() is used instead. If
  115. * not %NULL, for Pango versions before 1.16 (module interface version
  116. * before 1.6.0), this was called instead of pango_default_break(),
  117. * but in newer versions, pango_default_break() is always called and
  118. * this is called after that to allow tailoring the breaking results.
  119. *
  120. * Class structure for `PangoEngineLang`
  121. *
  122. * Deprecated: 1.38
  123. **/
  124. struct _PangoEngineLangClass
  125. {
  126. /*< private >*/
  127. PangoEngineClass parent_class;
  128. /*< public >*/
  129. void (*script_break) (PangoEngineLang *engine,
  130. const char *text,
  131. int len,
  132. PangoAnalysis *analysis,
  133. PangoLogAttr *attrs,
  134. int attrs_len);
  135. };
  136. PANGO_DEPRECATED_IN_1_38
  137. GType pango_engine_lang_get_type (void) G_GNUC_CONST;
  138. /**
  139. * PANGO_ENGINE_TYPE_SHAPE:
  140. *
  141. * A string constant defining the engine type for shaping engines.
  142. * These engines derive from `PangoEngineShape`.
  143. *
  144. * Deprecated: 1.38
  145. */
  146. #define PANGO_ENGINE_TYPE_SHAPE "PangoEngineShape"
  147. #define PANGO_TYPE_ENGINE_SHAPE (pango_engine_shape_get_type ())
  148. #define PANGO_ENGINE_SHAPE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ENGINE_SHAPE, PangoEngineShape))
  149. #define PANGO_IS_ENGINE_SHAPE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ENGINE_SHAPE))
  150. #define PANGO_ENGINE_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ENGINE_SHAPE, PangoEngineShapeClass))
  151. #define PANGO_IS_ENGINE_SHAPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ENGINE_SHAPE))
  152. #define PANGO_ENGINE_SHAPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ENGINE_SHAPE, PangoEngineShapeClass))
  153. typedef struct _PangoEngineShapeClass PangoEngineShapeClass;
  154. /**
  155. * PangoEngineShape:
  156. *
  157. * The `PangoEngineShape` class is implemented by engines that
  158. * customize the rendering-system dependent part of the
  159. * Pango pipeline for a particular script or language.
  160. * A `PangoEngineShape` implementation is then specific to both
  161. * a particular rendering system or group of rendering systems
  162. * and to a particular script. For instance, there is one
  163. * `PangoEngineShape` implementation to handle shaping Arabic
  164. * for Fontconfig-based backends.
  165. *
  166. * Deprecated: 1.38
  167. **/
  168. struct _PangoEngineShape
  169. {
  170. PangoEngine parent_instance;
  171. };
  172. /**
  173. * PangoEngineShapeClass:
  174. * @script_shape: Given a font, a piece of text, and a `PangoAnalysis`
  175. * structure, converts characters to glyphs and positions the
  176. * resulting glyphs. The results are stored in the `PangoGlyphString`
  177. * that is passed in. (The implementation should resize it
  178. * appropriately using pango_glyph_string_set_size()). All fields
  179. * of the @log_clusters and @glyphs array must be filled in, with
  180. * the exception that Pango will automatically generate
  181. * `glyphs->glyphs[i].attr.is_cluster_start`
  182. * using the @log_clusters array. Each input character must occur in one
  183. * of the output logical clusters;
  184. * if no rendering is desired for a character, this may involve
  185. * inserting glyphs with the `PangoGlyph` ID %PANGO_GLYPH_EMPTY, which
  186. * is guaranteed never to render. If the shaping fails for any reason,
  187. * the shaper should return with an empty (zero-size) glyph string.
  188. * If the shaper has not set the size on the glyph string yet, simply
  189. * returning signals the failure too.
  190. * @covers: Returns the characters that this engine can cover
  191. * with a given font for a given language. If not overridden, the default
  192. * implementation simply returns the coverage information for the
  193. * font itself unmodified.
  194. *
  195. * Class structure for `PangoEngineShape`
  196. *
  197. * Deprecated: 1.38
  198. **/
  199. struct _PangoEngineShapeClass
  200. {
  201. /*< private >*/
  202. PangoEngineClass parent_class;
  203. /*< public >*/
  204. void (*script_shape) (PangoEngineShape *engine,
  205. PangoFont *font,
  206. const char *item_text,
  207. unsigned int item_length,
  208. const PangoAnalysis *analysis,
  209. PangoGlyphString *glyphs,
  210. const char *paragraph_text,
  211. unsigned int paragraph_length);
  212. PangoCoverageLevel (*covers) (PangoEngineShape *engine,
  213. PangoFont *font,
  214. PangoLanguage *language,
  215. gunichar wc);
  216. };
  217. PANGO_DEPRECATED_IN_1_38
  218. GType pango_engine_shape_get_type (void) G_GNUC_CONST;
  219. typedef struct _PangoEngineInfo PangoEngineInfo;
  220. typedef struct _PangoEngineScriptInfo PangoEngineScriptInfo;
  221. /**
  222. * PangoEngineScriptInfo:
  223. * @script: a `PangoScript`. The value %PANGO_SCRIPT_COMMON has
  224. * the special meaning here of "all scripts"
  225. * @langs: a semicolon separated list of languages that this
  226. * engine handles for this script. This may be empty,
  227. * in which case the engine is saying that it is a
  228. * fallback choice for all languages for this range,
  229. * but should not be used if another engine
  230. * indicates that it is specific for the language for
  231. * a given code point. An entry in this list of "*"
  232. * indicates that this engine is specific to all
  233. * languages for this range.
  234. *
  235. * The `PangoEngineScriptInfo` structure contains
  236. * information about how the shaper covers a particular script.
  237. *
  238. * Deprecated: 1.38
  239. */
  240. struct _PangoEngineScriptInfo
  241. {
  242. PangoScript script;
  243. const gchar *langs;
  244. };
  245. /**
  246. * PangoEngineInfo:
  247. * @id: a unique string ID for the engine.
  248. * @engine_type: a string identifying the engine type.
  249. * @render_type: a string identifying the render type.
  250. * @scripts: array of scripts this engine supports.
  251. * @n_scripts: number of items in @scripts.
  252. *
  253. * The `PangoEngineInfo` structure contains information about a particular
  254. * engine. It contains the following fields:
  255. *
  256. * Deprecated: 1.38
  257. */
  258. struct _PangoEngineInfo
  259. {
  260. const gchar *id;
  261. const gchar *engine_type;
  262. const gchar *render_type;
  263. PangoEngineScriptInfo *scripts;
  264. gint n_scripts;
  265. };
  266. /**
  267. * script_engine_list: (skip)
  268. * @engines: location to store a pointer to an array of engines.
  269. * @n_engines: location to store the number of elements in @engines.
  270. *
  271. * Do not use.
  272. *
  273. * Deprecated: 1.38
  274. **/
  275. PANGO_DEPRECATED_IN_1_38
  276. void script_engine_list (PangoEngineInfo **engines,
  277. int *n_engines);
  278. /**
  279. * script_engine_init: (skip)
  280. * @module: a `GTypeModule` structure used to associate any
  281. * GObject types created in this module with the module.
  282. *
  283. * Do not use.
  284. *
  285. * Deprecated: 1.38
  286. **/
  287. PANGO_DEPRECATED_IN_1_38
  288. void script_engine_init (GTypeModule *module);
  289. /**
  290. * script_engine_exit: (skip)
  291. *
  292. * Do not use.
  293. *
  294. * Deprecated: 1.38
  295. **/
  296. PANGO_DEPRECATED_IN_1_38
  297. void script_engine_exit (void);
  298. /**
  299. * script_engine_create: (skip)
  300. * @id: the ID of an engine as reported by script_engine_list.
  301. *
  302. * Do not use.
  303. *
  304. * Deprecated: 1.38
  305. **/
  306. PANGO_DEPRECATED_IN_1_38
  307. PangoEngine *script_engine_create (const char *id);
  308. /* Utility macro used by PANGO_ENGINE_LANG_DEFINE_TYPE and
  309. * PANGO_ENGINE_LANG_DEFINE_TYPE
  310. */
  311. #define PANGO_ENGINE_DEFINE_TYPE(name, prefix, class_init, instance_init, parent_type) \
  312. static GType prefix ## _type; \
  313. static void \
  314. prefix ## _register_type (GTypeModule *module) \
  315. { \
  316. const GTypeInfo object_info = \
  317. { \
  318. sizeof (name ## Class), \
  319. (GBaseInitFunc) NULL, \
  320. (GBaseFinalizeFunc) NULL, \
  321. (GClassInitFunc) class_init, \
  322. (GClassFinalizeFunc) NULL, \
  323. NULL, /* class_data */ \
  324. sizeof (name), \
  325. 0, /* n_prelocs */ \
  326. (GInstanceInitFunc) instance_init, \
  327. NULL /* value_table */ \
  328. }; \
  329. \
  330. prefix ## _type = g_type_module_register_type (module, parent_type, \
  331. # name, \
  332. &object_info, 0); \
  333. }
  334. /**
  335. * PANGO_ENGINE_LANG_DEFINE_TYPE:
  336. * @name: Name of the the type to register (for example:, ArabicEngineFc)
  337. * @prefix: Prefix for symbols that will be defined (for example:, arabic_engine_fc)
  338. * @class_init: (nullable): Class initialization function for the new type
  339. * @instance_init: (nullable): Instance initialization function for the new type
  340. *
  341. * Outputs the necessary code for GObject type registration for a
  342. * `PangoEngineLang` class defined in a module. Two static symbols
  343. * are defined.
  344. *
  345. * <programlisting>
  346. * static GType *prefix*_type;
  347. * static void *prefix*_register_type (GTypeModule module);
  348. *
  349. * The *prefix*_register_type()
  350. * function should be called in your script_engine_init() function for
  351. * each type that your module implements, and then your script_engine_create()
  352. * function can create instances of the object as follows:
  353. *
  354. * ```
  355. * PangoEngine *engine = g_object_new (prefix_type, NULL);
  356. * ```
  357. *
  358. * Deprecated: 1.38
  359. **/
  360. #define PANGO_ENGINE_LANG_DEFINE_TYPE(name, prefix, class_init, instance_init) \
  361. PANGO_ENGINE_DEFINE_TYPE (name, prefix, \
  362. class_init, instance_init, \
  363. PANGO_TYPE_ENGINE_LANG)
  364. /**
  365. * PANGO_ENGINE_SHAPE_DEFINE_TYPE:
  366. * @name: Name of the the type to register (for example:, ArabicEngineFc)
  367. * @prefix: Prefix for symbols that will be defined (for example:, arabic_engine_fc)
  368. * @class_init: (nullable): Class initialization function for the new type
  369. * @instance_init: (nullable): Instance initialization function for the new type
  370. *
  371. * Outputs the necessary code for GObject type registration for a
  372. * `PangoEngineShape` class defined in a module. Two static symbols
  373. * are defined.
  374. *
  375. * <programlisting>
  376. * static GType *prefix*_type;
  377. * static void *prefix*_register_type (GTypeModule module);
  378. * </programlisting>
  379. *
  380. * The *prefix*_register_type()
  381. * function should be called in your script_engine_init() function for
  382. * each type that your module implements, and then your script_engine_create()
  383. * function can create instances of the object as follows:
  384. *
  385. * ```
  386. * PangoEngine *engine = g_object_new (prefix_type, NULL);
  387. * ```
  388. *
  389. * Deprecated: 1.38
  390. **/
  391. #define PANGO_ENGINE_SHAPE_DEFINE_TYPE(name, prefix, class_init, instance_init) \
  392. PANGO_ENGINE_DEFINE_TYPE (name, prefix, \
  393. class_init, instance_init, \
  394. PANGO_TYPE_ENGINE_SHAPE)
  395. /* Macro used for possibly builtin Pango modules. Not useful
  396. * for externally build modules. If we are compiling a module standalone,
  397. * then we name the entry points script_engine_list, etc. But if we
  398. * are compiling it for inclusion directly in Pango, then we need them to
  399. * to have distinct names for this module, so we prepend a prefix.
  400. *
  401. * The two intermediate macros are to deal with details of the C
  402. * preprocessor; token pasting tokens must be function arguments,
  403. * and macro substitution isn't used on function arguments that
  404. * are used for token pasting.
  405. */
  406. #ifdef PANGO_MODULE_PREFIX
  407. #define PANGO_MODULE_ENTRY(func) _PANGO_MODULE_ENTRY2(PANGO_MODULE_PREFIX,func)
  408. #define _PANGO_MODULE_ENTRY2(prefix,func) _PANGO_MODULE_ENTRY3(prefix,func)
  409. #define _PANGO_MODULE_ENTRY3(prefix,func) prefix##_script_engine_##func
  410. #else
  411. #define PANGO_MODULE_ENTRY(func) script_engine_##func
  412. #endif
  413. #endif /* PANGO_DISABLE_DEPRECATED */
  414. #endif /* __GI_SCANNER__ */
  415. G_END_DECLS
  416. #endif /* __PANGO_ENGINE_H__ */