all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Evgeny Zajcev <lg.zevlg@gmail.com>
To: Alan Third <alan@idiocy.org>, Evgeny Zajcev <lg.zevlg@gmail.com>,
	Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org
Subject: Re: [PATCH] Add support for `ch' and `cw' dimension specifiers for the image
Date: Thu, 28 Mar 2024 22:34:32 +0300	[thread overview]
Message-ID: <CAO=W_ZqYMuEk3GFafPCAkz=LEjOneZhL5Sdu=3UcCh-Jq2gnSg@mail.gmail.com> (raw)
In-Reply-To: <ZgVXY07F7LXo2Mmi@idiocy.org>

[-- Attachment #1: Type: text/plain, Size: 2590 bytes --]

чт, 28 мар. 2024 г. в 14:41, Alan Third <alan@idiocy.org>:

> On Thu, Mar 28, 2024 at 01:50:37PM +0300, Evgeny Zajcev wrote:
> > Yes, this is intentional, because saying "height of the font" in docs,
> when
> > font's pixel size is used in code, is misleading and it took me some time
> > to understand why image renders smaller then font height if '(1 . em) is
> > specified as dimension modifier.  That's why I started using coefficient
> > (calculated with `my-em-height-ratio') to `em' specifier
>
> Does this mean we have em wrong? It should ideally, IMO, be equivalent
> to em in a web browser because that seems the most common use Emacs
> users will be aware of. If we're using the wrong value then we should
> change it.
>

Not wrong, but different.

I don't know what `em' in web browser means, however, in web browser,
for example, it is possible to create an image of 3em height and
display it like this:

.----------.
|          | Text line 1
|          | Text line 2
|          | Text line 3
`----------'

And image will be displayed solely and will fit into 3 lines height.

In Emacs, if image with 3em in height is displayed using slices, it
will result in a gap in the final slice, because 1em (font's size) is
less in pixels, than 1ch (font's height and final line height).

Let me elaborate: For example we have 45px font, with ascent 38px and
descent 10px, resulting in font height equal to 48px.  And we create
3em image, which will be 45*3 = 135px in height.  Now, we display this
image using slices: first slice will be: 0,48 (to occupy full line
height), second slice - 48,48, and third slice 96,39.  Last slice is
39px in height and if you display it with :ascent 'center it will have
4px gap.  If you display it with :ascent 100, it will increase final
line height by 1px, because 39-38.  You probably can calculate correct
:ascent value to get exact value of ascent in %, but, unfortunatety,
ascent is integer and in general integer number of percents is not
enough to get exact value (for example for fonts larger then 100px).
Also, this forces to modify :ascent value for the last slice, which
leads to additional garbage.

`ch' and `cw' specifiers solves two problems:
1) Makes it possible to create image intended for slices display
without gaps, and automatically adopts to text-scale changes.

2) Makes it possible to align images precisely to the width of the
given number of characters, especially this makes sense when monospace
font is used.  Also adopts to text-scale changes.

-- 
lg

[-- Attachment #2: Type: text/html, Size: 3201 bytes --]

  reply	other threads:[~2024-03-28 19:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 14:53 [PATCH] Add support for `ch' and `cw' dimension specifiers for the image Evgeny Zajcev
2024-03-21 16:57 ` Eli Zaretskii
2024-03-21 19:14   ` Evgeny Zajcev
2024-03-28 10:06     ` Eli Zaretskii
2024-03-28 10:50       ` Evgeny Zajcev
2024-03-28 11:29         ` Evgeny Zajcev
2024-03-31  8:44           ` Eli Zaretskii
2024-04-01  9:43             ` Evgeny Zajcev
2024-04-01 11:42               ` Eli Zaretskii
2024-04-01 23:02                 ` lg.zevlg
2024-04-01 23:06                   ` lg.zevlg
2024-03-28 11:41         ` Alan Third
2024-03-28 19:34           ` Evgeny Zajcev [this message]
2024-03-29  9:50             ` Alan Third
2024-03-29 10:52               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO=W_ZqYMuEk3GFafPCAkz=LEjOneZhL5Sdu=3UcCh-Jq2gnSg@mail.gmail.com' \
    --to=lg.zevlg@gmail.com \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.