Font.h
Go to the documentation of this file.
/* 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 14
#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;
GR2_API void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix);
enum gr_face_options {
gr_face_default = 0,
gr_face_dumbRendering = 1,
gr_face_preloadGlyphs = 2,
gr_face_cacheCmap = 4,
gr_face_preloadAll = gr_face_preloadGlyphs | gr_face_cacheCmap
};
struct gr_faceinfo {
gr_uint16 extra_ascent;
gr_uint16 extra_descent;
gr_uint16 upem;
enum gr_space_contextuals {
gr_space_unknown = 0,
gr_space_none = 1,
gr_space_left_only = 2,
gr_space_right_only = 3,
gr_space_either_only = 4,
gr_space_both = 5,
gr_space_cross = 6
} space_contextuals;
unsigned int has_bidi_pass : 1;
unsigned int line_ends : 1;
unsigned int justifies : 1;
};
typedef struct gr_faceinfo gr_faceinfo;
typedef const void *(*gr_get_table_fn)(const void* appFaceHandle, unsigned int name, size_t *len);
typedef void (*gr_release_table_fn)(const void* appFaceHandle, const void *table_buffer);
struct gr_face_ops
{
size_t size;
gr_get_table_fn get_table;
gr_release_table_fn release_table;
};
typedef struct gr_face_ops gr_face_ops;
GR2_API gr_face* gr_make_face_with_ops(const void* appFaceHandle/*non-NULL*/, const gr_face_ops *face_ops, unsigned int faceOptions);
GR2_DEPRECATED_API gr_face* gr_make_face(const void* appFaceHandle/*non-NULL*/, gr_get_table_fn getTable, unsigned int faceOptions);
GR2_DEPRECATED_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);
GR2_DEPRECATED_API gr_face* gr_make_face_with_seg_cache(const void* appFaceHandle, gr_get_table_fn getTable, unsigned int segCacheMaxSize, unsigned int faceOptions);
GR2_API gr_uint32 gr_str_to_tag(const char *str);
GR2_API void gr_tag_to_str(gr_uint32 tag, char *str);
GR2_API gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, gr_uint32 langname);
GR2_API const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId);
GR2_API gr_uint16 gr_face_n_fref(const gr_face* pFace);
GR2_API const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i);
GR2_API unsigned short gr_face_n_languages(const gr_face* pFace);
GR2_API gr_uint32 gr_face_lang_by_index(const gr_face* pFace, gr_uint16 i);
GR2_API void gr_face_destroy(gr_face *face);
GR2_API unsigned short gr_face_n_glyphs(const gr_face* pFace);
GR2_API const gr_faceinfo *gr_face_info(const gr_face *pFace, gr_uint32 script);
GR2_API int gr_face_is_char_supported(const gr_face *pFace, gr_uint32 usv, gr_uint32 script);
#ifndef GRAPHITE2_NFILEFACE
GR2_API gr_face* gr_make_file_face(const char *filename, unsigned int faceOptions);
GR2_DEPRECATED_API gr_face* gr_make_file_face_with_seg_cache(const char *filename, unsigned int segCacheMaxSize, unsigned int faceOptions);
#endif // !GRAPHITE2_NFILEFACE
GR2_API gr_font* gr_make_font(float ppm, const gr_face *face);
typedef float (*gr_advance_fn)(const void* appFontHandle, gr_uint16 glyphid);
struct gr_font_ops
{
size_t size;
gr_advance_fn glyph_advance_x;
gr_advance_fn glyph_advance_y;
};
typedef struct gr_font_ops gr_font_ops;
GR2_API gr_font* gr_make_font_with_ops(float ppm, const void* appFontHandle, const gr_font_ops * font_ops, const gr_face *face);
GR2_API gr_font* gr_make_font_with_advance_fn(float ppm, const void* appFontHandle, gr_advance_fn getAdvance, const gr_face *face);
GR2_API void gr_font_destroy(gr_font *font);
GR2_API gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats);
GR2_API int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest);
GR2_API gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref);
GR2_API gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref);
GR2_API gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno);
GR2_API void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length);
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);
GR2_API void gr_label_destroy(void * label);
GR2_API gr_feature_val* gr_featureval_clone(const gr_feature_val* pfeatures);
GR2_API void gr_featureval_destroy(gr_feature_val *pfeatures);
#ifdef __cplusplus
}
#endif
gr_fref_value
GR2_API gr_int16 gr_fref_value(const gr_feature_ref *pfeatureref, gr_uint16 settingno)
Returns the value associated with a particular value in a feature.
gr_make_font_with_ops
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 functions.
gr_face_destroy
GR2_API void gr_face_destroy(gr_face *face)
Destroy the given face and free its memory.
gr_face_n_glyphs
GR2_API unsigned short gr_face_n_glyphs(const gr_face *pFace)
Returns the number of glyphs in the face.
gr_face_fref
GR2_API const gr_feature_ref * gr_face_fref(const gr_face *pFace, gr_uint16 i)
Returns feature reference at given index in face.
gr_face_options
gr_face_options
The Face Options allow the application to require that certain tables are read during face constructi...
Definition: Font.h:56
gr_face_default
@ gr_face_default
No preload, no cmap caching, fail if the graphite tables are invalid.
Definition: Font.h:58
gr_face_preloadAll
@ gr_face_preloadAll
Preload everything.
Definition: Font.h:66
gr_face_preloadGlyphs
@ gr_face_preloadGlyphs
preload glyphs at construction time
Definition: Font.h:62
gr_face_cacheCmap
@ gr_face_cacheCmap
Cache the lookup from code point to glyph ID at construction time.
Definition: Font.h:64
gr_face_dumbRendering
@ gr_face_dumbRendering
Dumb rendering will be enabled if the graphite tables are invalid.
Definition: Font.h:60
gr_feature_val
struct gr_feature_val gr_feature_val
Definition: Font.h:43
gr_face_lang_by_index
GR2_API gr_uint32 gr_face_lang_by_index(const gr_face *pFace, gr_uint16 i)
Returns a language id corresponding to a language of given index in the face.
gr_fref_label
GR2_API void * gr_fref_label(const gr_feature_ref *pfeatureref, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length)
Returns a string of the UI name of a feature.
gr_make_face_with_seg_cache
GR2_DEPRECATED_API gr_face * gr_make_face_with_seg_cache(const void *appFaceHandle, gr_get_table_fn getTable, unsigned int segCacheMaxSize, unsigned int faceOptions)
gr_fref_value_label
GR2_API void * gr_fref_value_label(const gr_feature_ref *pfeatureref, gr_uint16 settingno, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length)
Return a UI string for a possible value of a feature.
gr_featureval_clone
GR2_API gr_feature_val * gr_featureval_clone(const gr_feature_val *pfeatures)
Copies a gr_feature_val.
gr_face_is_char_supported
GR2_API int gr_face_is_char_supported(const gr_face *pFace, gr_uint32 usv, gr_uint32 script)
Returns whether the font supports a given Unicode character.
gr_face_n_fref
GR2_API gr_uint16 gr_face_n_fref(const gr_face *pFace)
Returns number of feature references in a face.
gr_face_info
GR2_API const gr_faceinfo * gr_face_info(const gr_face *pFace, gr_uint32 script)
Returns a faceinfo for the face and script.
gr_face
struct gr_face gr_face
Definition: Font.h:40
gr_engine_version
GR2_API void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix)
Returns version information on this engine.
gr_fref_n_values
GR2_API gr_uint16 gr_fref_n_values(const gr_feature_ref *pfeatureref)
Returns number of values a feature may take, given a gr_feature_ref.
gr_make_font
GR2_API gr_font * gr_make_font(float ppm, const gr_face *face)
Create a font from a face.
gr_font
struct gr_font gr_font
Definition: Font.h:41
gr_feature_ref
struct gr_feature_ref gr_feature_ref
Definition: Font.h:42
gr_advance_fn
float(* gr_advance_fn)(const void *appFontHandle, gr_uint16 glyphid)
query function to find the hinted advance of a glyph
Definition: Font.h:273
gr_fref_id
GR2_API gr_uint32 gr_fref_id(const gr_feature_ref *pfeatureref)
Returns the id tag for a gr_feature_ref.
gr_tag_to_str
GR2_API void gr_tag_to_str(gr_uint32 tag, char *str)
Convert a gr_uint32 tag into a string.
gr_make_file_face_with_seg_cache
GR2_DEPRECATED_API gr_face * gr_make_file_face_with_seg_cache(const char *filename, unsigned int segCacheMaxSize, unsigned int faceOptions)
gr_face_featureval_for_lang
GR2_API gr_feature_val * gr_face_featureval_for_lang(const gr_face *pFace, gr_uint32 langname)
Get feature values for a given language or default.
gr_face_find_fref
GR2_API const gr_feature_ref * gr_face_find_fref(const gr_face *pFace, gr_uint32 featId)
Get feature reference for a given feature id from a face.
gr_make_face_with_ops
GR2_API gr_face * gr_make_face_with_ops(const void *appFaceHandle, const gr_face_ops *face_ops, unsigned int faceOptions)
Create a gr_face object given application information and a table functions.
gr_make_face
GR2_DEPRECATED_API gr_face * gr_make_face(const void *appFaceHandle, gr_get_table_fn getTable, unsigned int faceOptions)
gr_make_font_with_advance_fn
GR2_API gr_font * gr_make_font_with_advance_fn(float ppm, const void *appFontHandle, gr_advance_fn getAdvance, const gr_face *face)
Creates a font with hinted advance width query function.
gr_font_destroy
GR2_API void gr_font_destroy(gr_font *font)
Free a font.
gr_str_to_tag
GR2_API gr_uint32 gr_str_to_tag(const char *str)
Convert a tag in a string into a gr_uint32.
gr_featureval_destroy
GR2_API void gr_featureval_destroy(gr_feature_val *pfeatures)
Destroys a gr_feature_val.
gr_fref_feature_value
GR2_API gr_uint16 gr_fref_feature_value(const gr_feature_ref *pfeatureref, const gr_feature_val *feats)
get a feature value
gr_face_n_languages
GR2_API unsigned short gr_face_n_languages(const gr_face *pFace)
Return number of languages the face knows about.
gr_fref_set_feature_value
GR2_API int gr_fref_set_feature_value(const gr_feature_ref *pfeatureref, gr_uint16 val, gr_feature_val *pDest)
set a feature value
gr_get_table_fn
const void *(* gr_get_table_fn)(const void *appFaceHandle, unsigned int name, size_t *len)
type describing function to retrieve font table information
Definition: Font.h:98
gr_make_file_face
GR2_API gr_face * gr_make_file_face(const char *filename, unsigned int faceOptions)
Create gr_face from a font file.
gr_release_table_fn
void(* gr_release_table_fn)(const void *appFaceHandle, const void *table_buffer)
type describing function to release any resources allocated by the above get_table table function
Definition: Font.h:105
gr_label_destroy
GR2_API void gr_label_destroy(void *label)
Destroy a previously returned label string.
gr_make_face_with_seg_cache_and_ops
GR2_DEPRECATED_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)
Types.h
gr_int16
short gr_int16
Definition: Types.h:35
gr_uint16
unsigned short gr_uint16
Definition: Types.h:34
gr_encform
gr_encform
Definition: Types.h:39
GR2_DEPRECATED_API
#define GR2_DEPRECATED_API
Definition: Types.h:78
gr_uint32
unsigned int gr_uint32
Definition: Types.h:36
GR2_API
#define GR2_API
Definition: Types.h:77
gr_face_ops
struct housing function pointers to manage font table buffers for the graphite engine.
Definition: Font.h:109
gr_face_ops::get_table
gr_get_table_fn get_table
a pointer to a function to request a table from the client.
Definition: Font.h:113
gr_face_ops::size
size_t size
size in bytes of this structure
Definition: Font.h:111
gr_face_ops::release_table
gr_release_table_fn release_table
is a pointer to a function to notify the client the a table can be released.
Definition: Font.h:116
gr_faceinfo
Holds information about a particular Graphite silf table that has been loaded.
Definition: Font.h:70
gr_faceinfo::space_contextuals
enum gr_faceinfo::gr_space_contextuals space_contextuals
gr_faceinfo::gr_space_contextuals
gr_space_contextuals
Definition: Font.h:74
gr_faceinfo::gr_space_left_only
@ gr_space_left_only
the space character only occurs as the first element in a rule.
Definition: Font.h:77
gr_faceinfo::gr_space_either_only
@ gr_space_either_only
the space character only occurs as the only element in a rule.
Definition: Font.h:79
gr_faceinfo::gr_space_both
@ gr_space_both
the space character may occur as the first or last element of a rule.
Definition: Font.h:80
gr_faceinfo::gr_space_none
@ gr_space_none
the space character never occurs in any rules.
Definition: Font.h:76
gr_faceinfo::gr_space_cross
@ gr_space_cross
the space character occurs in a rule not as a first or last element.
Definition: Font.h:81
gr_faceinfo::gr_space_right_only
@ gr_space_right_only
the space character only occurs as the last element in a rule.
Definition: Font.h:78
gr_faceinfo::gr_space_unknown
@ gr_space_unknown
no information is known.
Definition: Font.h:75
gr_faceinfo::extra_descent
gr_uint16 extra_descent
The extra_descent in the GDL, in design units.
Definition: Font.h:72
gr_faceinfo::has_bidi_pass
unsigned int has_bidi_pass
the table specifies that a bidirectional pass should run
Definition: Font.h:83
gr_faceinfo::justifies
unsigned int justifies
there are .justify properties set somewhere on some glyphs
Definition: Font.h:85
gr_faceinfo::upem
gr_uint16 upem
The design units for the font.
Definition: Font.h:73
gr_faceinfo::line_ends
unsigned int line_ends
there are line end contextuals somewhere
Definition: Font.h:84
gr_faceinfo::extra_ascent
gr_uint16 extra_ascent
The extra_ascent in the GDL, in design units.
Definition: Font.h:71
gr_font_ops
struct housing function pointers to manage font hinted metrics for the graphite engine.
Definition: Font.h:278
gr_font_ops::glyph_advance_x
gr_advance_fn glyph_advance_x
a pointer to a function to retrieve the hinted advance width of a glyph which the font cannot provide...
Definition: Font.h:285
gr_font_ops::glyph_advance_y
gr_advance_fn glyph_advance_y
a pointer to a function to retrieve the hinted advance height of a glyph which the font cannot provid...
Definition: Font.h:290
gr_font_ops::size
size_t size
size of the structure in bytes to allow for future extensibility
Definition: Font.h:280