0N/A/*
2362N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation. Oracle designates this
2362N/A * particular file as subject to the "Classpath" exception as provided
0N/A * by Oracle in the LICENSE file that accompanied this code.
2362N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2362N/A *
0N/A */
0N/A
0N/A
0N/A/*
0N/A * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
0N/A *
0N/A * This file is a modification of the ICU file IndicLayoutEngine.cpp
0N/A * by Jens Herden and Javier Sola for Khmer language
0N/A *
0N/A */
0N/A
0N/A
0N/A#include "OpenTypeLayoutEngine.h"
0N/A#include "KhmerLayoutEngine.h"
0N/A#include "LEGlyphStorage.h"
0N/A#include "KhmerReordering.h"
0N/A
0N/AU_NAMESPACE_BEGIN
0N/A
0N/AUOBJECT_DEFINE_RTTI_IMPLEMENTATION(KhmerOpenTypeLayoutEngine)
0N/A
0N/AKhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
0N/A le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success)
0N/A : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success)
0N/A{
0N/A fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
0N/A fFeatureOrder = TRUE;
0N/A}
0N/A
0N/AKhmerOpenTypeLayoutEngine::KhmerOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
0N/A le_int32 typoFlags, LEErrorCode &success)
0N/A : OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success)
0N/A{
0N/A fFeatureMap = KhmerReordering::getFeatureMap(fFeatureMapCount);
0N/A fFeatureOrder = TRUE;
0N/A}
0N/A
0N/AKhmerOpenTypeLayoutEngine::~KhmerOpenTypeLayoutEngine()
0N/A{
0N/A // nothing to do
0N/A}
0N/A
0N/A// Input: characters
0N/A// Output: characters, char indices, tags
0N/A// Returns: output character count
0N/Ale_int32 KhmerOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
0N/A LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success)
0N/A{
0N/A if (LE_FAILURE(success)) {
0N/A return 0;
0N/A }
0N/A
0N/A if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) {
0N/A success = LE_ILLEGAL_ARGUMENT_ERROR;
0N/A return 0;
0N/A }
0N/A
0N/A le_int32 worstCase = count * 3; // worst case is 3 for Khmer TODO check if 2 is enough
0N/A
0N/A outChars = LE_NEW_ARRAY(LEUnicode, worstCase);
0N/A
0N/A if (outChars == NULL) {
0N/A success = LE_MEMORY_ALLOCATION_ERROR;
0N/A return 0;
0N/A }
0N/A
0N/A glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success);
0N/A glyphStorage.allocateAuxData(success);
0N/A
0N/A if (LE_FAILURE(success)) {
0N/A LE_DELETE_ARRAY(outChars);
0N/A return 0;
0N/A }
0N/A
0N/A // NOTE: assumes this allocates featureTags...
0N/A // (probably better than doing the worst case stuff here...)
0N/A le_int32 outCharCount = KhmerReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage);
0N/A
0N/A glyphStorage.adoptGlyphCount(outCharCount);
0N/A return outCharCount;
0N/A}
0N/A
0N/AU_NAMESPACE_END
0N/A