src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-kern-table.hh
author prr
Thu, 07 Dec 2017 11:55:06 -0800
changeset 48274 51772bf1fb0c
child 50352 25db2c8f3cf8
permissions -rw-r--r--
8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10 Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48274
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     1
/*
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     2
 * Copyright © 2017  Google, Inc.
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     3
 *
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     4
 *  This is part of HarfBuzz, a text shaping library.
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     5
 *
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     6
 * Permission is hereby granted, without written agreement and without
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     7
 * license or royalty fees, to use, copy, modify, and distribute this
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     8
 * software and its documentation for any purpose, provided that the
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
     9
 * above copyright notice and the following two paragraphs appear in
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    10
 * all copies of this software.
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    11
 *
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    12
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    13
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    14
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    15
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    16
 * DAMAGE.
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    17
 *
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    18
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    19
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    20
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    21
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    22
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    23
 *
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    24
 * Google Author(s): Behdad Esfahbod
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    25
 */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    26
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    27
#ifndef HB_OT_KERN_TABLE_HH
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    28
#define HB_OT_KERN_TABLE_HH
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    29
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    30
#include "hb-open-type-private.hh"
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    31
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    32
namespace OT {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    33
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    34
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    35
/*
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    36
 * kern -- Kerning
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    37
 */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    38
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    39
#define HB_OT_TAG_kern HB_TAG('k','e','r','n')
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    40
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    41
struct hb_glyph_pair_t
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    42
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    43
  hb_codepoint_t left;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    44
  hb_codepoint_t right;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    45
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    46
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    47
struct KernPair
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    48
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    49
  inline int get_kerning (void) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    50
  { return value; }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    51
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    52
  inline int cmp (const hb_glyph_pair_t &o) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    53
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    54
    int ret = left.cmp (o.left);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    55
    if (ret) return ret;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    56
    return right.cmp (o.right);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    57
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    58
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    59
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    60
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    61
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    62
    return_trace (c->check_struct (this));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    63
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    64
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    65
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    66
  GlyphID       left;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    67
  GlyphID       right;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    68
  FWORD         value;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    69
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    70
  DEFINE_SIZE_STATIC (6);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    71
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    72
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    73
struct KernSubTableFormat0
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    74
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    75
  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    76
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    77
    hb_glyph_pair_t pair = {left, right};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    78
    int i = pairs.bsearch (pair);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    79
    if (i == -1)
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    80
      return 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    81
    return pairs[i].get_kerning ();
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    82
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    83
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    84
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    85
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    86
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    87
    return_trace (pairs.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    88
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    89
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    90
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    91
  BinSearchArrayOf<KernPair> pairs;     /* Array of kerning pairs. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    92
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    93
  DEFINE_SIZE_ARRAY (8, pairs);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    94
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    95
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    96
struct KernClassTable
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    97
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    98
  inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
    99
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   100
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   101
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   102
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   103
    return_trace (firstGlyph.sanitize (c) && classes.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   104
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   105
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   106
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   107
  USHORT                firstGlyph;     /* First glyph in class range. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   108
  ArrayOf<USHORT>       classes;        /* Glyph classes. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   109
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   110
  DEFINE_SIZE_ARRAY (4, classes);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   111
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   112
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   113
struct KernSubTableFormat2
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   114
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   115
  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   116
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   117
    unsigned int l = (this+leftClassTable).get_class (left);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   118
    unsigned int r = (this+leftClassTable).get_class (left);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   119
    unsigned int offset = l * rowWidth + r * sizeof (FWORD);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   120
    const FWORD *arr = &(this+array);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   121
    if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end))
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   122
      return 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   123
    const FWORD *v = &StructAtOffset<FWORD> (arr, offset);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   124
    if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end))
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   125
      return 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   126
    return *v;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   127
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   128
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   129
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   130
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   131
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   132
    return_trace (rowWidth.sanitize (c) &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   133
                  leftClassTable.sanitize (c, this) &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   134
                  rightClassTable.sanitize (c, this) &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   135
                  array.sanitize (c, this));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   136
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   137
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   138
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   139
  USHORT        rowWidth;       /* The width, in bytes, of a row in the table. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   140
  OffsetTo<KernClassTable>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   141
                leftClassTable; /* Offset from beginning of this subtable to
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   142
                                 * left-hand class table. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   143
  OffsetTo<KernClassTable>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   144
                rightClassTable;/* Offset from beginning of this subtable to
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   145
                                 * right-hand class table. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   146
  OffsetTo<FWORD>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   147
                array;          /* Offset from beginning of this subtable to
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   148
                                 * the start of the kerning array. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   149
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   150
  DEFINE_SIZE_MIN (8);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   151
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   152
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   153
struct KernSubTable
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   154
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   155
  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end, unsigned int format) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   156
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   157
    switch (format) {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   158
    case 0: return u.format0.get_kerning (left, right);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   159
    case 2: return u.format2.get_kerning (left, right, end);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   160
    default:return 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   161
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   162
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   163
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   164
  inline bool sanitize (hb_sanitize_context_t *c, unsigned int format) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   165
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   166
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   167
    switch (format) {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   168
    case 0: return_trace (u.format0.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   169
    case 2: return_trace (u.format2.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   170
    default:return_trace (true);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   171
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   172
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   173
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   174
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   175
  union {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   176
  KernSubTableFormat0   format0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   177
  KernSubTableFormat2   format2;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   178
  } u;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   179
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   180
  DEFINE_SIZE_MIN (0);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   181
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   182
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   183
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   184
template <typename T>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   185
struct KernSubTableWrapper
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   186
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   187
  /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   188
  inline const T* thiz (void) const { return static_cast<const T *> (this); }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   189
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   190
  inline bool is_horizontal (void) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   191
  { return (thiz()->coverage & T::COVERAGE_CHECK_FLAGS) == T::COVERAGE_CHECK_HORIZONTAL; }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   192
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   193
  inline bool is_override (void) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   194
  { return bool (thiz()->coverage & T::COVERAGE_OVERRIDE_FLAG); }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   195
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   196
  inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   197
  { return thiz()->subtable.get_kerning (left, right, end, thiz()->format); }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   198
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   199
  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   200
  { return is_horizontal () ? get_kerning (left, right, end) : 0; }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   201
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   202
  inline unsigned int get_size (void) const { return thiz()->length; }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   203
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   204
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   205
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   206
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   207
    return_trace (c->check_struct (thiz()) &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   208
                  thiz()->length >= thiz()->min_size &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   209
                  c->check_array (thiz(), 1, thiz()->length) &&
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   210
                  thiz()->subtable.sanitize (c, thiz()->format));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   211
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   212
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   213
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   214
template <typename T>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   215
struct KernTable
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   216
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   217
  /* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   218
  inline const T* thiz (void) const { return static_cast<const T *> (this); }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   219
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   220
  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   221
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   222
    int v = 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   223
    const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (thiz()->data);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   224
    unsigned int count = thiz()->nTables;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   225
    for (unsigned int i = 0; i < count; i++)
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   226
    {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   227
      if (st->is_override ())
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   228
        v = 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   229
      v += st->get_h_kerning (left, right, table_length + (const char *) this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   230
      st = &StructAfter<typename T::SubTableWrapper> (*st);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   231
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   232
    return v;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   233
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   234
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   235
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   236
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   237
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   238
    if (unlikely (!c->check_struct (thiz()) ||
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   239
                  thiz()->version != T::VERSION))
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   240
      return_trace (false);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   241
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   242
    const typename T::SubTableWrapper *st = CastP<typename T::SubTableWrapper> (thiz()->data);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   243
    unsigned int count = thiz()->nTables;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   244
    for (unsigned int i = 0; i < count; i++)
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   245
    {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   246
      if (unlikely (!st->sanitize (c)))
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   247
        return_trace (false);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   248
      st = &StructAfter<typename T::SubTableWrapper> (*st);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   249
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   250
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   251
    return_trace (true);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   252
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   253
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   254
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   255
struct KernOT : KernTable<KernOT>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   256
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   257
  friend struct KernTable<KernOT>;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   258
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   259
  static const uint16_t VERSION = 0x0000u;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   260
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   261
  struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   262
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   263
    friend struct KernSubTableWrapper<SubTableWrapper>;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   264
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   265
    enum coverage_flags_t {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   266
      COVERAGE_DIRECTION_FLAG   = 0x01u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   267
      COVERAGE_MINIMUM_FLAG     = 0x02u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   268
      COVERAGE_CROSSSTREAM_FLAG = 0x04u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   269
      COVERAGE_OVERRIDE_FLAG    = 0x08u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   270
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   271
      COVERAGE_VARIATION_FLAG   = 0x00u, /* Not supported. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   272
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   273
      COVERAGE_CHECK_FLAGS      = 0x07u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   274
      COVERAGE_CHECK_HORIZONTAL = 0x01u
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   275
    };
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   276
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   277
    protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   278
    USHORT      versionZ;       /* Unused. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   279
    USHORT      length;         /* Length of the subtable (including this header). */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   280
    BYTE        format;         /* Subtable format. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   281
    BYTE        coverage;       /* Coverage bits. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   282
    KernSubTable subtable;      /* Subtable data. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   283
    public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   284
    DEFINE_SIZE_MIN (6);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   285
  };
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   286
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   287
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   288
  USHORT        version;        /* Version--0x0000u */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   289
  USHORT        nTables;        /* Number of subtables in the kerning table. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   290
  BYTE          data[VAR];
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   291
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   292
  DEFINE_SIZE_ARRAY (4, data);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   293
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   294
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   295
struct KernAAT : KernTable<KernAAT>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   296
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   297
  friend struct KernTable<KernAAT>;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   298
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   299
  static const uint32_t VERSION = 0x00010000u;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   300
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   301
  struct SubTableWrapper : KernSubTableWrapper<SubTableWrapper>
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   302
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   303
    friend struct KernSubTableWrapper<SubTableWrapper>;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   304
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   305
    enum coverage_flags_t {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   306
      COVERAGE_DIRECTION_FLAG   = 0x80u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   307
      COVERAGE_CROSSSTREAM_FLAG = 0x40u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   308
      COVERAGE_VARIATION_FLAG   = 0x20u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   309
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   310
      COVERAGE_OVERRIDE_FLAG    = 0x00u, /* Not supported. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   311
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   312
      COVERAGE_CHECK_FLAGS      = 0xE0u,
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   313
      COVERAGE_CHECK_HORIZONTAL = 0x00u
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   314
    };
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   315
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   316
    protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   317
    ULONG       length;         /* Length of the subtable (including this header). */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   318
    BYTE        coverage;       /* Coverage bits. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   319
    BYTE        format;         /* Subtable format. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   320
    USHORT      tupleIndex;     /* The tuple index (used for variations fonts).
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   321
                                 * This value specifies which tuple this subtable covers. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   322
    KernSubTable subtable;      /* Subtable data. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   323
    public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   324
    DEFINE_SIZE_MIN (8);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   325
  };
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   326
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   327
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   328
  ULONG         version;        /* Version--0x00010000u */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   329
  ULONG         nTables;        /* Number of subtables in the kerning table. */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   330
  BYTE          data[VAR];
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   331
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   332
  DEFINE_SIZE_ARRAY (8, data);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   333
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   334
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   335
struct kern
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   336
{
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   337
  static const hb_tag_t tableTag = HB_OT_TAG_kern;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   338
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   339
  inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   340
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   341
    switch (u.major) {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   342
    case 0: return u.ot.get_h_kerning (left, right, table_length);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   343
    case 1: return u.aat.get_h_kerning (left, right, table_length);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   344
    default:return 0;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   345
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   346
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   347
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   348
  inline bool sanitize (hb_sanitize_context_t *c) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   349
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   350
    TRACE_SANITIZE (this);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   351
    if (!u.major.sanitize (c)) return_trace (false);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   352
    switch (u.major) {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   353
    case 0: return_trace (u.ot.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   354
    case 1: return_trace (u.aat.sanitize (c));
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   355
    default:return_trace (true);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   356
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   357
  }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   358
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   359
  struct accelerator_t
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   360
  {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   361
    inline void init (const kern *table_, unsigned int table_length_)
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   362
    {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   363
      table = table_;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   364
      table_length = table_length_;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   365
    }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   366
    inline void fini (void) {}
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   367
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   368
    inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right) const
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   369
    { return table->get_h_kerning (left, right, table_length); }
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   370
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   371
    private:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   372
    const kern *table;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   373
    unsigned int table_length;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   374
  };
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   375
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   376
  protected:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   377
  union {
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   378
  USHORT                major;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   379
  KernOT                ot;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   380
  KernAAT               aat;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   381
  } u;
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   382
  public:
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   383
  DEFINE_SIZE_UNION (2, major);
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   384
};
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   385
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   386
} /* namespace OT */
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   387
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   388
51772bf1fb0c 8188836: Upgrade to Harfbuzz 1.7.1 in JDK 10
prr
parents:
diff changeset
   389
#endif /* HB_OT_KERN_TABLE_HH */