author | prr |
Wed, 29 Jul 2015 11:04:39 -0700 | |
changeset 33299 | 78f5508cde89 |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 |
* |
|
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 6 |
* published by the Free Software Foundation. Oracle designates this |
2 | 7 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 8 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 9 |
* |
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
5506 | 20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
2 | 23 |
* |
24 |
*/ |
|
25 |
||
26 |
||
27 |
/* |
|
28 |
* |
|
7486 | 29 |
* (C) Copyright IBM Corp. 1998-2009 - All Rights Reserved |
2 | 30 |
* |
31 |
*/ |
|
32 |
||
33 |
#include "LETypes.h" |
|
34 |
#include "LayoutEngine.h" |
|
35 |
#include "OpenTypeLayoutEngine.h" |
|
36 |
#include "IndicLayoutEngine.h" |
|
37 |
#include "ScriptAndLanguageTags.h" |
|
38 |
||
39 |
#include "GlyphSubstitutionTables.h" |
|
40 |
#include "GlyphDefinitionTables.h" |
|
41 |
#include "GlyphPositioningTables.h" |
|
42 |
||
43 |
#include "GDEFMarkFilter.h" |
|
44 |
#include "LEGlyphStorage.h" |
|
45 |
||
46 |
#include "IndicReordering.h" |
|
22330 | 47 |
|
3935 | 48 |
U_NAMESPACE_BEGIN |
49 |
||
50 |
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IndicOpenTypeLayoutEngine) |
|
51 |
||
52 |
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, |
|
16891 | 53 |
le_int32 typoFlags, le_bool version2, const LEReferenceTo<GlyphSubstitutionTableHeader> &gsubTable, LEErrorCode &success) |
7486 | 54 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, gsubTable, success), fMPreFixups(NULL) |
55 |
{ |
|
22330 | 56 |
if ( version2 ) { |
57 |
fFeatureMap = IndicReordering::getv2FeatureMap(fFeatureMapCount); |
|
58 |
} else { |
|
7486 | 59 |
fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount); |
22330 | 60 |
} |
61 |
fFeatureOrder = TRUE; |
|
62 |
fVersion2 = version2; |
|
63 |
fFilterZeroWidth = IndicReordering::getFilterZeroWidth(fScriptCode); |
|
7486 | 64 |
} |
65 |
||
66 |
IndicOpenTypeLayoutEngine::IndicOpenTypeLayoutEngine(const LEFontInstance *fontInstance, le_int32 scriptCode, le_int32 languageCode, le_int32 typoFlags, LEErrorCode &success) |
|
67 |
: OpenTypeLayoutEngine(fontInstance, scriptCode, languageCode, typoFlags, success), fMPreFixups(NULL) |
|
2 | 68 |
{ |
69 |
fFeatureMap = IndicReordering::getFeatureMap(fFeatureMapCount); |
|
70 |
fFeatureOrder = TRUE; |
|
22330 | 71 |
fVersion2 = FALSE; |
2 | 72 |
} |
73 |
||
74 |
IndicOpenTypeLayoutEngine::~IndicOpenTypeLayoutEngine() |
|
75 |
{ |
|
76 |
// nothing to do |
|
77 |
} |
|
78 |
||
79 |
// Input: characters, tags |
|
80 |
// Output: glyphs, char indices |
|
3935 | 81 |
le_int32 IndicOpenTypeLayoutEngine::glyphProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, |
82 |
LEGlyphStorage &glyphStorage, LEErrorCode &success) |
|
2 | 83 |
{ |
84 |
if (LE_FAILURE(success)) { |
|
85 |
return 0; |
|
86 |
} |
|
87 |
||
88 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { |
|
89 |
success = LE_ILLEGAL_ARGUMENT_ERROR; |
|
90 |
return 0; |
|
91 |
} |
|
92 |
||
22330 | 93 |
_LETRACE("IOTLE::gp, calling parent"); |
3935 | 94 |
le_int32 retCount = OpenTypeLayoutEngine::glyphProcessing(chars, offset, count, max, rightToLeft, glyphStorage, success); |
2 | 95 |
|
96 |
if (LE_FAILURE(success)) { |
|
97 |
return 0; |
|
98 |
} |
|
99 |
||
7486 | 100 |
if (fVersion2) { |
22330 | 101 |
_LETRACE("IOTLE::gp, v2 final,"); |
102 |
IndicReordering::finalReordering(glyphStorage,retCount); |
|
103 |
_LETRACE("IOTLE::gp, v2 pres"); |
|
104 |
IndicReordering::applyPresentationForms(glyphStorage,retCount); |
|
105 |
_LETRACE("IOTLE::gp, parent gsub"); |
|
106 |
OpenTypeLayoutEngine::glyphSubstitution(count,max, rightToLeft, glyphStorage, success); |
|
7486 | 107 |
} else { |
22330 | 108 |
_LETRACE("IOTLE::gp, adjust mpres"); |
109 |
IndicReordering::adjustMPres(fMPreFixups, glyphStorage, success); |
|
7486 | 110 |
} |
2 | 111 |
return retCount; |
112 |
} |
|
113 |
||
114 |
// Input: characters |
|
115 |
// Output: characters, char indices, tags |
|
116 |
// Returns: output character count |
|
3935 | 117 |
le_int32 IndicOpenTypeLayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 offset, le_int32 count, le_int32 max, le_bool rightToLeft, |
118 |
LEUnicode *&outChars, LEGlyphStorage &glyphStorage, LEErrorCode &success) |
|
2 | 119 |
{ |
120 |
if (LE_FAILURE(success)) { |
|
121 |
return 0; |
|
122 |
} |
|
123 |
||
22330 | 124 |
_LETRACE("IOTLE: charProc"); |
125 |
||
2 | 126 |
if (chars == NULL || offset < 0 || count < 0 || max < 0 || offset >= max || offset + count > max) { |
127 |
success = LE_ILLEGAL_ARGUMENT_ERROR; |
|
128 |
return 0; |
|
129 |
} |
|
130 |
||
131 |
le_int32 worstCase = count * IndicReordering::getWorstCaseExpansion(fScriptCode); |
|
132 |
||
133 |
outChars = LE_NEW_ARRAY(LEUnicode, worstCase); |
|
134 |
||
135 |
if (outChars == NULL) { |
|
136 |
success = LE_MEMORY_ALLOCATION_ERROR; |
|
137 |
return 0; |
|
138 |
} |
|
139 |
||
140 |
glyphStorage.allocateGlyphArray(worstCase, rightToLeft, success); |
|
141 |
glyphStorage.allocateAuxData(success); |
|
142 |
||
143 |
if (LE_FAILURE(success)) { |
|
144 |
LE_DELETE_ARRAY(outChars); |
|
145 |
return 0; |
|
146 |
} |
|
147 |
||
148 |
// NOTE: assumes this allocates featureTags... |
|
149 |
// (probably better than doing the worst case stuff here...) |
|
7486 | 150 |
|
151 |
le_int32 outCharCount; |
|
152 |
if (fVersion2) { |
|
22330 | 153 |
_LETRACE("v2process"); |
25101
2b07b28079a1
8042855: [parfait] Potential null pointer dereference in IndicLayoutEngine.cpp
prr
parents:
22330
diff
changeset
|
154 |
outCharCount = IndicReordering::v2process(&chars[offset], count, fScriptCode, outChars, glyphStorage, success); |
7486 | 155 |
} else { |
22330 | 156 |
_LETRACE("reorder"); |
7486 | 157 |
outCharCount = IndicReordering::reorder(&chars[offset], count, fScriptCode, outChars, glyphStorage, &fMPreFixups, success); |
158 |
} |
|
159 |
||
160 |
if (LE_FAILURE(success)) { |
|
161 |
LE_DELETE_ARRAY(outChars); |
|
162 |
return 0; |
|
163 |
} |
|
3935 | 164 |
|
2 | 165 |
glyphStorage.adoptGlyphCount(outCharCount); |
166 |
return outCharCount; |
|
167 |
} |
|
3935 | 168 |
|
169 |
U_NAMESPACE_END |