bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57693: 29.0.50; Is there a more reliable version of `char-displayabl


From: Ihor Radchenko
Subject: bug#57693: 29.0.50; Is there a more reliable version of `char-displayable-p'?
Date: Sat, 18 Feb 2023 11:32:56 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>>     (defun insert-char-safely (ch repl)
>>       "Insert character CH, if it can be displayed; otherwise insert REPL.
>>     On TTY frames, always insert REPL."
>>       (if (not (display-graphic-p))
>>           (insert repl)
>>         (insert ch)
>>         (unless (font-at (1- (point)))
>>           (delete-char -1)
>>           (insert repl))))
>
> We could, but IME typical uses of fancy characters do not insert them
> into a buffer, but use them in header-line, overlay strings, and
> suchlikes.

`font-at' accepts optional third argument STRING.
For example, (font-at 0 nil "🧠a")

I am not sure how reliable this approach with string is though.

As an alternative thought, may Emacs display engine accept a text
property like 'display-alternative to display some fallback
character/string if some parts of the displayed text cannot be
displayed?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]