summaryrefslogtreecommitdiffstats
path: root/gfx/graphite2/include
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /gfx/graphite2/include
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/graphite2/include')
-rw-r--r--gfx/graphite2/include/graphite2/Font.h388
-rw-r--r--gfx/graphite2/include/graphite2/Log.h85
-rw-r--r--gfx/graphite2/include/graphite2/Segment.h461
-rw-r--r--gfx/graphite2/include/graphite2/Types.h72
-rw-r--r--gfx/graphite2/include/graphite2/XmlLog.h55
5 files changed, 1061 insertions, 0 deletions
diff --git a/gfx/graphite2/include/graphite2/Font.h b/gfx/graphite2/include/graphite2/Font.h
new file mode 100644
index 000000000..729ebff88
--- /dev/null
+++ b/gfx/graphite2/include/graphite2/Font.h
@@ -0,0 +1,388 @@
+/* GRAPHITE2 LICENSING
+
+ Copyright 2010, SIL International
+ All rights reserved.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should also have received a copy of the GNU Lesser General Public
+ License along with this library in the file named "LICENSE".
+ If not, write to the Free Software Foundation, 51 Franklin Street,
+ Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
+ internet at http://www.fsf.org/licenses/lgpl.html.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
+ General Public License, as published by the Free Software Foundation,
+ either version 2 of the License or (at your option) any later version.
+*/
+#pragma once
+
+#include "graphite2/Types.h"
+
+#define GR2_VERSION_MAJOR 1
+#define GR2_VERSION_MINOR 3
+#define GR2_VERSION_BUGFIX 10
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct gr_face gr_face;
+typedef struct gr_font gr_font;
+typedef struct gr_feature_ref gr_feature_ref;
+typedef struct gr_feature_val gr_feature_val;
+
+/**
+* Returns version information on this engine
+*/
+GR2_API void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix);
+
+/**
+* The Face Options allow the application to require that certain tables are
+* read during face construction. This may be of concern if the appFaceHandle
+* used in the gr_get_table_fn may change.
+* The values can be combined
+*/
+enum gr_face_options {
+ /** No preload, no cmap caching, fail if the graphite tables are invalid */
+ gr_face_default = 0,
+ /** Dumb rendering will be enabled if the graphite tables are invalid */
+ gr_face_dumbRendering = 1,
+ /** preload glyphs at construction time */
+ gr_face_preloadGlyphs = 2,
+ /** Cache the lookup from code point to glyph ID at construction time */
+ gr_face_cacheCmap = 4,
+ /** Preload everything */
+ gr_face_preloadAll = gr_face_preloadGlyphs | gr_face_cacheCmap
+};
+
+/** Holds information about a particular Graphite silf table that has been loaded */
+struct gr_faceinfo {
+ gr_uint16 extra_ascent; /**< The extra_ascent in the GDL, in design units */
+ gr_uint16 extra_descent; /**< The extra_descent in the GDL, in design units */
+ gr_uint16 upem; /**< The design units for the font */
+ enum gr_space_contextuals {
+ gr_space_unknown = 0, /**< no information is known. */
+ gr_space_none = 1, /**< the space character never occurs in any rules. */
+ gr_space_left_only = 2, /**< the space character only occurs as the first element in a rule. */
+ gr_space_right_only = 3, /**< the space character only occurs as the last element in a rule. */
+ gr_space_either_only = 4, /**< the space character only occurs as the only element in a rule. */
+ gr_space_both = 5, /**< the space character may occur as the first or last element of a rule. */
+ gr_space_cross = 6 /**< the space character occurs in a rule not as a first or last element. */
+ } space_contextuals;
+ unsigned int has_bidi_pass : 1; /**< the table specifies that a bidirectional pass should run */
+ unsigned int line_ends : 1; /**< there are line end contextuals somewhere */
+ unsigned int justifies : 1; /**< there are .justify properties set somewhere on some glyphs */
+};
+
+typedef struct gr_faceinfo gr_faceinfo;
+
+/** type describing function to retrieve font table information
+ *
+ * @return a pointer to the table in memory. The pointed to memory must exist as
+ * long as the gr_face which makes the call.
+ * @param appFaceHandle is the unique information passed to gr_make_face()
+ * @param name is a 32bit tag to the table name.
+ * @param len returned by this function to say how long the table is in memory.
+ */
+typedef const void *(*gr_get_table_fn)(const void* appFaceHandle, unsigned int name, size_t *len);
+
+/** type describing function to release any resources allocated by the above get_table table function
+ *
+ * @param appFaceHandle is the unique information passed to gr_make_face()
+ * @param pointer to table memory returned by get_table.
+ */
+typedef void (*gr_release_table_fn)(const void* appFaceHandle, const void *table_buffer);
+
+/** struct housing function pointers to manage font table buffers for the graphite engine. */
+struct gr_face_ops
+{
+ /** size in bytes of this structure */
+ size_t size;
+ /** a pointer to a function to request a table from the client. */
+ gr_get_table_fn get_table;
+ /** is a pointer to a function to notify the client the a table can be released.
+ * This can be NULL to signify that the client does not wish to do any release handling. */
+ gr_release_table_fn release_table;
+};
+typedef struct gr_face_ops gr_face_ops;
+
+/** Create a gr_face object given application information and a table functions.
+ *
+ * @return gr_face or NULL if the font fails to load for some reason.
+ * @param appFaceHandle This is application specific information that is passed
+ * to the getTable function. The appFaceHandle must stay
+ * alive as long as the gr_face is alive.
+ * @param face_ops Pointer to face specific callback structure for table
+ * management. Must stay alive for the duration of the
+ * call only.
+ * @param faceOptions Bitfield describing various options. See enum gr_face_options for details.
+ */
+GR2_API gr_face* gr_make_face_with_ops(const void* appFaceHandle/*non-NULL*/, const gr_face_ops *face_ops, unsigned int faceOptions);
+
+/** Create a gr_face object given application information and a getTable function. This function is deprecated as of v1.2.0 in
+ * favour of gr_make_face_with_ops.
+ *
+ * @return gr_face or NULL if the font fails to load for some reason.
+ * @param appFaceHandle This is application specific information that is passed
+ * to the getTable function. The appFaceHandle must stay
+ * alive as long as the gr_face is alive.
+ * @param getTable Callback function to get table data.
+ * @param faceOptions Bitfield describing various options. See enum gr_face_options for details.
+ */
+GR2_API gr_face* gr_make_face(const void* appFaceHandle/*non-NULL*/, gr_get_table_fn getTable, unsigned int faceOptions);
+
+//#ifndef GRAPHITE2_NSEGCACHE
+/** Create a gr_face object given application information, with subsegmental caching support
+ *
+ * @return gr_face or NULL if the font fails to load.
+ * @param appFaceHandle is a pointer to application specific information that is passed to getTable.
+ * This may not be NULL and must stay alive as long as the gr_face is alive.
+ * @param face_ops Pointer to face specific callback structure for table management. Must stay
+ * alive for the duration of the call only.
+ * @param segCacheMaxSize How large the segment cache is.
+ * @param faceOptions Bitfield of values from enum gr_face_options
+ */
+GR2_API gr_face* gr_make_face_with_seg_cache_and_ops(const void* appFaceHandle, const gr_face_ops *face_ops, unsigned int segCacheMaxSize, unsigned int faceOptions);
+
+/** Create a gr_face object given application information, with subsegmental caching support.
+ * This function is deprecated as of v1.2.0 in favour of gr_make_face_with_seg_cache_and_ops.
+ *
+ * @return gr_face or NULL if the font fails to load.
+ * @param appFaceHandle is a pointer to application specific information that is passed to getTable.
+ * This may not be NULL and must stay alive as long as the gr_face is alive.
+ * @param getTable The function graphite calls to access font table data
+ * @param segCacheMaxSize How large the segment cache is.
+ * @param faceOptions Bitfield of values from enum gr_face_options
+ */
+GR2_API gr_face* gr_make_face_with_seg_cache(const void* appFaceHandle, gr_get_table_fn getTable, unsigned int segCacheMaxSize, unsigned int faceOptions);
+//#endif
+
+/** Convert a tag in a string into a gr_uint32
+ *
+ * @return gr_uint32 tag, zero padded
+ * @param str a nul terminated string of which at most the first 4 characters are read
+ */
+GR2_API gr_uint32 gr_str_to_tag(const char *str);
+
+/** Convert a gr_uint32 tag into a string
+ *
+ * @param tag contains the tag to convert
+ * @param str is a pointer to a char array of at least size 4 bytes. The first 4 bytes of this array
+ * will be overwritten by this function. No nul is appended.
+ */
+GR2_API void gr_tag_to_str(gr_uint32 tag, char *str);
+
+/** Get feature values for a given language or default
+ *
+ * @return a copy of the default feature values for a given language. The application must call
+ * gr_featureval_destroy() to free this object when done.
+ * @param pFace The font face to get feature values from
+ * @param langname The language tag to get feature values for. If there is no such language or
+ * langname is 0, the default feature values for the font are returned.
+ * langname is right 0 padded and assumes lowercase. Thus the en langauge
+ * would be 0x656E0000. Langname may also be space padded, thus 0x656E2020.
+ */
+GR2_API gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, gr_uint32 langname);
+
+/** Get feature reference for a given feature id from a face
+ *
+ * @return a feature reference corresponding to the given id. This data is part of the gr_face and
+ * will be freed when the face is destroyed.
+ * @param pFace Font face to get information on.
+ * @param featId Feature id tag to get reference to.
+ */
+GR2_API const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId);
+
+/** Returns number of feature references in a face **/
+GR2_API gr_uint16 gr_face_n_fref(const gr_face* pFace);
+
+/** Returns feature reference at given index in face **/
+GR2_API const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i);
+
+/** Return number of languages the face knows about **/
+GR2_API unsigned short gr_face_n_languages(const gr_face* pFace);
+
+/** Returns a language id corresponding to a language of given index in the face **/
+GR2_API gr_uint32 gr_face_lang_by_index(const gr_face* pFace, gr_uint16 i);
+
+/** Destroy the given face and free its memory **/
+GR2_API void gr_face_destroy(gr_face *face);
+
+/** Returns the number of glyphs in the face **/
+GR2_API unsigned short gr_face_n_glyphs(const gr_face* pFace);
+
+/** Returns a faceinfo for the face and script **/
+GR2_API const gr_faceinfo *gr_face_info(const gr_face *pFace, gr_uint32 script);
+
+/** Returns whether the font supports a given Unicode character
+ *
+ * @return true if the character is supported.
+ * @param pFace face to test within
+ * @param usv Unicode Scalar Value of character to test
+ * @param script Tag of script for selecting which set of pseudo glyphs to test. May be NULL.
+ */
+GR2_API int gr_face_is_char_supported(const gr_face *pFace, gr_uint32 usv, gr_uint32 script);
+
+#ifndef GRAPHITE2_NFILEFACE
+/** Create gr_face from a font file
+ *
+ * @return gr_face that accesses a font file directly. Returns NULL on failure.
+ * @param filename Full path and filename to font file
+ * @param faceOptions Bitfile from enum gr_face_options to control face options.
+ */
+GR2_API gr_face* gr_make_file_face(const char *filename, unsigned int faceOptions);
+
+//#ifndef GRAPHITE2_NSEGCACHE
+/** Create gr_face from a font file, with subsegment caching support.
+ *
+ * @return gr_face that accesses a font file directly. Returns NULL on failure.
+ * @param filename Full path and filename to font file
+ * @param segCacheMaxSize Specifies how big to make the cache in segments.
+ * @param faceOptions Bitfield from enum gr_face_options to control face options.
+ */
+GR2_API gr_face* gr_make_file_face_with_seg_cache(const char *filename, unsigned int segCacheMaxSize, unsigned int faceOptions);
+//#endif
+#endif // !GRAPHITE2_NFILEFACE
+
+/** Create a font from a face
+ *
+ * @return gr_font Call font_destroy to free this font
+ * @param ppm Resolution of the font in pixels per em
+ * @param face Face this font corresponds to. This must stay alive as long as the font is alive.
+ */
+GR2_API gr_font* gr_make_font(float ppm, const gr_face *face);
+
+/** query function to find the hinted advance of a glyph
+ *
+ * @param appFontHandle is the unique information passed to gr_make_font_with_advance()
+ * @param glyphid is the glyph to retireve the hinted advance for.
+ */
+typedef float (*gr_advance_fn)(const void* appFontHandle, gr_uint16 glyphid);
+
+/** struct housing function pointers to manage font hinted metrics for the
+ * graphite engine. */
+struct gr_font_ops
+{
+ /** size of the structure in bytes to allow for future extensibility */
+ size_t size;
+ /** a pointer to a function to retrieve the hinted
+ * advance width of a glyph which the font cannot
+ * provide without client assistance. This can be
+ * NULL to signify no horizontal hinted metrics are necessary. */
+ gr_advance_fn glyph_advance_x;
+ /** a pointer to a function to retrieve the hinted
+ * advance height of a glyph which the font cannot
+ * provide without client assistance. This can be
+ * NULL to signify no horizontal hinted metrics are necessary. */
+ gr_advance_fn glyph_advance_y;
+};
+typedef struct gr_font_ops gr_font_ops;
+
+/** Creates a font with hinted advance width query functions
+ *
+ * @return gr_font to be destroyed via font_destroy
+ * @param ppm size of font in pixels per em
+ * @param appFontHandle font specific information that must stay alive as long
+ * as the font does
+ * @param font_ops pointer font specific callback structure for hinted metrics.
+ * Need only stay alive for the duration of the call.
+ * @param face the face this font corresponds to. Must stay alive as long as
+ * the font does.
+ */
+GR2_API gr_font* gr_make_font_with_ops(float ppm, const void* appFontHandle, const gr_font_ops * font_ops, const gr_face *face);
+
+/** Creates a font with hinted advance width query function.
+ * This function is deprecated. Use gr_make_font_with_ops instead.
+ *
+ * @return gr_font to be destroyed via font_destroy
+ * @param ppm size of font in pixels per em
+ * @param appFontHandle font specific information that must stay alive as long
+ * as the font does
+ * @param getAdvance callback function reference that returns horizontal advance in pixels for a glyph.
+ * @param face the face this font corresponds to. Must stay alive as long as
+ * the font does.
+ */
+GR2_API gr_font* gr_make_font_with_advance_fn(float ppm, const void* appFontHandle, gr_advance_fn getAdvance, const gr_face *face);
+
+/** Free a font **/
+GR2_API void gr_font_destroy(gr_font *font);
+
+/** get a feature value
+ *
+ * @return value of specific feature or 0 if any problems.
+ * @param pfeatureref gr_feature_ref to the feature
+ * @param feats gr_feature_val containing all the values
+ */
+GR2_API gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats);
+
+/** set a feature value
+ *
+ * @return false if there were any problems (value out of range, etc.)
+ * @param pfeatureref gr_feature_ref to the feature
+ * @param val value to set the feature to
+ * @param pDest the gr_feature_val containing all the values for all the features
+ */
+GR2_API int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest);
+
+/** Returns the id tag for a gr_feature_ref **/
+GR2_API gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref);
+
+/** Returns number of values a feature may take, given a gr_feature_ref **/
+GR2_API gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref);
+
+/** Returns the value associated with a particular value in a feature
+ *
+ * @return value
+ * @param pfeatureref gr_feature_ref of the feature of interest
+ * @param settingno Index up to the return value of gr_fref_n_values() of the value
+ */
+GR2_API gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno);
+
+/** Returns a string of the UI name of a feature
+ *
+ * @return string of the UI name, in the encoding form requested. Call gr_label_destroy() after use.
+ * @param pfeatureref gr_feature_ref of the feature
+ * @param langId This is a pointer since the face may not support a string in the requested
+ * language. The actual language of the string is returned in langId
+ * @param utf Encoding form for the string
+ * @param length Used to return the length of the string returned in bytes.
+ */
+GR2_API void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length);
+
+/** Return a UI string for a possible value of a feature
+ *
+ * @return string of the UI name, in the encoding form requested. nul terminated. Call gr_label_destroy()
+ * after use.
+ * @param pfeatureref gr_feature_ref of the feature
+ * @param settingno Value setting index
+ * @param langId This is a pointer to the requested language. The requested language id is
+ * replaced by the actual language id of the string returned.
+ * @param utf Encoding form for the string
+ * @param length Returns the length of the string returned in bytes.
+ */
+GR2_API void* gr_fref_value_label(const gr_feature_ref* pfeatureref, gr_uint16 settingno/*rather than a value*/, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length);
+
+/** Destroy a previously returned label string **/
+GR2_API void gr_label_destroy(void * label);
+
+/** Copies a gr_feature_val **/
+GR2_API gr_feature_val* gr_featureval_clone(const gr_feature_val* pfeatures);
+
+/** Destroys a gr_feature_val **/
+GR2_API void gr_featureval_destroy(gr_feature_val *pfeatures);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/gfx/graphite2/include/graphite2/Log.h b/gfx/graphite2/include/graphite2/Log.h
new file mode 100644
index 000000000..d1c6f0fe3
--- /dev/null
+++ b/gfx/graphite2/include/graphite2/Log.h
@@ -0,0 +1,85 @@
+/* GRAPHITE2 LICENSING
+
+ Copyright 2010, SIL International
+ All rights reserved.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should also have received a copy of the GNU Lesser General Public
+ License along with this library in the file named "LICENSE".
+ If not, write to the Free Software Foundation, 51 Franklin Street,
+ Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
+ internet at http://www.fsf.org/licenses/lgpl.html.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
+ General Public License, as published by the Free Software Foundation,
+ either version 2 of the License or (at your option) any later version.
+*/
+#pragma once
+
+#include <graphite2/Types.h>
+#include <graphite2/Font.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/** deprecated mechanism that doesn't do anything now. */
+typedef enum {
+ GRLOG_NONE = 0x0,
+ GRLOG_FACE = 0x01,
+ GRLOG_SEGMENT = 0x02,
+ GRLOG_PASS = 0x04,
+ GRLOG_CACHE = 0x08,
+
+ GRLOG_OPCODE = 0x80,
+ GRLOG_ALL = 0xFF
+} GrLogMask;
+
+/** Start logging all segment creation and updates on the provided face. This
+ * is logged to a JSON file, see "Segment JSON Schema.txt" for a precise
+ * definition of the file
+ *
+ * @return true if the file was successfully created and logging is correctly
+ * initialised.
+ * @param face the gr_face whose segments you want to log to the given file
+ * @param log_path a utf8 encoded file name and path to log to.
+ */
+GR2_API bool gr_start_logging(gr_face * face, const char *log_path);
+
+
+/** Stop logging on the given face. This will close the log file created by
+ * gr_start_logging.
+ *
+ * @param face the gr_face whose segments you want to stop logging
+ */
+GR2_API void gr_stop_logging(gr_face * face);
+
+/** Start logging to a FILE object.
+ * This function is deprecated as of 1.2.0, use the _face versions instead.
+ *
+ * @return True on success
+ * @param logfile FILE reference to output logging to
+ * @param mask What aspects of logging to report (ignored)
+ */
+GR2_API bool graphite_start_logging(FILE * logFile, GrLogMask mask); //may not do anthing if disabled in the implementation of the engine.
+
+/** Stop logging to a FILE object.
+ * This function is deprecated as of 1.2.0, use the _face versions instead.
+ */
+GR2_API void graphite_stop_logging();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/gfx/graphite2/include/graphite2/Segment.h b/gfx/graphite2/include/graphite2/Segment.h
new file mode 100644
index 000000000..0c3c49a3a
--- /dev/null
+++ b/gfx/graphite2/include/graphite2/Segment.h
@@ -0,0 +1,461 @@
+/* GRAPHITE2 LICENSING
+
+ Copyright 2010, SIL International
+ All rights reserved.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should also have received a copy of the GNU Lesser General Public
+ License along with this library in the file named "LICENSE".
+ If not, write to the Free Software Foundation, 51 Franklin Street,
+ Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
+ internet at http://www.fsf.org/licenses/lgpl.html.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
+ General Public License, as published by the Free Software Foundation,
+ either version 2 of the License or (at your option) any later version.
+*/
+#pragma once
+
+#include "graphite2/Types.h"
+#include "graphite2/Font.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+enum gr_break_weight {
+ gr_breakNone = 0,
+ /* after break weights */
+ gr_breakWhitespace = 10,
+ gr_breakWord = 15,
+ gr_breakIntra = 20,
+ gr_breakLetter = 30,
+ gr_breakClip = 40,
+ /* before break weights */
+ gr_breakBeforeWhitespace = -10,
+ gr_breakBeforeWord = -15,
+ gr_breakBeforeIntra = -20,
+ gr_breakBeforeLetter = -30,
+ gr_breakBeforeClip = -40
+};
+
+enum gr_justFlags {
+ /// Indicates that this segment is a complete line
+ gr_justCompleteLine = 0,
+ /// Indicates that the start of the slot list is not at the start of a line
+ gr_justStartInline = 1,
+ /// Indicates that the end of the slot list is not at the end of a line
+ gr_justEndInline = 2
+};
+
+/** Used for looking up slot attributes. Most are already available in other functions **/
+enum gr_attrCode {
+ /// adjusted glyph advance in x direction in design units
+ gr_slatAdvX = 0,
+ /// adjusted glyph advance in y direction (usually 0) in design units
+ gr_slatAdvY,
+ /// returns 0. Deprecated.
+ gr_slatAttTo,
+ /// This slot attaches to its parent at the given design units in the x direction
+ gr_slatAttX,
+ /// This slot attaches to its parent at the given design units in the y direction
+ gr_slatAttY,
+ /// This slot attaches to its parent at the given glyph point (not implemented)
+ gr_slatAttGpt,
+ /// x-direction adjustment from the given glyph point (not implemented)
+ gr_slatAttXOff,
+ /// y-direction adjustment from the given glyph point (not implemented)
+ gr_slatAttYOff,
+ /// Where on this glyph should align with the attachment point on the parent glyph in the x-direction.
+ gr_slatAttWithX,
+ /// Where on this glyph should align with the attachment point on the parent glyph in the y-direction
+ gr_slatAttWithY,
+ /// Which glyph point on this glyph should align with the attachment point on the parent glyph (not implemented).
+ gr_slatWithGpt,
+ /// Adjustment to gr_slatWithGpt in x-direction (not implemented)
+ gr_slatAttWithXOff,
+ /// Adjustment to gr_slatWithGpt in y-direction (not implemented)
+ gr_slatAttWithYOff,
+ /// Attach at given nesting level (not implemented)
+ gr_slatAttLevel,
+ /// Line break breakweight for this glyph
+ gr_slatBreak,
+ /// Ligature component reference (not implemented)
+ gr_slatCompRef,
+ /// bidi directionality of this glyph (not implemented)
+ gr_slatDir,
+ /// Whether insertion is allowed before this glyph
+ gr_slatInsert,
+ /// Final positioned position of this glyph relative to its parent in x-direction in pixels
+ gr_slatPosX,
+ /// Final positioned position of this glyph relative to its parent in y-direction in pixels
+ gr_slatPosY,
+ /// Amount to shift glyph by in x-direction design units
+ gr_slatShiftX,
+ /// Amount to shift glyph by in y-direction design units
+ gr_slatShiftY,
+ /// attribute user1
+ gr_slatUserDefnV1,
+ /// not implemented
+ gr_slatMeasureSol,
+ /// not implemented
+ gr_slatMeasureEol,
+ /// Amount this slot can stretch (not implemented)
+ gr_slatJStretch,
+ /// Amount this slot can shrink (not implemented)
+ gr_slatJShrink,
+ /// Granularity by which this slot can stretch or shrink (not implemented)
+ gr_slatJStep,
+ /// Justification weight for this glyph (not implemented)
+ gr_slatJWeight,
+ /// Amount this slot mush shrink or stretch in design units
+ gr_slatJWidth = 29,
+ /// SubSegment split point
+ gr_slatSegSplit = gr_slatJStretch + 29,
+ /// User defined attribute, see subattr for user attr number
+ gr_slatUserDefn,
+ /// Bidi level
+ gr_slatBidiLevel = 56,
+ /// Collision flags
+ gr_slatColFlags,
+ /// Collision constraint rectangle left (bl.x)
+ gr_slatColLimitblx,
+ /// Collision constraint rectangle lower (bl.y)
+ gr_slatColLimitbly,
+ /// Collision constraint rectangle right (tr.x)
+ gr_slatColLimittrx,
+ /// Collision constraint rectangle upper (tr.y)
+ gr_slatColLimittry,
+ /// Collision shift x
+ gr_slatColShiftx,
+ /// Collision shift y
+ gr_slatColShifty,
+ /// Collision margin
+ gr_slatColMargin,
+ /// Margin cost weight
+ gr_slatColMarginWt,
+ // Additional glyph that excludes movement near this one:
+ gr_slatColExclGlyph,
+ gr_slatColExclOffx,
+ gr_slatColExclOffy,
+ // Collision sequence enforcing attributes:
+ gr_slatSeqClass,
+ gr_slatSeqProxClass,
+ gr_slatSeqOrder,
+ gr_slatSeqAboveXoff,
+ gr_slatSeqAboveWt,
+ gr_slatSeqBelowXlim,
+ gr_slatSeqBelowWt,
+ gr_slatSeqValignHt,
+ gr_slatSeqValignWt,
+
+ /// not implemented
+ gr_slatMax,
+ /// not implemented
+ gr_slatNoEffect = gr_slatMax + 1
+};
+
+enum gr_bidirtl {
+ /// Underlying paragraph direction is RTL
+ gr_rtl = 1,
+ /// Set this to not run the bidi pass internally, even if the font asks for it.
+ /// This presumes that the segment is in a single direction. Most of the time
+ /// this bit should be set unless you know you are passing full paragraphs of text.
+ gr_nobidi = 2,
+ /// Disable auto mirroring for rtl text
+ gr_nomirror = 4
+};
+
+typedef struct gr_char_info gr_char_info;
+typedef struct gr_segment gr_segment;
+typedef struct gr_slot gr_slot;
+
+/** Returns Unicode character for a charinfo.
+ *
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info* p/*not NULL*/);
+
+/** Returns breakweight for a charinfo.
+ *
+ * @return Breakweight is a number between -50 and 50 indicating the cost of a
+ * break before or after this character. If the value < 0, the absolute value
+ * is this character's contribution to the overall breakweight before it. If the value
+ * > 0, then the value is this character's contribution to the overall breakweight after it.
+ * The overall breakweight between two characters is the maximum of the breakweight
+ * contributions from the characters either side of it. If a character makes no
+ * contribution to the breakweight on one side of it, the contribution is considered
+ * to be 0.
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/);
+
+/** Returns the slot index that after this character is after in the slot stream
+ *
+ * In effect each character is associated with a set of slots and this returns
+ * the index of the last slot in the segment this character is associated with.
+ *
+ * @return after slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/);
+
+/** Returns the slot index that before this character is before in the slot stream
+ *
+ * In effect each character is associated with a set of slots and this returns
+ * the index of the first slot in the segment this character is associated with.
+ *
+ * @return before slot index between 0 and gr_seg_n_slots()
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/);
+
+/** Returns the code unit index of this character in the input string
+ *
+ * @return code unit index between 0 and the end of the string
+ * @param p Pointer to charinfo to return information on.
+ */
+GR2_API size_t gr_cinfo_base(const gr_char_info* p/*not NULL*/);
+
+/** Returns the number of unicode characters in a string.
+ *
+ * @return number of characters in the string
+ * @param enc Specifies the type of data in the string: utf8, utf16, utf32
+ * @param buffer_begin The start of the string
+ * @param buffer_end Measure up to the first nul or when end is reached, whichever is earliest.
+ * This parameter may be NULL.
+ * @param pError If there is a structural fault in the string, the location is returned
+ * in this variable. If no error occurs, pError will contain NULL. NULL
+ * may be passed for pError if no such information is required.
+ */
+GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void* buffer_begin, const void* buffer_end, const void** pError);
+
+/** Creates and returns a segment.
+ *
+ * @return a segment that needs seg_destroy called on it. May return NULL if bad problems
+ * in segment processing.
+ * @param font Gives the size of the font in pixels per em for final positioning. If
+ * NULL, positions are returned in design units, i.e. at a ppm of the upem
+ * of the face.
+ * @param face The face containing all the non-size dependent information.
+ * @param script This is a tag containing a script identifier that is used to choose
+ * which graphite table within the font to use. Maybe 0. Tag may be 4 chars
+ * NULL padded in LSBs or space padded in LSBs.
+ * @param pFeats Pointer to a feature values to be used for the segment. Only one
+ * feature values may be used for a segment. If NULL the default features
+ * for the font will be used.
+ * @param enc Specifies what encoding form the string is in (utf8, utf16, utf32)
+ * @param pStart Start of the string
+ * @param nChars Number of unicode characters to process in the string. The string will
+ * be processed either up to the first NULL or until nChars have been
+ * processed. nChars is also used to initialise the internal memory
+ * allocations of the segment. So it is wise not to make nChars too much
+ * greater than the actual number of characters being processed.
+ * @param dir Specifies whether the segment is processed right to left (1) or left to
+ * right (0) and whether to run the internal bidi pass, if a font requests it.
+ * See enum gr_bidirtl for details.
+ */
+GR2_API gr_segment* gr_make_seg(const gr_font* font, const gr_face* face, gr_uint32 script, const gr_feature_val* pFeats, enum gr_encform enc, const void* pStart, size_t nChars, int dir);
+
+/** Destroys a segment, freeing the memory.
+ *
+ * @param p The segment to destroy
+ */
+GR2_API void gr_seg_destroy(gr_segment* p);
+
+/** Returns the advance for the whole segment.
+ *
+ * Returns the width of the segment up to the next glyph origin after the segment
+ */
+GR2_API float gr_seg_advance_X(const gr_segment* pSeg/*not NULL*/);
+
+/** Returns the height advance for the segment. **/
+GR2_API float gr_seg_advance_Y(const gr_segment* pSeg/*not NULL*/);
+
+/** Returns the number of gr_char_infos in the segment. **/
+GR2_API unsigned int gr_seg_n_cinfo(const gr_segment* pSeg/*not NULL*/);
+
+/** Returns a gr_char_info at a given index in the segment. **/
+GR2_API const gr_char_info* gr_seg_cinfo(const gr_segment* pSeg/*not NULL*/, unsigned int index/*must be <number_of_CharInfo*/);
+
+/** Returns the number of glyph gr_slots in the segment. **/
+GR2_API unsigned int gr_seg_n_slots(const gr_segment* pSeg/*not NULL*/); //one slot per glyph
+
+/** Returns the first gr_slot in the segment.
+ *
+ * The first slot in a segment has a gr_slot_prev_in_segment() of NULL. Slots are owned
+ * by their segment and are destroyed along with the segment.
+ */
+GR2_API const gr_slot* gr_seg_first_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
+
+/** Returns the last gr_slot in the segment.
+ *
+ * The last slot in a segment has a gr_slot_next_in_segment() of NULL
+ */
+GR2_API const gr_slot* gr_seg_last_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another
+
+/** Justifies a linked list of slots for a line to a given width
+ *
+ * Passed a pointer to the start of a linked list of slots corresponding to a line, as
+ * set up by gr_slot_linebreak_before, this function will position the glyphs in the line
+ * to take up the given width. It is possible to specify a subrange within the line to process.
+ * This allows skipping of line initial or final whitespace, for example. While this will ensure
+ * that the subrange fits width, the line will still be positioned with the first glyph of the
+ * line at 0. So the resulting positions may be beyond width.
+ *
+ * @return float The resulting width of the range of slots justified.
+ * @param pSeg Pointer to the segment
+ * @param pStart Pointer to the start of the line linked list (including skipped characters)
+ * @param pFont Font to use for positioning
+ * @param width Width in pixels in which to fit the line. If < 0. don't adjust natural width, just run justification passes
+ * to handle line end contextuals, if there are any.
+ * @param flags Indicates line ending types. Default is linked list is a full line
+ * @param pFirst If not NULL, the first slot in the list to be considered part of the line (so can skip)
+ * @param pLast If not NULL, the last slot to process in the line (allow say trailing whitespace to be skipped)
+ */
+GR2_API float gr_seg_justify(gr_segment* pSeg/*not NULL*/, const gr_slot* pStart/*not NULL*/, const gr_font *pFont, double width, enum gr_justFlags flags, const gr_slot* pFirst, const gr_slot* pLast);
+
+/** Returns the next slot along in the segment.
+ *
+ * Slots are held in a linked list. This returns the next in the linked list. The slot
+ * may or may not be attached to another slot. Returns NULL at the end of the segment.
+ */
+GR2_API const gr_slot* gr_slot_next_in_segment(const gr_slot* p);
+
+/** Returns the previous slot along in the segment.
+ *
+ * Slots are held in a doubly linked list. This returns the previos slot in the linked
+ * list. This slot may or may not be attached to it. Returns NULL at the start of the
+ * segment.
+ */
+GR2_API const gr_slot* gr_slot_prev_in_segment(const gr_slot* p);
+
+/** Returns the attachment parent slot of this slot.
+ *
+ * Attached slots form a tree. This returns the parent of this slot in that tree. A
+ * base glyph which is not attached to another glyph, always returns NULL.
+ */
+GR2_API const gr_slot* gr_slot_attached_to(const gr_slot* p);
+
+/** Returns the first slot attached to this slot.
+ *
+ * Attached slots form a singly linked list from the parent. This returns the first
+ * slot in that list. Note that this is a reference to another slot that is also in
+ * the main segment doubly linked list.
+ *
+ * if gr_slot_first_attachment(p) != NULL then gr_slot_attached_to(gr_slot_first_attachment(p)) == p.
+ */
+GR2_API const gr_slot* gr_slot_first_attachment(const gr_slot* p);
+
+/** Returns the next slot attached to our attachment parent.
+ *
+ * This returns the next slot in the singly linked list of slots attached to this
+ * slot's parent. If there are no more such slots, NULL is returned. If there is
+ * no parent, i.e. the passed slot is a cluster base, then the next cluster base
+ * in graphical order (ltr, even for rtl text) is returned.
+ *
+ * if gr_slot_next_sibling_attachment(p) != NULL then gr_slot_attached_to(gr_slot_next_sibling_attachment(p)) == gr_slot_attached_to(p).
+ */
+GR2_API const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p);
+
+
+/** Returns glyph id of the slot
+ *
+ * Each slot has a glyphid which is rendered at the position given by the slot. This
+ * glyphid is the real glyph to be rendered and never a pseudo glyph.
+ */
+GR2_API unsigned short gr_slot_gid(const gr_slot* p);
+
+/** Returns X offset of glyph from start of segment **/
+GR2_API float gr_slot_origin_X(const gr_slot* p);
+
+/** Returns Y offset of glyph from start of segment **/
+GR2_API float gr_slot_origin_Y(const gr_slot* p);
+
+/** Returns the glyph advance for this glyph as adjusted for kerning
+ *
+ * @param p Slot to give results for
+ * @param face gr_face of the glyphs. May be NULL if unhinted advances used
+ * @param font gr_font to scale for pixel results. If NULL returns design
+ * units advance. If not NULL then returns pixel advance based
+ * on hinted or scaled glyph advances in the font. face must be
+ * passed for hinted advances to be used.
+ */
+GR2_API float gr_slot_advance_X(const gr_slot* p, const gr_face* face, const gr_font *font);
+
+/** Returns the vertical advance for the glyph in the slot adjusted for kerning
+ *
+ * Returns design units unless font is not NULL in which case the pixel value
+ * is returned scaled for the given font
+ */
+GR2_API float gr_slot_advance_Y(const gr_slot* p, const gr_face* face, const gr_font *font);
+
+/** Returns the gr_char_info index before us
+ *
+ * Returns the index of the gr_char_info that a cursor before this slot, would put
+ * an underlying cursor before. This may also be interpretted as each slot holding
+ * a set of char_infos that it is associated with and this function returning the
+ * index of the char_info with lowest index, from this set.
+ */
+GR2_API int gr_slot_before(const gr_slot* p/*not NULL*/);
+
+/** Returns the gr_char_info index after us
+ *
+ * Returns the index of the gr_char_info that a cursor after this slot would put an
+ * underlying cursor after. This may also be interpretted as each slot holding a set
+ * of char_infos that it is associated with and this function returning the index of
+ * the char_info with the highest index, from this set.
+ */
+GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/);
+
+/** Returns the index of this slot in the segment
+ *
+ * Returns the index given to this slot during final positioning. This corresponds
+ * to the value returned br gr_cinfo_before() and gr_cinfo_after()
+ */
+GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/);
+
+/** Return a slot attribute value
+ *
+ * Given a slot and an attribute along with a possible subattribute, return the
+ * corresponding value in the slot. See enum gr_attrCode for details of each attribute.
+ */
+GR2_API int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, enum gr_attrCode index, gr_uint8 subindex); //tbd - do we need to expose this?
+
+/** Returns whether text may be inserted before this glyph.
+ *
+ * This indicates whether a cursor can be put before this slot. It applies to
+ * base glyphs that have no parent as well as attached glyphs that have the
+ * .insert attribute explicitly set to true. This is the primary mechanism
+ * for identifying contiguous sequences of base plus diacritics.
+ */
+GR2_API int gr_slot_can_insert_before(const gr_slot* p);
+
+/** Returns the original gr_char_info index this slot refers to.
+ *
+ * Each Slot has a gr_char_info that it originates from. This is that gr_char_info.
+ * The index is passed to gr_seg_cinfo(). This information is useful for testing.
+ */
+GR2_API int gr_slot_original(const gr_slot* p/*not NULL*/);
+
+/** Breaks a segment into lines.
+ *
+ * Breaks the slot linked list at the given point in the linked list. It is up
+ * to the application to keep track of the first slot on each line.
+ */
+GR2_API void gr_slot_linebreak_before(gr_slot *p/*not NULL*/);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/gfx/graphite2/include/graphite2/Types.h b/gfx/graphite2/include/graphite2/Types.h
new file mode 100644
index 000000000..e8e45c1ff
--- /dev/null
+++ b/gfx/graphite2/include/graphite2/Types.h
@@ -0,0 +1,72 @@
+/* GRAPHITE2 LICENSING
+
+ Copyright 2010, SIL International
+ All rights reserved.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should also have received a copy of the GNU Lesser General Public
+ License along with this library in the file named "LICENSE".
+ If not, write to the Free Software Foundation, 51 Franklin Street,
+ Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
+ internet at http://www.fsf.org/licenses/lgpl.html.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
+ General Public License, as published by the Free Software Foundation,
+ either version 2 of the License or (at your option) any later version.
+*/
+#pragma once
+
+#include <stddef.h>
+
+typedef unsigned char gr_uint8;
+typedef gr_uint8 gr_byte;
+typedef signed char gr_int8;
+typedef unsigned short gr_uint16;
+typedef short gr_int16;
+typedef unsigned int gr_uint32;
+typedef int gr_int32;
+
+enum gr_encform {
+ gr_utf8 = 1/*sizeof(uint8)*/, gr_utf16 = 2/*sizeof(uint16)*/, gr_utf32 = 4/*sizeof(uint32)*/
+};
+
+// Definitions for library publicly exported symbols
+#if defined _WIN32 || defined __CYGWIN__
+ #if defined GRAPHITE2_STATIC
+ #define GR2_API
+ #elif defined GRAPHITE2_EXPORTING
+ #if defined __GNUC__
+ #define GR2_API __attribute__((dllexport))
+ #else
+ #define GR2_API __declspec(dllexport)
+ #endif
+ #else
+ #if defined __GNUC__
+ #define GR2_API __attribute__((dllimport))
+ #else
+ #define GR2_API __declspec(dllimport)
+ #endif
+ #endif
+ #define GR2_LOCAL
+#elif __GNUC__ >= 4
+ #if defined GRAPHITE2_STATIC
+ #define GR2_API __attribute__ ((visibility("hidden")))
+ #else
+ #define GR2_API __attribute__ ((visibility("default")))
+ #endif
+ #define GR2_LOCAL __attribute__ ((visibility("hidden")))
+#else
+ #define GR2_API
+ #define GR2_LOCAL
+#endif
+
diff --git a/gfx/graphite2/include/graphite2/XmlLog.h b/gfx/graphite2/include/graphite2/XmlLog.h
new file mode 100644
index 000000000..554132756
--- /dev/null
+++ b/gfx/graphite2/include/graphite2/XmlLog.h
@@ -0,0 +1,55 @@
+/* GRAPHITE2 LICENSING
+
+ Copyright 2010, SIL International
+ All rights reserved.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should also have received a copy of the GNU Lesser General Public
+ License along with this library in the file named "LICENSE".
+ If not, write to the Free Software Foundation, 51 Franklin Street,
+ Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
+ internet at http://www.fsf.org/licenses/lgpl.html.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the Mozilla Public License (http://mozilla.org/MPL) or the GNU
+ General Public License, as published by the Free Software Foundation,
+ either version 2 of the License or (at your option) any later version.
+*/
+#pragma once
+
+#include <graphite2/Types.h>
+#include <stdio.h>
+
+typedef enum {
+ GRLOG_NONE = 0x0,
+ GRLOG_FACE = 0x01,
+ GRLOG_SEGMENT = 0x02,
+ GRLOG_PASS = 0x04,
+ GRLOG_CACHE = 0x08,
+
+ GRLOG_OPCODE = 0x80,
+ GRLOG_ALL = 0xFF
+} GrLogMask;
+
+// If startGraphiteLogging returns true, logging is enabled and the FILE handle
+// will be closed by graphite when stopGraphiteLogging is called.
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+GR2_API bool graphite_start_logging(FILE * logFile, GrLogMask mask); //may not do anthing if disabled in the implementation of the engine.
+GR2_API void graphite_stop_logging();
+
+#ifdef __cplusplus
+}
+#endif