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