@@ -119,7 +119,7 @@ class FontAtlas {
119119 }
120120
121121 fun addFontFromMemoryTTF (fontData : CharArray , sizePixels : Float , fontCfg : FontConfig = FontConfig (), glyphRanges : Array <IntRange > = emptyArray()): Font =
122- addFontFromMemoryTTF(ByteArray (fontData.size) { fontData[it].b }, sizePixels, fontCfg, glyphRanges)
122+ addFontFromMemoryTTF(ByteArray (fontData.size) { fontData[it].b }, sizePixels, fontCfg, glyphRanges)
123123
124124 /* * @param compressedFontData still owned by caller. Compress with binary_to_compressed_c.cpp. */
125125 fun addFontFromMemoryCompressedTTF (compressedFontData : CharArray , sizePixels : Float , fontCfg : FontConfig = FontConfig (), glyphRanges : Array <IntRange > = emptyArray()): Font {
@@ -205,10 +205,10 @@ class FontAtlas {
205205 // using a hot-reloading scheme that messes up static data, store your own instance of ImFontBuilderIO somewhere
206206 // and point to it instead of pointing directly to return value of the GetBuilderXXX functions.
207207 val builderIo = fontBuilderIO ? :
208- // #ifdef IMGUI_ENABLE_FREETYPE
209- // TODO builderIo = ImGuiFreeType::GetBuilderForFreeType()
210- // #elif defined(IMGUI_ENABLE_STB_TRUETYPE)
211- getBuilderForStbTruetype()
208+ // #ifdef IMGUI_ENABLE_FREETYPE
209+ // TODO builderIo = ImGuiFreeType::GetBuilderForFreeType()
210+ // #elif defined(IMGUI_ENABLE_STB_TRUETYPE)
211+ getBuilderForStbTruetype()
212212 // #else
213213 // IM_ASSERT(0) // Invalid Build function
214214
@@ -538,7 +538,7 @@ class FontAtlas {
538538 var rects: Array < rectpack.Rect > = emptyArray()
539539
540540 /* * Output glyphs */
541- var packedChars: List <PackedChar > = emptyList ()
541+ var packedChars: Array <PackedChar > = emptyArray ()
542542
543543 /* * Ranges as requested by user (user is allowed to request too much, e.g. 0x0020..0xFFFF) */
544544 lateinit var srcRanges: Array <IntRange >
@@ -694,8 +694,8 @@ class FontAtlas {
694694 if (srcTmp.glyphsCount == 0 )
695695 continue
696696
697- srcTmp.rects = bufRects.drop (bufRectsOutN).toTypedArray( )
698- srcTmp.packedChars = bufPackedchars.drop (bufPackedcharsOutN)
697+ srcTmp.rects = bufRects.copyOfRange (bufRectsOutN, bufRectsOutN + srcTmp.glyphsCount )
698+ srcTmp.packedChars = bufPackedchars.copyOfRange (bufPackedcharsOutN, bufPackedcharsOutN + srcTmp.glyphsCount )
699699 bufRectsOutN + = srcTmp.glyphsCount
700700 bufPackedcharsOutN + = srcTmp.glyphsCount
701701
@@ -706,7 +706,7 @@ class FontAtlas {
706706 firstUnicodeCodepointInRange = 0
707707 arrayOfUnicodeCodepoints = srcTmp.glyphsList.toIntArray()
708708 numChars = srcTmp.glyphsList.size
709- chardataForRange = ArrayList ( srcTmp.packedChars)
709+ chardataForRange = srcTmp.packedChars
710710 hOversample = cfg.oversample.x.ui
711711 vOversample = cfg.oversample.y.ui
712712 }
@@ -763,7 +763,7 @@ class FontAtlas {
763763
764764 // Extend texture height and mark missing glyphs as non-packed so we won't render them.
765765 // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?)
766- for (glyphIdx in 0 until srcTmp.glyphsCount)
766+ for (glyphIdx in 0 .. < srcTmp.glyphsCount)
767767 if (srcTmp.rects[glyphIdx].wasPacked != 0 )
768768 texSize.y = texSize.y max (srcTmp.rects[glyphIdx].y + srcTmp.rects[glyphIdx].h)
769769 }
@@ -832,7 +832,7 @@ class FontAtlas {
832832 val q = AlignedQuad ()
833833 getPackedQuad(srcTmp.packedChars, texSize.x, texSize.y, glyphIdx, q = q)
834834 dstFont.addGlyph(cfg, codepoint, q.x0 + fontOff.x, q.y0 + fontOff.y,
835- q.x1 + fontOff.x, q.y1 + fontOff.y, q.s0, q.t0, q.s1, q.t1, pc.xAdvance)
835+ q.x1 + fontOff.x, q.y1 + fontOff.y, q.s0, q.t0, q.s1, q.t1, pc.xAdvance)
836836 }
837837 }
838838// bufPackedchars.free()
@@ -928,7 +928,7 @@ class FontAtlas {
928928 val uv1 = Vec2 ()
929929 calcCustomRectUV(r, uv0, uv1)
930930 font.addGlyph(null , r.glyphID, r.glyphOffset.x, r.glyphOffset.y, r.glyphOffset.x + r.width, r.glyphOffset.y + r.height,
931- uv0.x, uv0.y, uv1.x, uv1.y, r.glyphAdvanceX)
931+ uv0.x, uv0.y, uv1.x, uv1.y, r.glyphAdvanceX)
932932 }
933933 // Build all fonts lookup tables
934934 fonts.filter { it.dirtyLookupTables }.forEach { it.buildLookupTable() }
@@ -1113,15 +1113,15 @@ class FontAtlas {
11131113 }
11141114
11151115 val cursorDatas = arrayOf(
1116- // Pos ........ Size ......... Offset ......
1117- arrayOf(Vec2 (0 , 3 ), Vec2 (12 , 19 ), Vec2 (0 )), // MouseCursor.Arrow
1118- arrayOf(Vec2 (13 , 0 ), Vec2 (7 , 16 ), Vec2 (1 , 8 )), // MouseCursor.TextInput
1119- arrayOf(Vec2 (31 , 0 ), Vec2 (23 ), Vec2 (11 )), // MouseCursor.Move
1120- arrayOf(Vec2 (21 , 0 ), Vec2 (9 , 23 ), Vec2 (4 , 11 )), // MouseCursor.ResizeNS
1121- arrayOf(Vec2 (55 , 18 ), Vec2 (23 , 9 ), Vec2 (11 , 4 )), // MouseCursor.ResizeEW
1122- arrayOf(Vec2 (73 , 0 ), Vec2 (17 ), Vec2 (8 )), // MouseCursor.ResizeNESW
1123- arrayOf(Vec2 (55 , 0 ), Vec2 (17 ), Vec2 (8 )), // MouseCursor.ResizeNWSE
1124- arrayOf(Vec2 (91 , 0 ), Vec2 (17 , 22 ), Vec2 (5 , 0 )), // ImGuiMouseCursor_Hand
1125- arrayOf(Vec2 (109 , 0 ), Vec2 (13 , 15 ), Vec2 (6 , 7 ))) // ImGuiMouseCursor_NotAllowed
1116+ // Pos ........ Size ......... Offset ......
1117+ arrayOf(Vec2 (0 , 3 ), Vec2 (12 , 19 ), Vec2 (0 )), // MouseCursor.Arrow
1118+ arrayOf(Vec2 (13 , 0 ), Vec2 (7 , 16 ), Vec2 (1 , 8 )), // MouseCursor.TextInput
1119+ arrayOf(Vec2 (31 , 0 ), Vec2 (23 ), Vec2 (11 )), // MouseCursor.Move
1120+ arrayOf(Vec2 (21 , 0 ), Vec2 (9 , 23 ), Vec2 (4 , 11 )), // MouseCursor.ResizeNS
1121+ arrayOf(Vec2 (55 , 18 ), Vec2 (23 , 9 ), Vec2 (11 , 4 )), // MouseCursor.ResizeEW
1122+ arrayOf(Vec2 (73 , 0 ), Vec2 (17 ), Vec2 (8 )), // MouseCursor.ResizeNESW
1123+ arrayOf(Vec2 (55 , 0 ), Vec2 (17 ), Vec2 (8 )), // MouseCursor.ResizeNWSE
1124+ arrayOf(Vec2 (91 , 0 ), Vec2 (17 , 22 ), Vec2 (5 , 0 )), // ImGuiMouseCursor_Hand
1125+ arrayOf(Vec2 (109 , 0 ), Vec2 (13 , 15 ), Vec2 (6 , 7 ))) // ImGuiMouseCursor_NotAllowed
11261126 }
11271127}
0 commit comments