Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/font/layout/ArabicLayoutEngine.h
38918 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/242526/*27*28* (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved29*30*/3132#ifndef __ARABICLAYOUTENGINE_H33#define __ARABICLAYOUTENGINE_H3435#include "LETypes.h"36#include "LEFontInstance.h"37#include "LEGlyphFilter.h"38#include "LayoutEngine.h"39#include "OpenTypeLayoutEngine.h"4041#include "GlyphSubstitutionTables.h"42#include "GlyphDefinitionTables.h"43#include "GlyphPositioningTables.h"4445U_NAMESPACE_BEGIN4647/**48* This class implements OpenType layout for Arabic fonts. It overrides49* the characerProcessing method to assign the correct OpenType feature50* tags for the Arabic contextual forms. It also overrides the adjustGlyphPositions51* method to guarantee that all vowel and accent glyphs have zero advance width.52*53* @internal54*/55class ArabicOpenTypeLayoutEngine : public OpenTypeLayoutEngine56{57public:58/**59* This is the main constructor. It constructs an instance of ArabicOpenTypeLayoutEngine for60* a particular font, script and language. It takes the GSUB table as a parameter since61* LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has an62* Indic OpenType font.63*64* @param fontInstance - the font65* @param scriptCode - the script66* @param langaugeCode - the language67* @param gsubTable - the GSUB table68* @param success - set to an error code if the operation fails69*70* @see LayoutEngine::layoutEngineFactory71* @see OpenTypeLayoutEngine72* @see ScriptAndLanguageTags.h for script and language codes73*74* @internal75*/76ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,77le_int32 typoFlags, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success);7879/**80* This constructor is used when the font requires a "canned" GSUB table which can't be known81* until after this constructor has been invoked.82*83* @param fontInstance - the font84* @param scriptCode - the script85* @param langaugeCode - the language86* @param success - set to an error code if the operation fails87*88* @see OpenTypeLayoutEngine89* @see ScriptAndLanguageTags.h for script and language codes90*91* @internal92*/93ArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,94le_int32 typoFlags, LEErrorCode &success);9596/**97* The destructor, virtual for correct polymorphic invocation.98*99* @internal100*/101virtual ~ArabicOpenTypeLayoutEngine();102103/**104* ICU "poor man's RTTI", returns a UClassID for the actual class.105*106* @stable ICU 2.8107*/108virtual UClassID getDynamicClassID() const;109110/**111* ICU "poor man's RTTI", returns a UClassID for this class.112*113* @stable ICU 2.8114*/115static UClassID getStaticClassID();116117protected:118119/**120* This method does Arabic OpenType character processing. It assigns the OpenType feature121* tags to the characters to generate the correct contextual forms and ligatures.122*123* Input parameters:124* @param chars - the input character context125* @param offset - the index of the first character to process126* @param count - the number of characters to process127* @param max - the number of characters in the input context128* @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run129*130* Output parameters:131* @param outChars - the output character arrayt132* @param charIndices - the output character index array133* @param featureTags - the output feature tag array134* @param success - set to an error code if the operation fails135*136* @return the output character count137*138* @internal139*/140virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,141LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);142143/**144* This method applies the GPOS table if it is present, otherwise it ensures that all vowel145* and accent glyphs have a zero advance width by calling the adjustMarkGlyphs method.146* If the font contains a GDEF table, that is used to identify voewls and accents. Otherwise147* the character codes are used.148*149* @param chars - the input character context150* @param offset - the offset of the first character to process151* @param count - the number of characters to process152* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered153* @param glyphs - the input glyph array154* @param glyphCount - the number of glyphs155* @param positions - the position array, will be updated as needed156* @param success - output parameter set to an error code if the operation fails157*158* @internal159*/160virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);161162// static void adjustMarkGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool rightToLeft, LEGlyphStorage &glyphStorage, LEErrorCode &success);163164};165166/**167* The class implements OpenType layout for Arabic fonts which don't168* contain a GSUB table, using a canned GSUB table based on Unicode169* Arabic Presentation Forms. It overrides the mapCharsToGlyphs method170* to use the Presentation Forms as logical glyph indices. It overrides the171* glyphPostProcessing method to convert the Presentation Forms to actual172* glyph indices.173*174* @see ArabicOpenTypeLayoutEngine175*176* @internal177*/178class UnicodeArabicOpenTypeLayoutEngine : public ArabicOpenTypeLayoutEngine179{180public:181/**182* This constructs an instance of UnicodeArabicOpenTypeLayoutEngine for a specific font,183* script and language.184*185* @param fontInstance - the font186* @param scriptCode - the script187* @param languageCode - the language188* @param success - set to an error code if the operation fails189*190* @see LEFontInstance191* @see ScriptAndLanguageTags.h for script and language codes192*193* @internal194*/195UnicodeArabicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,196le_int32 typoFlags, LEErrorCode &success);197198/**199* The destructor, virtual for correct polymorphic invocation.200*201* @internal202*/203virtual ~UnicodeArabicOpenTypeLayoutEngine();204205protected:206207/**208* This method converts the Arabic Presentation Forms in the temp glyph array209* into actual glyph indices using ArabicOpenTypeLayoutEngine::mapCharsToGlyps.210*211* Input parameters:212* @param tempGlyphs - the input presentation forms213* @param tempCharIndices - the input character index array214* @param tempGlyphCount - the number of Presentation Froms215*216* Output parameters:217* @param glyphs - the output glyph index array218* @param charIndices - the output character index array219* @param success - set to an error code if the operation fails220*221* @return the number of glyph indices in the output glyph index array222*223* @internal224*/225virtual le_int32 glyphPostProcessing(LEGlyphStorage &tempGlyphStorage, LEGlyphStorage &glyphStorage, LEErrorCode &success);226227/**228* This method copies the input characters into the output glyph index array,229* for use by the canned GSUB table. It also generates the character index array.230*231* Input parameters:232* @param chars - the input character context233* @param offset - the offset of the first character to be mapped234* @param count - the number of characters to be mapped235* @param reverse - if <code>TRUE</code>, the output will be in reverse order236* @param mirror - if <code>TRUE</code>, do character mirroring237* @param glyphStorage - the glyph storage object. Glyph and char index arrays will be updated.238*239* @param success - set to an error code if the operation fails240*241* @internal242*/243virtual void mapCharsToGlyphs(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, le_bool mirror,244LEGlyphStorage &glyphStorage, LEErrorCode &success);245246/**247* This method ensures that all vowel and accent glyphs have a zero advance width by calling248* the adjustMarkGlyphs method. The character codes are used to identify the vowel and mark249* glyphs.250*251* @param chars - the input character context252* @param offset - the offset of the first character to process253* @param count - the number of characters to process254* @param reverse - <code>TRUE</code> if the glyphs in the glyph array have been reordered255* @param glyphStorage - the glyph storage object. The glyph positions will be updated as needed.256* @param success - output parameter set to an error code if the operation fails257*258* @internal259*/260virtual void adjustGlyphPositions(const LEUnicode chars[], le_int32 offset, le_int32 count, le_bool reverse, LEGlyphStorage &glyphStorage, LEErrorCode &success);261};262263U_NAMESPACE_END264#endif265266267268