@@ -19,22 +19,6 @@ class FontRenderer(
1919 private val vao = VAO (VertexMode .TRIANGLES , VertexAttrib .Group .FONT )
2020
2121 private val scaleMultiplier = 1.0
22- private val emojiRegex = Regex (" :[a-zA-Z0-9_]+:" )
23-
24- /* *
25- * Parses the emojis in the given text.
26- *
27- * @param text The text to parse.
28- * @return A list of pairs containing the glyph info and the range of the emoji in the text.
29- */
30- fun parseEmojis (text : String ) =
31- mutableListOf<Pair <GlyphInfo , IntRange >>().apply {
32- emojiRegex.findAll(text).forEach { match ->
33- val emojiKey = match.value.substring(1 , match.value.length - 1 )
34- val charInfo = emojis[emojiKey] ? : return @forEach
35- add(charInfo to match.range)
36- }
37- }
3822
3923 /* *
4024 * Builds the vertex array for rendering the text.
@@ -101,7 +85,7 @@ class FontRenderer(
10185 var posX = 0.0
10286 val posY = getHeight(scale) * - 0.5 + baselineOffset * actualScale
10387
104- val emojis = parseEmojis(text)
88+ val emojis = parseEmojis(text, emojis )
10589
10690 fun draw (info : GlyphInfo , color : Color , offset : Double = 0.0) {
10791 val scaledSize = info.size * actualScale
@@ -170,8 +154,25 @@ class FontRenderer(
170154 companion object {
171155 private val shader = Shader (" renderer/font" )
172156
173- private val shadowShift get() = RenderSettings .shadowShift * 5.0
174- private val baselineOffset get() = RenderSettings .baselineOffset * 2.0f - 10f
175- private val gap get() = RenderSettings .gap * 0.5f - 0.8f
157+ val shadowShift get() = RenderSettings .shadowShift * 5.0
158+ val baselineOffset get() = RenderSettings .baselineOffset * 2.0f - 10f
159+ val gap get() = RenderSettings .gap * 0.5f - 0.8f
160+
161+ private val emojiRegex = Regex (" :[a-zA-Z0-9_]+:" )
162+
163+ /* *
164+ * Parses the emojis in the given text.
165+ *
166+ * @param text The text to parse.
167+ * @return A list of pairs containing the glyph info and the range of the emoji in the text.
168+ */
169+ fun parseEmojis (text : String , emojis : LambdaEmoji ) =
170+ mutableListOf<Pair <GlyphInfo , IntRange >>().apply {
171+ emojiRegex.findAll(text).forEach { match ->
172+ val emojiKey = match.value.substring(1 , match.value.length - 1 )
173+ val charInfo = emojis[emojiKey] ? : return @forEach
174+ add(charInfo to match.range)
175+ }
176+ }
176177 }
177178}
0 commit comments