Skip to content

[Bug]: Font is tool large in IDE #71

Open

Description

@jaclas

Contact Details

No response

IDE version

1.7? latest

What happened?

I downloaded and ran the latest installer; the window looks like the screenshot. All menu items and window titles and captions are displayed incorrectly.
I'm using Kubuntu 24.04 LTS with Plasma 5.27

Image Image Image

Error and Warning messages

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. jaclas commented on Sep 26, 2026

    @jaclas
    Author

    1.8 beta 6:

    Image
  2. Duefectu commented on Sep 26, 2026

    @Duefectu
    Collaborator

    Do you use any sort of on-screen font enlargement?

  3. jaclas commented on Sep 26, 2026

    @jaclas
    Author

    No, my DPI is unchanged — Xft.dpi: 96 and KDE's forceFontDPI=96. Scaling was not involved: forcing AVALONIA_GLOBAL_SCALE_FACTOR=1 resized the whole window but left the clipping proportions identical.

    Root cause: a broken font, not DPI

    The font Avalonia picked was Fashion Fetish, installed in ~/.local/share/fonts. Its vertical metrics are wrong — hhea has hardcoded placeholder values in all 8 styles:

    hhea claims actual glyph bounds (head)
    ascender 600 (0.700 em) yMax 1199 (1.199 em)
    descender −100 yMin −412
    line height 0.700 em 1.611 em

    Glyphs overshoot hhea.ascender by 50%, so anything sizing a line box from hhea clips the top half. OS/2.usWinAscent was too low as well (1175 vs yMax 1225 in Bold). The same font clipped text in LibreOffice Writer, which confirmed it wasn't an IDE bug.

    I fixed the font by setting hhea and OS/2 win metrics from head.yMax/yMin via fontTools. Text renders fully now.

    The actual feature request

    The IDE does not declare a UI font, so Avalonia falls back to SkiaSharp's default typeface — effectively the first family in the enumeration. On my system that happened to be a broken font, purely because it sorts first alphabetically in my user font directory.

    Two observations:

    1. fc-match never returns that font for any family name, including an empty one — it always returns DejaVu Sans. So the IDE isn't going through fontconfig name matching; it takes whatever the enumeration yields first. Adding another font directory changed which font was picked, while the name lookup stayed the same.
    2. Only a few controls were unaffected ("No project open", the Memory viewer / Output / Emulator tabs) — presumably those set FontFamily explicitly in XAML.

    It would help a lot to be able to set the UI font — either in Tools → Options next to EditorFontSize, or as a key in ZXBasicStudioOptions.json. Right now the font is whatever the system happens to enumerate first, which is unpredictable across machines. A FontFamily setting (falling back to the current behaviour when empty) would make this configurable instead of accidental.

    Note this is separate from EditorFontSize, which only affects the code editor — the editor was always fine, since Cascadia Code is embedded in the binary.

    Workaround for other Linux users

    Until then, this launcher substitutes the UI font for the IDE process only, without touching the system:

    #!/usr/bin/env bash
    set -euo pipefail
    
    FONT="${ZXBS_FONT:-DejaVu Sans Condensed}"
    
    DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
    CONF="${XDG_RUNTIME_DIR:-/tmp}/zxbs-fonts.conf"
    
    cat > "$CONF" <<EOF
    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
    <fontconfig>
      <include ignore_missing="no">/etc/fonts/fonts.conf</include>
      <match target="pattern">
        <edit name="family" mode="prepend" binding="strong">
          <string>${FONT}</string>
        </edit>
      </match>
    </fontconfig>
    EOF
    
    FONTCONFIG_FILE="$CONF" exec "$DIR/ZXBasicStudio" "$@"

    It deliberately names no specific font to avoid — the broken one differs per machine. mode="prepend" puts the chosen family first for every query, so it doesn't matter which font the enumeration would otherwise return, and the rest of the list stays in place as fallback (CJK and emoji still resolve correctly — verified with fc-match).

    One trap, in case you try it: <selectfont><rejectfont> does not work here. Font directories come from the system config and are already cached by the time the rule is parsed, so the broken font stays visible. Moving <selectfont> before <include> doesn't help either. Substituting the family is what works.

    And now:

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions