pango-engine.h 15 KB

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