}
}
- private fun TTFFile.getGlyphs(str: String): GlyphSequence {
- val length = str.codePointCount(0, str.length)
- val codeSeq = str.toCodePointSequence()
- val glyphSeq = codeSeq.map { getGlyph(it) }
-
- val codes = codeSeq.iterator().let { iter ->
- IntArray(length) {
- assert(iter.hasNext())
- iter.next()
- }
- }
+ private fun String.toCodePointArray(): IntArray {
+ val iter = toCodePointSequence().iterator()
- val glyphs = glyphSeq.iterator().let { iter ->
- IntArray(length) {
- assert(iter.hasNext())
- iter.next()
- }
+ return IntArray(codePointCount(0, length)) { _ ->
+ assert(iter.hasNext())
+ iter.next()
}
+ }
+
+ private fun TTFFile.getGlyphs(str: String): GlyphSequence {
+ val codes = str.toCodePointArray()
+ val glyphs = IntArray(codes.size) { i -> getGlyph(codes[i]) }
return GlyphSequence(IntBuffer.wrap(codes), IntBuffer.wrap(glyphs), null)
}