unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73752: 29.4; Ligatures are randomly rendered with extra spaces
@ 2024-10-11 16:18 xuan
  2024-10-12  8:02 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: xuan @ 2024-10-11 16:18 UTC (permalink / raw)
  To: 73752

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


Setup:

1. install `ligature.el` from melpa.

2. start `emacs -Q` and execute the attached script or simply use the attached script as the `init.el`.

3. open the attached `init.el` file and execute `init-faces` or hit "C-#" to start randomizing the font faces,

4. eventually you will see some characters gets rendered with extra spaces (sample screenshots provided below), hit "C-!" to stop the randomization,



5. hitting "C-return" will randomize font once, which might be useful for you find debug,



Expected behavior:

the fonts are rendered consistently without extra spacing,



Observed behavior:

the fonts are rendered with extra spacing randomly,



Related information:

I previously reported this bug here: https://github.com/mickeynp/ligature.el/issues/56.



In GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version

3.24.42, cairo version 1.18.0) of 2024-07-16 built on 
27527c2e06f843c0962737354e0b3cf7 
System Description: Fedora Linux 40 (Sway) 

Configured using: 
'configure --build=x86_64-redhat-linux-gnu 
--host=x86_64-redhat-linux-gnu --program-prefix= 
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr 
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc 
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 
--libexecdir=/usr/libexec --localstatedir=/var --runstatedir=/run 
--sharedstatedir=/var/lib --mandir=/usr/share/man 
--infodir=/usr/share/info --with-cairo --with-dbus --with-gif 
--with-gpm=no --with-harfbuzz --with-jpeg --with-json --with-modules 
--with-native-compilation=aot --with-pgtk --with-png --with-rsvg 
--with-sqlite3 --with-tiff --with-tree-sitter --with-webp --with-xpm 
--with-xwidgets build_alias=x86_64-redhat-linux-gnu 
host_alias=x86_64-redhat-linux-gnu CC=gcc 'CFLAGS=-DMAIL_USE_LOCKF -O2 
-flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches 
-pipe -Wall -Werror=format-security 
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong 
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
-fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' 
LDFLAGS=-Wl,-z,relro 
PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig CXX=g++ 
'CXXFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g 
-grecord-gcc-switches -pipe -Wall -Werror=format-security 
-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS 
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong 
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 
-mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection 
-fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer '' 

Configured features: 
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON 
LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY 
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF 
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM XWIDGETS GTK3 ZLIB 

Important settings: 
value of $LANG: en_US.UTF-8 
locale-coding-system: utf-8-unix 

Major mode: ELisp/l 

Minor modes in effect: 
global-ligature-mode: t 
ligature-mode: t 
tooltip-mode: t 
global-eldoc-mode: t 
eldoc-mode: t 
show-paren-mode: t 
electric-indent-mode: t 
mouse-wheel-mode: t 
tool-bar-mode: t 
menu-bar-mode: t 
file-name-shadow-mode: t 
global-font-lock-mode: t 
font-lock-mode: t 
blink-cursor-mode: t 
line-number-mode: t 
indent-tabs-mode: t 
transient-mark-mode: t 
auto-composition-mode: t 
auto-encryption-mode: t 
auto-compression-mode: t 

Load-path shadows: 
None found. 

Features: 
(shadow sort mail-extr emacsbug message yank-media puny dired 
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config 
gnus-util text-property-search time-date mm-decode mm-bodies mm-encode 
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 
rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp comp-cstr warnings 
icons rx ligature cl-extra help-mode use-package-core ligature-autoloads 
package browse-url url url-proxy url-privacy url-expand url-methods 
url-history url-cookie generate-lisp-file url-domsuf url-util mailcap 
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs 
password-cache json subr-x map byte-opt gv bytecomp byte-compile 
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren 
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel 
term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd fontset 
image regexp-opt fringe tabulated-list replace newcomment text-mode 
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch 
easymenu timer select scroll-bar mouse jit-lock font-lock syntax 
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic 
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese 
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek 
romanian slovak czech european ethiopic indian cyrillic chinese 
composite emoji-zwj charscript charprop case-table epa-hook 
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs 
theme-loaddefs faces cus-face macroexp files window text-properties 
overlay sha1 md5 base64 format env code-pages mule custom widget keymap 
hashtable-print-readable backquote threads xwidget-internal dbusbind 
inotify dynamic-setting system-font-setting font-render-setting cairo 
gtk pgtk multi-tty make-network-process native-compile emacs) 

Memory information: 
((conses 16 108675 14724) 
(symbols 48 8830 0) 
(strings 32 27784 2658) 
(string-bytes 1 906120) 
(vectors 16 22224) 
(vector-slots 8 441624 17378) 
(floats 8 45 30) 
(intervals 56 736 1) 
(buffers 984 12))  

[-- Attachment #2.1: Type: text/html, Size: 748 bytes --]

[-- Attachment #2.2: 83k2iR0RkF0vUnlj.png --]
[-- Type: image/png, Size: 5035 bytes --]

[-- Attachment #2.3: Type: text/html, Size: 189 bytes --]

[-- Attachment #2.4: vj0A4vBxR2UgLHU2.png --]
[-- Type: image/png, Size: 1199 bytes --]

[-- Attachment #2.5: Type: text/html, Size: 189 bytes --]

[-- Attachment #2.6: dknFd3G9YDiGAGQ9.png --]
[-- Type: image/png, Size: 1323 bytes --]

[-- Attachment #2.7: Type: text/html, Size: 189 bytes --]

[-- Attachment #2.8: uM000GtbhXhDurze.png --]
[-- Type: image/png, Size: 1330 bytes --]

[-- Attachment #2.9: Type: text/html, Size: 6959 bytes --]

[-- Attachment #2.10: init.el --]
[-- Type: application/octet-stream, Size: 3667 bytes --]

;; -*- lexical-binding: t; -*-
(setq inhibit-startup-screen t)

;; starting font
(setq default-font (font-spec :family "JetBrains Mono" :size 16 :weight 'regular))
(set-face-attribute 'default nil :width 'normal :weight 'normal :slant 'normal :font default-font)

(use-package ligature
  :config
  (ligature-set-ligatures 'prog-mode '("--" "---" "==" "===" "!=" "!==" "=!="
                              "=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++" "***" ";;" "!!"
                              "??" "???" "?:" "?." "?=" "<:" ":<" ":>" ">:" "<:<" "<>" "<<<" ">>>"
                              "<<" ">>" "||" "-|" "_|_" "|-" "||-" "|=" "||=" "##" "###" "####"
                              "#{" "#[" "]#" "#(" "#?" "#_" "#_(" "#:" "#!" "#=" "^=" "<$>" "<$"
                              "$>" "<+>" "<+" "+>" "<*>" "<*" "*>" "</" "</>" "/>" "<!--" "<#--"
                              "-->" "->" "->>" "<<-" "<-" "<=<" "=<<" "<<=" "<==" "<=>" "<==>"
                              "==>" "=>" "=>>" ">=>" ">>=" ">>-" ">-" "-<" "-<<" ">->" "<-<" "<-|"
                              "<=|" "|=>" "|->" "<->" "<~~" "<~" "<~>" "~~" "~~>" "~>" "~-" "-~"
                              "~@" "[||]" "|]" "[|" "|}" "{|" "[<" ">]" "|>" "<|" "||>" "<||"
                              "|||>" "<|||" "<|>" "..." ".." ".=" "..<" ".?" "::" ":::" ":=" "::="
                              ":?" ":?>" "//" "///" "/*" "*/" "/=" "//=" "/==" "@_" "__" "???"
                              "<:<" ";;;"))
  (global-ligature-mode t))

;; ("\\\"o" ?ö)
;; ("^^+" ?⁺) ("__+" ?₊) ("^^-" ?⁻)
;; ("__0" ?₀) ("__1" ?₁) ("__2" ?₂) ("__3" ?₃) ("__4" ?₄)
;; ("__5" ?₅) ("__6" ?₆) ("__7" ?₇) ("__8" ?₈) ("__9" ?₉)
;; ("__a" ?ₐ) ("__e" ?ₑ) ("__h" ?ₕ) ("__i" ?ᵢ) ("__k" ?ₖ)
;; ("__l" ?ₗ) ("__m" ?ₘ) ("__n" ?ₙ) ("__o" ?ₒ) ("__p" ?ₚ)
;; ("__r" ?ᵣ) ("__s" ?ₛ) ("__t" ?ₜ) ("__u" ?ᵤ) ("__v" ?ᵥ) ("__x" ?ₓ))

(setq faces '((face1 . "--")
	      (face2 . "__")
	      (face3 . "=:=")
	      (face4 . "??")
	      (face5 . "<<")
	      (face6 . "#{")
	      (face7 . "$>")
	      (face8 . "-->")
	      (face9 . "==>")
	      (face10 . "<=|")
	      (face11 . "~@")
	      (face12 . "||>")
	      (face13 . "<:<")))

(defun init-faces ()
  (interactive)
  (dolist (face faces)
    (make-face (car face))
    (highlight-lines-matching-regexp (cdr face) (car face))
    (run-at-time nil 1 #'random-faces)))
  
(defun random-from-list (l)
  (nth (random (length l)) l))

(defun random-face (face)
  (interactive)
  (let* ((weight (random-from-list '(light normal medium bold)))
	 (slant (random-from-list '(normal italic)))
	 (height (random-from-list '(120 125 115 110 130)))
	 )
    (set-face-attribute face nil :weight weight :slant slant :height height)))

(defun random-faces ()
  (interactive)
  (dolist (face faces)
    (random-face (car face))))

(global-set-key (kbd "C-#") #'init-faces)
(global-set-key (kbd "C-!") (lambda () (interactive) (cancel-function-timers #'random-faces)))
(global-set-key (kbd "<C-return>") #'random-faces)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages '(ligature)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

[-- Attachment #2.11: Type: text/html, Size: 162 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73752: 29.4; Ligatures are randomly rendered with extra spaces
  2024-10-11 16:18 bug#73752: 29.4; Ligatures are randomly rendered with extra spaces xuan
@ 2024-10-12  8:02 ` Eli Zaretskii
  2024-10-12 16:09   ` Yixuan Chen
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2024-10-12  8:02 UTC (permalink / raw)
  To: xuan; +Cc: 73752

> From: xuan@xlk.me
> Date: Fri, 11 Oct 2024 12:18:57 -0400
> 
> Setup:
> 
> 1. install `ligature.el` from melpa.
> 
> 2. start `emacs -Q` and execute the attached script or simply use the attached script as the `init.el`.
> 
> 3. open the attached `init.el` file and execute `init-faces` or hit "C-#" to start randomizing the font faces,
> 
> 4. eventually you will see some characters gets rendered with extra spaces (sample screenshots provided below), hit "C-!" to stop the randomization,
> 
> 5. hitting "C-return" will randomize font once, which might be useful for you find debug,

I cannot reproduce the problem on my system.  I've let Emacs randomize
the fonts for quite some time, and everything keeps rendering
correctly without the extra spaces.  When you say "eventually", how
long do you typically wait until the problem appears?

(As two deviations from your init.el, I used a different font
(Cascadia Code), since I don't have JetBrains Mono installed; and I
replaces use-package with the equivalent Lisp, since I don't want to
install ligatures.el on this system.  I don't think these two
deviations should matter, but I mention them FTR.)

I think this might be system-dependent.  Can someone try this in a
Cairo build on GNU/Linux and see if the problem reproduces?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#73752: 29.4; Ligatures are randomly rendered with extra spaces
  2024-10-12  8:02 ` Eli Zaretskii
@ 2024-10-12 16:09   ` Yixuan Chen
  0 siblings, 0 replies; 3+ messages in thread
From: Yixuan Chen @ 2024-10-12 16:09 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 73752

On 10/12/24 04:02, Eli Zaretskii wrote:
> I cannot reproduce the problem on my system.  I've let Emacs randomize
> the fonts for quite some time, and everything keeps rendering
> correctly without the extra spaces.  When you say "eventually", how
> long do you typically wait until the problem appears?

It took me 5 seconds at most, and usually happened immediately.

> (As two deviations from your init.el, I used a different font
> (Cascadia Code), since I don't have JetBrains Mono installed; and I
> replaces use-package with the equivalent Lisp, since I don't want to
> install ligatures.el on this system.  I don't think these two
> deviations should matter, but I mention them FTR.)

I can replicate the same problem (and even worse in some cases) using 
Cascadia Code.

The `use-package` should be replaceable, except you want to keep the 
list of ligature strings formatted in the same way. I'm not fluent in 
Elisp or emacs API, so my dumb way of randomization is achieved through 
regexp matching over the ligature strings. If they are re-organized in 
some way (say merged into one huge line), it might break the randomization.

> I think this might be system-dependent.  Can someone try this in a
> Cairo build on GNU/Linux and see if the problem reproduces?

Potentially, I'm using emacs-pgtk on wayland.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-12 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-11 16:18 bug#73752: 29.4; Ligatures are randomly rendered with extra spaces xuan
2024-10-12  8:02 ` Eli Zaretskii
2024-10-12 16:09   ` Yixuan Chen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).