Skip to content

Commit 122f563

Browse files
committed
[lib] Added helper methods related to clusters in intrinsic run
1 parent 1b3b447 commit 122f563

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

tehreer-android/src/main/java/com/mta/tehreer/internal/layout/IntrinsicRun.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.mta.tehreer.internal.layout;
1818

1919
import com.mta.tehreer.graphics.Typeface;
20+
import com.mta.tehreer.internal.util.Clusters;
2021
import com.mta.tehreer.sfnt.WritingDirection;
2122

2223
public class IntrinsicRun {
@@ -108,28 +109,17 @@ public int glyphCount() {
108109
return glyphIds.length;
109110
}
110111

111-
public int charGlyphStart(int charIndex) {
112-
return clusterMap[charIndex - charStart];
112+
public void loadGlyphRange(int startIndex, int endIndex, int[] glyphRange) {
113+
Clusters.loadGlyphRange(clusterMap, startIndex - charStart, endIndex - charStart,
114+
isBackward, glyphIds.length, glyphRange);
113115
}
114116

115-
public int charGlyphEnd(int charIndex) {
116-
int glyphEnd;
117-
118-
if (!isBackward) {
119-
int charNext = charIndex + 1;
120-
121-
glyphEnd = (charNext < charEnd
122-
? clusterMap[charNext - charStart]
123-
: glyphCount());
124-
} else {
125-
int charPrevious = charIndex - 1;
126-
127-
glyphEnd = (charPrevious > charStart
128-
? clusterMap[charPrevious - charStart]
129-
: glyphCount());
130-
}
117+
public int clusterStart(int charIndex) {
118+
return Clusters.actualClusterStart(clusterMap, charIndex - charStart) + charStart;
119+
}
131120

132-
return glyphEnd;
121+
public int clusterEnd(int charIndex) {
122+
return Clusters.actualClusterEnd(clusterMap, charIndex - charStart) + charStart;
133123
}
134124

135125
public float measureGlyphs(int glyphStart, int glyphEnd) {

0 commit comments

Comments
 (0)