Skip to content

Commit 97a2feb

Browse files
committed
Add MC Font
1 parent 3ce6dc6 commit 97a2feb

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/main/kotlin/com/lambda/gui/DearImGui.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import imgui.gl3.ImGuiImplGl3
3535
import imgui.glfw.ImGuiImplGlfw
3636
import net.minecraft.client.gl.GlBackend
3737
import net.minecraft.client.texture.GlTexture
38-
import org.lwjgl.opengl.GL11.glViewport
3938
import org.lwjgl.opengl.GL30.GL_FRAMEBUFFER
4039
import kotlin.math.abs
4140

@@ -45,6 +44,7 @@ object DearImGui : Loadable {
4544

4645
const val EXTERNAL_LINK = ''
4746
const val BREADCRUMB_SEPARATOR = '»'
47+
const val BASE_FONT_SCALE = 13f
4848

4949
val io: ImGuiIO get() = ImGui.getIO()
5050
const val DEFAULT_FLAGS = ImGuiConfigFlags.NavEnableKeyboard or // Enable Keyboard Controls
@@ -57,16 +57,20 @@ object DearImGui : Loadable {
5757
private var targetScale = 0f
5858

5959
private fun updateScale(scale: Float) {
60-
io.fonts.clear()
61-
val baseFontSize = 13f
6260
val glyphRanges = ImFontGlyphRangesBuilder().apply {
6361
addRanges(io.fonts.glyphRangesDefault)
6462
addRanges(io.fonts.glyphRangesGreek)
6563
addChar(EXTERNAL_LINK)
6664
addChar(BREADCRUMB_SEPARATOR)
6765
}.buildRanges()
68-
io.fonts.addFontFromFileTTF("fonts/FiraSans-Regular.ttf".path, baseFontSize * scale, ImFontConfig(), glyphRanges)
69-
io.fonts.build()
66+
val fontConfig = ImFontConfig()
67+
val size = BASE_FONT_SCALE * scale
68+
with(io.fonts) {
69+
clear()
70+
addFontFromFileTTF("fonts/FiraSans-Regular.ttf".path, size, fontConfig, glyphRanges)
71+
addFontFromFileTTF("fonts/MinecraftDefault-Regular.ttf".path, size, fontConfig, glyphRanges)
72+
build()
73+
}
7074
implGl3.createFontsTexture()
7175
}
7276

src/main/kotlin/com/lambda/gui/components/QuickSearch.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ object QuickSearch {
4747

4848
private var lastShiftPressTime = 0L
4949
private var lastShiftKeyCode = -1
50-
private const val DOUBLE_SHIFT_WINDOW_MS = 500L
5150

51+
private const val DOUBLE_SHIFT_WINDOW_MS = 500L
5252
private const val MAX_RESULTS = 50
5353
private const val SIMILARITY_THRESHOLD = 3
54-
5554
private const val WINDOW_FLAGS = ImGuiWindowFlags.AlwaysAutoResize or
5655
ImGuiWindowFlags.NoTitleBar or
5756
ImGuiWindowFlags.NoMove or
@@ -136,12 +135,12 @@ object QuickSearch {
136135
config.configurables.flatMap { configurable ->
137136
val confNameL = configurable.name.lowercase()
138137
configurable.settings.filter { setting ->
139-
setting.visibility() && (setting.name.lowercase().contains(query) || confNameL.contains(query))
138+
setting.visibility() && (setting.name.lowercase().contains(query))
140139
}.map { setting ->
141140
SettingResult(setting, configurable)
142141
}
143142
}
144-
}.take(15)
143+
}
145144
}
146145
}
147146

Binary file not shown.

0 commit comments

Comments
 (0)