Skip to content

Do not let Emacs rescale the grid tiles - #2

Merged
Gleek merged 1 commit into
Gleek:mainfrom
demoj1:fix/tile-scale
Sep 2, 2026
Merged

Gleek merged 1 commit into
Gleek:mainfrom
demoj1:fix/tile-scale

Conversation

@demoj1

@demoj1 demoj1 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

The grid tiles are made with create-image and no :scale, but the header image passes :scale 1. So Emacs scales only the tiles, by image-scaling-factor. Its default is auto, which means char-width / 10.

My font is Iosevka at 19.6pt, so one character is 13px wide and the factor is 1.3.

Both the header and the grid come from the same column-width, but then the grid is stretched by 30% and the header is not. Each column moves a bit further away from its day name.

Measured on 2a03d9d (emacs -Q, empty backend, only the font set):

step
day names in the header 136px
column lines in the grid 176px

176 / 136 = 1.29, which is the scaling factor.

before

With :scale 1 on the tiles, the columns are 135px and line up with the header:

after

Note that this is not fixed by org-timegrid-default-zoom. Your zoom makes the drawing inside the SVG bigger, and image-scaling-factor stretches the finished image on top of that. The two just multiply.

Nothing changes for users whose character is under 10px wide, because the factor was already 1 for them.

Tests: 30 pass.

The header image passes `:scale 1', but the grid tiles do not. So Emacs
scales only the tiles, by `image-scaling-factor'. Its default is `auto',
which means `char-width / 10'. With a 13px wide character that is 1.3.

The header and the grid are laid out from the same `column-width', but one
of them is then stretched by 30%. Every column moves further away from its
day name, so the last day of the week is off by about a third of a column.

Pass `:scale 1' for the tiles too. Nothing changes for anyone whose
character is under 10px wide, where the factor was already 1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014nqM3DEZjQyybPRfBMwypu
@Gleek

Gleek commented Sep 2, 2026

Copy link
Copy Markdown
Owner

The code looks good. Thanks.

I'm wondering why is the misalignment still there in your fixed screenshot. Is this your scroll bar on the left that shifts the timegrid to the right?

Also the now line doesn't appear. Not sure why that would be happening.

Anyway, merging this.

@Gleek
Gleek merged commit 7de4e59 into Gleek:main Sep 2, 2026
@Gleek

Gleek commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Also the now line doesn't appear. Not sure why that would be happening.

This is fixed. Emacs uses X11 colours that SVG can't always recognize. Have passed it through a convertor which now renders the colours correctly.

@demoj1

demoj1 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for merging!

Is this your scroll bar on the left that shifts the timegrid to the right?

Yes, exactly that. window-edges reports a 24px gap on my window: an 8px fringe and a 16px scroll bar. I build Emacs with the Lucid toolkit, where the vertical scroll bar is on the left. The header line starts at the window edge, but the tiles are text and start after the scroll bar, so the header was 16px to the left of the grid.

The column step was already correct, so the header was shifted as a whole. That is why it looked like a small constant error and not a growing one.

Opened #5 for it: it measures the gap with window-edges instead of counting the fringe, which also covers the margin and a scroll bar on either side. After the fix the day names sit exactly on the column centres.

Also the now line doesn't appear.

Good catch on the X11 colours, and thanks for fixing it — the red line renders here now.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants