hb-ot-layout-gdef-table.hh revision 5f5b24f99f52bbc922e238b65c06061ba07c8548
164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod/*
2ee58aaebd296ea8237516754fd4e825d524b11b7Behdad Esfahbod * Copyright (C) 2007,2008,2009  Red Hat, Inc.
364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *  This is part of HarfBuzz, an OpenType Layout engine library.
564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Permission is hereby granted, without written agreement and without
764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * software and its documentation for any purpose, provided that the
964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
1064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * all copies of this software.
1164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
1264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
1364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
1464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
1564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
1664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * DAMAGE.
1764aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
1864aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
1964aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
2064aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
2164aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
2264aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
2364aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod *
2464aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod * Red Hat Author(s): Behdad Esfahbod
2564aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod */
2664aef3a54999496fd1de4f5aa5b019e4c03b3836Behdad Esfahbod
275f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#ifndef HB_OT_LAYOUT_GDEF_PRIVATE_HH
285f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#define HB_OT_LAYOUT_GDEF_PRIVATE_HH
295b3f7702a64fe0513d08a67bdb72704e46fd7cd4Behdad Esfahbod
305f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#include "hb-ot-layout-common-private.hh"
315b3f7702a64fe0513d08a67bdb72704e46fd7cd4Behdad Esfahbod
3212360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod
3360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct GlyphClassDef : ClassDef
3460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
354fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod  enum {
364fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    BaseGlyph		= 0x0001u,
374fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    LigatureGlyph	= 0x0002u,
384fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    MarkGlyph		= 0x0003u,
394fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    ComponentGlyph	= 0x0004u,
404fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod  };
414c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
424c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
431f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod/*
441f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod * Attachment List Table
451f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod */
464c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
47e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbodtypedef ArrayOf<USHORT> AttachPoint;	/* Array of contour point indices--in
481f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod					 * increasing numerical order */
498b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (AttachPoint, 2);
50303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod
5160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct AttachList
5260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
5362964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod  inline bool get_attach_points (hb_codepoint_t glyph_id,
5479420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod				 unsigned int *point_count /* IN/OUT */,
5579420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod				 unsigned int *point_array /* OUT */) const
56855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod  {
5779420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    unsigned int index = (this+coverage) (glyph_id);
5862964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    if (index == NOT_COVERED)
5962964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    {
6062964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod      *point_count = 0;
6162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod      return false;
6262964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    }
6379420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    const AttachPoint &points = this+attachPoint[index];
6479420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod
6579420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    unsigned int count = MIN (points.len, *point_count);
6679420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    for (unsigned int i = 0; i < count; i++)
6779420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod      point_array[i] = points[i];
6879420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod
6979420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    *point_count = points.len;
7062964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod
7162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    return true;
72855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod  }
734c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
74855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod  private:
753d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod  OffsetTo<Coverage>
763d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod		coverage;		/* Offset to Coverage table -- from
774c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod					 * beginning of AttachList table */
785f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod  OffsetArrayOf<AttachPoint>
795f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod		attachPoint;		/* Array of AttachPoint tables
805f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod					 * in Coverage Index order */
814c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
828b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (AttachList, 4);
834c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
844c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod/*
854c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod * Ligature Caret Table
864c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod */
874c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
8860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat1
8960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
907586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  friend struct CaretValue;
917586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod
927586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  private:
930ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
9460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod  {
95e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod    /* XXX vertical */
960ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    return context->font->x_scale * coordinate / 0x10000;
974c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  }
98303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod
99303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  private:
100303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  USHORT	caretValueFormat;	/* Format identifier--format = 1 */
101303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  SHORT		coordinate;		/* X or Y value, in design units */
1024c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
10312360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat1, 4);
1044c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
10560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat2
10660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
1077586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  friend struct CaretValue;
1087586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod
1097586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  private:
1100ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
11160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod  {
112e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod    return /* TODO contour point */ 0;
1134c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  }
114303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod
115303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  private:
116303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  USHORT	caretValueFormat;	/* Format identifier--format = 2 */
117303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  USHORT	caretValuePoint;	/* Contour point index on glyph */
1184c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
11912360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat2, 4);
1204c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
12160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValueFormat3
12260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
1237586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  friend struct CaretValue;
1247586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod
1250ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
12660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod  {
127e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod    /* XXX vertical */
1280ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    return context->font->x_scale * coordinate / 0x10000 +
1290ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod	   (this+deviceTable).get_delta (context->font->x_ppem) << 6;
130303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  }
131303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod
132303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  private:
1334c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  USHORT	caretValueFormat;	/* Format identifier--format = 3 */
1344c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  SHORT		coordinate;		/* X or Y value, in design units */
135263bbef7670b59aa88ef9ba910579dfa51226524Behdad Esfahbod  OffsetTo<Device>
136263bbef7670b59aa88ef9ba910579dfa51226524Behdad Esfahbod		deviceTable;		/* Offset to Device table for X or Y
1374c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod					 * value--from beginning of CaretValue
1384c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod					 * table */
1394c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
14012360f7c159826ae72271b34486dee59d96aa8caBehdad EsfahbodASSERT_SIZE (CaretValueFormat3, 6);
1414c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
14260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CaretValue
14360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
1444c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  /* XXX  we need access to a load-contour-point vfunc here */
1450ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
14660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod  {
147f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod    switch (u.format) {
1480ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    case 1: return u.format1->get_caret_value (context, glyph_id);
1490ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    case 2: return u.format2->get_caret_value (context, glyph_id);
1500ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    case 3: return u.format3->get_caret_value (context, glyph_id);
1514c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod    default:return 0;
1524c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod    }
1534c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  }
1544c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod
155303fe62824d4e99df554b6bfaacba05d068522fbBehdad Esfahbod  private:
1564c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  union {
157f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod  USHORT		format;		/* Format identifier */
158f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod  CaretValueFormat1	format1[];
159f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod  CaretValueFormat2	format2[];
160f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad Esfahbod  CaretValueFormat3	format3[];
1614c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod  } u;
1624c2556cb4c38a56c3a5087deb54aa6262ab3aff9Behdad Esfahbod};
163f8dc67b3c24dfc805da756a73cb217b36e16b4b8Behdad EsfahbodASSERT_SIZE (CaretValue, 2);
1641f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod
16560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LigGlyph
16660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
1670ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline void get_lig_carets (hb_ot_layout_context_t *context,
16862964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      hb_codepoint_t glyph_id,
16962964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      unsigned int *caret_count /* IN/OUT */,
17062964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      int *caret_array /* OUT */) const
17162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod  {
17262964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod
17362964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    unsigned int count = MIN (carets.len, *caret_count);
17462964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    for (unsigned int i = 0; i < count; i++)
1750ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod      caret_array[i] = (this+carets[i]).get_caret_value (context, glyph_id);
17662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod
17762964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    *caret_count = carets.len;
17862964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod  }
1797586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod
18060d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod  private:
1815f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod  OffsetArrayOf<CaretValue>
18262964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod		carets;			/* Offset rrray of CaretValue tables
183e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod					 * --from beginning of LigGlyph table
184e4efdd80a8fa4edbcdec9cd84f35f5f4521943c2Behdad Esfahbod					 * --in increasing coordinate order */
1851f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod};
1868b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (LigGlyph, 2);
187b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
18860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LigCaretList
18960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
1900ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline bool get_lig_carets (hb_ot_layout_context_t *context,
19162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      hb_codepoint_t glyph_id,
19262964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      unsigned int *caret_count /* IN/OUT */,
19362964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      int *caret_array /* OUT */) const
194855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod  {
19579420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod    unsigned int index = (this+coverage) (glyph_id);
19662964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    if (index == NOT_COVERED)
19762964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    {
19862964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod      *caret_count = 0;
19962964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod      return false;
20062964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    }
20162964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    const LigGlyph &lig_glyph = this+ligGlyph[index];
2020ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod    lig_glyph.get_lig_carets (context, glyph_id, caret_count, caret_array);
20362964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod    return true;
204855720ca47bf5a7a44eb5b84dce9f7da6e7156bdBehdad Esfahbod  }
20512360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod
20612360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod  private:
2073d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod  OffsetTo<Coverage>
2083d54bd1293069fc3d3bdeeea8ad45036f3ee65f3Behdad Esfahbod		coverage;		/* Offset to Coverage table--from
20912360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod					 * beginning of LigCaretList table */
2105f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod  OffsetArrayOf<LigGlyph>
2115f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod		ligGlyph;		/* Array of LigGlyph tables
2125f810363acc3ad3cba631a68620e3d37e54c95c4Behdad Esfahbod					 * in Coverage Index order */
21312360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod};
2148b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (LigCaretList, 4);
21512360f7c159826ae72271b34486dee59d96aa8caBehdad Esfahbod
216e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
217e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbodstruct MarkGlyphSetsFormat1
218e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod{
219e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
220e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  { return (this+coverage[set_index]).get_coverage (glyph_id) != NOT_COVERED; }
221e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
222e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  private:
223e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  USHORT	format;			/* Format identifier--format = 1 */
224e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  LongOffsetArrayOf<Coverage>
225e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod		coverage;		/* Array of long offsets to mark set
226e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod					 * coverage tables */
227e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod};
228e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad EsfahbodASSERT_SIZE (MarkGlyphSetsFormat1, 4);
229e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
230e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbodstruct MarkGlyphSets
231e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod{
232e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline bool covers (unsigned int set_index, hb_codepoint_t glyph_id) const
233e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  {
234e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod    switch (u.format) {
235e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod    case 1: return u.format1->covers (set_index, glyph_id);
236e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod    default:return false;
237e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod    }
238e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  }
239e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
240e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  private:
241e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  union {
242e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  USHORT		format;		/* Format identifier */
243e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  MarkGlyphSetsFormat1	format1[];
244e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  } u;
245e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod};
246e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad EsfahbodASSERT_SIZE (MarkGlyphSets, 2);
247e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
248e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
2491f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod/*
250aefaafe5bc4fc6d37a412c135b1079c287be7045Behdad Esfahbod * GDEF
2511f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod */
252b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
25360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct GDEF
25460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{
2557586089c6fa8185cad8387869d3703c637e5cbb1Behdad Esfahbod  static const hb_tag_t Tag		= HB_TAG ('G','D','E','F');
256600e5eb80f553ea8eb862e6784133574c74ca513Behdad Esfahbod
2574fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod  enum {
2584fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    UnclassifiedGlyph	= 0,
2594fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    BaseGlyph		= 1,
2604fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    LigatureGlyph	= 2,
2614fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    MarkGlyph		= 3,
2624fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod    ComponentGlyph	= 4,
2634fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod  };
264aff831ed6787abe8e24a977e34d97ff2e0b7dc21Behdad Esfahbod
265212aba6189d7aaac0bab169b77ae6bdab16800a5Behdad Esfahbod  STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GDEF, 1);
266b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
2679e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  inline bool has_glyph_classes () const { return glyphClassDef != 0; }
268e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline hb_ot_layout_class_t get_glyph_class (hb_codepoint_t glyph) const
26979420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod  { return (this+glyphClassDef).get_class (glyph); }
270b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
2719e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  inline bool has_mark_attachment_types () const { return markAttachClassDef != 0; }
272e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline hb_ot_layout_class_t get_mark_attachment_type (hb_codepoint_t glyph) const
27379420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod  { return (this+markAttachClassDef).get_class (glyph); }
27479420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod
27579420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod  inline bool has_attach_points () const { return attachList != 0; }
276e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline bool get_attach_points (hb_codepoint_t glyph_id,
27779420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod				 unsigned int *point_count /* IN/OUT */,
27879420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod				 unsigned int *point_array /* OUT */) const
27962964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod  { return (this+attachList).get_attach_points (glyph_id, point_count, point_array); }
280b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
28179420ad9caf2d5fc94c3693e8292edfa27060b2dBehdad Esfahbod  inline bool has_lig_carets () const { return ligCaretList != 0; }
2820ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  inline bool get_lig_carets (hb_ot_layout_context_t *context,
28362964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      hb_codepoint_t glyph_id,
28462964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      unsigned int *caret_count /* IN/OUT */,
28562964afcecd96038cfaa8bc2bc931f43ee83be7eBehdad Esfahbod			      int *caret_array /* OUT */) const
2860ead481a5a8623103565fd7d924666e7342278ddBehdad Esfahbod  { return (this+ligCaretList).get_lig_carets (context, glyph_id, caret_count, caret_array); }
287b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
288e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline bool has_mark_sets () const { return version >= 0x00010002 && markGlyphSetsDef[0] != 0; }
289e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  inline bool mark_set_covers (unsigned int set_index, hb_codepoint_t glyph_id) const
290e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  { return version >= 0x00010002 && (this+markGlyphSetsDef[0]).covers (set_index, glyph_id); }
291e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod
292238c855fcd4f0ef97a94a8662d2a2f2bb5c21ecbBehdad Esfahbod  private:
293e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  FixedVersion	version;		/* Version of the GDEF table--currently
294e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod					 * 0x00010002 */
2959e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  OffsetTo<ClassDef>
2969e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod		glyphClassDef;		/* Offset to class definition table
297b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod					 * for glyph type--from beginning of
2981f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod					 * GDEF header (may be Null) */
2999e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  OffsetTo<AttachList>
3009e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod		attachList;		/* Offset to list of glyphs with
301b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod					 * attachment points--from beginning
3021f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod					 * of GDEF header (may be Null) */
3039e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  OffsetTo<LigCaretList>
3049e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod		ligCaretList;		/* Offset to list of positioning points
305b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod					 * for ligature carets--from beginning
3061f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod					 * of GDEF header (may be Null) */
3079e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod  OffsetTo<ClassDef>
3089e4d9d7b2721859172bc9c59c1aea27b01eb9c07Behdad Esfahbod		markAttachClassDef;	/* Offset to class definition table for
309b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod					 * mark attachment type--from beginning
3101f437e6f47fb6c15761021bd2078f31778f2179cBehdad Esfahbod					 * of GDEF header (may be Null) */
311e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod  OffsetTo<MarkGlyphSets>
312e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod		markGlyphSetsDef[0];	/* Offset to the table of mark set
313e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod					 * definitions--from beginning of GDEF
314e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod					 * header (may be NULL).  Introduced
315e4b92b85a7750bd4271ad607b3c41f0184e89febBehdad Esfahbod					 * in version 00010002. */
316b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod};
3178b8358033184198ff638ee1379093717596e162dBehdad EsfahbodASSERT_SIZE (GDEF, 12);
318b9d7688fb3d45894901484b74095c4f11cab6196Behdad Esfahbod
3196f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod
3205f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#endif /* HB_OT_LAYOUT_GDEF_PRIVATE_HH */
321