選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

382 行
14 KiB

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