Skip to content

Commit

Permalink
Fix Thai rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
wyskoj committed Dec 7, 2022
1 parent a2abd6a commit 8e5fa98
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
15 changes: 15 additions & 0 deletions src/main/kotlin/org/wysko/midis2jam2/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ import org.wysko.midis2jam2.starter.Execution
import org.wysko.midis2jam2.starter.loadSequencerJob
import org.wysko.midis2jam2.util.Utils
import org.wysko.midis2jam2.util.logger
import java.awt.Font
import java.awt.datatransfer.DataFlavor
import java.awt.dnd.DnDConstants
import java.awt.dnd.DropTarget
import java.awt.dnd.DropTargetDropEvent
import java.io.File
import java.util.Enumeration
import java.util.Properties
import javax.swing.UIManager
import javax.swing.plaf.FontUIResource

/**
* The user's home folder.
Expand All @@ -63,6 +66,15 @@ val CONFIGURATION_DIRECTORY: File = File(USER_HOME, ".midis2jam2")
*/
var launcherController: LauncherController? = null

fun setUIFont(f: FontUIResource?) {
val keys: Enumeration<*> = UIManager.getDefaults().keys()
while (keys.hasMoreElements()) {
val key = keys.nextElement()
val value = UIManager.get(key)
if (value is FontUIResource) UIManager.put(key, f)
}
}

/**
* Where it all begins.
*/
Expand All @@ -81,6 +93,9 @@ fun main(args: Array<String>) {
/* Initialize themes */
try {
UIManager.setLookAndFeel(FlatDarkLaf())
val createFont =
Font.createFont(Font.TRUETYPE_FONT, Main.javaClass.getResourceAsStream("/tahoma.ttf")).deriveFont(12f)
setUIFont(FontUIResource(createFont))
} catch (e: Exception) {
with(Main.logger()) {
warn("Failed to initialize FlatLaf theme, reverting to default.")
Expand Down
27 changes: 13 additions & 14 deletions src/main/kotlin/org/wysko/midis2jam2/gui/ConfigureGraphics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.wysko.midis2jam2.gui.Internationalization.i18n
import org.wysko.midis2jam2.util.logger
import java.awt.Dialog
import java.awt.Dimension
import java.awt.Font
import java.awt.GridBagConstraints
import java.awt.GridBagLayout
import java.awt.Insets
Expand Down Expand Up @@ -212,19 +211,19 @@ object ConfigureGraphics {
}

/* Title label */
JLabel().also {
it.font = font.deriveFont(Font.BOLD, font.size + 2f)
it.text = i18n.getString("graphics.title")
add(
it,
GridBagConstraints().apply {
gridx = 0
gridy = 0
gridwidth = 2
insets = Insets(7, 0, 7, 0)
}
)
}
// JLabel().also {
// it.font = font.deriveFont(Font.BOLD, font.size + 2f)
// it.text = i18n.getString("graphics.title")
// add(
// it,
// GridBagConstraints().apply {
// gridx = 0
// gridy = 0
// gridwidth = 2
// insets = Insets(7, 0, 7, 0)
// }
// )
// }

/* Anti-aliasing label */
JLabel().also {
Expand Down
Binary file added src/main/resources/tahoma.ttf
Binary file not shown.

0 comments on commit 8e5fa98

Please sign in to comment.