Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuring fonts if possible #99

Open
bitspittle opened this issue Jul 19, 2023 · 0 comments
Open

Allow configuring fonts if possible #99

bitspittle opened this issue Jul 19, 2023 · 0 comments
Labels
enhancement New feature / functionality

Comments

@bitspittle
Copy link
Contributor

bitspittle commented Jul 19, 2023

This was a feature request from a user, who shared a way you can change fonts on Windows:

actual fun changeConsoleFonts() {
    platform.posix.system("chcp 65001")
    memScoped {
        val fontName = "Lucida Console"
        val hnd = GetStdHandle(STD_OUTPUT_HANDLE)
        if (hnd != INVALID_HANDLE_VALUE) {
            val info = alloc<CONSOLE_FONT_INFOEX>()
            info.cbSize = sizeOf<CONSOLE_FONT_INFOEX>().toUInt()
            val tt: Boolean
            // First determine whether there's already a TrueType font.
            if (GetCurrentConsoleFontEx(hnd, FALSE, info.ptr) == TRUE) {
//                tt = (info.FontFamily and TMPF_TRUETYPE.toUInt()).toInt() == TMPF_TRUETYPE
//                if (tt) {
//                    println("The console already is using a TrueType font.")
//                    return
//                }
                // Set console font to Lucida Console.
                val newInfo = alloc<CONSOLE_FONT_INFOEX>()
                newInfo.cbSize = sizeOf<CONSOLE_FONT_INFOEX>().toUInt()
                newInfo.FontFamily = TMPF_TRUETYPE.toUInt()
                newInfo.FaceName.writeBytes(fontName.encodeToByteArray())
                // Get some settings from current font.
                newInfo.dwFontSize.X = info.dwFontSize.X
                newInfo.dwFontSize.Y = info.dwFontSize.Y
                newInfo.FontWeight = info.FontWeight
                SetCurrentConsoleFontEx(hnd, FALSE, newInfo.ptr)
            } else {
                println("GetCurrentConsoleFontEx false.")
            }
        }
    }
}

Windows is actually pretty powerful with their console API. I'm not sure it's a standard feature, however.

So questions...

  • Is there a way to allow configuring fonts in a standard way across all terminals?
  • Is it worth exposing Kotter API bits that are platform specific?
@bitspittle bitspittle added the enhancement New feature / functionality label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature / functionality
Projects
None yet
Development

No branches or pull requests

1 participant