os/graphics/graphicsdeviceinterface/gdi/sgdi/FontIndic.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
/**
sl@0
    17
 @file
sl@0
    18
 @internalComponent
sl@0
    19
*/
sl@0
    20
sl@0
    21
#include "FontIndic.h"
sl@0
    22
#include <gdi.h>
sl@0
    23
#include "GlyphSel.h"
sl@0
    24
#include "ShapeInfo.h"
sl@0
    25
#include "gdiinline.inl"
sl@0
    26
sl@0
    27
// State machine for determining syllable boundaries.
sl@0
    28
// Key: D = Dependent vowel. V = Virama. N = Nukta
sl@0
    29
// I = Independent Vowel. S = Candrabindu/Anusvara/Visarga
sl@0
    30
// C = Consonant. J = zero-width joiner. X = Other
sl@0
    31
// A = Addak (double the following constant)
sl@0
    32
enum TSyllableState
sl@0
    33
	{
sl@0
    34
	EReject = -1,
sl@0
    35
	// Begin + I: add and move to IndependentVowel
sl@0
    36
	// Begin + C: add and move to Consonant
sl@0
    37
	// Begin + V/N/D/S/J/X: add and close syllable
sl@0
    38
	EBegin = 0,
sl@0
    39
	// Consonant + D: add and move to ConsonantVowel
sl@0
    40
	// Consonant + N: add
sl@0
    41
	// Consonant + V: add and move to Virama
sl@0
    42
	// Consonant + S: add and close syllable
sl@0
    43
	// Consonant + C/I/J/X: close syllable
sl@0
    44
	EConsonant = 1,
sl@0
    45
	// Consonant2 + D: add and move to ConsonantVowel
sl@0
    46
	// Consonant2 + N: add
sl@0
    47
	// Consonant2 + V: add and move to Virama2
sl@0
    48
	// Consonant2 + S: add and close syllable
sl@0
    49
	// Consonant2 + C/I/J/X: close syllable
sl@0
    50
	EConsonant2 = 2,
sl@0
    51
	// Consonant3 + D: add and move to ConsonantVowel
sl@0
    52
	// Consonant3 + N: add
sl@0
    53
	// Consonant3 + V: add and move to Virama3
sl@0
    54
	// Consonant3 + S: add and close syllable
sl@0
    55
	// Consonant3 + C/I/J/X: close syllable
sl@0
    56
	EConsonant3 = 3,
sl@0
    57
	// Consonant + D: add and move to ConsonantVowel
sl@0
    58
	// Consonant + N: add
sl@0
    59
	// Consonant + V: add and close syllable
sl@0
    60
	// Consonant + S: add and close syllable
sl@0
    61
	// Consonant + C/I/J/X: close syllable
sl@0
    62
	EConsonant4 = 4,
sl@0
    63
	// IndependentVowel + S: add
sl@0
    64
	// IndependentVowel + D/V/N/I/C/J/X: close syllable
sl@0
    65
	EIndependentVowel = 5,
sl@0
    66
	// Virama + C: add and move to Consonant
sl@0
    67
	// Virama + J: add and close syllable
sl@0
    68
	// Virama + N/V/D/I/S/X: close syllable
sl@0
    69
	EVirama = 6,
sl@0
    70
	// Virama2 + C: add and move to Consonant3
sl@0
    71
	// Virama2 + J: add and close syllable
sl@0
    72
	// Virama2 + N/V/D/I/S/X: close syllable
sl@0
    73
	EVirama2 = 7,
sl@0
    74
	// Virama3 + C: add and move to Consonant4
sl@0
    75
	// Virama3 + J: add and close syllable
sl@0
    76
	// Virama3 + N/V/D/I/S/X: close syllable
sl@0
    77
	EVirama3 = 8,
sl@0
    78
	// Virama4 + J: add and close syllable
sl@0
    79
	// Virama4 + CN/V/D/I/S/X: close syllable
sl@0
    80
	EVirama4 = 9,
sl@0
    81
	// ConsonantVowel + S: add
sl@0
    82
	// ConsonantVowel + D/V/N/I/C/J/X: close syllable
sl@0
    83
	EConsonantVowel = 10,
sl@0
    84
	// NuktaConsonant + D/V: add
sl@0
    85
	// NuktaConsonant + S/N/I/C/J/X: close syllable
sl@0
    86
	ENuktaConsonant = 11,
sl@0
    87
	// NuktaConsonant + D/V: add
sl@0
    88
	// NuktaConsonant + S/N/I/C/J/X: close syllable
sl@0
    89
	ENuktaConsonant2 = 12,
sl@0
    90
	// NuktaConsonant + D/V: add
sl@0
    91
	// NuktaConsonant + S/N/I/C/J/X: close syllable
sl@0
    92
	ENuktaConsonant3 = 13,
sl@0
    93
	// NuktaConsonant + D: add
sl@0
    94
	// NuktaConsonant + V/S/N/I/C/J/X: close syllable
sl@0
    95
	ENuktaConsonant4 = 14,
sl@0
    96
	// IndependentVowelA + CANDRA E: add
sl@0
    97
	// IndependentVowelA + anything else: close syllable
sl@0
    98
	EIndependentVowelA = 15,
sl@0
    99
	// ZeroWidthJoinerC + V: add
sl@0
   100
	// ZeroWidthJoinerC + C/S/N/I/J/X/D: close syllable
sl@0
   101
	EZeroWidthJoinerC = 16,
sl@0
   102
	// ZeroWidthJoinerA + CANDRA E: add
sl@0
   103
	// ZeroWidthJoinerA +anything else: close syllable
sl@0
   104
	EZeroWidthJoinerA = 17,
sl@0
   105
	// ZeroWidthJoinerV + C/N: add
sl@0
   106
	// ZeroWidthJoinerV + anything else: close syllable
sl@0
   107
	EZeroWidthJoinerV = 18,
sl@0
   108
	// ZeroWidthJoinerV2 + C/N: add
sl@0
   109
	// ZeroWidthJoinerV2 + anything else: close syllable
sl@0
   110
	EZeroWidthJoinerV2 = 19,
sl@0
   111
	// ZeroWidthJoinerV3 + C/N: add
sl@0
   112
	// ZeroWidthJoinerV3 + anything else: close syllable
sl@0
   113
	EZeroWidthJoinerV3 =20,
sl@0
   114
	// EKannadaRa + C/N/V/ZWJ(C): add
sl@0
   115
	EKannadaRa = 21,
sl@0
   116
	// ESplitVowel1 + SV2: add and close syllable
sl@0
   117
	// ESPlitVowel1 + anything else: close syllable
sl@0
   118
	ESplitVowel1 = 22,
sl@0
   119
	//EGurBearerA + EIndicCodeGurDependentVowelA: add and move to EIndependentVowel
sl@0
   120
	//EGurBearerA + modifier: add and close syllable
sl@0
   121
	//EGurBearerA + anything else: close syllable
sl@0
   122
	EGurBearerA = 23,
sl@0
   123
	//EGurBearerU + EIndicCodeGurDependentVowelU: add and move to EIndependentVowel
sl@0
   124
	//EGurBearerU + anything else: close syllable
sl@0
   125
	EGurBearerU = 24,
sl@0
   126
	//EGurBearerI + EIndicCodeGurDependentVowelI: add and move to EIndependentVowel
sl@0
   127
	//EGurBearerI + anything else: close syllable	
sl@0
   128
	EGurBearerI = 25,
sl@0
   129
	
sl@0
   130
	EConsonantMalaChillu = 26,
sl@0
   131
	EConsonantMalaChillu2 = 27,
sl@0
   132
	EConsonantMalaChillu3 = 28,
sl@0
   133
	EViramaMalaChillu = 29,
sl@0
   134
	EViramaMalaChillu2 = 30,
sl@0
   135
	EViramaMalaChillu3 = 31,
sl@0
   136
	EConsonantMalaChilluNA = 32,
sl@0
   137
	EConsonantMalaChilluNA2 = 33,
sl@0
   138
	EConsonantMalaChilluNA3 = 34,
sl@0
   139
	EViramaMalaChilluNA = 35,
sl@0
   140
	EViramaMalaChilluNA2 = 36,
sl@0
   141
	EViramaMalaChilluNA3 = 37,
sl@0
   142
	EZeroWidthJoinerMalaChilluNA = 38,
sl@0
   143
	EZeroWidthJoinerMalaChilluNA2 = 39,
sl@0
   144
	EZeroWidthJoinerMalaChilluNA3 = 40,
sl@0
   145
	// Add and close acceptances go here.
sl@0
   146
	EAccept = 41
sl@0
   147
	};
sl@0
   148
sl@0
   149
/** Defines the transitions for a state machine for determining syllable
sl@0
   150
boundaries. The machine starts in state 0. On receiving a character of type t
sl@0
   151
while in state s, moves to state KStateResponse[s][t]. */
sl@0
   152
const TSyllableState KStateResponse[42][24] =
sl@0
   153
	{
sl@0
   154
	// EBegin -- nothing added yet
sl@0
   155
	{EAccept, EAccept, EIndependentVowel, EConsonant, EAccept, EAccept, EAccept, EAccept, ENuktaConsonant, EIndependentVowelA, EAccept, EKannadaRa, EAccept, EAccept, EAccept, EGurBearerA, EGurBearerU, EGurBearerI, EAccept, EAccept, EAccept, EConsonantMalaChillu,EConsonantMalaChilluNA,EConsonant},
sl@0
   156
	// EConsonant -- seen a consonant either at the start or after virama
sl@0
   157
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama, ENuktaConsonant, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   158
	// EConsonant2 -- seen a consonant after virama
sl@0
   159
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama2, ENuktaConsonant2, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   160
	// EConsonant3 -- seen a consonant after virama2 
sl@0
   161
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama3, ENuktaConsonant3, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   162
	// EConsonant4 -- seen a consonant after virama3
sl@0
   163
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama4, ENuktaConsonant4, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   164
	// EIndependentVowel -- possibly nasalized. I haven't bothered to distinguish between
sl@0
   165
	// nasalization and visarga.
sl@0
   166
	{EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantVowel, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   167
	// EVirama -- just seen a virama in a legal context. Must be consonant or ZWJ next
sl@0
   168
	{EReject, EReject, EReject, EConsonant2, EReject, EReject, EReject, EZeroWidthJoinerV, ENuktaConsonant2, EReject, EReject, EConsonant2, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantMalaChillu2,EConsonantMalaChilluNA2,EConsonant2},
sl@0
   169
	// EVirama2 -- just seen a virama in a legal context. Must be consonant2
sl@0
   170
	{EReject, EReject, EReject, EConsonant3, EReject, EReject, EReject, EZeroWidthJoinerV2, ENuktaConsonant3, EReject, EReject, EConsonant3, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantMalaChillu3,EConsonantMalaChilluNA3,EConsonant3},
sl@0
   171
	// EVirama3 -- just seen a virama in a legal context. Must be consonant3
sl@0
   172
	{EReject, EReject, EReject, EConsonant4, EReject, EReject, EReject, EZeroWidthJoinerV3, ENuktaConsonant4, EReject, EReject, EConsonant4, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonant4,EConsonant4,EConsonant4},
sl@0
   173
	// EVirama4 -- just seen a virama in a legal context. Must be consonant4
sl@0
   174
	{EReject, EReject, EReject, EReject, EReject, EReject, EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   175
	// EConsonantVowel -- Just seen a consonant with matra. Can only nasalize or visarg
sl@0
   176
	{EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   177
	// ENuktaConsonant -- Just seen a consonant with Nukta. Can only accept a dependant vowel or a Virama at this stage.
sl@0
   178
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama, EReject, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   179
	// ENuktaConsonant2 -- Just seen a consonant with Nukta after a virama.
sl@0
   180
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama2, EReject, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   181
	// ENuktaConsonant3 -- Just seen a consonant with Nukta after Virama2.
sl@0
   182
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama3, EReject, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   183
	// ENuktaConsonant4 -- Just seen a consonant with Nukta after Virama3.
sl@0
   184
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama4, EReject, EReject, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   185
	// EIndependentVowelA -- Special case Devanagari independent vowel
sl@0
   186
	{EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EZeroWidthJoinerA, EReject, EReject, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   187
	// EZeroWidthJoinerC -- Just seen a ZWJ after a consonant
sl@0
   188
	{EReject, EReject, EReject, EReject, EReject, EVirama, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   189
	// EZeroWidthJoinerA -- Just seen a ZWJ after the dependent Vowel A
sl@0
   190
	{EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   191
	// EZeroWidthJoinerV -- Just seen the ZWJ after the first pair of consonant + virama
sl@0
   192
	{EReject, EAccept, EReject, EConsonant2, EReject, EReject, EReject, EReject, ENuktaConsonant2, EReject, EReject, EConsonant2, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantMalaChillu2,EConsonantMalaChilluNA2,EConsonant2},
sl@0
   193
	// EZeroWidthJoinerV2 -- Just seen the ZWJ after consonant + virama + consonant + virama
sl@0
   194
	{EReject, EAccept, EReject, EConsonant3, EReject, EReject, EReject, EReject, ENuktaConsonant3, EReject, EReject, EConsonant3, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantMalaChillu3,EConsonantMalaChilluNA3,EConsonant3},
sl@0
   195
	// EZeroWidthJoinerV3 -- Just seen the ZWJ after consonant + virama + consonant + virama + consonant + virama
sl@0
   196
	{EReject, EAccept, EReject, EConsonant4, EReject, EReject, EReject, EReject, ENuktaConsonant4, EReject, EReject, EConsonant4, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonant4,EConsonant4,EConsonant4},
sl@0
   197
	// EKannadaRa -- Special case consonant
sl@0
   198
	{EReject, EAccept, EReject, EReject, EConsonantVowel, EVirama, ENuktaConsonant, EZeroWidthJoinerC, EReject, EReject, EConsonantVowel, EReject, ESplitVowel1, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EConsonantVowel, EReject,EReject,EReject},
sl@0
   199
	// ESplitVowel1 -- Just seen a consonant with first part of a split vowel. Can only nasalize, visarg or add second part of splt vowel
sl@0
   200
	{EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EConsonantVowel, EConsonantVowel, EReject, EReject, EReject, EReject, EReject, EReject, EReject,EReject,EReject},
sl@0
   201
	// EGurBearerA -- Just seen a dependent Vowel EIndicCodeGurDependentVowelA and modifier
sl@0
   202
	{EReject, EAccept, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EIndependentVowel, EReject, EReject, EReject,EReject,EReject},
sl@0
   203
	// EGurBearerU -- Just seen a dependent Vowel EIndicCodeGurDependentVowelU
sl@0
   204
	{EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EIndependentVowel, EReject, EReject,EReject,EReject},
sl@0
   205
	// EGurBearerI -- Just seen a dependent Vowel EIndicCodeGurDependentVowelI
sl@0
   206
	{EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EIndependentVowel, EReject,EReject,EReject},
sl@0
   207
	
sl@0
   208
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChillu,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   209
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChillu2,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   210
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChillu3,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   211
	{EReject,EReject,EReject,EConsonant2,EReject,EReject,EReject,EAccept,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonantMalaChillu2,EConsonantMalaChilluNA2,EConsonant2},
sl@0
   212
	{EReject,EReject,EReject,EConsonant3,EReject,EReject,EReject,EAccept,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonantMalaChillu3,EConsonantMalaChilluNA3,EConsonant3},
sl@0
   213
	{EReject,EReject,EReject,EConsonant4,EReject,EReject,EReject,EAccept,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonant4,EConsonant4,EConsonant4},
sl@0
   214
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChilluNA,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   215
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChilluNA2,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   216
	{EReject,EAccept,EReject,EReject,EConsonantVowel,EViramaMalaChilluNA3,EReject,EReject,EReject,EReject,EReject,EReject,ESplitVowel1,EConsonantVowel,EConsonantVowel,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject},
sl@0
   217
	{EReject,EReject,EReject,EConsonant2,EReject,EReject,EReject,EZeroWidthJoinerMalaChilluNA,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonantMalaChillu2,EConsonantMalaChilluNA2,EConsonant2},
sl@0
   218
	{EReject,EReject,EReject,EConsonant3,EReject,EReject,EReject,EZeroWidthJoinerMalaChilluNA2,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonantMalaChillu3,EConsonantMalaChilluNA3,EConsonant3},
sl@0
   219
	{EReject,EReject,EReject,EConsonant4,EReject,EReject,EReject,EZeroWidthJoinerMalaChilluNA3,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonant4,EConsonant4,EConsonant4},
sl@0
   220
	{EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonant2},
sl@0
   221
	{EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonant3},
sl@0
   222
	{EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EReject,EConsonant4},
sl@0
   223
	
sl@0
   224
	// EAccept -- this one is added but anything further is rejected
sl@0
   225
	{EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject, EReject}
sl@0
   226
	};
sl@0
   227
sl@0
   228
TIndicCodeType CodeType(TInt aCode, const TIndicCodeMapping aCodeMap[], TInt aMapLen)
sl@0
   229
	{
sl@0
   230
	TInt start = 0;
sl@0
   231
	TInt end = aMapLen - 1;
sl@0
   232
	while (start != end)
sl@0
   233
		{
sl@0
   234
		const TInt mid = (start + end + 1) >> 1;
sl@0
   235
		if (aCodeMap[mid].iFirstCodeInRange <= aCode)
sl@0
   236
			start = mid;
sl@0
   237
		else
sl@0
   238
			end = mid - 1;
sl@0
   239
		}
sl@0
   240
	return static_cast<TIndicCodeType>(aCodeMap[start].iCodeType);
sl@0
   241
	}
sl@0
   242
sl@0
   243
const TText16* SyllableEnd(const TText16* aCurrentPosition,
sl@0
   244
	const TText16* aEnd, const TIndicCodeMapping aCodeMap[], TInt aMapLen)
sl@0
   245
	{
sl@0
   246
	TSyllableState state = EBegin;
sl@0
   247
	while (aCurrentPosition != aEnd)
sl@0
   248
		{
sl@0
   249
		const TIndicCodeType ct = CodeType(*aCurrentPosition, aCodeMap, aMapLen);
sl@0
   250
		state = KStateResponse[state][ct];
sl@0
   251
		if (state == EReject)
sl@0
   252
			return aCurrentPosition;
sl@0
   253
		++aCurrentPosition;
sl@0
   254
		}
sl@0
   255
	return aCurrentPosition;
sl@0
   256
	}
sl@0
   257
sl@0
   258
/**
sl@0
   259
Common function for all Indic scripts. 
sl@0
   260
Performs the shaping operation on Indic script text up to KMaxTextToShape.
sl@0
   261
*/	
sl@0
   262
TInt IndicShapingProcess(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo, 
sl@0
   263
						const TIndicCodeMapping aCodeMap[], TInt aMapLen, const TUint aHighChar, 
sl@0
   264
						const TUint aLowChar, const TUint32 aScript, const TUint32 aLang)
sl@0
   265
	{
sl@0
   266
	const TText16* startCharacter = aGss.iParam.iText.Ptr();
sl@0
   267
	const TText16* endCharacter = startCharacter + aGss.iParam.iText.Length();
sl@0
   268
	const TText16* currentCharacter = aGss.iText.CurrentPosition();
sl@0
   269
	TInt currentPosition = currentCharacter - startCharacter;
sl@0
   270
sl@0
   271
	// Do some new shaping
sl@0
   272
	
sl@0
   273
	// First close the existing RShapeInfo
sl@0
   274
	if(aShapeInfo.IsOpen())
sl@0
   275
		aShapeInfo.Close();
sl@0
   276
	
sl@0
   277
	// Find the end of Indic text whilst limiting the amount of text to be shaped to 
sl@0
   278
	// KMaxTextToShape. When finding the end of end position of the text to be shaped,
sl@0
   279
	// include numerals, punctuations and other control characters.
sl@0
   280
	const TText16* endIndic = currentCharacter;
sl@0
   281
	TChar endIndicChar = *endIndic;
sl@0
   282
	while((endIndic <= endCharacter || endIndic - currentCharacter <= KMaxTextToShape) &&
sl@0
   283
		 ((*endIndic >= aLowChar && *endIndic <= aHighChar) || 
sl@0
   284
		 	((endIndicChar.IsDigit() || endIndicChar.IsPunctuation()) && !QuoteOrBracketPair(*endIndic))))
sl@0
   285
		{
sl@0
   286
		if (endIndic == endCharacter || endIndic - currentCharacter > KMaxTextToShape)
sl@0
   287
			break;
sl@0
   288
		endIndic = SyllableEnd(endIndic, endCharacter, aCodeMap, aMapLen);	
sl@0
   289
		endIndicChar = *endIndic;
sl@0
   290
		}
sl@0
   291
	
sl@0
   292
	TInt endPosForShaping = endIndic - startCharacter;
sl@0
   293
	
sl@0
   294
	//Now shape from current position to the end of Hindi
sl@0
   295
	return aShapeInfo.Open(aGss.iFont, aGss.iParam.iText,
sl@0
   296
						currentPosition, endPosForShaping, aScript, aLang);
sl@0
   297
	}
sl@0
   298
sl@0
   299
/**
sl@0
   300
Common function for all Indic scripts. Adds the shaped glyphs to the glyph cluster.
sl@0
   301
This function is called regardless of whether shaping was done or skipped in this 
sl@0
   302
iteration of the Default Process
sl@0
   303
*/
sl@0
   304
TBool IndicPostShapingProcess(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo, 
sl@0
   305
							TInt aCurrPos, TInt aSyllEndPos, const TText16* aSyllableEnd)
sl@0
   306
	{
sl@0
   307
	// Now get all the shaped values
sl@0
   308
	// Get the number of glyphs, glyphs, positions and indices after shaping.
sl@0
   309
	TInt numGlyphs = aShapeInfo.GlyphCount();
sl@0
   310
	const TInt32* glyph = aShapeInfo.Glyphs();
sl@0
   311
	const RShapeInfo::TPoint16* position = aShapeInfo.GlyphPositions();
sl@0
   312
	const TInt16* indices = aShapeInfo.Indices();
sl@0
   313
	TPoint origin;
sl@0
   314
	
sl@0
   315
	// Shift the indices and positions until the current poisition is reached. This done so that the 
sl@0
   316
	// origin can be set back to the original co-ordinates at the start of this Hindi text
sl@0
   317
	while (*indices < aCurrPos)
sl@0
   318
		{
sl@0
   319
		position++;
sl@0
   320
		indices++;
sl@0
   321
		}
sl@0
   322
	// Set the origin back by subtracting the current position co-ordinates from the current pen position	
sl@0
   323
	origin.iX = aGss.iParam.iPen.iX - position->iX;
sl@0
   324
	origin.iY = aGss.iParam.iPen.iY - position->iY;
sl@0
   325
	
sl@0
   326
	// No re-initialise the indices and positions to start appending the glyphs to clusters from the beginning
sl@0
   327
	indices = aShapeInfo.Indices();
sl@0
   328
	position = aShapeInfo.GlyphPositions();
sl@0
   329
	
sl@0
   330
	// Now do some post shaping syllable chopping
sl@0
   331
	for (TInt i = 0; i < numGlyphs; i++, glyph++, position++, indices++)
sl@0
   332
		{
sl@0
   333
		if(*indices >= aSyllEndPos)
sl@0
   334
			break;
sl@0
   335
		if(*indices >= aCurrPos && *indices < aSyllEndPos)
sl@0
   336
			{
sl@0
   337
			aGss.iParam.iPen.iX = origin.iX + position->iX;
sl@0
   338
			aGss.iParam.iPen.iY = origin.iY + position->iY;
sl@0
   339
			
sl@0
   340
			//Just skip the non-existing glyph and continue handling other glyphs if AppendGlyphToCluster return false.
sl@0
   341
			// The "continue" statement is for avoiding the potential risk of handling the non-existing glyph.
sl@0
   342
			if (!aGss.AppendGlyphToCluster(0x80000000UL | *glyph))
sl@0
   343
				continue;
sl@0
   344
			}
sl@0
   345
		}
sl@0
   346
	
sl@0
   347
	// We'll do pen advance ourselves, thanks.
sl@0
   348
	aGss.iPen = TGlyphSelectionState::EPenAdvance_No;
sl@0
   349
	aGss.iParam.iPen.iX = origin.iX + position->iX;
sl@0
   350
	aGss.iParam.iPen.iY = origin.iY + position->iY;
sl@0
   351
	aGss.iClusterState = TGlyphSelectionState::EGClusterComplete;
sl@0
   352
	aGss.iText.SetCurrentPosition(aSyllableEnd);
sl@0
   353
	return ETrue;
sl@0
   354
	}
sl@0
   355
sl@0
   356
/**
sl@0
   357
Common function for all Indic scripts.
sl@0
   358
Performs shaping and Rasterizing operation on Indic script text 
sl@0
   359
*/
sl@0
   360
TBool DoProcess(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo, const TIndicScriptProcessorParameters& aScriptSpecificParameters){
sl@0
   361
	const TText16* startCharacter = aGss.iParam.iText.Ptr();
sl@0
   362
	const TText16* endCharacter = startCharacter + aGss.iParam.iText.Length();
sl@0
   363
	const TText16* currentCharacter = aGss.iText.CurrentPosition();
sl@0
   364
	TInt currentPosition = currentCharacter - startCharacter;
sl@0
   365
		
sl@0
   366
	// Get the logical end of the syllable from the input text. We will use this later to chop
sl@0
   367
	// syllables from the glyph values we get.
sl@0
   368
	const TText16* syllableEnd = SyllableEnd(currentCharacter, endCharacter, aScriptSpecificParameters.iCodeMap,
sl@0
   369
			aScriptSpecificParameters.iMapLen);
sl@0
   370
	TInt syllableEndPos = syllableEnd - startCharacter;
sl@0
   371
			
sl@0
   372
	TInt ret = KErrNone;
sl@0
   373
	if(currentPosition >= aShapeInfo.EndOfShapedText())	
sl@0
   374
		ret = IndicShapingProcess(aGss, aShapeInfo, aScriptSpecificParameters.iCodeMap, aScriptSpecificParameters.iMapLen, 
sl@0
   375
				aScriptSpecificParameters.iUCHigh, aScriptSpecificParameters.iUCLow, aScriptSpecificParameters.iScriptCode, aScriptSpecificParameters.iLanguageCode);
sl@0
   376
		
sl@0
   377
	// If an RShapeInfo could not be opened, call the default process
sl@0
   378
	if (ret != KErrNone)
sl@0
   379
		return GlyphSelector_Default::Process(aGss, aShapeInfo);	
sl@0
   380
	
sl@0
   381
	// Now call the post shaping process to add glyphs to the glyph cluster
sl@0
   382
	return IndicPostShapingProcess(aGss, aShapeInfo, currentPosition, syllableEndPos, syllableEnd);
sl@0
   383
}
sl@0
   384
sl@0
   385
/*************************************************** D E V A N A G A R I ***************************************************/
sl@0
   386
TBool GlyphSelector_Devanagari::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   387
	{
sl@0
   388
	return DoProcess(aGss, aShapeInfo, KIndicDevParameters);
sl@0
   389
	}
sl@0
   390
	
sl@0
   391
/***************************************************** K A N N A D A ******************************************************/
sl@0
   392
TBool GlyphSelector_Kannada::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   393
	{
sl@0
   394
	return DoProcess(aGss, aShapeInfo, KIndicKanParameters);
sl@0
   395
	}
sl@0
   396
sl@0
   397
/***************************************************** G U J A R A T I ******************************************************/
sl@0
   398
TBool GlyphSelector_Gujarati::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   399
	{
sl@0
   400
	return DoProcess(aGss, aShapeInfo, KIndicGujParameters);
sl@0
   401
	}
sl@0
   402
sl@0
   403
/***************************************************** B E N G A L I ******************************************************/
sl@0
   404
TBool GlyphSelector_Bengali::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   405
	{
sl@0
   406
	return DoProcess(aGss, aShapeInfo, KIndicBenParameters);
sl@0
   407
	}
sl@0
   408
sl@0
   409
/***************************************************** T A M I L ******************************************************/
sl@0
   410
TBool GlyphSelector_Tamil::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   411
	{
sl@0
   412
	return DoProcess(aGss, aShapeInfo, KIndicTamParameters);
sl@0
   413
	}
sl@0
   414
sl@0
   415
/***************************************************** T E L U G U ******************************************************/
sl@0
   416
TBool GlyphSelector_Telugu::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   417
	{
sl@0
   418
	return DoProcess(aGss, aShapeInfo, KIndicTelParameters);
sl@0
   419
	}
sl@0
   420
sl@0
   421
/***************************************************** G U R M U K H I ******************************************************/
sl@0
   422
TBool GlyphSelector_Gurmukhi::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)\
sl@0
   423
	{
sl@0
   424
	return DoProcess(aGss, aShapeInfo, KIndicGurParameters);
sl@0
   425
	}
sl@0
   426
sl@0
   427
/***************************************************** M A L A Y A L A M ******************************************************/
sl@0
   428
TBool GlyphSelector_Malayalam::Process(TGlyphSelectionState& aGss, RShapeInfo& aShapeInfo)
sl@0
   429
	{
sl@0
   430
	return DoProcess(aGss, aShapeInfo, KIndicMalParameters);
sl@0
   431
	}
sl@0
   432