Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlib:text-extents emits error when unable to translate unicode character. #182

Open
fourier opened this issue Mar 18, 2021 · 4 comments
Open

Comments

@fourier
Copy link

fourier commented Mar 18, 2021

(defparameter *myfont* (xlib:open-font *display* "terminus-bold-16"))
(xlib:text-extents *myfont* "привет")
; Debugger entered on #<TYPE-ERROR expected-type: BASE-CHAR datum: #\CYRILLIC_SMALL_LETTER_PE>

Seems error in translate-default:

(let ((wbuf (xlib::display-tbuf16 *display*)))
           (xlib::translate-default "привет" 0 3 *myfont* wbuf 0)
           wbuf)
; Debugger entered on #<TYPE-ERROR expected-type: BASE-CHAR datum: #\CYRILLIC_SMALL_LETTER_PE>

or futher down in char->card8:

(xlib:char->card8 (char "привет" 0))
; Debugger entered on #<TYPE-ERROR expected-type: BASE-CHAR datum: #\CYRILLIC_SMALL_LETTER_PE>
@fourier
Copy link
Author

fourier commented Mar 18, 2021

This error could be avoided with ugly hack for text-extents:

(xlib:text-extents font (mapcar #'char-code (coerce string 'list)))

or similar, by converting the string to the list of numbers.

@fourier
Copy link
Author

fourier commented Mar 18, 2021

And finally to use the unicode string with draw-image-glyphs I had to supply the same list (mapcar #'char-code (coerce string 'list)) instead of the string (and additional argument :size 16)

fourier added a commit to fourier/stumpwm that referenced this issue Mar 18, 2021
@fourier
Copy link
Author

fourier commented Mar 19, 2021

However the hack doesn't work for the unicode characters outside of the font range, i.e.

CL-USER> (code-char 128081)
#\CROWN
CL-USER> #\crown
#\CROWN
CL-USER> #\👑
#\CROWN

@JMC-design
Copy link
Contributor

that's what the TRANSLATE key is for.

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

No branches or pull requests

2 participants