How is high DPI handled in theme CSS

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
xtal256
Moon lover
Moon lover
Posts: 95
Joined: 2014-06-22, 00:32
Location: here

How is high DPI handled in theme CSS

Unread post by xtal256 » 2025-02-28, 05:14

I recently got new 4K monitors and set Windows to 150% scale, i.e. 144 DPI. Pale Moon handles this well, but some of the borders in the browser UI are 2px thick where I want them to be 1px (since it's not possible to have 1 1/2 physical pixels :D ).
As a workaround, I have changed the CSS of my theme to set the border width to 0.9px which seems to round down to 1 when at 150%. But I am wondering if there is any better way to control whether pixels sizes are rounded up or down when scaling to a factor that is not a whole multiple (e.g. 100%, 200%, 300%)?


Operating system: Windows 10, 22H2, 19045.5487
Browser version: 33.5.1
32-bit or 64-bit browser?: 64 bit
Browser theme (if not default): My own custom theme, based somewhat on the old Firefox 1.5 and Firefox 3 styles.
Installed add-ons:
Adblock Latitude, version: 5.0.9, id: adblocklatitude@addons.palemoon.org
Clear Search 2, version: 1.1.2, id: ClearSearch2@extension-id.invalid
DOM Inspector, version: 3.1.7534, id: inspector@mozilla.org
Download Manager (S3), version: 4.13, id: s3download@statusbar
Forecastfox (fix version), version: 2.4.8, id: forecastfox@s3_fix_version
ImageTweak, version: 0.25.1.2, id: {DB2EA31C-58F5-48b7-8D60-CB0739257904}
keyconfig, version: 20110522, id: keyconfig@dorando
LastPass, version: 3.3.4, id: support@lastpass.com
lori (Life-of-request info), version: 0.2.0.20080521.2, id: {6dfc4f52-26f0-4e5f-89c7-31d6de480db9}
Markdown Viewer, version: 1.12, id: markdownviewer@thiht.fr
Menu Wizard, version: 5.05, id: s3menu@wizard
Organize Status Bar, version: 0.6.5, id: {35106bca-6c78-48c7-ac28-56df30b51d2c}
Pale Moon Commander, version: 3.0.1, id: commander@palemoon.org
Stylish, version: 2.0.7, id: {46551EC9-40F0-4e47-8E18-8E5CF550CFB8}
Tab Mix Plus, version: 0.5.8.4, id: {dc572301-7619-498c-a57d-39143191b318}
Tab Scope, version: 1.6.1.2, id: tabscope@xuldev.org
Windowify Manager Pages, version: 2.0, id: {450aca1a-ca16-4ab6-82bd-188bdce72ef7}
Greasemonkey (disabled), version: 1.15, id: {e4a8a97b-f2ed-450b-b12d-ee082ba24781}
Web Developer (disabled), version: 1.2.11, id: {c45c406e-ab73-11d8-be73-000a95be3b12}
Installed plugins: (about:plugins):
File: NPSPWRAP.DLL
Path: C:\Program Files\Microsoft Office\root\Office16\NPSPWRAP.DLL
Version: 16.0.17425.20008
State: Disabled

File: npctrl.dll
Path: C:\Program Files\Microsoft Silverlight\5.1.50907.0\npctrl.dll
Version: 5.1.50907.0
State: Disabled
5.1.50907.0

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 37350
Joined: 2011-08-28, 17:27
Location: Motala, SE

Re: How is high DPI handled in theme CSS

Unread post by Moonchild » 2025-02-28, 10:32

Mathematically, it is normal to round 1.5(e) up to 2. There is no better way than to fine-tune your theme to your liking when you want to depart from that by forcefully rounding down even if it's 1.5 or above. Mozilla does special-case some of this in Gecko but we don't (and have removed the IMO incorrect truncations that were present in Goanna that were inherited from Mozilla) since it's just not consistent to make these kinds of exceptions and introduce rounding errors deliberately and ambiguously. If not at 150%, then when should it become 2px? at 160? at 170? at 199.99? I hope you get my drift :)
"The world will not be destroyed by those who do evil, but by those who watch them without doing anything." - Albert Einstein
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

BenFenner
Keeps coming back
Keeps coming back
Posts: 814
Joined: 2015-06-01, 12:52
Location: US Southeast

Re: How is high DPI handled in theme CSS

Unread post by BenFenner » 2025-02-28, 14:01

xtal256 wrote:
2025-02-28, 05:14
since it's not possible to have 1 1/2 physical pixels :D

xtal256
Moon lover
Moon lover
Posts: 95
Joined: 2014-06-22, 00:32
Location: here

Re: How is high DPI handled in theme CSS

Unread post by xtal256 » 2025-03-02, 23:45

Thanks Moonchild,

I certainly would not expect Gecko to fudge the numbers just to get some themes looking nice! If there is not a "proper" way to do this in CSS then I will settle for my current solution of adjusting the width to 0.9px.

As for subpixel rendering, I was thinking that might make borders (or any other thin lines) look blurry, but if there is a way to turn in on then I'll give it a try.