Skip to content

Use FC_SIZE (point size) instead of FC_PIXEL_SIZE for cairo/Xft font rendering #171

Description

@sporteka2

Mlterm uses FC_PIXEL_SIZE for fontconfig font size in cairo and Xft type engines. This means the fontsize config value is interpreted as absolute pixels, ignoring the system DPI setting (Xft.dpi).

Other terminal emulators (gnome-terminal, wezterm, alacritty) use FC_SIZE (point size), which makes fonts scale correctly with the display DPI. This causes mlterm's font to appear at a different physical size than other terminals when Xft.dpi is set to a non-default value.

For example, on a system with Xft.dpi: 307:

  • gnome-terminal with "DejaVu Sans Mono 10" (10pt) renders at ~43px: 10 * 307 / 72
  • mlterm with fontsize=10 renders at 10px (tiny)
  • mlterm with fontsize=43 renders at 43px but column widths may be wrong

The fix is to change fc_size_type from FC_PIXEL_SIZE to FC_SIZE in uitoolkit/libtype/ui_font_ft.c. See the get_fc_col_width() function which already handles both modes correctly with DPI-based calculations for FC_SIZE.

Proposed change:

-static const char *fc_size_type = FC_PIXEL_SIZE;
+static const char *fc_size_type = FC_SIZE;

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions