2 * Copyright (C) 2006 Red Hat, Inc.
4 * This is part of HarfBuzz, an OpenType Layout engine library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Red Hat Author(s): Owen Taylor
31 typedef hb_uint16 HB_CodePoint
; /* UTF-16 codepoint (not character ) */
32 typedef char HB_Boolean
;
33 typedef hb_uint32 HB_Fixed
; /* 26.6 */
34 typedef hb_uint32 HB_Glyph
;
35 typedef hb_uint32 HB_Unichar
;
37 /* Metrics reported by the font backend for use of the shaper */
38 typedef struct _HB_GlyphMetrics HB_GlyphMetrics
;
39 struct _HB_GlyphMetrics
43 /* Do we need ink/logical extents for the glyph here? */
47 * HB_Font: Abstract font interface.
48 * First pass of this might just have FT_Face *getFace();
50 typedef struct _HB_Font HB_Font
;
51 typedef struct _HB_FontClass HB_FontClass
;
54 HB_Glyph (*charToGlyph
)(HB_Font
*font
, HB_Unichar chr
);
55 void (*getMetrics
)(HB_Font
*font
, HB_Glyph glyph
, HB_GlyphMetrics
*metrics
);
56 HB_Boolean (*getSFontTable
)(HB_Font
*font
, void **cookie
, char **start
, int *len
);
57 HB_Boolean (*freeSFontTable
)(void **cookie
);
65 * Language tags, of the form en-us; represented as interned, canonicalized
66 * strings. hb_language_from_string("en_US"), hb_language_from_string("en-us")
67 * both return the same (pointer-comparable) HB_Language).
69 typedef struct HB_Language_
*HB_Language
;
71 HB_Language
hb_language_from_string(const char *str
);
72 const char *hb_language_to_string(HB_Language language
);
74 /* Special treatment for the edges of runs.
77 HB_RUN_EDGE_LINE_VISUAL_EDGE
= 1 << 0,
78 HB_RUN_EDGE_LINE_LOGICAL_EDGE
= 1 << 1,
79 HB_RUN_EDGE_LINE_ADD_HYPHEN
= 1 << 2 /* ???? */
82 /* Defines optional informaiton in HB_ShapeInput; this allows extension
83 * of HB_ShapeInput while keeping binary compatibility
86 HB_SHAPE_START_TYPE
= 1 << 0,
87 HB_SHAPE_END_TYPE
= 1 << 1
90 /* Attributes types are described by "interned strings"; this is a little
91 * annoying if you want to write a switch statement, but keeps things
94 typedef struct _HB_AttributeType
*HB_AttributeType
;
96 HB_AttributeType
hb_attribute_type_from_string(const char *str
);
97 const char *hb_attribute_type_to_string(HB_AttributeType attribute_type
);
100 HB_AttributeType type
;
107 * You could handle this like HB_Language, but an enum seems a little nicer;
108 * another approach would be to use OpenType script tags.
115 /* This is just the subset of direction information needed by the shaper */
122 typedef struct _HB_ShapeInput HB_ShapeInput
;
123 struct _HB_ShapeInput
{
124 /* Defines what fields the caller has initialized - fields not in
125 * the enum are mandatory.
130 int length
; /* total length of text to shape */
131 int shape_offset
; /* start of section to shape */
132 int shape_length
; /* number of code points to shape */
134 HB_Direction direction
;
135 HB_ShapeScript script
;
136 HB_Language language
;
138 HB_AttributeType
*attributes
;
141 HB_RunEdge start_type
;
145 struct HB_GlyphItem
{
152 /* Add kashida information, etc, here */
158 HB_SHAPE_RESULT_FAILED
164 typedef struct _HB_GlyphBuffer HB_GlyphBuffer
;
165 struct _HB_GlyphBuffer
{
169 int *log_clusters
; /* Uniscribe style */
176 /* Making this self-allocating simplifies writing shapers and
177 * also keeps things easier for caller. item_size passed in
178 * must be at least sizeof(HB_GlyphItem) but can be bigger,
179 * to accomodate application structures that extend HB_GlyphItem.
180 * The allocated items will be zero-initialized.
182 * (Hack: Harfbuzz could choose to use even a *bigger* item size
183 * and stick internal information before the public item structure.
184 * This hack could possibly be used to unify this with HB_Buffer)
186 HB_GlyphBuffer
*hb_glyph_buffer_new (size_t item_size
);
187 void hb_glyph_buffer_clear (HB_GlyphBuffer
*buf
);
188 HB_Result
hb_glyph_buffer_extend_glyphs (HB_GlyphBuffer
*buf
, int n_items
);
189 HB_Result
hb_glyph_buffer_extend_clusters (HB_GlyphBuffer
*buf
, int n_clusters
);
190 void hb_glyph_buffer_free (HB_GlyphBuffer
*buf
);
193 /* Accessor for a particular glyph */
194 #define HB_GLYPH_BUFFER_ITEM(buffer, index)
197 * Main shaping function
199 HB_Result
hb_shape(HB_ShapeInput
*input
, HB_GlyphBuffer
*output
);