author | kvn |
Tue, 28 Jan 2014 14:57:41 -0800 | |
changeset 22607 | ba232b417248 |
parent 22330 | cafb826672bd |
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 |
* |
|
7486 | 28 |
* (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved |
2 | 29 |
* |
30 |
*/ |
|
31 |
||
32 |
#include "LETypes.h" |
|
33 |
#include "LEGlyphFilter.h" |
|
34 |
#include "OpenTypeTables.h" |
|
35 |
#include "GlyphSubstitutionTables.h" |
|
36 |
#include "MultipleSubstSubtables.h" |
|
37 |
#include "GlyphIterator.h" |
|
38 |
#include "LESwaps.h" |
|
39 |
||
3935 | 40 |
U_NAMESPACE_BEGIN |
41 |
||
16891 | 42 |
le_uint32 MultipleSubstitutionSubtable::process(const LETableReference &base, GlyphIterator *glyphIterator, LEErrorCode& success, const LEGlyphFilter *filter) const |
2 | 43 |
{ |
7486 | 44 |
if (LE_FAILURE(success)) { |
45 |
return 0; |
|
46 |
} |
|
47 |
||
2 | 48 |
LEGlyphID glyph = glyphIterator->getCurrGlyphID(); |
49 |
||
50 |
// If there's a filter, we only want to do the |
|
51 |
// substitution if the *input* glyphs doesn't |
|
52 |
// exist. |
|
53 |
// |
|
54 |
// FIXME: is this always the right thing to do? |
|
55 |
// FIXME: should this only be done for a non-zero |
|
56 |
// glyphCount? |
|
22330 | 57 |
if (filter != NULL && filter->accept(glyph, success)) { |
2 | 58 |
return 0; |
59 |
} |
|
22330 | 60 |
if(LE_FAILURE(success)) return 0; |
2 | 61 |
|
16891 | 62 |
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success); |
2 | 63 |
le_uint16 seqCount = SWAPW(sequenceCount); |
64 |
||
18256
79d3f8278a38
8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
prr
parents:
16891
diff
changeset
|
65 |
if (LE_FAILURE(success)) { |
79d3f8278a38
8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
prr
parents:
16891
diff
changeset
|
66 |
return 0; |
79d3f8278a38
8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
prr
parents:
16891
diff
changeset
|
67 |
} |
79d3f8278a38
8012617: ArrayIndexOutOfBoundsException with some fonts using LineBreakMeasurer
prr
parents:
16891
diff
changeset
|
68 |
|
2 | 69 |
if (coverageIndex >= 0 && coverageIndex < seqCount) { |
70 |
Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]); |
|
22330 | 71 |
LEReferenceTo<SequenceTable> sequenceTable(base, success, sequenceTableOffset); |
2 | 72 |
le_uint16 glyphCount = SWAPW(sequenceTable->glyphCount); |
73 |
||
74 |
if (glyphCount == 0) { |
|
75 |
glyphIterator->setCurrGlyphID(0xFFFF); |
|
76 |
return 1; |
|
77 |
} else if (glyphCount == 1) { |
|
78 |
TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[0]); |
|
79 |
||
22330 | 80 |
if (filter != NULL && ! filter->accept(LE_SET_GLYPH(glyph, substitute), success)) { |
2 | 81 |
return 0; |
82 |
} |
|
83 |
||
84 |
glyphIterator->setCurrGlyphID(substitute); |
|
85 |
return 1; |
|
86 |
} else { |
|
87 |
// If there's a filter, make sure all of the output glyphs |
|
88 |
// exist. |
|
89 |
if (filter != NULL) { |
|
90 |
for (le_int32 i = 0; i < glyphCount; i += 1) { |
|
91 |
TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[i]); |
|
92 |
||
22330 | 93 |
if (! filter->accept(substitute, success)) { |
2 | 94 |
return 0; |
95 |
} |
|
96 |
} |
|
97 |
} |
|
98 |
||
7486 | 99 |
LEGlyphID *newGlyphs = glyphIterator->insertGlyphs(glyphCount, success); |
100 |
if (LE_FAILURE(success)) { |
|
101 |
return 0; |
|
102 |
} |
|
103 |
||
2 | 104 |
le_int32 insert = 0, direction = 1; |
105 |
||
106 |
if (glyphIterator->isRightToLeft()) { |
|
107 |
insert = glyphCount - 1; |
|
108 |
direction = -1; |
|
109 |
} |
|
110 |
||
111 |
for (le_int32 i = 0; i < glyphCount; i += 1) { |
|
112 |
TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[i]); |
|
113 |
||
114 |
newGlyphs[insert] = LE_SET_GLYPH(glyph, substitute); |
|
115 |
insert += direction; |
|
116 |
} |
|
117 |
||
118 |
return 1; |
|
119 |
} |
|
120 |
} |
|
121 |
||
122 |
return 0; |
|
123 |
} |
|
3935 | 124 |
|
125 |
U_NAMESPACE_END |