1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * HanLayoutEngine.h: OpenType processing for Han fonts.
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved.
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __HANLAYOUTENGINE_H
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __HANLAYOUTENGINE_H
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LETypes.h"
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LEFontInstance.h"
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LayoutEngine.h"
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "OpenTypeLayoutEngine.h"
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "GlyphSubstitutionTables.h"
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass LEGlyphStorage;
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This class implements OpenType layout for Han fonts. It overrides
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the characerProcessing method to assign the correct OpenType feature
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * tags for the CJK language-specific forms.
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass HanOpenTypeLayoutEngine : public OpenTypeLayoutEngine
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This is the main constructor. It constructs an instance of HanOpenTypeLayoutEngine for
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * a particular font, script and language. It takes the GSUB table as a parameter since
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * LayoutEngine::layoutEngineFactory has to read the GSUB table to know that it has a
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Han OpenType font.
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param fontInstance - the font
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param scriptCode - the script
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param langaugeCode - the language
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param gsubTable - the GSUB table
4285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho     * @param success - set to an error code if the operation fails
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see LayoutEngine::layoutEngineFactory
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see OpenTypeLayoutEngine
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @see ScriptAndLangaugeTags.h for script and language codes
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    HanOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode,
5185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho                            le_int32 typoFlags, const GlyphSubstitutionTableHeader *gsubTablem, LEErrorCode &success);
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * The destructor, virtual for correct polymorphic invocation.
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~HanOpenTypeLayoutEngine();
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for the actual class.
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID() const;
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for this class.
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @stable ICU 2.8
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID getStaticClassID();
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected:
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * This method does Han OpenType character processing. It assigns the OpenType feature
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * tags to the characters to generate the correct language-specific variants.
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Input parameters:
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param chars - the input character context
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param offset - the index of the first character to process
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param count - the number of characters to process
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param max - the number of characters in the input context
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param rightToLeft - <code>TRUE</code> if the characters are in a right to left directional run
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param glyphStorage - the object holding the glyph storage. The char index and auxillary data arrays will be set.
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Output parameters:
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param outChars - the output character arrayt
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param charIndices - the output character index array
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param featureTags - the output feature tag array
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param success - set to an error code if the operation fails
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return the output character count
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     *
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @internal
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual le_int32 characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft,
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru            LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success);
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
106