src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape-complex-khmer.cc
author jiefu
Fri, 15 Nov 2019 20:39:26 +0800
changeset 59110 8c4c358272a9
parent 54232 7c11a7cc7c1d
permissions -rw-r--r--
8234232: [TESTBUG] gc/shenandoah/jvmti/TestHeapDump.java fails with -Xcomp Reviewed-by: zgu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     1
/*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     2
 * Copyright © 2011,2012  Google, Inc.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     3
 *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     4
 *  This is part of HarfBuzz, a text shaping library.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     5
 *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     6
 * Permission is hereby granted, without written agreement and without
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     7
 * license or royalty fees, to use, copy, modify, and distribute this
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     8
 * software and its documentation for any purpose, provided that the
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
     9
 * above copyright notice and the following two paragraphs appear in
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    10
 * all copies of this software.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    11
 *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    12
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    13
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    14
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    15
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    16
 * DAMAGE.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    17
 *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    18
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    19
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    20
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    21
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    22
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    23
 *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    24
 * Google Author(s): Behdad Esfahbod
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    25
 */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    26
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    27
#include "hb-ot-shape-complex-khmer.hh"
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    28
#include "hb-ot-layout.hh"
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    29
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    30
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    31
/*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    32
 * Khmer shaper.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    33
 */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    34
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    35
static const hb_ot_map_feature_t
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    36
khmer_features[] =
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    37
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    38
  /*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    39
   * Basic features.
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    40
   * These features are applied in order, one at a time, after reordering.
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    41
   */
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    42
  {HB_TAG('p','r','e','f'), F_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    43
  {HB_TAG('b','l','w','f'), F_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    44
  {HB_TAG('a','b','v','f'), F_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    45
  {HB_TAG('p','s','t','f'), F_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    46
  {HB_TAG('c','f','a','r'), F_MANUAL_JOINERS},
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    47
  /*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    48
   * Other features.
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    49
   * These features are applied all at once after clearing syllables.
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    50
   */
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    51
  {HB_TAG('p','r','e','s'), F_GLOBAL_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    52
  {HB_TAG('a','b','v','s'), F_GLOBAL_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    53
  {HB_TAG('b','l','w','s'), F_GLOBAL_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    54
  {HB_TAG('p','s','t','s'), F_GLOBAL_MANUAL_JOINERS},
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    55
  /*
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    56
   * Positioning features.
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    57
   * We don't care about the types.
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    58
   */
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    59
  {HB_TAG('d','i','s','t'), F_GLOBAL},
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    60
  {HB_TAG('a','b','v','m'), F_GLOBAL},
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    61
  {HB_TAG('b','l','w','m'), F_GLOBAL},
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    62
};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    63
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    64
/*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    65
 * Must be in the same order as the khmer_features array.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    66
 */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    67
enum {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    68
  PREF,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    69
  BLWF,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    70
  ABVF,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    71
  PSTF,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    72
  CFAR,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    73
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    74
  _PRES,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    75
  _ABVS,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    76
  _BLWS,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    77
  _PSTS,
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    78
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    79
  _DIST,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    80
  _ABVM,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    81
  _BLWM,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    82
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    83
  KHMER_NUM_FEATURES,
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    84
  KHMER_BASIC_FEATURES = _PRES, /* Don't forget to update this! */
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    85
};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    86
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    87
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    88
setup_syllables (const hb_ot_shape_plan_t *plan,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    89
                 hb_font_t *font,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    90
                 hb_buffer_t *buffer);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    91
static void
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    92
reorder (const hb_ot_shape_plan_t *plan,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    93
         hb_font_t *font,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
    94
         hb_buffer_t *buffer);
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    95
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    96
clear_syllables (const hb_ot_shape_plan_t *plan,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    97
                 hb_font_t *font,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    98
                 hb_buffer_t *buffer);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
    99
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   100
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   101
collect_features_khmer (hb_ot_shape_planner_t *plan)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   102
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   103
  hb_ot_map_builder_t *map = &plan->map;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   104
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   105
  /* Do this before any lookups have been applied. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   106
  map->add_gsub_pause (setup_syllables);
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   107
  map->add_gsub_pause (reorder);
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   108
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   109
  /* Testing suggests that Uniscribe does NOT pause between basic
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   110
   * features.  Test with KhmerUI.ttf and the following three
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   111
   * sequences:
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   112
   *
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   113
   *   U+1789,U+17BC
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   114
   *   U+1789,U+17D2,U+1789
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   115
   *   U+1789,U+17D2,U+1789,U+17BC
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   116
   *
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   117
   * https://github.com/harfbuzz/harfbuzz/issues/974
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   118
   */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   119
  map->enable_feature (HB_TAG('l','o','c','l'));
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   120
  map->enable_feature (HB_TAG('c','c','m','p'));
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   121
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   122
  unsigned int i = 0;
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   123
  for (; i < KHMER_BASIC_FEATURES; i++)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   124
    map->add_feature (khmer_features[i]);
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   125
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   126
  map->add_gsub_pause (clear_syllables);
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   127
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   128
  for (; i < KHMER_NUM_FEATURES; i++)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   129
    map->add_feature (khmer_features[i]);
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   130
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   131
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   132
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   133
override_features_khmer (hb_ot_shape_planner_t *plan)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   134
{
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   135
  hb_ot_map_builder_t *map = &plan->map;
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   136
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   137
  /* Khmer spec has 'clig' as part of required shaping features:
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   138
   * "Apply feature 'clig' to form ligatures that are desired for
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   139
   * typographical correctness.", hence in overrides... */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   140
  map->enable_feature (HB_TAG('c','l','i','g'));
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   141
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   142
  /* Uniscribe does not apply 'kern' in Khmer. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   143
  if (hb_options ().uniscribe_bug_compatible)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   144
  {
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   145
    map->disable_feature (HB_TAG('k','e','r','n'));
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   146
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   147
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   148
  map->disable_feature (HB_TAG('l','i','g','a'));
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   149
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   150
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   151
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   152
struct would_substitute_feature_t
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   153
{
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   154
  void init (const hb_ot_map_t *map, hb_tag_t feature_tag, bool zero_context_)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   155
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   156
    zero_context = zero_context_;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   157
    map->get_stage_lookups (0/*GSUB*/,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   158
                            map->get_feature_stage (0/*GSUB*/, feature_tag),
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   159
                            &lookups, &count);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   160
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   161
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   162
  bool would_substitute (const hb_codepoint_t *glyphs,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   163
                         unsigned int          glyphs_count,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   164
                         hb_face_t            *face) const
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   165
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   166
    for (unsigned int i = 0; i < count; i++)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   167
      if (hb_ot_layout_lookup_would_substitute_fast (face, lookups[i].index, glyphs, glyphs_count, zero_context))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   168
        return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   169
    return false;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   170
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   171
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   172
  private:
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   173
  const hb_ot_map_t::lookup_map_t *lookups;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   174
  unsigned int count;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   175
  bool zero_context;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   176
};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   177
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   178
struct khmer_shape_plan_t
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   179
{
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   180
  bool get_virama_glyph (hb_font_t *font, hb_codepoint_t *pglyph) const
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   181
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   182
    hb_codepoint_t glyph = virama_glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   183
    if (unlikely (virama_glyph == (hb_codepoint_t) -1))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   184
    {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   185
      if (!font->get_nominal_glyph (0x17D2u, &glyph))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   186
        glyph = 0;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   187
      /* Technically speaking, the spec says we should apply 'locl' to virama too.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   188
       * Maybe one day... */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   189
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   190
      /* Our get_nominal_glyph() function needs a font, so we can't get the virama glyph
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   191
       * during shape planning...  Instead, overwrite it here.  It's safe.  Don't worry! */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   192
      virama_glyph = glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   193
    }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   194
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   195
    *pglyph = glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   196
    return glyph != 0;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   197
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   198
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   199
  mutable hb_codepoint_t virama_glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   200
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   201
  would_substitute_feature_t pref;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   202
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   203
  hb_mask_t mask_array[KHMER_NUM_FEATURES];
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   204
};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   205
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   206
static void *
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   207
data_create_khmer (const hb_ot_shape_plan_t *plan)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   208
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   209
  khmer_shape_plan_t *khmer_plan = (khmer_shape_plan_t *) calloc (1, sizeof (khmer_shape_plan_t));
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   210
  if (unlikely (!khmer_plan))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   211
    return nullptr;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   212
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   213
  khmer_plan->virama_glyph = (hb_codepoint_t) -1;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   214
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   215
  khmer_plan->pref.init (&plan->map, HB_TAG('p','r','e','f'), true);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   216
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   217
  for (unsigned int i = 0; i < ARRAY_LENGTH (khmer_plan->mask_array); i++)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   218
    khmer_plan->mask_array[i] = (khmer_features[i].flags & F_GLOBAL) ?
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   219
                                 0 : plan->map.get_1_mask (khmer_features[i].tag);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   220
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   221
  return khmer_plan;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   222
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   223
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   224
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   225
data_destroy_khmer (void *data)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   226
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   227
  free (data);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   228
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   229
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   230
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   231
enum syllable_type_t {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   232
  consonant_syllable,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   233
  broken_cluster,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   234
  non_khmer_cluster,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   235
};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   236
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   237
#include "hb-ot-shape-complex-khmer-machine.hh"
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   238
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   239
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   240
setup_masks_khmer (const hb_ot_shape_plan_t *plan HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   241
                   hb_buffer_t              *buffer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   242
                   hb_font_t                *font HB_UNUSED)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   243
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   244
  HB_BUFFER_ALLOCATE_VAR (buffer, khmer_category);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   245
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   246
  /* We cannot setup masks here.  We save information about characters
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   247
   * and setup masks later on in a pause-callback. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   248
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   249
  unsigned int count = buffer->len;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   250
  hb_glyph_info_t *info = buffer->info;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   251
  for (unsigned int i = 0; i < count; i++)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   252
    set_khmer_properties (info[i]);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   253
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   254
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   255
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   256
setup_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   257
                 hb_font_t *font HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   258
                 hb_buffer_t *buffer)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   259
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   260
  find_syllables (buffer);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   261
  foreach_syllable (buffer, start, end)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   262
    buffer->unsafe_to_break (start, end);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   263
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   264
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   265
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   266
/* Rules from:
50826
f5b95be8b6e2 8205441: Upgrade to harfbuzz 1.8.1
prr
parents: 50352
diff changeset
   267
 * https://docs.microsoft.com/en-us/typography/script-development/devanagari */
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   268
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   269
static void
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   270
reorder_consonant_syllable (const hb_ot_shape_plan_t *plan,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   271
                            hb_face_t *face HB_UNUSED,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   272
                            hb_buffer_t *buffer,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   273
                            unsigned int start, unsigned int end)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   274
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   275
  const khmer_shape_plan_t *khmer_plan = (const khmer_shape_plan_t *) plan->data;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   276
  hb_glyph_info_t *info = buffer->info;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   277
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   278
  /* Setup masks. */
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   279
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   280
    /* Post-base */
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   281
    hb_mask_t mask = khmer_plan->mask_array[BLWF] | khmer_plan->mask_array[ABVF] | khmer_plan->mask_array[PSTF];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   282
    for (unsigned int i = start + 1; i < end; i++)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   283
      info[i].mask  |= mask;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   284
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   285
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   286
  unsigned int num_coengs = 0;
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   287
  for (unsigned int i = start + 1; i < end; i++)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   288
  {
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   289
    /* """
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   290
     * When a COENG + (Cons | IndV) combination are found (and subscript count
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   291
     * is less than two) the character combination is handled according to the
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   292
     * subscript type of the character following the COENG.
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   293
     *
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   294
     * ...
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   295
     *
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   296
     * Subscript Type 2 - The COENG + RO characters are reordered to immediately
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   297
     * before the base glyph. Then the COENG + RO characters are assigned to have
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   298
     * the 'pref' OpenType feature applied to them.
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   299
     * """
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   300
     */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   301
    if (info[i].khmer_category() == OT_Coeng && num_coengs <= 2 && i + 1 < end)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   302
    {
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   303
      num_coengs++;
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   304
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   305
      if (info[i + 1].khmer_category() == OT_Ra)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   306
      {
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   307
        for (unsigned int j = 0; j < 2; j++)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   308
          info[i + j].mask |= khmer_plan->mask_array[PREF];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   309
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   310
        /* Move the Coeng,Ro sequence to the start. */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   311
        buffer->merge_clusters (start, i + 2);
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   312
        hb_glyph_info_t t0 = info[i];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   313
        hb_glyph_info_t t1 = info[i + 1];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   314
        memmove (&info[start + 2], &info[start], (i - start) * sizeof (info[0]));
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   315
        info[start] = t0;
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   316
        info[start + 1] = t1;
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   317
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   318
        /* Mark the subsequent stuff with 'cfar'.  Used in Khmer.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   319
         * Read the feature spec.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   320
         * This allows distinguishing the following cases with MS Khmer fonts:
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   321
         * U+1784,U+17D2,U+179A,U+17D2,U+1782
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   322
         * U+1784,U+17D2,U+1782,U+17D2,U+179A
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   323
         */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   324
        if (khmer_plan->mask_array[CFAR])
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   325
          for (unsigned int j = i + 2; j < end; j++)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   326
            info[j].mask |= khmer_plan->mask_array[CFAR];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   327
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   328
        num_coengs = 2; /* Done. */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   329
      }
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   330
    }
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   331
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   332
    /* Reorder left matra piece. */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   333
    else if (info[i].khmer_category() == OT_VPre)
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   334
    {
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   335
      /* Move to the start. */
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   336
      buffer->merge_clusters (start, i + 1);
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   337
      hb_glyph_info_t t = info[i];
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   338
      memmove (&info[start + 1], &info[start], (i - start) * sizeof (info[0]));
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   339
      info[start] = t;
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   340
    }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   341
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   342
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   343
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   344
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   345
initial_reordering_syllable (const hb_ot_shape_plan_t *plan,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   346
                             hb_face_t *face,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   347
                             hb_buffer_t *buffer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   348
                             unsigned int start, unsigned int end)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   349
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   350
  syllable_type_t syllable_type = (syllable_type_t) (buffer->info[start].syllable() & 0x0F);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   351
  switch (syllable_type)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   352
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   353
    case broken_cluster: /* We already inserted dotted-circles, so just call the consonant_syllable. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   354
    case consonant_syllable:
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   355
     reorder_consonant_syllable (plan, face, buffer, start, end);
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   356
     break;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   357
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   358
    case non_khmer_cluster:
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   359
      break;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   360
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   361
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   362
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   363
static inline void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   364
insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   365
                       hb_font_t *font,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   366
                       hb_buffer_t *buffer)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   367
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   368
  /* Note: This loop is extra overhead, but should not be measurable. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   369
  bool has_broken_syllables = false;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   370
  unsigned int count = buffer->len;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   371
  hb_glyph_info_t *info = buffer->info;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   372
  for (unsigned int i = 0; i < count; i++)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   373
    if ((info[i].syllable() & 0x0F) == broken_cluster)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   374
    {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   375
      has_broken_syllables = true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   376
      break;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   377
    }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   378
  if (likely (!has_broken_syllables))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   379
    return;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   380
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   381
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   382
  hb_codepoint_t dottedcircle_glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   383
  if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   384
    return;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   385
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   386
  hb_glyph_info_t dottedcircle = {0};
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   387
  dottedcircle.codepoint = 0x25CCu;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   388
  set_khmer_properties (dottedcircle);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   389
  dottedcircle.codepoint = dottedcircle_glyph;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   390
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   391
  buffer->clear_output ();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   392
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   393
  buffer->idx = 0;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   394
  unsigned int last_syllable = 0;
50826
f5b95be8b6e2 8205441: Upgrade to harfbuzz 1.8.1
prr
parents: 50352
diff changeset
   395
  while (buffer->idx < buffer->len && buffer->successful)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   396
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   397
    unsigned int syllable = buffer->cur().syllable();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   398
    syllable_type_t syllable_type = (syllable_type_t) (syllable & 0x0F);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   399
    if (unlikely (last_syllable != syllable && syllable_type == broken_cluster))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   400
    {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   401
      last_syllable = syllable;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   402
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   403
      hb_glyph_info_t ginfo = dottedcircle;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   404
      ginfo.cluster = buffer->cur().cluster;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   405
      ginfo.mask = buffer->cur().mask;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   406
      ginfo.syllable() = buffer->cur().syllable();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   407
      /* TODO Set glyph_props? */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   408
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   409
      /* Insert dottedcircle after possible Repha. */
50826
f5b95be8b6e2 8205441: Upgrade to harfbuzz 1.8.1
prr
parents: 50352
diff changeset
   410
      while (buffer->idx < buffer->len && buffer->successful &&
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   411
             last_syllable == buffer->cur().syllable() &&
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   412
             buffer->cur().khmer_category() == OT_Repha)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   413
        buffer->next_glyph ();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   414
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   415
      buffer->output_info (ginfo);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   416
    }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   417
    else
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   418
      buffer->next_glyph ();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   419
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   420
  buffer->swap_buffers ();
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   421
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   422
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   423
static void
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   424
reorder (const hb_ot_shape_plan_t *plan,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   425
         hb_font_t *font,
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   426
         hb_buffer_t *buffer)
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   427
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   428
  insert_dotted_circles (plan, font, buffer);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   429
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   430
  foreach_syllable (buffer, start, end)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   431
    initial_reordering_syllable (plan, font->face, buffer, start, end);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   432
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   433
  HB_BUFFER_DEALLOCATE_VAR (buffer, khmer_category);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   434
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   435
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   436
static void
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   437
clear_syllables (const hb_ot_shape_plan_t *plan HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   438
                 hb_font_t *font HB_UNUSED,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   439
                 hb_buffer_t *buffer)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   440
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   441
  hb_glyph_info_t *info = buffer->info;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   442
  unsigned int count = buffer->len;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   443
  for (unsigned int i = 0; i < count; i++)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   444
    info[i].syllable() = 0;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   445
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   446
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   447
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   448
static bool
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   449
decompose_khmer (const hb_ot_shape_normalize_context_t *c,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   450
                 hb_codepoint_t  ab,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   451
                 hb_codepoint_t *a,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   452
                 hb_codepoint_t *b)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   453
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   454
  switch (ab)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   455
  {
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   456
    /*
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   457
     * Decompose split matras that don't have Unicode decompositions.
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   458
     */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   459
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   460
    /* Khmer */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   461
    case 0x17BEu  : *a = 0x17C1u; *b= 0x17BEu; return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   462
    case 0x17BFu  : *a = 0x17C1u; *b= 0x17BFu; return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   463
    case 0x17C0u  : *a = 0x17C1u; *b= 0x17C0u; return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   464
    case 0x17C4u  : *a = 0x17C1u; *b= 0x17C4u; return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   465
    case 0x17C5u  : *a = 0x17C1u; *b= 0x17C5u; return true;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   466
  }
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   467
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   468
  return (bool) c->unicode->decompose (ab, a, b);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   469
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   470
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   471
static bool
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   472
compose_khmer (const hb_ot_shape_normalize_context_t *c,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   473
               hb_codepoint_t  a,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   474
               hb_codepoint_t  b,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   475
               hb_codepoint_t *ab)
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   476
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   477
  /* Avoid recomposing split matras. */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   478
  if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a)))
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   479
    return false;
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   480
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   481
  return (bool) c->unicode->compose (a, b, ab);
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   482
}
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   483
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   484
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   485
const hb_ot_complex_shaper_t _hb_ot_complex_shaper_khmer =
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   486
{
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   487
  collect_features_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   488
  override_features_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   489
  data_create_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   490
  data_destroy_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   491
  nullptr, /* preprocess_text */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   492
  nullptr, /* postprocess_glyphs */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   493
  HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   494
  decompose_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   495
  compose_khmer,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   496
  setup_masks_khmer,
54232
7c11a7cc7c1d 8210782: Upgrade HarfBuzz to the latest 2.3.1
prr
parents: 51000
diff changeset
   497
  HB_TAG_NONE, /* gpos_tag */
50352
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   498
  nullptr, /* reorder_marks */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   499
  HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   500
  false, /* fallback_position */
25db2c8f3cf8 8199530: Upgrade to harfbuzz 1.7.6
prr
parents:
diff changeset
   501
};