Skip to content

Windows: LocalKaos.exec() resets console TrueType font (Consolas) to raster #24

Description

@biaks

On Windows, calling LocalKaos.exec() to spawn a subprocess (e.g. PowerShell) with redirected stdin/stdout/stderr pipes causes the parent cmd.exe console's TrueType font (specifically Consolas) to be silently reset to a raster/legacy font. After this, all non-ASCII characters (Cyrillic, emoji, etc.) become invisible. The code page remains UTF-8 (chcp 65001), so the issue is purely the console font being mutated.
Other TrueType fonts (Ubuntu Mono, Iosevka) are unaffected; only Consolis is reset.

Reproduction

  1. Open cmd.exe on Windows 10/11.
  2. chcp 65001
  3. Set console font to Consolas (Properties → Font).
  4. Run a script that calls kaos.local.LocalKaos.exec("powershell", "-command", "echo test").
  5. After the subprocess exits, type Cyrillic text in the console — characters are invisible/blank.

Root cause

asyncio.create_subprocess_exec() is called without creationflags. On Windows, the child process inherits a console handle, which triggers the OS to re-evaluate the parent console font and fall back to a raster font.

Proposed fix

Pass subprocess.CREATE_NO_WINDOW on Windows to detach the child from the parent console host:

      async def exec(self, *args: str, env: Mapping[str, str] | None = None) -> KaosProcess:
          if not args:
              raise ValueError("At least one argument (the program to execute) is required.")

          import subprocess

          creationflags = 0
          if os.name == "nt":
              creationflags = subprocess.CREATE_NO_WINDOW

          process = await asyncio.create_subprocess_exec(
              *args,
              stdin=asyncio.subprocess.PIPE,
              stdout=asyncio.subprocess.PIPE,
              stderr=asyncio.subprocess.PIPE,
              env=env,
              creationflags=creationflags,
          )
          return self.Process(process)

This change prevents the font reset while keeping all existing functionality intact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions