jdk/src/share/native/sun/font/layout/GXLayoutEngine2.cpp
author prr
Thu, 07 Mar 2013 10:02:20 -0800
changeset 16891 91e99bed64ae
parent 16889 3df90f344221
permissions -rw-r--r--
8001031: Better font processing Reviewed-by: srl, vadim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     1
/*
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     3
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     9
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    14
 * accompanied this code).
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    15
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    19
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    22
 * questions.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    23
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    24
 */
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    25
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    26
/*
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    27
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    28
 * (C) Copyright IBM Corp.  and others 1998-2013 - All Rights Reserved
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    29
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    30
 */
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    31
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    32
#include "LETypes.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    33
#include "LayoutEngine.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    34
#include "GXLayoutEngine2.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    35
#include "LEGlyphStorage.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    36
#include "MorphTables.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    37
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    38
U_NAMESPACE_BEGIN
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    39
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    40
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(GXLayoutEngine2)
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    41
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
    42
GXLayoutEngine2::GXLayoutEngine2(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, const LEReferenceTo<MorphTableHeader2> &morphTable, le_int32 typoFlags, LEErrorCode &success)
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
    43
  : LayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success), fMorphTable(morphTable)
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    44
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
    45
  // nothing else to do?
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    46
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    47
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    48
GXLayoutEngine2::~GXLayoutEngine2()
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    49
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    50
    reset();
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    51
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    52
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    53
// apply 'morx' table
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    54
le_int32 GXLayoutEngine2::computeGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success)
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    55
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    56
    if (LE_FAILURE(success)) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    57
        return 0;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    58
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    59
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    60
    if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    61
        success = LE_ILLEGAL_ARGUMENT_ERROR;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    62
        return 0;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    63
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    64
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    65
    mapCharsToGlyphs(chars, offset, count, rightToLeft, rightToLeft, glyphStorage, success);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    66
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    67
    if (LE_FAILURE(success)) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    68
        return 0;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    69
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    70
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
    71
    fMorphTable->process(fMorphTable, glyphStorage, fTypoFlags, success);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    72
    return count;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    73
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    74
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    75
// apply positional tables
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    76
void GXLayoutEngine2::adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool /*reverse*/,
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    77
                                          LEGlyphStorage &/*glyphStorage*/, LEErrorCode &success)
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    78
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    79
    if (LE_FAILURE(success)) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    80
        return;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    81
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    82
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    83
    if (chars == NULL || offset < 0 || count < 0) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    84
        success = LE_ILLEGAL_ARGUMENT_ERROR;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    85
        return;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    86
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    87
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    88
    // FIXME: no positional processing yet...
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    89
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    90
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    91
U_NAMESPACE_END