hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.64k stars 829 forks source link

Allow configuring subpixel rendering (per monitor) #6986

Open sliedes opened 1 month ago

sliedes commented 1 month ago

Description

I admit I don't 100% understand what this requires and if this is actually fully (separately for both displays) implementable using current Wayland; but Wayland seems to have information about the subpixel format of displays, as displayed by, for example, wayland-info. For my two monitors in Hyprland, it says under "interface: 'wl_output'":

subpixel_orientation: unknown, output_transform: normal (or 270° for the other).

This results in suboptimal grayscale antialiasing for fonts.

Use case 1 (simpler)

I'd want to set the same subpixel rendering for all displays. I believe this is at least something supported by Wayland (or maybe I'm wrong and it's a fontconfig setting, but then I don't understand why Wayland knows about subpixel order?)

Use case 2

Two different monitors with different pixel orders; perhaps most commonly one horizontal and one vertical monitor.

I actually tried to hack Hyprland to call wlr_output_state_set_subpixel(state.wrl(), WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB) in CMonitor::onConnect() to see if that would have an effect (I'm speculating that in Wayland the compositor somehow sends this information to applications). The effect that I do see is wayland-info showing that subpixel orientation; however, all text in all applications still seems to be grayscale antialiased. Documentation seems to indicate that some other compositors (like sway) have settings for this; perhaps I should test what kinds of results I could get with those.

vaxerski commented 1 month ago

makes sense, maybe we can also query the properties via the edid in aq

BBaoVanC commented 2 weeks ago

I am not familiar with what client apps actually make use of this, but in Sway it's configurable in the settings. Sway doesn't autodetect it though so even there you currently have to manually set it.

It doesn't seem like this is required to have subpixel rendered text; it works for me even on sway where swaymsg -t get_outputs shows unknown for the subpixel orientation. It looks to me like proper subpixel rendering has to be configured in fontconfig based on ArchWiki?

sliedes commented 1 week ago

Yeah, this is a very interesting question (if I even understand it correctly). In fontconfig I think you cannot configure it per display (and this makes sense to me because I don't think fontconfig ought to know about displays). In sway you can. I never questioned whether that actually works in the sense that it gives us different subpixel rendering on different displays. Or, in other words, while it seems wayland can somehow provide this information, is it actually used by anything at all.