]>
git.saurik.com Git - apple/icu.git/blob - icuSources/layout/MPreFixups.cpp
3 * (C) Copyright IBM Corp. 2002-2004 - All Rights Reserved
8 #include "LEGlyphStorage.h"
9 #include "MPreFixups.h"
19 MPreFixups::MPreFixups(le_int32 charCount
)
20 : fFixupData(NULL
), fFixupCount(0)
22 fFixupData
= LE_NEW_ARRAY(FixupData
, charCount
);
25 MPreFixups::~MPreFixups()
27 LE_DELETE_ARRAY(fFixupData
);
31 void MPreFixups::add(le_int32 baseIndex
, le_int32 mpreIndex
)
33 // NOTE: don't add the fixup data if the mpre is right
34 // before the base consonant glyph.
35 if (baseIndex
- mpreIndex
> 1) {
36 fFixupData
[fFixupCount
].fBaseIndex
= baseIndex
;
37 fFixupData
[fFixupCount
].fMPreIndex
= mpreIndex
;
43 void MPreFixups::apply(LEGlyphStorage
&glyphStorage
)
45 for (le_int32 fixup
= 0; fixup
< fFixupCount
; fixup
+= 1) {
46 le_int32 baseIndex
= fFixupData
[fixup
].fBaseIndex
;
47 le_int32 mpreIndex
= fFixupData
[fixup
].fMPreIndex
;
48 le_int32 mpreLimit
= mpreIndex
+ 1;
50 while (glyphStorage
[baseIndex
] == 0xFFFF || glyphStorage
[baseIndex
] == 0xFFFE) {
54 while (glyphStorage
[mpreLimit
] == 0xFFFF || glyphStorage
[mpreLimit
] == 0xFFFE) {
58 if (mpreLimit
== baseIndex
) {
62 LEErrorCode success
= LE_NO_ERROR
;
63 le_int32 mpreCount
= mpreLimit
- mpreIndex
;
64 le_int32 moveCount
= baseIndex
- mpreLimit
;
65 le_int32 mpreDest
= baseIndex
- mpreCount
;
66 LEGlyphID
*mpreSave
= LE_NEW_ARRAY(LEGlyphID
, mpreCount
);
67 le_int32
*indexSave
= LE_NEW_ARRAY(le_int32
, mpreCount
);
70 for (i
= 0; i
< mpreCount
; i
+= 1) {
71 mpreSave
[i
] = glyphStorage
[mpreIndex
+ i
];
72 indexSave
[i
] = glyphStorage
.getCharIndex(mpreIndex
+ i
, success
); //charIndices[mpreIndex + i];
75 for (i
= 0; i
< moveCount
; i
+= 1) {
76 LEGlyphID glyph
= glyphStorage
[mpreLimit
+ i
];
77 le_int32 charIndex
= glyphStorage
.getCharIndex(mpreLimit
+ i
, success
);
79 glyphStorage
[mpreIndex
+ i
] = glyph
;
80 glyphStorage
.setCharIndex(mpreIndex
+ i
, charIndex
, success
);
83 for (i
= 0; i
< mpreCount
; i
+= 1) {
84 glyphStorage
[mpreDest
+ i
] = mpreSave
[i
];
85 glyphStorage
.setCharIndex(mpreDest
, indexSave
[i
], success
);
88 LE_DELETE_ARRAY(indexSave
);
89 LE_DELETE_ARRAY(mpreSave
);