Tk Source Code

View Ticket
Login
Ticket UUID: e2e9ce70b2151e26ef430c05bac25dcb2db7a2ed
Title: Aqua: Retina-aware alternative to drawing into pixmaps
Type: RFE Version: 8.6.10
Submitter: chrstphrchvz Created on: 2020-04-13 15:18:58
Subsystem: 82. X11 Emulation Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2020-08-09 16:11:01
Resolution: None Closed By: nobody
    Closed on:
Description:

As a workaround for the Tktable issue of improperly drawn cells with overflowing text on Aqua ([685ac30727]), the currently suggested workaround is to use -drawmode slow.

However, a user that tried the -drawmode slow workaround observes fuzzy text in cells on their Retina display (see report on comp.lang.tcl; reporter sent me screenshots; I lack a convenient way to emulate a Retina display, so I have not yet observed the issue firsthand).

Without -drawmode slow (cells without overflowing text look sharp):

With -drawmode slow (all cells in table look fuzzy):

I believe this is because when -drawmode slow is in use, the entire table is drawn to a pixmap, but content (including text) is drawn at non-Retina (1x) scale. Then, when the whole pixmap is drawn to the screen, it is magnified 200% and antialiased, leading to the fuzzy text observed. (Drawing text, etc. directly to the screen are Retina-aware operations and so do not require magnification and do not look fuzzy.)

To resolve this, it would seem that either Tk should make drawing to pixmaps "Retina-aware", or Tktable should avoid drawing to pixmaps (I'm not sure how or whether it can do so).

There exist approaches for handling the underlying CGBitmapContext in a Retina-aware way (example). However, I'm inclined to think making pixmaps Retina-aware might not even be desirable. Pixmaps can persist across draw operations; there likely isn't a way for Tk to tell the difference between a persistent pixmap and one used to temporarily draw offscreen (as by Tktable). And since there can be both a Retina and non-Retina display present, it wouldn't make sense for a pixmap to have an associated scale factor. Maybe also the pixmap should be considered a somewhat low-level format, where things using it expect to be interacting with actual/physical pixels, and could break if interacting with scaled/logical pixels instead.

Can/should drawing into pixmaps be made Retina-aware, or is X11 compatibility the priority and this is won't-fix (at least for Tk 8.6)?

User Comments: chrstphrchvz added on 2020-08-09 16:11:01:

It appears there already was an attempt to give pixmaps an associated scale factor: the pixelpower attribute. Although, the purpose of that appears more in the hope of supporting captures of windows from Retina displays rather than drawing offscreen at Retina resolution. But I've come to believe that Tk is obligated to remain compatible with existing X11 API usage in programs and extensions despite any limitations, and that attributes like pixelpower are non-solutions which break API/ABI compatibility and should possibly be reverted (although doing so means breaking the ABI again): [fcd6717d8b].

So I believe this ticket should be an RFE rather than a bug: it should focus on a new or alternative API for Retina-aware offscreen drawing, if such a feature is useful/desirable for programs.

For Tktable specifically: I think offscreen drawing may not be strictly necessary, but also that any solution Tk Aqua provides will likely require at least a minor change made in Tktable.