pango-engine.h 15 KB

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