1fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod/*
22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2007,2008,2009  Red Hat, Inc.
3f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod * Copyright © 2012  Google, Inc.
4fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod *
5c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod *  This is part of HarfBuzz, a text shaping library.
6fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod *
7fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * Permission is hereby granted, without written agreement and without
8fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
9fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * software and its documentation for any purpose, provided that the
10fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * above copyright notice and the following two paragraphs appear in
11fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * all copies of this software.
12fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod *
13fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * DAMAGE.
18fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod *
19fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod *
25fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod * Red Hat Author(s): Behdad Esfahbod
26f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod * Google Author(s): Behdad Esfahbod
27fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod */
28fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod
290f0cd9d361f1bb614aa3fd4616160d027062370eBehdad Esfahbod#ifndef HB_OT_LAYOUT_PRIVATE_HH
300f0cd9d361f1bb614aa3fd4616160d027062370eBehdad Esfahbod#define HB_OT_LAYOUT_PRIVATE_HH
31fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod
32c57d454accff66e5f2c58006e8fb40bc020b6182Behdad Esfahbod#include "hb-private.hh"
332c80296aa5991ad67483889147f5c84fefe54af2Behdad Esfahbod
34fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod#include "hb-ot-layout.h"
352c80296aa5991ad67483889147f5c84fefe54af2Behdad Esfahbod
36c57d454accff66e5f2c58006e8fb40bc020b6182Behdad Esfahbod#include "hb-font-private.hh"
3722da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#include "hb-buffer-private.hh"
381336ecdf8e4e9879b96b26ecfbf5c9ba6c49e2b9Behdad Esfahbod#include "hb-set-private.hh"
39fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod
4023c86aa0009324433e78fcd0c47f2c0ff14b1949Behdad Esfahbod
41f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod/* buffer var allocations, used during the GSUB/GPOS processing */
42cd0c6e148f6d078b364370cb2f808b793b921be2Behdad Esfahbod#define glyph_props()		var1.u16[0] /* GDEF glyph properties */
43cd0c6e148f6d078b364370cb2f808b793b921be2Behdad Esfahbod#define syllable()		var1.u8[2] /* GSUB/GPOS shaping boundaries */
44cd0c6e148f6d078b364370cb2f808b793b921be2Behdad Esfahbod#define lig_props()		var1.u8[3] /* GSUB/GPOS ligature tracking */
45f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod
46607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod/* buffer var allocations, used during the entire shaping process */
47607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod#define unicode_props0()	var2.u8[0]
48607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod#define unicode_props1()	var2.u8[1]
49607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
50607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
51607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline void
52607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unicode)
53607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
54607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  info->unicode_props0() = ((unsigned int) unicode->general_category (info->codepoint)) |
55607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod			   (unicode->is_default_ignorable (info->codepoint) ? 0x80 : 0) |
560b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod			   (info->codepoint == 0x200C ? 0x40 : 0) |
570b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod			   (info->codepoint == 0x200D ? 0x20 : 0);
58607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  info->unicode_props1() = unicode->modified_combining_class (info->codepoint);
59607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
60607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
61607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline hb_unicode_general_category_t
62607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_get_general_category (const hb_glyph_info_t *info)
63607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
640b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod  return (hb_unicode_general_category_t) (info->unicode_props0() & 0x1F);
65607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
66607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
67607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline void
68607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_set_modified_combining_class (hb_glyph_info_t *info, unsigned int modified_class)
69607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
70607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  info->unicode_props1() = modified_class;
71607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
72607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
73607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline unsigned int
74607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info)
75607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
76607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  return info->unicode_props1();
77607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
78607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
79607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline hb_bool_t
80607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_is_default_ignorable (const hb_glyph_info_t *info)
81607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
82607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  return !!(info->unicode_props0() & 0x80);
83607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
84607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
85607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbodinline hb_bool_t
86607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod_hb_glyph_info_is_zwnj (const hb_glyph_info_t *info)
87607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod{
88607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod  return !!(info->unicode_props0() & 0x40);
89607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod}
90607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
910b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbodinline hb_bool_t
920b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod_hb_glyph_info_is_zwj (const hb_glyph_info_t *info)
930b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod{
940b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod  return !!(info->unicode_props0() & 0x20);
950b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod}
960b45479198d61d5135dad771e9c68408eb13f930Behdad Esfahbod
97607feb7cff0e50f8738d2e49ca463fc9d7d494deBehdad Esfahbod
98ea278d3895fe0c92801d692cd71d8d9f1de7c048Behdad Esfahbod#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot)
99acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
100266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod/*
101266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod * GDEF
102266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod */
103266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod
1045a08ecf9200a6ac9b4ebb7ec5c13dcb42d8820ceBehdad Esfahbodtypedef enum {
10557542d7f411c71d9b8110ce6f64090b2c0f6a925Behdad Esfahbod  HB_OT_LAYOUT_GLYPH_PROPS_UNCLASSIFIED	= 1 << HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED,
10657542d7f411c71d9b8110ce6f64090b2c0f6a925Behdad Esfahbod  HB_OT_LAYOUT_GLYPH_PROPS_BASE_GLYPH	= 1 << HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH,
10757542d7f411c71d9b8110ce6f64090b2c0f6a925Behdad Esfahbod  HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE	= 1 << HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE,
10857542d7f411c71d9b8110ce6f64090b2c0f6a925Behdad Esfahbod  HB_OT_LAYOUT_GLYPH_PROPS_MARK		= 1 << HB_OT_LAYOUT_GLYPH_CLASS_MARK,
10957542d7f411c71d9b8110ce6f64090b2c0f6a925Behdad Esfahbod  HB_OT_LAYOUT_GLYPH_PROPS_COMPONENT	= 1 << HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT
1105a08ecf9200a6ac9b4ebb7ec5c13dcb42d8820ceBehdad Esfahbod} hb_ot_layout_glyph_class_mask_t;
1115a08ecf9200a6ac9b4ebb7ec5c13dcb42d8820ceBehdad Esfahbod
112ead428d7a0bf4dc84340a99f3959e5cc58123e99Behdad Esfahbod
113266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod
11449c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod/*
11549c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod * GSUB/GPOS
11649c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod */
11749c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod
118a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod/* lig_id / lig_comp
119a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *
120a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod * When a ligature is formed:
121a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *
1225d874d566fe5d2cc4cfaf02c79b663d8a626ca1eBehdad Esfahbod *   - The ligature glyph and any marks in between all the same newly allocated
1235d874d566fe5d2cc4cfaf02c79b663d8a626ca1eBehdad Esfahbod *     lig_id,
1244751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod *   - The ligature glyph will get lig_num_comps set to the number of components
125a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *   - The marks get lig_comp > 0, reflecting which component of the ligature
126a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *     they were applied to.
127a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *   - This is used in GPOS to attach marks to the right component of a ligature
128a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *     in MarkLigPos.
129a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *
130a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod * When a multiple-substitution is done:
131a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *
132a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *   - All resulting glyphs will have lig_id = 0,
133a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *   - The resulting glyphs will have lig_comp = 0, 1, 2, ... respectively.
1345d874d566fe5d2cc4cfaf02c79b663d8a626ca1eBehdad Esfahbod *   - This is used in GPOS to attach marks to the first component of a
135a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *     multiple substitution in MarkBasePos.
136a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod *
137a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod * The numbers are also used in GPOS to do mark-to-mark positioning only
138a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod * to marks that belong to the same component of a ligature in MarkMarPos.
139a3313e54008167e415b72c780ca7b9cda958d07eBehdad Esfahbod */
1404751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod#define IS_LIG_BASE 0x10
14149c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodstatic inline void
1422ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodset_lig_props_for_ligature (hb_glyph_info_t &info, unsigned int lig_id, unsigned int lig_num_comps)
1432ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod{
1444751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod  info.lig_props() = (lig_id << 5) | IS_LIG_BASE | (lig_num_comps & 0x0F);
1452ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod}
1462ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodstatic inline void
1472ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodset_lig_props_for_mark (hb_glyph_info_t &info, unsigned int lig_id, unsigned int lig_comp)
1482ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod{
1492ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  info.lig_props() = (lig_id << 5) | (lig_comp & 0x0F);
1502ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod}
1512ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodstatic inline void
1522ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodset_lig_props_for_component (hb_glyph_info_t &info, unsigned int comp)
1532ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod{
1542ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  set_lig_props_for_mark (info, 0, comp);
1552ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod}
1562ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod
15749c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodstatic inline unsigned int
15849c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodget_lig_id (const hb_glyph_info_t &info)
15949c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod{
1602ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  return info.lig_props() >> 5;
16149c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod}
1624751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbodstatic inline bool
1634751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbodis_a_ligature (const hb_glyph_info_t &info)
1644751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod{
1654751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod  return !!(info.lig_props() & IS_LIG_BASE);
1664751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod}
16749c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodstatic inline unsigned int
16849c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodget_lig_comp (const hb_glyph_info_t &info)
16949c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod{
1704751dec8be05883483fd5f6b474ebd22583ae566Behdad Esfahbod  if (is_a_ligature (info))
1712ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod    return 0;
1722ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  else
1732ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod    return info.lig_props() & 0x0F;
1742ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod}
1752ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodstatic inline unsigned int
1762ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbodget_lig_num_comps (const hb_glyph_info_t &info)
1772ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod{
1785a08ecf9200a6ac9b4ebb7ec5c13dcb42d8820ceBehdad Esfahbod  if ((info.glyph_props() & HB_OT_LAYOUT_GLYPH_PROPS_LIGATURE) && is_a_ligature (info))
1792ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod    return info.lig_props() & 0x0F;
1802ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  else
1812ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod    return 1;
18249c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod}
18349c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod
18449c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbodstatic inline uint8_t allocate_lig_id (hb_buffer_t *buffer) {
1852ec3ba46a3c24469096e901750e38f6ee555479aBehdad Esfahbod  uint8_t lig_id = buffer->next_serial () & 0x07;
18649c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod  if (unlikely (!lig_id))
18749c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod    lig_id = allocate_lig_id (buffer); /* in case of overflow */
18849c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod  return lig_id;
18949c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod}
19049c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod
19149c5ec51444f27f33e1eb6aa1959c61b08fa89c0Behdad Esfahbod
192f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad EsfahbodHB_INTERNAL hb_bool_t
193362a990b2246f5448ecb9d600761f710aea7d42dBehdad Esfahbodhb_ot_layout_lookup_would_substitute_fast (hb_face_t            *face,
194d9b204d3d24cde165167714728bf380267903d6aBehdad Esfahbod					   unsigned int          lookup_index,
195f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod					   const hb_codepoint_t *glyphs,
196f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod					   unsigned int          glyphs_length,
197d9b204d3d24cde165167714728bf380267903d6aBehdad Esfahbod					   hb_bool_t             zero_context);
198f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod
199b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
200b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod/* Should be called before all the substitute_lookup's are done. */
201b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad EsfahbodHB_INTERNAL void
202afbcc24be01a64bdb5c05c63880269145fa1d3c8Behdad Esfahbodhb_ot_layout_substitute_start (hb_font_t    *font,
203b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod			       hb_buffer_t  *buffer);
204b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
205f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad EsfahbodHB_INTERNAL hb_bool_t
206afbcc24be01a64bdb5c05c63880269145fa1d3c8Behdad Esfahbodhb_ot_layout_substitute_lookup (hb_font_t    *font,
207b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod				hb_buffer_t  *buffer,
208b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod				unsigned int  lookup_index,
209cfc507c5432e6327e8484b07b9e091212653bc92Behdad Esfahbod				hb_mask_t     mask,
210a8cf7b43fa795150ae3d42d64424bb6e0373d0b2Behdad Esfahbod				hb_bool_t     auto_zwj);
211b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
212b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod/* Should be called after all the substitute_lookup's are done */
213b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad EsfahbodHB_INTERNAL void
214afbcc24be01a64bdb5c05c63880269145fa1d3c8Behdad Esfahbodhb_ot_layout_substitute_finish (hb_font_t    *font,
215b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod				hb_buffer_t  *buffer);
216b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
217b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
218b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod/* Should be called before all the position_lookup's are done.  Resets positions to zero. */
219b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad EsfahbodHB_INTERNAL void
220b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbodhb_ot_layout_position_start (hb_font_t    *font,
221b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod			     hb_buffer_t  *buffer);
222f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod
223f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad EsfahbodHB_INTERNAL hb_bool_t
224b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbodhb_ot_layout_position_lookup (hb_font_t    *font,
225b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod			      hb_buffer_t  *buffer,
226b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod			      unsigned int  lookup_index,
227cfc507c5432e6327e8484b07b9e091212653bc92Behdad Esfahbod			      hb_mask_t     mask,
228a8cf7b43fa795150ae3d42d64424bb6e0373d0b2Behdad Esfahbod			      hb_bool_t     auto_zwj);
229b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
230b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod/* Should be called after all the position_lookup's are done */
231b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad EsfahbodHB_INTERNAL void
232b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbodhb_ot_layout_position_finish (hb_font_t    *font,
233568000274c8edb5f41bc4f876ce21fcc8bdaeed8Behdad Esfahbod			      hb_buffer_t  *buffer);
234b0e6a26a10ccca70ebc88a9e158a89ccfab0add5Behdad Esfahbod
235f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod
236f860366456d9e59b139a940da6d89c3c4fb9e96eBehdad Esfahbod
2370ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod/*
2380ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod * hb_ot_layout_t
2390ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod */
2400ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod
2417c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbodnamespace OT {
2427c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  struct GDEF;
2437c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  struct GSUB;
2447c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  struct GPOS;
2457c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod}
2467c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod
2470a4399ca228d244e646abdb3487da0f13b228889Behdad Esfahbodstruct hb_ot_layout_t
24860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
24970e0f2a75ec1559f2f70ada837ce4bc4baca49e3Behdad Esfahbod  hb_blob_t *gdef_blob;
25070e0f2a75ec1559f2f70ada837ce4bc4baca49e3Behdad Esfahbod  hb_blob_t *gsub_blob;
25170e0f2a75ec1559f2f70ada837ce4bc4baca49e3Behdad Esfahbod  hb_blob_t *gpos_blob;
25270e0f2a75ec1559f2f70ada837ce4bc4baca49e3Behdad Esfahbod
2537c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  const struct OT::GDEF *gdef;
2547c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  const struct OT::GSUB *gsub;
2557c8e844d92aa604fc4b396343721ea90eb83adb8Behdad Esfahbod  const struct OT::GPOS *gpos;
2561336ecdf8e4e9879b96b26ecfbf5c9ba6c49e2b9Behdad Esfahbod
2576f7611375521c6d285a9aa763f2ea5cb44cd0d39Behdad Esfahbod  unsigned int gsub_lookup_count;
2586f7611375521c6d285a9aa763f2ea5cb44cd0d39Behdad Esfahbod  unsigned int gpos_lookup_count;
2596f7611375521c6d285a9aa763f2ea5cb44cd0d39Behdad Esfahbod
2601336ecdf8e4e9879b96b26ecfbf5c9ba6c49e2b9Behdad Esfahbod  hb_set_digest_t *gsub_digests;
2611336ecdf8e4e9879b96b26ecfbf5c9ba6c49e2b9Behdad Esfahbod  hb_set_digest_t *gpos_digests;
2620ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod};
2635e5eb0573f7ea2ce2cf037fef0df70a4351e82c0Behdad Esfahbod
264c43562b2a7587fa3f9ef4c1c4338e4eda77368b5Behdad Esfahbod
2650a4399ca228d244e646abdb3487da0f13b228889Behdad EsfahbodHB_INTERNAL hb_ot_layout_t *
266266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod_hb_ot_layout_create (hb_face_t *face);
26723c86aa0009324433e78fcd0c47f2c0ff14b1949Behdad Esfahbod
268eee8598d75d3af692d9ececf7e8ac458e892ba9eBehdad EsfahbodHB_INTERNAL void
269266b34418c9bbe23ccaf29cb354b58c465fa3b22Behdad Esfahbod_hb_ot_layout_destroy (hb_ot_layout_t *layout);
2704189b92aaa41e4a1756c561cc6e08b0ed024afdaBehdad Esfahbod
271acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod
272fd92a3dde32fd10df30c9eeb97641bc3c15b1e9bBehdad Esfahbod
2730f0cd9d361f1bb614aa3fd4616160d027062370eBehdad Esfahbod#endif /* HB_OT_LAYOUT_PRIVATE_HH */
274