jdk/src/share/native/sun/font/layout/ArabicLayoutEngine.cpp
author srl
Mon, 06 Dec 2010 16:10:01 -0800
changeset 7486 6a36b1ebc620
parent 5506 202f599c92aa
child 16890 36b30720a997
permissions -rw-r--r--
6886358: layout code update Reviewed-by: igor, prr
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "LEScripts.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "LEGlyphFilter.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "LEGlyphStorage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "LayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "OpenTypeLayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "ArabicLayoutEngine.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "ScriptAndLanguageTags.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "CharSubstitutionFilter.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "GlyphSubstitutionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#include "GlyphDefinitionTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#include "GlyphPositioningTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#include "GDEFMarkFilter.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#include "ArabicShaping.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#include "CanonShaping.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    52
U_NAMESPACE_BEGIN
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    53
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
le_bool CharSubstitutionFilter::accept(LEGlyphID glyph) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    return fFontInstance->canDisplay((LEUnicode) glyph);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    59
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ArabicOpenTypeLayoutEngine)
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    60
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    61
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    62
                        le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTable, LEErrorCode &success)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    63
    : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    fFeatureMap = ArabicShaping::getFeatureMap(fFeatureMapCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    fFeatureOrder = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    69
ArabicOpenTypeLayoutEngine::ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    70
                                                       le_int32 typoFlags, LEErrorCode &success)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    71
    : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    fFeatureMap = ArabicShaping::getFeatureMap(fFeatureMapCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    // NOTE: We don't need to set fFeatureOrder to TRUE here
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // because this constructor is only called by the constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    // for UnicodeArabicOpenTypeLayoutEngine, which uses a pre-built
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // GSUB table that has the features in the correct order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    //fFeatureOrder = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
ArabicOpenTypeLayoutEngine::~ArabicOpenTypeLayoutEngine()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    // nothing to do
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
// Input: characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
// Output: characters, char indices, tags
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
// Returns: output character count
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    91
le_int32 ArabicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    92
        LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        success = LE_ILLEGAL_ARGUMENT_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    outChars = LE_NEW_ARRAY(LEUnicode, count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    if (outChars == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        success = LE_MEMORY_ALLOCATION_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    glyphStorage.allocateGlyphArray(count, rightToLeft, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    glyphStorage.allocateAuxData(success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        LE_DELETE_ARRAY(outChars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    CanonShaping::reorderMarks(&chars[offset], count, rightToLeft, outChars, glyphStorage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // Note: This processes the *original* character array so we can get context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // for the first and last characters. This is OK because only the marks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    // will have been reordered, and they don't contribute to shaping.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    ArabicShaping::shape(chars, offset, count, max, rightToLeft, glyphStorage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    return count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   128
void ArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   129
                                                      LEGlyphStorage &glyphStorage, LEErrorCode &success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    if (chars == NULL || offset < 0 || count < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        success = LE_ILLEGAL_ARGUMENT_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    if (fGPOSTable != NULL) {
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   141
        OpenTypeLayoutEngine::adjustGlyphPositions(chars, offset, count, reverse, glyphStorage, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    } else if (fGDEFTable != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        GDEFMarkFilter filter(fGDEFTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        adjustMarkGlyphs(glyphStorage, &filter, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    } else {
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   147
        GlyphDefinitionTableHeader *gdefTable = (GlyphDefinitionTableHeader *) CanonShaping::glyphDefinitionTable;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        GDEFMarkFilter filter(gdefTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        adjustMarkGlyphs(&chars[offset], count, reverse, glyphStorage, &filter, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   154
UnicodeArabicOpenTypeLayoutEngine::UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   155
    : ArabicOpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    fGSUBTable = (const GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    fGDEFTable = (const GlyphDefinitionTableHeader *) CanonShaping::glyphDefinitionTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    fSubstitutionFilter = new CharSubstitutionFilter(fontInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
UnicodeArabicOpenTypeLayoutEngine::~UnicodeArabicOpenTypeLayoutEngine()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    delete fSubstitutionFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
// "glyphs", "indices" -> glyphs, indices
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   169
le_int32 UnicodeArabicOpenTypeLayoutEngine::glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    // FIXME: we could avoid the memory allocation and copy if we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    // made a clone of mapCharsToGlyphs which took the fake glyphs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    // directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    le_int32 tempGlyphCount = tempGlyphStorage.getGlyphCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    LEUnicode *tempChars = LE_NEW_ARRAY(LEUnicode, tempGlyphCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    if (tempChars == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        success = LE_MEMORY_ALLOCATION_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    for (le_int32 i = 0; i < tempGlyphCount; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        tempChars[i] = (LEUnicode) LE_GET_GLYPH(tempGlyphStorage[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    glyphStorage.adoptCharIndicesArray(tempGlyphStorage);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   192
    ArabicOpenTypeLayoutEngine::mapCharsToGlyphs(tempChars, 0, tempGlyphCount, FALSE, TRUE, glyphStorage, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    LE_DELETE_ARRAY(tempChars);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    return tempGlyphCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   199
void UnicodeArabicOpenTypeLayoutEngine::mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool /*mirror*/, LEGlyphStorage &glyphStorage, LEErrorCode &success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    if (chars == NULL || offset < 0 || count < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        success = LE_ILLEGAL_ARGUMENT_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    le_int32 i, dir = 1, out = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    if (reverse) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        out = count - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        dir = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    glyphStorage.allocateGlyphArray(count, reverse, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    for (i = 0; i < count; i += 1, out += dir) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        glyphStorage[out] = (LEGlyphID) chars[offset + i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   224
void UnicodeArabicOpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse,
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   225
                                                      LEGlyphStorage &glyphStorage, LEErrorCode &success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    if (LE_FAILURE(success)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    if (chars == NULL || offset < 0 || count < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        success = LE_ILLEGAL_ARGUMENT_ERROR;
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
    GDEFMarkFilter filter(fGDEFTable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    adjustMarkGlyphs(&chars[offset], count, reverse, glyphStorage, &filter, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
}
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   240
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   241
U_NAMESPACE_END
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   242