jdk/src/share/native/sun/font/layout/GlyphIterator.cpp
author prr
Thu, 07 Mar 2013 10:02:20 -0800
changeset 16891 91e99bed64ae
parent 7486 6a36b1ebc620
child 18518 153791a0895c
permissions -rw-r--r--
8001031: Better font processing Reviewed-by: srl, vadim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "GlyphDefinitionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "GlyphPositionAdjustments.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "GlyphIterator.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "LEGlyphStorage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "Lookups.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "LESwaps.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    41
U_NAMESPACE_BEGIN
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    43
GlyphIterator::GlyphIterator(LEGlyphStorage &theGlyphStorage, GlyphPositionAdjustments *theGlyphPositionAdjustments, le_bool rightToLeft, le_uint16 theLookupFlags,
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    44
                             FeatureMask theFeatureMask, const LEReferenceTo<GlyphDefinitionTableHeader> &theGlyphDefinitionTableHeader)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  : direction(1), position(-1), nextLimit(-1), prevLimit(-1),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    glyphStorage(theGlyphStorage), glyphPositionAdjustments(theGlyphPositionAdjustments),
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    47
    srcIndex(-1), destIndex(-1), lookupFlags(theLookupFlags), featureMask(theFeatureMask), glyphGroup(0),
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    48
    glyphClassDefinitionTable(), markAttachClassDefinitionTable()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    51
  LEErrorCode success = LE_NO_ERROR; // TODO
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    le_int32 glyphCount = glyphStorage.getGlyphCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    54
    if (theGlyphDefinitionTableHeader.isValid()) {
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    55
      glyphClassDefinitionTable = theGlyphDefinitionTableHeader
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    56
        -> getGlyphClassDefinitionTable(theGlyphDefinitionTableHeader, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    57
      markAttachClassDefinitionTable = theGlyphDefinitionTableHeader
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
    58
        ->getMarkAttachClassDefinitionTable(theGlyphDefinitionTableHeader, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    nextLimit = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    if (rightToLeft) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        direction = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        position = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        nextLimit = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        prevLimit = glyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
GlyphIterator::GlyphIterator(GlyphIterator &that)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    lookupFlags = that.lookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    featureMask = that.featureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    84
    glyphGroup  = that.glyphGroup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
GlyphIterator::GlyphIterator(GlyphIterator &that, FeatureMask newFeatureMask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    lookupFlags = that.lookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    featureMask = newFeatureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   102
    glyphGroup  = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
GlyphIterator::GlyphIterator(GlyphIterator &that, le_uint16 newLookupFlags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
  : glyphStorage(that.glyphStorage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    direction    = that.direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    position     = that.position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    nextLimit    = that.nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    prevLimit    = that.prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    glyphPositionAdjustments = that.glyphPositionAdjustments;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    srcIndex = that.srcIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    destIndex = that.destIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    lookupFlags = newLookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    featureMask = that.featureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   120
    glyphGroup  = that.glyphGroup;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    glyphClassDefinitionTable = that.glyphClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    markAttachClassDefinitionTable = that.markAttachClassDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
GlyphIterator::~GlyphIterator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    // nothing to do, right?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
void GlyphIterator::reset(le_uint16 newLookupFlags, FeatureMask newFeatureMask)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    position     = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    featureMask  = newFeatureMask;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   134
    glyphGroup   = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    lookupFlags  = newLookupFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   138
LEGlyphID *GlyphIterator::insertGlyphs(le_int32 count, LEErrorCode& success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   140
    return glyphStorage.insertGlyphs(position, count, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
le_int32 GlyphIterator::applyInsertions()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    le_int32 newGlyphCount = glyphStorage.applyInsertions();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        prevLimit = newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        nextLimit = newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    return newGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
le_int32 GlyphIterator::getCurrStreamPosition() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    return position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
le_bool GlyphIterator::isRightToLeft() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    return direction < 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
le_bool GlyphIterator::ignoresMarks() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    return (lookupFlags & lfIgnoreMarks) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
le_bool GlyphIterator::baselineIsLogicalEnd() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    return (lookupFlags & lfBaselineIsLogicalEnd) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
LEGlyphID GlyphIterator::getCurrGlyphID() const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            return 0xFFFF;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    return glyphStorage[position];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
void GlyphIterator::getCursiveEntryPoint(LEPoint &entryPoint) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    glyphPositionAdjustments->getEntryPoint(position, entryPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
void GlyphIterator::getCursiveExitPoint(LEPoint &exitPoint) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    glyphPositionAdjustments->getExitPoint(position, exitPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
void GlyphIterator::setCurrGlyphID(TTGlyphID glyphID)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    LEGlyphID glyph = glyphStorage[position];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    glyphStorage[position] = LE_SET_GLYPH(glyph, glyphID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
void GlyphIterator::setCurrStreamPosition(le_int32 newPosition)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if (newPosition >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            position = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (newPosition <= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            position = nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (newPosition <= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            position = prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        if (newPosition >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            position = nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    position = newPosition - direction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
void GlyphIterator::setCurrGlyphBaseOffset(le_int32 baseOffset)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    glyphPositionAdjustments->setBaseOffset(position, baseOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   271
void GlyphIterator::adjustCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   272
                                                      float xAdvanceAdjust, float yAdvanceAdjust)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    glyphPositionAdjustments->adjustXPlacement(position, xPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    glyphPositionAdjustments->adjustYPlacement(position, yPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    glyphPositionAdjustments->adjustXAdvance(position, xAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    glyphPositionAdjustments->adjustYAdvance(position, yAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   290
void GlyphIterator::setCurrGlyphPositionAdjustment(float xPlacementAdjust, float yPlacementAdjust,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   291
                                                      float xAdvanceAdjust, float yAdvanceAdjust)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    glyphPositionAdjustments->setXPlacement(position, xPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    glyphPositionAdjustments->setYPlacement(position, yPlacementAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    glyphPositionAdjustments->setXAdvance(position, xAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    glyphPositionAdjustments->setYAdvance(position, yAdvanceAdjust);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   309
void GlyphIterator::clearCursiveEntryPoint()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   310
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   311
    if (direction < 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   312
        if (position <= nextLimit || position >= prevLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   313
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   314
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   315
    } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   316
        if (position <= prevLimit || position >= nextLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   317
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   318
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   319
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   320
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   321
    glyphPositionAdjustments->clearEntryPoint(position);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   322
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   323
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   324
void GlyphIterator::clearCursiveExitPoint()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   325
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   326
    if (direction < 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   327
        if (position <= nextLimit || position >= prevLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   328
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   329
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   330
    } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   331
        if (position <= prevLimit || position >= nextLimit) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   332
            return;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   333
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   334
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   335
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   336
    glyphPositionAdjustments->clearExitPoint(position);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   337
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   338
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
void GlyphIterator::setCursiveEntryPoint(LEPoint &entryPoint)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    glyphPositionAdjustments->setEntryPoint(position, entryPoint, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
void GlyphIterator::setCursiveExitPoint(LEPoint &exitPoint)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    glyphPositionAdjustments->setExitPoint(position, exitPoint, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
void GlyphIterator::setCursiveGlyph()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    if (direction < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        if (position <= nextLimit || position >= prevLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        if (position <= prevLimit || position >= nextLimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    glyphPositionAdjustments->setCursiveGlyph(position, baselineIsLogicalEnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
le_bool GlyphIterator::filterGlyph(le_uint32 index) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   386
    LEErrorCode success = LE_NO_ERROR;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    LEGlyphID glyphID = glyphStorage[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    le_int32 glyphClass = gcdNoGlyphClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    if (LE_GET_GLYPH(glyphID) >= 0xFFFE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   394
    if (glyphClassDefinitionTable.isValid()) {
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   395
      glyphClass = glyphClassDefinitionTable->getGlyphClass(glyphClassDefinitionTable, glyphID, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    switch (glyphClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    case gcdNoGlyphClass:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    case gcdSimpleGlyph:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    case gcdLigatureGlyph:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        return (lookupFlags & lfIgnoreLigatures) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    case gcdMarkGlyph:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        if ((lookupFlags & lfIgnoreMarks) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        le_uint16 markAttachType = (lookupFlags & lfMarkAttachTypeMask) >> lfMarkAttachTypeShift;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   417
        if ((markAttachType != 0) && (markAttachClassDefinitionTable.isValid())) {
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   418
          return markAttachClassDefinitionTable
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   419
            -> getGlyphClass(markAttachClassDefinitionTable, glyphID, success) != markAttachType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    case gcdComponentGlyph:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        return (lookupFlags & lfIgnoreBaseGlyphs) != 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   433
le_bool GlyphIterator::hasFeatureTag(le_bool matchGroup) const
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    if (featureMask == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    LEErrorCode success = LE_NO_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    FeatureMask fm = glyphStorage.getAuxData(position, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   442
    return ((fm & featureMask) == featureMask) && (!matchGroup || (le_int32)(fm & LE_GLYPH_GROUP_MASK) == glyphGroup);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
le_bool GlyphIterator::findFeatureTag()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   447
  //glyphGroup = 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   448
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    while (nextInternal()) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   450
        if (hasFeatureTag(FALSE)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   451
            LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   452
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   453
            glyphGroup = (glyphStorage.getAuxData(position, success) & LE_GLYPH_GROUP_MASK);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
le_bool GlyphIterator::nextInternal(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    while (newPosition != nextLimit && delta > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            newPosition += direction;
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   469
            //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        } while (newPosition != nextLimit && filterGlyph(newPosition));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        delta -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   477
    //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    return position != nextLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
le_bool GlyphIterator::next(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   483
    return nextInternal(delta) && hasFeatureTag(TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
le_bool GlyphIterator::prevInternal(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    while (newPosition != prevLimit && delta > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            newPosition -= direction;
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   493
            //fprintf(stderr,"%s:%d:%s: newPosition = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, newPosition, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        } while (newPosition != prevLimit && filterGlyph(newPosition));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        delta -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 7486
diff changeset
   501
    //fprintf(stderr,"%s:%d:%s: exit position = %d, delta = %d\n", __FILE__, __LINE__, __FUNCTION__, position, delta);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    return position != prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
le_bool GlyphIterator::prev(le_uint32 delta)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   507
    return prevInternal(delta) && hasFeatureTag(TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
le_int32 GlyphIterator::getMarkComponent(le_int32 markPosition) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    le_int32 component = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    le_int32 posn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    for (posn = position; posn != markPosition; posn += direction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (glyphStorage[posn] == 0xFFFE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            component += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    return component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
// This is basically prevInternal except that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
// doesn't take a delta argument, and it doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
// filter out 0xFFFE glyphs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
le_bool GlyphIterator::findMark2Glyph()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    le_int32 newPosition = position;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        newPosition -= direction;
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   533
    } while (newPosition != prevLimit && glyphStorage[newPosition] != 0xFFFE && filterGlyph(newPosition));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    position = newPosition;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    return position != prevLimit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
}
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   539
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   540
U_NAMESPACE_END