[mcclim-devel] Use Unicode fonts when available

Christophe Rhodes csr21 at cantab.net
Mon Apr 20 10:22:05 UTC 2009


Juliusz Chroboczek <jch at pps.jussieu.fr> writes:

> Don't leave the choice of font encoding to the server, as this is highly
> unreliable.  Try fonts as iso10646-1 if the server supports that, fall-back
> to iso8859-1.  If that's still not available, choose any font at all.
>
> iso10646-1 is only tried when (> char-code-limit #x100).

Thank you; this patch looks uncontroversial, and I've merged it as-is.

Best,

Christophe

> diff -u -r1.137 port.lisp
> --- Backends/CLX/port.lisp	18 Feb 2009 17:34:44 -0000	1.137
> +++ Backends/CLX/port.lisp	2 Mar 2009 21:07:05 -0000
> @@ -970,8 +984,6 @@
>        :italic-bold         "bold-i")) ))
>  
>  (defun open-font (display font-name)
> -
> -
>    (let ((fonts (xlib:list-font-names display font-name :max-fonts 1)))
>      (if fonts
>  	(xlib:open-font display (first fonts))
> @@ -1003,13 +1015,20 @@
>                     (size-number (if (numberp size)
>                                      (round size)
>                                      (or (getf *clx-text-sizes* size)
> -                                        (getf *clx-text-sizes* :normal))))
> -                   (font-name (format nil "-~A-~A-*-*-~D-*-*-*-*-*-*-*"
> -                                      family-name face-name size-number)))
> -              (setf (gethash text-style table)
> -                    (cons font-name
> -                          (open-font (clx-port-display port) font-name)))
> -              font-name))))))
> +                                        (getf *clx-text-sizes* :normal)))))
> +              (flet ((try (encoding)
> +                       (let* ((fn (format nil "-~A-~A-*-*-~D-*-*-*-*-*-~A"
> +                                          family-name face-name size-number
> +                                          encoding))
> +                              (font (open-font (clx-port-display port) fn)))
> +                         (and font (cons fn font)))))
> +                (let ((fn-font
> +                       (or
> +                        (and (> char-code-limit #x100) (try "iso10646-1"))
> +                        (try "iso8859-1")
> +                        (try "*-*"))))
> +                  (setf (gethash text-style table) fn-font)
> +                  (car fn-font)))))))))
>  
>  (defmethod (setf text-style-mapping) (font-name (port clx-port)
>                                        (text-style text-style)
> diff -u -r1.89 medium.lisp
> --- Backends/CLX/medium.lisp    9 Nov 2008 19:55:38 -0000       1.89
> +++ Backends/CLX/medium.lisp    2 Mar 2009 21:11:31 -0000
> @@ -945,8 +1020,8 @@
>  ;;; is by no means a proper solution to the problem of
>  ;;; internationalization, because fonts tend not to have a complete
>  ;;; coverage of the entirety of the Unicode space, even assuming that
> -;;; the underlying lisp supports it (as of 2006-02-06, only the case
> -;;; for SBCL and CLISP); instead, the translation function is meant to
> +;;; the underlying lisp supports it (this is the case at least for SBCL,
> +;;; CLISP and CCL); instead, the translation function is meant to
>  ;;; handle font sets by requesting the X server change fonts in the
>  ;;; middle of rendering strings.  However, the below stands a chance
>  ;;; of working when using ISO-8859-1-encoded fonts, and will tend to




More information about the mcclim-devel mailing list