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

text-extents returns invalid values for arabic fonts #57

Open
dkochmanski opened this issue Sep 17, 2016 · 0 comments
Open

text-extents returns invalid values for arabic fonts #57

dkochmanski opened this issue Sep 17, 2016 · 0 comments
Labels

Comments

@dkochmanski
Copy link
Member

dkochmanski commented Sep 17, 2016

I've approached this problem during work on McCLIM clx font part refactoring. It seems, that xlib:text-extents returns invalid values for arabic fonts (#<XLIB:FONT -arabic-newspaper-medium-r-normal--32-246-100-100-p-137-iso10646-1 :0 12583033>).

After digging a bit more, I've found, that local-text-extents returns invalid ascent/descent values for the font (i.e -32767). This is fixed, if we comment out local-text-extents and server-text-extents is always called (hack below).

Steps to reproduce:

  1. Install xorg-fonts-misc (or arabic24.pcf.gz font from the preferred source)
  2. Run font-selector demo from McCLIM)
(eval-when (:compile-toplevel :load-toplevel :execute)
  (ql:quickload 'clim-examples))
(clim-demo:demodemo)
;; pick font-selector demo

NB Arabic font won't be rendered even if we have sane ascent/descent values, but this seems to be a separate issue which I'm not sure where it belongs to, or if its a bug – it may be that Arabic font can't render ASCII characters – but the system doesn't crash, only text isn't rendered).

Hack correcting behaviour (but we should fix local-text-extents instead):

diff --git a/text.lisp b/text.lisp
index dcac272..743fbaa 100644
--- a/text.lisp
+++ b/text.lisp
@@ -165,7 +165,7 @@
              ((integerp new-font) (incf width (the int32 new-font))))

        (let (w a d l r)
-         (if (or (font-char-infos-internal font) (font-local-only-p font))
+         (if nil ;(or (font-char-infos-internal font) (font-local-only-p font))
              ;; Calculate text extents locally
              (progn
                (multiple-value-setq (w a d l r)
@@ -254,7 +254,7 @@
              ((integerp new-font) (incf width (the int32 new-font))))

        (incf width
-             (if (or (font-char-infos-internal font) (font-local-only-p font))
+             (if nil ;(or (font-char-infos-internal font) (font-local-only-p font))
                  (text-extents-local font wbuf 0 buf-end :width-only)
                (text-width-server font wbuf 0 buf-end)))
        (when (type? new-font 'font)
@dkochmanski dkochmanski changed the title text-extents: function miserably fail for certain fonts text-extents returns invalid values for arabic fonts Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant