чт, 28 мар. 2024 г. в 14:41, Alan Third : > 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