Mercurial > hg > xemacs-beta
changeset 5180:4cd28c29a7a1
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 29 Mar 2010 22:52:01 -0500 |
parents | 14fda1dbdb26 (current diff) 97eb4942aec8 (diff) |
children | a00bfbd64e0a |
files | lisp/objects.el src/ChangeLog src/emacs.c src/lisp.h src/lrecord.h src/objects-gtk-impl.h src/objects-gtk.c src/objects-gtk.h src/objects-impl.h src/objects-msw-impl.h src/objects-msw.c src/objects-msw.h src/objects-tty-impl.h src/objects-tty.c src/objects-tty.h src/objects-x-impl.h src/objects-x.c src/objects-x.h src/objects-xlike-inc.c src/objects.c src/objects.h src/symsinit.h |
diffstat | 96 files changed, 8088 insertions(+), 7921 deletions(-) [+] |
line wrap: on
line diff
--- a/etc/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/etc/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -1,3 +1,8 @@ +2010-02-22 Ben Wing <ben@xemacs.org> + + * dbxrc.in: + Rename objects.c -> fontcolor.c. + 2010-02-22 Ben Wing <ben@xemacs.org> * dbxrc.in:
--- a/etc/dbxrc.in Mon Mar 29 22:47:55 2010 -0500 +++ b/etc/dbxrc.in Mon Mar 29 22:52:01 2010 -0500 @@ -278,7 +278,7 @@ elif test $lrecord_type = lrecord_type_coding_system; then pstruct file-coding.c Lisp_Coding_System elif test $lrecord_type = lrecord_type_color_instance; then - pstruct objects.c Lisp_Color_Instance + pstruct fontcolor.c Lisp_Color_Instance elif test $lrecord_type = lrecord_type_command_builder; then pstruct event-stream.c command_builder elif test $lrecord_type = lrecord_type_compiled_function; then @@ -302,7 +302,7 @@ elif test $lrecord_type = lrecord_type_float; then pstruct floatfns.c Lisp_Float elif test $lrecord_type = lrecord_type_font_instance; then - pstruct objects.c Lisp_Font_Instance + pstruct fontcolor.c Lisp_Font_Instance elif test $lrecord_type = lrecord_type_frame; then pstruct frame.c frame elif test $lrecord_type = lrecord_type_glyph; then
--- a/lisp/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -1,3 +1,57 @@ +2010-02-22 Ben Wing <ben@xemacs.org> + + * dumped-lisp.el (preloaded-file-list): + * font.el (font-tty-find-closest-color): + * fontcolor.el: + * fontcolor.el (ws-object-property-1): Removed. + * fontcolor.el (fontcolor-property-1): New. + * fontcolor.el (font-name): + * fontcolor.el (font-ascent): + * fontcolor.el (font-descent): + * fontcolor.el (font-width): + * fontcolor.el (font-height): + * fontcolor.el (font-proportional-p): + * fontcolor.el (font-properties): + * fontcolor.el (font-truename): + * fontcolor.el (color-name): + * fontcolor.el (color-rgb-components): + * x-faces.el: + Rename objects.el -> fontcolor.el. + +2010-02-22 Ben Wing <ben@xemacs.org> + + * obsolete.el: + * obsolete.el ('show-buffer): New. + * obsolete.el ('buffer-flush-undo): New. + * obsolete.el (buffer-local-value): New. + * obsolete.el (Info-default-directory-list): Removed. + * obsolete.el (x-color-values): New. + * obsolete.el (mswindows-color-list): + * obsolete.el (init-file-user): Removed. + * obsolete.el ('pui-add-install-directory): Removed. + * obsolete.el (line-beginning-position): + * obsolete.el ('line-beginning-position): New. + * obsolete.el ('line-end-position): New. + * obsolete.el (obsolete-throw): New. + * obsolete.el ('cl-mapc): New. + * obsolete.el ('byte-code-function-p): New. + * obsolete.el ('interactive-form): New. + * obsolete.el ('assq-delete-all): New. + * obsolete.el (makehash): New. + * obsolete.el ('user-original-login-name): Removed. + * obsolete.el ('isearch-yank-x-selection): Removed. + * obsolete.el ('isearch-yank-x-clipboard): Removed. + * obsolete.el ('display-column-mode): New. + Rearrange; create some new categories out of "misc" stuff, + put categories in alphabetical order, move remaning "misc" + stuff to bottom. + +2010-03-29 Aidan Kehoe <kehoea@parhasard.net> + + * hyper-apropos.el (hyper-apropos-get-doc): + Use help.el's #'function-arglist, #'function-documentation, + #'symbol-file in this function, instead of rolling our own. + 2010-03-25 Ben Wing <ben@xemacs.org> * diagnose.el (show-memory-usage):
--- a/lisp/dumped-lisp.el Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/dumped-lisp.el Mon Mar 29 22:52:01 2010 -0500 @@ -61,7 +61,7 @@ "faces" ; must be loaded before any make-face call ;;(pureload "facemenu") #### not yet ported "glyphs" - "objects" + "fontcolor" "extents" "events" "hash-table"
--- a/lisp/font.el Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/font.el Mon Mar 29 22:52:01 2010 -0500 @@ -1288,7 +1288,7 @@ (defun font-tty-find-closest-color (r g b) ;; This is basically just a lisp copy of allocate_nearest_color - ;; from objects-x.c from Emacs 19 + ;; from fontcolor-x.c from Emacs 19 ;; We really should just check tty-color-list, but unfortunately ;; that does not include any RGB information at all. ;; So for now we just hardwire in the default list and call it
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/fontcolor.el Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,212 @@ +;;; fontcolor.el --- Lisp interface to fonts and colors + +;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. +;; Copyright (C) 1995 Ben Wing +;; Copyright (C) 2010 Didier Verna + +;; Author: Chuck Thompson <cthomp@xemacs.org> +;; Author: Ben Wing <ben@xemacs.org> +;; Maintainer: XEmacs Development Team +;; Keywords: faces, internal, dumped + +;; This file is part of XEmacs. + +;; XEmacs is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; XEmacs is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with XEmacs; see the file COPYING. If not, write to the +;; Free Software Foundation, 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Synched up with: Not in FSF. + +;;; Commentary: + +;; This file is dumped with XEmacs. + +;;; Code: + +(defun fontcolor-property-1 (function object domain &optional matchspec) + (let ((instance (if matchspec + (specifier-matching-instance object matchspec domain) + (specifier-instance object domain)))) + (and instance (funcall function instance)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers + +(defun make-font-specifier (spec-list) + "Return a new `font' specifier object with the given specification list. +SPEC-LIST can be a list of specifications (each of which is a cons of a +locale and a list of instantiators), a single instantiator, or a list +of instantiators. See `make-specifier' for more information about +specifiers. + +Valid instantiators for font specifiers are: + +-- a string naming a font; syntax is platform dependent. Some examples for + a 14-point upright medium-weight Courier font: + X11 (and GTK1): \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" + Xft (and GTK2): \"Courier-14\" + MS-Windows: \"Courier:14:Western\" +-- a font instance (use that instance directly if the device matches, + or use the string that generated it) +-- a vector of no elements (only on TTY's; this means to set no font + at all, thus using the \"natural\" font of the terminal's text) +-- a vector of one element (a face to inherit from) +" + (make-specifier-and-init 'font spec-list)) + +(defun font-name (font &optional domain charset) + "Return the name of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-name' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-name font domain charset)) + +(defun font-ascent (font &optional domain charset) + "Return the ascent of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-ascent' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-ascent font domain charset)) + +(defun font-descent (font &optional domain charset) + "Return the descent of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-descent' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-descent font domain charset)) + +(defun font-width (font &optional domain charset) + "Return the width of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-width' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-width font domain charset)) + +(defun font-height (font &optional domain charset) + "Return the height of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-height' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-height font domain charset)) + +(defun font-proportional-p (font &optional domain charset) + "Return whether FONT is proportional in the specified DOMAIN, if known. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-proportional-p' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-proportional-p font domain charset)) + +(defun font-properties (font &optional domain charset) + "Return the properties of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-properties' +to the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-properties font domain charset)) + +(defun font-truename (font &optional domain charset) + "Return the truename of the FONT in the specified DOMAIN, if any. +FONT should be a font specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `font-instance-truename' +to the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'font-instance-truename font domain charset)) + +(defun font-instance-height (font-instance) + "Return the height in pixels of FONT-INSTANCE. +The returned value is the maximum height for all characters in the font,\n\ +and is equivalent to the sum of the font instance's ascent and descent." + (+ (font-instance-ascent font-instance) + (font-instance-descent font-instance))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; color specifiers + +(defun make-color-specifier (spec-list) + "Return a new `color' specifier object with the given specification list. +SPEC-LIST can be a list of specifications (each of which is a cons of a +locale and a list of instantiators), a single instantiator, or a list +of instantiators. See `make-specifier' for a detailed description of +how specifiers work. + +Valid instantiators for color specifiers are: + +-- a string naming a color (e.g. under X this might be \"lightseagreen2\" + or \"#F534B2\") +-- a color instance (use that instance directly if the device matches, + or use the string that generated it) +-- a vector of no elements (only on TTY's; this means to set no color + at all, thus using the \"natural\" color of the terminal's text) +-- a vector of one or two elements: a face to inherit from, and + optionally a symbol naming which property of that face to inherit, + either `foreground' or `background' (if omitted, defaults to the same + property that this color specifier is used for; if this specifier is + not part of a face, the instantiator would not be valid)." + (make-specifier-and-init 'color spec-list)) + +(defun color-name (color &optional domain) + "Return the name of the COLOR in the specified DOMAIN, if any. +COLOR should be a color specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `color-instance-name' to +the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'color-instance-name color domain)) + +(defun color-rgb-components (color &optional domain) + "Return the RGB components of the COLOR in the specified DOMAIN, if any. +COLOR should be a color specifier object and DOMAIN is normally a window +and defaults to the selected window if omitted. This is equivalent +to using `specifier-instance' and applying `color-instance-rgb-components' +to the result. See `make-specifier' for more information about specifiers." + (fontcolor-property-1 'color-instance-rgb-components color domain)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-boolean specifiers + +(defun make-face-boolean-specifier (spec-list) + "Return a new `face-boolean' specifier object with the given spec list. +SPEC-LIST can be a list of specifications (each of which is a cons of a +locale and a list of instantiators), a single instantiator, or a list +of instantiators. See `make-specifier' for a detailed description of +how specifiers work. + +Valid instantiators for face-boolean specifiers are + +-- t or nil +-- a vector of one, two or three elements: a face to inherit from, + optionally a symbol naming the property of that face to inherit from + (if omitted, defaults to the same property that this face-boolean + specifier is used for; if this specifier is not part of a face, + the instantiator would not be valid), and optionally a value which, + if non-nil, means to invert the sense of the inherited property." + (make-specifier-and-init 'face-boolean spec-list)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-background-placement specifiers + +(defun make-face-background-placement-specifier (spec-list) + "Return a new `face-background-placement' specifier object. +SPEC-LIST can be a list of specifications (each of which is a cons of a +locale and a list of instantiators), a single instantiator, or a list +of instantiators. See `make-specifier' for a detailed description of +how specifiers work. + +Valid instantiators for face-background-placement specifiers are: +-- absolute or relative (symbols), +-- a vector of one element: a face to inherit from." + (make-specifier-and-init 'face-background-placement spec-list)) + +;;; fontcolor.el ends here.
--- a/lisp/hyper-apropos.el Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/hyper-apropos.el Mon Mar 29 22:52:01 2010 -0500 @@ -730,7 +730,7 @@ (local mode-name) global local-str global-str font fore back undl - aliases alias-desc desc) + aliases alias-desc desc arglist) (save-excursion (set-buffer (get-buffer-create hyper-apropos-help-buf)) ;;(setq standard-output (current-buffer)) @@ -764,21 +764,19 @@ (bytecode . "compiled Lisp ") (autoload . "autoloaded Lisp ") (lambda . "Lisp ")))) - desc - (case symtype - ((autoload) (format ",\n(autoloaded from \"%s\")" - (nth 1 newsym))) - ((bytecode) (format ",\n(loaded from \"%s\")" - (symbol-file symbol))))) + desc ",\n(loaded from \"" + (or (symbol-file symbol 'defun) + "[no file information available]") + "\")") local (current-local-map) global (current-global-map) obsolete (get symbol 'byte-obsolete-info) - doc (or (condition-case nil - (documentation symbol) - (void-function - "(alias for undefined function)") - (error "(unexpected error from `documention')")) - "function not documented")) + doc (function-documentation symbol t) + arglist (replace-in-string + (function-arglist symbol) + (format "^(%s " + (regexp-quote (symbol-name symbol))) + "(")) (save-excursion (set-buffer hyper-apropos-help-buf) (goto-char (point-max)) @@ -802,32 +800,7 @@ 'hyper-apropos-warning)) (setq beg (point)) (insert-face "arguments: " 'hyper-apropos-heading) - (cond ((eq symtype 'lambda) - (princ (or (nth 1 newsym) "()"))) - ((eq symtype 'bytecode) - (princ (or (compiled-function-arglist newsym) - "()"))) - ((and (or (eq symtype 'subr) (eq symtype 'autoload)) - (string-match - "[\n\t ]*\narguments: ?(\\([^)]*\\))\n?\\'" - doc)) - (insert (substring doc - (match-beginning 1) - (match-end 1))) - (setq doc (substring doc 0 (match-beginning 0)))) - ((and (eq symtype 'subr) - (string-match - "\ -\[\n\t ]*([^\n\t )]+[\t ]*\\([^\n)]+\\)?)\\(:[\t ]*\\|\n?\\'\\)" - doc)) - (insert "(" - (if (match-end 1) - (substring doc - (match-beginning 1) - (match-end 1))) - ")") - (setq doc (substring doc (match-end 0)))) - (t (princ "[not available]"))) + (princ arglist) (insert "\n\n") (hyper-apropos-insert-face doc) (insert "\n") @@ -944,14 +917,14 @@ (progn (setq ok t) (copy-face symbol 'hyper-apropos-temp-face 'global) - (mapcar #'(lambda (property) - (setq symtype (face-property-instance symbol - property)) - (if symtype - (set-face-property 'hyper-apropos-temp-face - property - symtype))) - built-in-face-specifiers) + (mapc #'(lambda (property) + (setq symtype (face-property-instance symbol + property)) + (if symtype + (set-face-property 'hyper-apropos-temp-face + property + symtype))) + built-in-face-specifiers) (setq font (cons (face-property-instance symbol 'font nil 0 t) (face-property-instance symbol 'font)) fore (cons (face-foreground-instance symbol nil 0 t)
--- a/lisp/objects.el Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ -;;; objects.el --- Lisp interface to C window-system objects - -;; Copyright (C) 1994, 1997 Free Software Foundation, Inc. -;; Copyright (C) 1995 Ben Wing -;; Copyright (C) 2010 Didier Verna - -;; Author: Chuck Thompson <cthomp@xemacs.org> -;; Author: Ben Wing <ben@xemacs.org> -;; Maintainer: XEmacs Development Team -;; Keywords: faces, internal, dumped - -;; This file is part of XEmacs. - -;; XEmacs is free software; you can redistribute it and/or modify it -;; under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; XEmacs is distributed in the hope that it will be useful, but -;; WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -;; General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with XEmacs; see the file COPYING. If not, write to the -;; Free Software Foundation, 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Synched up with: Not in FSF. - -;;; Commentary: - -;; This file is dumped with XEmacs. - -;;; Code: - -(defun ws-object-property-1 (function object domain &optional matchspec) - (let ((instance (if matchspec - (specifier-matching-instance object matchspec domain) - (specifier-instance object domain)))) - (and instance (funcall function instance)))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; font specifiers - -(defun make-font-specifier (spec-list) - "Return a new `font' specifier object with the given specification list. -SPEC-LIST can be a list of specifications (each of which is a cons of a -locale and a list of instantiators), a single instantiator, or a list -of instantiators. See `make-specifier' for more information about -specifiers. - -Valid instantiators for font specifiers are: - --- a string naming a font; syntax is platform dependent. Some examples for - a 14-point upright medium-weight Courier font: - X11 (and GTK1): \"-*-courier-medium-r-*-*-*-140-*-*-*-*-iso8859-*\" - Xft (and GTK2): \"Courier-14\" - MS-Windows: \"Courier:14:Western\" --- a font instance (use that instance directly if the device matches, - or use the string that generated it) --- a vector of no elements (only on TTY's; this means to set no font - at all, thus using the \"natural\" font of the terminal's text) --- a vector of one element (a face to inherit from) -" - (make-specifier-and-init 'font spec-list)) - -(defun font-name (font &optional domain charset) - "Return the name of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-name' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-name font domain charset)) - -(defun font-ascent (font &optional domain charset) - "Return the ascent of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-ascent' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-ascent font domain charset)) - -(defun font-descent (font &optional domain charset) - "Return the descent of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-descent' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-descent font domain charset)) - -(defun font-width (font &optional domain charset) - "Return the width of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-width' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-width font domain charset)) - -(defun font-height (font &optional domain charset) - "Return the height of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-height' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-height font domain charset)) - -(defun font-proportional-p (font &optional domain charset) - "Return whether FONT is proportional in the specified DOMAIN, if known. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-proportional-p' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-proportional-p font domain charset)) - -(defun font-properties (font &optional domain charset) - "Return the properties of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-properties' -to the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-properties font domain charset)) - -(defun font-truename (font &optional domain charset) - "Return the truename of the FONT in the specified DOMAIN, if any. -FONT should be a font specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `font-instance-truename' -to the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'font-instance-truename font domain charset)) - -(defun font-instance-height (font-instance) - "Return the height in pixels of FONT-INSTANCE. -The returned value is the maximum height for all characters in the font,\n\ -and is equivalent to the sum of the font instance's ascent and descent." - (+ (font-instance-ascent font-instance) - (font-instance-descent font-instance))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; color specifiers - -(defun make-color-specifier (spec-list) - "Return a new `color' specifier object with the given specification list. -SPEC-LIST can be a list of specifications (each of which is a cons of a -locale and a list of instantiators), a single instantiator, or a list -of instantiators. See `make-specifier' for a detailed description of -how specifiers work. - -Valid instantiators for color specifiers are: - --- a string naming a color (e.g. under X this might be \"lightseagreen2\" - or \"#F534B2\") --- a color instance (use that instance directly if the device matches, - or use the string that generated it) --- a vector of no elements (only on TTY's; this means to set no color - at all, thus using the \"natural\" color of the terminal's text) --- a vector of one or two elements: a face to inherit from, and - optionally a symbol naming which property of that face to inherit, - either `foreground' or `background' (if omitted, defaults to the same - property that this color specifier is used for; if this specifier is - not part of a face, the instantiator would not be valid)." - (make-specifier-and-init 'color spec-list)) - -(defun color-name (color &optional domain) - "Return the name of the COLOR in the specified DOMAIN, if any. -COLOR should be a color specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `color-instance-name' to -the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'color-instance-name color domain)) - -(defun color-rgb-components (color &optional domain) - "Return the RGB components of the COLOR in the specified DOMAIN, if any. -COLOR should be a color specifier object and DOMAIN is normally a window -and defaults to the selected window if omitted. This is equivalent -to using `specifier-instance' and applying `color-instance-rgb-components' -to the result. See `make-specifier' for more information about specifiers." - (ws-object-property-1 'color-instance-rgb-components color domain)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-boolean specifiers - -(defun make-face-boolean-specifier (spec-list) - "Return a new `face-boolean' specifier object with the given spec list. -SPEC-LIST can be a list of specifications (each of which is a cons of a -locale and a list of instantiators), a single instantiator, or a list -of instantiators. See `make-specifier' for a detailed description of -how specifiers work. - -Valid instantiators for face-boolean specifiers are - --- t or nil --- a vector of one, two or three elements: a face to inherit from, - optionally a symbol naming the property of that face to inherit from - (if omitted, defaults to the same property that this face-boolean - specifier is used for; if this specifier is not part of a face, - the instantiator would not be valid), and optionally a value which, - if non-nil, means to invert the sense of the inherited property." - (make-specifier-and-init 'face-boolean spec-list)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; face-background-placement specifiers - -(defun make-face-background-placement-specifier (spec-list) - "Return a new `face-background-placement' specifier object. -SPEC-LIST can be a list of specifications (each of which is a cons of a -locale and a list of instantiators), a single instantiator, or a list -of instantiators. See `make-specifier' for a detailed description of -how specifiers work. - -Valid instantiators for face-background-placement specifiers are: --- absolute or relative (symbols), --- a vector of one element: a face to inherit from." - (make-specifier-and-init 'face-background-placement spec-list)) - -;;; objects.el ends here.
--- a/lisp/obsolete.el Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/obsolete.el Mon Mar 29 22:52:01 2010 -0500 @@ -3,7 +3,7 @@ ;; Copyright (C) 1985-1994, 1997 Free Software Foundation, Inc. ;; Copyright (C) 1994, 1995 Amdahl Corporation. ;; Copyright (C) 1995 Sun Microsystems. -;; Copyright (C) 2002, 2004 Ben Wing. +;; Copyright (C) 2002, 2004, 2010 Ben Wing. ;; Maintainer: XEmacs Development Team ;; Keywords: internal, dumped @@ -72,6 +72,19 @@ (defvaralias oldvar newvar) (make-compatible-variable oldvar newvar)) +;;;;;;;;;;;;;;;;;;;;;;;;;;;; buffers + +(define-obsolete-function-alias 'show-buffer 'set-window-buffer) +(define-obsolete-function-alias 'buffer-flush-undo 'buffer-disable-undo) +(make-compatible 'eval-current-buffer 'eval-buffer) + +(defun buffer-local-value (variable buffer) + "Return the value of VARIABLE in BUFFER. +If VARIABLE does not have a buffer-local binding in BUFFER, the value +is the default binding of variable." + (symbol-value-in-buffer variable buffer)) +(make-compatible 'buffer-local-value 'symbol-value-in-buffer) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;; device stuff (make-compatible-variable 'window-system "use (console-type)") @@ -111,6 +124,7 @@ 'lookup-syntax-properties) ;;;;;;;;;;;;;;;;;;;;;;;;;;;; frames + (defun frame-first-window (frame) "Return the topmost, leftmost window of FRAME. If omitted, FRAME defaults to the currently selected frame." @@ -172,20 +186,21 @@ (define-obsolete-function-alias 'list-faces-display 'edit-faces) (define-obsolete-function-alias 'list-faces 'face-list) -;;;;;;;;;;;;;;;;;;;;;;;;;;;; paths +;;;;;;;;;;;;;;;;;;;;;;;;;;;; fonts and colors -(defvar Info-default-directory-list nil - "This used to be the initial value of Info-directory-list. -If you want to change the locations where XEmacs looks for info files, -set Info-directory-list.") -(make-obsolete-variable 'Info-default-directory-list 'Info-directory-list) +(defun x-color-values (color &optional frame) + "Return a description of the color named COLOR on frame FRAME. +The value is a list of integer RGB values--(RED GREEN BLUE). +These values appear to range from 0 to 65280 or 65535, depending +on the system; white is (65280 65280 65280) or (65535 65535 65535). +If FRAME is omitted or nil, use the selected frame." + (color-instance-rgb-components (make-color-instance color))) +(make-compatible 'x-color-values 'color-instance-rgb-components) -(defvar init-file-user nil - "This used to be the name of the user whose init file was read at startup.") -(make-obsolete-variable 'init-file-user 'load-user-init-file-p) +(make-obsolete 'mswindows-color-list 'color-list) +(make-obsolete 'tty-color-list 'color-list) +(make-compatible 'list-fonts 'font-list) -(define-obsolete-function-alias 'pui-add-install-directory - 'pui-set-local-package-get-directory) ; misleading name ;;;;;;;;;;;;;;;;;;;;;;;;;;;; hooks (make-compatible-variable 'lisp-indent-hook 'lisp-indent-function) @@ -201,13 +216,51 @@ (make-obsolete-variable 'after-change-function "use after-change-functions; which is a list of functions rather than a single function.") -;;;;;;;;;;;;;;;;;;;;;;;;;;;; insertion and deletion +;;;;;;;;;;;;;;;;;;;;;;;;;;;; insertion, deletion, movement (define-compatible-function-alias 'insert-and-inherit 'insert) (define-compatible-function-alias 'insert-before-markers-and-inherit 'insert-before-markers) -;;;;;;;;;;;;;;;;;;;;;;;;;;;; keymaps +(define-compatible-function-alias 'line-beginning-position 'point-at-bol) +(define-compatible-function-alias 'line-end-position 'point-at-eol) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; Lisp engine, basic Lisp stuff + +(make-obsolete 'function-called-at-point 'function-at-point) + +;; As of 21.5, #'throw is a special operator. This makes bytecode using it +;; compiled for 21.4 fail; making this function available works around that. +(defun obsolete-throw (tag value) + "Ugly compatibility hack. + +See the implementation of #'funcall in eval.c. This should be removed once +we no longer encounter bytecode from 21.4." + (throw tag value)) + +(make-obsolete + 'obsolete-throw + "it says `obsolete' in the name, you know you shouldn't be using this.") + +(define-compatible-function-alias 'cl-mapc 'mapc) + +; old names +(define-compatible-function-alias 'byte-code-function-p + 'compiled-function-p) ;FSFmacs + +(define-compatible-function-alias 'interactive-form + 'function-interactive) ;GNU 21.1 +(define-compatible-function-alias 'assq-delete-all + 'remassq) ;GNU 21.1 + +(defun makehash (&optional test) + "Create a new hash table. +Optional first argument TEST specifies how to compare keys in the table. +Predefined tests are `eq', `eql', and `equal'. Default is `eql'." + (make-hash-table :test test)) +(make-compatible 'makehash 'make-hash-table) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; keys, keymaps (defun keymap-parent (keymap) "Return the first parent of the given keymap." @@ -220,6 +273,15 @@ parent) (make-compatible 'set-keymap-parent 'set-keymap-parents) +;; too bad there's not a way to check for aref, assq, and nconc +;; being called on the values of functions known to return keymaps, +;; or known to return vectors of events instead of strings... + +;;; Yes there is; make compiler macros for aref, assq, nconc, checking that +;;; the car of the relevant argument is sane. + +(make-obsolete-variable 'executing-macro 'executing-kbd-macro) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;; menu stuff (defun add-menu-item (menu-path item-name function enabled-p &optional before) @@ -251,57 +313,6 @@ 'read-expression) ; misleading name (define-compatible-function-alias 'read-input 'read-string) -;;;;;;;;;;;;;;;;;;;;;;;;;;;; misc - -;; (defun user-original-login-name () -;; "Return user's login name from original login. -;; This tries to remain unaffected by `su', by looking in environment variables." -;; (or (getenv "LOGNAME") (getenv "USER") (user-login-name))) -(define-obsolete-function-alias 'user-original-login-name 'user-login-name) - -; old names -(define-obsolete-function-alias 'show-buffer 'set-window-buffer) -(define-obsolete-function-alias 'buffer-flush-undo 'buffer-disable-undo) -(make-compatible 'eval-current-buffer 'eval-buffer) -(define-compatible-function-alias 'byte-code-function-p - 'compiled-function-p) ;FSFmacs - -(define-obsolete-function-alias 'isearch-yank-x-selection - 'isearch-yank-selection) -(define-obsolete-function-alias 'isearch-yank-x-clipboard - 'isearch-yank-clipboard) - -;; too bad there's not a way to check for aref, assq, and nconc -;; being called on the values of functions known to return keymaps, -;; or known to return vectors of events instead of strings... - -;;; Yes there is; make compiler macros for aref, assq, nconc, checking that -;;; the car of the relevant argument is sane. - -(make-obsolete-variable 'executing-macro 'executing-kbd-macro) - -(define-compatible-function-alias 'interactive-form - 'function-interactive) ;GNU 21.1 -(define-compatible-function-alias 'assq-delete-all - 'remassq) ;GNU 21.1 - -(defun makehash (&optional test) - "Create a new hash table. -Optional first argument TEST specifies how to compare keys in the table. -Predefined tests are `eq', `eql', and `equal'. Default is `eql'." - (make-hash-table :test test)) -(make-compatible 'makehash 'make-hash-table) - -(defun buffer-local-value (variable buffer) - "Return the value of VARIABLE in BUFFER. -If VARIABLE does not have a buffer-local binding in BUFFER, the value -is the default binding of variable." - (symbol-value-in-buffer variable buffer)) -(make-compatible 'buffer-local-value 'symbol-value-in-buffer) - -(define-compatible-function-alias 'line-beginning-position 'point-at-bol) -(define-compatible-function-alias 'line-end-position 'point-at-eol) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;; modeline (define-compatible-function-alias 'redraw-mode-line 'redraw-modeline) @@ -333,6 +344,21 @@ (cdr (mouse-position (frame-device frame)))) (make-obsolete 'read-mouse-position 'mouse-position) +;;;;;;;;;;;;;;;;;;;;;;;;;;;; paths + +(defvar Info-default-directory-list nil + "This used to be the initial value of Info-directory-list. +If you want to change the locations where XEmacs looks for info files, +set Info-directory-list.") +(make-obsolete-variable 'Info-default-directory-list 'Info-directory-list) + +(defvar init-file-user nil + "This used to be the name of the user whose init file was read at startup.") +(make-obsolete-variable 'init-file-user 'load-user-init-file-p) + +(define-obsolete-function-alias 'pui-add-install-directory + 'pui-set-local-package-get-directory) ; misleading name + ;;;;;;;;;;;;;;;;;;;;;;;;;;;; redisplay (defun redraw-display (&optional device) @@ -340,7 +366,18 @@ (mapcar 'redisplay-device (device-list)) (redisplay-device device))) -;;;;;;;;;;;;;;;;;;;;;;;;;;;; strings +;; the functionality of column.el has been moved into C +;; Function obsoleted for XEmacs 20.0/February 1997. +(defalias 'display-column-mode 'column-number-mode) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; selections + +(define-obsolete-function-alias 'isearch-yank-x-selection + 'isearch-yank-selection) +(define-obsolete-function-alias 'isearch-yank-x-clipboard + 'isearch-yank-clipboard) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; text and strings (define-obsolete-function-alias 'sref 'aref) @@ -370,48 +407,22 @@ ;; < 21.5 compatibility, eg. https://bugzilla.redhat.com/201524#c2 (define-obsolete-function-alias 'string-to-char-list 'string-to-list) -;;;;;;;;;;;;;;;;;;;;;;;;;;;; window-system objects - -;; the functionality of column.el has been moved into C -;; Function obsoleted for XEmacs 20.0/February 1997. -(defalias 'display-column-mode 'column-number-mode) - -(defun x-color-values (color &optional frame) - "Return a description of the color named COLOR on frame FRAME. -The value is a list of integer RGB values--(RED GREEN BLUE). -These values appear to range from 0 to 65280 or 65535, depending -on the system; white is (65280 65280 65280) or (65535 65535 65535). -If FRAME is omitted or nil, use the selected frame." - (color-instance-rgb-components (make-color-instance color))) -(make-compatible 'x-color-values 'color-instance-rgb-components) - -(make-obsolete 'mswindows-color-list 'color-list) -(make-obsolete 'tty-color-list 'color-list) -(make-compatible 'list-fonts 'font-list) - ;; Two loser functions which shouldn't be used. (make-obsolete 'following-char 'char-after) (make-obsolete 'preceding-char 'char-before) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;; misc + +;; (defun user-original-login-name () +;; "Return user's login name from original login. +;; This tries to remain unaffected by `su', by looking in environment variables." +;; (or (getenv "LOGNAME") (getenv "USER") (user-login-name))) +(define-obsolete-function-alias 'user-original-login-name 'user-login-name) + ;; Keywords already do The Right Thing in XEmacs (make-compatible 'define-widget-keywords "Just use them") -(make-obsolete 'function-called-at-point 'function-at-point) - -;; As of 21.5, #'throw is a special operator. This makes bytecode using it -;; compiled for 21.4 fail; making this function available works around that. -(defun obsolete-throw (tag value) - "Ugly compatibility hack. - -See the implementation of #'funcall in eval.c. This should be removed once -we no longer encounter bytecode from 21.4." - (throw tag value)) - -(make-obsolete - 'obsolete-throw - "it says `obsolete' in the name, you know you shouldn't be using this.") - -(define-compatible-function-alias 'cl-mapc 'mapc) (provide 'obsolete) ;;; obsolete.el ends here
--- a/lisp/x-faces.el Mon Mar 29 22:47:55 2010 -0500 +++ b/lisp/x-faces.el Mon Mar 29 22:52:01 2010 -0500 @@ -611,7 +611,7 @@ ;; -- sjt 2007-10-06 ;; This function is probably also used by the GTK platform. Cf. -;; gtk_color_list in src/objects-gtk.c. +;; gtk_color_list in src/fontcolor-gtk.c. (defun x-color-list-internal () (if (boundp 'x-color-list-internal-cache) x-color-list-internal-cache
--- a/lwlib/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/lwlib/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -1,3 +1,8 @@ +2010-02-22 Ben Wing <ben@xemacs.org> + + * lwlib-colors.h: + objects*.h -> fontcolor*.h. + 2010-02-08 Ben Wing <ben@xemacs.org> * xt-wrappers.h:
--- a/lwlib/lwlib-colors.h Mon Mar 29 22:47:55 2010 -0500 +++ b/lwlib/lwlib-colors.h Mon Mar 29 22:52:01 2010 -0500 @@ -35,7 +35,7 @@ /* basic version from xlwmenu.c */ int FIXME_allocate_nearest_color (Display *display, Colormap screen_colormap, XColor *color_def); -/* haired-up version from ../src/objects-x.c */ +/* haired-up version from ../src/fontcolor-x.c */ int x_allocate_nearest_color (Display *display, Colormap screen_colormap, Visual *visual, XColor *color_def);
--- a/man/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/man/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -1,3 +1,9 @@ +2010-02-22 Ben Wing <ben@xemacs.org> + + * internals/internals.texi (A Summary of the Various XEmacs Modules): + * internals/internals.texi (Modules for other Display-Related Lisp Objects): + objects*.[ch] -> fontcolor*.[ch]. + 2010-03-18 Mike Sperber <mike@xemacs.org> * xemacs/startup.texi (Startup Paths): Reflect the (long-ago)
--- a/man/internals/internals.texi Mon Mar 29 22:47:55 2010 -0500 +++ b/man/internals/internals.texi Mon Mar 29 22:52:01 2010 -0500 @@ -3143,21 +3143,21 @@ @item @file{number-mp.h} @tab @item @file{number.c} @tab @item @file{number.h} @tab -@item @file{objects-gtk-impl.h} @tab -@item @file{objects-gtk.c} @tab -@item @file{objects-gtk.h} @tab -@item @file{objects-impl.h} @tab -@item @file{objects-msw-impl.h} @tab -@item @file{objects-msw.c} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects-msw.h} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects-tty-impl.h} @tab -@item @file{objects-tty.c} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects-tty.h} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects-x-impl.h} @tab -@item @file{objects-x.c} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects-x.h} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects.c} @tab @ref{Modules for other Display-Related Lisp Objects}. -@item @file{objects.h} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-gtk-impl.h} @tab +@item @file{fontcolor-gtk.c} @tab +@item @file{fontcolor-gtk.h} @tab +@item @file{fontcolor-impl.h} @tab +@item @file{fontcolor-msw-impl.h} @tab +@item @file{fontcolor-msw.c} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-msw.h} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-tty-impl.h} @tab +@item @file{fontcolor-tty.c} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-tty.h} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-x-impl.h} @tab +@item @file{fontcolor-x.c} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor-x.h} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor.c} @tab @ref{Modules for other Display-Related Lisp Objects}. +@item @file{fontcolor.h} @tab @ref{Modules for other Display-Related Lisp Objects}. @item @file{opaque.c} @tab @ref{Modules for Other Aspects of the Lisp Interpreter and Object System}. @item @file{opaque.h} @tab @ref{Modules for Other Aspects of the Lisp Interpreter and Object System}. @item @file{paths.h.in} @tab @@ -18887,14 +18887,14 @@ @example -@file{objects-msw.c} -@file{objects-msw.h} -@file{objects-tty.c} -@file{objects-tty.h} -@file{objects-x.c} -@file{objects-x.h} -@file{objects.c} -@file{objects.h} +@file{fontcolor-msw.c} +@file{fontcolor-msw.h} +@file{fontcolor-tty.c} +@file{fontcolor-tty.h} +@file{fontcolor-x.c} +@file{fontcolor-x.h} +@file{fontcolor.c} +@file{fontcolor.h} @end example
--- a/nt/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/nt/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -1,3 +1,15 @@ +2010-02-22 Ben Wing <ben@xemacs.org> + + * xemacs.dsp: + * xemacs.mak: + * xemacs.mak (OPT_OBJS): + objects*.[ch] -> fontcolor*.[ch]. + +2010-03-29 Vin Shelton <acs@xemacs.org> + + * xemacs.mak (TEMACS_COMMON_OBJS): Add array.obj and remove + dynarr.obj, to catch up with Ben's changes of 2010-03-28. + 2010-03-08 Vin Shelton <acs@xemacs.org> * xemacs.mak (batch_test_emacs): The test harness no longer
--- a/nt/xemacs.dsp Mon Mar 29 22:47:55 2010 -0500 +++ b/nt/xemacs.dsp Mon Mar 29 22:52:01 2010 -0500 @@ -887,35 +887,35 @@ # End Source File # Begin Source File -SOURCE="..\src\objects-msw.c" +SOURCE="..\src\fontcolor-msw.c" # End Source File # Begin Source File -SOURCE="..\src\objects-msw.h" +SOURCE="..\src\fontcolor-msw.h" # End Source File # Begin Source File -SOURCE="..\src\objects-tty.c" +SOURCE="..\src\fontcolor-tty.c" # End Source File # Begin Source File -SOURCE="..\src\objects-tty.h" +SOURCE="..\src\fontcolor-tty.h" # End Source File # Begin Source File -SOURCE="..\src\objects-x.c" +SOURCE="..\src\fontcolor-x.c" # End Source File # Begin Source File -SOURCE="..\src\objects-x.h" +SOURCE="..\src\fontcolor-x.h" # End Source File # Begin Source File -SOURCE=..\src\objects.c +SOURCE=..\src\fontcolor.c # End Source File # Begin Source File -SOURCE=..\src\objects.h +SOURCE=..\src\fontcolor.h # End Source File # Begin Source File
--- a/nt/xemacs.mak Mon Mar 29 22:47:55 2010 -0500 +++ b/nt/xemacs.mak Mon Mar 29 22:52:01 2010 -0500 @@ -515,7 +515,7 @@ $(OUTDIR)\frame-msw.obj \ $(OUTDIR)\glyphs-msw.obj \ $(OUTDIR)\gui-msw.obj \ - $(OUTDIR)\objects-msw.obj \ + $(OUTDIR)\fontcolor-msw.obj \ $(OUTDIR)\redisplay-msw.obj \ $(OUTDIR)\select-msw.obj \ $(OUTDIR)\dired-msw.obj @@ -840,6 +840,7 @@ $(OUTDIR)\abbrev.obj \ $(OUTDIR)\alloc.obj \ $(OUTDIR)\alloca.obj \ + $(OUTDIR)\array.obj \ $(OUTDIR)\blocktype.obj \ $(OUTDIR)\buffer.obj \ $(OUTDIR)\bytecode.obj \ @@ -857,7 +858,6 @@ $(OUTDIR)\doc.obj \ $(OUTDIR)\doprnt.obj \ $(OUTDIR)\dragdrop.obj \ - $(OUTDIR)\dynarr.obj \ $(OUTDIR)\editfns.obj \ $(OUTDIR)\elhash.obj \ $(OUTDIR)\emacs.obj \ @@ -903,7 +903,7 @@ # #### Leave the next one out when integrating my working ws $(OUTDIR)\nt.obj \ $(OUTDIR)\ntplay.obj \ - $(OUTDIR)\objects.obj \ + $(OUTDIR)\fontcolor.obj \ $(OUTDIR)\opaque.obj \ $(OUTDIR)\print.obj \ $(OUTDIR)\process.obj \
--- a/src/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/src/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -2067,6 +2067,101 @@ 2010-02-22 Ben Wing <ben@xemacs.org> + * EmacsFrame.c: + * Makefile.in.in (x_objs): + * Makefile.in.in (mswindows_objs): + * Makefile.in.in (tty_objs): + * Makefile.in.in (gtk_objs): + * Makefile.in.in (objs): + * console-tty.h: + * console-x-impl.h: + * console-x-impl.h (struct x_device): + * console-x.h: + * console-xlike-inc.h: + * depend: + * device-gtk.c: + * device-msw.c: + * device-x.c: + * device-x.c (x_init_device): + * device-x.c (x_finish_init_device): + * device.c: + * devslots.h (MARKED_SLOT): + * emacs.c (main_1): + * event-Xt.c: + * event-gtk.c: + * event-msw.c: + * faces.c: + * font-mgr.c: + * fontcolor-gtk-impl.h: + * fontcolor-gtk.c: + * fontcolor-gtk.c (syms_of_fontcolor_gtk): + * fontcolor-gtk.c (console_type_create_fontcolor_gtk): + * fontcolor-gtk.c (vars_of_fontcolor_gtk): + * fontcolor-gtk.h: + * fontcolor-impl.h: + * fontcolor-msw-impl.h: + * fontcolor-msw.c: + * fontcolor-msw.c (syms_of_fontcolor_mswindows): + * fontcolor-msw.c (console_type_create_fontcolor_mswindows): + * fontcolor-msw.c (reinit_vars_of_fontcolor_mswindows): + * fontcolor-msw.c (vars_of_fontcolor_mswindows): + * fontcolor-msw.h: + * fontcolor-msw.h (mswindows_color_to_string): + * fontcolor-tty-impl.h: + * fontcolor-tty.c: + * fontcolor-tty.c (syms_of_fontcolor_tty): + * fontcolor-tty.c (console_type_create_fontcolor_tty): + * fontcolor-tty.c (vars_of_fontcolor_tty): + * fontcolor-tty.h: + * fontcolor-x-impl.h: + * fontcolor-x.c: + * fontcolor-x.c (syms_of_fontcolor_x): + * fontcolor-x.c (console_type_create_fontcolor_x): + * fontcolor-x.c (vars_of_fontcolor_x): + * fontcolor-x.c (Xatoms_of_fontcolor_x): + * fontcolor-x.h: + * fontcolor.c: + * fontcolor.c (syms_of_fontcolor): + * fontcolor.c (specifier_type_create_fontcolor): + * fontcolor.c (reinit_specifier_type_create_fontcolor): + * fontcolor.c (reinit_vars_of_fontcolor): + * fontcolor.c (vars_of_fontcolor): + * fontcolor.h: + * fontcolor.h (set_face_boolean_attached_to): + * frame-gtk.c: + * frame-x.c: + * glyphs-eimage.c: + * glyphs-gtk.c: + * glyphs-msw.c: + * glyphs-widget.c: + * glyphs-x.c: + * glyphs.c: + * gtk-glue.c: + * gtk-glue.c (xemacs_type_register): + * gtk-xemacs.c: + * inline.c: + * intl-win32.c: + * lisp.h: + * lrecord.h: + * mule-charset.c: + * native-gtk-toolbar.c: + * redisplay-msw.c: + * redisplay-tty.c: + * redisplay.c: + * select-x.c: + * select.c: + * symsinit.h: + * toolbar-msw.c: + * toolbar-msw.c (TOOLBAR_ITEM_ID_BITS): + * toolbar-x.c: + * ui-gtk.c: + * window.c: + Rename objects*.[ch] -> fontcolor*.[ch]. Fix up all references to + the old files (e.g. in #include statements, Makefiles, + functions like syms_of_objects_x(), etc.). + +2010-02-22 Ben Wing <ben@xemacs.org> + * .gdbinit.in.in: * Makefile.in.in (batch_test_emacs): test-harness.el is in lisp directory now so change how we call it.
--- a/src/EmacsFrame.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/EmacsFrame.c Mon Mar 29 22:52:01 2010 -0500 @@ -37,7 +37,7 @@ #include "console-x-impl.h" #include "glyphs-x.h" -#include "objects-x.h" +#include "fontcolor-x.h" #include <X11/Shell.h> #include <X11/Xmu/CharSet.h>
--- a/src/Makefile.in.in Mon Mar 29 22:47:55 2010 -0500 +++ b/src/Makefile.in.in Mon Mar 29 22:52:01 2010 -0500 @@ -132,7 +132,7 @@ #ifdef HAVE_X_WINDOWS x_objs=console-x.o device-x.o event-Xt.o frame-x.o \ - glyphs-x.o objects-x.o redisplay-x.o select-x.o gccache-x.o intl-x.o + glyphs-x.o fontcolor-x.o redisplay-x.o select-x.o gccache-x.o intl-x.o #ifdef HAVE_XFT x_objs += font-mgr.o #endif @@ -144,18 +144,18 @@ #ifdef HAVE_MS_WINDOWS mswindows_objs=console-msw.o device-msw.o event-msw.o frame-msw.o \ - objects-msw.o select-msw.o redisplay-msw.o glyphs-msw.o + fontcolor-msw.o select-msw.o redisplay-msw.o glyphs-msw.o mswindows_gui_objs=$(gui_objs:.o=-msw.o) #endif #ifdef HAVE_TTY -tty_objs=console-tty.o device-tty.o event-tty.o frame-tty.o objects-tty.o \ +tty_objs=console-tty.o device-tty.o event-tty.o frame-tty.o fontcolor-tty.o \ redisplay-tty.o cm.o #endif #ifdef HAVE_GTK gtk_objs=console-gtk.o device-gtk.o event-gtk.o frame-gtk.o \ - objects-gtk.o redisplay-gtk.o glyphs-gtk.o select-gtk.o gccache-gtk.o \ + fontcolor-gtk.o redisplay-gtk.o glyphs-gtk.o select-gtk.o gccache-gtk.o \ gtk-xemacs.o ui-gtk.o gtk_gui_objs=$(gui_objs:.o=-gtk.o) #ifdef HAVE_TOOLBARS @@ -291,7 +291,7 @@ keymap.o $(RTC_patch_objs) line-number.o $(ldap_objs) lread.o lstream.o\ $(new_gc_objs) $(vdb_objs) \ macros.o marker.o md5.o minibuf.o $(mswindows_objs) $(mswindows_gui_objs)\ - $(mule_objs) $(mule_canna_objs) $(mule_wnn_objs) $(number_objs) objects.o\ + $(mule_objs) $(mule_canna_objs) $(mule_wnn_objs) $(number_objs) fontcolor.o\ opaque.o $(postgresql_objs) print.o process.o $(process_objs) $(profile_objs)\ rangetab.o realpath.o redisplay.o redisplay-output.o regex.o\ search.o select.o $(sheap_objs) $(shlib_objs) signal.o sound.o\
--- a/src/console-tty.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/console-tty.h Mon Mar 29 22:52:01 2010 -0500 @@ -55,7 +55,7 @@ extern const struct sized_memory_description tty_console_data_description; -/*************** Prototypes from objects-tty.c ****************/ +/*************** Prototypes from fontcolor-tty.c ****************/ extern const struct sized_memory_description tty_color_instance_data_description; extern const struct sized_memory_description tty_font_instance_data_description;
--- a/src/console-x-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/console-x-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -89,7 +89,7 @@ Atom Xatom_ATOM_PAIR; Atom Xatom_COMPOUND_TEXT; - /* allocated in Xatoms_of_objects_x */ + /* allocated in Xatoms_of_fontcolor_x */ Atom Xatom_FOUNDRY; Atom Xatom_FAMILY_NAME; Atom Xatom_WEIGHT_NAME; @@ -219,7 +219,7 @@ #define DEVICE_XATOM_ATOM_PAIR(d) (DEVICE_X_DATA (d)->Xatom_ATOM_PAIR) #define DEVICE_XATOM_COMPOUND_TEXT(d) (DEVICE_X_DATA (d)->Xatom_COMPOUND_TEXT) -/* allocated in Xatoms_of_objects_x */ +/* allocated in Xatoms_of_fontcolor_x */ #define DEVICE_XATOM_FOUNDRY(d) (DEVICE_X_DATA (d)->Xatom_FOUNDRY) #define DEVICE_XATOM_FAMILY_NAME(d) (DEVICE_X_DATA (d)->Xatom_FAMILY_NAME) #define DEVICE_XATOM_WEIGHT_NAME(d) (DEVICE_X_DATA (d)->Xatom_WEIGHT_NAME)
--- a/src/console-x.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/console-x.h Mon Mar 29 22:52:01 2010 -0500 @@ -98,7 +98,7 @@ void x_handle_property_notify (XPropertyEvent *event); void Xatoms_of_select_x (struct device *d); -void Xatoms_of_objects_x (struct device *d); +void Xatoms_of_fontcolor_x (struct device *d); void x_wm_set_shell_iconic_p (Widget shell, int iconic_p); void x_wm_set_cell_size (Widget wmshell, int cw, int ch);
--- a/src/console-xlike-inc.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/console-xlike-inc.h Mon Mar 29 22:52:01 2010 -0500 @@ -90,7 +90,7 @@ # include "glyphs-x.h" # endif # ifdef NEED_OBJECTS_IMPL_H -# include "objects-x-impl.h" +# include "fontcolor-x-impl.h" # endif #else /* THIS_IS_GTK */ # include "console-gtk-impl.h" @@ -101,7 +101,7 @@ # include "glyphs-gtk.h" # endif # ifdef NEED_OBJECTS_IMPL_H -# include "objects-gtk-impl.h" +# include "fontcolor-gtk-impl.h" # endif #endif /* THIS_IS_GTK */
--- a/src/depend Mon Mar 29 22:47:55 2010 -0500 +++ b/src/depend Mon Mar 29 22:52:01 2010 -0500 @@ -16,87 +16,87 @@ #if defined(HAVE_MS_WINDOWS) console-msw.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console-msw-impl.h console-msw.h console.h elhash.h events.h intl-auto-encap-win32.h keymap-buttons.h opaque.h specifier.h systime.h syswindows.h -device-msw.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-msw-impl.h console-msw.h console-stream.h console.h device-impl.h device.h devslots.h events.h faces.h frame.h intl-auto-encap-win32.h keymap-buttons.h objects-msw.h objects.h redisplay.h specifier.h sysdep.h systime.h syswindows.h +device-msw.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-msw-impl.h console-msw.h console-stream.h console.h device-impl.h device.h devslots.h events.h faces.h fontcolor-msw.h fontcolor.h frame.h intl-auto-encap-win32.h keymap-buttons.h redisplay.h specifier.h sysdep.h systime.h syswindows.h dialog-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h frame-impl.h frame.h frameslots.h gui.h intl-auto-encap-win32.h opaque.h redisplay.h specifier.h sysfile.h syswindows.h dired-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console-msw.h console.h intl-auto-encap-win32.h ndir.h regex.h syntax.h sysdir.h sysfile.h sysfloat.h sysproc.h syspwd.h syssignal.h systime.h syswindows.h -event-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console-stream-impl.h console-stream.h console.h device-impl.h device.h devslots.h dragdrop.h events.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gui.h intl-auto-encap-win32.h keymap-buttons.h lstream.h menubar.h objects-impl.h objects-msw-impl.h objects-msw.h objects.h process.h redisplay.h scrollbar-msw.h scrollbar.h specifier.h sysdep.h sysfile.h sysproc.h syssignal.h systime.h syswait.h syswindows.h window-impl.h window.h winslots.h +event-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console-stream-impl.h console-stream.h console.h device-impl.h device.h devslots.h dragdrop.h events.h faces.h fontcolor-impl.h fontcolor-msw-impl.h fontcolor-msw.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gui.h intl-auto-encap-win32.h keymap-buttons.h lstream.h menubar.h process.h redisplay.h scrollbar-msw.h scrollbar.h specifier.h sysdep.h sysfile.h sysproc.h syssignal.h systime.h syswait.h syswindows.h window-impl.h window.h winslots.h +fontcolor-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device-impl.h device.h devslots.h elhash.h fontcolor-impl.h fontcolor-msw-impl.h fontcolor-msw.h fontcolor.h insdel.h intl-auto-encap-win32.h opaque.h specifier.h syswindows.h frame-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h intl-auto-encap-win32.h keymap-buttons.h redisplay.h scrollbar.h specifier.h systime.h syswindows.h window-impl.h window.h winslots.h -glyphs-msw.o: $(CONFIG_H) $(LISP_H) charset.h coding-system-slots.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device-impl.h device.h devslots.h elhash.h faces.h file-coding.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h lstream.h objects-impl.h objects-msw-impl.h objects-msw.h objects.h opaque.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h syswindows.h window-impl.h window.h winslots.h +glyphs-msw.o: $(CONFIG_H) $(LISP_H) charset.h coding-system-slots.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device-impl.h device.h devslots.h elhash.h faces.h file-coding.h fontcolor-impl.h fontcolor-msw-impl.h fontcolor-msw.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h lstream.h opaque.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h syswindows.h window-impl.h window.h winslots.h gui-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h elhash.h events.h frame-impl.h frame.h frameslots.h glyphs.h gui.h intl-auto-encap-win32.h keymap-buttons.h redisplay.h scrollbar.h specifier.h systime.h syswindows.h window-impl.h window.h winslots.h menubar-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h elhash.h events.h frame-impl.h frame.h frameslots.h gui.h intl-auto-encap-win32.h keymap-buttons.h menubar.h opaque.h redisplay.h scrollbar.h specifier.h systime.h syswindows.h window-impl.h window.h winslots.h -objects-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device-impl.h device.h devslots.h elhash.h insdel.h intl-auto-encap-win32.h objects-impl.h objects-msw-impl.h objects-msw.h objects.h opaque.h specifier.h syswindows.h -redisplay-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h debug.h device-impl.h device.h devslots.h events.h faces.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h gutter.h intl-auto-encap-win32.h keymap-buttons.h objects-impl.h objects-msw-impl.h objects-msw.h objects.h redisplay.h scrollbar.h specifier.h sysdep.h systime.h syswindows.h window-impl.h window.h winslots.h +redisplay-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h debug.h device-impl.h device.h devslots.h events.h faces.h fontcolor-impl.h fontcolor-msw-impl.h fontcolor-msw.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h gutter.h intl-auto-encap-win32.h keymap-buttons.h redisplay.h scrollbar.h specifier.h sysdep.h systime.h syswindows.h window-impl.h window.h winslots.h scrollbar-msw.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device.h elhash.h events.h frame-impl.h frame.h frameslots.h intl-auto-encap-win32.h keymap-buttons.h opaque.h redisplay.h scrollbar-msw.h scrollbar.h specifier.h systime.h syswindows.h window-impl.h window.h winslots.h select-msw.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h file-coding.h frame-impl.h frame.h frameslots.h intl-auto-encap-win32.h opaque.h redisplay.h select.h specifier.h syswindows.h toolbar-msw.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h device.h elhash.h faces.h frame-impl.h frame.h frameslots.h glyphs-msw.h glyphs.h gui.h intl-auto-encap-win32.h redisplay.h scrollbar.h specifier.h syswindows.h toolbar.h window-impl.h window.h winslots.h #endif #if defined(HAVE_XLIKE) event-xlike-inc.o: -objects-xlike-inc.o: $(LWLIB_SRCDIR)/lwlib.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h -redisplay-xlike-inc.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +fontcolor-xlike-inc.o: $(LWLIB_SRCDIR)/lwlib.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h +redisplay-xlike-inc.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h redisplay.h scrollbar.h specifier.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h select-xlike-inc.o: toolbar-xlike.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h faces.h frame-impl.h frame.h frameslots.h glyphs.h redisplay.h scrollbar.h specifier.h sysgtk.h toolbar-xlike.h toolbar.h window-impl.h window.h winslots.h xintrinsic.h #endif #if defined(HAVE_X_WINDOWS) -EmacsFrame.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h EmacsManager.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h faces.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h toolbar.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +EmacsFrame.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h EmacsManager.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h faces.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h redisplay.h scrollbar.h specifier.h toolbar.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h EmacsManager.o: $(CONFIG_H) $(LWLIB_SRCDIR)/lwlib.h EmacsManager.h EmacsManagerP.h compiler.h xintrinsicp.h xmmanagerp.h xmotif.h xmprimitivep.h EmacsShell-sub.o: $(CONFIG_H) $(LWLIB_SRCDIR)/lwlib.h EmacsShell.h EmacsShellP.h xintrinsic.h xintrinsicp.h EmacsShell.o: $(CONFIG_H) EmacsShell.h ExternalShell.h xintrinsicp.h balloon-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h balloon_help.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h specifier.h xintrinsic.h balloon_help.o: $(CONFIG_H) balloon_help.h compiler.h xintrinsic.h console-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h elhash.h process.h redisplay.h specifier.h xintrinsic.h -device-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gccache-x.h glyphs-x.h glyphs.h intl-auto-encap-win32.h keymap-buttons.h objects-x.h objects.h process.h redisplay.h scrollbar.h specifier.h sysdep.h sysdll.h sysfile.h systime.h syswindows.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h +device-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h file-coding.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h gccache-x.h glyphs-x.h glyphs.h intl-auto-encap-win32.h keymap-buttons.h process.h redisplay.h scrollbar.h specifier.h sysdep.h sysdll.h sysfile.h systime.h syswindows.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h dialog-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console-x-impl.h console-x.h console.h events.h frame-impl.h frame.h frameslots.h gui.h keymap-buttons.h opaque.h redisplay.h scrollbar.h specifier.h systime.h window.h xintrinsic.h -frame-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h EmacsManager.h EmacsShell.h ExternalShell.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dragdrop.h events.h extents.h faces.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h gutter.h keymap-buttons.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay.h scrollbar-x.h scrollbar.h specifier.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +fontcolor-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h elhash.h font-mgr.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor-xlike-inc.c fontcolor.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h +frame-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h EmacsManager.h EmacsShell.h ExternalShell.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dragdrop.h events.h extents.h faces.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h gutter.h keymap-buttons.h redisplay.h scrollbar-x.h scrollbar.h specifier.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h gccache-x.o: $(CONFIG_H) $(LISP_H) gccache-x.h hash.h -glyphs-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h bitmaps.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h faces.h file-coding.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h lstream.h objects-impl.h objects-x-impl.h objects-x.h objects.h opaque.h process.h redisplay.h scrollbar.h specifier.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h window-impl.h window.h winslots.h xintrinsic.h xmotif.h +glyphs-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h bitmaps.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h faces.h file-coding.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h lstream.h opaque.h process.h redisplay.h scrollbar.h specifier.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h window-impl.h window.h winslots.h xintrinsic.h xmotif.h gui-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h events.h frame.h glyphs.h gui.h keymap-buttons.h menubar.h opaque.h redisplay.h scrollbar.h specifier.h systime.h window-impl.h window.h winslots.h xintrinsic.h xmotif.h intl-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h console-x.h console.h xintrinsic.h menubar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h gui.h keymap-buttons.h keymap.h menubar.h opaque.h redisplay.h scrollbar.h specifier.h systime.h window-impl.h window.h winslots.h xintrinsic.h -objects-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h elhash.h font-mgr.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects-xlike-inc.c objects.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h -redisplay-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +redisplay-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h sysdep.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h scrollbar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h redisplay.h scrollbar-x.h scrollbar.h specifier.h window-impl.h window.h winslots.h xintrinsic.h -select-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h frame-impl.h frame.h frameslots.h objects-x.h objects.h opaque.h redisplay.h select-xlike-inc.c select.h specifier.h systime.h xintrinsic.h xmotif.h -toolbar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h faces.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h objects-x.h objects.h redisplay.h scrollbar.h specifier.h toolbar-xlike.h toolbar.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +select-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h opaque.h redisplay.h select-xlike-inc.c select.h specifier.h systime.h xintrinsic.h xmotif.h +toolbar-x.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h charset.h conslots.h console-impl.h console-x-impl.h console-x.h console.h faces.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-x.h glyphs.h redisplay.h scrollbar.h specifier.h toolbar-xlike.h toolbar.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h #endif #if defined(HAVE_TTY) console-tty.o: $(CONFIG_H) $(LISP_H) charset.h coding-system-slots.h conslots.h console-impl.h console-stream.h console-tty-impl.h console-tty.h console.h elhash.h faces.h file-coding.h frame.h glyphs.h intl-auto-encap-win32.h lstream.h process.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h systty.h syswindows.h window-impl.h window.h winslots.h device-tty.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-stream.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h faces.h frame.h intl-auto-encap-win32.h keymap-buttons.h lstream.h redisplay.h specifier.h sysdep.h sysfile.h syssignal.h systime.h systty.h syswindows.h event-tty.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device.h events.h frame.h keymap-buttons.h process.h redisplay.h specifier.h sysproc.h syssignal.h systime.h systty.h syswait.h +fontcolor-tty.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device.h fontcolor-impl.h fontcolor-tty-impl.h fontcolor-tty.h fontcolor.h insdel.h specifier.h systty.h frame-tty.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h keymap-buttons.h redisplay.h specifier.h systime.h systty.h -objects-tty.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device.h insdel.h objects-impl.h objects-tty-impl.h objects-tty.h objects.h specifier.h systty.h -redisplay-tty.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h faces.h frame-impl.h frame.h frameslots.h glyphs.h keymap-buttons.h lstream.h objects-impl.h objects-tty-impl.h objects-tty.h objects.h redisplay.h scrollbar.h specifier.h sysdep.h syssignal.h systime.h systty.h window-impl.h window.h winslots.h +redisplay-tty.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h faces.h fontcolor-impl.h fontcolor-tty-impl.h fontcolor-tty.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h keymap-buttons.h lstream.h redisplay.h scrollbar.h specifier.h sysdep.h syssignal.h systime.h systty.h window-impl.h window.h winslots.h #endif #if defined(HAVE_GTK) console-gtk.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h elhash.h process.h redisplay.h specifier.h sysgtk.h -device-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h frame-impl.h frame.h frameslots.h gccache-gtk.h glyphs-gtk.h glyphs.h gtk-xemacs.h intl-auto-encap-win32.h keymap-buttons.h objects-gtk.h objects.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h sysgdkx.h sysgtk.h systime.h syswindows.h window-impl.h window.h winslots.h +device-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h fontcolor-gtk.h fontcolor.h frame-impl.h frame.h frameslots.h gccache-gtk.h glyphs-gtk.h glyphs.h gtk-xemacs.h intl-auto-encap-win32.h keymap-buttons.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h sysgdkx.h sysgtk.h systime.h syswindows.h window-impl.h window.h winslots.h dialog-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h events.h frame.h gui.h keymap-buttons.h opaque.h redisplay.h scrollbar.h specifier.h sysgtk.h systime.h window.h emacs-marshals.o: hash.h emacs-widget-accessors.o: -event-gtk.o: $(CONFIG_H) $(LISP_H) blocktype.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h commands.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-tty.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h event-xlike-inc.c events.h file-coding.h frame-impl.h frame.h frameslots.h gtk-xemacs.h gui.h keymap-buttons.h lstream.h menubar.h objects-gtk.h objects.h process.h redisplay.h scrollbar.h specifier.h sysgdkx.h sysgtk.h sysproc.h syssignal.h systime.h systty.h window.h -frame-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h events.h extents.h faces.h frame-impl.h frame.h frameslots.h glyphs-gtk.h glyphs.h gtk-xemacs.h keymap-buttons.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects.h redisplay.h scrollbar-gtk.h scrollbar.h specifier.h sysdll.h sysgdkx.h sysgtk.h systime.h ui-gtk.h window-impl.h window.h winslots.h +event-gtk.o: $(CONFIG_H) $(LISP_H) blocktype.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h commands.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-tty.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h event-xlike-inc.c events.h file-coding.h fontcolor-gtk.h fontcolor.h frame-impl.h frame.h frameslots.h gtk-xemacs.h gui.h keymap-buttons.h lstream.h menubar.h process.h redisplay.h scrollbar.h specifier.h sysgdkx.h sysgtk.h sysproc.h syssignal.h systime.h systty.h window.h +fontcolor-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor-xlike-inc.c fontcolor.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h redisplay.h scrollbar.h specifier.h sysgdkx.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h +frame-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h events.h extents.h faces.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-gtk.h glyphs.h gtk-xemacs.h keymap-buttons.h redisplay.h scrollbar-gtk.h scrollbar.h specifier.h sysdll.h sysgdkx.h sysgtk.h systime.h ui-gtk.h window-impl.h window.h winslots.h gccache-gtk.o: $(CONFIG_H) $(LISP_H) gccache-gtk.h hash.h sysgtk.h glade.o: bytecode.h -glyphs-gtk.o: $(CONFIG_H) $(LISP_H) bitmaps.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h file-coding.h frame-impl.h frame.h frameslots.h glyphs-gtk.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h keymap-buttons.h lstream.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects.h opaque.h redisplay.h scrollbar.h specifier.h sysdll.h sysfile.h sysgdkx.h sysgtk.h systime.h syswindows.h ui-gtk.h window-impl.h window.h winslots.h -gtk-glue.o: console-gtk.h console.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects.h specifier.h sysgtk.h -gtk-xemacs.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gtk-xemacs.h objects-gtk.h objects.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h +glyphs-gtk.o: $(CONFIG_H) $(LISP_H) bitmaps.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h file-coding.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs-gtk.h glyphs.h gui.h imgproc.h insdel.h intl-auto-encap-win32.h keymap-buttons.h lstream.h opaque.h redisplay.h scrollbar.h specifier.h sysdll.h sysfile.h sysgdkx.h sysgtk.h systime.h syswindows.h ui-gtk.h window-impl.h window.h winslots.h +gtk-glue.o: console-gtk.h console.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor.h specifier.h sysgtk.h +gtk-xemacs.o: $(CONFIG_H) $(LISP_H) charset.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h faces.h fontcolor-gtk.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gtk-xemacs.h redisplay.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h gui-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h frame.h gui.h opaque.h redisplay.h specifier.h sysgtk.h menubar-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h gui.h keymap-buttons.h menubar.h opaque.h redisplay.h scrollbar.h specifier.h sysdll.h sysgtk.h systime.h ui-gtk.h window-impl.h window.h winslots.h -native-gtk-toolbar.o: $(CONFIG_H) $(LISP_H) charset.h console-gtk.h console.h faces.h frame.h glyphs-gtk.h glyphs.h objects-gtk.h objects.h redisplay.h scrollbar.h specifier.h sysgtk.h toolbar.h window-impl.h window.h winslots.h -objects-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h device-impl.h device.h devslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h insdel.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects-xlike-inc.c objects.h redisplay.h scrollbar.h specifier.h sysgdkx.h sysgtk.h window-impl.h window.h winslots.h xintrinsic.h -redisplay-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects-x-impl.h objects-x.h objects.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h sysdep.h sysgdkx.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h +native-gtk-toolbar.o: $(CONFIG_H) $(LISP_H) charset.h console-gtk.h console.h faces.h fontcolor-gtk.h fontcolor.h frame.h glyphs-gtk.h glyphs.h redisplay.h scrollbar.h specifier.h sysgtk.h toolbar.h window-impl.h window.h winslots.h +redisplay-gtk.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h EmacsFrameP.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-x-impl.h console-x.h console-xlike-inc.h console.h debug.h device-impl.h device.h devslots.h faces.h file-coding.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h gccache-gtk.h gccache-x.h glyphs-gtk.h glyphs-x.h glyphs.h gutter.h mule-ccl.h redisplay-xlike-inc.c redisplay.h scrollbar.h specifier.h sysdep.h sysgdkx.h sysgtk.h sysproc.h syssignal.h systime.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h xmprimitivep.h scrollbar-gtk.o: $(CONFIG_H) $(LISP_H) conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h frame-impl.h frame.h frameslots.h glyphs-gtk.h glyphs.h redisplay.h scrollbar-gtk.h scrollbar.h specifier.h sysgtk.h window-impl.h window.h winslots.h select-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device-impl.h device.h devslots.h events.h frame.h keymap-buttons.h opaque.h redisplay.h select-xlike-inc.c select.h specifier.h sysgtk.h systime.h toolbar-gtk.o: $(CONFIG_H) $(LISP_H) conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h frame.h redisplay.h specifier.h sysgtk.h toolbar-xlike.h ui-byhand.o: gui.h -ui-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device.h elhash.h emacs-marshals.c emacs-widget-accessors.c events.h faces.h glade.c glyphs-gtk.h glyphs.h gtk-glue.c gui.h hash.h keymap-buttons.h objects-gtk-impl.h objects-gtk.h objects-impl.h objects.h redisplay.h scrollbar.h specifier.h sysdll.h sysgtk.h systime.h ui-byhand.c ui-gtk.h window-impl.h window.h winslots.h +ui-gtk.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console.h device.h elhash.h emacs-marshals.c emacs-widget-accessors.c events.h faces.h fontcolor-gtk-impl.h fontcolor-gtk.h fontcolor-impl.h fontcolor.h glade.c glyphs-gtk.h glyphs.h gtk-glue.c gui.h hash.h keymap-buttons.h redisplay.h scrollbar.h specifier.h sysdll.h sysgtk.h systime.h ui-byhand.c ui-gtk.h window-impl.h window.h winslots.h #endif #if defined(HAVE_DATABASE) database.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h database.h file-coding.h intl-auto-encap-win32.h sysfile.h syswindows.h #endif #if defined(MULE) mule-ccl.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h elhash.h file-coding.h mule-ccl.h -mule-charset.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console.h device.h elhash.h faces.h lstream.h mule-ccl.h objects.h specifier.h +mule-charset.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console.h device.h elhash.h faces.h fontcolor.h lstream.h mule-ccl.h specifier.h mule-coding.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h elhash.h extents.h file-coding.h mule-ccl.h rangetab.h mule-wnnfns.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h redisplay.h scrollbar.h sysdep.h window.h #endif @@ -126,7 +126,7 @@ console.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-stream-impl.h console-stream.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h keymap-buttons.h redisplay.h scrollbar.h specifier.h sysdep.h systime.h systty.h window.h data.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h sysfloat.h syssignal.h debug.o: $(CONFIG_H) $(LISP_H) bytecode.h debug.h -device.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h frame-impl.h frame.h frameslots.h keymap-buttons.h keymap.h objects.h redisplay.h scrollbar.h specifier.h sysdep.h syssignal.h systime.h toolbar.h window.h +device.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h faces.h fontcolor.h frame-impl.h frame.h frameslots.h keymap-buttons.h keymap.h redisplay.h scrollbar.h specifier.h sysdep.h syssignal.h systime.h toolbar.h window.h dialog.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console.h frame-impl.h frame.h frameslots.h redisplay.h specifier.h dired.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h elhash.h intl-auto-encap-win32.h ndir.h opaque.h regex.h syntax.h sysdep.h sysdir.h sysfile.h syspwd.h systime.h syswindows.h doc.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h coding-system-slots.h file-coding.h insdel.h intl-auto-encap-win32.h keymap-buttons.h keymap.h lstream.h sysfile.h syswindows.h @@ -141,12 +141,12 @@ emodules.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h console.h emodules.h file-coding.h frame.h insdel.h lstream.h redisplay.h scrollbar.h sysdep.h sysdll.h window.h esd.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h intl-auto-encap-win32.h miscplay.h sound.h sysfile.h syswindows.h eval.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console.h device.h frame.h lstream.h opaque.h profile.h redisplay.h scrollbar.h specifier.h window.h -event-Xt.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h Emacs.ad.h EmacsFrame.h blocktype.h charset.h coding-system-slots.h conslots.h console-impl.h console-tty.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h event-xlike-inc.c events.h file-coding.h frame-impl.h frame.h frameslots.h glyphs.h keymap-buttons.h lstream.h objects-x.h objects.h process.h redisplay.h scrollbar.h specifier.h sysproc.h syssignal.h systime.h systty.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h +event-Xt.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h Emacs.ad.h EmacsFrame.h blocktype.h charset.h coding-system-slots.h conslots.h console-impl.h console-tty.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h dragdrop.h elhash.h event-xlike-inc.c events.h file-coding.h fontcolor-x.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h keymap-buttons.h lstream.h process.h redisplay.h scrollbar.h specifier.h sysproc.h syssignal.h systime.h systty.h window-impl.h window.h winslots.h xintrinsic.h xintrinsicp.h xmotif.h event-stream.o: $(CONFIG_H) $(LISP_H) backtrace.h blocktype.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h commands.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h events.h file-coding.h frame-impl.h frame.h frameslots.h gui.h insdel.h intl-auto-encap-win32.h keymap-buttons.h keymap.h lstream.h macros.h menubar.h process.h profile.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h syssignal.h systime.h syswindows.h window-impl.h window.h winslots.h event-unixoid.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console-stream-impl.h console-stream.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h intl-auto-encap-win32.h keymap-buttons.h lstream.h process.h specifier.h sysdep.h sysfile.h sysproc.h syssignal.h systime.h systty.h syswindows.h events.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device.h events.h extents.h frame-impl.h frame.h frameslots.h glyphs.h keymap-buttons.h keymap.h lstream.h redisplay.h scrollbar.h specifier.h systime.h systty.h toolbar.h window-impl.h window.h winslots.h extents.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h casetab.h charset.h chartab.h console.h debug.h device.h elhash.h extents-impl.h extents.h faces.h frame.h glyphs.h gutter.h insdel.h keymap-buttons.h keymap.h opaque.h process.h profile.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h -faces.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h extents-impl.h extents.h faces.h frame-impl.h frame.h frameslots.h glyphs.h objects-impl.h objects.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h +faces.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h extents-impl.h extents.h faces.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h file-coding.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h elhash.h extents.h file-coding.h insdel.h lstream.h opaque.h rangetab.h fileio.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h console.h device.h events.h file-coding.h frame.h insdel.h intl-auto-encap-win32.h keymap-buttons.h lstream.h ndir.h process.h profile.h redisplay.h scrollbar.h sysdep.h sysdir.h sysfile.h sysproc.h syspwd.h syssignal.h systime.h syswindows.h window-impl.h window.h winslots.h filelock.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h intl-auto-encap-win32.h ndir.h paths.h sysdir.h sysfile.h sysproc.h syspwd.h syssignal.h systime.h syswindows.h @@ -154,16 +154,17 @@ floatfns.o: $(CONFIG_H) $(LISP_H) sysfloat.h syssignal.h fns.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h console.h device.h events.h extents.h frame.h insdel.h intl-auto-encap-win32.h keymap-buttons.h lstream.h opaque.h process.h redisplay.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h font-lock.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h insdel.h syntax.h -font-mgr.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h font-mgr.h hash.h intl-auto-encap-win32.h objects-impl.h objects-x-impl.h objects-x.h objects.h specifier.h sysfile.h syswindows.h xintrinsic.h +font-mgr.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h font-mgr.h fontcolor-impl.h fontcolor-x-impl.h fontcolor-x.h fontcolor.h hash.h intl-auto-encap-win32.h specifier.h sysfile.h syswindows.h xintrinsic.h +fontcolor.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-tty.h console.h device-impl.h device.h devslots.h elhash.h faces.h fontcolor-impl.h fontcolor.h frame.h glyphs.h redisplay.h scrollbar.h specifier.h systty.h window-impl.h window.h winslots.h frame.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h events.h extents.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gui.h gutter.h keymap-buttons.h menubar.h process.h redisplay.h scrollbar.h specifier.h systime.h toolbar.h window-impl.h window.h winslots.h free-hook.o: $(CONFIG_H) $(LISP_H) hash.h gc.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console-stream.h console.h device.h elhash.h events.h extents-impl.h extents.h file-coding.h frame-impl.h frame.h frameslots.h glyphs.h intl-auto-encap-win32.h keymap-buttons.h lstream.h opaque.h process.h profile.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h systime.h syswindows.h window-impl.h window.h winslots.h general.o: $(CONFIG_H) $(LISP_H) general-slots.h getloadavg.o: $(CONFIG_H) $(LISP_H) intl-auto-encap-win32.h sysfile.h syswindows.h -glyphs-eimage.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h faces.h file-coding.h frame.h glyphs.h intl-auto-encap-win32.h lstream.h objects-impl.h objects.h opaque.h redisplay.h scrollbar.h specifier.h sysfile.h syswindows.h window-impl.h window.h winslots.h +glyphs-eimage.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h faces.h file-coding.h fontcolor-impl.h fontcolor.h frame.h glyphs.h intl-auto-encap-win32.h lstream.h opaque.h redisplay.h scrollbar.h specifier.h sysfile.h syswindows.h window-impl.h window.h winslots.h glyphs-shared.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console.h elhash.h faces.h frame.h glyphs.h imgproc.h insdel.h intl-auto-encap-win32.h lstream.h opaque.h redisplay.h scrollbar.h specifier.h sysdep.h sysfile.h syswindows.h window-impl.h window.h winslots.h -glyphs-widget.o: $(CONFIG_H) $(LISP_H) bytecode.h charset.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h faces.h frame.h glyphs.h gui.h insdel.h lstream.h objects.h opaque.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h -glyphs.o: $(CONFIG_H) $(LISP_H) blocktype.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gui.h insdel.h intl-auto-encap-win32.h objects-impl.h objects.h opaque.h rangetab.h redisplay.h scrollbar.h specifier.h sysfile.h syswindows.h window-impl.h window.h winslots.h +glyphs-widget.o: $(CONFIG_H) $(LISP_H) bytecode.h charset.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h faces.h fontcolor.h frame.h glyphs.h gui.h insdel.h lstream.h opaque.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h +glyphs.o: $(CONFIG_H) $(LISP_H) blocktype.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h faces.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gui.h insdel.h intl-auto-encap-win32.h opaque.h rangetab.h redisplay.h scrollbar.h specifier.h sysfile.h syswindows.h window-impl.h window.h winslots.h gmalloc.o: $(CONFIG_H) $(LISP_H) getpagesize.h sysdep.h gpmevent.o: $(CONFIG_H) $(LISP_H) commands.h conslots.h console-impl.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h events.h frame.h gpmevent.h keymap-buttons.h lstream.h process.h redisplay.h specifier.h sysdep.h sysproc.h syssignal.h systime.h systty.h gui.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h elhash.h gui.h menubar.h redisplay.h @@ -172,13 +173,13 @@ hpplay.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h sound.h imgproc.o: $(CONFIG_H) $(LISP_H) imgproc.h indent.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console.h device.h extents.h faces.h frame.h glyphs.h insdel.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h -inline.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-msw-impl.h console-msw.h console-stream-impl.h console-stream.h console-tty-impl.h console-tty.h console-x-impl.h console-x.h console.h database.h device-impl.h device.h devslots.h elhash.h events.h extents-impl.h extents.h faces.h file-coding.h font-mgr.h frame-impl.h frame.h frameslots.h glyphs.h gui.h intl-auto-encap-win32.h keymap-buttons.h keymap.h lstream.h objects-impl.h objects-tty-impl.h objects-tty.h objects.h opaque.h process.h rangetab.h redisplay.h scrollbar.h specifier.h syntax.h sysdll.h sysfile.h sysgtk.h systime.h systty.h syswindows.h toolbar.h tooltalk.h ui-gtk.h window-impl.h window.h winslots.h xintrinsic.h +inline.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h coding-system-slots.h conslots.h console-gtk-impl.h console-gtk.h console-impl.h console-msw-impl.h console-msw.h console-stream-impl.h console-stream.h console-tty-impl.h console-tty.h console-x-impl.h console-x.h console.h database.h device-impl.h device.h devslots.h elhash.h events.h extents-impl.h extents.h faces.h file-coding.h font-mgr.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gui.h intl-auto-encap-win32.h keymap-buttons.h keymap.h lstream.h opaque.h process.h rangetab.h redisplay.h scrollbar.h specifier.h syntax.h sysdll.h sysfile.h sysgtk.h systime.h systty.h syswindows.h toolbar.h tooltalk.h ui-gtk.h window-impl.h window.h winslots.h xintrinsic.h input-method-motif.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device.h frame-impl.h frame.h frameslots.h redisplay.h specifier.h xintrinsic.h xmotif.h input-method-xlib.o: $(CONFIG_H) $(LISP_H) $(LWLIB_SRCDIR)/lwlib.h EmacsFrame.h buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-x-impl.h console-x.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h keymap-buttons.h redisplay.h scrollbar.h specifier.h systime.h window-impl.h window.h winslots.h xintrinsic.h insdel.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h console.h device.h extents.h frame.h insdel.h line-number.h lstream.h redisplay.h intl-auto-encap-win32.o: $(CONFIG_H) $(LISP_H) intl-auto-encap-win32.h syswindows.h intl-encap-win32.o: $(CONFIG_H) $(LISP_H) console-msw.h console.h intl-auto-encap-win32.h syswindows.h -intl-win32.o: $(CONFIG_H) $(LISP_H) charset.h coding-system-slots.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h elhash.h faces.h file-coding.h frame-impl.h frame.h frameslots.h intl-auto-encap-win32.h objects-impl.h objects-msw-impl.h objects-msw.h objects.h redisplay.h scrollbar.h specifier.h syswindows.h window-impl.h window.h winslots.h +intl-win32.o: $(CONFIG_H) $(LISP_H) charset.h coding-system-slots.h conslots.h console-impl.h console-msw-impl.h console-msw.h console.h elhash.h faces.h file-coding.h fontcolor-impl.h fontcolor-msw-impl.h fontcolor-msw.h fontcolor.h frame-impl.h frame.h frameslots.h intl-auto-encap-win32.h redisplay.h scrollbar.h specifier.h syswindows.h window-impl.h window.h winslots.h intl.o: $(CONFIG_H) $(LISP_H) keymap.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h elhash.h events.h extents.h frame.h insdel.h keymap-buttons.h keymap-slots.h keymap.h redisplay.h scrollbar.h specifier.h systime.h window.h lastfile.o: $(CONFIG_H) @@ -202,7 +203,6 @@ number-gmp.o: $(CONFIG_H) $(LISP_H) sysproc.h syssignal.h systime.h number-mp.o: $(CONFIG_H) $(LISP_H) number.o: $(CONFIG_H) $(LISP_H) -objects.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console-tty.h console.h device-impl.h device.h devslots.h elhash.h faces.h frame.h glyphs.h objects-impl.h objects.h redisplay.h scrollbar.h specifier.h systty.h window-impl.h window.h winslots.h opaque.o: $(CONFIG_H) $(LISP_H) opaque.h print.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h bytecode.h casetab.h charset.h chartab.h conslots.h console-impl.h console-msw.h console-stream-impl.h console-stream.h console-tty-impl.h console-tty.h console.h device-impl.h device.h devslots.h extents.h frame.h insdel.h intl-auto-encap-win32.h lstream.h opaque.h redisplay.h specifier.h sysfile.h systty.h syswindows.h process-nt.o: $(CONFIG_H) $(LISP_H) console-msw.h console.h events.h hash.h intl-auto-encap-win32.h keymap-buttons.h lstream.h process-slots.h process.h procimpl.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h @@ -213,11 +213,11 @@ rangetab.o: $(CONFIG_H) $(LISP_H) rangetab.h realpath.o: $(CONFIG_H) $(LISP_H) backtrace.h intl-auto-encap-win32.h ndir.h profile.h sysdir.h sysfile.h syswindows.h redisplay-output.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gutter.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h -redisplay.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h commands.h conslots.h console-impl.h console-tty.h console.h debug.h device-impl.h device.h devslots.h elhash.h events.h extents-impl.h extents.h faces.h file-coding.h frame-impl.h frame.h frameslots.h glyphs.h gui.h gutter.h insdel.h intl-auto-encap-win32.h keymap-buttons.h line-number.h menubar.h objects-impl.h objects.h opaque.h process.h profile.h redisplay.h scrollbar.h specifier.h sysfile.h systime.h systty.h syswindows.h toolbar.h window-impl.h window.h winslots.h +redisplay.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h casetab.h charset.h chartab.h coding-system-slots.h commands.h conslots.h console-impl.h console-tty.h console.h debug.h device-impl.h device.h devslots.h elhash.h events.h extents-impl.h extents.h faces.h file-coding.h fontcolor-impl.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gui.h gutter.h insdel.h intl-auto-encap-win32.h keymap-buttons.h line-number.h menubar.h opaque.h process.h profile.h redisplay.h scrollbar.h specifier.h sysfile.h systime.h systty.h syswindows.h toolbar.h window-impl.h window.h winslots.h regex.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h regex.h syntax.h scrollbar.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h frame-impl.h frame.h frameslots.h glyphs.h gutter.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h search.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h insdel.h opaque.h regex.h syntax.h -select.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h extents.h frame.h objects.h opaque.h redisplay.h select.h specifier.h +select.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h extents.h fontcolor.h frame.h opaque.h redisplay.h select.h specifier.h sgiplay.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h intl-auto-encap-win32.h libst.h sound.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h sheap.o: $(CONFIG_H) $(LISP_H) intl-auto-encap-win32.h sheap-adjust.h sysfile.h syswindows.h signal.o: $(CONFIG_H) $(LISP_H) conslots.h console-impl.h console.h device-impl.h device.h devslots.h events.h frame-impl.h frame.h frameslots.h intl-auto-encap-win32.h keymap-buttons.h process.h redisplay.h specifier.h sysdep.h sysfile.h syssignal.h systime.h syswindows.h @@ -256,4 +256,4 @@ vm-limit.o: $(CONFIG_H) $(LISP_H) mem-limits.h widget.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h win32.o: $(CONFIG_H) $(LISP_H) backtrace.h buffer.h bufslots.h casetab.h charset.h chartab.h console-msw.h console.h hash.h intl-auto-encap-win32.h profile.h sysfile.h sysproc.h syssignal.h systime.h syswindows.h -window.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h faces.h frame-impl.h frame.h frameslots.h glyphs.h gutter.h objects.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h +window.o: $(CONFIG_H) $(LISP_H) buffer.h bufslots.h casetab.h charset.h chartab.h commands.h conslots.h console-impl.h console.h device-impl.h device.h devslots.h elhash.h faces.h fontcolor.h frame-impl.h frame.h frameslots.h glyphs.h gutter.h redisplay.h scrollbar.h specifier.h window-impl.h window.h winslots.h
--- a/src/device-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/device-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -42,7 +42,7 @@ #include "console-gtk-impl.h" #include "gccache-gtk.h" #include "glyphs-gtk.h" -#include "objects-gtk.h" +#include "fontcolor-gtk.h" #include "gtk-xemacs.h" #include "sysfile.h"
--- a/src/device-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/device-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -45,7 +45,7 @@ #include "console-msw-impl.h" #include "console-stream.h" -#include "objects-msw.h" +#include "fontcolor-msw.h" #include "sysdep.h"
--- a/src/device-x.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/device-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -44,7 +44,7 @@ #include "console-x-impl.h" #include "glyphs-x.h" -#include "objects-x.h" +#include "fontcolor-x.h" #include "sysfile.h" #include "systime.h" @@ -922,7 +922,7 @@ DEVICE_X_GRAY_PIXMAP (d) = None; Xatoms_of_device_x (d); Xatoms_of_select_x (d); - Xatoms_of_objects_x (d); + Xatoms_of_fontcolor_x (d); x_init_device_class (d); }
--- a/src/device.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/device.c Mon Mar 29 22:52:01 2010 -0500 @@ -38,7 +38,7 @@ #include "faces.h" #include "frame-impl.h" #include "keymap.h" -#include "objects.h" +#include "fontcolor.h" #include "redisplay.h" #include "specifier.h" #include "sysdep.h"
--- a/src/devslots.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/devslots.h Mon Mar 29 22:52:01 2010 -0500 @@ -106,7 +106,7 @@ to determine an appropriate font. */ MARKED_SLOT (charset_font_cache_stage_1) - /* Similar cache for stage 2, if it exists. See objects.c. */ + /* Similar cache for stage 2, if it exists. See fontcolor.c. */ MARKED_SLOT (charset_font_cache_stage_2) #endif
--- a/src/emacs.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/emacs.c Mon Mar 29 22:52:01 2010 -0500 @@ -1587,7 +1587,7 @@ #ifdef WITH_NUMBER_TYPES syms_of_number (); #endif - syms_of_objects (); + syms_of_fontcolor (); syms_of_print (); syms_of_process (); #ifdef HAVE_WIN32_PROCESSES @@ -1621,14 +1621,14 @@ syms_of_console_tty (); syms_of_device_tty (); syms_of_frame_tty (); - syms_of_objects_tty (); + syms_of_fontcolor_tty (); #endif #ifdef HAVE_GTK syms_of_device_gtk (); syms_of_frame_gtk (); syms_of_glyphs_gtk (); - syms_of_objects_gtk (); + syms_of_fontcolor_gtk (); syms_of_ui_gtk (); syms_of_select_gtk (); #ifdef HAVE_DIALOGS @@ -1654,7 +1654,7 @@ #endif syms_of_frame_x (); syms_of_glyphs_x (); - syms_of_objects_x (); + syms_of_fontcolor_x (); #ifdef HAVE_MENUBARS syms_of_menubar_x (); #endif @@ -1683,7 +1683,7 @@ syms_of_dialog_mswindows (); #endif syms_of_frame_mswindows (); - syms_of_objects_mswindows (); + syms_of_fontcolor_mswindows (); syms_of_select_mswindows (); syms_of_glyphs_mswindows (); #ifdef HAVE_GUI_OBJECTS @@ -1807,7 +1807,7 @@ console_type_create_tty (); console_type_create_device_tty (); console_type_create_frame_tty (); - console_type_create_objects_tty (); + console_type_create_fontcolor_tty (); console_type_create_redisplay_tty (); #endif @@ -1816,7 +1816,7 @@ console_type_create_select_gtk (); console_type_create_device_gtk (); console_type_create_frame_gtk (); - console_type_create_objects_gtk (); + console_type_create_fontcolor_gtk (); console_type_create_glyphs_gtk (); console_type_create_redisplay_gtk (); #ifdef HAVE_MENUBARS @@ -1842,7 +1842,7 @@ #ifdef HAVE_MENUBARS console_type_create_menubar_x (); #endif - console_type_create_objects_x (); + console_type_create_fontcolor_x (); console_type_create_redisplay_x (); #ifdef HAVE_SCROLLBARS console_type_create_scrollbar_x (); @@ -1859,7 +1859,7 @@ console_type_create_mswindows (); console_type_create_device_mswindows (); console_type_create_frame_mswindows (); - console_type_create_objects_mswindows (); + console_type_create_fontcolor_mswindows (); console_type_create_redisplay_mswindows (); console_type_create_glyphs_mswindows (); console_type_create_select_mswindows (); @@ -1891,7 +1891,7 @@ specifier_type_create_image (); specifier_type_create_gutter (); - specifier_type_create_objects (); + specifier_type_create_fontcolor (); #ifdef HAVE_TOOLBARS specifier_type_create_toolbar (); #endif @@ -1966,7 +1966,7 @@ reinit_specifier_type_create (); reinit_specifier_type_create_image (); reinit_specifier_type_create_gutter (); - reinit_specifier_type_create_objects (); + reinit_specifier_type_create_fontcolor (); #ifdef HAVE_TOOLBARS reinit_specifier_type_create_toolbar (); #endif @@ -2190,7 +2190,7 @@ #ifdef WITH_NUMBER_TYPES vars_of_number (); #endif - vars_of_objects (); + vars_of_fontcolor (); vars_of_print (); vars_of_process (); @@ -2229,7 +2229,7 @@ #ifdef HAVE_TTY vars_of_console_tty (); vars_of_frame_tty (); - vars_of_objects_tty (); + vars_of_fontcolor_tty (); #endif #ifdef HAVE_GTK @@ -2245,7 +2245,7 @@ #ifdef HAVE_MENUBARS vars_of_menubar_gtk (); #endif - vars_of_objects_gtk (); + vars_of_fontcolor_gtk (); vars_of_select_gtk (); #ifdef HAVE_SCROLLBARS vars_of_scrollbar_gtk (); @@ -2269,7 +2269,7 @@ #ifdef HAVE_MENUBARS vars_of_menubar_x (); #endif - vars_of_objects_x (); + vars_of_fontcolor_x (); vars_of_select_x (); #ifdef HAVE_SCROLLBARS vars_of_scrollbar_x (); @@ -2289,7 +2289,7 @@ vars_of_device_mswindows (); vars_of_console_mswindows (); vars_of_frame_mswindows (); - vars_of_objects_mswindows (); + vars_of_fontcolor_mswindows (); vars_of_select_mswindows (); vars_of_glyphs_mswindows (); #ifdef HAVE_SCROLLBARS @@ -2378,7 +2378,7 @@ #ifdef HAVE_SHLIB reinit_vars_of_module (); #endif - reinit_vars_of_objects (); + reinit_vars_of_fontcolor (); reinit_vars_of_print (); reinit_vars_of_search (); reinit_vars_of_text (); @@ -2388,7 +2388,7 @@ #ifdef HAVE_MS_WINDOWS reinit_vars_of_event_mswindows (); reinit_vars_of_frame_mswindows (); - reinit_vars_of_object_mswindows (); + reinit_vars_of_fontcolor_mswindows (); #endif #ifdef HAVE_GTK
--- a/src/event-Xt.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/event-Xt.c Mon Mar 29 22:52:01 2010 -0500 @@ -51,7 +51,7 @@ #include "console-tty.h" #include "console-x-impl.h" -#include "objects-x.h" +#include "fontcolor-x.h" #include "../lwlib/lwlib.h" #include "EmacsFrame.h"
--- a/src/event-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/event-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -45,7 +45,7 @@ #include "console-tty.h" #include "console-gtk-impl.h" -#include "objects-gtk.h" +#include "fontcolor-gtk.h" #include "gtk-xemacs.h"
--- a/src/event-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/event-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -83,7 +83,7 @@ #include "console-stream-impl.h" #include "console-msw-impl.h" -#include "objects-msw-impl.h" +#include "fontcolor-msw-impl.h" #ifdef HAVE_SCROLLBARS # include "scrollbar-msw.h"
--- a/src/faces.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/faces.c Mon Mar 29 22:52:01 2010 -0500 @@ -37,7 +37,7 @@ #include "faces.h" #include "frame-impl.h" #include "glyphs.h" -#include "objects-impl.h" +#include "fontcolor-impl.h" #include "specifier.h" #include "window.h"
--- a/src/font-mgr.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/font-mgr.c Mon Mar 29 22:52:01 2010 -0500 @@ -42,8 +42,8 @@ #include "device.h" #include "device-impl.h" #include "console-x-impl.h" -#include "objects-x.h" -#include "objects-x-impl.h" +#include "fontcolor-x.h" +#include "fontcolor-x-impl.h" #include "hash.h" #include "font-mgr.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-gtk-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,64 @@ +/* Gtk-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ +/* Gtk version by William Perry */ + +#ifndef _XEMACS_OBJECTS_GTK_IMPL_H_ +#define _XEMACS_OBJECTS_GTK_IMPL_H_ + +#include "fontcolor-impl.h" +#include "fontcolor-gtk.h" + +#ifdef HAVE_GTK + +/***************************************************************************** + Color-Instance + ****************************************************************************/ + +struct gtk_color_instance_data +{ + GdkColor *color; + char dealloc_on_gc; +}; + +#define GTK_COLOR_INSTANCE_DATA(c) ((struct gtk_color_instance_data *) (c)->data) +#define COLOR_INSTANCE_GTK_COLOR(c) (GTK_COLOR_INSTANCE_DATA (c)->color) +#define XCOLOR_INSTANCE_GTK_COLOR(c) COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (c)) +#define COLOR_INSTANCE_GTK_DEALLOC(c) (GTK_COLOR_INSTANCE_DATA (c)->dealloc_on_gc) + +/***************************************************************************** + Font-Instance + ****************************************************************************/ + +struct gtk_font_instance_data +{ + /* Gtk-specific information */ + GdkFont *font; +}; + +#define GTK_FONT_INSTANCE_DATA(f) ((struct gtk_font_instance_data *) (f)->data) +#define FONT_INSTANCE_GTK_FONT(f) (GTK_FONT_INSTANCE_DATA (f)->font) +#define XFONT_INSTANCE_GTK_FONT(c) FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (c)) + +#endif /* HAVE_GTK */ +#endif /* _XEMACS_OBJECTS_GTK_IMPL_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,511 @@ +/* X-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995 Tinker Systems. + Copyright (C) 1995, 1996, 2002 Ben Wing. + Copyright (C) 1995 Sun Microsystems, Inc. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */ +/* Gtk version by William Perry */ + +#include <config.h> +#include "lisp.h" + +#include "buffer.h" +#include "charset.h" +#include "device-impl.h" +#include "insdel.h" + +#include "console-gtk-impl.h" +#include "fontcolor-gtk-impl.h" + +/* sigh */ +#include "sysgdkx.h" + +/* XListFonts doesn't allocate memory unconditionally based on this. (For + XFree86 in 2005, at least. */ +#define MAX_FONT_COUNT INT_MAX + +#ifdef DEBUG_XEMACS +Fixnum debug_x_objects; +#endif /* DEBUG_XEMACS */ + + +/************************************************************************/ +/* color instances */ +/************************************************************************/ + +/* Replacement for XAllocColor() that tries to return the nearest + available color if the colormap is full. Original was from FSFmacs, + but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25 + Modified by Lee Kindness <lkindness@csl.co.uk> 31/08/99 to handle previous + total failure which was due to a read/write colorcell being the nearest + match - tries the next nearest... + + Gdk takes care of all this behind the scenes, so we don't need to + worry about it. + + Return value is 1 for normal success, 2 for nearest color success, + 3 for Non-deallocable sucess. */ +int +allocate_nearest_color (GdkColormap *colormap, GdkVisual *UNUSED (visual), + GdkColor *color_def) +{ + int rc; + + rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE); + + if (rc == TRUE) + return (1); + + return (0); +} + +int +gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name, + Bytecount len, Error_Behavior errb) +{ + GdkColormap *cmap; + GdkVisual *visual; + int result; + + cmap = DEVICE_GTK_COLORMAP(d); + visual = DEVICE_GTK_VISUAL (d); + + xzero (*color); + { + const Extbyte *extname; + Bytecount extnamelen; + + TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary); + + result = gdk_color_parse (extname, color); + } + + if (result == FALSE) + { + maybe_invalid_argument ("unrecognized color", make_string (name, len), + Qcolor, errb); + return 0; + } + result = allocate_nearest_color (cmap, visual, color); + if (!result) + { + maybe_signal_error (Qgui_error, "couldn't allocate color", + make_string (name, len), Qcolor, errb); + return 0; + } + + return result; +} + +static int +gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name, + Lisp_Object device, Error_Behavior errb) +{ + GdkColor color; + int result; + + result = gtk_parse_nearest_color (XDEVICE (device), &color, + XSTRING_DATA (name), + XSTRING_LENGTH (name), + errb); + + if (!result) + return 0; + + /* Don't allocate the data until we're sure that we will succeed, + or the finalize method may get fucked. */ + c->data = xnew (struct gtk_color_instance_data); + if (result == 3) + COLOR_INSTANCE_GTK_DEALLOC (c) = 0; + else + COLOR_INSTANCE_GTK_DEALLOC (c) = 1; + COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color); + return 1; +} + +static void +gtk_print_color_instance (struct Lisp_Color_Instance *c, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c); + write_fmt_string (printcharfun, " %ld=(%X,%X,%X)", + color->pixel, color->red, color->green, color->blue); +} + +static void +gtk_finalize_color_instance (struct Lisp_Color_Instance *c) +{ + if (c->data) + { + if (DEVICE_LIVE_P (XDEVICE (c->device))) + { + if (COLOR_INSTANCE_GTK_DEALLOC (c)) + { + gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)), + COLOR_INSTANCE_GTK_COLOR (c), 1); + } + gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c)); + } + xfree (c->data); + c->data = 0; + } +} + +/* Color instances are equal if they resolve to the same color on the + screen (have the same RGB values). I imagine that + "same RGB values" == "same cell in the colormap." Arguably we should + be comparing their names or pixel values instead. */ + +static int +gtk_color_instance_equal (struct Lisp_Color_Instance *c1, + struct Lisp_Color_Instance *c2, + int UNUSED (depth)) +{ + return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1), + COLOR_INSTANCE_GTK_COLOR (c2))); +} + +static Hashcode +gtk_color_instance_hash (struct Lisp_Color_Instance *c, int UNUSED (depth)) +{ + return (gdk_color_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL)); +} + +static Lisp_Object +gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c) +{ + GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c); + return (list3 (make_int (color->red), + make_int (color->green), + make_int (color->blue))); +} + +static int +gtk_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) +{ + GdkColor c; + const char *extname; + + extname = LISP_STRING_TO_EXTERNAL (color, Qctext); + + if (gdk_color_parse (extname, &c) != TRUE) + return(0); + return (1); +} + +static Lisp_Object +gtk_color_list (void) +{ + /* #### BILL!!! + Is this correct? */ + return call0 (intern ("x-color-list-internal")); +} + + +/************************************************************************/ +/* font instances */ +/************************************************************************/ + +static int +gtk_initialize_font_instance (struct Lisp_Font_Instance *f, + Lisp_Object UNUSED (name), + Lisp_Object UNUSED (device), Error_Behavior errb) +{ + GdkFont *gf; + XFontStruct *xf; + const char *extname; + + extname = LISP_STRING_TO_EXTERNAL (f->name, Qctext); + + gf = gdk_font_load (extname); + + if (!gf) + { + maybe_signal_error (Qgui_error, "couldn't load font", f->name, + Qfont, errb); + return 0; + } + + xf = (XFontStruct*) GDK_FONT_XFONT (gf); + + /* Don't allocate the data until we're sure that we will succeed, + or the finalize method may get fucked. */ + f->data = xnew (struct gtk_font_instance_data); + FONT_INSTANCE_GTK_FONT (f) = gf; + f->ascent = gf->ascent; + f->descent = gf->descent; + f->height = gf->ascent + gf->descent; + + /* Now lets figure out the width of the font */ + { + /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */ + unsigned int def_char = 'n'; /*xf->default_char;*/ + unsigned int byte1, byte2; + + once_more: + byte1 = def_char >> 8; + byte2 = def_char & 0xFF; + + if (xf->per_char) + { + /* Old versions of the R5 font server have garbage (>63k) as + def_char. 'n' might not be a valid character. */ + if (byte1 < xf->min_byte1 || + byte1 > xf->max_byte1 || + byte2 < xf->min_char_or_byte2 || + byte2 > xf->max_char_or_byte2) + f->width = 0; + else + f->width = xf->per_char[(byte1 - xf->min_byte1) * + (xf->max_char_or_byte2 - + xf->min_char_or_byte2 + 1) + + (byte2 - xf->min_char_or_byte2)].width; + } + else + f->width = xf->max_bounds.width; + + /* Some fonts have a default char whose width is 0. This is no good. + If that's the case, first try 'n' as the default char, and if n has + 0 width too (unlikely) then just use the max width. */ + if (f->width == 0) + { + if (def_char == xf->default_char) + f->width = xf->max_bounds.width; + else + { + def_char = xf->default_char; + goto once_more; + } + } + } + + /* If all characters don't exist then there could potentially be + 0-width characters lurking out there. Not setting this flag + trips an optimization that would make them appear to have width + to redisplay. This is bad. So we set it if not all characters + have the same width or if not all characters are defined. + */ + /* #### This sucks. There is a measurable performance increase + when using proportional width fonts if this flag is not set. + Unfortunately so many of the fucking X fonts are not fully + defined that we could almost just get rid of this damn flag and + make it an assertion. */ + f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width || + (/* x_handle_non_fully_specified_fonts */ 0 && + !xf->all_chars_exist)); +#if 0 + f->width = gdk_char_width (gf, 'n'); + f->proportional_p = (gdk_char_width (gf, '|') != gdk_char_width (gf, 'W')) ? 1 : 0; +#endif + return 1; +} + +static void +gtk_print_font_instance (struct Lisp_Font_Instance *f, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + write_fmt_string (printcharfun, " 0x%lx", + (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f))); +} + +static void +gtk_finalize_font_instance (struct Lisp_Font_Instance *f) +{ + if (f->data) + { + if (DEVICE_LIVE_P (XDEVICE (f->device))) + { + gdk_font_unref (FONT_INSTANCE_GTK_FONT (f)); + } + xfree (f->data); + f->data = 0; + } +} + +/* Forward declarations for X specific functions at the end of the file */ +Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp); +static Lisp_Object __gtk_font_list_internal (const char *pattern); + +static Lisp_Object +gtk_font_instance_truename (struct Lisp_Font_Instance *f, + Error_Behavior UNUSED (errb)) +{ + if (NILP (FONT_INSTANCE_TRUENAME (f))) + { + FONT_INSTANCE_TRUENAME (f) = __get_gtk_font_truename (FONT_INSTANCE_GTK_FONT (f), 1); + + if (NILP (FONT_INSTANCE_TRUENAME (f))) + { + /* Ok, just this once, return the font name as the truename. + (This is only used by Fequal() right now.) */ + return f->name; + } + } + return (FONT_INSTANCE_TRUENAME (f)); +} + +static Lisp_Object +gtk_font_instance_properties (struct Lisp_Font_Instance *UNUSED (f)) +{ + Lisp_Object result = Qnil; + + /* #### BILL!!! */ + /* There seems to be no way to get this information under Gtk */ + return result; +} + +static Lisp_Object +gtk_font_list (Lisp_Object pattern, Lisp_Object UNUSED (device), + Lisp_Object UNUSED (maxnumber)) +{ + const char *patternext; + + patternext = LISP_STRING_TO_EXTERNAL (pattern, Qbinary); + + return (__gtk_font_list_internal (patternext)); +} + +/* Include the charset support, shared, for the moment, with X11. */ +#define THIS_IS_GTK +#include "fontcolor-xlike-inc.c" + + +/************************************************************************/ +/* initialization */ +/************************************************************************/ + +void +syms_of_fontcolor_gtk (void) +{ +} + +void +console_type_create_fontcolor_gtk (void) +{ + /* object methods */ + + CONSOLE_HAS_METHOD (gtk, initialize_color_instance); + CONSOLE_HAS_METHOD (gtk, print_color_instance); + CONSOLE_HAS_METHOD (gtk, finalize_color_instance); + CONSOLE_HAS_METHOD (gtk, color_instance_equal); + CONSOLE_HAS_METHOD (gtk, color_instance_hash); + CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components); + CONSOLE_HAS_METHOD (gtk, valid_color_name_p); + CONSOLE_HAS_METHOD (gtk, color_list); + + CONSOLE_HAS_METHOD (gtk, initialize_font_instance); + CONSOLE_HAS_METHOD (gtk, print_font_instance); + CONSOLE_HAS_METHOD (gtk, finalize_font_instance); + CONSOLE_HAS_METHOD (gtk, font_instance_truename); + CONSOLE_HAS_METHOD (gtk, font_instance_properties); + CONSOLE_HAS_METHOD (gtk, font_list); +#ifdef MULE + CONSOLE_HAS_METHOD (gtk, find_charset_font); + CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset); +#endif +} + +void +vars_of_fontcolor_gtk (void) +{ +#ifdef DEBUG_XEMACS + DEFVAR_INT ("debug-x-objects", &debug_x_objects /* +If non-zero, display debug information about X objects +*/ ); + debug_x_objects = 0; +#endif +} + +static int +valid_font_name_p (Display *dpy, char *name) +{ + /* Maybe this should be implemented by callign XLoadFont and trapping + the error. That would be a lot of work, and wasteful as hell, but + might be more correct. + */ + int nnames = 0; + char **names = 0; + if (! name) + return 0; + names = XListFonts (dpy, name, 1, &nnames); + if (names) + XFreeFontNames (names); + return (nnames != 0); +} + +Lisp_Object +__get_gtk_font_truename (GdkFont *gdk_font, int expandp) +{ + Display *dpy = GDK_FONT_XDISPLAY (gdk_font); + GSList *names = ((GdkFontPrivate *) gdk_font)->names; + Lisp_Object font_name = Qnil; + + while (names) + { + if (names->data) + { + if (valid_font_name_p (dpy, (char*) names->data)) + { + if (!expandp) + { + /* They want the wildcarded version */ + font_name = build_cistring ((char*) names->data); + } + else + { + /* Need to expand out */ + int nnames = 0; + char **x_font_names = 0; + + x_font_names = XListFonts (dpy, (char*) names->data, 1, &nnames); + if (x_font_names) + { + font_name = build_cistring (x_font_names[0]); + XFreeFontNames (x_font_names); + } + } + break; + } + } + names = names->next; + } + return (font_name); +} + +static Lisp_Object __gtk_font_list_internal (const char *pattern) +{ + char **names; + int count = 0; + Lisp_Object result = Qnil; + + names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count); + while (count--) + result = Fcons (build_extstring (names [count], Qbinary), result); + if (names) + XFreeFontNames (names); + + return result; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-gtk.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,47 @@ +/* Gtk-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ +/* Gtk version by William Perry */ + +#ifndef _XEMACS_OBJECTS_GTK_H_ +#define _XEMACS_OBJECTS_GTK_H_ + +#include "fontcolor.h" + +#ifdef HAVE_GTK + +/***************************************************************************** + Color-Instance + ****************************************************************************/ + +int allocate_nearest_color (GdkColormap *screen_colormap, GdkVisual *visual, + GdkColor *color_def); +int gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name, + Bytecount len, Error_Behavior errb); + +/***************************************************************************** + Font-Instance + ****************************************************************************/ + +#endif /* HAVE_GTK */ +#endif /* _XEMACS_OBJECTS_GTK_H_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,193 @@ +/* Generic object functions -- header implementation. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002 Ben Wing. + Copyright (C) 2010 Didier Verna + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#ifndef INCLUDED_fontcolor_impl_h_ +#define INCLUDED_fontcolor_impl_h_ + +#include "specifier.h" +#include "fontcolor.h" + +/***************************************************************************** + * Color Specifier Object * + *****************************************************************************/ + +struct color_specifier +{ + Lisp_Object face; /* face this is attached to, or nil */ + Lisp_Object face_property; /* property of that face */ +}; + +#define COLOR_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, color) +#define COLOR_SPECIFIER_FACE(g) (COLOR_SPECIFIER_DATA (g)->face) +#define COLOR_SPECIFIER_FACE_PROPERTY(g) \ + (COLOR_SPECIFIER_DATA (g)->face_property) + +DECLARE_SPECIFIER_TYPE (color); +#define XCOLOR_SPECIFIER(x) XSPECIFIER_TYPE (x, color) +#define COLOR_SPECIFIERP(x) SPECIFIER_TYPEP (x, color) +#define CHECK_COLOR_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, color) +#define CONCHECK_COLOR_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, color) + +/***************************************************************************** + * Font Specifier Object * + *****************************************************************************/ + +struct font_specifier +{ + Lisp_Object face; /* face this is attached to, or nil */ + Lisp_Object face_property; /* property of that face */ +}; + +#define FONT_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, font) +#define FONT_SPECIFIER_FACE(g) (FONT_SPECIFIER_DATA (g)->face) +#define FONT_SPECIFIER_FACE_PROPERTY(g) \ + (FONT_SPECIFIER_DATA (g)->face_property) + +DECLARE_SPECIFIER_TYPE (font); +#define XFONT_SPECIFIER(x) XSPECIFIER_TYPE (x, font) +#define FONT_SPECIFIERP(x) SPECIFIER_TYPEP (x, font) +#define CHECK_FONT_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, font) +#define CONCHECK_FONT_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, font) + +/***************************************************************************** + * Face Boolean Specifier Object * + *****************************************************************************/ + +struct face_boolean_specifier +{ + Lisp_Object face; /* face this is attached to, or nil */ + Lisp_Object face_property; /* property of that face */ +}; + +#define FACE_BOOLEAN_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, face_boolean) +#define FACE_BOOLEAN_SPECIFIER_FACE(g) (FACE_BOOLEAN_SPECIFIER_DATA (g)->face) +#define FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY(g) \ + (FACE_BOOLEAN_SPECIFIER_DATA (g)->face_property) + +DECLARE_SPECIFIER_TYPE (face_boolean); +extern Lisp_Object Qface_boolean; +#define XFACE_BOOLEAN_SPECIFIER(x) XSPECIFIER_TYPE (x, face_boolean) +#define FACE_BOOLEAN_SPECIFIERP(x) SPECIFIER_TYPEP (x, face_boolean) +#define CHECK_FACE_BOOLEAN_SPECIFIER(x) \ + CHECK_SPECIFIER_TYPE (x, face_boolean) +#define CONCHECK_FACE_BOOLEAN_SPECIFIER(x) \ + CONCHECK_SPECIFIER_TYPE (x, face_boolean) + +/***************************************************************************** + * Background Placement Specifier Object * + *****************************************************************************/ + +struct face_background_placement_specifier +{ + Lisp_Object face; /* face this is attached to, or nil */ +}; + +#define FACE_BACKGROUND_PLACEMENT_SPECIFIER_DATA(g) \ + SPECIFIER_TYPE_DATA (g, face_background_placement) +#define FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE(g) \ + (FACE_BACKGROUND_PLACEMENT_SPECIFIER_DATA (g)->face) + +DECLARE_SPECIFIER_TYPE (face_background_placement); +extern Lisp_Object Qface_background_placement, Qabsolute, Qrelative; +#define XFACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ + XSPECIFIER_TYPE (x, face_background_placement) +#define FACE_BACKGROUND_PLACEMENT_SPECIFIERP(x) \ + SPECIFIER_TYPEP (x, face_background_placement) +#define CHECK_FACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ + CHECK_SPECIFIER_TYPE (x, face_background_placement) +#define CONCHECK_FACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ + CONCHECK_SPECIFIER_TYPE (x, face_background_placement) + +/**************************************************************************** + * Color Instance Object * + ****************************************************************************/ + +struct Lisp_Color_Instance +{ + NORMAL_LISP_OBJECT_HEADER header; + Lisp_Object name; + Lisp_Object device; + + /* See comment in struct console about console variants. */ + enum console_variant color_instance_type; + + /* console-type-specific data */ + void *data; +}; + +#define COLOR_INSTANCE_NAME(c) ((c)->name) +#define COLOR_INSTANCE_DEVICE(c) ((c)->device) + +/**************************************************************************** + * Font Instance Object * + ****************************************************************************/ + +struct Lisp_Font_Instance +{ + NORMAL_LISP_OBJECT_HEADER header; + Lisp_Object name; /* the instantiator used to create the font instance */ + Lisp_Object truename; /* used by the device-specific methods; we need to + call them to get the truename (#### in reality, + they all probably just store the truename here + if they know it, and nil otherwise; we should + check this and enforce it as a general policy + X and GTK do this, except that when they don't + know they return NAME and don't update TRUENAME. + MS Windows initializes TRUENAME when the font is + initialized. TTY doesn't do truename.) */ + Lisp_Object device; + Lisp_Object charset; /* Mule charset, or whatever */ + + /* See comment in struct console about console variants. */ + enum console_variant font_instance_type; + + unsigned short ascent; /* extracted from `font', or made up */ + unsigned short descent; + unsigned short width; + unsigned short height; + int proportional_p; + + /* console-type-specific data */ + void *data; +}; + +#define FONT_INSTANCE_NAME(f) ((f)->name) +#define FONT_INSTANCE_TRUENAME(f) ((f)->truename) +#define FONT_INSTANCE_CHARSET(f) ((f)->charset) +#define FONT_INSTANCE_DEVICE(f) ((f)->device) +#define FONT_INSTANCE_ASCENT(f) ((f)->ascent) +#define FONT_INSTANCE_DESCENT(f) ((f)->descent) +#define FONT_INSTANCE_WIDTH(f) ((f)->width) +#define FONT_INSTANCE_HEIGHT(f) ((f)->height) + +#define XFONT_INSTANCE_NAME(f) FONT_INSTANCE_NAME (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_TRUENAME(f) FONT_INSTANCE_TRUENAME (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_CHARSET(f) FONT_INSTANCE_CHARSET (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_DEVICE(f) FONT_INSTANCE_DEVICE (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_ASCENT(f) FONT_INSTANCE_ASCENT (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_DESCENT(f) FONT_INSTANCE_DESCENT (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_WIDTH(f) FONT_INSTANCE_WIDTH (XFONT_INSTANCE (f)) +#define XFONT_INSTANCE_HEIGHT(f) FONT_INSTANCE_HEIGHT (XFONT_INSTANCE (f)) + +#endif /* INCLUDED_fontcolor_impl_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-msw-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,75 @@ +/* mswindows-specific Lisp objects -- header implementation. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002 Ben Wing. + Copyright (C) 1997, Jonathan Harris. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Authorship: + + Ultimately based on FSF. + Rewritten by Ben Wing. + Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0. + */ + + +#ifndef INCLUDED_fontcolor_msw_impl_h_ +#define INCLUDED_fontcolor_msw_impl_h_ + +#include "fontcolor-impl.h" +#include "fontcolor-msw.h" + +struct mswindows_color_instance_data +{ + COLORREF color; +}; + +#define MSWINDOWS_COLOR_INSTANCE_DATA(c) \ + ((struct mswindows_color_instance_data *) (c)->data) +#define COLOR_INSTANCE_MSWINDOWS_COLOR(c) \ + (MSWINDOWS_COLOR_INSTANCE_DATA (c)->color) + +/* The four HFONTS are for the 4 (underlined, strikethrough) + combinations. Only the one at index 0, neither underlined nor + struk through is created with the font instance. Other fonts are + created as necessary during redisplay, using the one at index 0 + as prototype */ +#define MSWINDOWS_NUM_FONT_VARIANTS 4 +struct mswindows_font_instance_data +{ + HFONT hfont [MSWINDOWS_NUM_FONT_VARIANTS]; +}; + +#define MSWINDOWS_FONT_INSTANCE_DATA(c) \ + ((struct mswindows_font_instance_data *) (c)->data) + +#define FONT_INSTANCE_MSWINDOWS_HFONT_I(c,i) \ + (MSWINDOWS_FONT_INSTANCE_DATA(c)->hfont[(i)]) + +#define FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT(c,under,strike) \ + FONT_INSTANCE_MSWINDOWS_HFONT_I (c, (!!(strike)<<1)|!!(under)) + +/* If font creation during redisplay fails, then the following + value is used to prevent future attempts to create this font. + Redisplay uses the "main" font when encounters this value */ +#define MSWINDOWS_BAD_HFONT ((HFONT)INVALID_HANDLE_VALUE) + +#endif /* INCLUDED_fontcolor_msw_impl_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,2341 @@ +/* mswindows-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995 Tinker Systems. + Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2005, 2010 Ben Wing. + Copyright (C) 1995 Sun Microsystems, Inc. + Copyright (C) 1997 Jonathan Harris. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Authorship: + + This file created by Jonathan Harris, November 1997 for 21.0; based + heavily on fontcolor-x.c (see authorship there). Much further work + by Ben Wing. + */ + +/* This function Mule-ized by Ben Wing, 3-24-02. */ + +/* TODO: palette handling */ + +#include <config.h> +#include "lisp.h" + +#include "console-msw-impl.h" +#include "fontcolor-msw-impl.h" + +#include "buffer.h" +#include "charset.h" +#include "device-impl.h" +#include "elhash.h" +#include "insdel.h" +#include "opaque.h" + +typedef struct colormap_t +{ + const Ascbyte *name; + COLORREF colorref; +} colormap_t; + +/* Colors from X11R6 "XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp" */ +/* MSWindows tends to round up the numbers in its palette, ie where X uses + * 127, MSWindows uses 128. Colors commented as "Adjusted" are tweaked to + * match the Windows standard palette to increase the likelihood of + * mswindows_color_to_string() finding a named match. + */ +static const colormap_t mswindows_X_color_map[] = +{ + {"white" , PALETTERGB (255, 255, 255) }, + {"black" , PALETTERGB (0, 0, 0) }, + {"snow" , PALETTERGB (255, 250, 250) }, + {"GhostWhite" , PALETTERGB (248, 248, 255) }, + {"WhiteSmoke" , PALETTERGB (245, 245, 245) }, + {"gainsboro" , PALETTERGB (220, 220, 220) }, + {"FloralWhite" , PALETTERGB (255, 250, 240) }, + {"OldLace" , PALETTERGB (253, 245, 230) }, + {"linen" , PALETTERGB (250, 240, 230) }, + {"AntiqueWhite" , PALETTERGB (250, 235, 215) }, + {"PapayaWhip" , PALETTERGB (255, 239, 213) }, + {"BlanchedAlmond" , PALETTERGB (255, 235, 205) }, + {"bisque" , PALETTERGB (255, 228, 196) }, + {"PeachPuff" , PALETTERGB (255, 218, 185) }, + {"NavajoWhite" , PALETTERGB (255, 222, 173) }, + {"moccasin" , PALETTERGB (255, 228, 181) }, + {"cornsilk" , PALETTERGB (255, 248, 220) }, + {"ivory" , PALETTERGB (255, 255, 240) }, + {"LemonChiffon" , PALETTERGB (255, 250, 205) }, + {"seashell" , PALETTERGB (255, 245, 238) }, + {"honeydew" , PALETTERGB (240, 255, 240) }, + {"MintCream" , PALETTERGB (245, 255, 250) }, + {"azure" , PALETTERGB (240, 255, 255) }, + {"AliceBlue" , PALETTERGB (240, 248, 255) }, + {"lavender" , PALETTERGB (230, 230, 250) }, + {"LavenderBlush" , PALETTERGB (255, 240, 245) }, + {"MistyRose" , PALETTERGB (255, 228, 225) }, + {"DarkSlateGray" , PALETTERGB (47, 79, 79) }, + {"DarkSlateGrey" , PALETTERGB (47, 79, 79) }, + {"DimGray" , PALETTERGB (105, 105, 105) }, + {"DimGrey" , PALETTERGB (105, 105, 105) }, + {"SlateGray" , PALETTERGB (112, 128, 144) }, + {"SlateGrey" , PALETTERGB (112, 128, 144) }, + {"LightSlateGray" , PALETTERGB (119, 136, 153) }, + {"LightSlateGrey" , PALETTERGB (119, 136, 153) }, + {"gray" , PALETTERGB (190, 190, 190) }, + {"grey" , PALETTERGB (190, 190, 190) }, + {"LightGrey" , PALETTERGB (211, 211, 211) }, + {"LightGray" , PALETTERGB (211, 211, 211) }, + {"MidnightBlue" , PALETTERGB (25, 25, 112) }, + {"navy" , PALETTERGB (0, 0, 128) }, + {"NavyBlue" , PALETTERGB (0, 0, 128) }, + {"CornflowerBlue" , PALETTERGB (100, 149, 237) }, + {"DarkSlateBlue" , PALETTERGB (72, 61, 139) }, + {"SlateBlue" , PALETTERGB (106, 90, 205) }, + {"MediumSlateBlue" , PALETTERGB (123, 104, 238) }, + {"LightSlateBlue" , PALETTERGB (132, 112, 255) }, + {"MediumBlue" , PALETTERGB (0, 0, 205) }, + {"RoyalBlue" , PALETTERGB (65, 105, 225) }, + {"blue" , PALETTERGB (0, 0, 255) }, + {"DodgerBlue" , PALETTERGB (30, 144, 255) }, + {"DeepSkyBlue" , PALETTERGB (0, 191, 255) }, + {"SkyBlue" , PALETTERGB (135, 206, 235) }, + {"LightSkyBlue" , PALETTERGB (135, 206, 250) }, + {"SteelBlue" , PALETTERGB (70, 130, 180) }, + {"LightSteelBlue" , PALETTERGB (176, 196, 222) }, + {"LightBlue" , PALETTERGB (173, 216, 230) }, + {"PowderBlue" , PALETTERGB (176, 224, 230) }, + {"PaleTurquoise" , PALETTERGB (175, 238, 238) }, + {"DarkTurquoise" , PALETTERGB (0, 206, 209) }, + {"MediumTurquoise" , PALETTERGB (72, 209, 204) }, + {"turquoise" , PALETTERGB (64, 224, 208) }, + {"cyan" , PALETTERGB (0, 255, 255) }, + {"LightCyan" , PALETTERGB (224, 255, 255) }, + {"CadetBlue" , PALETTERGB (95, 158, 160) }, + {"MediumAquamarine" , PALETTERGB (102, 205, 170) }, + {"aquamarine" , PALETTERGB (127, 255, 212) }, + {"DarkGreen" , PALETTERGB (0, 128, 0) }, /* Adjusted */ + {"DarkOliveGreen" , PALETTERGB (85, 107, 47) }, + {"DarkSeaGreen" , PALETTERGB (143, 188, 143) }, + {"SeaGreen" , PALETTERGB (46, 139, 87) }, + {"MediumSeaGreen" , PALETTERGB (60, 179, 113) }, + {"LightSeaGreen" , PALETTERGB (32, 178, 170) }, + {"PaleGreen" , PALETTERGB (152, 251, 152) }, + {"SpringGreen" , PALETTERGB (0, 255, 127) }, + {"LawnGreen" , PALETTERGB (124, 252, 0) }, + {"green" , PALETTERGB (0, 255, 0) }, + {"chartreuse" , PALETTERGB (127, 255, 0) }, + {"MediumSpringGreen" , PALETTERGB (0, 250, 154) }, + {"GreenYellow" , PALETTERGB (173, 255, 47) }, + {"LimeGreen" , PALETTERGB (50, 205, 50) }, + {"YellowGreen" , PALETTERGB (154, 205, 50) }, + {"ForestGreen" , PALETTERGB (34, 139, 34) }, + {"OliveDrab" , PALETTERGB (107, 142, 35) }, + {"DarkKhaki" , PALETTERGB (189, 183, 107) }, + {"khaki" , PALETTERGB (240, 230, 140) }, + {"PaleGoldenrod" , PALETTERGB (238, 232, 170) }, + {"LightGoldenrodYellow", PALETTERGB (250, 250, 210) }, + {"LightYellow" , PALETTERGB (255, 255, 224) }, + {"LightYellow" , PALETTERGB (255, 255, 225) }, /* Adjusted */ + {"yellow" , PALETTERGB (255, 255, 0) }, + {"gold" , PALETTERGB (255, 215, 0) }, + {"LightGoldenrod" , PALETTERGB (238, 221, 130) }, + {"goldenrod" , PALETTERGB (218, 165, 32) }, + {"DarkGoldenrod" , PALETTERGB (184, 134, 11) }, + {"RosyBrown" , PALETTERGB (188, 143, 143) }, + {"IndianRed" , PALETTERGB (205, 92, 92) }, + {"SaddleBrown" , PALETTERGB (139, 69, 19) }, + {"sienna" , PALETTERGB (160, 82, 45) }, + {"peru" , PALETTERGB (205, 133, 63) }, + {"burlywood" , PALETTERGB (222, 184, 135) }, + {"beige" , PALETTERGB (245, 245, 220) }, + {"wheat" , PALETTERGB (245, 222, 179) }, + {"SandyBrown" , PALETTERGB (244, 164, 96) }, + {"tan" , PALETTERGB (210, 180, 140) }, + {"chocolate" , PALETTERGB (210, 105, 30) }, + {"firebrick" , PALETTERGB (178, 34, 34) }, + {"brown" , PALETTERGB (165, 42, 42) }, + {"DarkSalmon" , PALETTERGB (233, 150, 122) }, + {"salmon" , PALETTERGB (250, 128, 114) }, + {"LightSalmon" , PALETTERGB (255, 160, 122) }, + {"orange" , PALETTERGB (255, 165, 0) }, + {"DarkOrange" , PALETTERGB (255, 140, 0) }, + {"coral" , PALETTERGB (255, 127, 80) }, + {"LightCoral" , PALETTERGB (240, 128, 128) }, + {"tomato" , PALETTERGB (255, 99, 71) }, + {"OrangeRed" , PALETTERGB (255, 69, 0) }, + {"red" , PALETTERGB (255, 0, 0) }, + {"HotPink" , PALETTERGB (255, 105, 180) }, + {"DeepPink" , PALETTERGB (255, 20, 147) }, + {"pink" , PALETTERGB (255, 192, 203) }, + {"LightPink" , PALETTERGB (255, 182, 193) }, + {"PaleVioletRed" , PALETTERGB (219, 112, 147) }, + {"maroon" , PALETTERGB (176, 48, 96) }, + {"MediumVioletRed" , PALETTERGB (199, 21, 133) }, + {"VioletRed" , PALETTERGB (208, 32, 144) }, + {"magenta" , PALETTERGB (255, 0, 255) }, + {"violet" , PALETTERGB (238, 130, 238) }, + {"plum" , PALETTERGB (221, 160, 221) }, + {"orchid" , PALETTERGB (218, 112, 214) }, + {"MediumOrchid" , PALETTERGB (186, 85, 211) }, + {"DarkOrchid" , PALETTERGB (153, 50, 204) }, + {"DarkViolet" , PALETTERGB (148, 0, 211) }, + {"BlueViolet" , PALETTERGB (138, 43, 226) }, + {"purple" , PALETTERGB (160, 32, 240) }, + {"MediumPurple" , PALETTERGB (147, 112, 219) }, + {"thistle" , PALETTERGB (216, 191, 216) }, + {"snow1" , PALETTERGB (255, 250, 250) }, + {"snow2" , PALETTERGB (238, 233, 233) }, + {"snow3" , PALETTERGB (205, 201, 201) }, + {"snow4" , PALETTERGB (139, 137, 137) }, + {"seashell1" , PALETTERGB (255, 245, 238) }, + {"seashell2" , PALETTERGB (238, 229, 222) }, + {"seashell3" , PALETTERGB (205, 197, 191) }, + {"seashell4" , PALETTERGB (139, 134, 130) }, + {"AntiqueWhite1" , PALETTERGB (255, 239, 219) }, + {"AntiqueWhite2" , PALETTERGB (238, 223, 204) }, + {"AntiqueWhite3" , PALETTERGB (205, 192, 176) }, + {"AntiqueWhite4" , PALETTERGB (139, 131, 120) }, + {"bisque1" , PALETTERGB (255, 228, 196) }, + {"bisque2" , PALETTERGB (238, 213, 183) }, + {"bisque3" , PALETTERGB (205, 183, 158) }, + {"bisque4" , PALETTERGB (139, 125, 107) }, + {"PeachPuff1" , PALETTERGB (255, 218, 185) }, + {"PeachPuff2" , PALETTERGB (238, 203, 173) }, + {"PeachPuff3" , PALETTERGB (205, 175, 149) }, + {"PeachPuff4" , PALETTERGB (139, 119, 101) }, + {"NavajoWhite1" , PALETTERGB (255, 222, 173) }, + {"NavajoWhite2" , PALETTERGB (238, 207, 161) }, + {"NavajoWhite3" , PALETTERGB (205, 179, 139) }, + {"NavajoWhite4" , PALETTERGB (139, 121, 94) }, + {"LemonChiffon1" , PALETTERGB (255, 250, 205) }, + {"LemonChiffon2" , PALETTERGB (238, 233, 191) }, + {"LemonChiffon3" , PALETTERGB (205, 201, 165) }, + {"LemonChiffon4" , PALETTERGB (139, 137, 112) }, + {"cornsilk1" , PALETTERGB (255, 248, 220) }, + {"cornsilk2" , PALETTERGB (238, 232, 205) }, + {"cornsilk3" , PALETTERGB (205, 200, 177) }, + {"cornsilk4" , PALETTERGB (139, 136, 120) }, + {"ivory1" , PALETTERGB (255, 255, 240) }, + {"ivory2" , PALETTERGB (240, 240, 208) }, /* Adjusted */ + {"ivory3" , PALETTERGB (205, 205, 193) }, + {"ivory4" , PALETTERGB (139, 139, 131) }, + {"honeydew1" , PALETTERGB (240, 255, 240) }, + {"honeydew2" , PALETTERGB (224, 238, 224) }, + {"honeydew3" , PALETTERGB (193, 205, 193) }, + {"honeydew4" , PALETTERGB (131, 139, 131) }, + {"LavenderBlush1" , PALETTERGB (255, 240, 245) }, + {"LavenderBlush2" , PALETTERGB (238, 224, 229) }, + {"LavenderBlush3" , PALETTERGB (205, 193, 197) }, + {"LavenderBlush4" , PALETTERGB (139, 131, 134) }, + {"MistyRose1" , PALETTERGB (255, 228, 225) }, + {"MistyRose2" , PALETTERGB (238, 213, 210) }, + {"MistyRose3" , PALETTERGB (205, 183, 181) }, + {"MistyRose4" , PALETTERGB (139, 125, 123) }, + {"azure1" , PALETTERGB (240, 255, 255) }, + {"azure2" , PALETTERGB (224, 238, 238) }, + {"azure3" , PALETTERGB (193, 205, 205) }, + {"azure4" , PALETTERGB (131, 139, 139) }, + {"SlateBlue1" , PALETTERGB (131, 111, 255) }, + {"SlateBlue2" , PALETTERGB (122, 103, 238) }, + {"SlateBlue3" , PALETTERGB (105, 89, 205) }, + {"SlateBlue4" , PALETTERGB (71, 60, 139) }, + {"RoyalBlue1" , PALETTERGB (72, 118, 255) }, + {"RoyalBlue2" , PALETTERGB (67, 110, 238) }, + {"RoyalBlue3" , PALETTERGB (58, 95, 205) }, + {"RoyalBlue4" , PALETTERGB (39, 64, 139) }, + {"blue1" , PALETTERGB (0, 0, 255) }, + {"blue2" , PALETTERGB (0, 0, 238) }, + {"blue3" , PALETTERGB (0, 0, 205) }, + {"blue4" , PALETTERGB (0, 0, 139) }, + {"DodgerBlue1" , PALETTERGB (30, 144, 255) }, + {"DodgerBlue2" , PALETTERGB (28, 134, 238) }, + {"DodgerBlue3" , PALETTERGB (24, 116, 205) }, + {"DodgerBlue4" , PALETTERGB (16, 78, 139) }, + {"SteelBlue1" , PALETTERGB (99, 184, 255) }, + {"SteelBlue2" , PALETTERGB (92, 172, 238) }, + {"SteelBlue3" , PALETTERGB (79, 148, 205) }, + {"SteelBlue4" , PALETTERGB (54, 100, 139) }, + {"DeepSkyBlue1" , PALETTERGB (0, 191, 255) }, + {"DeepSkyBlue2" , PALETTERGB (0, 178, 238) }, + {"DeepSkyBlue3" , PALETTERGB (0, 154, 205) }, + {"DeepSkyBlue4" , PALETTERGB (0, 104, 139) }, + {"SkyBlue1" , PALETTERGB (135, 206, 255) }, + {"SkyBlue2" , PALETTERGB (126, 192, 238) }, + {"SkyBlue3" , PALETTERGB (108, 166, 205) }, + {"SkyBlue4" , PALETTERGB (74, 112, 139) }, + {"LightSkyBlue1" , PALETTERGB (176, 226, 255) }, + {"LightSkyBlue2" , PALETTERGB (164, 211, 238) }, + {"LightSkyBlue3" , PALETTERGB (141, 182, 205) }, + {"LightSkyBlue4" , PALETTERGB (96, 123, 139) }, + {"SlateGray1" , PALETTERGB (198, 226, 255) }, + {"SlateGray2" , PALETTERGB (185, 211, 238) }, + {"SlateGray3" , PALETTERGB (159, 182, 205) }, + {"SlateGray4" , PALETTERGB (108, 123, 139) }, + {"LightSteelBlue1" , PALETTERGB (202, 225, 255) }, + {"LightSteelBlue2" , PALETTERGB (188, 210, 238) }, + {"LightSteelBlue3" , PALETTERGB (162, 181, 205) }, + {"LightSteelBlue4" , PALETTERGB (110, 123, 139) }, + {"LightBlue1" , PALETTERGB (191, 239, 255) }, + {"LightBlue2" , PALETTERGB (178, 223, 238) }, + {"LightBlue3" , PALETTERGB (154, 192, 205) }, + {"LightBlue4" , PALETTERGB (104, 131, 139) }, + {"LightCyan1" , PALETTERGB (224, 255, 255) }, + {"LightCyan2" , PALETTERGB (209, 238, 238) }, + {"LightCyan3" , PALETTERGB (180, 205, 205) }, + {"LightCyan4" , PALETTERGB (122, 139, 139) }, + {"PaleTurquoise1" , PALETTERGB (187, 255, 255) }, + {"PaleTurquoise2" , PALETTERGB (174, 238, 238) }, + {"PaleTurquoise3" , PALETTERGB (150, 205, 205) }, + {"PaleTurquoise4" , PALETTERGB (102, 139, 139) }, + {"CadetBlue1" , PALETTERGB (152, 245, 255) }, + {"CadetBlue2" , PALETTERGB (144, 220, 240) }, /* Adjusted */ + {"CadetBlue3" , PALETTERGB (122, 197, 205) }, + {"CadetBlue4" , PALETTERGB (83, 134, 139) }, + {"turquoise1" , PALETTERGB (0, 245, 255) }, + {"turquoise2" , PALETTERGB (0, 229, 238) }, + {"turquoise3" , PALETTERGB (0, 197, 205) }, + {"turquoise4" , PALETTERGB (0, 134, 139) }, + {"cyan1" , PALETTERGB (0, 255, 255) }, + {"cyan2" , PALETTERGB (0, 238, 238) }, + {"cyan3" , PALETTERGB (0, 205, 205) }, + {"cyan4" , PALETTERGB (0, 139, 139) }, + {"DarkSlateGray1" , PALETTERGB (151, 255, 255) }, + {"DarkSlateGray2" , PALETTERGB (141, 238, 238) }, + {"DarkSlateGray3" , PALETTERGB (121, 205, 205) }, + {"DarkSlateGray4" , PALETTERGB (82, 139, 139) }, + {"aquamarine1" , PALETTERGB (127, 255, 212) }, + {"aquamarine2" , PALETTERGB (118, 238, 198) }, + {"aquamarine3" , PALETTERGB (102, 205, 170) }, + {"aquamarine4" , PALETTERGB (69, 139, 116) }, + {"DarkSeaGreen1" , PALETTERGB (193, 255, 193) }, + {"DarkSeaGreen2" , PALETTERGB (180, 238, 180) }, + {"DarkSeaGreen3" , PALETTERGB (155, 205, 155) }, + {"DarkSeaGreen4" , PALETTERGB (105, 139, 105) }, + {"SeaGreen1" , PALETTERGB (84, 255, 159) }, + {"SeaGreen2" , PALETTERGB (78, 238, 148) }, + {"SeaGreen3" , PALETTERGB (67, 205, 128) }, + {"SeaGreen4" , PALETTERGB (46, 139, 87) }, + {"PaleGreen1" , PALETTERGB (154, 255, 154) }, + {"PaleGreen2" , PALETTERGB (144, 238, 144) }, + {"PaleGreen3" , PALETTERGB (124, 205, 124) }, + {"PaleGreen4" , PALETTERGB (84, 139, 84) }, + {"SpringGreen1" , PALETTERGB (0, 255, 127) }, + {"SpringGreen2" , PALETTERGB (0, 238, 118) }, + {"SpringGreen3" , PALETTERGB (0, 205, 102) }, + {"SpringGreen4" , PALETTERGB (0, 139, 69) }, + {"green1" , PALETTERGB (0, 255, 0) }, + {"green2" , PALETTERGB (0, 238, 0) }, + {"green3" , PALETTERGB (0, 205, 0) }, + {"green4" , PALETTERGB (0, 139, 0) }, + {"chartreuse1" , PALETTERGB (127, 255, 0) }, + {"chartreuse2" , PALETTERGB (118, 238, 0) }, + {"chartreuse3" , PALETTERGB (102, 205, 0) }, + {"chartreuse4" , PALETTERGB (69, 139, 0) }, + {"OliveDrab1" , PALETTERGB (192, 255, 62) }, + {"OliveDrab2" , PALETTERGB (179, 238, 58) }, + {"OliveDrab3" , PALETTERGB (154, 205, 50) }, + {"OliveDrab4" , PALETTERGB (105, 139, 34) }, + {"DarkOliveGreen1" , PALETTERGB (202, 255, 112) }, + {"DarkOliveGreen2" , PALETTERGB (188, 238, 104) }, + {"DarkOliveGreen3" , PALETTERGB (162, 205, 90) }, + {"DarkOliveGreen4" , PALETTERGB (110, 139, 61) }, + {"khaki1" , PALETTERGB (255, 246, 143) }, + {"khaki2" , PALETTERGB (238, 230, 133) }, + {"khaki3" , PALETTERGB (205, 198, 115) }, + {"khaki4" , PALETTERGB (139, 134, 78) }, + {"LightGoldenrod1" , PALETTERGB (255, 236, 139) }, + {"LightGoldenrod2" , PALETTERGB (238, 220, 130) }, + {"LightGoldenrod3" , PALETTERGB (205, 190, 112) }, + {"LightGoldenrod4" , PALETTERGB (139, 129, 76) }, + {"LightYellow1" , PALETTERGB (255, 255, 224) }, + {"LightYellow2" , PALETTERGB (238, 238, 209) }, + {"LightYellow3" , PALETTERGB (205, 205, 180) }, + {"LightYellow4" , PALETTERGB (139, 139, 122) }, + {"yellow1" , PALETTERGB (255, 255, 0) }, + {"yellow2" , PALETTERGB (238, 238, 0) }, + {"yellow3" , PALETTERGB (205, 205, 0) }, + {"yellow4" , PALETTERGB (139, 139, 0) }, + {"gold1" , PALETTERGB (255, 215, 0) }, + {"gold2" , PALETTERGB (238, 201, 0) }, + {"gold3" , PALETTERGB (205, 173, 0) }, + {"gold4" , PALETTERGB (139, 117, 0) }, + {"goldenrod1" , PALETTERGB (255, 193, 37) }, + {"goldenrod2" , PALETTERGB (238, 180, 34) }, + {"goldenrod3" , PALETTERGB (205, 155, 29) }, + {"goldenrod4" , PALETTERGB (139, 105, 20) }, + {"DarkGoldenrod1" , PALETTERGB (255, 185, 15) }, + {"DarkGoldenrod2" , PALETTERGB (238, 173, 14) }, + {"DarkGoldenrod3" , PALETTERGB (205, 149, 12) }, + {"DarkGoldenrod4" , PALETTERGB (139, 101, 8) }, + {"RosyBrown1" , PALETTERGB (255, 193, 193) }, + {"RosyBrown2" , PALETTERGB (238, 180, 180) }, + {"RosyBrown3" , PALETTERGB (205, 155, 155) }, + {"RosyBrown4" , PALETTERGB (139, 105, 105) }, + {"IndianRed1" , PALETTERGB (255, 106, 106) }, + {"IndianRed2" , PALETTERGB (238, 99, 99) }, + {"IndianRed3" , PALETTERGB (205, 85, 85) }, + {"IndianRed4" , PALETTERGB (139, 58, 58) }, + {"sienna1" , PALETTERGB (255, 130, 71) }, + {"sienna2" , PALETTERGB (238, 121, 66) }, + {"sienna3" , PALETTERGB (205, 104, 57) }, + {"sienna4" , PALETTERGB (139, 71, 38) }, + {"burlywood1" , PALETTERGB (255, 211, 155) }, + {"burlywood2" , PALETTERGB (238, 197, 145) }, + {"burlywood3" , PALETTERGB (205, 170, 125) }, + {"burlywood4" , PALETTERGB (139, 115, 85) }, + {"wheat1" , PALETTERGB (255, 231, 186) }, + {"wheat2" , PALETTERGB (238, 216, 174) }, + {"wheat3" , PALETTERGB (205, 186, 150) }, + {"wheat4" , PALETTERGB (139, 126, 102) }, + {"tan1" , PALETTERGB (255, 165, 79) }, + {"tan2" , PALETTERGB (238, 154, 73) }, + {"tan3" , PALETTERGB (205, 133, 63) }, + {"tan4" , PALETTERGB (139, 90, 43) }, + {"chocolate1" , PALETTERGB (255, 127, 36) }, + {"chocolate2" , PALETTERGB (238, 118, 33) }, + {"chocolate3" , PALETTERGB (205, 102, 29) }, + {"chocolate4" , PALETTERGB (139, 69, 19) }, + {"firebrick1" , PALETTERGB (255, 48, 48) }, + {"firebrick2" , PALETTERGB (238, 44, 44) }, + {"firebrick3" , PALETTERGB (205, 38, 38) }, + {"firebrick4" , PALETTERGB (139, 26, 26) }, + {"brown1" , PALETTERGB (255, 64, 64) }, + {"brown2" , PALETTERGB (238, 59, 59) }, + {"brown3" , PALETTERGB (205, 51, 51) }, + {"brown4" , PALETTERGB (139, 35, 35) }, + {"salmon1" , PALETTERGB (255, 140, 105) }, + {"salmon2" , PALETTERGB (238, 130, 98) }, + {"salmon3" , PALETTERGB (205, 112, 84) }, + {"salmon4" , PALETTERGB (139, 76, 57) }, + {"LightSalmon1" , PALETTERGB (255, 160, 122) }, + {"LightSalmon2" , PALETTERGB (238, 149, 114) }, + {"LightSalmon3" , PALETTERGB (205, 129, 98) }, + {"LightSalmon4" , PALETTERGB (139, 87, 66) }, + {"orange1" , PALETTERGB (255, 165, 0) }, + {"orange2" , PALETTERGB (238, 154, 0) }, + {"orange3" , PALETTERGB (205, 133, 0) }, + {"orange4" , PALETTERGB (139, 90, 0) }, + {"DarkOrange1" , PALETTERGB (255, 127, 0) }, + {"DarkOrange2" , PALETTERGB (238, 118, 0) }, + {"DarkOrange3" , PALETTERGB (205, 102, 0) }, + {"DarkOrange4" , PALETTERGB (139, 69, 0) }, + {"coral1" , PALETTERGB (255, 114, 86) }, + {"coral2" , PALETTERGB (238, 106, 80) }, + {"coral3" , PALETTERGB (205, 91, 69) }, + {"coral4" , PALETTERGB (139, 62, 47) }, + {"tomato1" , PALETTERGB (255, 99, 71) }, + {"tomato2" , PALETTERGB (238, 92, 66) }, + {"tomato3" , PALETTERGB (205, 79, 57) }, + {"tomato4" , PALETTERGB (139, 54, 38) }, + {"OrangeRed1" , PALETTERGB (255, 69, 0) }, + {"OrangeRed2" , PALETTERGB (238, 64, 0) }, + {"OrangeRed3" , PALETTERGB (205, 55, 0) }, + {"OrangeRed4" , PALETTERGB (139, 37, 0) }, + {"red1" , PALETTERGB (255, 0, 0) }, + {"red2" , PALETTERGB (238, 0, 0) }, + {"red3" , PALETTERGB (205, 0, 0) }, + {"red4" , PALETTERGB (139, 0, 0) }, + {"DeepPink1" , PALETTERGB (255, 20, 147) }, + {"DeepPink2" , PALETTERGB (238, 18, 137) }, + {"DeepPink3" , PALETTERGB (205, 16, 118) }, + {"DeepPink4" , PALETTERGB (139, 10, 80) }, + {"HotPink1" , PALETTERGB (255, 110, 180) }, + {"HotPink2" , PALETTERGB (238, 106, 167) }, + {"HotPink3" , PALETTERGB (205, 96, 144) }, + {"HotPink4" , PALETTERGB (139, 58, 98) }, + {"pink1" , PALETTERGB (255, 181, 197) }, + {"pink2" , PALETTERGB (238, 169, 184) }, + {"pink3" , PALETTERGB (205, 145, 158) }, + {"pink4" , PALETTERGB (139, 99, 108) }, + {"LightPink1" , PALETTERGB (255, 174, 185) }, + {"LightPink2" , PALETTERGB (238, 162, 173) }, + {"LightPink3" , PALETTERGB (205, 140, 149) }, + {"LightPink4" , PALETTERGB (139, 95, 101) }, + {"PaleVioletRed1" , PALETTERGB (255, 130, 171) }, + {"PaleVioletRed2" , PALETTERGB (238, 121, 159) }, + {"PaleVioletRed3" , PALETTERGB (205, 104, 137) }, + {"PaleVioletRed4" , PALETTERGB (139, 71, 93) }, + {"maroon1" , PALETTERGB (255, 52, 179) }, + {"maroon2" , PALETTERGB (238, 48, 167) }, + {"maroon3" , PALETTERGB (205, 41, 144) }, + {"maroon4" , PALETTERGB (139, 28, 98) }, + {"VioletRed1" , PALETTERGB (255, 62, 150) }, + {"VioletRed2" , PALETTERGB (238, 58, 140) }, + {"VioletRed3" , PALETTERGB (205, 50, 120) }, + {"VioletRed4" , PALETTERGB (139, 34, 82) }, + {"magenta1" , PALETTERGB (255, 0, 255) }, + {"magenta2" , PALETTERGB (238, 0, 238) }, + {"magenta3" , PALETTERGB (205, 0, 205) }, + {"magenta4" , PALETTERGB (139, 0, 139) }, + {"orchid1" , PALETTERGB (255, 131, 250) }, + {"orchid2" , PALETTERGB (238, 122, 233) }, + {"orchid3" , PALETTERGB (205, 105, 201) }, + {"orchid4" , PALETTERGB (139, 71, 137) }, + {"plum1" , PALETTERGB (255, 187, 255) }, + {"plum2" , PALETTERGB (238, 174, 238) }, + {"plum3" , PALETTERGB (205, 150, 205) }, + {"plum4" , PALETTERGB (139, 102, 139) }, + {"MediumOrchid1" , PALETTERGB (224, 102, 255) }, + {"MediumOrchid2" , PALETTERGB (209, 95, 238) }, + {"MediumOrchid3" , PALETTERGB (180, 82, 205) }, + {"MediumOrchid4" , PALETTERGB (122, 55, 139) }, + {"DarkOrchid1" , PALETTERGB (191, 62, 255) }, + {"DarkOrchid2" , PALETTERGB (178, 58, 238) }, + {"DarkOrchid3" , PALETTERGB (154, 50, 205) }, + {"DarkOrchid4" , PALETTERGB (104, 34, 139) }, + {"purple1" , PALETTERGB (155, 48, 255) }, + {"purple2" , PALETTERGB (145, 44, 238) }, + {"purple3" , PALETTERGB (125, 38, 205) }, + {"purple4" , PALETTERGB (85, 26, 139) }, + {"MediumPurple1" , PALETTERGB (171, 130, 255) }, + {"MediumPurple2" , PALETTERGB (159, 121, 238) }, + {"MediumPurple3" , PALETTERGB (137, 104, 205) }, + {"MediumPurple4" , PALETTERGB (93, 71, 139) }, + {"thistle1" , PALETTERGB (255, 225, 255) }, + {"thistle2" , PALETTERGB (238, 210, 238) }, + {"thistle3" , PALETTERGB (205, 181, 205) }, + {"thistle4" , PALETTERGB (139, 123, 139) }, + {"gray0" , PALETTERGB (0, 0, 0) }, + {"grey0" , PALETTERGB (0, 0, 0) }, + {"gray1" , PALETTERGB (3, 3, 3) }, + {"grey1" , PALETTERGB (3, 3, 3) }, + {"gray2" , PALETTERGB (5, 5, 5) }, + {"grey2" , PALETTERGB (5, 5, 5) }, + {"gray3" , PALETTERGB (8, 8, 8) }, + {"grey3" , PALETTERGB (8, 8, 8) }, + {"gray4" , PALETTERGB (10, 10, 10) }, + {"grey4" , PALETTERGB (10, 10, 10) }, + {"gray5" , PALETTERGB (13, 13, 13) }, + {"grey5" , PALETTERGB (13, 13, 13) }, + {"gray6" , PALETTERGB (15, 15, 15) }, + {"grey6" , PALETTERGB (15, 15, 15) }, + {"gray7" , PALETTERGB (18, 18, 18) }, + {"grey7" , PALETTERGB (18, 18, 18) }, + {"gray8" , PALETTERGB (20, 20, 20) }, + {"grey8" , PALETTERGB (20, 20, 20) }, + {"gray9" , PALETTERGB (23, 23, 23) }, + {"grey9" , PALETTERGB (23, 23, 23) }, + {"gray10" , PALETTERGB (26, 26, 26) }, + {"grey10" , PALETTERGB (26, 26, 26) }, + {"gray11" , PALETTERGB (28, 28, 28) }, + {"grey11" , PALETTERGB (28, 28, 28) }, + {"gray12" , PALETTERGB (31, 31, 31) }, + {"grey12" , PALETTERGB (31, 31, 31) }, + {"gray13" , PALETTERGB (33, 33, 33) }, + {"grey13" , PALETTERGB (33, 33, 33) }, + {"gray14" , PALETTERGB (36, 36, 36) }, + {"grey14" , PALETTERGB (36, 36, 36) }, + {"gray15" , PALETTERGB (38, 38, 38) }, + {"grey15" , PALETTERGB (38, 38, 38) }, + {"gray16" , PALETTERGB (41, 41, 41) }, + {"grey16" , PALETTERGB (41, 41, 41) }, + {"gray17" , PALETTERGB (43, 43, 43) }, + {"grey17" , PALETTERGB (43, 43, 43) }, + {"gray18" , PALETTERGB (46, 46, 46) }, + {"grey18" , PALETTERGB (46, 46, 46) }, + {"gray19" , PALETTERGB (48, 48, 48) }, + {"grey19" , PALETTERGB (48, 48, 48) }, + {"gray20" , PALETTERGB (51, 51, 51) }, + {"grey20" , PALETTERGB (51, 51, 51) }, + {"gray21" , PALETTERGB (54, 54, 54) }, + {"grey21" , PALETTERGB (54, 54, 54) }, + {"gray22" , PALETTERGB (56, 56, 56) }, + {"grey22" , PALETTERGB (56, 56, 56) }, + {"gray23" , PALETTERGB (59, 59, 59) }, + {"grey23" , PALETTERGB (59, 59, 59) }, + {"gray24" , PALETTERGB (61, 61, 61) }, + {"grey24" , PALETTERGB (61, 61, 61) }, + {"gray25" , PALETTERGB (64, 64, 64) }, + {"grey25" , PALETTERGB (64, 64, 64) }, + {"gray26" , PALETTERGB (66, 66, 66) }, + {"grey26" , PALETTERGB (66, 66, 66) }, + {"gray27" , PALETTERGB (69, 69, 69) }, + {"grey27" , PALETTERGB (69, 69, 69) }, + {"gray28" , PALETTERGB (71, 71, 71) }, + {"grey28" , PALETTERGB (71, 71, 71) }, + {"gray29" , PALETTERGB (74, 74, 74) }, + {"grey29" , PALETTERGB (74, 74, 74) }, + {"gray30" , PALETTERGB (77, 77, 77) }, + {"grey30" , PALETTERGB (77, 77, 77) }, + {"gray31" , PALETTERGB (79, 79, 79) }, + {"grey31" , PALETTERGB (79, 79, 79) }, + {"gray32" , PALETTERGB (82, 82, 82) }, + {"grey32" , PALETTERGB (82, 82, 82) }, + {"gray33" , PALETTERGB (84, 84, 84) }, + {"grey33" , PALETTERGB (84, 84, 84) }, + {"gray34" , PALETTERGB (87, 87, 87) }, + {"grey34" , PALETTERGB (87, 87, 87) }, + {"gray35" , PALETTERGB (89, 89, 89) }, + {"grey35" , PALETTERGB (89, 89, 89) }, + {"gray36" , PALETTERGB (92, 92, 92) }, + {"grey36" , PALETTERGB (92, 92, 92) }, + {"gray37" , PALETTERGB (94, 94, 94) }, + {"grey37" , PALETTERGB (94, 94, 94) }, + {"gray38" , PALETTERGB (97, 97, 97) }, + {"grey38" , PALETTERGB (97, 97, 97) }, + {"gray39" , PALETTERGB (99, 99, 99) }, + {"grey39" , PALETTERGB (99, 99, 99) }, + {"gray40" , PALETTERGB (102, 102, 102) }, + {"grey40" , PALETTERGB (102, 102, 102) }, + {"gray41" , PALETTERGB (105, 105, 105) }, + {"grey41" , PALETTERGB (105, 105, 105) }, + {"gray42" , PALETTERGB (107, 107, 107) }, + {"grey42" , PALETTERGB (107, 107, 107) }, + {"gray43" , PALETTERGB (110, 110, 110) }, + {"grey43" , PALETTERGB (110, 110, 110) }, + {"gray44" , PALETTERGB (112, 112, 112) }, + {"grey44" , PALETTERGB (112, 112, 112) }, + {"gray45" , PALETTERGB (115, 115, 115) }, + {"grey45" , PALETTERGB (115, 115, 115) }, + {"gray46" , PALETTERGB (117, 117, 117) }, + {"grey46" , PALETTERGB (117, 117, 117) }, + {"gray47" , PALETTERGB (120, 120, 120) }, + {"grey47" , PALETTERGB (120, 120, 120) }, + {"gray48" , PALETTERGB (122, 122, 122) }, + {"grey48" , PALETTERGB (122, 122, 122) }, + {"gray49" , PALETTERGB (125, 125, 125) }, + {"grey49" , PALETTERGB (125, 125, 125) }, + {"gray50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ + {"grey50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ + {"gray51" , PALETTERGB (130, 130, 130) }, + {"grey51" , PALETTERGB (130, 130, 130) }, + {"gray52" , PALETTERGB (133, 133, 133) }, + {"grey52" , PALETTERGB (133, 133, 133) }, + {"gray53" , PALETTERGB (135, 135, 135) }, + {"grey53" , PALETTERGB (135, 135, 135) }, + {"gray54" , PALETTERGB (138, 138, 138) }, + {"grey54" , PALETTERGB (138, 138, 138) }, + {"gray55" , PALETTERGB (140, 140, 140) }, + {"grey55" , PALETTERGB (140, 140, 140) }, + {"gray56" , PALETTERGB (143, 143, 143) }, + {"grey56" , PALETTERGB (143, 143, 143) }, + {"gray57" , PALETTERGB (145, 145, 145) }, + {"grey57" , PALETTERGB (145, 145, 145) }, + {"gray58" , PALETTERGB (148, 148, 148) }, + {"grey58" , PALETTERGB (148, 148, 148) }, + {"gray59" , PALETTERGB (150, 150, 150) }, + {"grey59" , PALETTERGB (150, 150, 150) }, + {"gray60" , PALETTERGB (153, 153, 153) }, + {"grey60" , PALETTERGB (153, 153, 153) }, + {"gray61" , PALETTERGB (156, 156, 156) }, + {"grey61" , PALETTERGB (156, 156, 156) }, + {"gray62" , PALETTERGB (158, 158, 158) }, + {"grey62" , PALETTERGB (158, 158, 158) }, + {"gray63" , PALETTERGB (161, 161, 161) }, + {"grey63" , PALETTERGB (161, 161, 161) }, + {"gray64" , PALETTERGB (163, 163, 163) }, + {"grey64" , PALETTERGB (163, 163, 163) }, + {"gray65" , PALETTERGB (166, 166, 166) }, + {"grey65" , PALETTERGB (166, 166, 166) }, + {"gray66" , PALETTERGB (168, 168, 168) }, + {"grey66" , PALETTERGB (168, 168, 168) }, + {"gray67" , PALETTERGB (171, 171, 171) }, + {"grey67" , PALETTERGB (171, 171, 171) }, + {"gray68" , PALETTERGB (173, 173, 173) }, + {"grey68" , PALETTERGB (173, 173, 173) }, + {"gray69" , PALETTERGB (176, 176, 176) }, + {"grey69" , PALETTERGB (176, 176, 176) }, + {"gray70" , PALETTERGB (179, 179, 179) }, + {"grey70" , PALETTERGB (179, 179, 179) }, + {"gray71" , PALETTERGB (181, 181, 181) }, + {"grey71" , PALETTERGB (181, 181, 181) }, + {"gray72" , PALETTERGB (184, 184, 184) }, + {"grey72" , PALETTERGB (184, 184, 184) }, + {"gray73" , PALETTERGB (186, 186, 186) }, + {"grey73" , PALETTERGB (186, 186, 186) }, + {"gray74" , PALETTERGB (189, 189, 189) }, + {"grey74" , PALETTERGB (189, 189, 189) }, + {"gray75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ + {"grey75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ + {"gray76" , PALETTERGB (194, 194, 194) }, + {"grey76" , PALETTERGB (194, 194, 194) }, + {"gray77" , PALETTERGB (196, 196, 196) }, + {"grey77" , PALETTERGB (196, 196, 196) }, + {"gray78" , PALETTERGB (199, 199, 199) }, + {"grey78" , PALETTERGB (199, 199, 199) }, + {"gray79" , PALETTERGB (201, 201, 201) }, + {"grey79" , PALETTERGB (201, 201, 201) }, + {"gray80" , PALETTERGB (204, 204, 204) }, + {"grey80" , PALETTERGB (204, 204, 204) }, + {"gray81" , PALETTERGB (207, 207, 207) }, + {"grey81" , PALETTERGB (207, 207, 207) }, + {"gray82" , PALETTERGB (209, 209, 209) }, + {"grey82" , PALETTERGB (209, 209, 209) }, + {"gray83" , PALETTERGB (212, 212, 212) }, + {"grey83" , PALETTERGB (212, 212, 212) }, + {"gray84" , PALETTERGB (214, 214, 214) }, + {"grey84" , PALETTERGB (214, 214, 214) }, + {"gray85" , PALETTERGB (217, 217, 217) }, + {"grey85" , PALETTERGB (217, 217, 217) }, + {"gray86" , PALETTERGB (219, 219, 219) }, + {"grey86" , PALETTERGB (219, 219, 219) }, + {"gray87" , PALETTERGB (222, 222, 222) }, + {"grey87" , PALETTERGB (222, 222, 222) }, + {"gray88" , PALETTERGB (224, 224, 224) }, + {"grey88" , PALETTERGB (224, 224, 224) }, + {"gray89" , PALETTERGB (227, 227, 227) }, + {"grey89" , PALETTERGB (227, 227, 227) }, + {"gray90" , PALETTERGB (229, 229, 229) }, + {"grey90" , PALETTERGB (229, 229, 229) }, + {"gray91" , PALETTERGB (232, 232, 232) }, + {"grey91" , PALETTERGB (232, 232, 232) }, + {"gray92" , PALETTERGB (235, 235, 235) }, + {"grey92" , PALETTERGB (235, 235, 235) }, + {"gray93" , PALETTERGB (237, 237, 237) }, + {"grey93" , PALETTERGB (237, 237, 237) }, + {"gray94" , PALETTERGB (240, 240, 240) }, + {"grey94" , PALETTERGB (240, 240, 240) }, + {"gray95" , PALETTERGB (242, 242, 242) }, + {"grey95" , PALETTERGB (242, 242, 242) }, + {"gray96" , PALETTERGB (245, 245, 245) }, + {"grey96" , PALETTERGB (245, 245, 245) }, + {"gray97" , PALETTERGB (247, 247, 247) }, + {"grey97" , PALETTERGB (247, 247, 247) }, + {"gray98" , PALETTERGB (250, 250, 250) }, + {"grey98" , PALETTERGB (250, 250, 250) }, + {"gray99" , PALETTERGB (252, 252, 252) }, + {"grey99" , PALETTERGB (252, 252, 252) }, + {"gray100" , PALETTERGB (255, 255, 255) }, + {"grey100" , PALETTERGB (255, 255, 255) }, + {"DarkGrey" , PALETTERGB (169, 169, 169) }, + {"DarkGray" , PALETTERGB (169, 169, 169) }, + {"DarkBlue" , PALETTERGB (0, 0, 128) }, /* Adjusted == Navy */ + {"DarkCyan" , PALETTERGB (0, 128, 128) }, /* Adjusted */ + {"DarkMagenta" , PALETTERGB (128, 0, 128) }, /* Adjusted */ + {"DarkRed" , PALETTERGB (128, 0, 0) }, /* Adjusted */ + {"LightGreen" , PALETTERGB (144, 238, 144) }, + /* Added to match values in the default Windows palette: */ + {"DarkYellow" , PALETTERGB (128, 128, 0) }, + {"PaleYellow" , PALETTERGB (255, 255, 128) } +}; + + +typedef struct fontmap_t +{ + const Ascbyte *name; + int value; +} fontmap_t; + +/* Default weight first, preferred names listed before synonyms */ +static const fontmap_t fontweight_map[] = +{ + {"Regular" , FW_REGULAR}, /* The standard font weight */ + {"Thin" , FW_THIN}, + {"Extra Light" , FW_EXTRALIGHT}, + {"Ultra Light" , FW_ULTRALIGHT}, + {"Light" , FW_LIGHT}, + {"Normal" , FW_NORMAL}, + {"Medium" , FW_MEDIUM}, + {"Semi Bold" , FW_SEMIBOLD}, + {"Demi Bold" , FW_DEMIBOLD}, + {"Bold" , FW_BOLD}, /* The standard bold font weight */ + {"Extra Bold" , FW_EXTRABOLD}, + {"Ultra Bold" , FW_ULTRABOLD}, + {"Heavy" , FW_HEAVY}, + {"Black" , FW_BLACK} +}; + +/* Default charset must be listed first, no synonyms allowed because these + * names are matched against the names reported by win32 by match_font() */ +static const fontmap_t charset_map[] = +{ + {"Western" , ANSI_CHARSET}, /* Latin 1 */ + {"Central European" , EASTEUROPE_CHARSET}, + {"Cyrillic" , RUSSIAN_CHARSET}, + {"Greek" , GREEK_CHARSET}, + {"Turkish" , TURKISH_CHARSET}, + {"Hebrew" , HEBREW_CHARSET}, + {"Arabic" , ARABIC_CHARSET}, + {"Baltic" , BALTIC_CHARSET}, + {"Viet Nam" , VIETNAMESE_CHARSET}, + {"Thai" , THAI_CHARSET}, + {"Japanese" , SHIFTJIS_CHARSET}, + {"Korean" , HANGEUL_CHARSET}, + {"Simplified Chinese" , GB2312_CHARSET}, + {"Traditional Chinese", CHINESEBIG5_CHARSET}, + + {"Symbol" , SYMBOL_CHARSET}, + {"Mac" , MAC_CHARSET}, + {"Korean Johab" , JOHAB_CHARSET}, + {"OEM/DOS" , OEM_CHARSET} +}; + +#ifdef MULE + +typedef struct unicode_subrange_raw_t +{ + int subrange_bit; + int start; /* first Unicode codepoint */ + int end; /* last Unicode codepoint */ +} unicode_subrange_raw_t; + +/* This table comes from MSDN, Unicode Subset Bitfields [Platform SDK + Documentation, Base Services, International Features, Unicode and + Character Sets, Unicode and Character Set Reference, Unicode and + Character Set Constants]. We preprocess it at startup time into an + array of unicode_subrange_t. + */ + +static const unicode_subrange_raw_t unicode_subrange_raw_map[] = +{ + {0, 0x0020, 0x007e}, /* Basic Latin */ + {1, 0x00a0, 0x00ff}, /* Latin-1 Supplement */ + {2, 0x0100, 0x017f}, /* Latin Extended-A */ + {3, 0x0180, 0x024f}, /* Latin Extended-B */ + {4, 0x0250, 0x02af}, /* IPA Extensions */ + {5, 0x02b0, 0x02ff}, /* Spacing Modifier Letters */ + {6, 0x0300, 0x036f}, /* Combining Diacritical Marks */ + {7, 0x0370, 0x03ff}, /* Basic Greek */ + /* 8 Reserved */ + {9, 0x0400, 0x04ff}, /* Cyrillic */ + {10, 0x0530, 0x058f}, /* Armenian */ + {11, 0x0590, 0x05ff}, /* Basic Hebrew */ + /* 12 Reserved */ + {13, 0x0600, 0x06ff}, /* Basic Arabic */ + /* 14 Reserved */ + {15, 0x0900, 0x097f}, /* Devanagari */ + {16, 0x0980, 0x09ff}, /* Bengali */ + {17, 0x0a00, 0x0a7f}, /* Gurmukhi */ + {18, 0x0a80, 0x0aff}, /* Gujarati */ + {19, 0x0b00, 0x0b7f}, /* Oriya */ + {20, 0x0b80, 0x0bff}, /* Tamil */ + {21, 0x0c00, 0x0c7f}, /* Telugu */ + {22, 0x0c80, 0x0cff}, /* Kannada */ + {23, 0x0d00, 0x0d7f}, /* Malayalam */ + {24, 0x0e00, 0x0e7f}, /* Thai */ + {25, 0x0e80, 0x0eff}, /* Lao */ + {26, 0x10a0, 0x10ff}, /* Basic Georgian */ + /* 27 Reserved */ + {28, 0x1100, 0x11ff}, /* Hangul Jamo */ + {29, 0x1e00, 0x1eff}, /* Latin Extended Additional */ + {30, 0x1f00, 0x1fff}, /* Greek Extended */ + {31, 0x2000, 0x206f}, /* General Punctuation */ + {32, 0x2070, 0x209f}, /* Subscripts and Superscripts */ + {33, 0x20a0, 0x20cf}, /* Currency Symbols */ + {34, 0x20d0, 0x20ff}, /* Combining Diacritical Marks for Symbols */ + {35, 0x2100, 0x214f}, /* Letter-like Symbols */ + {36, 0x2150, 0x218f}, /* Number Forms */ + {37, 0x2190, 0x21ff}, /* Arrows */ + {38, 0x2200, 0x22ff}, /* Mathematical Operators */ + {39, 0x2300, 0x23ff}, /* Miscellaneous Technical */ + {40, 0x2400, 0x243f}, /* Control Pictures */ + {41, 0x2440, 0x245f}, /* Optical Character Recognition */ + {42, 0x2460, 0x24ff}, /* Enclosed Alphanumerics */ + {43, 0x2500, 0x257f}, /* Box Drawing */ + {44, 0x2580, 0x259f}, /* Block Elements */ + {45, 0x25a0, 0x25ff}, /* Geometric Shapes */ + {46, 0x2600, 0x26ff}, /* Miscellaneous Symbols */ + {47, 0x2700, 0x27bf}, /* Dingbats */ + {48, 0x3000, 0x303f}, /* Chinese, Japanese, and Korean (CJK) Symbols and Punctuation */ + {49, 0x3040, 0x309f}, /* Hiragana */ + {50, 0x30a0, 0x30ff}, /* Katakana */ + {51, 0x3100, 0x312f}, /* Bopomofo */ + {51, 0x31a0, 0x31bf}, /* Extended Bopomofo */ + {52, 0x3130, 0x318f}, /* Hangul Compatibility Jamo */ + {53, 0x3190, 0x319f}, /* CJK Miscellaneous */ + {54, 0x3200, 0x32ff}, /* Enclosed CJK Letters and Months */ + {55, 0x3300, 0x33ff}, /* CJK Compatibility */ + {56, 0xac00, 0xd7a3}, /* Hangul */ + {57, 0xd800, 0xdfff}, /* Surrogates. Note that setting this bit implies that there is at least one codepoint beyond the Basic Multilingual Plane that is supported by this font. */ + /* 58 Reserved */ + {59, 0x4e00, 0x9fff}, /* CJK Unified Ideographs */ + {59, 0x2e80, 0x2eff}, /* CJK Radicals Supplement */ + {59, 0x2f00, 0x2fdf}, /* Kangxi Radicals */ + {59, 0x2ff0, 0x2fff}, /* Ideographic Description */ + {59, 0x3400, 0x4dbf}, /* CJK Unified Ideograph Extension A */ + {60, 0xe000, 0xf8ff}, /* Private Use Area */ + {61, 0xf900, 0xfaff}, /* CJK Compatibility Ideographs */ + {62, 0xfb00, 0xfb4f}, /* Alphabetic Presentation Forms */ + {63, 0xfb50, 0xfdff}, /* Arabic Presentation Forms-A */ + {64, 0xfe20, 0xfe2f}, /* Combining Half Marks */ + {65, 0xfe30, 0xfe4f}, /* CJK Compatibility Forms */ + {66, 0xfe50, 0xfe6f}, /* Small Form Variants */ + {67, 0xfe70, 0xfefe}, /* Arabic Presentation Forms-B */ + {68, 0xff00, 0xffef}, /* Halfwidth and Fullwidth Forms */ + {69, 0xfff0, 0xfffd}, /* Specials */ + {70, 0x0f00, 0x0fcf}, /* Tibetan */ + {71, 0x0700, 0x074f}, /* Syriac */ + {72, 0x0780, 0x07bf}, /* Thaana */ + {73, 0x0d80, 0x0dff}, /* Sinhala */ + {74, 0x1000, 0x109f}, /* Myanmar */ + {75, 0x1200, 0x12bf}, /* Ethiopic */ + {76, 0x13a0, 0x13ff}, /* Cherokee */ + {77, 0x1400, 0x14df}, /* Canadian Aboriginal Syllabics */ + {78, 0x1680, 0x169f}, /* Ogham */ + {79, 0x16a0, 0x16ff}, /* Runic */ + {80, 0x1780, 0x17ff}, /* Khmer */ + {81, 0x1800, 0x18af}, /* Mongolian */ + {82, 0x2800, 0x28ff}, /* Braille */ + {83, 0xa000, 0xa48c}, /* Yi, Yi Radicals */ + /* 84-122 Reserved */ + /* 123 Windows 2000/XP: Layout progress: horizontal from right to left */ + /* 124 Windows 2000/XP: Layout progress: vertical before horizontal */ + /* 125 Windows 2000/XP: Layout progress: vertical bottom to top */ + /* 126 Reserved; must be 0 */ + /* 127 Reserved; must be 1 */ +}; + +typedef struct unicode_subrange_t +{ + int no_subranges; + const unicode_subrange_raw_t *subranges; +} unicode_subrange_t; + +unicode_subrange_t *unicode_subrange_table; + +/* Hash table mapping font specs (strings) to font signature data + (FONTSIGNATURE structures stored in opaques), as determined by + GetTextCharsetInfo(). I presume this is somewhat expensive because it + involves creating a font object. At the very least, with no hashing, it + definitely took awhile (a few seconds) when encountering characters from + charsets needing stage 2 processing. */ +Lisp_Object Vfont_signature_data; + +#endif /* MULE */ + + +/************************************************************************/ +/* helpers */ +/************************************************************************/ + +static int +hexval (Ibyte c) +{ + /* assumes ASCII and isxdigit (c) */ + if (c >= 'a') + return c - 'a' + 10; + else if (c >= 'A') + return c - 'A' + 10; + else + return c - '0'; +} + +COLORREF +mswindows_string_to_color (const Ibyte *name) +{ + int i; + + if (*name == '#') + { + /* numeric names look like "#RRGGBB", "#RRRGGGBBB" or "#RRRRGGGGBBBB" + or "rgb:rrrr/gggg/bbbb" */ + unsigned int r, g, b; + + for (i = 1; i < qxestrlen (name); i++) + { + if (!byte_ascii_p (name[i]) || !isxdigit ((int) name[i])) + return (COLORREF) -1; + } + if (qxestrlen (name) == 7) + { + r = hexval (name[1]) * 16 + hexval (name[2]); + g = hexval (name[3]) * 16 + hexval (name[4]); + b = hexval (name[5]) * 16 + hexval (name[6]); + return (PALETTERGB (r, g, b)); + } + else if (qxestrlen (name) == 10) + { + r = hexval (name[1]) * 16 + hexval (name[2]); + g = hexval (name[4]) * 16 + hexval (name[5]); + b = hexval (name[7]) * 16 + hexval (name[8]); + return (PALETTERGB (r, g, b)); + } + else if (qxestrlen (name) == 13) + { + r = hexval (name[1]) * 16 + hexval (name[2]); + g = hexval (name[5]) * 16 + hexval (name[6]); + b = hexval (name[9]) * 16 + hexval (name[10]); + return (PALETTERGB (r, g, b)); + } + } + else if (!qxestrncmp_ascii (name, "rgb:", 4)) + { + unsigned int r, g, b; + + if (sscanf ((CIbyte *) name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) + { + int len = qxestrlen (name); + if (len == 18) + { + r /= 257; + g /= 257; + b /= 257; + } + else if (len == 15) + { + r /= 17; + g /= 17; + b /= 17; + } + return (PALETTERGB (r, g, b)); + } + else + return (COLORREF) -1; + } + else if (*name) /* Can't be an empty string */ + { + Ibyte *nospaces = alloca_ibytes (qxestrlen (name) + 1); + Ibyte *c = nospaces; + while (*name) + if (*name != ' ') + *c++ = *name++; + else + name++; + *c = '\0'; + + for (i = 0; i < countof (mswindows_X_color_map); i++) + if (!qxestrcasecmp_ascii (nospaces, mswindows_X_color_map[i].name)) + return (mswindows_X_color_map[i].colorref); + } + return (COLORREF) -1; +} + +Lisp_Object +mswindows_color_to_string (COLORREF color) +{ + int i; + Ascbyte buf[8]; + COLORREF pcolor = PALETTERGB (GetRValue (color), GetGValue (color), + GetBValue (color)); + + for (i = 0; i < countof (mswindows_X_color_map); i++) + if (pcolor == (mswindows_X_color_map[i].colorref)) + return build_ascstring (mswindows_X_color_map[i].name); + + sprintf (buf, "#%02X%02X%02X", + GetRValue (color), GetGValue (color), GetBValue (color)); + return build_ascstring (buf); +} + +/* + * Returns non-zero if the two supplied font patterns match. + * If they match and fontname is not NULL, copies the logical OR of the + * patterns to fontname (which is assumed to be at least MSW_FONTSIZE in size). + * + * The patterns 'match' iff for each field that is not blank in either pattern, + * the corresponding field in the other pattern is either identical or blank. + */ +static int +match_font (Ibyte *pattern1, Ibyte *pattern2, + Ibyte *fontname) +{ + Ibyte *c1 = pattern1, *c2 = pattern2, *e1 = 0, *e2 = 0; + int i; + + if (fontname) + fontname[0] = '\0'; + + for (i = 0; i < 5; i++) + { + if (c1 && (e1 = qxestrchr (c1, ':'))) + *(e1) = '\0'; + if (c2 && (e2 = qxestrchr (c2, ':'))) + *(e2) = '\0'; + + if (c1 && c1[0] != '\0') + { + if (c2 && c2[0] != '\0' && qxestrcasecmp (c1, c2)) + { + if (e1) *e1 = ':'; + if (e2) *e2 = ':'; + return 0; + } + else if (fontname) + qxestrcat_ascii (qxestrcat (fontname, c1), ":"); + } + else if (fontname) + { + if (c2 && c2[0] != '\0') + qxestrcat_ascii (qxestrcat (fontname, c2), ":"); + else + qxestrcat_ascii (fontname, ":"); + } + + if (e1) *(e1++) = ':'; + if (e2) *(e2++) = ':'; + c1 = e1; + c2 = e2; + } + + if (fontname) + fontname[qxestrlen (fontname) - 1] = '\0'; /* Trim trailing ':' */ + return 1; +} + + +/************************************************************************/ +/* exports */ +/************************************************************************/ + +struct font_enum_t +{ + HDC hdc; + Lisp_Object list; +}; + +static int CALLBACK +font_enum_callback_2 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, + int FontType, struct font_enum_t *font_enum) +{ + Ibyte fontname[MSW_FONTSIZE * 2 * MAX_ICHAR_LEN]; /* should be enough :)*/ + Lisp_Object fontname_lispstr; + int i; + Ibyte *facename; + + /* + * The enumerated font weights are not to be trusted because: + * a) lpelfe->elfStyle is only filled in for TrueType fonts. + * b) Not all Bold and Italic styles of all fonts (including some Vector, + * Truetype and Raster fonts) are enumerated. + * I guess that fonts for which Bold and Italic styles are generated + * 'on-the-fly' are not enumerated. It would be overly restrictive to + * disallow Bold And Italic weights for these fonts, so we just leave + * weights unspecified. This means that we have to weed out duplicates of + * those fonts that do get enumerated with different weights. + */ + facename = TSTR_TO_ITEXT (lpelfe->elfLogFont.lfFaceName); + if (itext_ichar (facename) == '@') + /* This is a font for writing vertically. We ignore it. */ + return 1; + + if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) + /* Scalable, so leave pointsize blank */ + qxesprintf (fontname, "%s::::", facename); + else + /* Formula for pointsize->height from LOGFONT docs in Platform SDK */ + qxesprintf (fontname, "%s::%d::", facename, + MulDiv (lpntme->ntmTm.tmHeight - + lpntme->ntmTm.tmInternalLeading, + 72, GetDeviceCaps (font_enum->hdc, LOGPIXELSY))); + + /* + * The enumerated font character set strings are not to be trusted because + * lpelfe->elfScript is returned in the host language and not in English. + * We can't know a priori the translations of "Western", "Central European" + * etc into the host language, so we must use English. The same argument + * applies to the font weight string when matching fonts. + */ + for (i = 0; i < countof (charset_map); i++) + if (lpelfe->elfLogFont.lfCharSet == charset_map[i].value) + { + qxestrcat_ascii (fontname, charset_map[i].name); + break; + } + if (i == countof (charset_map)) + return 1; + + /* Add the font name to the list if not already there */ + fontname_lispstr = build_istring (fontname); + if (NILP (Fassoc (fontname_lispstr, font_enum->list))) + font_enum->list = + Fcons (Fcons (fontname_lispstr, + /* TMPF_FIXED_PITCH is backwards from what you expect! + If set, it means NOT fixed pitch. */ + (lpntme->ntmTm.tmPitchAndFamily & TMPF_FIXED_PITCH) ? + Qnil : Qt), + font_enum->list); + + return 1; +} + +static int CALLBACK +font_enum_callback_1 (ENUMLOGFONTEXW *lpelfe, + NEWTEXTMETRICEXW *UNUSED (lpntme), + int UNUSED (FontType), struct font_enum_t *font_enum) +{ + /* This function gets called once per facename per character set. + * We call a second callback to enumerate the fonts in each facename */ + return qxeEnumFontFamiliesEx (font_enum->hdc, &lpelfe->elfLogFont, + (FONTENUMPROCW) font_enum_callback_2, + (LPARAM) font_enum, 0); +} + +/* Function for sorting lists of fonts as obtained from + mswindows_enumerate_fonts(). These come in a known format: + "family::::charset" for TrueType fonts, "family::size::charset" + otherwise. */ + +static int +sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2, + Lisp_Object UNUSED (pred)) +{ + Ibyte *font1, *font2; + Ibyte *c1, *c2; + int t1, t2; + + /* + 1. fixed over proportional. + 2. Western over other charsets. + 3. TrueType over non-TrueType. + 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt. + 5. Courier New over other families. + */ + + /* The sort function should return > 0 if OBJ1 < OBJ2, < 0 otherwise. + NOTE: This is backwards from the way qsort() works. */ + + t1 = !NILP (XCDR (obj1)); + t2 = !NILP (XCDR (obj2)); + + if (t1 && !t2) + return 1; + if (t2 && !t1) + return -1; + + font1 = XSTRING_DATA (XCAR (obj1)); + font2 = XSTRING_DATA (XCAR (obj2)); + + c1 = qxestrrchr (font1, ':'); + c2 = qxestrrchr (font2, ':'); + + t1 = !qxestrcasecmp_ascii (c1 + 1, "western"); + t2 = !qxestrcasecmp_ascii (c2 + 1, "western"); + + if (t1 && !t2) + return 1; + if (t2 && !t1) + return -1; + + c1 -= 2; + c2 -= 2; + t1 = *c1 == ':'; + t2 = *c2 == ':'; + + if (t1 && !t2) + return 1; + if (t2 && !t1) + return -1; + + if (!t1 && !t2) + { + while (isdigit (*c1)) + c1--; + while (isdigit (*c2)) + c2--; + + t1 = qxeatoi (c1 + 1) - 10; + t2 = qxeatoi (c2 + 1) - 10; + + if (abs (t1) < abs (t2)) + return 1; + else if (abs (t2) < abs (t1)) + return -1; + else if (t1 < t2) + /* Prefer a smaller font over a larger one just as far away + because the smaller one won't upset the total line height if it's + just a few chars. */ + return 1; + } + + t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12); + t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12); + + if (t1 && !t2) + return 1; + if (t2 && !t1) + return -1; + + return -1; +} + +/* + * Enumerate the available on the HDC fonts and return a list of string + * font names. + */ +Lisp_Object +mswindows_enumerate_fonts (HDC hdc) +{ + /* This cannot GC */ + LOGFONTW logfont; + struct font_enum_t font_enum; + + assert (hdc != NULL); + logfont.lfCharSet = DEFAULT_CHARSET; + logfont.lfFaceName[0] = '\0'; + logfont.lfPitchAndFamily = DEFAULT_PITCH; + font_enum.hdc = hdc; + font_enum.list = Qnil; + /* EnumFontFamilies seems to enumerate only one charset per font, which + is not what we want. We aren't supporting NT 3.5x, so no need to + worry about this not existing. */ + qxeEnumFontFamiliesEx (hdc, &logfont, (FONTENUMPROCW) font_enum_callback_1, + (LPARAM) (&font_enum), 0); + + return list_sort (font_enum.list, Qnil, sort_font_list_function); +} + +static HFONT +mswindows_create_font_variant (Lisp_Font_Instance *f, + int under, int strike) +{ + /* Cannot GC */ + LOGFONTW lf; + HFONT hfont; + + assert (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) == NULL); + + if (qxeGetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0), + sizeof (lf), (void *) &lf) == 0) + { + hfont = MSWINDOWS_BAD_HFONT; + } + else + { + lf.lfUnderline = under; + lf.lfStrikeOut = strike; + + hfont = qxeCreateFontIndirect (&lf); + if (hfont == NULL) + hfont = MSWINDOWS_BAD_HFONT; + } + + FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) = hfont; + return hfont; +} + +HFONT +mswindows_get_hfont (Lisp_Font_Instance *f, + int under, int strike) +{ + /* Cannot GC */ + HFONT hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike); + + if (hfont == NULL) + hfont = mswindows_create_font_variant (f, under, strike); + + /* If strikeout/underline variant of the font could not be + created, then use the base version of the font */ + if (hfont == MSWINDOWS_BAD_HFONT) + hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0); + + assert (hfont != NULL && hfont != MSWINDOWS_BAD_HFONT); + + return hfont; +} + +/************************************************************************/ +/* methods */ +/************************************************************************/ + +static int +mswindows_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, + Lisp_Object UNUSED (device), + Error_Behavior errb) +{ + COLORREF color; + + color = mswindows_string_to_color (XSTRING_DATA (name)); + if (color != (COLORREF) -1) + { + c->data = xnew (struct mswindows_color_instance_data); + COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color; + return 1; + } + maybe_signal_error (Qinvalid_constant, + "Unrecognized color", name, Qcolor, errb); + return(0); +} + +#if 0 +static void +mswindows_mark_color_instance (Lisp_Color_Instance *c) +{ +} +#endif + +static void +mswindows_print_color_instance (Lisp_Color_Instance *c, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); + write_fmt_string (printcharfun, + " %06ld=(%04X,%04X,%04X)", color & 0xffffff, + GetRValue (color) * 257, GetGValue (color) * 257, + GetBValue (color) * 257); +} + +static void +mswindows_finalize_color_instance (Lisp_Color_Instance *c) +{ + if (c->data) + { + xfree (c->data); + c->data = 0; + } +} + +static int +mswindows_color_instance_equal (Lisp_Color_Instance *c1, + Lisp_Color_Instance *c2, + int UNUSED (depth)) +{ + return (COLOR_INSTANCE_MSWINDOWS_COLOR (c1) == + COLOR_INSTANCE_MSWINDOWS_COLOR (c2)); +} + +static Hashcode +mswindows_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) +{ + return (unsigned long) COLOR_INSTANCE_MSWINDOWS_COLOR (c); +} + +static Lisp_Object +mswindows_color_instance_rgb_components (Lisp_Color_Instance *c) +{ + COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); + return list3 (make_int (GetRValue (color) * 257), + make_int (GetGValue (color) * 257), + make_int (GetBValue (color) * 257)); +} + +static int +mswindows_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) +{ + return (mswindows_string_to_color (XSTRING_DATA (color)) != (COLORREF) -1); +} + + + +static void +mswindows_finalize_font_instance (Lisp_Font_Instance *f); + +/* Parse the font spec in NAMESTR. Maybe issue errors, according to ERRB; + NAME_FOR_ERRORS is the Lisp string to use when issuing errors. Store + the five parts of the font spec into the given strings, which should be + declared as + + Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; + Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; + + If LOGFONT is given, store the necessary information in LOGFONT to + create a font object. If LOGFONT is given, HDC must also be given; + else, NULL can be given for both. + + Return 1 if ok, 0 if error. + */ +static int +parse_font_spec (const Ibyte *namestr, + HDC hdc, + Lisp_Object name_for_errors, + Error_Behavior errb, + LOGFONTW *logfont, + Ibyte *fontname, + Ibyte *weight, + Ibyte *points, + Ibyte *effects, + Ibyte *charset) +{ + int fields, i; + int pt; + Ibyte *style; + Ibyte *c; + + /* + * mswindows fonts look like: + * fontname[:[weight ][style][:pointsize[:effects]]][:charset] + * The font name field shouldn't be empty. + * + * ie: + * Lucida Console:Regular:10 + * minimal: + * Courier New + * maximal: + * Courier New:Bold Italic:10:underline strikeout:western + */ + + fontname[0] = 0; + weight[0] = 0; + points[0] = 0; + effects[0] = 0; + charset[0] = 0; + + if (logfont) + xzero (*logfont); + + fields = sscanf ((CIbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s", + fontname, weight, points, effects, charset); + + /* This function is implemented in a fairly ad-hoc manner. + * The general idea is to validate and canonicalize each of the above fields + * at the same time as we build up the win32 LOGFONT structure. This enables + * us to use match_font() on a canonicalized font string to check the + * availability of the requested font */ + + if (fields < 0) + { + maybe_signal_error (Qinvalid_argument, "Invalid font", name_for_errors, + Qfont, errb); + return 0; + } + + if (fields > 0 && qxestrlen (fontname)) + { + Extbyte *extfontname; + + extfontname = ITEXT_TO_TSTR (fontname); + if (logfont) + { + qxetcsncpy ((Extbyte *) logfont->lfFaceName, extfontname, + LF_FACESIZE - 1); + logfont->lfFaceName[LF_FACESIZE - 1] = 0; + } + } + + /* weight */ + if (fields < 2) + qxestrcpy_ascii (weight, fontweight_map[0].name); + + /* Maybe split weight into weight and style */ + if ((c = qxestrchr (weight, ' '))) + { + *c = '\0'; + style = c + 1; + } + else + style = NULL; + + for (i = 0; i < countof (fontweight_map); i++) + if (!qxestrcasecmp_ascii (weight, fontweight_map[i].name)) + { + if (logfont) + logfont->lfWeight = fontweight_map[i].value; + break; + } + if (i == countof (fontweight_map)) /* No matching weight */ + { + if (!style) + { + if (logfont) + logfont->lfWeight = FW_REGULAR; + style = weight; /* May have specified style without weight */ + } + else + { + maybe_signal_error (Qinvalid_constant, "Invalid font weight", + name_for_errors, Qfont, errb); + return 0; + } + } + + if (style) + { + /* #### what about oblique? */ + if (qxestrcasecmp_ascii (style, "italic") == 0) + { + if (logfont) + logfont->lfItalic = TRUE; + } + else + { + maybe_signal_error (Qinvalid_constant, + "Invalid font weight or style", + name_for_errors, Qfont, errb); + return 0; + } + + /* Glue weight and style together again */ + if (weight != style) + *c = ' '; + } + else if (logfont) + logfont->lfItalic = FALSE; + + if (fields < 3 || !qxestrcmp_ascii (points, "")) + ; + else if (points[0] == '0' || + qxestrspn (points, "0123456789") < qxestrlen (points)) + { + maybe_signal_error (Qinvalid_argument, "Invalid font pointsize", + name_for_errors, Qfont, errb); + return 0; + } + else + { + pt = qxeatoi (points); + + if (logfont) + { + /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform + SDK */ + logfont->lfHeight = -MulDiv (pt, GetDeviceCaps (hdc, LOGPIXELSY), + 72); + logfont->lfWidth = 0; + } + } + + /* Effects */ + if (logfont) + { + logfont->lfUnderline = FALSE; + logfont->lfStrikeOut = FALSE; + } + + if (fields >= 4 && effects[0] != '\0') + { + Ibyte *effects2; + int underline = FALSE, strikeout = FALSE; + + /* Maybe split effects into effects and effects2 */ + if ((c = qxestrchr (effects, ' '))) + { + *c = '\0'; + effects2 = c + 1; + } + else + effects2 = NULL; + + if (qxestrcasecmp_ascii (effects, "underline") == 0) + underline = TRUE; + else if (qxestrcasecmp_ascii (effects, "strikeout") == 0) + strikeout = TRUE; + else + { + maybe_signal_error (Qinvalid_constant, "Invalid font effect", + name_for_errors, Qfont, errb); + return 0; + } + + if (effects2 && effects2[0] != '\0') + { + if (qxestrcasecmp_ascii (effects2, "underline") == 0) + underline = TRUE; + else if (qxestrcasecmp_ascii (effects2, "strikeout") == 0) + strikeout = TRUE; + else + { + maybe_signal_error (Qinvalid_constant, "Invalid font effect", + name_for_errors, Qfont, errb); + return 0; + } + } + + /* Regenerate sanitized effects string */ + if (underline) + { + if (strikeout) + qxestrcpy_ascii (effects, "underline strikeout"); + else + qxestrcpy_ascii (effects, "underline"); + } + else if (strikeout) + qxestrcpy_ascii (effects, "strikeout"); + + if (logfont) + { + logfont->lfUnderline = underline; + logfont->lfStrikeOut = strikeout; + } + } + + /* Charset */ + /* charset can be specified even if earlier fields haven't been */ + if (fields < 5) + { + if ((c = qxestrchr (namestr, ':')) && (c = qxestrchr (c + 1, ':')) && + (c = qxestrchr (c + 1, ':')) && (c = qxestrchr (c + 1, ':'))) + { + qxestrncpy (charset, c + 1, LF_FACESIZE); + charset[LF_FACESIZE - 1] = '\0'; + } + } + + /* NOTE: If you give a blank charset spec, we will normally not get here + under Mule unless we explicitly call `make-font-instance'! This is + because the C code instantiates fonts using particular charsets, by + way of specifier_matching_instance(). Before instantiating the font, + font_instantiate() calls the devmeth find_matching_font(), which gets + a truename font spec with the registry (i.e. the charset spec) filled + in appropriately to the charset. */ + if (!qxestrcmp_ascii (charset, "")) + ; + else + { + for (i = 0; i < countof (charset_map); i++) + if (!qxestrcasecmp_ascii (charset, charset_map[i].name)) + { + if (logfont) + logfont->lfCharSet = charset_map[i].value; + break; + } + + if (i == countof (charset_map)) /* No matching charset */ + { + maybe_signal_error (Qinvalid_argument, "Invalid charset", + name_for_errors, Qfont, errb); + return 0; + } + } + + if (logfont) + { + /* Misc crud */ +#if 1 + logfont->lfOutPrecision = OUT_DEFAULT_PRECIS; + logfont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + logfont->lfQuality = DEFAULT_QUALITY; +#else + logfont->lfOutPrecision = OUT_STROKE_PRECIS; + logfont->lfClipPrecision = CLIP_STROKE_PRECIS; + logfont->lfQuality = PROOF_QUALITY; +#endif + /* Default to monospaced if the specified fontname doesn't exist. */ + logfont->lfPitchAndFamily = FF_MODERN; + } + + return 1; +} + +/* + mswindows fonts look like: + [fontname[:style[:pointsize[:effects]]]][:charset] + A maximal mswindows font spec looks like: + Courier New:Bold Italic:10:underline strikeout:Western + + A missing weight/style field is the same as Regular, and a missing + effects field is left alone, and means no effects; but a missing + fontname, pointsize or charset field means any will do. We prefer + Courier New, 10, Western. See sort function above. */ + +static HFONT +create_hfont_from_font_spec (const Ibyte *namestr, + HDC hdc, + Lisp_Object name_for_errors, + Lisp_Object device_font_list, + Error_Behavior errb, + Lisp_Object *truename_ret) +{ + LOGFONTW logfont; + HFONT hfont; + Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; + Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; + Ibyte truename[MSW_FONTSIZE]; + Ibyte truername[MSW_FONTSIZE]; + + /* Windows will silently substitute a default font if the fontname + specifies a non-existent font. This is bad for screen fonts because + it doesn't allow higher-level code to see the error and to act + appropriately. For instance complex_vars_of_faces() sets up a + fallback list of fonts for the default face. Instead, we look at all + the possibilities and pick one that works, handling missing pointsize + and charset fields appropriately. + + For printer fonts, we used to go ahead and let Windows choose the + font, and for those devices, then, DEVICE_FONT_LIST would be nil. + However, this causes problems with the font-matching code below, which + needs a list of fonts so it can pick the right one for Mule. + + Thus, the code below to handle a nil DEVICE_FONT_LIST is not currently + used. */ + + if (!NILP (device_font_list)) + { + Lisp_Object fonttail = Qnil; + + if (!parse_font_spec (namestr, 0, name_for_errors, + errb, 0, fontname, weight, points, + effects, charset)) + return 0; + + /* The fonts in the device font list always specify fontname and + charset, but often times not the size; so if we don't have the + size specified either, do a round with size 10 so we'll always end + up with a size in the truename (if we fail this one but succeed + the next one, we'll have chosen a non-TrueType font, and in those + cases the size is specified in the font list item. */ + + if (!points[0]) + { + qxesprintf (truename, "%s:%s:10:%s:%s", + fontname, weight, effects, charset); + + LIST_LOOP (fonttail, device_font_list) + { + if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), + truename, truername)) + break; + } + } + + if (NILP (fonttail)) + { + qxesprintf (truename, "%s:%s:%s:%s:%s", + fontname, weight, points, effects, charset); + + LIST_LOOP (fonttail, device_font_list) + { + if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), + truename, truername)) + break; + } + } + + if (NILP (fonttail)) + { + maybe_signal_error (Qinvalid_argument, "No matching font", + name_for_errors, Qfont, errb); + return 0; + } + + if (!parse_font_spec (truername, hdc, name_for_errors, + ERROR_ME_DEBUG_WARN, &logfont, fontname, weight, + points, effects, charset)) + signal_error (Qinternal_error, "Bad value in device font list?", + build_istring (truername)); + } + else if (!parse_font_spec (namestr, hdc, name_for_errors, + errb, &logfont, fontname, weight, points, + effects, charset)) + return 0; + + if ((hfont = qxeCreateFontIndirect (&logfont)) == NULL) + { + maybe_signal_error (Qgui_error, "Couldn't create font", + name_for_errors, Qfont, errb); + return 0; + } + + /* #### Truename will not have all its fields filled in when we have no + list of fonts. Doesn't really matter now, since we always have one. + See above. */ + qxesprintf (truename, "%s:%s:%s:%s:%s", fontname, weight, + points, effects, charset); + + *truename_ret = build_istring (truename); + return hfont; +} + +/* + * This is a work horse for both mswindows_initialize_font_instance and + * msprinter_initialize_font_instance. + */ +static int +initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, + Lisp_Object device_font_list, HDC hdc, + Error_Behavior errb) +{ + HFONT hfont, hfont2; + TEXTMETRICW metrics; + Ibyte *namestr = XSTRING_DATA (name); + Lisp_Object truename; + + hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list, + errb, &truename); + if (!hfont) + return 0; + f->truename = truename; + f->data = xnew_and_zero (struct mswindows_font_instance_data); + FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0) = hfont; + + /* Some underlined fonts have the descent of one pixel more than their + non-underlined counterparts. Font variants though are assumed to have + identical metrics. So get the font metrics from the underlined variant + of the font */ + hfont2 = mswindows_create_font_variant (f, 1, 0); + if (hfont2 != MSWINDOWS_BAD_HFONT) + hfont = hfont2; + + hfont2 = (HFONT) SelectObject (hdc, hfont); + if (!hfont2) + { + mswindows_finalize_font_instance (f); + maybe_signal_error (Qgui_error, "Couldn't map font", name, Qfont, errb); + return 0; + } + qxeGetTextMetrics (hdc, &metrics); + SelectObject (hdc, hfont2); + + f->width = (unsigned short) metrics.tmAveCharWidth; + f->height = (unsigned short) metrics.tmHeight; + f->ascent = (unsigned short) metrics.tmAscent; + f->descent = (unsigned short) metrics.tmDescent; + f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH); + + return 1; +} + +static int +mswindows_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, + Lisp_Object device, Error_Behavior errb) +{ + HDC hdc = CreateCompatibleDC (NULL); + Lisp_Object font_list = DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device)); + int res = initialize_font_instance (f, name, font_list, hdc, errb); + DeleteDC (hdc); + return res; +} + +static int +msprinter_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, + Lisp_Object device, Error_Behavior errb) +{ + HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (device)); + Lisp_Object font_list = DEVICE_MSPRINTER_FONTLIST (XDEVICE (device)); + return initialize_font_instance (f, name, font_list, hdc, errb); +} + +static void +mswindows_finalize_font_instance (Lisp_Font_Instance *f) +{ + int i; + + if (f->data) + { + for (i = 0; i < MSWINDOWS_NUM_FONT_VARIANTS; i++) + { + if (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != NULL + && FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != MSWINDOWS_BAD_HFONT) + DeleteObject (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i)); + } + + xfree (f->data); + f->data = 0; + } +} + +#if 0 +static void +mswindows_mark_font_instance (Lisp_Font_Instance *f) +{ +} +#endif + +static void +mswindows_print_font_instance (Lisp_Font_Instance *f, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + write_fmt_string (printcharfun, " 0x%lx", + (unsigned long) + FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0)); + +} + +static Lisp_Object +mswindows_font_list (Lisp_Object pattern, Lisp_Object device, + Lisp_Object UNUSED (maxnumber)) +{ + struct device *d = XDEVICE (device); + Lisp_Object font_list = Qnil, fonttail, result = Qnil; + + if (DEVICE_MSWINDOWS_P (d)) + font_list = DEVICE_MSWINDOWS_FONTLIST (d); + else if (DEVICE_MSPRINTER_P (d)) + font_list = DEVICE_MSPRINTER_FONTLIST (d); + else + ABORT (); + + LIST_LOOP (fonttail, font_list) + { + Ibyte fontname[MSW_FONTSIZE]; + + if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), + XSTRING_DATA (pattern), + fontname)) + result = Fcons (build_istring (fontname), result); + } + + return Fnreverse (result); +} + +static Lisp_Object +mswindows_font_instance_truename (Lisp_Font_Instance *f, + Error_Behavior UNUSED (errb)) +{ + return f->truename; +} + +#ifdef MULE + +static int +mswindows_font_spec_matches_charset_stage_1 (struct device *UNUSED (d), + Lisp_Object charset, + const Ibyte *nonreloc, + Lisp_Object reloc, + Bytecount offset, + Bytecount length) +{ + int i; + Lisp_Object charset_registry; + const Ibyte *font_charset; + const Ibyte *the_nonreloc = nonreloc; + const Ibyte *c; + Bytecount the_length = length; + + if (NILP (charset)) + return 1; + + if (!the_nonreloc) + the_nonreloc = XSTRING_DATA (reloc); + fixup_internal_substring (nonreloc, reloc, offset, &the_length); + the_nonreloc += offset; + + c = the_nonreloc; + for (i = 0; i < 4; i++) + { + Ibyte *newc = (Ibyte *) memchr (c, ':', the_length); + if (!newc) + break; + newc++; + the_length -= (newc - c); + c = newc; + } + + if (i < 4) + return 0; + + font_charset = c; + + /* For border-glyph use */ + if (!qxestrcasecmp_ascii (font_charset, "symbol")) + font_charset = (const Ibyte *) "western"; + + /* Get code page for the charset */ + charset_registry = Fmswindows_charset_registry (charset); + if (!STRINGP (charset_registry)) + return 0; + + return !qxestrcasecmp (XSTRING_DATA (charset_registry), font_charset); +} + +/* + +#### The following comment is old and probably not applicable any longer. + +1. handle standard mapping and inheritance vectors properly in Face-frob-property. +2. finish impl of mswindows-charset-registry. +3. see if everything works under fixup, now that i copied the stuff over. +4. consider generalizing Face-frob-property to frob-specifier. +5. maybe extract some of the flets out of Face-frob-property as useful specifier frobbing. +6. eventually this stuff's got to be checked in!!!! +*/ + +static int +mswindows_font_spec_matches_charset_stage_2 (struct device *d, + Lisp_Object charset, + const Ibyte *nonreloc, + Lisp_Object reloc, + Bytecount offset, + Bytecount length) +{ + const Ibyte *the_nonreloc = nonreloc; + FONTSIGNATURE fs; + FONTSIGNATURE *fsp = &fs; + struct gcpro gcpro1; + Lisp_Object fontsig; + Bytecount the_length = length; + int i; + + if (NILP (charset)) + return 1; + + if (!the_nonreloc) + the_nonreloc = XSTRING_DATA (reloc); + fixup_internal_substring (nonreloc, reloc, offset, &the_length); + the_nonreloc += offset; + + /* Get the list of Unicode subranges corresponding to the font. This + is contained inside of FONTSIGNATURE data, obtained by calling + GetTextCharsetInfo on a font object, which we need to create from the + spec. See if the FONTSIGNATURE data is already cached. If not, get + it and cache it. */ + if (!STRINGP (reloc) || the_nonreloc != XSTRING_DATA (reloc)) + reloc = build_istring (the_nonreloc); + GCPRO1 (reloc); + fontsig = Fgethash (reloc, Vfont_signature_data, Qunbound); + + if (!UNBOUNDP (fontsig)) + { + fsp = (FONTSIGNATURE *) XOPAQUE_DATA (fontsig); + UNGCPRO; + } + else + { + HDC hdc = CreateCompatibleDC (NULL); + Lisp_Object font_list = Qnil, truename; + HFONT hfont; + + if (DEVICE_TYPE_P (d, mswindows)) + { + font_list = DEVICE_MSWINDOWS_FONTLIST (d); + } + else if (DEVICE_TYPE_P (d, msprinter)) + { + font_list = DEVICE_MSPRINTER_FONTLIST (d); + } + else + { + assert(0); + } + + hfont = create_hfont_from_font_spec (the_nonreloc, hdc, Qnil, + font_list, + ERROR_ME_DEBUG_WARN, + &truename); + + if (!hfont || !(hfont = (HFONT) SelectObject (hdc, hfont))) + { + nope: + DeleteDC (hdc); + UNGCPRO; + return 0; + } + + if (GetTextCharsetInfo (hdc, &fs, 0) == DEFAULT_CHARSET) + { + SelectObject (hdc, hfont); + goto nope; + } + SelectObject (hdc, hfont); + DeleteDC (hdc); + Fputhash (reloc, make_opaque (&fs, sizeof (fs)), Vfont_signature_data); + UNGCPRO; + } + + { + int lowlim, highlim; + int dim, j, cp = -1; + + /* Try to find a Unicode char in the charset. #### This is somewhat + bogus. See below. + + #### Cache me baby!!!!!!!!!!!!! + */ + get_charset_limits (charset, &lowlim, &highlim); + dim = XCHARSET_DIMENSION (charset); + + if (dim == 1) + { + for (i = lowlim; i <= highlim; i++) + if ((cp = ichar_to_unicode (make_ichar (charset, i, 0))) >= 0) + break; + } + else + { + for (i = lowlim; i <= highlim; i++) + for (j = lowlim; j <= highlim; j++) + if ((cp = ichar_to_unicode (make_ichar (charset, i, j))) >= 0) + break; + } + + if (cp < 0) + return 0; + + /* Check to see, for each subrange supported by the font, + whether the Unicode char is within that subrange. If any match, + the font supports the char (whereby, the charset, bogusly). */ + + for (i = 0; i < 128; i++) + { + if (fsp->fsUsb[i >> 5] & (1 << (i & 32))) + { + for (j = 0; j < unicode_subrange_table[i].no_subranges; j++) + if (cp >= unicode_subrange_table[i].subranges[j].start && + cp <= unicode_subrange_table[i].subranges[j].end) + return 1; + } + } + + return 0; + } +} + +/* + Given a truename font spec, does it match CHARSET? + + We try two stages: + + -- First see if the charset corresponds to one of the predefined Windows + charsets; if so, we see if the registry (that's the last element of the + font spec) is that same charset. If so, this means that the font is + specifically designed for the charset, and we prefer it. + + -- However, there are only a limited number of defined Windows charsets, + and new ones aren't being defined; so if we fail the first stage, we find + a character from the charset with a Unicode equivalent, and see if the + font can display this character. we do that by retrieving the Unicode + ranges that the font supports, to see if the character comes from that + subrange. + + #### Note: We really want to be doing all these checks at the character + level, not the charset level. There's no guarantee that a charset covers + a single Unicode range. Furthermore, this is extremely wasteful. We + should be doing this when we're about to redisplay and already have the + Unicode codepoints in hand. +*/ + +static int +mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, + const Ibyte *nonreloc, + Lisp_Object reloc, + Bytecount offset, Bytecount length, + enum font_specifier_matchspec_stages stage) +{ + return stage == STAGE_FINAL ? + mswindows_font_spec_matches_charset_stage_2 (d, charset, nonreloc, + reloc, offset, length) + : mswindows_font_spec_matches_charset_stage_1 (d, charset, nonreloc, + reloc, offset, length); +} + + +/* Find a font spec that matches font spec FONT and also matches + (the registry of) CHARSET. */ + +static Lisp_Object +mswindows_find_charset_font (Lisp_Object device, Lisp_Object font, + Lisp_Object charset, + enum font_specifier_matchspec_stages stage) +{ + Lisp_Object fontlist, fonttail; + + /* If FONT specifies a particular charset, this will only list fonts with + that charset; otherwise, it will list fonts with all charsets. */ + fontlist = mswindows_font_list (font, device, Qnil); + + if (stage == STAGE_INITIAL) + { + LIST_LOOP (fonttail, fontlist) + { + if (mswindows_font_spec_matches_charset_stage_1 + (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) + return XCAR (fonttail); + } + } + else + { + LIST_LOOP (fonttail, fontlist) + { + if (mswindows_font_spec_matches_charset_stage_2 + (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) + return XCAR (fonttail); + } + } + + return Qnil; +} + +#endif /* MULE */ + + +/************************************************************************/ +/* non-methods */ +/************************************************************************/ + +static Lisp_Object +mswindows_color_list (void) +{ + Lisp_Object result = Qnil; + int i; + + for (i = 0; i < countof (mswindows_X_color_map); i++) + result = Fcons (build_ascstring (mswindows_X_color_map[i].name), result); + + return Fnreverse (result); +} + + +/************************************************************************/ +/* initialization */ +/************************************************************************/ + +void +syms_of_fontcolor_mswindows (void) +{ +} + +void +console_type_create_fontcolor_mswindows (void) +{ + /* object methods */ + CONSOLE_HAS_METHOD (mswindows, initialize_color_instance); +/* CONSOLE_HAS_METHOD (mswindows, mark_color_instance); */ + CONSOLE_HAS_METHOD (mswindows, print_color_instance); + CONSOLE_HAS_METHOD (mswindows, finalize_color_instance); + CONSOLE_HAS_METHOD (mswindows, color_instance_equal); + CONSOLE_HAS_METHOD (mswindows, color_instance_hash); + CONSOLE_HAS_METHOD (mswindows, color_instance_rgb_components); + CONSOLE_HAS_METHOD (mswindows, valid_color_name_p); + CONSOLE_HAS_METHOD (mswindows, color_list); + + CONSOLE_HAS_METHOD (mswindows, initialize_font_instance); +/* CONSOLE_HAS_METHOD (mswindows, mark_font_instance); */ + CONSOLE_HAS_METHOD (mswindows, print_font_instance); + CONSOLE_HAS_METHOD (mswindows, finalize_font_instance); + CONSOLE_HAS_METHOD (mswindows, font_instance_truename); + CONSOLE_HAS_METHOD (mswindows, font_list); +#ifdef MULE + CONSOLE_HAS_METHOD (mswindows, font_spec_matches_charset); + CONSOLE_HAS_METHOD (mswindows, find_charset_font); +#endif + + /* Printer methods - delegate most to windows methods, + since graphical objects behave the same way. */ + + CONSOLE_INHERITS_METHOD (msprinter, mswindows, initialize_color_instance); +/* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_color_instance); */ + CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_color_instance); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_color_instance); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_equal); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_hash); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_rgb_components); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, valid_color_name_p); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_list); + + CONSOLE_HAS_METHOD (msprinter, initialize_font_instance); +/* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_font_instance); */ + CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_font_instance); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_font_instance); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_instance_truename); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_list); +#ifdef MULE + CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_spec_matches_charset); + CONSOLE_INHERITS_METHOD (msprinter, mswindows, find_charset_font); +#endif +} + +void +reinit_vars_of_fontcolor_mswindows (void) +{ +#ifdef MULE + int i; + + unicode_subrange_table = xnew_array_and_zero (unicode_subrange_t, 128); + for (i = 0; i < countof (unicode_subrange_raw_map); i++) + { + const unicode_subrange_raw_t *el = &unicode_subrange_raw_map[i]; + if (unicode_subrange_table[el->subrange_bit].subranges == 0) + unicode_subrange_table[el->subrange_bit].subranges = el; + unicode_subrange_table[el->subrange_bit].no_subranges++; + } + + Fclrhash (Vfont_signature_data); +#endif /* MULE */ +} + +void +vars_of_fontcolor_mswindows (void) +{ +#ifdef MULE + Vfont_signature_data = + make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); + staticpro (&Vfont_signature_data); +#endif /* MULE */ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-msw.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,42 @@ +/* mswindows-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002 Ben Wing. + Copyright (C) 1997, Jonathan Harris. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Authorship: + + Ultimately based on FSF. + Rewritten by Ben Wing. + Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0. + */ + + +#ifndef INCLUDED_fontcolor_msw_h_ +#define INCLUDED_fontcolor_msw_h_ + +#include "fontcolor.h" + +HFONT mswindows_get_hfont (Lisp_Font_Instance *f, int under, int strike); +Lisp_Object mswindows_color_to_string (COLORREF color); + +#endif /* INCLUDED_fontcolor_msw_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-tty-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,82 @@ +/* TTY-specific Lisp objects. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995 Ben Wing + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#ifndef INCLUDED_fontcolor_tty_impl_h_ +#define INCLUDED_fontcolor_tty_impl_h_ + +#include "fontcolor-impl.h" +#include "fontcolor-tty.h" + +struct tty_color_instance_data +{ +#ifdef NEW_GC + NORMAL_LISP_OBJECT_HEADER header; +#endif /* NEW_GC */ + Lisp_Object symbol; /* so we don't have to constantly call Fintern() */ +}; + +#ifdef NEW_GC +DECLARE_LISP_OBJECT (tty_color_instance_data, struct tty_color_instance_data); +#define XTTY_COLOR_INSTANCE_DATA(x) \ + XRECORD (x, tty_color_instance_data, struct tty_color_instance_data) +#define wrap_tty_color_instance_data(p) \ + wrap_record (p, tty_color_instance_data) +#define TTY_COLOR_INSTANCE_DATAP(x) RECORDP (x, tty_color_instance_data) +#define CHECK_TTY_COLOR_INSTANCE_DATA(x) \ + CHECK_RECORD (x, tty_color_instance_data) +#define CONCHECK_TTY_COLOR_INSTANCE_DATA(x) \ + CONCHECK_RECORD (x, tty_color_instance_data) +#endif /* NEW_GC */ + +#define TTY_COLOR_INSTANCE_DATA(c) \ + ((struct tty_color_instance_data *) (c)->data) + +#define COLOR_INSTANCE_TTY_SYMBOL(c) (TTY_COLOR_INSTANCE_DATA (c)->symbol) + +struct tty_font_instance_data +{ +#ifdef NEW_GC + NORMAL_LISP_OBJECT_HEADER header; +#endif /* NEW_GC */ + Lisp_Object charset; +}; + +#ifdef NEW_GC +DECLARE_LISP_OBJECT (tty_font_instance_data, struct tty_font_instance_data); +#define XTTY_FONT_INSTANCE_DATA(x) \ + XRECORD (x, tty_font_instance_data, struct tty_font_instance_data) +#define wrap_tty_font_instance_data(p) \ + wrap_record (p, tty_font_instance_data) +#define TTY_FONT_INSTANCE_DATAP(x) RECORDP (x, tty_font_instance_data) +#define CHECK_TTY_FONT_INSTANCE_DATA(x) \ + CHECK_RECORD (x, tty_font_instance_data) +#define CONCHECK_TTY_FONT_INSTANCE_DATA(x) \ + CONCHECK_RECORD (x, tty_font_instance_data) +#endif /* NEW_GC */ + +#define TTY_FONT_INSTANCE_DATA(c) \ + ((struct tty_font_instance_data *) (c)->data) + +#define FONT_INSTANCE_TTY_CHARSET(c) (TTY_FONT_INSTANCE_DATA (c)->charset) + +#endif /* INCLUDED_fontcolor_tty_impl_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-tty.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,452 @@ +/* TTY-specific Lisp objects. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2001, 2002, 2010 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#include <config.h> +#include "lisp.h" + +#include "console-tty-impl.h" +#include "insdel.h" +#include "fontcolor-tty-impl.h" +#include "device.h" +#include "charset.h" + +/* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ +Lisp_Object Vtty_color_alist; +#if 0 /* This stuff doesn't quite work yet */ +Lisp_Object Vtty_dynamic_color_fg; +Lisp_Object Vtty_dynamic_color_bg; +#endif + +static const struct memory_description tty_color_instance_data_description_1 [] = { + { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) }, + { XD_END } +}; + +#ifdef NEW_GC +DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-color-instance-data", + tty_color_instance_data, + 0, tty_color_instance_data_description_1, + struct tty_color_instance_data); +#else /* not NEW_GC */ +const struct sized_memory_description tty_color_instance_data_description = { + sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 +}; +#endif /* not NEW_GC */ + +static const struct memory_description tty_font_instance_data_description_1 [] = { + { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, + { XD_END } +}; + +#ifdef NEW_GC +DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-font-instance-data", + tty_font_instance_data, 0, + tty_font_instance_data_description_1, + struct tty_font_instance_data); +#else /* not NEW_GC */ +const struct sized_memory_description tty_font_instance_data_description = { + sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 +}; +#endif /* not NEW_GC */ + +DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* +Register COLOR as a recognized TTY color. +COLOR should be a string. +Strings FG-STRING and BG-STRING should specify the escape sequences to + set the foreground and background to the given color, respectively. +*/ + (color, fg_string, bg_string)) +{ + CHECK_STRING (color); + CHECK_STRING (fg_string); + CHECK_STRING (bg_string); + + color = Fintern (color, Qnil); + Vtty_color_alist = Fremassq (color, Vtty_color_alist); + Vtty_color_alist = Fcons (Fcons (color, Fcons (fg_string, bg_string)), + Vtty_color_alist); + + return Qnil; +} + +DEFUN ("unregister-tty-color", Funregister_tty_color, 1, 1, 0, /* +Unregister COLOR as a recognized TTY color. +*/ + (color)) +{ + CHECK_STRING (color); + + color = Fintern (color, Qnil); + Vtty_color_alist = Fremassq (color, Vtty_color_alist); + return Qnil; +} + +DEFUN ("find-tty-color", Ffind_tty_color, 1, 1, 0, /* +Look up COLOR in the list of registered TTY colors. +If it is found, return a list (FG-STRING BG-STRING) of the escape +sequences used to set the foreground and background to the color, respectively. +If it is not found, return nil. +*/ + (color)) +{ + Lisp_Object result; + + CHECK_STRING (color); + + result = Fassq (Fintern (color, Qnil), Vtty_color_alist); + if (!NILP (result)) + return list2 (Fcar (Fcdr (result)), Fcdr (Fcdr (result))); + else + return Qnil; +} + +static Lisp_Object +tty_color_list (void) +{ + Lisp_Object result = Qnil; + Lisp_Object rest; + + LIST_LOOP (rest, Vtty_color_alist) + { + result = Fcons (Fsymbol_name (XCAR (XCAR (rest))), result); + } + + return Fnreverse (result); +} + +#if 0 + +/* This approach is too simplistic. The problem is that the + dynamic color settings apply to *all* text in the default color, + not just the text output after the escape sequence has been given. */ + +DEFUN ("set-tty-dynamic-color-specs", Fset_tty_dynamic_color_specs, 2, 2, 0, /* +Set the dynamic color specifications for TTY's. +FG and BG should be either nil or vaguely printf-like strings, +where each occurrence of %s is replaced with the color name and each +occurrence of %% is replaced with a single % character. +*/ + (fg, bg)) +{ + if (!NILP (fg)) + CHECK_STRING (fg); + if (!NILP (bg)) + CHECK_STRING (bg); + + Vtty_dynamic_color_fg = fg; + Vtty_dynamic_color_bg = bg; + + return Qnil; +} + +DEFUN ("tty-dynamic-color-specs", Ftty_dynamic_color_specs, 0, 0, 0, /* +Return the dynamic color specifications for TTY's as a list of (FG BG). +See `set-tty-dynamic-color-specs'. +*/ + ()) +{ + return list2 (Vtty_dynamic_color_fg, Vtty_dynamic_color_bg); +} + +#endif /* 0 */ + +static int +tty_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, + Lisp_Object UNUSED (device), + Error_Behavior UNUSED (errb)) +{ + Lisp_Object result; + + name = Fintern (name, Qnil); + result = assq_no_quit (name, Vtty_color_alist); + + if (NILP (result)) + { +#if 0 + if (!STRINGP (Vtty_dynamic_color_fg) + && !STRINGP (Vtty_dynamic_color_bg)) +#endif + return 0; + } + + /* Don't allocate the data until we're sure that we will succeed. */ +#ifdef NEW_GC + c->data = + XTTY_COLOR_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_color_instance_data)); +#else /* not NEW_GC */ + c->data = xnew (struct tty_color_instance_data); +#endif /* not NEW_GC */ + COLOR_INSTANCE_TTY_SYMBOL (c) = name; + + return 1; +} + +static void +tty_mark_color_instance (Lisp_Color_Instance *c) +{ + mark_object (COLOR_INSTANCE_TTY_SYMBOL (c)); +} + +static void +tty_print_color_instance (Lisp_Color_Instance *UNUSED (c), + Lisp_Object UNUSED (printcharfun), + int UNUSED (escapeflag)) +{ +} + +static void +tty_finalize_color_instance (Lisp_Color_Instance *UNUSED_IF_NEW_GC (c)) +{ +#ifndef NEW_GC + if (c->data) + { + xfree (c->data); + c->data = 0; + } +#endif /* not NEW_GC */ +} + +static int +tty_color_instance_equal (Lisp_Color_Instance *c1, + Lisp_Color_Instance *c2, + int UNUSED (depth)) +{ + return (EQ (COLOR_INSTANCE_TTY_SYMBOL (c1), + COLOR_INSTANCE_TTY_SYMBOL (c2))); +} + +static Hashcode +tty_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) +{ + return LISP_HASH (COLOR_INSTANCE_TTY_SYMBOL (c)); +} + +static int +tty_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) +{ + return (!NILP (assoc_no_quit (Fintern (color, Qnil), Vtty_color_alist))); +#if 0 + || STRINGP (Vtty_dynamic_color_fg) + || STRINGP (Vtty_dynamic_color_bg) +#endif +} + + +static int +tty_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, + Lisp_Object UNUSED (device), + Error_Behavior UNUSED (errb)) +{ + Ibyte *str = XSTRING_DATA (name); + Lisp_Object charset = Qnil; + + if (qxestrncmp_ascii (str, "normal", 6)) + return 0; + str += 6; + if (*str) + { +#ifdef MULE + if (*str != '/') + return 0; + str++; + charset = Ffind_charset (intern_istring (str)); + if (NILP (charset)) + return 0; +#else + return 0; +#endif + } + + /* Don't allocate the data until we're sure that we will succeed. */ +#ifdef NEW_GC + f->data = + XTTY_FONT_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_font_instance_data)); +#else /* not NEW_GC */ + f->data = xnew (struct tty_font_instance_data); +#endif /* not NEW_GC */ + FONT_INSTANCE_TTY_CHARSET (f) = charset; +#ifdef MULE + if (CHARSETP (charset)) + f->width = XCHARSET_COLUMNS (charset); + else +#endif + f->width = 1; + + f->proportional_p = 0; + f->ascent = f->height = 1; + f->descent = 0; + + return 1; +} + +static void +tty_mark_font_instance (Lisp_Font_Instance *f) +{ + mark_object (FONT_INSTANCE_TTY_CHARSET (f)); +} + +static void +tty_print_font_instance (Lisp_Font_Instance *UNUSED (f), + Lisp_Object UNUSED (printcharfun), + int UNUSED (escapeflag)) +{ +} + +static void +tty_finalize_font_instance (Lisp_Font_Instance *UNUSED_IF_NEW_GC (f)) +{ +#ifndef NEW_GC + if (f->data) + { + xfree (f->data); + f->data = 0; + } +#endif /* not NEW_GC */ +} + +static Lisp_Object +tty_font_list (Lisp_Object UNUSED (pattern), Lisp_Object UNUSED (device), + Lisp_Object UNUSED (maxnumber)) +{ + return list1 (build_ascstring ("normal")); +} + +#ifdef MULE + +static int +tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, + const Ibyte *nonreloc, Lisp_Object reloc, + Bytecount offset, Bytecount length, + enum font_specifier_matchspec_stages stage) +{ + const Ibyte *the_nonreloc = nonreloc; + + if (stage == STAGE_FINAL) + return 0; + + if (!the_nonreloc) + the_nonreloc = XSTRING_DATA (reloc); + fixup_internal_substring (nonreloc, reloc, offset, &length); + the_nonreloc += offset; + + if (NILP (charset)) + return !memchr (the_nonreloc, '/', length); + the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); + if (!the_nonreloc) + return 0; + the_nonreloc++; + { + Lisp_Object s = symbol_name (XSYMBOL (XCHARSET_NAME (charset))); + return !qxestrcmp (the_nonreloc, XSTRING_DATA (s)); + } +} + +/* find a font spec that matches font spec FONT and also matches + (the registry of) CHARSET. */ +static Lisp_Object +tty_find_charset_font (Lisp_Object device, Lisp_Object font, + Lisp_Object charset, + enum font_specifier_matchspec_stages stage) +{ + Ibyte *fontname = XSTRING_DATA (font); + + if (stage == STAGE_FINAL) + return Qnil; + + if (strchr ((const char *) fontname, '/')) + { + if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, + font, 0, -1, STAGE_INITIAL)) + return font; + return Qnil; + } + + if (NILP (charset)) + return font; + + return concat3 (font, build_ascstring ("/"), + Fsymbol_name (XCHARSET_NAME (charset))); +} + +#endif /* MULE */ + + +/************************************************************************/ +/* initialization */ +/************************************************************************/ + +void +syms_of_fontcolor_tty (void) +{ +#ifdef NEW_GC + INIT_LISP_OBJECT (tty_color_instance_data); + INIT_LISP_OBJECT (tty_font_instance_data); +#endif /* NEW_GC */ + + DEFSUBR (Fregister_tty_color); + DEFSUBR (Funregister_tty_color); + DEFSUBR (Ffind_tty_color); +#if 0 + DEFSUBR (Fset_tty_dynamic_color_specs); + DEFSUBR (Ftty_dynamic_color_specs); +#endif +} + +void +console_type_create_fontcolor_tty (void) +{ + /* object methods */ + CONSOLE_HAS_METHOD (tty, initialize_color_instance); + CONSOLE_HAS_METHOD (tty, mark_color_instance); + CONSOLE_HAS_METHOD (tty, print_color_instance); + CONSOLE_HAS_METHOD (tty, finalize_color_instance); + CONSOLE_HAS_METHOD (tty, color_instance_equal); + CONSOLE_HAS_METHOD (tty, color_instance_hash); + CONSOLE_HAS_METHOD (tty, valid_color_name_p); + CONSOLE_HAS_METHOD (tty, color_list); + + CONSOLE_HAS_METHOD (tty, initialize_font_instance); + CONSOLE_HAS_METHOD (tty, mark_font_instance); + CONSOLE_HAS_METHOD (tty, print_font_instance); + CONSOLE_HAS_METHOD (tty, finalize_font_instance); + CONSOLE_HAS_METHOD (tty, font_list); +#ifdef MULE + CONSOLE_HAS_METHOD (tty, font_spec_matches_charset); + CONSOLE_HAS_METHOD (tty, find_charset_font); +#endif +} + +void +vars_of_fontcolor_tty (void) +{ + staticpro (&Vtty_color_alist); + Vtty_color_alist = Qnil; + +#if 0 + staticpro (&Vtty_dynamic_color_fg); + Vtty_dynamic_color_fg = Qnil; + + staticpro (&Vtty_dynamic_color_bg); + Vtty_dynamic_color_bg = Qnil; +#endif +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-tty.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,32 @@ +/* TTY-specific Lisp objects. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995 Ben Wing + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#ifndef INCLUDED_fontcolor_tty_h_ +#define INCLUDED_fontcolor_tty_h_ + +#include "fontcolor.h" + +extern Lisp_Object Vtty_color_alist, Vtty_dynamic_color_bg; +extern Lisp_Object Vtty_dynamic_color_fg; + +#endif /* INCLUDED_fontcolor_tty_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-x-impl.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,88 @@ +/* X-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* This file Mule-ized (more like Mule-verified) by Ben Wing, 7-10-00. */ + +#ifndef INCLUDED_fontcolor_x_impl_h_ +#define INCLUDED_fontcolor_x_impl_h_ + +#include "fontcolor-impl.h" +#include "fontcolor-x.h" +#ifdef HAVE_XFT +/* for resource name definitions, etc */ +#include "../lwlib/lwlib-fonts.h" +#endif + +#ifdef HAVE_X_WINDOWS + +/***************************************************************************** + Color-Instance + ****************************************************************************/ + +struct x_color_instance_data +{ + XColor color; + /* Yes, it looks crazy to have both the XColor and the XftColor, but + pragmatically both are used. */ +#ifdef HAVE_XFT + XftColor xftColor; +#endif + char dealloc_on_gc; +}; + +#define X_COLOR_INSTANCE_DATA(c) ((struct x_color_instance_data *) (c)->data) +#define COLOR_INSTANCE_X_COLOR(c) (X_COLOR_INSTANCE_DATA (c)->color) +#define XCOLOR_INSTANCE_X_COLOR(c) COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (c)) +#ifdef HAVE_XFT +#define COLOR_INSTANCE_X_XFTCOLOR(c) (X_COLOR_INSTANCE_DATA (c)->xftColor) +#endif +#define COLOR_INSTANCE_X_DEALLOC(c) (X_COLOR_INSTANCE_DATA (c)->dealloc_on_gc) + +/***************************************************************************** + Font-Instance + ****************************************************************************/ + +struct x_font_instance_data +{ + /* X-specific information */ + /* Yes, it looks crazy to have both the XFontStruct and the XftFont, but + pragmatically both are used (lwlib delegates labels to the widget sets, + which internally use XFontStructs). */ + XFontStruct * font; +#ifdef HAVE_XFT + XftFont *xftFont; +#endif + +}; + +#define X_FONT_INSTANCE_DATA(f) ((struct x_font_instance_data *) (f)->data) +#define FONT_INSTANCE_X_FONT(f) (X_FONT_INSTANCE_DATA (f)->font) +#define XFONT_INSTANCE_X_FONT(c) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (c)) +#ifdef HAVE_XFT +#define FONT_INSTANCE_X_XFTFONT(f) (X_FONT_INSTANCE_DATA (f)->xftFont) +#endif + +#endif /* HAVE_X_WINDOWS */ + +#endif /* INCLUDED_fontcolor_x_impl_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,988 @@ +/* X-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995 Tinker Systems. + Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004 Ben Wing. + Copyright (C) 1995 Sun Microsystems, Inc. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */ + +/* This file Mule-ized by Ben Wing, 7-10-00. */ + +#include <config.h> +#include "lisp.h" + +#include "charset.h" +#include "device-impl.h" +#include "insdel.h" + +#include "console-x-impl.h" +#include "fontcolor-x-impl.h" +#include "elhash.h" + +#ifdef HAVE_XFT +#include "font-mgr.h" +#endif + +int x_handle_non_fully_specified_fonts; + +#ifdef DEBUG_XEMACS +Fixnum debug_x_objects; +#endif /* DEBUG_XEMACS */ + + +/************************************************************************/ +/* color instances */ +/************************************************************************/ + +static int +x_parse_nearest_color (struct device *d, XColor *color, Lisp_Object name, + Error_Behavior errb) +{ + Display *dpy = DEVICE_X_DISPLAY (d); + Colormap cmap = DEVICE_X_COLORMAP (d); + Visual *visual = DEVICE_X_VISUAL (d); + int result; + + xzero (*color); + { + const Extbyte *extname; + + extname = LISP_STRING_TO_EXTERNAL (name, Qx_color_name_encoding); + result = XParseColor (dpy, cmap, extname, color); + } + if (!result) + { + maybe_signal_error (Qgui_error, "Unrecognized color", + name, Qcolor, errb); + return 0; + } + result = x_allocate_nearest_color (dpy, cmap, visual, color); + if (!result) + { + maybe_signal_error (Qgui_error, "Couldn't allocate color", + name, Qcolor, errb); + return 0; + } + + return result; +} + +static int +x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, + Lisp_Object device, Error_Behavior errb) +{ + XColor color; +#ifdef HAVE_XFT + XftColor xftColor; +#endif + int result; + + result = x_parse_nearest_color (XDEVICE (device), &color, name, errb); + + if (!result) + return 0; + + /* Don't allocate the data until we're sure that we will succeed, + or the finalize method may get fucked. */ + c->data = xnew (struct x_color_instance_data); + if (result == 3) + COLOR_INSTANCE_X_DEALLOC (c) = 0; + else + COLOR_INSTANCE_X_DEALLOC (c) = 1; + COLOR_INSTANCE_X_COLOR (c) = color; + +#ifdef HAVE_XFT + xftColor.pixel = color.pixel; + xftColor.color.red = color.red; + xftColor.color.green = color.green; + xftColor.color.blue = color.blue; + xftColor.color.alpha = 0xffff; + + COLOR_INSTANCE_X_XFTCOLOR (c) = xftColor; +#endif + + return 1; +} + +static void +x_print_color_instance (Lisp_Color_Instance *c, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + XColor color = COLOR_INSTANCE_X_COLOR (c); + write_fmt_string (printcharfun, " %ld=(%X,%X,%X)", + color.pixel, color.red, color.green, color.blue); +} + +static void +x_finalize_color_instance (Lisp_Color_Instance *c) +{ + if (c->data) + { + if (DEVICE_LIVE_P (XDEVICE (c->device))) + { + if (COLOR_INSTANCE_X_DEALLOC (c)) + { + XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)), + DEVICE_X_COLORMAP (XDEVICE (c->device)), + &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0); + } + } + xfree (c->data); + c->data = 0; + } +} + +/* Color instances are equal if they resolve to the same color on the + screen (have the same RGB values). I imagine that + "same RGB values" == "same cell in the colormap." Arguably we should + be comparing their names or pixel values instead. */ + +static int +x_color_instance_equal (Lisp_Color_Instance *c1, + Lisp_Color_Instance *c2, + int UNUSED (depth)) +{ + XColor color1 = COLOR_INSTANCE_X_COLOR (c1); + XColor color2 = COLOR_INSTANCE_X_COLOR (c2); + return ((color1.red == color2.red) && + (color1.green == color2.green) && + (color1.blue == color2.blue)); +} + +static Hashcode +x_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) +{ + XColor color = COLOR_INSTANCE_X_COLOR (c); + return HASH3 (color.red, color.green, color.blue); +} + +static Lisp_Object +x_color_instance_rgb_components (Lisp_Color_Instance *c) +{ + XColor color = COLOR_INSTANCE_X_COLOR (c); + return (list3 (make_int (color.red), + make_int (color.green), + make_int (color.blue))); +} + +static int +x_valid_color_name_p (struct device *d, Lisp_Object color) +{ + XColor c; + Display *dpy = DEVICE_X_DISPLAY (d); + Colormap cmap = DEVICE_X_COLORMAP (d); + const Extbyte *extname; + + extname = LISP_STRING_TO_EXTERNAL (color, Qx_color_name_encoding); + + return XParseColor (dpy, cmap, extname, &c); +} + +static Lisp_Object +x_color_list (void) +{ + return call0 (intern ("x-color-list-internal")); +} + + +/************************************************************************/ +/* font instances */ +/************************************************************************/ + + +static int +x_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object UNUSED (name), + Lisp_Object device, Error_Behavior errb) +{ + Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); + Extbyte *extname; + XFontStruct *fs = NULL; /* _F_ont _S_truct */ +#ifdef HAVE_XFT + XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */ +#else +#define rf (0) +#endif + +#ifdef HAVE_XFT + DEBUG_XFT1 (2, "attempting to initialize font spec %s\n", + XSTRING_DATA(f->name)); + /* #### serialize (optimize) these later... */ + /* #### This function really needs to go away. + The problem is that the fontconfig/Xft functions work much too hard + to ensure that something is returned; but that something need not be + at all close to what we asked for. */ + extname = LISP_STRING_TO_EXTERNAL (f->name, Qfc_font_name_encoding); + rf = xft_open_font_by_name (dpy, extname); +#endif + extname = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); + /* With XFree86 4.0's fonts, XListFonts returns an entry for + -isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0 but + an XLoadQueryFont on the corresponding XLFD returns NULL. + + XListFonts is not trustworthy (of course, this is news to exactly + no-one used to reading XEmacs source.) */ + fs = XLoadQueryFont (dpy, extname); + + if (!fs && !rf) + { + /* #### should this refer to X and/or Xft? */ + maybe_signal_error (Qgui_error, "Couldn't load font", f->name, + Qfont, errb); + return 0; + } + + if (rf && fs) + { + XFreeFont (dpy, fs); + fs = NULL; /* we don' need no steenkin' X font */ + } + + if (fs && !fs->max_bounds.width) + { + /* yes, this has been known to happen. */ + XFreeFont (dpy, fs); + fs = NULL; + maybe_signal_error (Qgui_error, "X font is too small", f->name, Qfont, + errb); + return 0; + } + + /* Now that we're sure that we will succeed, we can allocate data without + fear that the finalize method may get fucked. */ + f->data = xnew (struct x_font_instance_data); + +#ifdef HAVE_XFT + FONT_INSTANCE_X_XFTFONT (f) = rf; + if (rf) + /* Have an Xft font, initialize font info from it. */ + { + DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n", + f->ascent, f->descent, f->width, f->height); + + /* #### This shit is just plain wrong unless we have a character cell + font. It really hoses us on large repertoire Unicode fonts with + "double-width" characters. */ + f->ascent = rf->ascent; + f->descent = rf->descent; + { + /* This is an approximation that AFAIK only gets used to compute + cell size for estimating window dimensions. The test_string8 + is an ASCII string whose characters should approximate the + distribution of widths expected in real text. */ + static const FcChar8 test_string8[] = "Mmneei"; + static const int len = sizeof (test_string8) - 1; + XGlyphInfo glyphinfo; + + XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo); + /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */ + f->width = (2*glyphinfo.width + len)/(2*len); + } + f->height = rf->height; + f->proportional_p = 1; /* we can't recognize monospaced fonts! */ + + /* #### This message appears wa-a-ay too often! + We probably need to cache truenames or something? + Even if Xft does it for us, we cons too many font instances. */ + DEBUG_XFT4 (0, + "initialized metrics ascent %d descent %d width %d height %d\n", + f->ascent, f->descent, f->width, f->height); + } + else + { + DEBUG_XFT1 (0, "couldn't initialize Xft font %s\n", + XSTRING_DATA(f->name)); + } +#endif + + FONT_INSTANCE_X_FONT (f) = fs; + if (fs) + /* Have to use a core font, initialize font info from it. */ + { + f->ascent = fs->ascent; + f->descent = fs->descent; + f->height = fs->ascent + fs->descent; + { + /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */ + int def_char = 'n'; /*fs->default_char;*/ + int byte1, byte2; + + once_more: + byte1 = def_char >> 8; + byte2 = def_char & 0xFF; + + if (fs->per_char) + { + /* Old versions of the R5 font server have garbage (>63k) as + def_char. 'n' might not be a valid character. */ + if (byte1 < (int) fs->min_byte1 || + byte1 > (int) fs->max_byte1 || + byte2 < (int) fs->min_char_or_byte2 || + byte2 > (int) fs->max_char_or_byte2) + f->width = 0; + else + f->width = fs->per_char[(byte1 - fs->min_byte1) * + (fs->max_char_or_byte2 - + fs->min_char_or_byte2 + 1) + + (byte2 - fs->min_char_or_byte2)].width; + } + else + f->width = fs->max_bounds.width; + + /* Some fonts have a default char whose width is 0. This is no good. + If that's the case, first try 'n' as the default char, and if n has + 0 width too (unlikely) then just use the max width. */ + if (f->width == 0) + { + if (def_char == (int) fs->default_char) + f->width = fs->max_bounds.width; + else + { + def_char = fs->default_char; + goto once_more; + } + } + } + + /* If all characters don't exist then there could potentially be + 0-width characters lurking out there. Not setting this flag + trips an optimization that would make them appear to have width + to redisplay. This is bad. So we set it if not all characters + have the same width or if not all characters are defined. */ + /* #### This sucks. There is a measurable performance increase + when using proportional width fonts if this flag is not set. + Unfortunately so many of the fucking X fonts are not fully + defined that we could almost just get rid of this damn flag and + make it an assertion. */ + f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width || + (x_handle_non_fully_specified_fonts && + !fs->all_chars_exist)); + } + +#ifdef HAVE_XFT + if (debug_xft > 0) + { + int n = 3, d = 5; + /* check for weirdness */ + if (n * f->height < d * f->width) + stderr_out ("font %s: width:height is %d:%d, larger than %d:%d\n", + XSTRING_DATA(f->name), f->width, f->height, n, d); + if (f->height <= 0 || f->width <= 0) + stderr_out ("bogus dimensions of font %s: width = %d, height = %d\n", + XSTRING_DATA(f->name), f->width, f->height); + stderr_out ("initialized font %s\n", XSTRING_DATA(f->name)); + } +#else +#undef rf +#endif + + return 1; +} + +static void +x_print_font_instance (Lisp_Font_Instance *f, + Lisp_Object printcharfun, + int UNUSED (escapeflag)) +{ + /* We should print information here about initial vs. final stages; we + can't rely on the device charset stage cache for that, + unfortunately. */ + if (FONT_INSTANCE_X_FONT (f)) + write_fmt_string (printcharfun, " font id: 0x%lx,", + (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); + +#ifdef HAVE_XFT + /* #### What should we do here? For now, print the address. */ + if (FONT_INSTANCE_X_XFTFONT (f)) + write_fmt_string (printcharfun, " xft font: 0x%lx", + (unsigned long) FONT_INSTANCE_X_XFTFONT (f)); +#endif +} + +static void +x_finalize_font_instance (Lisp_Font_Instance *f) +{ + +#ifdef HAVE_XFT + DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name) + ? (char *) XSTRING_DATA (f->name) + : "(unnamed font)")); +#endif + + if (f->data) + { + if (DEVICE_LIVE_P (XDEVICE (f->device))) + { + Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); + + if (FONT_INSTANCE_X_FONT (f)) + XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); +#ifdef HAVE_XFT + if (FONT_INSTANCE_X_XFTFONT (f)) + XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f)); +#endif + } + xfree (f->data); + f->data = 0; + } +} + +/* Determining the truename of a font is hard. (Big surprise.) + + This is not true for fontconfig. Each font has a (nearly) canonical + representation up to permutation of the order of properties. It is + possible to construct a name which exactly identifies the properties of + the current font. However, it is theoretically possible that there exists + another font with a super set of those properties that would happen to get + selected. -- sjt + + By "truename" we mean an XLFD-form name which contains no wildcards, yet + which resolves to *exactly* the same font as the one which we already have + the (probably wildcarded) name and `XFontStruct' of. + + One might think that the first font returned by XListFonts would be the one + that XOpenFont would pick. Apparently this is the case on some servers, + but not on others. It would seem not to be specified. + + The MIT R5 server sometimes appears to be picking the lexicographically + smallest font which matches the name (thus picking "adobe" fonts before + "bitstream" fonts even if the bitstream fonts are earlier in the path, and + also picking 100dpi adobe fonts over 75dpi adobe fonts even though the + 75dpi are in the path earlier) but sometimes appears to be doing something + else entirely (for example, removing the bitstream fonts from the path will + cause the 75dpi adobe fonts to be used instead of the 100dpi, even though + their relative positions in the path (and their names!) have not changed). + + The documentation for XSetFontPath() seems to indicate that the order of + entries in the font path means something, but it's pretty noncommittal about + it, and the spirit of the law is apparently not being obeyed... + + All the fonts I've seen have a property named `FONT' which contains the + truename of the font. However, there are two problems with using this: the + first is that the X Protocol Document is quite explicit that all properties + are optional, so we can't depend on it being there. The second is that + it's conceivable that this alleged truename isn't actually accessible as a + font, due to some difference of opinion between the font designers and + whoever installed the font on the system. + + So, our first attempt is to look for a FONT property, and then verify that + the name there is a valid name by running XListFonts on it. There's still + the potential that this could be true but we could still be being lied to, + but that seems pretty remote. + + Late breaking news: I've gotten reports that SunOS 4.1.3U1 + with OpenWound 3.0 has a font whose truename is really + "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1" + but whose FONT property contains "Courier". + + So we disbelieve the FONT property unless it begins with a dash and + is more than 30 characters long. X Windows: The defacto substandard. + X Windows: Complex nonsolutions to simple nonproblems. X Windows: + Live the nightmare. + + If the FONT property doesn't exist, then we try and construct an XLFD name + out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc). + This is necessary at least for some versions of OpenWound. But who knows + what the future will bring. + + If that doesn't work, then we use XListFonts and either take the first font + (which I think is the most sensible thing) or we find the lexicographically + least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is + defined. This sucks because the two behaviors are a property of the server + being used, not the architecture on which emacs has been compiled. Also, + as I described above, sorting isn't ALWAYS what the server does. Really it + does something seemingly random. There is no reliable way to win if the + FONT property isn't present. + + Another possibility which I haven't bothered to implement would be to map + over all of the matching fonts and find the first one that has the same + character metrics as the font we already have loaded. Even if this didn't + return exactly the same font, it would at least return one whose characters + were the same sizes, which would probably be good enough. + + More late-breaking news: on RS/6000 AIX 3.2.4, the expression + XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1") + actually returns the font + -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1 + which is crazy, because that font doesn't even match that pattern! It is + also not included in the output produced by `xlsfonts' with that pattern. + + So this is yet another example of XListFonts() and XOpenFont() using + completely different algorithms. This, however, is a goofier example of + this bug, because in this case, it's not just the search order that is + different -- the sets don't even intersect. + + If anyone has any better ideas how to do this, or any insights on what it is + that the various servers are actually doing, please let me know! -- jwz. */ + +static int +valid_x_font_name_p (Display *dpy, Extbyte *name) +{ + /* Maybe this should be implemented by calling XLoadFont and trapping + the error. That would be a lot of work, and wasteful as hell, but + might be more correct. + */ + int nnames = 0; + Extbyte **names = 0; + if (! name) + return 0; + names = XListFonts (dpy, name, 1, &nnames); + if (names) + XFreeFontNames (names); + return (nnames != 0); +} + +static Extbyte * +truename_via_FONT_prop (Display *dpy, XFontStruct *font) +{ + unsigned long value = 0; + Extbyte *result = 0; + if (XGetFontProperty (font, XA_FONT, &value)) + result = XGetAtomName (dpy, value); + /* result is now 0, or the string value of the FONT property. */ + if (result) + { + /* Verify that result is an XLFD name (roughly...) */ + if (result [0] != '-' || strlen (result) < 30) + { + XFree (result); + result = 0; + } + } + return result; /* this must be freed by caller if non-0 */ +} + +static Extbyte * +truename_via_random_props (Display *dpy, XFontStruct *font) +{ + struct device *d = get_device_from_display (dpy); + unsigned long value = 0; + Extbyte *foundry, *family, *weight, *slant, *setwidth, *add_style; + unsigned long pixel, point, res_x, res_y; + Extbyte *spacing; + unsigned long avg_width; + Extbyte *registry, *encoding; + Extbyte composed_name [2048]; + int ok = 0; + Extbyte *result; + +#define get_string(atom,var) \ + if (XGetFontProperty (font, (atom), &value)) \ + var = XGetAtomName (dpy, value); \ + else { \ + var = 0; \ + goto FAIL; } +#define get_number(atom,var) \ + if (!XGetFontProperty (font, (atom), &var) || \ + var > 999) \ + goto FAIL; + + foundry = family = weight = slant = setwidth = 0; + add_style = spacing = registry = encoding = 0; + + get_string (DEVICE_XATOM_FOUNDRY (d), foundry); + get_string (DEVICE_XATOM_FAMILY_NAME (d), family); + get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight); + get_string (DEVICE_XATOM_SLANT (d), slant); + get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth); + get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style); + get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel); + get_number (DEVICE_XATOM_POINT_SIZE (d), point); + get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x); + get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y); + get_string (DEVICE_XATOM_SPACING (d), spacing); + get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width); + get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry); + get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding); +#undef get_number +#undef get_string + + sprintf (composed_name, + "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s", + foundry, family, weight, slant, setwidth, add_style, pixel, + point, res_x, res_y, spacing, avg_width, registry, encoding); + ok = 1; + + FAIL: + if (ok) + { + int L = strlen (composed_name) + 1; + result = xnew_extbytes (L); + strncpy (result, composed_name, L); + } + else + result = 0; + + if (foundry) XFree (foundry); + if (family) XFree (family); + if (weight) XFree (weight); + if (slant) XFree (slant); + if (setwidth) XFree (setwidth); + if (add_style) XFree (add_style); + if (spacing) XFree (spacing); + if (registry) XFree (registry); + if (encoding) XFree (encoding); + + return result; +} + +/* XListFonts doesn't allocate memory unconditionally based on this. (For + XFree86 in 2005, at least. */ +#define MAX_FONT_COUNT INT_MAX + +static Extbyte * +truename_via_XListFonts (Display *dpy, Extbyte *font_name) +{ + Extbyte *result = 0; + Extbyte **names; + int count = 0; + +#ifndef XOPENFONT_SORTS + /* In a sensible world, the first font returned by XListFonts() + would be the font that XOpenFont() would use. */ + names = XListFonts (dpy, font_name, 1, &count); + if (count) result = names [0]; +#else + /* But the world I live in is much more perverse. */ + names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count); + /* Find the lexicographic minimum of names[]. + (#### Should we be comparing case-insensitively?) */ + while (count--) + /* [[ !!#### Not Mule-friendly ]] + Doesn't matter, XLFDs are HPC (old) or Latin1 (modern). If they + aren't, who knows what they are? -- sjt */ + if (result == 0 || (strcmp (result, names [count]) < 0)) + result = names [count]; +#endif + + if (result) + result = xstrdup (result); + if (names) + XFreeFontNames (names); + + return result; /* this must be freed by caller if non-0 */ +} + +static Lisp_Object +x_font_truename (Display *dpy, Extbyte *name, XFontStruct *font) +{ + Extbyte *truename_FONT = 0; + Extbyte *truename_random = 0; + Extbyte *truename = 0; + + /* The search order is: + - if FONT property exists, and is a valid name, return it. + - if the other props exist, and add up to a valid name, return it. + - if we find a matching name with XListFonts, return it. + - if FONT property exists, return it regardless. + - if other props exist, return the resultant name regardless. + - else return 0. + */ + + truename = truename_FONT = truename_via_FONT_prop (dpy, font); + if (truename && !valid_x_font_name_p (dpy, truename)) + truename = 0; + if (!truename) + truename = truename_random = truename_via_random_props (dpy, font); + if (truename && !valid_x_font_name_p (dpy, truename)) + truename = 0; + if (!truename && name) + truename = truename_via_XListFonts (dpy, name); + + if (!truename) + { + /* Gag - we weren't able to find a seemingly-valid truename. + Well, maybe we're on one of those braindead systems where + XListFonts() and XLoadFont() are in violent disagreement. + If we were able to compute a truename, try using that even + if evidence suggests that it's not a valid name - because + maybe it is, really, and that's better than nothing. + X Windows: You'll envy the dead. + */ + if (truename_FONT) + truename = truename_FONT; + else if (truename_random) + truename = truename_random; + } + + /* One or both of these are not being used - free them. */ + if (truename_FONT && truename_FONT != truename) + XFree (truename_FONT); + if (truename_random && truename_random != truename) + XFree (truename_random); + + if (truename) + { + Lisp_Object result = build_extstring (truename, Qx_font_name_encoding); + XFree (truename); + return result; + } + else + return Qnil; +} + +static Lisp_Object +x_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb) +{ + struct device *d = XDEVICE (f->device); + Display *dpy = DEVICE_X_DISPLAY (d); + Extbyte *nameext; + + /* #### restructure this so that we return a valid truename at the end, + and otherwise only return when we return something desperate that + doesn't get stored for future use. */ + +#ifdef HAVE_XFT + /* First, try an Xft font. */ + if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f)) + { + /* The font is already open, we just unparse. */ + FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern); + if (! FONT_INSTANCE_X_XFTFONT (f)->pattern) + { + maybe_signal_error (Qgui_error, + "Xft font present but lacks pattern", + wrap_font_instance(f), Qfont, errb); + } + if (res) + { + FONT_INSTANCE_TRUENAME (f) = + build_extstring ((Extbyte *) res, Qfc_font_name_encoding); + free (res); + return FONT_INSTANCE_TRUENAME (f); + } + else + { + maybe_signal_error (Qgui_error, + "Couldn't unparse Xft font to truename", + wrap_font_instance(f), Qfont, errb); + /* used to return Qnil here */ + } + } +#endif /* HAVE_XFT */ + + /* OK, fall back to core font. */ + if (NILP (FONT_INSTANCE_TRUENAME (f)) + && FONT_INSTANCE_X_FONT (f)) + { + nameext = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); + FONT_INSTANCE_TRUENAME (f) = + x_font_truename (dpy, nameext, FONT_INSTANCE_X_FONT (f)); + } + + if (NILP (FONT_INSTANCE_TRUENAME (f))) + { + /* Urk, no luck. Whine about our bad luck and exit. */ + Lisp_Object font_instance = wrap_font_instance (f); + + + maybe_signal_error (Qgui_error, "Couldn't determine font truename", + font_instance, Qfont, errb); + /* Ok, just this once, return the font name as the truename. + (This is only used by Fequal() right now.) */ + return f->name; + } + + /* Return what we found. */ + return FONT_INSTANCE_TRUENAME (f); +} + +static Lisp_Object +x_font_instance_properties (Lisp_Font_Instance *f) +{ + struct device *d = XDEVICE (f->device); + int i; + Lisp_Object result = Qnil; + Display *dpy = DEVICE_X_DISPLAY (d); + XFontProp *props = NULL; + + /* #### really should hack Xft fonts, too + Strategy: fontconfig must have an iterator for this purpose. */ + if (! FONT_INSTANCE_X_FONT (f)) return result; + + props = FONT_INSTANCE_X_FONT (f)->properties; + for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) + { + Lisp_Object name, value; + Atom atom = props [i].name; + Ibyte *name_str = 0; + Bytecount name_len; + Extbyte *namestrext = XGetAtomName (dpy, atom); + + if (namestrext) + TO_INTERNAL_FORMAT (C_STRING, namestrext, + ALLOCA, (name_str, name_len), + Qx_atom_name_encoding); + + name = (name_str ? intern_istring (name_str) : Qnil); + if (name_str && + (atom == XA_FONT || + atom == DEVICE_XATOM_FOUNDRY (d) || + atom == DEVICE_XATOM_FAMILY_NAME (d) || + atom == DEVICE_XATOM_WEIGHT_NAME (d) || + atom == DEVICE_XATOM_SLANT (d) || + atom == DEVICE_XATOM_SETWIDTH_NAME (d) || + atom == DEVICE_XATOM_ADD_STYLE_NAME (d) || + atom == DEVICE_XATOM_SPACING (d) || + atom == DEVICE_XATOM_CHARSET_REGISTRY (d) || + atom == DEVICE_XATOM_CHARSET_ENCODING (d) || + !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") || + !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") || + !qxestrcmp_ascii (name_str, "CLASSIFICATION") || + !qxestrcmp_ascii (name_str, "COPYRIGHT") || + !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") || + !qxestrcmp_ascii (name_str, "FULL_NAME") || + !qxestrcmp_ascii (name_str, "MONOSPACED") || + !qxestrcmp_ascii (name_str, "QUALITY") || + !qxestrcmp_ascii (name_str, "RELATIVE_SET") || + !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") || + !qxestrcmp_ascii (name_str, "STYLE"))) + { + Extbyte *val_str = XGetAtomName (dpy, props [i].card32); + + value = (val_str ? build_extstring (val_str, Qx_atom_name_encoding) + : Qnil); + } + else + value = make_int (props [i].card32); + if (namestrext) XFree (namestrext); + result = Fcons (Fcons (name, value), result); + } + return result; +} + +static Lisp_Object +x_font_list (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber) +{ + Extbyte **names; + int count = 0; + int max_number = MAX_FONT_COUNT; + Lisp_Object result = Qnil; + const Extbyte *patternext; + + patternext = LISP_STRING_TO_EXTERNAL (pattern, Qx_font_name_encoding); + + if (!NILP(maxnumber) && INTP(maxnumber)) + { + max_number = XINT(maxnumber); + } + + names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)), + patternext, max_number, &count); + while (count--) + result = Fcons (build_extstring (names[count], Qx_font_name_encoding), + result); + if (names) + XFreeFontNames (names); + return result; +} + +/* Include the charset support, shared, for the moment, with GTK. */ +#define THIS_IS_X +#include "fontcolor-xlike-inc.c" + + +/************************************************************************/ +/* initialization */ +/************************************************************************/ + +void +syms_of_fontcolor_x (void) +{ +} + +void +console_type_create_fontcolor_x (void) +{ + /* object methods */ + + CONSOLE_HAS_METHOD (x, initialize_color_instance); + CONSOLE_HAS_METHOD (x, print_color_instance); + CONSOLE_HAS_METHOD (x, finalize_color_instance); + CONSOLE_HAS_METHOD (x, color_instance_equal); + CONSOLE_HAS_METHOD (x, color_instance_hash); + CONSOLE_HAS_METHOD (x, color_instance_rgb_components); + CONSOLE_HAS_METHOD (x, valid_color_name_p); + CONSOLE_HAS_METHOD (x, color_list); + + CONSOLE_HAS_METHOD (x, initialize_font_instance); + CONSOLE_HAS_METHOD (x, print_font_instance); + CONSOLE_HAS_METHOD (x, finalize_font_instance); + CONSOLE_HAS_METHOD (x, font_instance_truename); + CONSOLE_HAS_METHOD (x, font_instance_properties); + CONSOLE_HAS_METHOD (x, font_list); +#ifdef MULE + CONSOLE_HAS_METHOD (x, find_charset_font); + CONSOLE_HAS_METHOD (x, font_spec_matches_charset); +#endif +} + +void +vars_of_fontcolor_x (void) +{ +#ifdef DEBUG_XEMACS + DEFVAR_INT ("debug-x-objects", &debug_x_objects /* +If non-zero, display debug information about X objects +*/ ); + debug_x_objects = 0; +#endif + + DEFVAR_BOOL ("x-handle-non-fully-specified-fonts", + &x_handle_non_fully_specified_fonts /* +If this is true then fonts which do not have all characters specified +will be considered to be proportional width even if they are actually +fixed-width. If this is not done then characters which are supposed to +have 0 width may appear to actually have some width. + +Note: While setting this to t guarantees correct output in all +circumstances, it also causes a noticeable performance hit when using +fixed-width fonts. Since most people don't use characters which could +cause problems this is set to nil by default. +*/ ); + x_handle_non_fully_specified_fonts = 0; + +#ifdef HAVE_XFT + Fprovide (intern ("xft-fonts")); +#endif +} + +void +Xatoms_of_fontcolor_x (struct device *d) +{ + Display *D = DEVICE_X_DISPLAY (d); + + DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False); + DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False); + DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False); + DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False); + DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False); + DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False); + DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False); + DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False); + DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False); + DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False); + DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False); + DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False); + DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False); + DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-x.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,43 @@ +/* X-specific Lisp objects. + Copyright (C) 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* This file Mule-ized (more like Mule-verified) by Ben Wing, 7-10-00. */ + +#ifndef INCLUDED_fontcolor_x_h_ +#define INCLUDED_fontcolor_x_h_ + +#include "fontcolor.h" +#include "../lwlib/lwlib-colors.h" /* for x_allocate_nearest_color */ + +#ifdef HAVE_X_WINDOWS + +#ifdef HAVE_XFT +EXFUN (Ffc_font_real_pattern, 2); +#endif + +/* Lisp_Object Fxlfd_font_name_p; */ + +#endif /* HAVE_X_WINDOWS */ + +#endif /* INCLUDED_fontcolor_x_h_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor-xlike-inc.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,878 @@ +/* Common code between X and GTK -- fonts and colors. + Copyright (C) 1991-5, 1997 Free Software Foundation, Inc. + Copyright (C) 1995 Sun Microsystems, Inc. + Copyright (C) 1996, 2001, 2002, 2003, 2010 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +/* Before including this file, you need to define either THIS_IS_X or + THIS_IS_GTK. */ + +/* See comment at top of console-xlike-inc.h for an explanation of + how this file works. */ + +/* Pango is ready for prime-time now, as far as I understand it. The GTK + people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12 + CET 2006) */ + +#include "console-xlike-inc.h" + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) + +#ifdef DEBUG_XEMACS +# define DEBUG_OBJECTS(FORMAT, ...) \ + do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0) +#else /* DEBUG_XEMACS */ +# define DEBUG_OBJECTS(format, ...) +#endif /* DEBUG_XEMACS */ + +#elif defined(__GNUC__) + +#ifdef DEBUG_XEMACS +# define DEBUG_OBJECTS(format, args...) \ + do { if (debug_x_objects) stderr_out(format, args ); } while (0) +#else /* DEBUG_XEMACS */ +# define DEBUG_OBJECTS(format, args...) +#endif /* DEBUG_XEMACS */ + +#else /* defined(__STDC_VERSION__) [...] */ +# define DEBUG_OBJECTS (void) +#endif + +#ifdef MULE + +/* For some code it's reasonable to have only one copy and conditionalize + at run-time. For other code it isn't. */ + +static int +count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen) +{ + int hyphen_count = 0; + const Ibyte *hyphening = str; + const Ibyte *new_hyphening; + + for (hyphen_count = 0; + NULL != (new_hyphening = (Ibyte *) memchr((const void *)hyphening, '-', length)); + hyphen_count++) + { + ++new_hyphening; + length -= new_hyphening - hyphening; + hyphening = new_hyphening; + } + + if (NULL != last_hyphen) + { + *last_hyphen = (Ibyte *)hyphening; + } + + return hyphen_count; +} + +static int +XFUN (font_spec_matches_charset) (struct device * USED_IF_XFT (d), + Lisp_Object charset, + const Ibyte *nonreloc, Lisp_Object reloc, + Bytecount offset, Bytecount length, + enum font_specifier_matchspec_stages stage) +{ + Lisp_Object registries = Qnil; + long i, registries_len; + const Ibyte *the_nonreloc; + Bytecount the_length; + + the_nonreloc = nonreloc; + the_length = length; + + if (!the_nonreloc) + the_nonreloc = XSTRING_DATA (reloc); + fixup_internal_substring (nonreloc, reloc, offset, &the_length); + the_nonreloc += offset; + +#ifdef USE_XFT + if (stage == STAGE_FINAL) + { + Display *dpy = DEVICE_X_DISPLAY (d); + Extbyte *extname; + XftFont *rf; + const Ibyte *the_nonreloc; + + if (!NILP(reloc)) + { + the_nonreloc = XSTRING_DATA (reloc); + extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding); + rf = xft_open_font_by_name (dpy, extname); + return 0; /* #### maybe this will compile and run ;) */ + /* Jesus, Stephen, what the fuck? */ + } + } +#endif + + /* Hmm, this smells bad. */ + if (NILP (charset)) + return 1; + + /* Hack! Short font names don't have the registry in them, + so we just assume the user knows what they're doing in the + case of ASCII. For other charsets, you gotta give the + long form; sorry buster. + #### FMH: this screws fontconfig/Xft? + STRATEGY: use fontconfig's ability to hack languages and character + sets (lang and charset properties). + #### Maybe we can use the fontconfig model to eliminate the difference + between faces and fonts? No - it looks like that would be an abuse + (fontconfig doesn't know about colors, although Xft does). + */ + if (EQ (charset, Vcharset_ascii) && + (!memchr (the_nonreloc, '*', the_length)) + && (5 > (count_hyphens(the_nonreloc, the_length, NULL)))) + { + return 1; + } + + if (STAGE_FINAL == stage) + { + registries = Qunicode_registries; + } + else if (STAGE_INITIAL == stage) + { + registries = XCHARSET_REGISTRIES (charset); + if (NILP(registries)) + { + return 0; + } + } + else assert(0); + + CHECK_VECTOR (registries); + registries_len = XVECTOR_LENGTH(registries); + + for (i = 0; i < registries_len; ++i) + { + if (!(STRINGP(XVECTOR_DATA(registries)[i])) + || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length)) + { + continue; + } + + /* Check if the font spec ends in the registry specified. X11 says + this comparison is case insensitive: XLFD, section 3.11: + + "Alphabetic case distinctions are allowed but are for human + readability concerns only. Conforming X servers will perform + matching on font name query or open requests independent of case." */ + if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]), + the_nonreloc + (the_length - + XSTRING_LENGTH + (XVECTOR_DATA(registries)[i])))) + { + return 1; + } + } + return 0; +} + +static Lisp_Object +xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd, + Lisp_Object charset, + enum font_specifier_matchspec_stages stage) +{ + Extbyte **names; + Lisp_Object result = Qnil; + int count = 0, i; + DECLARE_EISTRING(ei_single_result); + + names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)), + xlfd, MAX_FONT_COUNT, &count); + + for (i = 0; i < count; ++i) + { + eireset(ei_single_result); + eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding); + + if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset, + (XDEVICE (device), charset, + eidata(ei_single_result), Qnil, 0, + -1, stage), 0)) + { + result = eimake_string(ei_single_result); + DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n", + eidata(ei_single_result)); + break; + } + } + + if (names) + { + XFreeFontNames (names); + } + + return result; +} + +#ifdef USE_XFT +/* #### debug functions: find a better place for us */ +const char *FcResultToString (FcResult r); +const char * +FcResultToString (FcResult r) +{ + static char buffer[256]; + switch (r) + { + case FcResultMatch: + return "FcResultMatch"; + case FcResultNoMatch: + return "FcResultNoMatch"; + case FcResultTypeMismatch: + return "FcResultTypeMismatch"; + case FcResultNoId: + return "FcResultNoId"; + default: + snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r); + return buffer; + } +} + +const char *FcTypeOfValueToString (FcValue v); +const char * +FcTypeOfValueToString (FcValue v) +{ + static char buffer[256]; + switch (v.type) + { + case FcTypeMatrix: + return "FcTypeMatrix"; + case FcTypeString: + return "FcTypeString"; + case FcTypeVoid: + return "FcTypeVoid"; + case FcTypeDouble: + return "FcTypeDouble"; + case FcTypeInteger: + return "FcTypeInteger"; + case FcTypeBool: + return "FcTypeBool"; + case FcTypeCharSet: + return "FcTypeCharSet"; + case FcTypeLangSet: + return "FcTypeLangSet"; + /* #### There is no union member of this type, but there are void* and + FcPattern* members, as of fontconfig.h FC_VERSION 10002 */ + case FcTypeFTFace: + return "FcTypeFTFace"; + default: + snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type); + return buffer; + } +} + +static FcCharSet * +mule_to_fc_charset (Lisp_Object cs) +{ + int ucode, i, j; + FcCharSet *fccs; + + CHECK_CHARSET (cs); + fccs = FcCharSetCreate (); + /* #### do we also need to deal with 94 vs. 96 charsets? + ie, how are SP and DEL treated in ASCII? non-graphic should return -1 */ + if (1 == XCHARSET_DIMENSION (cs)) + /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ + for (i = 0; i < 96; i++) + { + ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i]; + if (ucode >= 0) + /* #### should check for allocation failure */ + FcCharSetAddChar (fccs, (FcChar32) ucode); + } + else if (2 == XCHARSET_DIMENSION (cs)) + /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ + for (i = 0; i < 96; i++) + for (j = 0; j < 96; j++) + { + ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j]; + if (ucode >= 0) + /* #### should check for allocation failure */ + FcCharSetAddChar (fccs, (FcChar32) ucode); + } + else + { + FcCharSetDestroy (fccs); + fccs = NULL; + } + return fccs; +} + +struct charset_reporter { + Lisp_Object *charset; + /* This is a debug facility, require ASCII. */ + const Ascbyte *language; /* ASCII, please */ + /* Technically this is FcChar8, but fsckin' GCC 4 bitches. + RFC 3066 is a combination of ISO 639 and ISO 3166. */ + const Ascbyte *rfc3066; /* ASCII, please */ +}; + +static struct charset_reporter charset_table[] = + { + /* #### It's my branch, my favorite charsets get checked first! + That's a joke, Son. + Ie, I don't know what I'm doing, so my charsets first is as good as + any other arbitrary order. If you have a better idea, speak up! */ + { &Vcharset_ascii, "English", "en" }, + { &Vcharset_japanese_jisx0208, "Japanese", "ja" }, + { &Vcharset_japanese_jisx0212, "Japanese", "ja" }, + { &Vcharset_katakana_jisx0201, "Japanese", "ja" }, + { &Vcharset_latin_jisx0201, "Japanese", "ja" }, + { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" }, + { &Vcharset_greek_iso8859_7, "Greek", "el" }, + /* #### all the Chinese need checking + Damn the blood-sucking ISO anyway. */ + { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-cn" }, + { &Vcharset_korean_ksc5601, "Korean", "ko" }, + { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-tw" }, + { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-tw" }, + /* #### not obvious how to handle these + We could (for experimental purposes) make the last element into + an array of ISO 639 codes, and check for all of them. If a font + provides some but not others, warn. */ + { &Vcharset_latin_iso8859_1, NULL, NULL }, + { &Vcharset_latin_iso8859_2, NULL, NULL }, + { &Vcharset_latin_iso8859_3, NULL, NULL }, + { &Vcharset_latin_iso8859_4, NULL, NULL }, + { &Vcharset_latin_iso8859_9, NULL, NULL }, + { &Vcharset_latin_iso8859_15, NULL, NULL }, + { &Vcharset_thai_tis620, "Thai", "th" }, + /* We don't have an arabic charset. bidi issues, I guess? */ + /* { &Vcharset_arabic_iso8859_6, "Arabic", "ar" }, */ + { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" }, + /* #### probably close enough for Ukraine? */ + { &Vcharset_cyrillic_iso8859_5, "Russian", "ru" }, + /* #### these probably are not quite right */ + { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-tw" }, + { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-tw" }, + { NULL, NULL, NULL } + }; + +/* Choose appropriate font name for debug messages. + Use only in the top half of next function (enforced with #undef). */ +#define DECLARE_DEBUG_FONTNAME(__xemacs_name) \ + Eistring *__xemacs_name; \ + do \ + { \ + __xemacs_name = debug_xft > 2 ? eistr_fullname \ + : debug_xft > 1 ? eistr_longname \ + : eistr_shortname; \ + } while (0) + +static Lisp_Object +xft_find_charset_font (Lisp_Object font, Lisp_Object charset, + enum font_specifier_matchspec_stages stage) +{ + const Extbyte *patternext; + Lisp_Object result = Qnil; + + /* #### with Xft need to handle second stage here -- sjt + Hm. Or maybe not. That would be cool. :-) */ + if (stage == STAGE_FINAL) + return Qnil; + + /* Fontconfig converts all FreeType names to UTF-8 before passing them + back to callers---see fcfreetype.c (FcFreeTypeQuery). + I don't believe this is documented. */ + + DEBUG_XFT1 (1, "confirming charset for font instance %s\n", + XSTRING_DATA(font)); + + /* #### this looks like a fair amount of work, but the basic design + has never been rethought, and it should be + + what really should happen here is that we use FcFontSort (FcFontList?) + to get a list of matching fonts, then pick the first (best) one that + gives language or repertoire coverage. + */ + + FcInit (); /* No-op if already initialized. + In fontconfig 2.3.2, this cannot return + failure, but that looks like a bug. We + check for it with FcGetCurrentConfig(), + which *can* fail. */ + if (!FcConfigGetCurrent()) + stderr_out ("Failed fontconfig initialization\n"); + else + { + FcPattern *fontxft; /* long-lived, freed at end of this block */ + FcResult fcresult; + FcConfig *fcc; + const Ascbyte *lang = "en"; + FcCharSet *fccs = NULL; + DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */ + DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */ + DECLARE_EISTRING (eistr_fullname); /* everything */ + + patternext = LISP_STRING_TO_EXTERNAL (font, Qfc_font_name_encoding); + fcc = FcConfigGetCurrent (); + + /* parse the name, do the substitutions, and match the font */ + + { + FcPattern *p = FcNameParse ((FcChar8 *) patternext); + PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p); + /* #### Next two return FcBool, but what does the return mean? */ + /* The order is correct according the fontconfig docs. */ + FcConfigSubstitute (fcc, p, FcMatchPattern); + PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p); + FcDefaultSubstitute (p); + PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p); + /* #### check fcresult of following match? */ + fcresult = FcResultMatch; + fontxft = FcFontMatch (fcc, p, &fcresult); + switch (fcresult) + { + /* case FcResultOutOfMemory: */ + case FcResultNoMatch: + case FcResultTypeMismatch: + case FcResultNoId: + break; + case FcResultMatch: + /* this prints the long fontconfig name */ + PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft); + break; + } + FcPatternDestroy (p); + } + + /* heuristic to give reasonable-length names for debug reports + + I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's + pointless. We're just going to remove this code once the font/ + face refactoring is done, but until then it could be very useful. + */ + { + FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft); + Extbyte *name; + + /* full name, including language coverage and repertoire */ + name = (Extbyte *) FcNameUnparse (p); + eicpy_ext (eistr_fullname, + (name ? name : "NOT FOUND"), + Qfc_font_name_encoding); + if (name) free (name); + + /* long name, omitting coverage and repertoire, plus a number + of rarely useful properties */ + FcPatternDel (p, FC_CHARSET); + FcPatternDel (p, FC_LANG); +#ifdef FC_WIDTH + FcPatternDel (p, FC_WIDTH); +#endif + FcPatternDel (p, FC_SPACING); + FcPatternDel (p, FC_HINTING); + FcPatternDel (p, FC_VERTICAL_LAYOUT); + FcPatternDel (p, FC_AUTOHINT); + FcPatternDel (p, FC_GLOBAL_ADVANCE); + FcPatternDel (p, FC_INDEX); + FcPatternDel (p, FC_SCALE); + FcPatternDel (p, FC_FONTVERSION); + name = (Extbyte *) FcNameUnparse (p); + eicpy_ext (eistr_longname, + (name ? name : "NOT FOUND"), + Qfc_font_name_encoding); + if (name) free (name); + + /* nickname, just family and size, but + "family" names usually have style, slant, and weight */ + FcPatternDel (p, FC_FOUNDRY); + FcPatternDel (p, FC_STYLE); + FcPatternDel (p, FC_SLANT); + FcPatternDel (p, FC_WEIGHT); + FcPatternDel (p, FC_PIXEL_SIZE); + FcPatternDel (p, FC_OUTLINE); + FcPatternDel (p, FC_SCALABLE); + FcPatternDel (p, FC_DPI); + name = (Extbyte *) FcNameUnparse (p); + eicpy_ext (eistr_shortname, + (name ? name : "NOT FOUND"), + Qfc_font_name_encoding); + if (name) free (name); + + FcPatternDestroy (p); + } + + /* The language approach may better in the long run, but we can't use + it based on Mule charsets; fontconfig doesn't provide a way to test + for unions of languages, etc. That will require support from the + text module. + + Optimization: cache the generated FcCharSet in the Mule charset. + Don't forget to destroy it if the Mule charset gets deallocated. */ + + { + /* This block possibly should be a function, but it generates + multiple values. I find the "pass an address to return the + value in" idiom opaque, so prefer a block. */ + struct charset_reporter *cr; + for (cr = charset_table; + cr->charset && !EQ (*(cr->charset), charset); + cr++) + ; + + if (cr->rfc3066) + { + DECLARE_DEBUG_FONTNAME (name); + CHECKING_LANG (0, eidata(name), cr->language); + lang = cr->rfc3066; + } + else if (cr->charset) + { + /* what the hey, build 'em on the fly */ + /* #### in the case of error this could return NULL! */ + fccs = mule_to_fc_charset (charset); + /* #### Bad idea here */ + lang = (const Ascbyte *) XSTRING_DATA (XSYMBOL (XCHARSET_NAME + (charset))->name); + } + else + { + /* OK, we fell off the end of the table */ + warn_when_safe_lispobj (intern ("xft"), intern ("alert"), + list2 (build_ascstring ("unchecked charset"), + charset)); + /* default to "en" + #### THIS IS WRONG, WRONG, WRONG!! + It is why we never fall through to XLFD-checking. */ + } + + ASSERT_ASCTEXT_ASCII (lang); + + if (fccs) + { + /* check for character set coverage */ + int i = 0; + FcCharSet *v; + FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v); + + if (r == FcResultTypeMismatch) + { + DEBUG_XFT0 (0, "Unexpected type return in charset value\n"); + result = Qnil; + } + else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v)) + { + /* The full pattern with the bitmap coverage is massively + unwieldy, but the shorter names are just *wrong*. We + should have the full thing internally as truename, and + filter stuff the client doesn't want to see on output. + Should we just store it into the truename right here? */ + DECLARE_DEBUG_FONTNAME (name); + DEBUG_XFT2 (0, "Xft font %s supports %s\n", + eidata(name), lang); +#ifdef RETURN_LONG_FONTCONFIG_NAMES + result = eimake_string(eistr_fullname); +#else + result = eimake_string(eistr_longname); +#endif + } + else + { + DECLARE_DEBUG_FONTNAME (name); + DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", + eidata(name), lang); + result = Qnil; + } + + /* clean up */ + FcCharSetDestroy (fccs); + } + else + { + /* check for language coverage */ + int i = 0; + FcValue v; + /* the main event */ + FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v); + + if (r == FcResultMatch) + { + if (v.type != FcTypeLangSet) /* excessive paranoia */ + { + ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v)); + /* Urk! Fall back and punt to core font. */ + DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n", + FcTypeOfValueToString (v)); + result = Qnil; + } + else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang) + != FcLangDifferentLang) + { + DECLARE_DEBUG_FONTNAME (name); + DEBUG_XFT2 (0, "Xft font %s supports %s\n", + eidata(name), lang); +#ifdef RETURN_LONG_FONTCONFIG_NAMES + result = eimake_string(eistr_fullname); +#else + result = eimake_string(eistr_longname); +#endif + } + else + { + DECLARE_DEBUG_FONTNAME (name); + DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", + eidata(name), lang); + result = Qnil; + } + } + else + { + ASSERT_ASCTEXT_ASCII(FcResultToString(r)); + DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n", + FcResultToString (r)); + result = Qnil; + } + } + + /* clean up and maybe return */ + FcPatternDestroy (fontxft); + if (!UNBOUNDP (result)) + return result; + } + } + return Qnil; +} +#undef DECLARE_DEBUG_FONTNAME + +#endif /* USE_XFT */ + +/* find a font spec that matches font spec FONT and also matches + (the registry of) CHARSET. */ +static Lisp_Object +XFUN (find_charset_font) (Lisp_Object device, Lisp_Object font, + Lisp_Object charset, + enum font_specifier_matchspec_stages stage) +{ + Lisp_Object result = Qnil, registries = Qnil; + int j, hyphen_count, registries_len = 0; + Ibyte *hyphening, *new_hyphening; + Bytecount xlfd_length; + + DECLARE_EISTRING(ei_xlfd_without_registry); + DECLARE_EISTRING(ei_xlfd); + +#ifdef USE_XFT + result = xft_find_charset_font(font, charset, stage); + if (!NILP(result)) + { + return result; + } +#endif + + switch (stage) + { + case STAGE_INITIAL: + { + if (!(NILP(XCHARSET_REGISTRIES(charset))) + && VECTORP(XCHARSET_REGISTRIES(charset))) + { + registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset)); + registries = XCHARSET_REGISTRIES(charset); + } + break; + } + case STAGE_FINAL: + { + registries_len = 1; + registries = Qunicode_registries; + break; + } + default: + { + assert(0); + break; + } + } + + eicpy_lstr(ei_xlfd, font); + hyphening = eidata(ei_xlfd); + xlfd_length = eilen(ei_xlfd); + + /* Count the hyphens in the string, moving new_hyphening to just after the + last one. */ + hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening); + + if (0 == registries_len || (5 > hyphen_count && + !(1 == xlfd_length && '*' == *hyphening))) + { + /* No proper XLFD specified, or we can't modify the pattern to change + the registry and encoding to match what we want, or we have no + information on the registry needed. */ + eito_external(ei_xlfd, Qx_font_name_encoding); + DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", + eidata(ei_xlfd)); + result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), + charset, stage); + /* No need to loop through the available registries; return + immediately. */ + return result; + } + else if (1 == xlfd_length && '*' == *hyphening) + { + /* It's a single asterisk. We can add the registry directly to the + end. */ + eicpy_ch(ei_xlfd_without_registry, '*'); + } + else + { + /* It's a fully-specified XLFD. Work out where the registry and + encoding are, and initialise ei_xlfd_without_registry to the string + without them. */ + + /* count_hyphens has set new_hyphening to just after the last + hyphen. Move back to just after the hyphen before it. */ + + for (new_hyphening -= 2; new_hyphening > hyphening + && '-' != *new_hyphening; --new_hyphening) + ; + ++new_hyphening; + + eicpy_ei(ei_xlfd_without_registry, ei_xlfd); + + /* Manipulate ei_xlfd_without_registry, using the information about + ei_xlfd, to which it's identical. */ + eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1, + eilen(ei_xlfd) - (new_hyphening - hyphening), -1); + + } + + /* Now, loop through the registries and encodings defined for this + charset, doing an XListFonts each time with the pattern modified to + specify the regisry and encoding. This avoids huge amounts of IPC and + duplicated searching; now we use the searching the X server was doing + anyway, where before the X server did its search, transferred huge + amounts of data, and then we proceeded to do a regexp search on that + data. */ + for (j = 0; j < registries_len && NILP(result); ++j) + { + eireset(ei_xlfd); + eicpy_ei(ei_xlfd, ei_xlfd_without_registry); + + eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]); + + eito_external(ei_xlfd, Qx_font_name_encoding); + + DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", + eidata(ei_xlfd)); + result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), + charset, stage); + } + + /* In the event that the charset is ASCII and we haven't matched + anything up to now, even with a pattern of "*", add "iso8859-1" + to the charset's registry and try again. Not returning a result + for ASCII means our frame geometry calculations are + inconsistent, and that we may crash. */ + + if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result) + && ('*' == eigetch(ei_xlfd_without_registry, 0))) + + { + int have_latin1 = 0; + + /* Set this to, for example, is08859-1 if you want to see the + error behaviour. */ + +#define FALLBACK_ASCII_REGISTRY "iso8859-1" + + for (j = 0; j < registries_len; ++j) + { + if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]), + (Ibyte *) FALLBACK_ASCII_REGISTRY)) + { + have_latin1 = 1; + break; + } + } + + if (!have_latin1) + { + Lisp_Object new_registries = make_vector(registries_len + 1, Qnil); + + XVECTOR_DATA(new_registries)[0] + = build_ascstring(FALLBACK_ASCII_REGISTRY); + + memcpy(XVECTOR_DATA(new_registries) + 1, + XVECTOR_DATA(registries), + sizeof XVECTOR_DATA(registries)[0] * + XVECTOR_LENGTH(registries)); + + /* Calling set_charset_registries instead of overwriting the + value directly, to allow the charset font caches to be + invalidated and a change to the default face to be + noted. */ + set_charset_registries(charset, new_registries); + + warn_when_safe (Qface, Qwarning, + "Your ASCII charset registries contain nothing " + "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'."); + + /* And recurse. */ + result = + DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font, + (device, font, charset, stage), + result); + } + else + { + DECLARE_EISTRING (ei_connection_name); + + /* We preserve a copy of the connection name for the error message + after the device is deleted. */ + eicpy_lstr (ei_connection_name, + DEVICE_CONNECTION (XDEVICE(device))); + + stderr_out ("Cannot find a font for ASCII, deleting device on %s\n", + eidata (ei_connection_name)); + + io_error_delete_device (device); + + /* Do a normal warning in the event that we have other, non-X + frames available. (If we don't, io_error_delete_device will + have exited.) */ + warn_when_safe + (Qface, Qerror, + "Cannot find a font for ASCII, deleting device on %s.\n" + "\n" + "Your X server fonts appear to be inconsistent; fix them, or\n" + "the next frame you create on that DISPLAY will crash this\n" + "XEmacs. At a minimum, provide one font with an XLFD ending\n" + "in `" FALLBACK_ASCII_REGISTRY "', so we can work out what size\n" + "a frame should be. ", + eidata (ei_connection_name)); + } + + } + + /* This function used to return the font spec, in the case where a font + didn't exist on the X server but it did match the charset. We're not + doing that any more, because none of the other platform code does, and + the old behaviour was badly-judged in other respects, so I don't trust + the original author to have had a good reason for it. */ + + return result; +} + +#endif /* MULE */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor.c Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,1468 @@ +/* Generic Objects and Functions. + Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing. + Copyright (C) 2010 Didier Verna + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#include <config.h> +#include "lisp.h" + +#include "buffer.h" +#include "device-impl.h" +#include "elhash.h" +#include "faces.h" +#include "frame.h" +#include "glyphs.h" +#include "fontcolor-impl.h" +#include "specifier.h" +#include "window.h" + +#ifdef HAVE_TTY +#include "console-tty.h" +#endif + +/* Objects that are substituted when an instantiation fails. + If we leave in the Qunbound value, we will probably get crashes. */ +Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance; + +/* Author: Ben Wing; some earlier code from Chuck Thompson, Jamie + Zawinski. */ + +DOESNT_RETURN +finalose (void *ptr) +{ + Lisp_Object obj = wrap_pointer_1 (ptr); + + invalid_operation + ("Can't dump an emacs containing window system objects", obj); +} + + +/**************************************************************************** + * Color-Instance Object * + ****************************************************************************/ + +Lisp_Object Qcolor_instancep; + +static const struct memory_description color_instance_data_description_1 []= { +#ifdef HAVE_TTY +#ifdef NEW_GC + { XD_LISP_OBJECT, tty_console }, +#else /* not NEW_GC */ + { XD_BLOCK_PTR, tty_console, 1, { &tty_color_instance_data_description } }, +#endif /* not NEW_GC */ +#endif + { XD_END } +}; + +static const struct sized_memory_description color_instance_data_description = { + sizeof (void *), color_instance_data_description_1 +}; + +static const struct memory_description color_instance_description[] = { + { XD_INT, offsetof (Lisp_Color_Instance, color_instance_type) }, + { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, name)}, + { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, device)}, + { XD_UNION, offsetof (Lisp_Color_Instance, data), + XD_INDIRECT (0, 0), { &color_instance_data_description } }, + {XD_END} +}; + +static Lisp_Object +mark_color_instance (Lisp_Object obj) +{ + Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); + mark_object (c->name); + if (!NILP (c->device)) /* Vthe_null_color_instance */ + MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c)); + + return c->device; +} + +static void +print_color_instance (Lisp_Object obj, Lisp_Object printcharfun, + int escapeflag) +{ + Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); + if (print_readably) + printing_unreadable_lisp_object (obj, 0); + write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name); + write_fmt_string_lisp (printcharfun, " on %s", 1, c->device); + if (!NILP (c->device)) /* Vthe_null_color_instance */ + MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance, + (c, printcharfun, escapeflag)); + write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); +} + +static void +finalize_color_instance (Lisp_Object obj) +{ + Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); + + if (!NILP (c->device)) + MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c)); +} + +static int +color_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, + int UNUSED (foldcase)) +{ + Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (obj1); + Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (obj2); + + return (c1 == c2) || + (EQ (c1->device, c2->device) && + DEVICEP (c1->device) && + HAS_DEVMETH_P (XDEVICE (c1->device), color_instance_equal) && + DEVMETH (XDEVICE (c1->device), color_instance_equal, (c1, c2, depth))); +} + +static Hashcode +color_instance_hash (Lisp_Object obj, int depth) +{ + Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); + struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0; + + return HASH2 ((Hashcode) d, + !d ? LISP_HASH (obj) + : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth), + LISP_HASH (obj))); +} + +DEFINE_NODUMP_LISP_OBJECT ("color-instance", color_instance, + mark_color_instance, print_color_instance, + finalize_color_instance, color_instance_equal, + color_instance_hash, + color_instance_description, + Lisp_Color_Instance); + +DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /* +Return a new `color-instance' object named NAME (a string). + +Optional argument DEVICE specifies the device this object applies to +and defaults to the selected device. + +An error is signaled if the color is unknown or cannot be allocated; +however, if optional argument NOERROR is non-nil, nil is simply +returned in this case. (And if NOERROR is other than t, a warning may +be issued.) + +The returned object is a normal, first-class lisp object. The way you +`deallocate' the color is the way you deallocate any other lisp object: +you drop all pointers to it and allow it to be garbage collected. When +these objects are GCed, the underlying window-system data (e.g. X object) +is deallocated as well. +*/ + (name, device, noerror)) +{ + Lisp_Object obj; + Lisp_Color_Instance *c; + int retval; + + CHECK_STRING (name); + device = wrap_device (decode_device (device)); + + obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); + c = XCOLOR_INSTANCE (obj); + c->name = name; + c->device = device; + c->data = 0; + c->color_instance_type = get_console_variant (XDEVICE_TYPE (c->device)); + + retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance, + (c, name, device, + decode_error_behavior_flag (noerror))); + if (!retval) + return Qnil; + + return obj; +} + +DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /* +Return non-nil if OBJECT is a color instance. +*/ + (object)) +{ + return COLOR_INSTANCEP (object) ? Qt : Qnil; +} + +DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /* +Return the name used to allocate COLOR-INSTANCE. +*/ + (color_instance)) +{ + CHECK_COLOR_INSTANCE (color_instance); + return XCOLOR_INSTANCE (color_instance)->name; +} + +DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /* +Return a three element list containing the red, green, and blue +color components of COLOR-INSTANCE, or nil if unknown. +Component values range from 0 to 65535. +*/ + (color_instance)) +{ + Lisp_Color_Instance *c; + + CHECK_COLOR_INSTANCE (color_instance); + c = XCOLOR_INSTANCE (color_instance); + + if (NILP (c->device)) + return Qnil; + + return MAYBE_LISP_DEVMETH (XDEVICE (c->device), + color_instance_rgb_components, + (c)); +} + +DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /* +Return true if COLOR names a valid color for the current device. + +Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or +whatever the equivalent is on your system. + +Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence. +In addition to being a color this may be one of a number of attributes +such as `blink'. +*/ + (color, device)) +{ + struct device *d = decode_device (device); + + CHECK_STRING (color); + return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil; +} + +DEFUN ("color-list", Fcolor_list, 0, 1, 0, /* +Return a list of color names. +DEVICE specifies which device to return names for, and defaults to the +currently selected device. +*/ + (device)) +{ + device = wrap_device (decode_device (device)); + + return MAYBE_LISP_DEVMETH (XDEVICE (device), color_list, ()); +} + + +/*************************************************************************** + * Font-Instance Object * + ***************************************************************************/ + +Lisp_Object Qfont_instancep; + +static Lisp_Object font_instance_truename_internal (Lisp_Object xfont, + Error_Behavior errb); + +static const struct memory_description font_instance_data_description_1 []= { +#ifdef HAVE_TTY +#ifdef NEW_GC + { XD_LISP_OBJECT, tty_console }, +#else /* not NEW_GC */ + { XD_BLOCK_PTR, tty_console, 1, { &tty_font_instance_data_description } }, +#endif /* not NEW_GC */ +#endif + { XD_END } +}; + +static const struct sized_memory_description font_instance_data_description = { + sizeof (void *), font_instance_data_description_1 +}; + +static const struct memory_description font_instance_description[] = { + { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) }, + { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)}, + { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)}, + { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)}, + { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, charset)}, + { XD_UNION, offsetof (Lisp_Font_Instance, data), + XD_INDIRECT (0, 0), { &font_instance_data_description } }, + { XD_END } +}; + + +static Lisp_Object +mark_font_instance (Lisp_Object obj) +{ + Lisp_Font_Instance *f = XFONT_INSTANCE (obj); + + mark_object (f->name); + mark_object (f->truename); + if (!NILP (f->device)) /* Vthe_null_font_instance */ + MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f)); + + return f->device; +} + +static void +print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) +{ + Lisp_Font_Instance *f = XFONT_INSTANCE (obj); + if (print_readably) + printing_unreadable_lisp_object (obj, 0); + write_fmt_string_lisp (printcharfun, "#<font-instance %S", 1, f->name); + write_fmt_string_lisp (printcharfun, " on %s", 1, f->device); + if (!NILP (f->device)) + { + MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance, + (f, printcharfun, escapeflag)); + + } + write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); +} + +static void +finalize_font_instance (Lisp_Object obj) +{ + Lisp_Font_Instance *f = XFONT_INSTANCE (obj); + + if (!NILP (f->device)) + { + MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f)); + } +} + +/* Fonts are equal if they resolve to the same name. + Since we call `font-truename' to do this, and since font-truename is lazy, + this means the `equal' could cause XListFonts to be run the first time. + */ +static int +font_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, + int UNUSED (foldcase)) +{ + /* #### should this be moved into a device method? */ + return internal_equal (font_instance_truename_internal + (obj1, ERROR_ME_DEBUG_WARN), + font_instance_truename_internal + (obj2, ERROR_ME_DEBUG_WARN), + depth + 1); +} + +static Hashcode +font_instance_hash (Lisp_Object obj, int depth) +{ + return internal_hash (font_instance_truename_internal + (obj, ERROR_ME_DEBUG_WARN), + depth + 1); +} + +DEFINE_NODUMP_LISP_OBJECT ("font-instance", font_instance, + mark_font_instance, print_font_instance, + finalize_font_instance, font_instance_equal, + font_instance_hash, font_instance_description, + Lisp_Font_Instance); + + +/* #### Why is this exposed to Lisp? Used in: +x-frob-font-size, gtk-font-menu-load-font, x-font-menu-load-font-xft, +x-font-menu-load-font-core, mswindows-font-menu-load-font, +mswindows-frob-font-style-and-sizify, mswindows-frob-font-size. */ +DEFUN ("make-font-instance", Fmake_font_instance, 1, 4, 0, /* +Return a new `font-instance' object named NAME. +DEVICE specifies the device this object applies to and defaults to the +selected device. An error is signalled if the font is unknown or cannot +be allocated; however, if NOERROR is non-nil, nil is simply returned in +this case. CHARSET is used internally. #### make helper function? + +The returned object is a normal, first-class lisp object. The way you +`deallocate' the font is the way you deallocate any other lisp object: +you drop all pointers to it and allow it to be garbage collected. When +these objects are GCed, the underlying GUI data is deallocated as well. +*/ + (name, device, noerror, charset)) +{ + Lisp_Object obj; + Lisp_Font_Instance *f; + int retval = 0; + Error_Behavior errb = decode_error_behavior_flag (noerror); + + if (ERRB_EQ (errb, ERROR_ME)) + CHECK_STRING (name); + else if (!STRINGP (name)) + return Qnil; + + device = wrap_device (decode_device (device)); + + obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); + f = XFONT_INSTANCE (obj); + f->name = name; + f->truename = Qnil; + f->device = device; + + f->data = 0; + f->font_instance_type = get_console_variant (XDEVICE_TYPE (f->device)); + + /* Stick some default values here ... */ + f->ascent = f->height = 1; + f->descent = 0; + f->width = 1; + f->charset = charset; + f->proportional_p = 0; + + retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance, + (f, name, device, errb)); + + if (!retval) + return Qnil; + + return obj; +} + +DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /* +Return non-nil if OBJECT is a font instance. +*/ + (object)) +{ + return FONT_INSTANCEP (object) ? Qt : Qnil; +} + +DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /* +Return the name used to allocate FONT-INSTANCE. +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return XFONT_INSTANCE (font_instance)->name; +} + +DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /* +Return the ascent in pixels of FONT-INSTANCE. +The returned value is the maximum ascent for all characters in the font, +where a character's ascent is the number of pixels above (and including) +the baseline. +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return make_int (XFONT_INSTANCE (font_instance)->ascent); +} + +DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /* +Return the descent in pixels of FONT-INSTANCE. +The returned value is the maximum descent for all characters in the font, +where a character's descent is the number of pixels below the baseline. +\(Many characters to do not have any descent. Typical characters with a +descent are lowercase p and lowercase g.) +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return make_int (XFONT_INSTANCE (font_instance)->descent); +} + +DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /* +Return the width in pixels of FONT-INSTANCE. +The returned value is the average width for all characters in the font. +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return make_int (XFONT_INSTANCE (font_instance)->width); +} + +DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /* +Return whether FONT-INSTANCE is proportional. +This means that different characters in the font have different widths. +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil; +} + +static Lisp_Object +font_instance_truename_internal (Lisp_Object font_instance, + Error_Behavior errb) +{ + Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance); + + if (NILP (f->device)) + { + maybe_signal_error (Qgui_error, + "can't determine truename: " + "no device for font instance", + font_instance, Qfont, errb); + return Qnil; + } + + return DEVMETH_OR_GIVEN (XDEVICE (f->device), + font_instance_truename, (f, errb), f->name); +} + +DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /* +Return the canonical name of FONT-INSTANCE. +Font names are patterns which may match any number of fonts, of which +the first found is used. This returns an unambiguous name for that font +\(but not necessarily its only unambiguous name). +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return font_instance_truename_internal (font_instance, ERROR_ME); +} + +DEFUN ("font-instance-charset", Ffont_instance_charset, 1, 1, 0, /* +Return the Mule charset that FONT-INSTANCE was allocated to handle. +*/ + (font_instance)) +{ + CHECK_FONT_INSTANCE (font_instance); + return XFONT_INSTANCE (font_instance)->charset; +} + +DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /* +Return the properties (an alist or nil) of FONT-INSTANCE. +*/ + (font_instance)) +{ + Lisp_Font_Instance *f; + + CHECK_FONT_INSTANCE (font_instance); + f = XFONT_INSTANCE (font_instance); + + if (NILP (f->device)) + return Qnil; + + return MAYBE_LISP_DEVMETH (XDEVICE (f->device), + font_instance_properties, (f)); +} + +DEFUN ("font-list", Ffont_list, 1, 3, 0, /* +Return a list of font names matching the given pattern. +DEVICE specifies which device to search for names, and defaults to the +currently selected device. +*/ + (pattern, device, maxnumber)) +{ + CHECK_STRING (pattern); + device = wrap_device (decode_device (device)); + + return MAYBE_LISP_DEVMETH (XDEVICE (device), font_list, (pattern, device, + maxnumber)); +} + + +/**************************************************************************** + Color Object + ***************************************************************************/ + +static const struct memory_description color_specifier_description[] = { + { XD_LISP_OBJECT, offsetof (struct color_specifier, face) }, + { XD_LISP_OBJECT, offsetof (struct color_specifier, face_property) }, + { XD_END } +}; + +DEFINE_SPECIFIER_TYPE_WITH_DATA (color); +/* Qcolor defined in general.c */ + +static void +color_create (Lisp_Object obj) +{ + Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); + + COLOR_SPECIFIER_FACE (color) = Qnil; + COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil; +} + +static void +color_mark (Lisp_Object obj) +{ + Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); + + mark_object (COLOR_SPECIFIER_FACE (color)); + mark_object (COLOR_SPECIFIER_FACE_PROPERTY (color)); +} + +/* No equal or hash methods; ignore the face the color is based off + of for `equal' */ + +static Lisp_Object +color_instantiate (Lisp_Object specifier, Lisp_Object UNUSED (matchspec), + Lisp_Object domain, Lisp_Object instantiator, + Lisp_Object depth, int no_fallback) +{ + /* When called, we're inside of call_with_suspended_errors(), + so we can freely error. */ + Lisp_Object device = DOMAIN_DEVICE (domain); + struct device *d = XDEVICE (device); + + if (COLOR_INSTANCEP (instantiator)) + { + /* If we are on the same device then we're done. Otherwise change + the instantiator to the name used to generate the pixel and let the + STRINGP case deal with it. */ + if (NILP (device) /* Vthe_null_color_instance */ + || EQ (device, XCOLOR_INSTANCE (instantiator)->device)) + return instantiator; + else + instantiator = Fcolor_instance_name (instantiator); + } + + if (STRINGP (instantiator)) + { + /* First, look to see if we can retrieve a cached value. */ + Lisp_Object instance = + Fgethash (instantiator, d->color_instance_cache, Qunbound); + /* Otherwise, make a new one. */ + if (UNBOUNDP (instance)) + { + /* make sure we cache the failures, too. */ + instance = Fmake_color_instance (instantiator, device, Qt); + Fputhash (instantiator, instance, d->color_instance_cache); + } + + return NILP (instance) ? Qunbound : instance; + } + else if (VECTORP (instantiator)) + { + switch (XVECTOR_LENGTH (instantiator)) + { + case 0: + if (DEVICE_TTY_P (d)) + return Vthe_null_color_instance; + else + gui_error ("Color instantiator [] only valid on TTY's", + device); + + case 1: + if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)))) + gui_error ("Color specifier not attached to a face", + instantiator); + return (FACE_PROPERTY_INSTANCE_1 + (Fget_face (XVECTOR_DATA (instantiator)[0]), + COLOR_SPECIFIER_FACE_PROPERTY + (XCOLOR_SPECIFIER (specifier)), + domain, ERROR_ME, no_fallback, depth)); + + case 2: + return (FACE_PROPERTY_INSTANCE_1 + (Fget_face (XVECTOR_DATA (instantiator)[0]), + XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, + no_fallback, depth)); + + default: + ABORT (); + } + } + else if (NILP (instantiator)) + { + if (DEVICE_TTY_P (d)) + return Vthe_null_color_instance; + else + gui_error ("Color instantiator [] only valid on TTY's", + device); + } + else + ABORT (); /* The spec validation routines are screwed up. */ + + return Qunbound; +} + +static void +color_validate (Lisp_Object instantiator) +{ + if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator)) + return; + if (VECTORP (instantiator)) + { + if (XVECTOR_LENGTH (instantiator) > 2) + sferror ("Inheritance vector must be of size 0 - 2", + instantiator); + else if (XVECTOR_LENGTH (instantiator) > 0) + { + Lisp_Object face = XVECTOR_DATA (instantiator)[0]; + + Fget_face (face); + if (XVECTOR_LENGTH (instantiator) == 2) + { + Lisp_Object field = XVECTOR_DATA (instantiator)[1]; + if (!EQ (field, Qforeground) && !EQ (field, Qbackground)) + invalid_constant + ("Inheritance field must be `foreground' or `background'", + field); + } + } + } + else + invalid_argument ("Invalid color instantiator", instantiator); +} + +static void +color_after_change (Lisp_Object specifier, Lisp_Object locale) +{ + Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)); + Lisp_Object property = + COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)); + if (!NILP (face)) + { + face_property_was_changed (face, property, locale); + if (BUFFERP (locale)) + XBUFFER (locale)->buffer_local_face_property = 1; + } +} + +void +set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) +{ + Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); + + COLOR_SPECIFIER_FACE (color) = face; + COLOR_SPECIFIER_FACE_PROPERTY (color) = property; +} + +DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /* +Return t if OBJECT is a color specifier. + +See `make-color-specifier' for a description of possible color instantiators. +*/ + (object)) +{ + return COLOR_SPECIFIERP (object) ? Qt : Qnil; +} + + +/**************************************************************************** + Font Object + ***************************************************************************/ + +static const struct memory_description font_specifier_description[] = { + { XD_LISP_OBJECT, offsetof (struct font_specifier, face) }, + { XD_LISP_OBJECT, offsetof (struct font_specifier, face_property) }, + { XD_END } +}; + +DEFINE_SPECIFIER_TYPE_WITH_DATA (font); +/* Qfont defined in general.c */ + +static void +font_create (Lisp_Object obj) +{ + Lisp_Specifier *font = XFONT_SPECIFIER (obj); + + FONT_SPECIFIER_FACE (font) = Qnil; + FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil; +} + +static void +font_mark (Lisp_Object obj) +{ + Lisp_Specifier *font = XFONT_SPECIFIER (obj); + + mark_object (FONT_SPECIFIER_FACE (font)); + mark_object (FONT_SPECIFIER_FACE_PROPERTY (font)); +} + +/* No equal or hash methods; ignore the face the font is based off + of for `equal' */ + +#ifdef MULE + +/* Given a truename font spec (i.e. the font spec should have its registry + field filled in), does it support displaying characters from CHARSET? */ + +static int +font_spec_matches_charset (struct device *d, Lisp_Object charset, + const Ibyte *nonreloc, Lisp_Object reloc, + Bytecount offset, Bytecount length, + enum font_specifier_matchspec_stages stage) +{ + return DEVMETH_OR_GIVEN (d, font_spec_matches_charset, + (d, charset, nonreloc, reloc, offset, length, + stage), + 1); +} + +static void +font_validate_matchspec (Lisp_Object matchspec) +{ + CHECK_CONS (matchspec); + Fget_charset (XCAR (matchspec)); + + do + { + if (EQ(XCDR(matchspec), Qinitial)) + { + break; + } + if (EQ(XCDR(matchspec), Qfinal)) + { + break; + } + + invalid_argument("Invalid font matchspec stage", + XCDR(matchspec)); + } while (0); +} + +void +initialize_charset_font_caches (struct device *d) +{ + /* Note that the following tables are bi-level. */ + d->charset_font_cache_stage_1 = + make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); + d->charset_font_cache_stage_2 = + make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); +} + +void +invalidate_charset_font_caches (Lisp_Object charset) +{ + /* Invalidate font cache entries for charset on all devices. */ + Lisp_Object devcons, concons, hash_table; + DEVICE_LOOP_NO_BREAK (devcons, concons) + { + struct device *d = XDEVICE (XCAR (devcons)); + hash_table = Fgethash (charset, d->charset_font_cache_stage_1, + Qunbound); + if (!UNBOUNDP (hash_table)) + Fclrhash (hash_table); + hash_table = Fgethash (charset, d->charset_font_cache_stage_2, + Qunbound); + if (!UNBOUNDP (hash_table)) + Fclrhash (hash_table); + } +} + +#endif /* MULE */ + +/* It's a little non-obvious what's going on here. Specifically: + + MATCHSPEC is a somewhat bogus way in the specifier mechanism of passing + in additional information needed to instantiate some object. For fonts, + it's a cons of (CHARSET . SECOND-STAGE-P). SECOND-STAGE-P, if set, + means "try harder to find an appropriate font" and is a very bogus way + of dealing with the fact that it may not be possible to may a charset + directly onto a font; it's used esp. under Windows. @@#### We need to + change this so that MATCHSPEC is just a character. + + When redisplay is building up its structure, and needs font info, it + calls functions in faces.c such as ensure_face_cachel_complete() (map + fonts needed for a string of text) or + ensure_face_cachel_contains_charset() (map fonts needed for a charset + derived from a single character). The former function calls the latter; + the latter calls face_property_matching_instance(); this constructs the + MATCHSPEC and calls specifier_instance_no_quit() twice (first stage and + second stage, updating MATCHSPEC appropriately). That function, in + turn, looks up the appropriate specifier method to do the instantiation, + which, lo and behold, is this function here (because we set it in + initialization using `SPECIFIER_HAS_METHOD (font, instantiate);'). We + in turn call the device method `find_charset_font', which maps to + mswindows_find_charset_font(), x_find_charset_font(), or similar, in + fontcolor-msw.c or the like. + + --ben */ + +static Lisp_Object +font_instantiate (Lisp_Object UNUSED (specifier), + Lisp_Object USED_IF_MULE (matchspec), + Lisp_Object domain, Lisp_Object instantiator, + Lisp_Object depth, int no_fallback) +{ + /* When called, we're inside of call_with_suspended_errors(), + so we can freely error. */ + Lisp_Object device = DOMAIN_DEVICE (domain); + struct device *d = XDEVICE (device); + Lisp_Object instance; + Lisp_Object charset = Qnil; +#ifdef MULE + enum font_specifier_matchspec_stages stage = STAGE_INITIAL; + + if (!UNBOUNDP (matchspec)) + { + charset = Fget_charset (XCAR (matchspec)); + +#define FROB(new_stage, enumstage) \ + if (EQ(Q##new_stage, XCDR(matchspec))) \ + { \ + stage = enumstage; \ + } + + FROB (initial, STAGE_INITIAL) + else FROB (final, STAGE_FINAL) + else assert(0); + +#undef FROB + + } +#endif + + if (FONT_INSTANCEP (instantiator)) + { + if (NILP (device) + || EQ (device, XFONT_INSTANCE (instantiator)->device)) + { +#ifdef MULE + if (font_spec_matches_charset (d, charset, 0, + Ffont_instance_truename + (instantiator), + 0, -1, stage)) +#endif + return instantiator; + } + instantiator = Ffont_instance_name (instantiator); + } + + if (STRINGP (instantiator)) + { +#ifdef MULE + /* #### rename these caches. */ + Lisp_Object cache = stage == STAGE_FINAL ? + d->charset_font_cache_stage_2 : + d->charset_font_cache_stage_1; +#else + Lisp_Object cache = d->font_instance_cache; +#endif + +#ifdef MULE + if (!NILP (charset)) + { + /* The instantiator is a font spec that could match many + different fonts. We need to find one of those fonts + whose registry matches the registry of the charset in + MATCHSPEC. This is potentially a very slow operation, + as it involves doing an XListFonts() or equivalent to + iterate over all possible fonts, and a regexp match + on each one. So we cache the results. */ + Lisp_Object matching_font = Qunbound; + Lisp_Object hash_table = Fgethash (charset, cache, Qunbound); + if (UNBOUNDP (hash_table)) + { + /* need to make a sub hash table. */ + hash_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, + HASH_TABLE_EQUAL); + Fputhash (charset, hash_table, cache); + } + else + matching_font = Fgethash (instantiator, hash_table, Qunbound); + + if (UNBOUNDP (matching_font)) + { + /* make sure we cache the failures, too. */ + matching_font = + DEVMETH_OR_GIVEN (d, find_charset_font, + (device, instantiator, charset, stage), + instantiator); + Fputhash (instantiator, matching_font, hash_table); + } + if (NILP (matching_font)) + return Qunbound; + instantiator = matching_font; + } +#endif /* MULE */ + + /* First, look to see if we can retrieve a cached value. */ + instance = Fgethash (instantiator, cache, Qunbound); + /* Otherwise, make a new one. */ + if (UNBOUNDP (instance)) + { + /* make sure we cache the failures, too. */ + instance = Fmake_font_instance (instantiator, device, Qt, charset); + Fputhash (instantiator, instance, cache); + } + + return NILP (instance) ? Qunbound : instance; + } + else if (VECTORP (instantiator)) + { + Lisp_Object match_inst = Qunbound; + assert (XVECTOR_LENGTH (instantiator) == 1); + + match_inst = face_property_matching_instance + (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, + charset, domain, ERROR_ME, no_fallback, depth, STAGE_INITIAL); + + if (UNBOUNDP(match_inst)) + { + match_inst = face_property_matching_instance + (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, + charset, domain, ERROR_ME, no_fallback, depth, STAGE_FINAL); + } + + return match_inst; + + } + else if (NILP (instantiator)) + return Qunbound; + else + ABORT (); /* Eh? */ + + return Qunbound; +} + +static void +font_validate (Lisp_Object instantiator) +{ + if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator)) + return; + if (VECTORP (instantiator)) + { + if (XVECTOR_LENGTH (instantiator) != 1) + { + sferror + ("Vector length must be one for font inheritance", instantiator); + } + Fget_face (XVECTOR_DATA (instantiator)[0]); + } + else + invalid_argument ("Must be string, vector, or font-instance", + instantiator); +} + +static void +font_after_change (Lisp_Object specifier, Lisp_Object locale) +{ + Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier)); + Lisp_Object property = + FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier)); + if (!NILP (face)) + { + face_property_was_changed (face, property, locale); + if (BUFFERP (locale)) + XBUFFER (locale)->buffer_local_face_property = 1; + } +} + +void +set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) +{ + Lisp_Specifier *font = XFONT_SPECIFIER (obj); + + FONT_SPECIFIER_FACE (font) = face; + FONT_SPECIFIER_FACE_PROPERTY (font) = property; +} + +DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /* +Return non-nil if OBJECT is a font specifier. + +See `make-font-specifier' for a description of possible font instantiators. +*/ + (object)) +{ + return FONT_SPECIFIERP (object) ? Qt : Qnil; +} + + +/***************************************************************************** + Face Boolean Object + ****************************************************************************/ + +static const struct memory_description face_boolean_specifier_description[] = { + { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face) }, + { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face_property) }, + { XD_END } +}; + +DEFINE_SPECIFIER_TYPE_WITH_DATA (face_boolean); +Lisp_Object Qface_boolean; + +static void +face_boolean_create (Lisp_Object obj) +{ + Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); + + FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil; + FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil; +} + +static void +face_boolean_mark (Lisp_Object obj) +{ + Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); + + mark_object (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)); + mark_object (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)); +} + +/* No equal or hash methods; ignore the face the face-boolean is based off + of for `equal' */ + +static Lisp_Object +face_boolean_instantiate (Lisp_Object specifier, + Lisp_Object UNUSED (matchspec), + Lisp_Object domain, Lisp_Object instantiator, + Lisp_Object depth, int no_fallback) +{ + /* When called, we're inside of call_with_suspended_errors(), + so we can freely error. */ + if (NILP (instantiator) || EQ (instantiator, Qt)) + return instantiator; + else if (VECTORP (instantiator)) + { + Lisp_Object retval; + Lisp_Object prop; + int instantiator_len = XVECTOR_LENGTH (instantiator); + + assert (instantiator_len >= 1 && instantiator_len <= 3); + if (instantiator_len > 1) + prop = XVECTOR_DATA (instantiator)[1]; + else + { + if (NILP (FACE_BOOLEAN_SPECIFIER_FACE + (XFACE_BOOLEAN_SPECIFIER (specifier)))) + gui_error + ("Face-boolean specifier not attached to a face", instantiator); + prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY + (XFACE_BOOLEAN_SPECIFIER (specifier)); + } + + retval = (FACE_PROPERTY_INSTANCE_1 + (Fget_face (XVECTOR_DATA (instantiator)[0]), + prop, domain, ERROR_ME, no_fallback, depth)); + + if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2])) + retval = NILP (retval) ? Qt : Qnil; + + return retval; + } + else + ABORT (); /* Eh? */ + + return Qunbound; +} + +static void +face_boolean_validate (Lisp_Object instantiator) +{ + if (NILP (instantiator) || EQ (instantiator, Qt)) + return; + else if (VECTORP (instantiator) && + (XVECTOR_LENGTH (instantiator) >= 1 && + XVECTOR_LENGTH (instantiator) <= 3)) + { + Lisp_Object face = XVECTOR_DATA (instantiator)[0]; + + Fget_face (face); + + if (XVECTOR_LENGTH (instantiator) > 1) + { + Lisp_Object field = XVECTOR_DATA (instantiator)[1]; + if (!EQ (field, Qunderline) + && !EQ (field, Qstrikethru) + && !EQ (field, Qhighlight) + && !EQ (field, Qdim) + && !EQ (field, Qblinking) + && !EQ (field, Qreverse)) + invalid_constant ("Invalid face-boolean inheritance field", + field); + } + } + else if (VECTORP (instantiator)) + sferror ("Wrong length for face-boolean inheritance spec", + instantiator); + else + invalid_argument ("Face-boolean instantiator must be nil, t, or vector", + instantiator); +} + +static void +face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale) +{ + Lisp_Object face = + FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier)); + Lisp_Object property = + FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier)); + if (!NILP (face)) + { + face_property_was_changed (face, property, locale); + if (BUFFERP (locale)) + XBUFFER (locale)->buffer_local_face_property = 1; + } +} + +void +set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face, + Lisp_Object property) +{ + Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); + + FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face; + FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property; +} + +DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /* +Return non-nil if OBJECT is a face-boolean specifier. + +See `make-face-boolean-specifier' for a description of possible +face-boolean instantiators. +*/ + (object)) +{ + return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; +} + + +/***************************************************************************** + Face Background Placement Object + ****************************************************************************/ +Lisp_Object Qabsolute, Qrelative; + +static const struct memory_description +face_background_placement_specifier_description[] = { + { XD_LISP_OBJECT, offsetof (struct face_background_placement_specifier, + face) }, + { XD_END } +}; + +DEFINE_SPECIFIER_TYPE_WITH_DATA (face_background_placement); +Lisp_Object Qface_background_placement; + +static void +face_background_placement_create (Lisp_Object obj) +{ + Lisp_Specifier *face_background_placement + = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); + + FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = Qnil; +} + +static void +face_background_placement_mark (Lisp_Object obj) +{ + Lisp_Specifier *face_background_placement + = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); + + mark_object + (FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement)); +} + +/* No equal or hash methods; ignore the face the background-placement is based + off of for `equal' */ + +extern Lisp_Object Qbackground_placement; + +static Lisp_Object +face_background_placement_instantiate (Lisp_Object UNUSED (specifier), + Lisp_Object UNUSED (matchspec), + Lisp_Object domain, + Lisp_Object instantiator, + Lisp_Object depth, + int no_fallback) +{ + /* When called, we're inside of call_with_suspended_errors(), + so we can freely error. */ + if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative)) + return instantiator; + else if (VECTORP (instantiator)) + { + assert (XVECTOR_LENGTH (instantiator) == 1); + + return FACE_PROPERTY_INSTANCE_1 + (Fget_face (XVECTOR_DATA (instantiator)[0]), + Qbackground_placement, domain, ERROR_ME, no_fallback, depth); + } + else + ABORT (); /* Eh? */ + + return Qunbound; +} + +static void +face_background_placement_validate (Lisp_Object instantiator) +{ + if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative)) + return; + else if (VECTORP (instantiator) && + (XVECTOR_LENGTH (instantiator) == 1)) + { + Lisp_Object face = XVECTOR_DATA (instantiator)[0]; + + Fget_face (face); /* just to check that the face exists -- dvl */ + } + else if (VECTORP (instantiator)) + sferror ("Wrong length for background-placement inheritance spec", + instantiator); + else + invalid_argument + ("\ +Background-placement instantiator must be absolute, relative or vector", + instantiator); +} + +static void +face_background_placement_after_change (Lisp_Object specifier, + Lisp_Object locale) +{ + Lisp_Object face + = FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE + (XFACE_BACKGROUND_PLACEMENT_SPECIFIER (specifier)); + + if (!NILP (face)) + { + face_property_was_changed (face, Qbackground_placement, locale); + if (BUFFERP (locale)) + XBUFFER (locale)->buffer_local_face_property = 1; + } +} + +void +set_face_background_placement_attached_to (Lisp_Object obj, Lisp_Object face) +{ + Lisp_Specifier *face_background_placement + = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); + + FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = face; +} + +DEFUN ("face-background-placement-specifier-p", Fface_background_placement_specifier_p, 1, 1, 0, /* +Return non-nil if OBJECT is a face-background-placement specifier. + +See `make-face-background-placement-specifier' for a description of possible +face-background-placement instantiators. +*/ + (object)) +{ + return FACE_BACKGROUND_PLACEMENT_SPECIFIERP (object) ? Qt : Qnil; +} + + +/************************************************************************/ +/* initialization */ +/************************************************************************/ + +void +syms_of_fontcolor (void) +{ + INIT_LISP_OBJECT (color_instance); + INIT_LISP_OBJECT (font_instance); + + DEFSUBR (Fcolor_specifier_p); + DEFSUBR (Ffont_specifier_p); + DEFSUBR (Fface_boolean_specifier_p); + DEFSUBR (Fface_background_placement_specifier_p); + + DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep); + DEFSUBR (Fmake_color_instance); + DEFSUBR (Fcolor_instance_p); + DEFSUBR (Fcolor_instance_name); + DEFSUBR (Fcolor_instance_rgb_components); + DEFSUBR (Fvalid_color_name_p); + DEFSUBR (Fcolor_list); + + DEFSYMBOL_MULTIWORD_PREDICATE (Qfont_instancep); + DEFSUBR (Fmake_font_instance); + DEFSUBR (Ffont_instance_p); + DEFSUBR (Ffont_instance_name); + DEFSUBR (Ffont_instance_ascent); + DEFSUBR (Ffont_instance_descent); + DEFSUBR (Ffont_instance_width); + DEFSUBR (Ffont_instance_charset); + DEFSUBR (Ffont_instance_proportional_p); + DEFSUBR (Ffont_instance_truename); + DEFSUBR (Ffont_instance_properties); + DEFSUBR (Ffont_list); + + /* Qcolor, Qfont defined in general.c */ + DEFSYMBOL (Qface_boolean); + + DEFSYMBOL (Qface_background_placement); + DEFSYMBOL (Qabsolute); + DEFSYMBOL (Qrelative); +} + +void +specifier_type_create_fontcolor (void) +{ + INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p"); + INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p"); + INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean", + "face-boolean-specifier-p"); + INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_background_placement, + "face-background-placement", + "\ +face-background-placement-specifier-p"); + + SPECIFIER_HAS_METHOD (color, instantiate); + SPECIFIER_HAS_METHOD (font, instantiate); + SPECIFIER_HAS_METHOD (face_boolean, instantiate); + SPECIFIER_HAS_METHOD (face_background_placement, instantiate); + + SPECIFIER_HAS_METHOD (color, validate); + SPECIFIER_HAS_METHOD (font, validate); + SPECIFIER_HAS_METHOD (face_boolean, validate); + SPECIFIER_HAS_METHOD (face_background_placement, validate); + + SPECIFIER_HAS_METHOD (color, create); + SPECIFIER_HAS_METHOD (font, create); + SPECIFIER_HAS_METHOD (face_boolean, create); + SPECIFIER_HAS_METHOD (face_background_placement, create); + + SPECIFIER_HAS_METHOD (color, mark); + SPECIFIER_HAS_METHOD (font, mark); + SPECIFIER_HAS_METHOD (face_boolean, mark); + SPECIFIER_HAS_METHOD (face_background_placement, mark); + + SPECIFIER_HAS_METHOD (color, after_change); + SPECIFIER_HAS_METHOD (font, after_change); + SPECIFIER_HAS_METHOD (face_boolean, after_change); + SPECIFIER_HAS_METHOD (face_background_placement, after_change); + +#ifdef MULE + SPECIFIER_HAS_METHOD (font, validate_matchspec); +#endif +} + +void +reinit_specifier_type_create_fontcolor (void) +{ + REINITIALIZE_SPECIFIER_TYPE (color); + REINITIALIZE_SPECIFIER_TYPE (font); + REINITIALIZE_SPECIFIER_TYPE (face_boolean); + REINITIALIZE_SPECIFIER_TYPE (face_background_placement); +} + +void +reinit_vars_of_fontcolor (void) +{ + { + Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); + Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); + c->name = Qnil; + c->device = Qnil; + c->data = 0; + + Vthe_null_color_instance = obj; + staticpro_nodump (&Vthe_null_color_instance); + } + + { + Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); + Lisp_Font_Instance *f = XFONT_INSTANCE (obj); + f->name = Qnil; + f->truename = Qnil; + f->device = Qnil; + f->data = 0; + + f->ascent = f->height = 0; + f->descent = 0; + f->width = 0; + f->proportional_p = 0; + + Vthe_null_font_instance = obj; + staticpro_nodump (&Vthe_null_font_instance); + } +} + +void +vars_of_fontcolor (void) +{ +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/fontcolor.h Mon Mar 29 22:52:01 2010 -0500 @@ -0,0 +1,87 @@ +/* Generic object functions -- interface. + Copyright (C) 1995 Board of Trustees, University of Illinois. + Copyright (C) 1995, 1996, 2002, 2010 Ben Wing. + +This file is part of XEmacs. + +XEmacs is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +XEmacs is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with XEmacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +/* Synched up with: Not in FSF. */ + +#ifndef INCLUDED_fontcolor_h_ +#define INCLUDED_fontcolor_h_ + +DECLARE_DOESNT_RETURN (finalose (void *ptr)); + +/**************************************************************************** + * Color Instance Object * + ****************************************************************************/ + +DECLARE_LISP_OBJECT (color_instance, Lisp_Color_Instance); +#define XCOLOR_INSTANCE(x) XRECORD (x, color_instance, Lisp_Color_Instance) +#define wrap_color_instance(p) wrap_record (p, color_instance) +#define COLOR_INSTANCEP(x) RECORDP (x, color_instance) +#define CHECK_COLOR_INSTANCE(x) CHECK_RECORD (x, color_instance) +#define CONCHECK_COLOR_INSTANCE(x) CONCHECK_RECORD (x, color_instance) + +EXFUN (Fmake_color_instance, 3); + +extern Lisp_Object Vthe_null_color_instance; + +void set_color_attached_to (Lisp_Object obj, Lisp_Object face, + Lisp_Object property); + +/**************************************************************************** + * Font Instance Object * + ****************************************************************************/ + +void initialize_charset_font_caches (struct device *d); +void invalidate_charset_font_caches (Lisp_Object charset); + +DECLARE_LISP_OBJECT (font_instance, Lisp_Font_Instance); +#define XFONT_INSTANCE(x) XRECORD (x, font_instance, Lisp_Font_Instance) +#define wrap_font_instance(p) wrap_record (p, font_instance) +#define FONT_INSTANCEP(x) RECORDP (x, font_instance) +#define CHECK_FONT_INSTANCE(x) CHECK_RECORD (x, font_instance) +#define CONCHECK_FONT_INSTANCE(x) CONCHECK_RECORD (x, font_instance) + +EXFUN (Fmake_font_instance, 4); +EXFUN (Ffont_instance_name, 1); +EXFUN (Ffont_instance_p, 1); +EXFUN (Ffont_instance_truename, 1); +EXFUN (Ffont_instance_charset, 1); + +extern Lisp_Object Vthe_null_font_instance; + +void set_font_attached_to (Lisp_Object obj, Lisp_Object face, + Lisp_Object property); + +/***************************************************************************** + * Face Boolean Specifier Object * + *****************************************************************************/ + +void set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face, + Lisp_Object property); + +/***************************************************************************** + * Face Background Placement Specifier Object * + *****************************************************************************/ + +void set_face_background_placement_attached_to (Lisp_Object obj, + Lisp_Object face); + + +#endif /* INCLUDED_fontcolor_h_ */
--- a/src/frame-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/frame-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -42,7 +42,7 @@ #include "elhash.h" #include "console-gtk-impl.h" #include "glyphs-gtk.h" -#include "objects-gtk-impl.h" +#include "fontcolor-gtk-impl.h" #include "scrollbar-gtk.h" #include "ui-gtk.h"
--- a/src/frame-x.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/frame-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -40,7 +40,7 @@ #include "console-x-impl.h" #include "glyphs-x.h" -#include "objects-x-impl.h" +#include "fontcolor-x-impl.h" #include "scrollbar-x.h" #include "xintrinsicp.h" /* CoreP.h needs this */
--- a/src/glyphs-eimage.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs-eimage.c Mon Mar 29 22:52:01 2010 -0500 @@ -47,7 +47,7 @@ #include "device-impl.h" #include "faces.h" #include "glyphs.h" -#include "objects-impl.h" +#include "fontcolor-impl.h" #include "buffer.h" #include "frame.h"
--- a/src/glyphs-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -67,7 +67,7 @@ #include "console-gtk-impl.h" #include "glyphs-gtk.h" -#include "objects-gtk-impl.h" +#include "fontcolor-gtk-impl.h" #include "ui-gtk.h" #include "sysfile.h"
--- a/src/glyphs-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -47,7 +47,7 @@ #include "console-msw-impl.h" #include "glyphs-msw.h" -#include "objects-msw-impl.h" +#include "fontcolor-msw-impl.h" #define WIDGET_GLYPH_SLOT 0
--- a/src/glyphs-widget.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs-widget.c Mon Mar 29 22:52:01 2010 -0500 @@ -35,7 +35,7 @@ #include "gui.h" #include "insdel.h" #include "lstream.h" -#include "objects.h" +#include "fontcolor.h" #include "opaque.h" #include "window.h"
--- a/src/glyphs-x.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -69,7 +69,7 @@ #include "console-x-impl.h" #include "glyphs-x.h" -#include "objects-x-impl.h" +#include "fontcolor-x-impl.h" #include "sysfile.h" #include "sysproc.h" /* for qxe_getpid() */
--- a/src/glyphs.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/glyphs.c Mon Mar 29 22:52:01 2010 -0500 @@ -57,7 +57,7 @@ #include "glyphs.h" #include "gui.h" #include "insdel.h" -#include "objects-impl.h" +#include "fontcolor-impl.h" #include "opaque.h" #include "rangetab.h" #include "redisplay.h"
--- a/src/gtk-glue.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/gtk-glue.c Mon Mar 29 22:52:01 2010 -0500 @@ -26,7 +26,7 @@ GtkType GTK_TYPE_GDK_GC = 0; #include "console-gtk.h" -#include "objects-gtk-impl.h" +#include "fontcolor-gtk-impl.h" static GtkType xemacs_type_register (gchar *name, GtkType parent)
--- a/src/gtk-xemacs.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/gtk-xemacs.c Mon Mar 29 22:52:01 2010 -0500 @@ -36,7 +36,7 @@ #include "console-gtk-impl.h" #include "device-impl.h" #include "gtk-xemacs.h" -#include "objects-gtk.h" +#include "fontcolor-gtk.h" extern Lisp_Object Vmodeline_face; extern Lisp_Object Vscrollbar_on_left_p; @@ -148,7 +148,7 @@ extern Lisp_Object xemacs_gtk_convert_color(GdkColor *c, GtkWidget *w); -/* From objects-gtk.c */ +/* From fontcolor-gtk.c */ extern Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp); #define convert_font(f) __get_gtk_font_truename (f, 0)
--- a/src/inline.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/inline.c Mon Mar 29 22:52:01 2010 -0500 @@ -1,5 +1,6 @@ /* Repository for inline functions Copyright (C) 1995 Sun Microsystems, Inc. + Copyright (C) 2010 Ben Wing. This file is part of XEmacs. @@ -59,7 +60,7 @@ #include "gui.h" #include "keymap.h" #include "lstream.h" -#include "objects-impl.h" +#include "fontcolor-impl.h" #include "opaque.h" #include "process.h" #include "rangetab.h" @@ -114,7 +115,7 @@ #ifdef HAVE_TTY #include "console-tty-impl.h" -#include "objects-tty-impl.h" +#include "fontcolor-tty-impl.h" #endif #ifdef HAVE_GTK
--- a/src/intl-win32.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/intl-win32.c Mon Mar 29 22:52:01 2010 -0500 @@ -42,7 +42,7 @@ #include "window-impl.h" #include "console-msw-impl.h" -#include "objects-msw-impl.h" +#include "fontcolor-msw-impl.h" #ifndef CYGWIN_HEADERS # include <mbctype.h>
--- a/src/lisp.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/lisp.h Mon Mar 29 22:52:01 2010 -0500 @@ -1546,8 +1546,8 @@ typedef struct Lisp_Event Lisp_Event; /* "events.h" */ typedef struct Lisp_Face Lisp_Face; /* "faces-impl.h" */ typedef struct Lisp_Process Lisp_Process; /* "procimpl.h" */ -typedef struct Lisp_Color_Instance Lisp_Color_Instance; /* objects-impl.h */ -typedef struct Lisp_Font_Instance Lisp_Font_Instance; /* objects-impl.h */ +typedef struct Lisp_Color_Instance Lisp_Color_Instance; /* fontcolor-impl.h */ +typedef struct Lisp_Font_Instance Lisp_Font_Instance; /* fontcolor-impl.h */ typedef struct Lisp_Image_Instance Lisp_Image_Instance; /* glyphs.h */ typedef struct Lisp_Gui_Item Lisp_Gui_Item;
--- a/src/lrecord.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/lrecord.h Mon Mar 29 22:52:01 2010 -0500 @@ -1123,7 +1123,7 @@ "inline" to the union data, like XD_BLOCK_ARRAY and not XD_BLOCK_PTR. If the union data is a pointer to different types of structures, each element in the memory_description should be an XD_BLOCK_PTR. See - unicode.c, redisplay.c and objects.c for examples of XD_UNION. + unicode.c, redisplay.c and fontcolor.c for examples of XD_UNION. XD_UNION_DYNAMIC_SIZE
--- a/src/mule-charset.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/mule-charset.c Mon Mar 29 22:52:01 2010 -0500 @@ -34,7 +34,7 @@ #include "faces.h" #include "lstream.h" #include "mule-ccl.h" -#include "objects.h" +#include "fontcolor.h" #include "specifier.h" /* The various pre-defined charsets. */
--- a/src/native-gtk-toolbar.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/native-gtk-toolbar.c Mon Mar 29 22:52:01 2010 -0500 @@ -26,7 +26,7 @@ #include "console-gtk.h" #include "glyphs-gtk.h" -#include "objects-gtk.h" +#include "fontcolor-gtk.h" #include "faces.h" #include "frame.h"
--- a/src/objects-gtk-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -/* Gtk-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ -/* Gtk version by William Perry */ - -#ifndef _XEMACS_OBJECTS_GTK_IMPL_H_ -#define _XEMACS_OBJECTS_GTK_IMPL_H_ - -#include "objects-impl.h" -#include "objects-gtk.h" - -#ifdef HAVE_GTK - -/***************************************************************************** - Color-Instance - ****************************************************************************/ - -struct gtk_color_instance_data -{ - GdkColor *color; - char dealloc_on_gc; -}; - -#define GTK_COLOR_INSTANCE_DATA(c) ((struct gtk_color_instance_data *) (c)->data) -#define COLOR_INSTANCE_GTK_COLOR(c) (GTK_COLOR_INSTANCE_DATA (c)->color) -#define XCOLOR_INSTANCE_GTK_COLOR(c) COLOR_INSTANCE_GTK_COLOR (XCOLOR_INSTANCE (c)) -#define COLOR_INSTANCE_GTK_DEALLOC(c) (GTK_COLOR_INSTANCE_DATA (c)->dealloc_on_gc) - -/***************************************************************************** - Font-Instance - ****************************************************************************/ - -struct gtk_font_instance_data -{ - /* Gtk-specific information */ - GdkFont *font; -}; - -#define GTK_FONT_INSTANCE_DATA(f) ((struct gtk_font_instance_data *) (f)->data) -#define FONT_INSTANCE_GTK_FONT(f) (GTK_FONT_INSTANCE_DATA (f)->font) -#define XFONT_INSTANCE_GTK_FONT(c) FONT_INSTANCE_GTK_FONT (XFONT_INSTANCE (c)) - -#endif /* HAVE_GTK */ -#endif /* _XEMACS_OBJECTS_GTK_IMPL_H_ */
--- a/src/objects-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,511 +0,0 @@ -/* X-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995 Tinker Systems. - Copyright (C) 1995, 1996, 2002 Ben Wing. - Copyright (C) 1995 Sun Microsystems, Inc. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */ -/* Gtk version by William Perry */ - -#include <config.h> -#include "lisp.h" - -#include "buffer.h" -#include "charset.h" -#include "device-impl.h" -#include "insdel.h" - -#include "console-gtk-impl.h" -#include "objects-gtk-impl.h" - -/* sigh */ -#include "sysgdkx.h" - -/* XListFonts doesn't allocate memory unconditionally based on this. (For - XFree86 in 2005, at least. */ -#define MAX_FONT_COUNT INT_MAX - -#ifdef DEBUG_XEMACS -Fixnum debug_x_objects; -#endif /* DEBUG_XEMACS */ - - -/************************************************************************/ -/* color instances */ -/************************************************************************/ - -/* Replacement for XAllocColor() that tries to return the nearest - available color if the colormap is full. Original was from FSFmacs, - but rewritten by Jareth Hein <jareth@camelot-soft.com> 97/11/25 - Modified by Lee Kindness <lkindness@csl.co.uk> 31/08/99 to handle previous - total failure which was due to a read/write colorcell being the nearest - match - tries the next nearest... - - Gdk takes care of all this behind the scenes, so we don't need to - worry about it. - - Return value is 1 for normal success, 2 for nearest color success, - 3 for Non-deallocable sucess. */ -int -allocate_nearest_color (GdkColormap *colormap, GdkVisual *UNUSED (visual), - GdkColor *color_def) -{ - int rc; - - rc = gdk_colormap_alloc_color (colormap, color_def, FALSE, TRUE); - - if (rc == TRUE) - return (1); - - return (0); -} - -int -gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name, - Bytecount len, Error_Behavior errb) -{ - GdkColormap *cmap; - GdkVisual *visual; - int result; - - cmap = DEVICE_GTK_COLORMAP(d); - visual = DEVICE_GTK_VISUAL (d); - - xzero (*color); - { - const Extbyte *extname; - Bytecount extnamelen; - - TO_EXTERNAL_FORMAT (DATA, (name, len), ALLOCA, (extname, extnamelen), Qbinary); - - result = gdk_color_parse (extname, color); - } - - if (result == FALSE) - { - maybe_invalid_argument ("unrecognized color", make_string (name, len), - Qcolor, errb); - return 0; - } - result = allocate_nearest_color (cmap, visual, color); - if (!result) - { - maybe_signal_error (Qgui_error, "couldn't allocate color", - make_string (name, len), Qcolor, errb); - return 0; - } - - return result; -} - -static int -gtk_initialize_color_instance (struct Lisp_Color_Instance *c, Lisp_Object name, - Lisp_Object device, Error_Behavior errb) -{ - GdkColor color; - int result; - - result = gtk_parse_nearest_color (XDEVICE (device), &color, - XSTRING_DATA (name), - XSTRING_LENGTH (name), - errb); - - if (!result) - return 0; - - /* Don't allocate the data until we're sure that we will succeed, - or the finalize method may get fucked. */ - c->data = xnew (struct gtk_color_instance_data); - if (result == 3) - COLOR_INSTANCE_GTK_DEALLOC (c) = 0; - else - COLOR_INSTANCE_GTK_DEALLOC (c) = 1; - COLOR_INSTANCE_GTK_COLOR (c) = gdk_color_copy (&color); - return 1; -} - -static void -gtk_print_color_instance (struct Lisp_Color_Instance *c, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c); - write_fmt_string (printcharfun, " %ld=(%X,%X,%X)", - color->pixel, color->red, color->green, color->blue); -} - -static void -gtk_finalize_color_instance (struct Lisp_Color_Instance *c) -{ - if (c->data) - { - if (DEVICE_LIVE_P (XDEVICE (c->device))) - { - if (COLOR_INSTANCE_GTK_DEALLOC (c)) - { - gdk_colormap_free_colors (DEVICE_GTK_COLORMAP (XDEVICE (c->device)), - COLOR_INSTANCE_GTK_COLOR (c), 1); - } - gdk_color_free (COLOR_INSTANCE_GTK_COLOR (c)); - } - xfree (c->data); - c->data = 0; - } -} - -/* Color instances are equal if they resolve to the same color on the - screen (have the same RGB values). I imagine that - "same RGB values" == "same cell in the colormap." Arguably we should - be comparing their names or pixel values instead. */ - -static int -gtk_color_instance_equal (struct Lisp_Color_Instance *c1, - struct Lisp_Color_Instance *c2, - int UNUSED (depth)) -{ - return (gdk_color_equal (COLOR_INSTANCE_GTK_COLOR (c1), - COLOR_INSTANCE_GTK_COLOR (c2))); -} - -static Hashcode -gtk_color_instance_hash (struct Lisp_Color_Instance *c, int UNUSED (depth)) -{ - return (gdk_color_hash (COLOR_INSTANCE_GTK_COLOR (c), NULL)); -} - -static Lisp_Object -gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c) -{ - GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c); - return (list3 (make_int (color->red), - make_int (color->green), - make_int (color->blue))); -} - -static int -gtk_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) -{ - GdkColor c; - const char *extname; - - extname = LISP_STRING_TO_EXTERNAL (color, Qctext); - - if (gdk_color_parse (extname, &c) != TRUE) - return(0); - return (1); -} - -static Lisp_Object -gtk_color_list (void) -{ - /* #### BILL!!! - Is this correct? */ - return call0 (intern ("x-color-list-internal")); -} - - -/************************************************************************/ -/* font instances */ -/************************************************************************/ - -static int -gtk_initialize_font_instance (struct Lisp_Font_Instance *f, - Lisp_Object UNUSED (name), - Lisp_Object UNUSED (device), Error_Behavior errb) -{ - GdkFont *gf; - XFontStruct *xf; - const char *extname; - - extname = LISP_STRING_TO_EXTERNAL (f->name, Qctext); - - gf = gdk_font_load (extname); - - if (!gf) - { - maybe_signal_error (Qgui_error, "couldn't load font", f->name, - Qfont, errb); - return 0; - } - - xf = (XFontStruct*) GDK_FONT_XFONT (gf); - - /* Don't allocate the data until we're sure that we will succeed, - or the finalize method may get fucked. */ - f->data = xnew (struct gtk_font_instance_data); - FONT_INSTANCE_GTK_FONT (f) = gf; - f->ascent = gf->ascent; - f->descent = gf->descent; - f->height = gf->ascent + gf->descent; - - /* Now lets figure out the width of the font */ - { - /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */ - unsigned int def_char = 'n'; /*xf->default_char;*/ - unsigned int byte1, byte2; - - once_more: - byte1 = def_char >> 8; - byte2 = def_char & 0xFF; - - if (xf->per_char) - { - /* Old versions of the R5 font server have garbage (>63k) as - def_char. 'n' might not be a valid character. */ - if (byte1 < xf->min_byte1 || - byte1 > xf->max_byte1 || - byte2 < xf->min_char_or_byte2 || - byte2 > xf->max_char_or_byte2) - f->width = 0; - else - f->width = xf->per_char[(byte1 - xf->min_byte1) * - (xf->max_char_or_byte2 - - xf->min_char_or_byte2 + 1) + - (byte2 - xf->min_char_or_byte2)].width; - } - else - f->width = xf->max_bounds.width; - - /* Some fonts have a default char whose width is 0. This is no good. - If that's the case, first try 'n' as the default char, and if n has - 0 width too (unlikely) then just use the max width. */ - if (f->width == 0) - { - if (def_char == xf->default_char) - f->width = xf->max_bounds.width; - else - { - def_char = xf->default_char; - goto once_more; - } - } - } - - /* If all characters don't exist then there could potentially be - 0-width characters lurking out there. Not setting this flag - trips an optimization that would make them appear to have width - to redisplay. This is bad. So we set it if not all characters - have the same width or if not all characters are defined. - */ - /* #### This sucks. There is a measurable performance increase - when using proportional width fonts if this flag is not set. - Unfortunately so many of the fucking X fonts are not fully - defined that we could almost just get rid of this damn flag and - make it an assertion. */ - f->proportional_p = (xf->min_bounds.width != xf->max_bounds.width || - (/* x_handle_non_fully_specified_fonts */ 0 && - !xf->all_chars_exist)); -#if 0 - f->width = gdk_char_width (gf, 'n'); - f->proportional_p = (gdk_char_width (gf, '|') != gdk_char_width (gf, 'W')) ? 1 : 0; -#endif - return 1; -} - -static void -gtk_print_font_instance (struct Lisp_Font_Instance *f, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - write_fmt_string (printcharfun, " 0x%lx", - (unsigned long) gdk_font_id (FONT_INSTANCE_GTK_FONT (f))); -} - -static void -gtk_finalize_font_instance (struct Lisp_Font_Instance *f) -{ - if (f->data) - { - if (DEVICE_LIVE_P (XDEVICE (f->device))) - { - gdk_font_unref (FONT_INSTANCE_GTK_FONT (f)); - } - xfree (f->data); - f->data = 0; - } -} - -/* Forward declarations for X specific functions at the end of the file */ -Lisp_Object __get_gtk_font_truename (GdkFont *gdk_font, int expandp); -static Lisp_Object __gtk_font_list_internal (const char *pattern); - -static Lisp_Object -gtk_font_instance_truename (struct Lisp_Font_Instance *f, - Error_Behavior UNUSED (errb)) -{ - if (NILP (FONT_INSTANCE_TRUENAME (f))) - { - FONT_INSTANCE_TRUENAME (f) = __get_gtk_font_truename (FONT_INSTANCE_GTK_FONT (f), 1); - - if (NILP (FONT_INSTANCE_TRUENAME (f))) - { - /* Ok, just this once, return the font name as the truename. - (This is only used by Fequal() right now.) */ - return f->name; - } - } - return (FONT_INSTANCE_TRUENAME (f)); -} - -static Lisp_Object -gtk_font_instance_properties (struct Lisp_Font_Instance *UNUSED (f)) -{ - Lisp_Object result = Qnil; - - /* #### BILL!!! */ - /* There seems to be no way to get this information under Gtk */ - return result; -} - -static Lisp_Object -gtk_font_list (Lisp_Object pattern, Lisp_Object UNUSED (device), - Lisp_Object UNUSED (maxnumber)) -{ - const char *patternext; - - patternext = LISP_STRING_TO_EXTERNAL (pattern, Qbinary); - - return (__gtk_font_list_internal (patternext)); -} - -/* Include the charset support, shared, for the moment, with X11. */ -#define THIS_IS_GTK -#include "objects-xlike-inc.c" - - -/************************************************************************/ -/* initialization */ -/************************************************************************/ - -void -syms_of_objects_gtk (void) -{ -} - -void -console_type_create_objects_gtk (void) -{ - /* object methods */ - - CONSOLE_HAS_METHOD (gtk, initialize_color_instance); - CONSOLE_HAS_METHOD (gtk, print_color_instance); - CONSOLE_HAS_METHOD (gtk, finalize_color_instance); - CONSOLE_HAS_METHOD (gtk, color_instance_equal); - CONSOLE_HAS_METHOD (gtk, color_instance_hash); - CONSOLE_HAS_METHOD (gtk, color_instance_rgb_components); - CONSOLE_HAS_METHOD (gtk, valid_color_name_p); - CONSOLE_HAS_METHOD (gtk, color_list); - - CONSOLE_HAS_METHOD (gtk, initialize_font_instance); - CONSOLE_HAS_METHOD (gtk, print_font_instance); - CONSOLE_HAS_METHOD (gtk, finalize_font_instance); - CONSOLE_HAS_METHOD (gtk, font_instance_truename); - CONSOLE_HAS_METHOD (gtk, font_instance_properties); - CONSOLE_HAS_METHOD (gtk, font_list); -#ifdef MULE - CONSOLE_HAS_METHOD (gtk, find_charset_font); - CONSOLE_HAS_METHOD (gtk, font_spec_matches_charset); -#endif -} - -void -vars_of_objects_gtk (void) -{ -#ifdef DEBUG_XEMACS - DEFVAR_INT ("debug-x-objects", &debug_x_objects /* -If non-zero, display debug information about X objects -*/ ); - debug_x_objects = 0; -#endif -} - -static int -valid_font_name_p (Display *dpy, char *name) -{ - /* Maybe this should be implemented by callign XLoadFont and trapping - the error. That would be a lot of work, and wasteful as hell, but - might be more correct. - */ - int nnames = 0; - char **names = 0; - if (! name) - return 0; - names = XListFonts (dpy, name, 1, &nnames); - if (names) - XFreeFontNames (names); - return (nnames != 0); -} - -Lisp_Object -__get_gtk_font_truename (GdkFont *gdk_font, int expandp) -{ - Display *dpy = GDK_FONT_XDISPLAY (gdk_font); - GSList *names = ((GdkFontPrivate *) gdk_font)->names; - Lisp_Object font_name = Qnil; - - while (names) - { - if (names->data) - { - if (valid_font_name_p (dpy, (char*) names->data)) - { - if (!expandp) - { - /* They want the wildcarded version */ - font_name = build_cistring ((char*) names->data); - } - else - { - /* Need to expand out */ - int nnames = 0; - char **x_font_names = 0; - - x_font_names = XListFonts (dpy, (char*) names->data, 1, &nnames); - if (x_font_names) - { - font_name = build_cistring (x_font_names[0]); - XFreeFontNames (x_font_names); - } - } - break; - } - } - names = names->next; - } - return (font_name); -} - -static Lisp_Object __gtk_font_list_internal (const char *pattern) -{ - char **names; - int count = 0; - Lisp_Object result = Qnil; - - names = XListFonts (GDK_DISPLAY (), pattern, MAX_FONT_COUNT, &count); - while (count--) - result = Fcons (build_extstring (names [count], Qbinary), result); - if (names) - XFreeFontNames (names); - - return result; -}
--- a/src/objects-gtk.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* Gtk-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ -/* Gtk version by William Perry */ - -#ifndef _XEMACS_OBJECTS_GTK_H_ -#define _XEMACS_OBJECTS_GTK_H_ - -#include "objects.h" - -#ifdef HAVE_GTK - -/***************************************************************************** - Color-Instance - ****************************************************************************/ - -int allocate_nearest_color (GdkColormap *screen_colormap, GdkVisual *visual, - GdkColor *color_def); -int gtk_parse_nearest_color (struct device *d, GdkColor *color, Ibyte *name, - Bytecount len, Error_Behavior errb); - -/***************************************************************************** - Font-Instance - ****************************************************************************/ - -#endif /* HAVE_GTK */ -#endif /* _XEMACS_OBJECTS_GTK_H_ */
--- a/src/objects-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/* Generic object functions -- header implementation. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - Copyright (C) 2010 Didier Verna - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#ifndef INCLUDED_objects_impl_h_ -#define INCLUDED_objects_impl_h_ - -#include "specifier.h" -#include "objects.h" - -/***************************************************************************** - * Color Specifier Object * - *****************************************************************************/ - -struct color_specifier -{ - Lisp_Object face; /* face this is attached to, or nil */ - Lisp_Object face_property; /* property of that face */ -}; - -#define COLOR_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, color) -#define COLOR_SPECIFIER_FACE(g) (COLOR_SPECIFIER_DATA (g)->face) -#define COLOR_SPECIFIER_FACE_PROPERTY(g) \ - (COLOR_SPECIFIER_DATA (g)->face_property) - -DECLARE_SPECIFIER_TYPE (color); -#define XCOLOR_SPECIFIER(x) XSPECIFIER_TYPE (x, color) -#define COLOR_SPECIFIERP(x) SPECIFIER_TYPEP (x, color) -#define CHECK_COLOR_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, color) -#define CONCHECK_COLOR_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, color) - -/***************************************************************************** - * Font Specifier Object * - *****************************************************************************/ - -struct font_specifier -{ - Lisp_Object face; /* face this is attached to, or nil */ - Lisp_Object face_property; /* property of that face */ -}; - -#define FONT_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, font) -#define FONT_SPECIFIER_FACE(g) (FONT_SPECIFIER_DATA (g)->face) -#define FONT_SPECIFIER_FACE_PROPERTY(g) \ - (FONT_SPECIFIER_DATA (g)->face_property) - -DECLARE_SPECIFIER_TYPE (font); -#define XFONT_SPECIFIER(x) XSPECIFIER_TYPE (x, font) -#define FONT_SPECIFIERP(x) SPECIFIER_TYPEP (x, font) -#define CHECK_FONT_SPECIFIER(x) CHECK_SPECIFIER_TYPE (x, font) -#define CONCHECK_FONT_SPECIFIER(x) CONCHECK_SPECIFIER_TYPE (x, font) - -/***************************************************************************** - * Face Boolean Specifier Object * - *****************************************************************************/ - -struct face_boolean_specifier -{ - Lisp_Object face; /* face this is attached to, or nil */ - Lisp_Object face_property; /* property of that face */ -}; - -#define FACE_BOOLEAN_SPECIFIER_DATA(g) SPECIFIER_TYPE_DATA (g, face_boolean) -#define FACE_BOOLEAN_SPECIFIER_FACE(g) (FACE_BOOLEAN_SPECIFIER_DATA (g)->face) -#define FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY(g) \ - (FACE_BOOLEAN_SPECIFIER_DATA (g)->face_property) - -DECLARE_SPECIFIER_TYPE (face_boolean); -extern Lisp_Object Qface_boolean; -#define XFACE_BOOLEAN_SPECIFIER(x) XSPECIFIER_TYPE (x, face_boolean) -#define FACE_BOOLEAN_SPECIFIERP(x) SPECIFIER_TYPEP (x, face_boolean) -#define CHECK_FACE_BOOLEAN_SPECIFIER(x) \ - CHECK_SPECIFIER_TYPE (x, face_boolean) -#define CONCHECK_FACE_BOOLEAN_SPECIFIER(x) \ - CONCHECK_SPECIFIER_TYPE (x, face_boolean) - -/***************************************************************************** - * Background Placement Specifier Object * - *****************************************************************************/ - -struct face_background_placement_specifier -{ - Lisp_Object face; /* face this is attached to, or nil */ -}; - -#define FACE_BACKGROUND_PLACEMENT_SPECIFIER_DATA(g) \ - SPECIFIER_TYPE_DATA (g, face_background_placement) -#define FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE(g) \ - (FACE_BACKGROUND_PLACEMENT_SPECIFIER_DATA (g)->face) - -DECLARE_SPECIFIER_TYPE (face_background_placement); -extern Lisp_Object Qface_background_placement, Qabsolute, Qrelative; -#define XFACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ - XSPECIFIER_TYPE (x, face_background_placement) -#define FACE_BACKGROUND_PLACEMENT_SPECIFIERP(x) \ - SPECIFIER_TYPEP (x, face_background_placement) -#define CHECK_FACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ - CHECK_SPECIFIER_TYPE (x, face_background_placement) -#define CONCHECK_FACE_BACKGROUND_PLACEMENT_SPECIFIER(x) \ - CONCHECK_SPECIFIER_TYPE (x, face_background_placement) - -/**************************************************************************** - * Color Instance Object * - ****************************************************************************/ - -struct Lisp_Color_Instance -{ - NORMAL_LISP_OBJECT_HEADER header; - Lisp_Object name; - Lisp_Object device; - - /* See comment in struct console about console variants. */ - enum console_variant color_instance_type; - - /* console-type-specific data */ - void *data; -}; - -#define COLOR_INSTANCE_NAME(c) ((c)->name) -#define COLOR_INSTANCE_DEVICE(c) ((c)->device) - -/**************************************************************************** - * Font Instance Object * - ****************************************************************************/ - -struct Lisp_Font_Instance -{ - NORMAL_LISP_OBJECT_HEADER header; - Lisp_Object name; /* the instantiator used to create the font instance */ - Lisp_Object truename; /* used by the device-specific methods; we need to - call them to get the truename (#### in reality, - they all probably just store the truename here - if they know it, and nil otherwise; we should - check this and enforce it as a general policy - X and GTK do this, except that when they don't - know they return NAME and don't update TRUENAME. - MS Windows initializes TRUENAME when the font is - initialized. TTY doesn't do truename.) */ - Lisp_Object device; - Lisp_Object charset; /* Mule charset, or whatever */ - - /* See comment in struct console about console variants. */ - enum console_variant font_instance_type; - - unsigned short ascent; /* extracted from `font', or made up */ - unsigned short descent; - unsigned short width; - unsigned short height; - int proportional_p; - - /* console-type-specific data */ - void *data; -}; - -#define FONT_INSTANCE_NAME(f) ((f)->name) -#define FONT_INSTANCE_TRUENAME(f) ((f)->truename) -#define FONT_INSTANCE_CHARSET(f) ((f)->charset) -#define FONT_INSTANCE_DEVICE(f) ((f)->device) -#define FONT_INSTANCE_ASCENT(f) ((f)->ascent) -#define FONT_INSTANCE_DESCENT(f) ((f)->descent) -#define FONT_INSTANCE_WIDTH(f) ((f)->width) -#define FONT_INSTANCE_HEIGHT(f) ((f)->height) - -#define XFONT_INSTANCE_NAME(f) FONT_INSTANCE_NAME (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_TRUENAME(f) FONT_INSTANCE_TRUENAME (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_CHARSET(f) FONT_INSTANCE_CHARSET (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_DEVICE(f) FONT_INSTANCE_DEVICE (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_ASCENT(f) FONT_INSTANCE_ASCENT (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_DESCENT(f) FONT_INSTANCE_DESCENT (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_WIDTH(f) FONT_INSTANCE_WIDTH (XFONT_INSTANCE (f)) -#define XFONT_INSTANCE_HEIGHT(f) FONT_INSTANCE_HEIGHT (XFONT_INSTANCE (f)) - -#endif /* INCLUDED_objects_impl_h_ */
--- a/src/objects-msw-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* mswindows-specific Lisp objects -- header implementation. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - Copyright (C) 1997, Jonathan Harris. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Authorship: - - Ultimately based on FSF. - Rewritten by Ben Wing. - Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0. - */ - - -#ifndef INCLUDED_objects_msw_impl_h_ -#define INCLUDED_objects_msw_impl_h_ - -#include "objects-impl.h" -#include "objects-msw.h" - -struct mswindows_color_instance_data -{ - COLORREF color; -}; - -#define MSWINDOWS_COLOR_INSTANCE_DATA(c) \ - ((struct mswindows_color_instance_data *) (c)->data) -#define COLOR_INSTANCE_MSWINDOWS_COLOR(c) \ - (MSWINDOWS_COLOR_INSTANCE_DATA (c)->color) - -/* The four HFONTS are for the 4 (underlined, strikethrough) - combinations. Only the one at index 0, neither underlined nor - struk through is created with the font instance. Other fonts are - created as necessary during redisplay, using the one at index 0 - as prototype */ -#define MSWINDOWS_NUM_FONT_VARIANTS 4 -struct mswindows_font_instance_data -{ - HFONT hfont [MSWINDOWS_NUM_FONT_VARIANTS]; -}; - -#define MSWINDOWS_FONT_INSTANCE_DATA(c) \ - ((struct mswindows_font_instance_data *) (c)->data) - -#define FONT_INSTANCE_MSWINDOWS_HFONT_I(c,i) \ - (MSWINDOWS_FONT_INSTANCE_DATA(c)->hfont[(i)]) - -#define FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT(c,under,strike) \ - FONT_INSTANCE_MSWINDOWS_HFONT_I (c, (!!(strike)<<1)|!!(under)) - -/* If font creation during redisplay fails, then the following - value is used to prevent future attempts to create this font. - Redisplay uses the "main" font when encounters this value */ -#define MSWINDOWS_BAD_HFONT ((HFONT)INVALID_HANDLE_VALUE) - -#endif /* INCLUDED_objects_msw_impl_h_ */
--- a/src/objects-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2341 +0,0 @@ -/* mswindows-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995 Tinker Systems. - Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2005, 2010 Ben Wing. - Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 1997 Jonathan Harris. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Authorship: - - This file created by Jonathan Harris, November 1997 for 21.0; based - heavily on objects-x.c (see authorship there). Much further work - by Ben Wing. - */ - -/* This function Mule-ized by Ben Wing, 3-24-02. */ - -/* TODO: palette handling */ - -#include <config.h> -#include "lisp.h" - -#include "console-msw-impl.h" -#include "objects-msw-impl.h" - -#include "buffer.h" -#include "charset.h" -#include "device-impl.h" -#include "elhash.h" -#include "insdel.h" -#include "opaque.h" - -typedef struct colormap_t -{ - const Ascbyte *name; - COLORREF colorref; -} colormap_t; - -/* Colors from X11R6 "XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp" */ -/* MSWindows tends to round up the numbers in its palette, ie where X uses - * 127, MSWindows uses 128. Colors commented as "Adjusted" are tweaked to - * match the Windows standard palette to increase the likelihood of - * mswindows_color_to_string() finding a named match. - */ -static const colormap_t mswindows_X_color_map[] = -{ - {"white" , PALETTERGB (255, 255, 255) }, - {"black" , PALETTERGB (0, 0, 0) }, - {"snow" , PALETTERGB (255, 250, 250) }, - {"GhostWhite" , PALETTERGB (248, 248, 255) }, - {"WhiteSmoke" , PALETTERGB (245, 245, 245) }, - {"gainsboro" , PALETTERGB (220, 220, 220) }, - {"FloralWhite" , PALETTERGB (255, 250, 240) }, - {"OldLace" , PALETTERGB (253, 245, 230) }, - {"linen" , PALETTERGB (250, 240, 230) }, - {"AntiqueWhite" , PALETTERGB (250, 235, 215) }, - {"PapayaWhip" , PALETTERGB (255, 239, 213) }, - {"BlanchedAlmond" , PALETTERGB (255, 235, 205) }, - {"bisque" , PALETTERGB (255, 228, 196) }, - {"PeachPuff" , PALETTERGB (255, 218, 185) }, - {"NavajoWhite" , PALETTERGB (255, 222, 173) }, - {"moccasin" , PALETTERGB (255, 228, 181) }, - {"cornsilk" , PALETTERGB (255, 248, 220) }, - {"ivory" , PALETTERGB (255, 255, 240) }, - {"LemonChiffon" , PALETTERGB (255, 250, 205) }, - {"seashell" , PALETTERGB (255, 245, 238) }, - {"honeydew" , PALETTERGB (240, 255, 240) }, - {"MintCream" , PALETTERGB (245, 255, 250) }, - {"azure" , PALETTERGB (240, 255, 255) }, - {"AliceBlue" , PALETTERGB (240, 248, 255) }, - {"lavender" , PALETTERGB (230, 230, 250) }, - {"LavenderBlush" , PALETTERGB (255, 240, 245) }, - {"MistyRose" , PALETTERGB (255, 228, 225) }, - {"DarkSlateGray" , PALETTERGB (47, 79, 79) }, - {"DarkSlateGrey" , PALETTERGB (47, 79, 79) }, - {"DimGray" , PALETTERGB (105, 105, 105) }, - {"DimGrey" , PALETTERGB (105, 105, 105) }, - {"SlateGray" , PALETTERGB (112, 128, 144) }, - {"SlateGrey" , PALETTERGB (112, 128, 144) }, - {"LightSlateGray" , PALETTERGB (119, 136, 153) }, - {"LightSlateGrey" , PALETTERGB (119, 136, 153) }, - {"gray" , PALETTERGB (190, 190, 190) }, - {"grey" , PALETTERGB (190, 190, 190) }, - {"LightGrey" , PALETTERGB (211, 211, 211) }, - {"LightGray" , PALETTERGB (211, 211, 211) }, - {"MidnightBlue" , PALETTERGB (25, 25, 112) }, - {"navy" , PALETTERGB (0, 0, 128) }, - {"NavyBlue" , PALETTERGB (0, 0, 128) }, - {"CornflowerBlue" , PALETTERGB (100, 149, 237) }, - {"DarkSlateBlue" , PALETTERGB (72, 61, 139) }, - {"SlateBlue" , PALETTERGB (106, 90, 205) }, - {"MediumSlateBlue" , PALETTERGB (123, 104, 238) }, - {"LightSlateBlue" , PALETTERGB (132, 112, 255) }, - {"MediumBlue" , PALETTERGB (0, 0, 205) }, - {"RoyalBlue" , PALETTERGB (65, 105, 225) }, - {"blue" , PALETTERGB (0, 0, 255) }, - {"DodgerBlue" , PALETTERGB (30, 144, 255) }, - {"DeepSkyBlue" , PALETTERGB (0, 191, 255) }, - {"SkyBlue" , PALETTERGB (135, 206, 235) }, - {"LightSkyBlue" , PALETTERGB (135, 206, 250) }, - {"SteelBlue" , PALETTERGB (70, 130, 180) }, - {"LightSteelBlue" , PALETTERGB (176, 196, 222) }, - {"LightBlue" , PALETTERGB (173, 216, 230) }, - {"PowderBlue" , PALETTERGB (176, 224, 230) }, - {"PaleTurquoise" , PALETTERGB (175, 238, 238) }, - {"DarkTurquoise" , PALETTERGB (0, 206, 209) }, - {"MediumTurquoise" , PALETTERGB (72, 209, 204) }, - {"turquoise" , PALETTERGB (64, 224, 208) }, - {"cyan" , PALETTERGB (0, 255, 255) }, - {"LightCyan" , PALETTERGB (224, 255, 255) }, - {"CadetBlue" , PALETTERGB (95, 158, 160) }, - {"MediumAquamarine" , PALETTERGB (102, 205, 170) }, - {"aquamarine" , PALETTERGB (127, 255, 212) }, - {"DarkGreen" , PALETTERGB (0, 128, 0) }, /* Adjusted */ - {"DarkOliveGreen" , PALETTERGB (85, 107, 47) }, - {"DarkSeaGreen" , PALETTERGB (143, 188, 143) }, - {"SeaGreen" , PALETTERGB (46, 139, 87) }, - {"MediumSeaGreen" , PALETTERGB (60, 179, 113) }, - {"LightSeaGreen" , PALETTERGB (32, 178, 170) }, - {"PaleGreen" , PALETTERGB (152, 251, 152) }, - {"SpringGreen" , PALETTERGB (0, 255, 127) }, - {"LawnGreen" , PALETTERGB (124, 252, 0) }, - {"green" , PALETTERGB (0, 255, 0) }, - {"chartreuse" , PALETTERGB (127, 255, 0) }, - {"MediumSpringGreen" , PALETTERGB (0, 250, 154) }, - {"GreenYellow" , PALETTERGB (173, 255, 47) }, - {"LimeGreen" , PALETTERGB (50, 205, 50) }, - {"YellowGreen" , PALETTERGB (154, 205, 50) }, - {"ForestGreen" , PALETTERGB (34, 139, 34) }, - {"OliveDrab" , PALETTERGB (107, 142, 35) }, - {"DarkKhaki" , PALETTERGB (189, 183, 107) }, - {"khaki" , PALETTERGB (240, 230, 140) }, - {"PaleGoldenrod" , PALETTERGB (238, 232, 170) }, - {"LightGoldenrodYellow", PALETTERGB (250, 250, 210) }, - {"LightYellow" , PALETTERGB (255, 255, 224) }, - {"LightYellow" , PALETTERGB (255, 255, 225) }, /* Adjusted */ - {"yellow" , PALETTERGB (255, 255, 0) }, - {"gold" , PALETTERGB (255, 215, 0) }, - {"LightGoldenrod" , PALETTERGB (238, 221, 130) }, - {"goldenrod" , PALETTERGB (218, 165, 32) }, - {"DarkGoldenrod" , PALETTERGB (184, 134, 11) }, - {"RosyBrown" , PALETTERGB (188, 143, 143) }, - {"IndianRed" , PALETTERGB (205, 92, 92) }, - {"SaddleBrown" , PALETTERGB (139, 69, 19) }, - {"sienna" , PALETTERGB (160, 82, 45) }, - {"peru" , PALETTERGB (205, 133, 63) }, - {"burlywood" , PALETTERGB (222, 184, 135) }, - {"beige" , PALETTERGB (245, 245, 220) }, - {"wheat" , PALETTERGB (245, 222, 179) }, - {"SandyBrown" , PALETTERGB (244, 164, 96) }, - {"tan" , PALETTERGB (210, 180, 140) }, - {"chocolate" , PALETTERGB (210, 105, 30) }, - {"firebrick" , PALETTERGB (178, 34, 34) }, - {"brown" , PALETTERGB (165, 42, 42) }, - {"DarkSalmon" , PALETTERGB (233, 150, 122) }, - {"salmon" , PALETTERGB (250, 128, 114) }, - {"LightSalmon" , PALETTERGB (255, 160, 122) }, - {"orange" , PALETTERGB (255, 165, 0) }, - {"DarkOrange" , PALETTERGB (255, 140, 0) }, - {"coral" , PALETTERGB (255, 127, 80) }, - {"LightCoral" , PALETTERGB (240, 128, 128) }, - {"tomato" , PALETTERGB (255, 99, 71) }, - {"OrangeRed" , PALETTERGB (255, 69, 0) }, - {"red" , PALETTERGB (255, 0, 0) }, - {"HotPink" , PALETTERGB (255, 105, 180) }, - {"DeepPink" , PALETTERGB (255, 20, 147) }, - {"pink" , PALETTERGB (255, 192, 203) }, - {"LightPink" , PALETTERGB (255, 182, 193) }, - {"PaleVioletRed" , PALETTERGB (219, 112, 147) }, - {"maroon" , PALETTERGB (176, 48, 96) }, - {"MediumVioletRed" , PALETTERGB (199, 21, 133) }, - {"VioletRed" , PALETTERGB (208, 32, 144) }, - {"magenta" , PALETTERGB (255, 0, 255) }, - {"violet" , PALETTERGB (238, 130, 238) }, - {"plum" , PALETTERGB (221, 160, 221) }, - {"orchid" , PALETTERGB (218, 112, 214) }, - {"MediumOrchid" , PALETTERGB (186, 85, 211) }, - {"DarkOrchid" , PALETTERGB (153, 50, 204) }, - {"DarkViolet" , PALETTERGB (148, 0, 211) }, - {"BlueViolet" , PALETTERGB (138, 43, 226) }, - {"purple" , PALETTERGB (160, 32, 240) }, - {"MediumPurple" , PALETTERGB (147, 112, 219) }, - {"thistle" , PALETTERGB (216, 191, 216) }, - {"snow1" , PALETTERGB (255, 250, 250) }, - {"snow2" , PALETTERGB (238, 233, 233) }, - {"snow3" , PALETTERGB (205, 201, 201) }, - {"snow4" , PALETTERGB (139, 137, 137) }, - {"seashell1" , PALETTERGB (255, 245, 238) }, - {"seashell2" , PALETTERGB (238, 229, 222) }, - {"seashell3" , PALETTERGB (205, 197, 191) }, - {"seashell4" , PALETTERGB (139, 134, 130) }, - {"AntiqueWhite1" , PALETTERGB (255, 239, 219) }, - {"AntiqueWhite2" , PALETTERGB (238, 223, 204) }, - {"AntiqueWhite3" , PALETTERGB (205, 192, 176) }, - {"AntiqueWhite4" , PALETTERGB (139, 131, 120) }, - {"bisque1" , PALETTERGB (255, 228, 196) }, - {"bisque2" , PALETTERGB (238, 213, 183) }, - {"bisque3" , PALETTERGB (205, 183, 158) }, - {"bisque4" , PALETTERGB (139, 125, 107) }, - {"PeachPuff1" , PALETTERGB (255, 218, 185) }, - {"PeachPuff2" , PALETTERGB (238, 203, 173) }, - {"PeachPuff3" , PALETTERGB (205, 175, 149) }, - {"PeachPuff4" , PALETTERGB (139, 119, 101) }, - {"NavajoWhite1" , PALETTERGB (255, 222, 173) }, - {"NavajoWhite2" , PALETTERGB (238, 207, 161) }, - {"NavajoWhite3" , PALETTERGB (205, 179, 139) }, - {"NavajoWhite4" , PALETTERGB (139, 121, 94) }, - {"LemonChiffon1" , PALETTERGB (255, 250, 205) }, - {"LemonChiffon2" , PALETTERGB (238, 233, 191) }, - {"LemonChiffon3" , PALETTERGB (205, 201, 165) }, - {"LemonChiffon4" , PALETTERGB (139, 137, 112) }, - {"cornsilk1" , PALETTERGB (255, 248, 220) }, - {"cornsilk2" , PALETTERGB (238, 232, 205) }, - {"cornsilk3" , PALETTERGB (205, 200, 177) }, - {"cornsilk4" , PALETTERGB (139, 136, 120) }, - {"ivory1" , PALETTERGB (255, 255, 240) }, - {"ivory2" , PALETTERGB (240, 240, 208) }, /* Adjusted */ - {"ivory3" , PALETTERGB (205, 205, 193) }, - {"ivory4" , PALETTERGB (139, 139, 131) }, - {"honeydew1" , PALETTERGB (240, 255, 240) }, - {"honeydew2" , PALETTERGB (224, 238, 224) }, - {"honeydew3" , PALETTERGB (193, 205, 193) }, - {"honeydew4" , PALETTERGB (131, 139, 131) }, - {"LavenderBlush1" , PALETTERGB (255, 240, 245) }, - {"LavenderBlush2" , PALETTERGB (238, 224, 229) }, - {"LavenderBlush3" , PALETTERGB (205, 193, 197) }, - {"LavenderBlush4" , PALETTERGB (139, 131, 134) }, - {"MistyRose1" , PALETTERGB (255, 228, 225) }, - {"MistyRose2" , PALETTERGB (238, 213, 210) }, - {"MistyRose3" , PALETTERGB (205, 183, 181) }, - {"MistyRose4" , PALETTERGB (139, 125, 123) }, - {"azure1" , PALETTERGB (240, 255, 255) }, - {"azure2" , PALETTERGB (224, 238, 238) }, - {"azure3" , PALETTERGB (193, 205, 205) }, - {"azure4" , PALETTERGB (131, 139, 139) }, - {"SlateBlue1" , PALETTERGB (131, 111, 255) }, - {"SlateBlue2" , PALETTERGB (122, 103, 238) }, - {"SlateBlue3" , PALETTERGB (105, 89, 205) }, - {"SlateBlue4" , PALETTERGB (71, 60, 139) }, - {"RoyalBlue1" , PALETTERGB (72, 118, 255) }, - {"RoyalBlue2" , PALETTERGB (67, 110, 238) }, - {"RoyalBlue3" , PALETTERGB (58, 95, 205) }, - {"RoyalBlue4" , PALETTERGB (39, 64, 139) }, - {"blue1" , PALETTERGB (0, 0, 255) }, - {"blue2" , PALETTERGB (0, 0, 238) }, - {"blue3" , PALETTERGB (0, 0, 205) }, - {"blue4" , PALETTERGB (0, 0, 139) }, - {"DodgerBlue1" , PALETTERGB (30, 144, 255) }, - {"DodgerBlue2" , PALETTERGB (28, 134, 238) }, - {"DodgerBlue3" , PALETTERGB (24, 116, 205) }, - {"DodgerBlue4" , PALETTERGB (16, 78, 139) }, - {"SteelBlue1" , PALETTERGB (99, 184, 255) }, - {"SteelBlue2" , PALETTERGB (92, 172, 238) }, - {"SteelBlue3" , PALETTERGB (79, 148, 205) }, - {"SteelBlue4" , PALETTERGB (54, 100, 139) }, - {"DeepSkyBlue1" , PALETTERGB (0, 191, 255) }, - {"DeepSkyBlue2" , PALETTERGB (0, 178, 238) }, - {"DeepSkyBlue3" , PALETTERGB (0, 154, 205) }, - {"DeepSkyBlue4" , PALETTERGB (0, 104, 139) }, - {"SkyBlue1" , PALETTERGB (135, 206, 255) }, - {"SkyBlue2" , PALETTERGB (126, 192, 238) }, - {"SkyBlue3" , PALETTERGB (108, 166, 205) }, - {"SkyBlue4" , PALETTERGB (74, 112, 139) }, - {"LightSkyBlue1" , PALETTERGB (176, 226, 255) }, - {"LightSkyBlue2" , PALETTERGB (164, 211, 238) }, - {"LightSkyBlue3" , PALETTERGB (141, 182, 205) }, - {"LightSkyBlue4" , PALETTERGB (96, 123, 139) }, - {"SlateGray1" , PALETTERGB (198, 226, 255) }, - {"SlateGray2" , PALETTERGB (185, 211, 238) }, - {"SlateGray3" , PALETTERGB (159, 182, 205) }, - {"SlateGray4" , PALETTERGB (108, 123, 139) }, - {"LightSteelBlue1" , PALETTERGB (202, 225, 255) }, - {"LightSteelBlue2" , PALETTERGB (188, 210, 238) }, - {"LightSteelBlue3" , PALETTERGB (162, 181, 205) }, - {"LightSteelBlue4" , PALETTERGB (110, 123, 139) }, - {"LightBlue1" , PALETTERGB (191, 239, 255) }, - {"LightBlue2" , PALETTERGB (178, 223, 238) }, - {"LightBlue3" , PALETTERGB (154, 192, 205) }, - {"LightBlue4" , PALETTERGB (104, 131, 139) }, - {"LightCyan1" , PALETTERGB (224, 255, 255) }, - {"LightCyan2" , PALETTERGB (209, 238, 238) }, - {"LightCyan3" , PALETTERGB (180, 205, 205) }, - {"LightCyan4" , PALETTERGB (122, 139, 139) }, - {"PaleTurquoise1" , PALETTERGB (187, 255, 255) }, - {"PaleTurquoise2" , PALETTERGB (174, 238, 238) }, - {"PaleTurquoise3" , PALETTERGB (150, 205, 205) }, - {"PaleTurquoise4" , PALETTERGB (102, 139, 139) }, - {"CadetBlue1" , PALETTERGB (152, 245, 255) }, - {"CadetBlue2" , PALETTERGB (144, 220, 240) }, /* Adjusted */ - {"CadetBlue3" , PALETTERGB (122, 197, 205) }, - {"CadetBlue4" , PALETTERGB (83, 134, 139) }, - {"turquoise1" , PALETTERGB (0, 245, 255) }, - {"turquoise2" , PALETTERGB (0, 229, 238) }, - {"turquoise3" , PALETTERGB (0, 197, 205) }, - {"turquoise4" , PALETTERGB (0, 134, 139) }, - {"cyan1" , PALETTERGB (0, 255, 255) }, - {"cyan2" , PALETTERGB (0, 238, 238) }, - {"cyan3" , PALETTERGB (0, 205, 205) }, - {"cyan4" , PALETTERGB (0, 139, 139) }, - {"DarkSlateGray1" , PALETTERGB (151, 255, 255) }, - {"DarkSlateGray2" , PALETTERGB (141, 238, 238) }, - {"DarkSlateGray3" , PALETTERGB (121, 205, 205) }, - {"DarkSlateGray4" , PALETTERGB (82, 139, 139) }, - {"aquamarine1" , PALETTERGB (127, 255, 212) }, - {"aquamarine2" , PALETTERGB (118, 238, 198) }, - {"aquamarine3" , PALETTERGB (102, 205, 170) }, - {"aquamarine4" , PALETTERGB (69, 139, 116) }, - {"DarkSeaGreen1" , PALETTERGB (193, 255, 193) }, - {"DarkSeaGreen2" , PALETTERGB (180, 238, 180) }, - {"DarkSeaGreen3" , PALETTERGB (155, 205, 155) }, - {"DarkSeaGreen4" , PALETTERGB (105, 139, 105) }, - {"SeaGreen1" , PALETTERGB (84, 255, 159) }, - {"SeaGreen2" , PALETTERGB (78, 238, 148) }, - {"SeaGreen3" , PALETTERGB (67, 205, 128) }, - {"SeaGreen4" , PALETTERGB (46, 139, 87) }, - {"PaleGreen1" , PALETTERGB (154, 255, 154) }, - {"PaleGreen2" , PALETTERGB (144, 238, 144) }, - {"PaleGreen3" , PALETTERGB (124, 205, 124) }, - {"PaleGreen4" , PALETTERGB (84, 139, 84) }, - {"SpringGreen1" , PALETTERGB (0, 255, 127) }, - {"SpringGreen2" , PALETTERGB (0, 238, 118) }, - {"SpringGreen3" , PALETTERGB (0, 205, 102) }, - {"SpringGreen4" , PALETTERGB (0, 139, 69) }, - {"green1" , PALETTERGB (0, 255, 0) }, - {"green2" , PALETTERGB (0, 238, 0) }, - {"green3" , PALETTERGB (0, 205, 0) }, - {"green4" , PALETTERGB (0, 139, 0) }, - {"chartreuse1" , PALETTERGB (127, 255, 0) }, - {"chartreuse2" , PALETTERGB (118, 238, 0) }, - {"chartreuse3" , PALETTERGB (102, 205, 0) }, - {"chartreuse4" , PALETTERGB (69, 139, 0) }, - {"OliveDrab1" , PALETTERGB (192, 255, 62) }, - {"OliveDrab2" , PALETTERGB (179, 238, 58) }, - {"OliveDrab3" , PALETTERGB (154, 205, 50) }, - {"OliveDrab4" , PALETTERGB (105, 139, 34) }, - {"DarkOliveGreen1" , PALETTERGB (202, 255, 112) }, - {"DarkOliveGreen2" , PALETTERGB (188, 238, 104) }, - {"DarkOliveGreen3" , PALETTERGB (162, 205, 90) }, - {"DarkOliveGreen4" , PALETTERGB (110, 139, 61) }, - {"khaki1" , PALETTERGB (255, 246, 143) }, - {"khaki2" , PALETTERGB (238, 230, 133) }, - {"khaki3" , PALETTERGB (205, 198, 115) }, - {"khaki4" , PALETTERGB (139, 134, 78) }, - {"LightGoldenrod1" , PALETTERGB (255, 236, 139) }, - {"LightGoldenrod2" , PALETTERGB (238, 220, 130) }, - {"LightGoldenrod3" , PALETTERGB (205, 190, 112) }, - {"LightGoldenrod4" , PALETTERGB (139, 129, 76) }, - {"LightYellow1" , PALETTERGB (255, 255, 224) }, - {"LightYellow2" , PALETTERGB (238, 238, 209) }, - {"LightYellow3" , PALETTERGB (205, 205, 180) }, - {"LightYellow4" , PALETTERGB (139, 139, 122) }, - {"yellow1" , PALETTERGB (255, 255, 0) }, - {"yellow2" , PALETTERGB (238, 238, 0) }, - {"yellow3" , PALETTERGB (205, 205, 0) }, - {"yellow4" , PALETTERGB (139, 139, 0) }, - {"gold1" , PALETTERGB (255, 215, 0) }, - {"gold2" , PALETTERGB (238, 201, 0) }, - {"gold3" , PALETTERGB (205, 173, 0) }, - {"gold4" , PALETTERGB (139, 117, 0) }, - {"goldenrod1" , PALETTERGB (255, 193, 37) }, - {"goldenrod2" , PALETTERGB (238, 180, 34) }, - {"goldenrod3" , PALETTERGB (205, 155, 29) }, - {"goldenrod4" , PALETTERGB (139, 105, 20) }, - {"DarkGoldenrod1" , PALETTERGB (255, 185, 15) }, - {"DarkGoldenrod2" , PALETTERGB (238, 173, 14) }, - {"DarkGoldenrod3" , PALETTERGB (205, 149, 12) }, - {"DarkGoldenrod4" , PALETTERGB (139, 101, 8) }, - {"RosyBrown1" , PALETTERGB (255, 193, 193) }, - {"RosyBrown2" , PALETTERGB (238, 180, 180) }, - {"RosyBrown3" , PALETTERGB (205, 155, 155) }, - {"RosyBrown4" , PALETTERGB (139, 105, 105) }, - {"IndianRed1" , PALETTERGB (255, 106, 106) }, - {"IndianRed2" , PALETTERGB (238, 99, 99) }, - {"IndianRed3" , PALETTERGB (205, 85, 85) }, - {"IndianRed4" , PALETTERGB (139, 58, 58) }, - {"sienna1" , PALETTERGB (255, 130, 71) }, - {"sienna2" , PALETTERGB (238, 121, 66) }, - {"sienna3" , PALETTERGB (205, 104, 57) }, - {"sienna4" , PALETTERGB (139, 71, 38) }, - {"burlywood1" , PALETTERGB (255, 211, 155) }, - {"burlywood2" , PALETTERGB (238, 197, 145) }, - {"burlywood3" , PALETTERGB (205, 170, 125) }, - {"burlywood4" , PALETTERGB (139, 115, 85) }, - {"wheat1" , PALETTERGB (255, 231, 186) }, - {"wheat2" , PALETTERGB (238, 216, 174) }, - {"wheat3" , PALETTERGB (205, 186, 150) }, - {"wheat4" , PALETTERGB (139, 126, 102) }, - {"tan1" , PALETTERGB (255, 165, 79) }, - {"tan2" , PALETTERGB (238, 154, 73) }, - {"tan3" , PALETTERGB (205, 133, 63) }, - {"tan4" , PALETTERGB (139, 90, 43) }, - {"chocolate1" , PALETTERGB (255, 127, 36) }, - {"chocolate2" , PALETTERGB (238, 118, 33) }, - {"chocolate3" , PALETTERGB (205, 102, 29) }, - {"chocolate4" , PALETTERGB (139, 69, 19) }, - {"firebrick1" , PALETTERGB (255, 48, 48) }, - {"firebrick2" , PALETTERGB (238, 44, 44) }, - {"firebrick3" , PALETTERGB (205, 38, 38) }, - {"firebrick4" , PALETTERGB (139, 26, 26) }, - {"brown1" , PALETTERGB (255, 64, 64) }, - {"brown2" , PALETTERGB (238, 59, 59) }, - {"brown3" , PALETTERGB (205, 51, 51) }, - {"brown4" , PALETTERGB (139, 35, 35) }, - {"salmon1" , PALETTERGB (255, 140, 105) }, - {"salmon2" , PALETTERGB (238, 130, 98) }, - {"salmon3" , PALETTERGB (205, 112, 84) }, - {"salmon4" , PALETTERGB (139, 76, 57) }, - {"LightSalmon1" , PALETTERGB (255, 160, 122) }, - {"LightSalmon2" , PALETTERGB (238, 149, 114) }, - {"LightSalmon3" , PALETTERGB (205, 129, 98) }, - {"LightSalmon4" , PALETTERGB (139, 87, 66) }, - {"orange1" , PALETTERGB (255, 165, 0) }, - {"orange2" , PALETTERGB (238, 154, 0) }, - {"orange3" , PALETTERGB (205, 133, 0) }, - {"orange4" , PALETTERGB (139, 90, 0) }, - {"DarkOrange1" , PALETTERGB (255, 127, 0) }, - {"DarkOrange2" , PALETTERGB (238, 118, 0) }, - {"DarkOrange3" , PALETTERGB (205, 102, 0) }, - {"DarkOrange4" , PALETTERGB (139, 69, 0) }, - {"coral1" , PALETTERGB (255, 114, 86) }, - {"coral2" , PALETTERGB (238, 106, 80) }, - {"coral3" , PALETTERGB (205, 91, 69) }, - {"coral4" , PALETTERGB (139, 62, 47) }, - {"tomato1" , PALETTERGB (255, 99, 71) }, - {"tomato2" , PALETTERGB (238, 92, 66) }, - {"tomato3" , PALETTERGB (205, 79, 57) }, - {"tomato4" , PALETTERGB (139, 54, 38) }, - {"OrangeRed1" , PALETTERGB (255, 69, 0) }, - {"OrangeRed2" , PALETTERGB (238, 64, 0) }, - {"OrangeRed3" , PALETTERGB (205, 55, 0) }, - {"OrangeRed4" , PALETTERGB (139, 37, 0) }, - {"red1" , PALETTERGB (255, 0, 0) }, - {"red2" , PALETTERGB (238, 0, 0) }, - {"red3" , PALETTERGB (205, 0, 0) }, - {"red4" , PALETTERGB (139, 0, 0) }, - {"DeepPink1" , PALETTERGB (255, 20, 147) }, - {"DeepPink2" , PALETTERGB (238, 18, 137) }, - {"DeepPink3" , PALETTERGB (205, 16, 118) }, - {"DeepPink4" , PALETTERGB (139, 10, 80) }, - {"HotPink1" , PALETTERGB (255, 110, 180) }, - {"HotPink2" , PALETTERGB (238, 106, 167) }, - {"HotPink3" , PALETTERGB (205, 96, 144) }, - {"HotPink4" , PALETTERGB (139, 58, 98) }, - {"pink1" , PALETTERGB (255, 181, 197) }, - {"pink2" , PALETTERGB (238, 169, 184) }, - {"pink3" , PALETTERGB (205, 145, 158) }, - {"pink4" , PALETTERGB (139, 99, 108) }, - {"LightPink1" , PALETTERGB (255, 174, 185) }, - {"LightPink2" , PALETTERGB (238, 162, 173) }, - {"LightPink3" , PALETTERGB (205, 140, 149) }, - {"LightPink4" , PALETTERGB (139, 95, 101) }, - {"PaleVioletRed1" , PALETTERGB (255, 130, 171) }, - {"PaleVioletRed2" , PALETTERGB (238, 121, 159) }, - {"PaleVioletRed3" , PALETTERGB (205, 104, 137) }, - {"PaleVioletRed4" , PALETTERGB (139, 71, 93) }, - {"maroon1" , PALETTERGB (255, 52, 179) }, - {"maroon2" , PALETTERGB (238, 48, 167) }, - {"maroon3" , PALETTERGB (205, 41, 144) }, - {"maroon4" , PALETTERGB (139, 28, 98) }, - {"VioletRed1" , PALETTERGB (255, 62, 150) }, - {"VioletRed2" , PALETTERGB (238, 58, 140) }, - {"VioletRed3" , PALETTERGB (205, 50, 120) }, - {"VioletRed4" , PALETTERGB (139, 34, 82) }, - {"magenta1" , PALETTERGB (255, 0, 255) }, - {"magenta2" , PALETTERGB (238, 0, 238) }, - {"magenta3" , PALETTERGB (205, 0, 205) }, - {"magenta4" , PALETTERGB (139, 0, 139) }, - {"orchid1" , PALETTERGB (255, 131, 250) }, - {"orchid2" , PALETTERGB (238, 122, 233) }, - {"orchid3" , PALETTERGB (205, 105, 201) }, - {"orchid4" , PALETTERGB (139, 71, 137) }, - {"plum1" , PALETTERGB (255, 187, 255) }, - {"plum2" , PALETTERGB (238, 174, 238) }, - {"plum3" , PALETTERGB (205, 150, 205) }, - {"plum4" , PALETTERGB (139, 102, 139) }, - {"MediumOrchid1" , PALETTERGB (224, 102, 255) }, - {"MediumOrchid2" , PALETTERGB (209, 95, 238) }, - {"MediumOrchid3" , PALETTERGB (180, 82, 205) }, - {"MediumOrchid4" , PALETTERGB (122, 55, 139) }, - {"DarkOrchid1" , PALETTERGB (191, 62, 255) }, - {"DarkOrchid2" , PALETTERGB (178, 58, 238) }, - {"DarkOrchid3" , PALETTERGB (154, 50, 205) }, - {"DarkOrchid4" , PALETTERGB (104, 34, 139) }, - {"purple1" , PALETTERGB (155, 48, 255) }, - {"purple2" , PALETTERGB (145, 44, 238) }, - {"purple3" , PALETTERGB (125, 38, 205) }, - {"purple4" , PALETTERGB (85, 26, 139) }, - {"MediumPurple1" , PALETTERGB (171, 130, 255) }, - {"MediumPurple2" , PALETTERGB (159, 121, 238) }, - {"MediumPurple3" , PALETTERGB (137, 104, 205) }, - {"MediumPurple4" , PALETTERGB (93, 71, 139) }, - {"thistle1" , PALETTERGB (255, 225, 255) }, - {"thistle2" , PALETTERGB (238, 210, 238) }, - {"thistle3" , PALETTERGB (205, 181, 205) }, - {"thistle4" , PALETTERGB (139, 123, 139) }, - {"gray0" , PALETTERGB (0, 0, 0) }, - {"grey0" , PALETTERGB (0, 0, 0) }, - {"gray1" , PALETTERGB (3, 3, 3) }, - {"grey1" , PALETTERGB (3, 3, 3) }, - {"gray2" , PALETTERGB (5, 5, 5) }, - {"grey2" , PALETTERGB (5, 5, 5) }, - {"gray3" , PALETTERGB (8, 8, 8) }, - {"grey3" , PALETTERGB (8, 8, 8) }, - {"gray4" , PALETTERGB (10, 10, 10) }, - {"grey4" , PALETTERGB (10, 10, 10) }, - {"gray5" , PALETTERGB (13, 13, 13) }, - {"grey5" , PALETTERGB (13, 13, 13) }, - {"gray6" , PALETTERGB (15, 15, 15) }, - {"grey6" , PALETTERGB (15, 15, 15) }, - {"gray7" , PALETTERGB (18, 18, 18) }, - {"grey7" , PALETTERGB (18, 18, 18) }, - {"gray8" , PALETTERGB (20, 20, 20) }, - {"grey8" , PALETTERGB (20, 20, 20) }, - {"gray9" , PALETTERGB (23, 23, 23) }, - {"grey9" , PALETTERGB (23, 23, 23) }, - {"gray10" , PALETTERGB (26, 26, 26) }, - {"grey10" , PALETTERGB (26, 26, 26) }, - {"gray11" , PALETTERGB (28, 28, 28) }, - {"grey11" , PALETTERGB (28, 28, 28) }, - {"gray12" , PALETTERGB (31, 31, 31) }, - {"grey12" , PALETTERGB (31, 31, 31) }, - {"gray13" , PALETTERGB (33, 33, 33) }, - {"grey13" , PALETTERGB (33, 33, 33) }, - {"gray14" , PALETTERGB (36, 36, 36) }, - {"grey14" , PALETTERGB (36, 36, 36) }, - {"gray15" , PALETTERGB (38, 38, 38) }, - {"grey15" , PALETTERGB (38, 38, 38) }, - {"gray16" , PALETTERGB (41, 41, 41) }, - {"grey16" , PALETTERGB (41, 41, 41) }, - {"gray17" , PALETTERGB (43, 43, 43) }, - {"grey17" , PALETTERGB (43, 43, 43) }, - {"gray18" , PALETTERGB (46, 46, 46) }, - {"grey18" , PALETTERGB (46, 46, 46) }, - {"gray19" , PALETTERGB (48, 48, 48) }, - {"grey19" , PALETTERGB (48, 48, 48) }, - {"gray20" , PALETTERGB (51, 51, 51) }, - {"grey20" , PALETTERGB (51, 51, 51) }, - {"gray21" , PALETTERGB (54, 54, 54) }, - {"grey21" , PALETTERGB (54, 54, 54) }, - {"gray22" , PALETTERGB (56, 56, 56) }, - {"grey22" , PALETTERGB (56, 56, 56) }, - {"gray23" , PALETTERGB (59, 59, 59) }, - {"grey23" , PALETTERGB (59, 59, 59) }, - {"gray24" , PALETTERGB (61, 61, 61) }, - {"grey24" , PALETTERGB (61, 61, 61) }, - {"gray25" , PALETTERGB (64, 64, 64) }, - {"grey25" , PALETTERGB (64, 64, 64) }, - {"gray26" , PALETTERGB (66, 66, 66) }, - {"grey26" , PALETTERGB (66, 66, 66) }, - {"gray27" , PALETTERGB (69, 69, 69) }, - {"grey27" , PALETTERGB (69, 69, 69) }, - {"gray28" , PALETTERGB (71, 71, 71) }, - {"grey28" , PALETTERGB (71, 71, 71) }, - {"gray29" , PALETTERGB (74, 74, 74) }, - {"grey29" , PALETTERGB (74, 74, 74) }, - {"gray30" , PALETTERGB (77, 77, 77) }, - {"grey30" , PALETTERGB (77, 77, 77) }, - {"gray31" , PALETTERGB (79, 79, 79) }, - {"grey31" , PALETTERGB (79, 79, 79) }, - {"gray32" , PALETTERGB (82, 82, 82) }, - {"grey32" , PALETTERGB (82, 82, 82) }, - {"gray33" , PALETTERGB (84, 84, 84) }, - {"grey33" , PALETTERGB (84, 84, 84) }, - {"gray34" , PALETTERGB (87, 87, 87) }, - {"grey34" , PALETTERGB (87, 87, 87) }, - {"gray35" , PALETTERGB (89, 89, 89) }, - {"grey35" , PALETTERGB (89, 89, 89) }, - {"gray36" , PALETTERGB (92, 92, 92) }, - {"grey36" , PALETTERGB (92, 92, 92) }, - {"gray37" , PALETTERGB (94, 94, 94) }, - {"grey37" , PALETTERGB (94, 94, 94) }, - {"gray38" , PALETTERGB (97, 97, 97) }, - {"grey38" , PALETTERGB (97, 97, 97) }, - {"gray39" , PALETTERGB (99, 99, 99) }, - {"grey39" , PALETTERGB (99, 99, 99) }, - {"gray40" , PALETTERGB (102, 102, 102) }, - {"grey40" , PALETTERGB (102, 102, 102) }, - {"gray41" , PALETTERGB (105, 105, 105) }, - {"grey41" , PALETTERGB (105, 105, 105) }, - {"gray42" , PALETTERGB (107, 107, 107) }, - {"grey42" , PALETTERGB (107, 107, 107) }, - {"gray43" , PALETTERGB (110, 110, 110) }, - {"grey43" , PALETTERGB (110, 110, 110) }, - {"gray44" , PALETTERGB (112, 112, 112) }, - {"grey44" , PALETTERGB (112, 112, 112) }, - {"gray45" , PALETTERGB (115, 115, 115) }, - {"grey45" , PALETTERGB (115, 115, 115) }, - {"gray46" , PALETTERGB (117, 117, 117) }, - {"grey46" , PALETTERGB (117, 117, 117) }, - {"gray47" , PALETTERGB (120, 120, 120) }, - {"grey47" , PALETTERGB (120, 120, 120) }, - {"gray48" , PALETTERGB (122, 122, 122) }, - {"grey48" , PALETTERGB (122, 122, 122) }, - {"gray49" , PALETTERGB (125, 125, 125) }, - {"grey49" , PALETTERGB (125, 125, 125) }, - {"gray50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ - {"grey50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ - {"gray51" , PALETTERGB (130, 130, 130) }, - {"grey51" , PALETTERGB (130, 130, 130) }, - {"gray52" , PALETTERGB (133, 133, 133) }, - {"grey52" , PALETTERGB (133, 133, 133) }, - {"gray53" , PALETTERGB (135, 135, 135) }, - {"grey53" , PALETTERGB (135, 135, 135) }, - {"gray54" , PALETTERGB (138, 138, 138) }, - {"grey54" , PALETTERGB (138, 138, 138) }, - {"gray55" , PALETTERGB (140, 140, 140) }, - {"grey55" , PALETTERGB (140, 140, 140) }, - {"gray56" , PALETTERGB (143, 143, 143) }, - {"grey56" , PALETTERGB (143, 143, 143) }, - {"gray57" , PALETTERGB (145, 145, 145) }, - {"grey57" , PALETTERGB (145, 145, 145) }, - {"gray58" , PALETTERGB (148, 148, 148) }, - {"grey58" , PALETTERGB (148, 148, 148) }, - {"gray59" , PALETTERGB (150, 150, 150) }, - {"grey59" , PALETTERGB (150, 150, 150) }, - {"gray60" , PALETTERGB (153, 153, 153) }, - {"grey60" , PALETTERGB (153, 153, 153) }, - {"gray61" , PALETTERGB (156, 156, 156) }, - {"grey61" , PALETTERGB (156, 156, 156) }, - {"gray62" , PALETTERGB (158, 158, 158) }, - {"grey62" , PALETTERGB (158, 158, 158) }, - {"gray63" , PALETTERGB (161, 161, 161) }, - {"grey63" , PALETTERGB (161, 161, 161) }, - {"gray64" , PALETTERGB (163, 163, 163) }, - {"grey64" , PALETTERGB (163, 163, 163) }, - {"gray65" , PALETTERGB (166, 166, 166) }, - {"grey65" , PALETTERGB (166, 166, 166) }, - {"gray66" , PALETTERGB (168, 168, 168) }, - {"grey66" , PALETTERGB (168, 168, 168) }, - {"gray67" , PALETTERGB (171, 171, 171) }, - {"grey67" , PALETTERGB (171, 171, 171) }, - {"gray68" , PALETTERGB (173, 173, 173) }, - {"grey68" , PALETTERGB (173, 173, 173) }, - {"gray69" , PALETTERGB (176, 176, 176) }, - {"grey69" , PALETTERGB (176, 176, 176) }, - {"gray70" , PALETTERGB (179, 179, 179) }, - {"grey70" , PALETTERGB (179, 179, 179) }, - {"gray71" , PALETTERGB (181, 181, 181) }, - {"grey71" , PALETTERGB (181, 181, 181) }, - {"gray72" , PALETTERGB (184, 184, 184) }, - {"grey72" , PALETTERGB (184, 184, 184) }, - {"gray73" , PALETTERGB (186, 186, 186) }, - {"grey73" , PALETTERGB (186, 186, 186) }, - {"gray74" , PALETTERGB (189, 189, 189) }, - {"grey74" , PALETTERGB (189, 189, 189) }, - {"gray75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ - {"grey75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ - {"gray76" , PALETTERGB (194, 194, 194) }, - {"grey76" , PALETTERGB (194, 194, 194) }, - {"gray77" , PALETTERGB (196, 196, 196) }, - {"grey77" , PALETTERGB (196, 196, 196) }, - {"gray78" , PALETTERGB (199, 199, 199) }, - {"grey78" , PALETTERGB (199, 199, 199) }, - {"gray79" , PALETTERGB (201, 201, 201) }, - {"grey79" , PALETTERGB (201, 201, 201) }, - {"gray80" , PALETTERGB (204, 204, 204) }, - {"grey80" , PALETTERGB (204, 204, 204) }, - {"gray81" , PALETTERGB (207, 207, 207) }, - {"grey81" , PALETTERGB (207, 207, 207) }, - {"gray82" , PALETTERGB (209, 209, 209) }, - {"grey82" , PALETTERGB (209, 209, 209) }, - {"gray83" , PALETTERGB (212, 212, 212) }, - {"grey83" , PALETTERGB (212, 212, 212) }, - {"gray84" , PALETTERGB (214, 214, 214) }, - {"grey84" , PALETTERGB (214, 214, 214) }, - {"gray85" , PALETTERGB (217, 217, 217) }, - {"grey85" , PALETTERGB (217, 217, 217) }, - {"gray86" , PALETTERGB (219, 219, 219) }, - {"grey86" , PALETTERGB (219, 219, 219) }, - {"gray87" , PALETTERGB (222, 222, 222) }, - {"grey87" , PALETTERGB (222, 222, 222) }, - {"gray88" , PALETTERGB (224, 224, 224) }, - {"grey88" , PALETTERGB (224, 224, 224) }, - {"gray89" , PALETTERGB (227, 227, 227) }, - {"grey89" , PALETTERGB (227, 227, 227) }, - {"gray90" , PALETTERGB (229, 229, 229) }, - {"grey90" , PALETTERGB (229, 229, 229) }, - {"gray91" , PALETTERGB (232, 232, 232) }, - {"grey91" , PALETTERGB (232, 232, 232) }, - {"gray92" , PALETTERGB (235, 235, 235) }, - {"grey92" , PALETTERGB (235, 235, 235) }, - {"gray93" , PALETTERGB (237, 237, 237) }, - {"grey93" , PALETTERGB (237, 237, 237) }, - {"gray94" , PALETTERGB (240, 240, 240) }, - {"grey94" , PALETTERGB (240, 240, 240) }, - {"gray95" , PALETTERGB (242, 242, 242) }, - {"grey95" , PALETTERGB (242, 242, 242) }, - {"gray96" , PALETTERGB (245, 245, 245) }, - {"grey96" , PALETTERGB (245, 245, 245) }, - {"gray97" , PALETTERGB (247, 247, 247) }, - {"grey97" , PALETTERGB (247, 247, 247) }, - {"gray98" , PALETTERGB (250, 250, 250) }, - {"grey98" , PALETTERGB (250, 250, 250) }, - {"gray99" , PALETTERGB (252, 252, 252) }, - {"grey99" , PALETTERGB (252, 252, 252) }, - {"gray100" , PALETTERGB (255, 255, 255) }, - {"grey100" , PALETTERGB (255, 255, 255) }, - {"DarkGrey" , PALETTERGB (169, 169, 169) }, - {"DarkGray" , PALETTERGB (169, 169, 169) }, - {"DarkBlue" , PALETTERGB (0, 0, 128) }, /* Adjusted == Navy */ - {"DarkCyan" , PALETTERGB (0, 128, 128) }, /* Adjusted */ - {"DarkMagenta" , PALETTERGB (128, 0, 128) }, /* Adjusted */ - {"DarkRed" , PALETTERGB (128, 0, 0) }, /* Adjusted */ - {"LightGreen" , PALETTERGB (144, 238, 144) }, - /* Added to match values in the default Windows palette: */ - {"DarkYellow" , PALETTERGB (128, 128, 0) }, - {"PaleYellow" , PALETTERGB (255, 255, 128) } -}; - - -typedef struct fontmap_t -{ - const Ascbyte *name; - int value; -} fontmap_t; - -/* Default weight first, preferred names listed before synonyms */ -static const fontmap_t fontweight_map[] = -{ - {"Regular" , FW_REGULAR}, /* The standard font weight */ - {"Thin" , FW_THIN}, - {"Extra Light" , FW_EXTRALIGHT}, - {"Ultra Light" , FW_ULTRALIGHT}, - {"Light" , FW_LIGHT}, - {"Normal" , FW_NORMAL}, - {"Medium" , FW_MEDIUM}, - {"Semi Bold" , FW_SEMIBOLD}, - {"Demi Bold" , FW_DEMIBOLD}, - {"Bold" , FW_BOLD}, /* The standard bold font weight */ - {"Extra Bold" , FW_EXTRABOLD}, - {"Ultra Bold" , FW_ULTRABOLD}, - {"Heavy" , FW_HEAVY}, - {"Black" , FW_BLACK} -}; - -/* Default charset must be listed first, no synonyms allowed because these - * names are matched against the names reported by win32 by match_font() */ -static const fontmap_t charset_map[] = -{ - {"Western" , ANSI_CHARSET}, /* Latin 1 */ - {"Central European" , EASTEUROPE_CHARSET}, - {"Cyrillic" , RUSSIAN_CHARSET}, - {"Greek" , GREEK_CHARSET}, - {"Turkish" , TURKISH_CHARSET}, - {"Hebrew" , HEBREW_CHARSET}, - {"Arabic" , ARABIC_CHARSET}, - {"Baltic" , BALTIC_CHARSET}, - {"Viet Nam" , VIETNAMESE_CHARSET}, - {"Thai" , THAI_CHARSET}, - {"Japanese" , SHIFTJIS_CHARSET}, - {"Korean" , HANGEUL_CHARSET}, - {"Simplified Chinese" , GB2312_CHARSET}, - {"Traditional Chinese", CHINESEBIG5_CHARSET}, - - {"Symbol" , SYMBOL_CHARSET}, - {"Mac" , MAC_CHARSET}, - {"Korean Johab" , JOHAB_CHARSET}, - {"OEM/DOS" , OEM_CHARSET} -}; - -#ifdef MULE - -typedef struct unicode_subrange_raw_t -{ - int subrange_bit; - int start; /* first Unicode codepoint */ - int end; /* last Unicode codepoint */ -} unicode_subrange_raw_t; - -/* This table comes from MSDN, Unicode Subset Bitfields [Platform SDK - Documentation, Base Services, International Features, Unicode and - Character Sets, Unicode and Character Set Reference, Unicode and - Character Set Constants]. We preprocess it at startup time into an - array of unicode_subrange_t. - */ - -static const unicode_subrange_raw_t unicode_subrange_raw_map[] = -{ - {0, 0x0020, 0x007e}, /* Basic Latin */ - {1, 0x00a0, 0x00ff}, /* Latin-1 Supplement */ - {2, 0x0100, 0x017f}, /* Latin Extended-A */ - {3, 0x0180, 0x024f}, /* Latin Extended-B */ - {4, 0x0250, 0x02af}, /* IPA Extensions */ - {5, 0x02b0, 0x02ff}, /* Spacing Modifier Letters */ - {6, 0x0300, 0x036f}, /* Combining Diacritical Marks */ - {7, 0x0370, 0x03ff}, /* Basic Greek */ - /* 8 Reserved */ - {9, 0x0400, 0x04ff}, /* Cyrillic */ - {10, 0x0530, 0x058f}, /* Armenian */ - {11, 0x0590, 0x05ff}, /* Basic Hebrew */ - /* 12 Reserved */ - {13, 0x0600, 0x06ff}, /* Basic Arabic */ - /* 14 Reserved */ - {15, 0x0900, 0x097f}, /* Devanagari */ - {16, 0x0980, 0x09ff}, /* Bengali */ - {17, 0x0a00, 0x0a7f}, /* Gurmukhi */ - {18, 0x0a80, 0x0aff}, /* Gujarati */ - {19, 0x0b00, 0x0b7f}, /* Oriya */ - {20, 0x0b80, 0x0bff}, /* Tamil */ - {21, 0x0c00, 0x0c7f}, /* Telugu */ - {22, 0x0c80, 0x0cff}, /* Kannada */ - {23, 0x0d00, 0x0d7f}, /* Malayalam */ - {24, 0x0e00, 0x0e7f}, /* Thai */ - {25, 0x0e80, 0x0eff}, /* Lao */ - {26, 0x10a0, 0x10ff}, /* Basic Georgian */ - /* 27 Reserved */ - {28, 0x1100, 0x11ff}, /* Hangul Jamo */ - {29, 0x1e00, 0x1eff}, /* Latin Extended Additional */ - {30, 0x1f00, 0x1fff}, /* Greek Extended */ - {31, 0x2000, 0x206f}, /* General Punctuation */ - {32, 0x2070, 0x209f}, /* Subscripts and Superscripts */ - {33, 0x20a0, 0x20cf}, /* Currency Symbols */ - {34, 0x20d0, 0x20ff}, /* Combining Diacritical Marks for Symbols */ - {35, 0x2100, 0x214f}, /* Letter-like Symbols */ - {36, 0x2150, 0x218f}, /* Number Forms */ - {37, 0x2190, 0x21ff}, /* Arrows */ - {38, 0x2200, 0x22ff}, /* Mathematical Operators */ - {39, 0x2300, 0x23ff}, /* Miscellaneous Technical */ - {40, 0x2400, 0x243f}, /* Control Pictures */ - {41, 0x2440, 0x245f}, /* Optical Character Recognition */ - {42, 0x2460, 0x24ff}, /* Enclosed Alphanumerics */ - {43, 0x2500, 0x257f}, /* Box Drawing */ - {44, 0x2580, 0x259f}, /* Block Elements */ - {45, 0x25a0, 0x25ff}, /* Geometric Shapes */ - {46, 0x2600, 0x26ff}, /* Miscellaneous Symbols */ - {47, 0x2700, 0x27bf}, /* Dingbats */ - {48, 0x3000, 0x303f}, /* Chinese, Japanese, and Korean (CJK) Symbols and Punctuation */ - {49, 0x3040, 0x309f}, /* Hiragana */ - {50, 0x30a0, 0x30ff}, /* Katakana */ - {51, 0x3100, 0x312f}, /* Bopomofo */ - {51, 0x31a0, 0x31bf}, /* Extended Bopomofo */ - {52, 0x3130, 0x318f}, /* Hangul Compatibility Jamo */ - {53, 0x3190, 0x319f}, /* CJK Miscellaneous */ - {54, 0x3200, 0x32ff}, /* Enclosed CJK Letters and Months */ - {55, 0x3300, 0x33ff}, /* CJK Compatibility */ - {56, 0xac00, 0xd7a3}, /* Hangul */ - {57, 0xd800, 0xdfff}, /* Surrogates. Note that setting this bit implies that there is at least one codepoint beyond the Basic Multilingual Plane that is supported by this font. */ - /* 58 Reserved */ - {59, 0x4e00, 0x9fff}, /* CJK Unified Ideographs */ - {59, 0x2e80, 0x2eff}, /* CJK Radicals Supplement */ - {59, 0x2f00, 0x2fdf}, /* Kangxi Radicals */ - {59, 0x2ff0, 0x2fff}, /* Ideographic Description */ - {59, 0x3400, 0x4dbf}, /* CJK Unified Ideograph Extension A */ - {60, 0xe000, 0xf8ff}, /* Private Use Area */ - {61, 0xf900, 0xfaff}, /* CJK Compatibility Ideographs */ - {62, 0xfb00, 0xfb4f}, /* Alphabetic Presentation Forms */ - {63, 0xfb50, 0xfdff}, /* Arabic Presentation Forms-A */ - {64, 0xfe20, 0xfe2f}, /* Combining Half Marks */ - {65, 0xfe30, 0xfe4f}, /* CJK Compatibility Forms */ - {66, 0xfe50, 0xfe6f}, /* Small Form Variants */ - {67, 0xfe70, 0xfefe}, /* Arabic Presentation Forms-B */ - {68, 0xff00, 0xffef}, /* Halfwidth and Fullwidth Forms */ - {69, 0xfff0, 0xfffd}, /* Specials */ - {70, 0x0f00, 0x0fcf}, /* Tibetan */ - {71, 0x0700, 0x074f}, /* Syriac */ - {72, 0x0780, 0x07bf}, /* Thaana */ - {73, 0x0d80, 0x0dff}, /* Sinhala */ - {74, 0x1000, 0x109f}, /* Myanmar */ - {75, 0x1200, 0x12bf}, /* Ethiopic */ - {76, 0x13a0, 0x13ff}, /* Cherokee */ - {77, 0x1400, 0x14df}, /* Canadian Aboriginal Syllabics */ - {78, 0x1680, 0x169f}, /* Ogham */ - {79, 0x16a0, 0x16ff}, /* Runic */ - {80, 0x1780, 0x17ff}, /* Khmer */ - {81, 0x1800, 0x18af}, /* Mongolian */ - {82, 0x2800, 0x28ff}, /* Braille */ - {83, 0xa000, 0xa48c}, /* Yi, Yi Radicals */ - /* 84-122 Reserved */ - /* 123 Windows 2000/XP: Layout progress: horizontal from right to left */ - /* 124 Windows 2000/XP: Layout progress: vertical before horizontal */ - /* 125 Windows 2000/XP: Layout progress: vertical bottom to top */ - /* 126 Reserved; must be 0 */ - /* 127 Reserved; must be 1 */ -}; - -typedef struct unicode_subrange_t -{ - int no_subranges; - const unicode_subrange_raw_t *subranges; -} unicode_subrange_t; - -unicode_subrange_t *unicode_subrange_table; - -/* Hash table mapping font specs (strings) to font signature data - (FONTSIGNATURE structures stored in opaques), as determined by - GetTextCharsetInfo(). I presume this is somewhat expensive because it - involves creating a font object. At the very least, with no hashing, it - definitely took awhile (a few seconds) when encountering characters from - charsets needing stage 2 processing. */ -Lisp_Object Vfont_signature_data; - -#endif /* MULE */ - - -/************************************************************************/ -/* helpers */ -/************************************************************************/ - -static int -hexval (Ibyte c) -{ - /* assumes ASCII and isxdigit (c) */ - if (c >= 'a') - return c - 'a' + 10; - else if (c >= 'A') - return c - 'A' + 10; - else - return c - '0'; -} - -COLORREF -mswindows_string_to_color (const Ibyte *name) -{ - int i; - - if (*name == '#') - { - /* numeric names look like "#RRGGBB", "#RRRGGGBBB" or "#RRRRGGGGBBBB" - or "rgb:rrrr/gggg/bbbb" */ - unsigned int r, g, b; - - for (i = 1; i < qxestrlen (name); i++) - { - if (!byte_ascii_p (name[i]) || !isxdigit ((int) name[i])) - return (COLORREF) -1; - } - if (qxestrlen (name) == 7) - { - r = hexval (name[1]) * 16 + hexval (name[2]); - g = hexval (name[3]) * 16 + hexval (name[4]); - b = hexval (name[5]) * 16 + hexval (name[6]); - return (PALETTERGB (r, g, b)); - } - else if (qxestrlen (name) == 10) - { - r = hexval (name[1]) * 16 + hexval (name[2]); - g = hexval (name[4]) * 16 + hexval (name[5]); - b = hexval (name[7]) * 16 + hexval (name[8]); - return (PALETTERGB (r, g, b)); - } - else if (qxestrlen (name) == 13) - { - r = hexval (name[1]) * 16 + hexval (name[2]); - g = hexval (name[5]) * 16 + hexval (name[6]); - b = hexval (name[9]) * 16 + hexval (name[10]); - return (PALETTERGB (r, g, b)); - } - } - else if (!qxestrncmp_ascii (name, "rgb:", 4)) - { - unsigned int r, g, b; - - if (sscanf ((CIbyte *) name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) - { - int len = qxestrlen (name); - if (len == 18) - { - r /= 257; - g /= 257; - b /= 257; - } - else if (len == 15) - { - r /= 17; - g /= 17; - b /= 17; - } - return (PALETTERGB (r, g, b)); - } - else - return (COLORREF) -1; - } - else if (*name) /* Can't be an empty string */ - { - Ibyte *nospaces = alloca_ibytes (qxestrlen (name) + 1); - Ibyte *c = nospaces; - while (*name) - if (*name != ' ') - *c++ = *name++; - else - name++; - *c = '\0'; - - for (i = 0; i < countof (mswindows_X_color_map); i++) - if (!qxestrcasecmp_ascii (nospaces, mswindows_X_color_map[i].name)) - return (mswindows_X_color_map[i].colorref); - } - return (COLORREF) -1; -} - -Lisp_Object -mswindows_color_to_string (COLORREF color) -{ - int i; - Ascbyte buf[8]; - COLORREF pcolor = PALETTERGB (GetRValue (color), GetGValue (color), - GetBValue (color)); - - for (i = 0; i < countof (mswindows_X_color_map); i++) - if (pcolor == (mswindows_X_color_map[i].colorref)) - return build_ascstring (mswindows_X_color_map[i].name); - - sprintf (buf, "#%02X%02X%02X", - GetRValue (color), GetGValue (color), GetBValue (color)); - return build_ascstring (buf); -} - -/* - * Returns non-zero if the two supplied font patterns match. - * If they match and fontname is not NULL, copies the logical OR of the - * patterns to fontname (which is assumed to be at least MSW_FONTSIZE in size). - * - * The patterns 'match' iff for each field that is not blank in either pattern, - * the corresponding field in the other pattern is either identical or blank. - */ -static int -match_font (Ibyte *pattern1, Ibyte *pattern2, - Ibyte *fontname) -{ - Ibyte *c1 = pattern1, *c2 = pattern2, *e1 = 0, *e2 = 0; - int i; - - if (fontname) - fontname[0] = '\0'; - - for (i = 0; i < 5; i++) - { - if (c1 && (e1 = qxestrchr (c1, ':'))) - *(e1) = '\0'; - if (c2 && (e2 = qxestrchr (c2, ':'))) - *(e2) = '\0'; - - if (c1 && c1[0] != '\0') - { - if (c2 && c2[0] != '\0' && qxestrcasecmp (c1, c2)) - { - if (e1) *e1 = ':'; - if (e2) *e2 = ':'; - return 0; - } - else if (fontname) - qxestrcat_ascii (qxestrcat (fontname, c1), ":"); - } - else if (fontname) - { - if (c2 && c2[0] != '\0') - qxestrcat_ascii (qxestrcat (fontname, c2), ":"); - else - qxestrcat_ascii (fontname, ":"); - } - - if (e1) *(e1++) = ':'; - if (e2) *(e2++) = ':'; - c1 = e1; - c2 = e2; - } - - if (fontname) - fontname[qxestrlen (fontname) - 1] = '\0'; /* Trim trailing ':' */ - return 1; -} - - -/************************************************************************/ -/* exports */ -/************************************************************************/ - -struct font_enum_t -{ - HDC hdc; - Lisp_Object list; -}; - -static int CALLBACK -font_enum_callback_2 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, - int FontType, struct font_enum_t *font_enum) -{ - Ibyte fontname[MSW_FONTSIZE * 2 * MAX_ICHAR_LEN]; /* should be enough :)*/ - Lisp_Object fontname_lispstr; - int i; - Ibyte *facename; - - /* - * The enumerated font weights are not to be trusted because: - * a) lpelfe->elfStyle is only filled in for TrueType fonts. - * b) Not all Bold and Italic styles of all fonts (including some Vector, - * Truetype and Raster fonts) are enumerated. - * I guess that fonts for which Bold and Italic styles are generated - * 'on-the-fly' are not enumerated. It would be overly restrictive to - * disallow Bold And Italic weights for these fonts, so we just leave - * weights unspecified. This means that we have to weed out duplicates of - * those fonts that do get enumerated with different weights. - */ - facename = TSTR_TO_ITEXT (lpelfe->elfLogFont.lfFaceName); - if (itext_ichar (facename) == '@') - /* This is a font for writing vertically. We ignore it. */ - return 1; - - if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) - /* Scalable, so leave pointsize blank */ - qxesprintf (fontname, "%s::::", facename); - else - /* Formula for pointsize->height from LOGFONT docs in Platform SDK */ - qxesprintf (fontname, "%s::%d::", facename, - MulDiv (lpntme->ntmTm.tmHeight - - lpntme->ntmTm.tmInternalLeading, - 72, GetDeviceCaps (font_enum->hdc, LOGPIXELSY))); - - /* - * The enumerated font character set strings are not to be trusted because - * lpelfe->elfScript is returned in the host language and not in English. - * We can't know a priori the translations of "Western", "Central European" - * etc into the host language, so we must use English. The same argument - * applies to the font weight string when matching fonts. - */ - for (i = 0; i < countof (charset_map); i++) - if (lpelfe->elfLogFont.lfCharSet == charset_map[i].value) - { - qxestrcat_ascii (fontname, charset_map[i].name); - break; - } - if (i == countof (charset_map)) - return 1; - - /* Add the font name to the list if not already there */ - fontname_lispstr = build_istring (fontname); - if (NILP (Fassoc (fontname_lispstr, font_enum->list))) - font_enum->list = - Fcons (Fcons (fontname_lispstr, - /* TMPF_FIXED_PITCH is backwards from what you expect! - If set, it means NOT fixed pitch. */ - (lpntme->ntmTm.tmPitchAndFamily & TMPF_FIXED_PITCH) ? - Qnil : Qt), - font_enum->list); - - return 1; -} - -static int CALLBACK -font_enum_callback_1 (ENUMLOGFONTEXW *lpelfe, - NEWTEXTMETRICEXW *UNUSED (lpntme), - int UNUSED (FontType), struct font_enum_t *font_enum) -{ - /* This function gets called once per facename per character set. - * We call a second callback to enumerate the fonts in each facename */ - return qxeEnumFontFamiliesEx (font_enum->hdc, &lpelfe->elfLogFont, - (FONTENUMPROCW) font_enum_callback_2, - (LPARAM) font_enum, 0); -} - -/* Function for sorting lists of fonts as obtained from - mswindows_enumerate_fonts(). These come in a known format: - "family::::charset" for TrueType fonts, "family::size::charset" - otherwise. */ - -static int -sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2, - Lisp_Object UNUSED (pred)) -{ - Ibyte *font1, *font2; - Ibyte *c1, *c2; - int t1, t2; - - /* - 1. fixed over proportional. - 2. Western over other charsets. - 3. TrueType over non-TrueType. - 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt. - 5. Courier New over other families. - */ - - /* The sort function should return > 0 if OBJ1 < OBJ2, < 0 otherwise. - NOTE: This is backwards from the way qsort() works. */ - - t1 = !NILP (XCDR (obj1)); - t2 = !NILP (XCDR (obj2)); - - if (t1 && !t2) - return 1; - if (t2 && !t1) - return -1; - - font1 = XSTRING_DATA (XCAR (obj1)); - font2 = XSTRING_DATA (XCAR (obj2)); - - c1 = qxestrrchr (font1, ':'); - c2 = qxestrrchr (font2, ':'); - - t1 = !qxestrcasecmp_ascii (c1 + 1, "western"); - t2 = !qxestrcasecmp_ascii (c2 + 1, "western"); - - if (t1 && !t2) - return 1; - if (t2 && !t1) - return -1; - - c1 -= 2; - c2 -= 2; - t1 = *c1 == ':'; - t2 = *c2 == ':'; - - if (t1 && !t2) - return 1; - if (t2 && !t1) - return -1; - - if (!t1 && !t2) - { - while (isdigit (*c1)) - c1--; - while (isdigit (*c2)) - c2--; - - t1 = qxeatoi (c1 + 1) - 10; - t2 = qxeatoi (c2 + 1) - 10; - - if (abs (t1) < abs (t2)) - return 1; - else if (abs (t2) < abs (t1)) - return -1; - else if (t1 < t2) - /* Prefer a smaller font over a larger one just as far away - because the smaller one won't upset the total line height if it's - just a few chars. */ - return 1; - } - - t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12); - t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12); - - if (t1 && !t2) - return 1; - if (t2 && !t1) - return -1; - - return -1; -} - -/* - * Enumerate the available on the HDC fonts and return a list of string - * font names. - */ -Lisp_Object -mswindows_enumerate_fonts (HDC hdc) -{ - /* This cannot GC */ - LOGFONTW logfont; - struct font_enum_t font_enum; - - assert (hdc != NULL); - logfont.lfCharSet = DEFAULT_CHARSET; - logfont.lfFaceName[0] = '\0'; - logfont.lfPitchAndFamily = DEFAULT_PITCH; - font_enum.hdc = hdc; - font_enum.list = Qnil; - /* EnumFontFamilies seems to enumerate only one charset per font, which - is not what we want. We aren't supporting NT 3.5x, so no need to - worry about this not existing. */ - qxeEnumFontFamiliesEx (hdc, &logfont, (FONTENUMPROCW) font_enum_callback_1, - (LPARAM) (&font_enum), 0); - - return list_sort (font_enum.list, Qnil, sort_font_list_function); -} - -static HFONT -mswindows_create_font_variant (Lisp_Font_Instance *f, - int under, int strike) -{ - /* Cannot GC */ - LOGFONTW lf; - HFONT hfont; - - assert (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) == NULL); - - if (qxeGetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0), - sizeof (lf), (void *) &lf) == 0) - { - hfont = MSWINDOWS_BAD_HFONT; - } - else - { - lf.lfUnderline = under; - lf.lfStrikeOut = strike; - - hfont = qxeCreateFontIndirect (&lf); - if (hfont == NULL) - hfont = MSWINDOWS_BAD_HFONT; - } - - FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) = hfont; - return hfont; -} - -HFONT -mswindows_get_hfont (Lisp_Font_Instance *f, - int under, int strike) -{ - /* Cannot GC */ - HFONT hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike); - - if (hfont == NULL) - hfont = mswindows_create_font_variant (f, under, strike); - - /* If strikeout/underline variant of the font could not be - created, then use the base version of the font */ - if (hfont == MSWINDOWS_BAD_HFONT) - hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0); - - assert (hfont != NULL && hfont != MSWINDOWS_BAD_HFONT); - - return hfont; -} - -/************************************************************************/ -/* methods */ -/************************************************************************/ - -static int -mswindows_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, - Lisp_Object UNUSED (device), - Error_Behavior errb) -{ - COLORREF color; - - color = mswindows_string_to_color (XSTRING_DATA (name)); - if (color != (COLORREF) -1) - { - c->data = xnew (struct mswindows_color_instance_data); - COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color; - return 1; - } - maybe_signal_error (Qinvalid_constant, - "Unrecognized color", name, Qcolor, errb); - return(0); -} - -#if 0 -static void -mswindows_mark_color_instance (Lisp_Color_Instance *c) -{ -} -#endif - -static void -mswindows_print_color_instance (Lisp_Color_Instance *c, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); - write_fmt_string (printcharfun, - " %06ld=(%04X,%04X,%04X)", color & 0xffffff, - GetRValue (color) * 257, GetGValue (color) * 257, - GetBValue (color) * 257); -} - -static void -mswindows_finalize_color_instance (Lisp_Color_Instance *c) -{ - if (c->data) - { - xfree (c->data); - c->data = 0; - } -} - -static int -mswindows_color_instance_equal (Lisp_Color_Instance *c1, - Lisp_Color_Instance *c2, - int UNUSED (depth)) -{ - return (COLOR_INSTANCE_MSWINDOWS_COLOR (c1) == - COLOR_INSTANCE_MSWINDOWS_COLOR (c2)); -} - -static Hashcode -mswindows_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) -{ - return (unsigned long) COLOR_INSTANCE_MSWINDOWS_COLOR (c); -} - -static Lisp_Object -mswindows_color_instance_rgb_components (Lisp_Color_Instance *c) -{ - COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); - return list3 (make_int (GetRValue (color) * 257), - make_int (GetGValue (color) * 257), - make_int (GetBValue (color) * 257)); -} - -static int -mswindows_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) -{ - return (mswindows_string_to_color (XSTRING_DATA (color)) != (COLORREF) -1); -} - - - -static void -mswindows_finalize_font_instance (Lisp_Font_Instance *f); - -/* Parse the font spec in NAMESTR. Maybe issue errors, according to ERRB; - NAME_FOR_ERRORS is the Lisp string to use when issuing errors. Store - the five parts of the font spec into the given strings, which should be - declared as - - Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; - Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; - - If LOGFONT is given, store the necessary information in LOGFONT to - create a font object. If LOGFONT is given, HDC must also be given; - else, NULL can be given for both. - - Return 1 if ok, 0 if error. - */ -static int -parse_font_spec (const Ibyte *namestr, - HDC hdc, - Lisp_Object name_for_errors, - Error_Behavior errb, - LOGFONTW *logfont, - Ibyte *fontname, - Ibyte *weight, - Ibyte *points, - Ibyte *effects, - Ibyte *charset) -{ - int fields, i; - int pt; - Ibyte *style; - Ibyte *c; - - /* - * mswindows fonts look like: - * fontname[:[weight ][style][:pointsize[:effects]]][:charset] - * The font name field shouldn't be empty. - * - * ie: - * Lucida Console:Regular:10 - * minimal: - * Courier New - * maximal: - * Courier New:Bold Italic:10:underline strikeout:western - */ - - fontname[0] = 0; - weight[0] = 0; - points[0] = 0; - effects[0] = 0; - charset[0] = 0; - - if (logfont) - xzero (*logfont); - - fields = sscanf ((CIbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s", - fontname, weight, points, effects, charset); - - /* This function is implemented in a fairly ad-hoc manner. - * The general idea is to validate and canonicalize each of the above fields - * at the same time as we build up the win32 LOGFONT structure. This enables - * us to use match_font() on a canonicalized font string to check the - * availability of the requested font */ - - if (fields < 0) - { - maybe_signal_error (Qinvalid_argument, "Invalid font", name_for_errors, - Qfont, errb); - return 0; - } - - if (fields > 0 && qxestrlen (fontname)) - { - Extbyte *extfontname; - - extfontname = ITEXT_TO_TSTR (fontname); - if (logfont) - { - qxetcsncpy ((Extbyte *) logfont->lfFaceName, extfontname, - LF_FACESIZE - 1); - logfont->lfFaceName[LF_FACESIZE - 1] = 0; - } - } - - /* weight */ - if (fields < 2) - qxestrcpy_ascii (weight, fontweight_map[0].name); - - /* Maybe split weight into weight and style */ - if ((c = qxestrchr (weight, ' '))) - { - *c = '\0'; - style = c + 1; - } - else - style = NULL; - - for (i = 0; i < countof (fontweight_map); i++) - if (!qxestrcasecmp_ascii (weight, fontweight_map[i].name)) - { - if (logfont) - logfont->lfWeight = fontweight_map[i].value; - break; - } - if (i == countof (fontweight_map)) /* No matching weight */ - { - if (!style) - { - if (logfont) - logfont->lfWeight = FW_REGULAR; - style = weight; /* May have specified style without weight */ - } - else - { - maybe_signal_error (Qinvalid_constant, "Invalid font weight", - name_for_errors, Qfont, errb); - return 0; - } - } - - if (style) - { - /* #### what about oblique? */ - if (qxestrcasecmp_ascii (style, "italic") == 0) - { - if (logfont) - logfont->lfItalic = TRUE; - } - else - { - maybe_signal_error (Qinvalid_constant, - "Invalid font weight or style", - name_for_errors, Qfont, errb); - return 0; - } - - /* Glue weight and style together again */ - if (weight != style) - *c = ' '; - } - else if (logfont) - logfont->lfItalic = FALSE; - - if (fields < 3 || !qxestrcmp_ascii (points, "")) - ; - else if (points[0] == '0' || - qxestrspn (points, "0123456789") < qxestrlen (points)) - { - maybe_signal_error (Qinvalid_argument, "Invalid font pointsize", - name_for_errors, Qfont, errb); - return 0; - } - else - { - pt = qxeatoi (points); - - if (logfont) - { - /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform - SDK */ - logfont->lfHeight = -MulDiv (pt, GetDeviceCaps (hdc, LOGPIXELSY), - 72); - logfont->lfWidth = 0; - } - } - - /* Effects */ - if (logfont) - { - logfont->lfUnderline = FALSE; - logfont->lfStrikeOut = FALSE; - } - - if (fields >= 4 && effects[0] != '\0') - { - Ibyte *effects2; - int underline = FALSE, strikeout = FALSE; - - /* Maybe split effects into effects and effects2 */ - if ((c = qxestrchr (effects, ' '))) - { - *c = '\0'; - effects2 = c + 1; - } - else - effects2 = NULL; - - if (qxestrcasecmp_ascii (effects, "underline") == 0) - underline = TRUE; - else if (qxestrcasecmp_ascii (effects, "strikeout") == 0) - strikeout = TRUE; - else - { - maybe_signal_error (Qinvalid_constant, "Invalid font effect", - name_for_errors, Qfont, errb); - return 0; - } - - if (effects2 && effects2[0] != '\0') - { - if (qxestrcasecmp_ascii (effects2, "underline") == 0) - underline = TRUE; - else if (qxestrcasecmp_ascii (effects2, "strikeout") == 0) - strikeout = TRUE; - else - { - maybe_signal_error (Qinvalid_constant, "Invalid font effect", - name_for_errors, Qfont, errb); - return 0; - } - } - - /* Regenerate sanitized effects string */ - if (underline) - { - if (strikeout) - qxestrcpy_ascii (effects, "underline strikeout"); - else - qxestrcpy_ascii (effects, "underline"); - } - else if (strikeout) - qxestrcpy_ascii (effects, "strikeout"); - - if (logfont) - { - logfont->lfUnderline = underline; - logfont->lfStrikeOut = strikeout; - } - } - - /* Charset */ - /* charset can be specified even if earlier fields haven't been */ - if (fields < 5) - { - if ((c = qxestrchr (namestr, ':')) && (c = qxestrchr (c + 1, ':')) && - (c = qxestrchr (c + 1, ':')) && (c = qxestrchr (c + 1, ':'))) - { - qxestrncpy (charset, c + 1, LF_FACESIZE); - charset[LF_FACESIZE - 1] = '\0'; - } - } - - /* NOTE: If you give a blank charset spec, we will normally not get here - under Mule unless we explicitly call `make-font-instance'! This is - because the C code instantiates fonts using particular charsets, by - way of specifier_matching_instance(). Before instantiating the font, - font_instantiate() calls the devmeth find_matching_font(), which gets - a truename font spec with the registry (i.e. the charset spec) filled - in appropriately to the charset. */ - if (!qxestrcmp_ascii (charset, "")) - ; - else - { - for (i = 0; i < countof (charset_map); i++) - if (!qxestrcasecmp_ascii (charset, charset_map[i].name)) - { - if (logfont) - logfont->lfCharSet = charset_map[i].value; - break; - } - - if (i == countof (charset_map)) /* No matching charset */ - { - maybe_signal_error (Qinvalid_argument, "Invalid charset", - name_for_errors, Qfont, errb); - return 0; - } - } - - if (logfont) - { - /* Misc crud */ -#if 1 - logfont->lfOutPrecision = OUT_DEFAULT_PRECIS; - logfont->lfClipPrecision = CLIP_DEFAULT_PRECIS; - logfont->lfQuality = DEFAULT_QUALITY; -#else - logfont->lfOutPrecision = OUT_STROKE_PRECIS; - logfont->lfClipPrecision = CLIP_STROKE_PRECIS; - logfont->lfQuality = PROOF_QUALITY; -#endif - /* Default to monospaced if the specified fontname doesn't exist. */ - logfont->lfPitchAndFamily = FF_MODERN; - } - - return 1; -} - -/* - mswindows fonts look like: - [fontname[:style[:pointsize[:effects]]]][:charset] - A maximal mswindows font spec looks like: - Courier New:Bold Italic:10:underline strikeout:Western - - A missing weight/style field is the same as Regular, and a missing - effects field is left alone, and means no effects; but a missing - fontname, pointsize or charset field means any will do. We prefer - Courier New, 10, Western. See sort function above. */ - -static HFONT -create_hfont_from_font_spec (const Ibyte *namestr, - HDC hdc, - Lisp_Object name_for_errors, - Lisp_Object device_font_list, - Error_Behavior errb, - Lisp_Object *truename_ret) -{ - LOGFONTW logfont; - HFONT hfont; - Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; - Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; - Ibyte truename[MSW_FONTSIZE]; - Ibyte truername[MSW_FONTSIZE]; - - /* Windows will silently substitute a default font if the fontname - specifies a non-existent font. This is bad for screen fonts because - it doesn't allow higher-level code to see the error and to act - appropriately. For instance complex_vars_of_faces() sets up a - fallback list of fonts for the default face. Instead, we look at all - the possibilities and pick one that works, handling missing pointsize - and charset fields appropriately. - - For printer fonts, we used to go ahead and let Windows choose the - font, and for those devices, then, DEVICE_FONT_LIST would be nil. - However, this causes problems with the font-matching code below, which - needs a list of fonts so it can pick the right one for Mule. - - Thus, the code below to handle a nil DEVICE_FONT_LIST is not currently - used. */ - - if (!NILP (device_font_list)) - { - Lisp_Object fonttail = Qnil; - - if (!parse_font_spec (namestr, 0, name_for_errors, - errb, 0, fontname, weight, points, - effects, charset)) - return 0; - - /* The fonts in the device font list always specify fontname and - charset, but often times not the size; so if we don't have the - size specified either, do a round with size 10 so we'll always end - up with a size in the truename (if we fail this one but succeed - the next one, we'll have chosen a non-TrueType font, and in those - cases the size is specified in the font list item. */ - - if (!points[0]) - { - qxesprintf (truename, "%s:%s:10:%s:%s", - fontname, weight, effects, charset); - - LIST_LOOP (fonttail, device_font_list) - { - if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), - truename, truername)) - break; - } - } - - if (NILP (fonttail)) - { - qxesprintf (truename, "%s:%s:%s:%s:%s", - fontname, weight, points, effects, charset); - - LIST_LOOP (fonttail, device_font_list) - { - if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), - truename, truername)) - break; - } - } - - if (NILP (fonttail)) - { - maybe_signal_error (Qinvalid_argument, "No matching font", - name_for_errors, Qfont, errb); - return 0; - } - - if (!parse_font_spec (truername, hdc, name_for_errors, - ERROR_ME_DEBUG_WARN, &logfont, fontname, weight, - points, effects, charset)) - signal_error (Qinternal_error, "Bad value in device font list?", - build_istring (truername)); - } - else if (!parse_font_spec (namestr, hdc, name_for_errors, - errb, &logfont, fontname, weight, points, - effects, charset)) - return 0; - - if ((hfont = qxeCreateFontIndirect (&logfont)) == NULL) - { - maybe_signal_error (Qgui_error, "Couldn't create font", - name_for_errors, Qfont, errb); - return 0; - } - - /* #### Truename will not have all its fields filled in when we have no - list of fonts. Doesn't really matter now, since we always have one. - See above. */ - qxesprintf (truename, "%s:%s:%s:%s:%s", fontname, weight, - points, effects, charset); - - *truename_ret = build_istring (truename); - return hfont; -} - -/* - * This is a work horse for both mswindows_initialize_font_instance and - * msprinter_initialize_font_instance. - */ -static int -initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, - Lisp_Object device_font_list, HDC hdc, - Error_Behavior errb) -{ - HFONT hfont, hfont2; - TEXTMETRICW metrics; - Ibyte *namestr = XSTRING_DATA (name); - Lisp_Object truename; - - hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list, - errb, &truename); - if (!hfont) - return 0; - f->truename = truename; - f->data = xnew_and_zero (struct mswindows_font_instance_data); - FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0) = hfont; - - /* Some underlined fonts have the descent of one pixel more than their - non-underlined counterparts. Font variants though are assumed to have - identical metrics. So get the font metrics from the underlined variant - of the font */ - hfont2 = mswindows_create_font_variant (f, 1, 0); - if (hfont2 != MSWINDOWS_BAD_HFONT) - hfont = hfont2; - - hfont2 = (HFONT) SelectObject (hdc, hfont); - if (!hfont2) - { - mswindows_finalize_font_instance (f); - maybe_signal_error (Qgui_error, "Couldn't map font", name, Qfont, errb); - return 0; - } - qxeGetTextMetrics (hdc, &metrics); - SelectObject (hdc, hfont2); - - f->width = (unsigned short) metrics.tmAveCharWidth; - f->height = (unsigned short) metrics.tmHeight; - f->ascent = (unsigned short) metrics.tmAscent; - f->descent = (unsigned short) metrics.tmDescent; - f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH); - - return 1; -} - -static int -mswindows_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, - Lisp_Object device, Error_Behavior errb) -{ - HDC hdc = CreateCompatibleDC (NULL); - Lisp_Object font_list = DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device)); - int res = initialize_font_instance (f, name, font_list, hdc, errb); - DeleteDC (hdc); - return res; -} - -static int -msprinter_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, - Lisp_Object device, Error_Behavior errb) -{ - HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (device)); - Lisp_Object font_list = DEVICE_MSPRINTER_FONTLIST (XDEVICE (device)); - return initialize_font_instance (f, name, font_list, hdc, errb); -} - -static void -mswindows_finalize_font_instance (Lisp_Font_Instance *f) -{ - int i; - - if (f->data) - { - for (i = 0; i < MSWINDOWS_NUM_FONT_VARIANTS; i++) - { - if (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != NULL - && FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != MSWINDOWS_BAD_HFONT) - DeleteObject (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i)); - } - - xfree (f->data); - f->data = 0; - } -} - -#if 0 -static void -mswindows_mark_font_instance (Lisp_Font_Instance *f) -{ -} -#endif - -static void -mswindows_print_font_instance (Lisp_Font_Instance *f, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - write_fmt_string (printcharfun, " 0x%lx", - (unsigned long) - FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0)); - -} - -static Lisp_Object -mswindows_font_list (Lisp_Object pattern, Lisp_Object device, - Lisp_Object UNUSED (maxnumber)) -{ - struct device *d = XDEVICE (device); - Lisp_Object font_list = Qnil, fonttail, result = Qnil; - - if (DEVICE_MSWINDOWS_P (d)) - font_list = DEVICE_MSWINDOWS_FONTLIST (d); - else if (DEVICE_MSPRINTER_P (d)) - font_list = DEVICE_MSPRINTER_FONTLIST (d); - else - ABORT (); - - LIST_LOOP (fonttail, font_list) - { - Ibyte fontname[MSW_FONTSIZE]; - - if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), - XSTRING_DATA (pattern), - fontname)) - result = Fcons (build_istring (fontname), result); - } - - return Fnreverse (result); -} - -static Lisp_Object -mswindows_font_instance_truename (Lisp_Font_Instance *f, - Error_Behavior UNUSED (errb)) -{ - return f->truename; -} - -#ifdef MULE - -static int -mswindows_font_spec_matches_charset_stage_1 (struct device *UNUSED (d), - Lisp_Object charset, - const Ibyte *nonreloc, - Lisp_Object reloc, - Bytecount offset, - Bytecount length) -{ - int i; - Lisp_Object charset_registry; - const Ibyte *font_charset; - const Ibyte *the_nonreloc = nonreloc; - const Ibyte *c; - Bytecount the_length = length; - - if (NILP (charset)) - return 1; - - if (!the_nonreloc) - the_nonreloc = XSTRING_DATA (reloc); - fixup_internal_substring (nonreloc, reloc, offset, &the_length); - the_nonreloc += offset; - - c = the_nonreloc; - for (i = 0; i < 4; i++) - { - Ibyte *newc = (Ibyte *) memchr (c, ':', the_length); - if (!newc) - break; - newc++; - the_length -= (newc - c); - c = newc; - } - - if (i < 4) - return 0; - - font_charset = c; - - /* For border-glyph use */ - if (!qxestrcasecmp_ascii (font_charset, "symbol")) - font_charset = (const Ibyte *) "western"; - - /* Get code page for the charset */ - charset_registry = Fmswindows_charset_registry (charset); - if (!STRINGP (charset_registry)) - return 0; - - return !qxestrcasecmp (XSTRING_DATA (charset_registry), font_charset); -} - -/* - -#### The following comment is old and probably not applicable any longer. - -1. handle standard mapping and inheritance vectors properly in Face-frob-property. -2. finish impl of mswindows-charset-registry. -3. see if everything works under fixup, now that i copied the stuff over. -4. consider generalizing Face-frob-property to frob-specifier. -5. maybe extract some of the flets out of Face-frob-property as useful specifier frobbing. -6. eventually this stuff's got to be checked in!!!! -*/ - -static int -mswindows_font_spec_matches_charset_stage_2 (struct device *d, - Lisp_Object charset, - const Ibyte *nonreloc, - Lisp_Object reloc, - Bytecount offset, - Bytecount length) -{ - const Ibyte *the_nonreloc = nonreloc; - FONTSIGNATURE fs; - FONTSIGNATURE *fsp = &fs; - struct gcpro gcpro1; - Lisp_Object fontsig; - Bytecount the_length = length; - int i; - - if (NILP (charset)) - return 1; - - if (!the_nonreloc) - the_nonreloc = XSTRING_DATA (reloc); - fixup_internal_substring (nonreloc, reloc, offset, &the_length); - the_nonreloc += offset; - - /* Get the list of Unicode subranges corresponding to the font. This - is contained inside of FONTSIGNATURE data, obtained by calling - GetTextCharsetInfo on a font object, which we need to create from the - spec. See if the FONTSIGNATURE data is already cached. If not, get - it and cache it. */ - if (!STRINGP (reloc) || the_nonreloc != XSTRING_DATA (reloc)) - reloc = build_istring (the_nonreloc); - GCPRO1 (reloc); - fontsig = Fgethash (reloc, Vfont_signature_data, Qunbound); - - if (!UNBOUNDP (fontsig)) - { - fsp = (FONTSIGNATURE *) XOPAQUE_DATA (fontsig); - UNGCPRO; - } - else - { - HDC hdc = CreateCompatibleDC (NULL); - Lisp_Object font_list = Qnil, truename; - HFONT hfont; - - if (DEVICE_TYPE_P (d, mswindows)) - { - font_list = DEVICE_MSWINDOWS_FONTLIST (d); - } - else if (DEVICE_TYPE_P (d, msprinter)) - { - font_list = DEVICE_MSPRINTER_FONTLIST (d); - } - else - { - assert(0); - } - - hfont = create_hfont_from_font_spec (the_nonreloc, hdc, Qnil, - font_list, - ERROR_ME_DEBUG_WARN, - &truename); - - if (!hfont || !(hfont = (HFONT) SelectObject (hdc, hfont))) - { - nope: - DeleteDC (hdc); - UNGCPRO; - return 0; - } - - if (GetTextCharsetInfo (hdc, &fs, 0) == DEFAULT_CHARSET) - { - SelectObject (hdc, hfont); - goto nope; - } - SelectObject (hdc, hfont); - DeleteDC (hdc); - Fputhash (reloc, make_opaque (&fs, sizeof (fs)), Vfont_signature_data); - UNGCPRO; - } - - { - int lowlim, highlim; - int dim, j, cp = -1; - - /* Try to find a Unicode char in the charset. #### This is somewhat - bogus. See below. - - #### Cache me baby!!!!!!!!!!!!! - */ - get_charset_limits (charset, &lowlim, &highlim); - dim = XCHARSET_DIMENSION (charset); - - if (dim == 1) - { - for (i = lowlim; i <= highlim; i++) - if ((cp = ichar_to_unicode (make_ichar (charset, i, 0))) >= 0) - break; - } - else - { - for (i = lowlim; i <= highlim; i++) - for (j = lowlim; j <= highlim; j++) - if ((cp = ichar_to_unicode (make_ichar (charset, i, j))) >= 0) - break; - } - - if (cp < 0) - return 0; - - /* Check to see, for each subrange supported by the font, - whether the Unicode char is within that subrange. If any match, - the font supports the char (whereby, the charset, bogusly). */ - - for (i = 0; i < 128; i++) - { - if (fsp->fsUsb[i >> 5] & (1 << (i & 32))) - { - for (j = 0; j < unicode_subrange_table[i].no_subranges; j++) - if (cp >= unicode_subrange_table[i].subranges[j].start && - cp <= unicode_subrange_table[i].subranges[j].end) - return 1; - } - } - - return 0; - } -} - -/* - Given a truename font spec, does it match CHARSET? - - We try two stages: - - -- First see if the charset corresponds to one of the predefined Windows - charsets; if so, we see if the registry (that's the last element of the - font spec) is that same charset. If so, this means that the font is - specifically designed for the charset, and we prefer it. - - -- However, there are only a limited number of defined Windows charsets, - and new ones aren't being defined; so if we fail the first stage, we find - a character from the charset with a Unicode equivalent, and see if the - font can display this character. we do that by retrieving the Unicode - ranges that the font supports, to see if the character comes from that - subrange. - - #### Note: We really want to be doing all these checks at the character - level, not the charset level. There's no guarantee that a charset covers - a single Unicode range. Furthermore, this is extremely wasteful. We - should be doing this when we're about to redisplay and already have the - Unicode codepoints in hand. -*/ - -static int -mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, - const Ibyte *nonreloc, - Lisp_Object reloc, - Bytecount offset, Bytecount length, - enum font_specifier_matchspec_stages stage) -{ - return stage == STAGE_FINAL ? - mswindows_font_spec_matches_charset_stage_2 (d, charset, nonreloc, - reloc, offset, length) - : mswindows_font_spec_matches_charset_stage_1 (d, charset, nonreloc, - reloc, offset, length); -} - - -/* Find a font spec that matches font spec FONT and also matches - (the registry of) CHARSET. */ - -static Lisp_Object -mswindows_find_charset_font (Lisp_Object device, Lisp_Object font, - Lisp_Object charset, - enum font_specifier_matchspec_stages stage) -{ - Lisp_Object fontlist, fonttail; - - /* If FONT specifies a particular charset, this will only list fonts with - that charset; otherwise, it will list fonts with all charsets. */ - fontlist = mswindows_font_list (font, device, Qnil); - - if (stage == STAGE_INITIAL) - { - LIST_LOOP (fonttail, fontlist) - { - if (mswindows_font_spec_matches_charset_stage_1 - (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) - return XCAR (fonttail); - } - } - else - { - LIST_LOOP (fonttail, fontlist) - { - if (mswindows_font_spec_matches_charset_stage_2 - (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) - return XCAR (fonttail); - } - } - - return Qnil; -} - -#endif /* MULE */ - - -/************************************************************************/ -/* non-methods */ -/************************************************************************/ - -static Lisp_Object -mswindows_color_list (void) -{ - Lisp_Object result = Qnil; - int i; - - for (i = 0; i < countof (mswindows_X_color_map); i++) - result = Fcons (build_ascstring (mswindows_X_color_map[i].name), result); - - return Fnreverse (result); -} - - -/************************************************************************/ -/* initialization */ -/************************************************************************/ - -void -syms_of_objects_mswindows (void) -{ -} - -void -console_type_create_objects_mswindows (void) -{ - /* object methods */ - CONSOLE_HAS_METHOD (mswindows, initialize_color_instance); -/* CONSOLE_HAS_METHOD (mswindows, mark_color_instance); */ - CONSOLE_HAS_METHOD (mswindows, print_color_instance); - CONSOLE_HAS_METHOD (mswindows, finalize_color_instance); - CONSOLE_HAS_METHOD (mswindows, color_instance_equal); - CONSOLE_HAS_METHOD (mswindows, color_instance_hash); - CONSOLE_HAS_METHOD (mswindows, color_instance_rgb_components); - CONSOLE_HAS_METHOD (mswindows, valid_color_name_p); - CONSOLE_HAS_METHOD (mswindows, color_list); - - CONSOLE_HAS_METHOD (mswindows, initialize_font_instance); -/* CONSOLE_HAS_METHOD (mswindows, mark_font_instance); */ - CONSOLE_HAS_METHOD (mswindows, print_font_instance); - CONSOLE_HAS_METHOD (mswindows, finalize_font_instance); - CONSOLE_HAS_METHOD (mswindows, font_instance_truename); - CONSOLE_HAS_METHOD (mswindows, font_list); -#ifdef MULE - CONSOLE_HAS_METHOD (mswindows, font_spec_matches_charset); - CONSOLE_HAS_METHOD (mswindows, find_charset_font); -#endif - - /* Printer methods - delegate most to windows methods, - since graphical objects behave the same way. */ - - CONSOLE_INHERITS_METHOD (msprinter, mswindows, initialize_color_instance); -/* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_color_instance); */ - CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_color_instance); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_color_instance); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_equal); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_hash); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_rgb_components); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, valid_color_name_p); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_list); - - CONSOLE_HAS_METHOD (msprinter, initialize_font_instance); -/* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_font_instance); */ - CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_font_instance); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_font_instance); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_instance_truename); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_list); -#ifdef MULE - CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_spec_matches_charset); - CONSOLE_INHERITS_METHOD (msprinter, mswindows, find_charset_font); -#endif -} - -void -reinit_vars_of_object_mswindows (void) -{ -#ifdef MULE - int i; - - unicode_subrange_table = xnew_array_and_zero (unicode_subrange_t, 128); - for (i = 0; i < countof (unicode_subrange_raw_map); i++) - { - const unicode_subrange_raw_t *el = &unicode_subrange_raw_map[i]; - if (unicode_subrange_table[el->subrange_bit].subranges == 0) - unicode_subrange_table[el->subrange_bit].subranges = el; - unicode_subrange_table[el->subrange_bit].no_subranges++; - } - - Fclrhash (Vfont_signature_data); -#endif /* MULE */ -} - -void -vars_of_objects_mswindows (void) -{ -#ifdef MULE - Vfont_signature_data = - make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); - staticpro (&Vfont_signature_data); -#endif /* MULE */ -}
--- a/src/objects-msw.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* mswindows-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - Copyright (C) 1997, Jonathan Harris. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Authorship: - - Ultimately based on FSF. - Rewritten by Ben Wing. - Rewritten for mswindows by Jonathan Harris, November 1997 for 21.0. - */ - - -#ifndef INCLUDED_objects_msw_h_ -#define INCLUDED_objects_msw_h_ - -#include "objects.h" - -HFONT mswindows_get_hfont (Lisp_Font_Instance *f, int under, int strike); -Lisp_Object mswindows_color_to_string (COLORREF color); - -#endif /* INCLUDED_objects_msw_h_ */
--- a/src/objects-tty-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* TTY-specific Lisp objects. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995 Ben Wing - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#ifndef INCLUDED_objects_tty_impl_h_ -#define INCLUDED_objects_tty_impl_h_ - -#include "objects-impl.h" -#include "objects-tty.h" - -struct tty_color_instance_data -{ -#ifdef NEW_GC - NORMAL_LISP_OBJECT_HEADER header; -#endif /* NEW_GC */ - Lisp_Object symbol; /* so we don't have to constantly call Fintern() */ -}; - -#ifdef NEW_GC -DECLARE_LISP_OBJECT (tty_color_instance_data, struct tty_color_instance_data); -#define XTTY_COLOR_INSTANCE_DATA(x) \ - XRECORD (x, tty_color_instance_data, struct tty_color_instance_data) -#define wrap_tty_color_instance_data(p) \ - wrap_record (p, tty_color_instance_data) -#define TTY_COLOR_INSTANCE_DATAP(x) RECORDP (x, tty_color_instance_data) -#define CHECK_TTY_COLOR_INSTANCE_DATA(x) \ - CHECK_RECORD (x, tty_color_instance_data) -#define CONCHECK_TTY_COLOR_INSTANCE_DATA(x) \ - CONCHECK_RECORD (x, tty_color_instance_data) -#endif /* NEW_GC */ - -#define TTY_COLOR_INSTANCE_DATA(c) \ - ((struct tty_color_instance_data *) (c)->data) - -#define COLOR_INSTANCE_TTY_SYMBOL(c) (TTY_COLOR_INSTANCE_DATA (c)->symbol) - -struct tty_font_instance_data -{ -#ifdef NEW_GC - NORMAL_LISP_OBJECT_HEADER header; -#endif /* NEW_GC */ - Lisp_Object charset; -}; - -#ifdef NEW_GC -DECLARE_LISP_OBJECT (tty_font_instance_data, struct tty_font_instance_data); -#define XTTY_FONT_INSTANCE_DATA(x) \ - XRECORD (x, tty_font_instance_data, struct tty_font_instance_data) -#define wrap_tty_font_instance_data(p) \ - wrap_record (p, tty_font_instance_data) -#define TTY_FONT_INSTANCE_DATAP(x) RECORDP (x, tty_font_instance_data) -#define CHECK_TTY_FONT_INSTANCE_DATA(x) \ - CHECK_RECORD (x, tty_font_instance_data) -#define CONCHECK_TTY_FONT_INSTANCE_DATA(x) \ - CONCHECK_RECORD (x, tty_font_instance_data) -#endif /* NEW_GC */ - -#define TTY_FONT_INSTANCE_DATA(c) \ - ((struct tty_font_instance_data *) (c)->data) - -#define FONT_INSTANCE_TTY_CHARSET(c) (TTY_FONT_INSTANCE_DATA (c)->charset) - -#endif /* INCLUDED_objects_tty_impl_h_ */
--- a/src/objects-tty.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,452 +0,0 @@ -/* TTY-specific Lisp objects. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2001, 2002, 2010 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#include <config.h> -#include "lisp.h" - -#include "console-tty-impl.h" -#include "insdel.h" -#include "objects-tty-impl.h" -#include "device.h" -#include "charset.h" - -/* An alist mapping from color names to a cons of (FG-STRING, BG-STRING). */ -Lisp_Object Vtty_color_alist; -#if 0 /* This stuff doesn't quite work yet */ -Lisp_Object Vtty_dynamic_color_fg; -Lisp_Object Vtty_dynamic_color_bg; -#endif - -static const struct memory_description tty_color_instance_data_description_1 [] = { - { XD_LISP_OBJECT, offsetof (struct tty_color_instance_data, symbol) }, - { XD_END } -}; - -#ifdef NEW_GC -DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-color-instance-data", - tty_color_instance_data, - 0, tty_color_instance_data_description_1, - struct tty_color_instance_data); -#else /* not NEW_GC */ -const struct sized_memory_description tty_color_instance_data_description = { - sizeof (struct tty_color_instance_data), tty_color_instance_data_description_1 -}; -#endif /* not NEW_GC */ - -static const struct memory_description tty_font_instance_data_description_1 [] = { - { XD_LISP_OBJECT, offsetof (struct tty_font_instance_data, charset) }, - { XD_END } -}; - -#ifdef NEW_GC -DEFINE_DUMPABLE_INTERNAL_LISP_OBJECT ("tty-font-instance-data", - tty_font_instance_data, 0, - tty_font_instance_data_description_1, - struct tty_font_instance_data); -#else /* not NEW_GC */ -const struct sized_memory_description tty_font_instance_data_description = { - sizeof (struct tty_font_instance_data), tty_font_instance_data_description_1 -}; -#endif /* not NEW_GC */ - -DEFUN ("register-tty-color", Fregister_tty_color, 3, 3, 0, /* -Register COLOR as a recognized TTY color. -COLOR should be a string. -Strings FG-STRING and BG-STRING should specify the escape sequences to - set the foreground and background to the given color, respectively. -*/ - (color, fg_string, bg_string)) -{ - CHECK_STRING (color); - CHECK_STRING (fg_string); - CHECK_STRING (bg_string); - - color = Fintern (color, Qnil); - Vtty_color_alist = Fremassq (color, Vtty_color_alist); - Vtty_color_alist = Fcons (Fcons (color, Fcons (fg_string, bg_string)), - Vtty_color_alist); - - return Qnil; -} - -DEFUN ("unregister-tty-color", Funregister_tty_color, 1, 1, 0, /* -Unregister COLOR as a recognized TTY color. -*/ - (color)) -{ - CHECK_STRING (color); - - color = Fintern (color, Qnil); - Vtty_color_alist = Fremassq (color, Vtty_color_alist); - return Qnil; -} - -DEFUN ("find-tty-color", Ffind_tty_color, 1, 1, 0, /* -Look up COLOR in the list of registered TTY colors. -If it is found, return a list (FG-STRING BG-STRING) of the escape -sequences used to set the foreground and background to the color, respectively. -If it is not found, return nil. -*/ - (color)) -{ - Lisp_Object result; - - CHECK_STRING (color); - - result = Fassq (Fintern (color, Qnil), Vtty_color_alist); - if (!NILP (result)) - return list2 (Fcar (Fcdr (result)), Fcdr (Fcdr (result))); - else - return Qnil; -} - -static Lisp_Object -tty_color_list (void) -{ - Lisp_Object result = Qnil; - Lisp_Object rest; - - LIST_LOOP (rest, Vtty_color_alist) - { - result = Fcons (Fsymbol_name (XCAR (XCAR (rest))), result); - } - - return Fnreverse (result); -} - -#if 0 - -/* This approach is too simplistic. The problem is that the - dynamic color settings apply to *all* text in the default color, - not just the text output after the escape sequence has been given. */ - -DEFUN ("set-tty-dynamic-color-specs", Fset_tty_dynamic_color_specs, 2, 2, 0, /* -Set the dynamic color specifications for TTY's. -FG and BG should be either nil or vaguely printf-like strings, -where each occurrence of %s is replaced with the color name and each -occurrence of %% is replaced with a single % character. -*/ - (fg, bg)) -{ - if (!NILP (fg)) - CHECK_STRING (fg); - if (!NILP (bg)) - CHECK_STRING (bg); - - Vtty_dynamic_color_fg = fg; - Vtty_dynamic_color_bg = bg; - - return Qnil; -} - -DEFUN ("tty-dynamic-color-specs", Ftty_dynamic_color_specs, 0, 0, 0, /* -Return the dynamic color specifications for TTY's as a list of (FG BG). -See `set-tty-dynamic-color-specs'. -*/ - ()) -{ - return list2 (Vtty_dynamic_color_fg, Vtty_dynamic_color_bg); -} - -#endif /* 0 */ - -static int -tty_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, - Lisp_Object UNUSED (device), - Error_Behavior UNUSED (errb)) -{ - Lisp_Object result; - - name = Fintern (name, Qnil); - result = assq_no_quit (name, Vtty_color_alist); - - if (NILP (result)) - { -#if 0 - if (!STRINGP (Vtty_dynamic_color_fg) - && !STRINGP (Vtty_dynamic_color_bg)) -#endif - return 0; - } - - /* Don't allocate the data until we're sure that we will succeed. */ -#ifdef NEW_GC - c->data = - XTTY_COLOR_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_color_instance_data)); -#else /* not NEW_GC */ - c->data = xnew (struct tty_color_instance_data); -#endif /* not NEW_GC */ - COLOR_INSTANCE_TTY_SYMBOL (c) = name; - - return 1; -} - -static void -tty_mark_color_instance (Lisp_Color_Instance *c) -{ - mark_object (COLOR_INSTANCE_TTY_SYMBOL (c)); -} - -static void -tty_print_color_instance (Lisp_Color_Instance *UNUSED (c), - Lisp_Object UNUSED (printcharfun), - int UNUSED (escapeflag)) -{ -} - -static void -tty_finalize_color_instance (Lisp_Color_Instance *UNUSED_IF_NEW_GC (c)) -{ -#ifndef NEW_GC - if (c->data) - { - xfree (c->data); - c->data = 0; - } -#endif /* not NEW_GC */ -} - -static int -tty_color_instance_equal (Lisp_Color_Instance *c1, - Lisp_Color_Instance *c2, - int UNUSED (depth)) -{ - return (EQ (COLOR_INSTANCE_TTY_SYMBOL (c1), - COLOR_INSTANCE_TTY_SYMBOL (c2))); -} - -static Hashcode -tty_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) -{ - return LISP_HASH (COLOR_INSTANCE_TTY_SYMBOL (c)); -} - -static int -tty_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) -{ - return (!NILP (assoc_no_quit (Fintern (color, Qnil), Vtty_color_alist))); -#if 0 - || STRINGP (Vtty_dynamic_color_fg) - || STRINGP (Vtty_dynamic_color_bg) -#endif -} - - -static int -tty_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, - Lisp_Object UNUSED (device), - Error_Behavior UNUSED (errb)) -{ - Ibyte *str = XSTRING_DATA (name); - Lisp_Object charset = Qnil; - - if (qxestrncmp_ascii (str, "normal", 6)) - return 0; - str += 6; - if (*str) - { -#ifdef MULE - if (*str != '/') - return 0; - str++; - charset = Ffind_charset (intern_istring (str)); - if (NILP (charset)) - return 0; -#else - return 0; -#endif - } - - /* Don't allocate the data until we're sure that we will succeed. */ -#ifdef NEW_GC - f->data = - XTTY_FONT_INSTANCE_DATA (ALLOC_NORMAL_LISP_OBJECT (tty_font_instance_data)); -#else /* not NEW_GC */ - f->data = xnew (struct tty_font_instance_data); -#endif /* not NEW_GC */ - FONT_INSTANCE_TTY_CHARSET (f) = charset; -#ifdef MULE - if (CHARSETP (charset)) - f->width = XCHARSET_COLUMNS (charset); - else -#endif - f->width = 1; - - f->proportional_p = 0; - f->ascent = f->height = 1; - f->descent = 0; - - return 1; -} - -static void -tty_mark_font_instance (Lisp_Font_Instance *f) -{ - mark_object (FONT_INSTANCE_TTY_CHARSET (f)); -} - -static void -tty_print_font_instance (Lisp_Font_Instance *UNUSED (f), - Lisp_Object UNUSED (printcharfun), - int UNUSED (escapeflag)) -{ -} - -static void -tty_finalize_font_instance (Lisp_Font_Instance *UNUSED_IF_NEW_GC (f)) -{ -#ifndef NEW_GC - if (f->data) - { - xfree (f->data); - f->data = 0; - } -#endif /* not NEW_GC */ -} - -static Lisp_Object -tty_font_list (Lisp_Object UNUSED (pattern), Lisp_Object UNUSED (device), - Lisp_Object UNUSED (maxnumber)) -{ - return list1 (build_ascstring ("normal")); -} - -#ifdef MULE - -static int -tty_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, - const Ibyte *nonreloc, Lisp_Object reloc, - Bytecount offset, Bytecount length, - enum font_specifier_matchspec_stages stage) -{ - const Ibyte *the_nonreloc = nonreloc; - - if (stage == STAGE_FINAL) - return 0; - - if (!the_nonreloc) - the_nonreloc = XSTRING_DATA (reloc); - fixup_internal_substring (nonreloc, reloc, offset, &length); - the_nonreloc += offset; - - if (NILP (charset)) - return !memchr (the_nonreloc, '/', length); - the_nonreloc = (const Ibyte *) memchr (the_nonreloc, '/', length); - if (!the_nonreloc) - return 0; - the_nonreloc++; - { - Lisp_Object s = symbol_name (XSYMBOL (XCHARSET_NAME (charset))); - return !qxestrcmp (the_nonreloc, XSTRING_DATA (s)); - } -} - -/* find a font spec that matches font spec FONT and also matches - (the registry of) CHARSET. */ -static Lisp_Object -tty_find_charset_font (Lisp_Object device, Lisp_Object font, - Lisp_Object charset, - enum font_specifier_matchspec_stages stage) -{ - Ibyte *fontname = XSTRING_DATA (font); - - if (stage == STAGE_FINAL) - return Qnil; - - if (strchr ((const char *) fontname, '/')) - { - if (tty_font_spec_matches_charset (XDEVICE (device), charset, 0, - font, 0, -1, STAGE_INITIAL)) - return font; - return Qnil; - } - - if (NILP (charset)) - return font; - - return concat3 (font, build_ascstring ("/"), - Fsymbol_name (XCHARSET_NAME (charset))); -} - -#endif /* MULE */ - - -/************************************************************************/ -/* initialization */ -/************************************************************************/ - -void -syms_of_objects_tty (void) -{ -#ifdef NEW_GC - INIT_LISP_OBJECT (tty_color_instance_data); - INIT_LISP_OBJECT (tty_font_instance_data); -#endif /* NEW_GC */ - - DEFSUBR (Fregister_tty_color); - DEFSUBR (Funregister_tty_color); - DEFSUBR (Ffind_tty_color); -#if 0 - DEFSUBR (Fset_tty_dynamic_color_specs); - DEFSUBR (Ftty_dynamic_color_specs); -#endif -} - -void -console_type_create_objects_tty (void) -{ - /* object methods */ - CONSOLE_HAS_METHOD (tty, initialize_color_instance); - CONSOLE_HAS_METHOD (tty, mark_color_instance); - CONSOLE_HAS_METHOD (tty, print_color_instance); - CONSOLE_HAS_METHOD (tty, finalize_color_instance); - CONSOLE_HAS_METHOD (tty, color_instance_equal); - CONSOLE_HAS_METHOD (tty, color_instance_hash); - CONSOLE_HAS_METHOD (tty, valid_color_name_p); - CONSOLE_HAS_METHOD (tty, color_list); - - CONSOLE_HAS_METHOD (tty, initialize_font_instance); - CONSOLE_HAS_METHOD (tty, mark_font_instance); - CONSOLE_HAS_METHOD (tty, print_font_instance); - CONSOLE_HAS_METHOD (tty, finalize_font_instance); - CONSOLE_HAS_METHOD (tty, font_list); -#ifdef MULE - CONSOLE_HAS_METHOD (tty, font_spec_matches_charset); - CONSOLE_HAS_METHOD (tty, find_charset_font); -#endif -} - -void -vars_of_objects_tty (void) -{ - staticpro (&Vtty_color_alist); - Vtty_color_alist = Qnil; - -#if 0 - staticpro (&Vtty_dynamic_color_fg); - Vtty_dynamic_color_fg = Qnil; - - staticpro (&Vtty_dynamic_color_bg); - Vtty_dynamic_color_bg = Qnil; -#endif -}
--- a/src/objects-tty.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/* TTY-specific Lisp objects. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995 Ben Wing - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#ifndef INCLUDED_objects_tty_h_ -#define INCLUDED_objects_tty_h_ - -#include "objects.h" - -extern Lisp_Object Vtty_color_alist, Vtty_dynamic_color_bg; -extern Lisp_Object Vtty_dynamic_color_fg; - -#endif /* INCLUDED_objects_tty_h_ */
--- a/src/objects-x-impl.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* X-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* This file Mule-ized (more like Mule-verified) by Ben Wing, 7-10-00. */ - -#ifndef INCLUDED_objects_x_impl_h_ -#define INCLUDED_objects_x_impl_h_ - -#include "objects-impl.h" -#include "objects-x.h" -#ifdef HAVE_XFT -/* for resource name definitions, etc */ -#include "../lwlib/lwlib-fonts.h" -#endif - -#ifdef HAVE_X_WINDOWS - -/***************************************************************************** - Color-Instance - ****************************************************************************/ - -struct x_color_instance_data -{ - XColor color; - /* Yes, it looks crazy to have both the XColor and the XftColor, but - pragmatically both are used. */ -#ifdef HAVE_XFT - XftColor xftColor; -#endif - char dealloc_on_gc; -}; - -#define X_COLOR_INSTANCE_DATA(c) ((struct x_color_instance_data *) (c)->data) -#define COLOR_INSTANCE_X_COLOR(c) (X_COLOR_INSTANCE_DATA (c)->color) -#define XCOLOR_INSTANCE_X_COLOR(c) COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (c)) -#ifdef HAVE_XFT -#define COLOR_INSTANCE_X_XFTCOLOR(c) (X_COLOR_INSTANCE_DATA (c)->xftColor) -#endif -#define COLOR_INSTANCE_X_DEALLOC(c) (X_COLOR_INSTANCE_DATA (c)->dealloc_on_gc) - -/***************************************************************************** - Font-Instance - ****************************************************************************/ - -struct x_font_instance_data -{ - /* X-specific information */ - /* Yes, it looks crazy to have both the XFontStruct and the XftFont, but - pragmatically both are used (lwlib delegates labels to the widget sets, - which internally use XFontStructs). */ - XFontStruct * font; -#ifdef HAVE_XFT - XftFont *xftFont; -#endif - -}; - -#define X_FONT_INSTANCE_DATA(f) ((struct x_font_instance_data *) (f)->data) -#define FONT_INSTANCE_X_FONT(f) (X_FONT_INSTANCE_DATA (f)->font) -#define XFONT_INSTANCE_X_FONT(c) FONT_INSTANCE_X_FONT (XFONT_INSTANCE (c)) -#ifdef HAVE_XFT -#define FONT_INSTANCE_X_XFTFONT(f) (X_FONT_INSTANCE_DATA (f)->xftFont) -#endif - -#endif /* HAVE_X_WINDOWS */ - -#endif /* INCLUDED_objects_x_impl_h_ */
--- a/src/objects-x.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,988 +0,0 @@ -/* X-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995 Tinker Systems. - Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004 Ben Wing. - Copyright (C) 1995 Sun Microsystems, Inc. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */ - -/* This file Mule-ized by Ben Wing, 7-10-00. */ - -#include <config.h> -#include "lisp.h" - -#include "charset.h" -#include "device-impl.h" -#include "insdel.h" - -#include "console-x-impl.h" -#include "objects-x-impl.h" -#include "elhash.h" - -#ifdef HAVE_XFT -#include "font-mgr.h" -#endif - -int x_handle_non_fully_specified_fonts; - -#ifdef DEBUG_XEMACS -Fixnum debug_x_objects; -#endif /* DEBUG_XEMACS */ - - -/************************************************************************/ -/* color instances */ -/************************************************************************/ - -static int -x_parse_nearest_color (struct device *d, XColor *color, Lisp_Object name, - Error_Behavior errb) -{ - Display *dpy = DEVICE_X_DISPLAY (d); - Colormap cmap = DEVICE_X_COLORMAP (d); - Visual *visual = DEVICE_X_VISUAL (d); - int result; - - xzero (*color); - { - const Extbyte *extname; - - extname = LISP_STRING_TO_EXTERNAL (name, Qx_color_name_encoding); - result = XParseColor (dpy, cmap, extname, color); - } - if (!result) - { - maybe_signal_error (Qgui_error, "Unrecognized color", - name, Qcolor, errb); - return 0; - } - result = x_allocate_nearest_color (dpy, cmap, visual, color); - if (!result) - { - maybe_signal_error (Qgui_error, "Couldn't allocate color", - name, Qcolor, errb); - return 0; - } - - return result; -} - -static int -x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, - Lisp_Object device, Error_Behavior errb) -{ - XColor color; -#ifdef HAVE_XFT - XftColor xftColor; -#endif - int result; - - result = x_parse_nearest_color (XDEVICE (device), &color, name, errb); - - if (!result) - return 0; - - /* Don't allocate the data until we're sure that we will succeed, - or the finalize method may get fucked. */ - c->data = xnew (struct x_color_instance_data); - if (result == 3) - COLOR_INSTANCE_X_DEALLOC (c) = 0; - else - COLOR_INSTANCE_X_DEALLOC (c) = 1; - COLOR_INSTANCE_X_COLOR (c) = color; - -#ifdef HAVE_XFT - xftColor.pixel = color.pixel; - xftColor.color.red = color.red; - xftColor.color.green = color.green; - xftColor.color.blue = color.blue; - xftColor.color.alpha = 0xffff; - - COLOR_INSTANCE_X_XFTCOLOR (c) = xftColor; -#endif - - return 1; -} - -static void -x_print_color_instance (Lisp_Color_Instance *c, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - XColor color = COLOR_INSTANCE_X_COLOR (c); - write_fmt_string (printcharfun, " %ld=(%X,%X,%X)", - color.pixel, color.red, color.green, color.blue); -} - -static void -x_finalize_color_instance (Lisp_Color_Instance *c) -{ - if (c->data) - { - if (DEVICE_LIVE_P (XDEVICE (c->device))) - { - if (COLOR_INSTANCE_X_DEALLOC (c)) - { - XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)), - DEVICE_X_COLORMAP (XDEVICE (c->device)), - &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0); - } - } - xfree (c->data); - c->data = 0; - } -} - -/* Color instances are equal if they resolve to the same color on the - screen (have the same RGB values). I imagine that - "same RGB values" == "same cell in the colormap." Arguably we should - be comparing their names or pixel values instead. */ - -static int -x_color_instance_equal (Lisp_Color_Instance *c1, - Lisp_Color_Instance *c2, - int UNUSED (depth)) -{ - XColor color1 = COLOR_INSTANCE_X_COLOR (c1); - XColor color2 = COLOR_INSTANCE_X_COLOR (c2); - return ((color1.red == color2.red) && - (color1.green == color2.green) && - (color1.blue == color2.blue)); -} - -static Hashcode -x_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) -{ - XColor color = COLOR_INSTANCE_X_COLOR (c); - return HASH3 (color.red, color.green, color.blue); -} - -static Lisp_Object -x_color_instance_rgb_components (Lisp_Color_Instance *c) -{ - XColor color = COLOR_INSTANCE_X_COLOR (c); - return (list3 (make_int (color.red), - make_int (color.green), - make_int (color.blue))); -} - -static int -x_valid_color_name_p (struct device *d, Lisp_Object color) -{ - XColor c; - Display *dpy = DEVICE_X_DISPLAY (d); - Colormap cmap = DEVICE_X_COLORMAP (d); - const Extbyte *extname; - - extname = LISP_STRING_TO_EXTERNAL (color, Qx_color_name_encoding); - - return XParseColor (dpy, cmap, extname, &c); -} - -static Lisp_Object -x_color_list (void) -{ - return call0 (intern ("x-color-list-internal")); -} - - -/************************************************************************/ -/* font instances */ -/************************************************************************/ - - -static int -x_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object UNUSED (name), - Lisp_Object device, Error_Behavior errb) -{ - Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); - Extbyte *extname; - XFontStruct *fs = NULL; /* _F_ont _S_truct */ -#ifdef HAVE_XFT - XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */ -#else -#define rf (0) -#endif - -#ifdef HAVE_XFT - DEBUG_XFT1 (2, "attempting to initialize font spec %s\n", - XSTRING_DATA(f->name)); - /* #### serialize (optimize) these later... */ - /* #### This function really needs to go away. - The problem is that the fontconfig/Xft functions work much too hard - to ensure that something is returned; but that something need not be - at all close to what we asked for. */ - extname = LISP_STRING_TO_EXTERNAL (f->name, Qfc_font_name_encoding); - rf = xft_open_font_by_name (dpy, extname); -#endif - extname = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); - /* With XFree86 4.0's fonts, XListFonts returns an entry for - -isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0 but - an XLoadQueryFont on the corresponding XLFD returns NULL. - - XListFonts is not trustworthy (of course, this is news to exactly - no-one used to reading XEmacs source.) */ - fs = XLoadQueryFont (dpy, extname); - - if (!fs && !rf) - { - /* #### should this refer to X and/or Xft? */ - maybe_signal_error (Qgui_error, "Couldn't load font", f->name, - Qfont, errb); - return 0; - } - - if (rf && fs) - { - XFreeFont (dpy, fs); - fs = NULL; /* we don' need no steenkin' X font */ - } - - if (fs && !fs->max_bounds.width) - { - /* yes, this has been known to happen. */ - XFreeFont (dpy, fs); - fs = NULL; - maybe_signal_error (Qgui_error, "X font is too small", f->name, Qfont, - errb); - return 0; - } - - /* Now that we're sure that we will succeed, we can allocate data without - fear that the finalize method may get fucked. */ - f->data = xnew (struct x_font_instance_data); - -#ifdef HAVE_XFT - FONT_INSTANCE_X_XFTFONT (f) = rf; - if (rf) - /* Have an Xft font, initialize font info from it. */ - { - DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n", - f->ascent, f->descent, f->width, f->height); - - /* #### This shit is just plain wrong unless we have a character cell - font. It really hoses us on large repertoire Unicode fonts with - "double-width" characters. */ - f->ascent = rf->ascent; - f->descent = rf->descent; - { - /* This is an approximation that AFAIK only gets used to compute - cell size for estimating window dimensions. The test_string8 - is an ASCII string whose characters should approximate the - distribution of widths expected in real text. */ - static const FcChar8 test_string8[] = "Mmneei"; - static const int len = sizeof (test_string8) - 1; - XGlyphInfo glyphinfo; - - XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo); - /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */ - f->width = (2*glyphinfo.width + len)/(2*len); - } - f->height = rf->height; - f->proportional_p = 1; /* we can't recognize monospaced fonts! */ - - /* #### This message appears wa-a-ay too often! - We probably need to cache truenames or something? - Even if Xft does it for us, we cons too many font instances. */ - DEBUG_XFT4 (0, - "initialized metrics ascent %d descent %d width %d height %d\n", - f->ascent, f->descent, f->width, f->height); - } - else - { - DEBUG_XFT1 (0, "couldn't initialize Xft font %s\n", - XSTRING_DATA(f->name)); - } -#endif - - FONT_INSTANCE_X_FONT (f) = fs; - if (fs) - /* Have to use a core font, initialize font info from it. */ - { - f->ascent = fs->ascent; - f->descent = fs->descent; - f->height = fs->ascent + fs->descent; - { - /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */ - int def_char = 'n'; /*fs->default_char;*/ - int byte1, byte2; - - once_more: - byte1 = def_char >> 8; - byte2 = def_char & 0xFF; - - if (fs->per_char) - { - /* Old versions of the R5 font server have garbage (>63k) as - def_char. 'n' might not be a valid character. */ - if (byte1 < (int) fs->min_byte1 || - byte1 > (int) fs->max_byte1 || - byte2 < (int) fs->min_char_or_byte2 || - byte2 > (int) fs->max_char_or_byte2) - f->width = 0; - else - f->width = fs->per_char[(byte1 - fs->min_byte1) * - (fs->max_char_or_byte2 - - fs->min_char_or_byte2 + 1) + - (byte2 - fs->min_char_or_byte2)].width; - } - else - f->width = fs->max_bounds.width; - - /* Some fonts have a default char whose width is 0. This is no good. - If that's the case, first try 'n' as the default char, and if n has - 0 width too (unlikely) then just use the max width. */ - if (f->width == 0) - { - if (def_char == (int) fs->default_char) - f->width = fs->max_bounds.width; - else - { - def_char = fs->default_char; - goto once_more; - } - } - } - - /* If all characters don't exist then there could potentially be - 0-width characters lurking out there. Not setting this flag - trips an optimization that would make them appear to have width - to redisplay. This is bad. So we set it if not all characters - have the same width or if not all characters are defined. */ - /* #### This sucks. There is a measurable performance increase - when using proportional width fonts if this flag is not set. - Unfortunately so many of the fucking X fonts are not fully - defined that we could almost just get rid of this damn flag and - make it an assertion. */ - f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width || - (x_handle_non_fully_specified_fonts && - !fs->all_chars_exist)); - } - -#ifdef HAVE_XFT - if (debug_xft > 0) - { - int n = 3, d = 5; - /* check for weirdness */ - if (n * f->height < d * f->width) - stderr_out ("font %s: width:height is %d:%d, larger than %d:%d\n", - XSTRING_DATA(f->name), f->width, f->height, n, d); - if (f->height <= 0 || f->width <= 0) - stderr_out ("bogus dimensions of font %s: width = %d, height = %d\n", - XSTRING_DATA(f->name), f->width, f->height); - stderr_out ("initialized font %s\n", XSTRING_DATA(f->name)); - } -#else -#undef rf -#endif - - return 1; -} - -static void -x_print_font_instance (Lisp_Font_Instance *f, - Lisp_Object printcharfun, - int UNUSED (escapeflag)) -{ - /* We should print information here about initial vs. final stages; we - can't rely on the device charset stage cache for that, - unfortunately. */ - if (FONT_INSTANCE_X_FONT (f)) - write_fmt_string (printcharfun, " font id: 0x%lx,", - (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); - -#ifdef HAVE_XFT - /* #### What should we do here? For now, print the address. */ - if (FONT_INSTANCE_X_XFTFONT (f)) - write_fmt_string (printcharfun, " xft font: 0x%lx", - (unsigned long) FONT_INSTANCE_X_XFTFONT (f)); -#endif -} - -static void -x_finalize_font_instance (Lisp_Font_Instance *f) -{ - -#ifdef HAVE_XFT - DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name) - ? (char *) XSTRING_DATA (f->name) - : "(unnamed font)")); -#endif - - if (f->data) - { - if (DEVICE_LIVE_P (XDEVICE (f->device))) - { - Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); - - if (FONT_INSTANCE_X_FONT (f)) - XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); -#ifdef HAVE_XFT - if (FONT_INSTANCE_X_XFTFONT (f)) - XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f)); -#endif - } - xfree (f->data); - f->data = 0; - } -} - -/* Determining the truename of a font is hard. (Big surprise.) - - This is not true for fontconfig. Each font has a (nearly) canonical - representation up to permutation of the order of properties. It is - possible to construct a name which exactly identifies the properties of - the current font. However, it is theoretically possible that there exists - another font with a super set of those properties that would happen to get - selected. -- sjt - - By "truename" we mean an XLFD-form name which contains no wildcards, yet - which resolves to *exactly* the same font as the one which we already have - the (probably wildcarded) name and `XFontStruct' of. - - One might think that the first font returned by XListFonts would be the one - that XOpenFont would pick. Apparently this is the case on some servers, - but not on others. It would seem not to be specified. - - The MIT R5 server sometimes appears to be picking the lexicographically - smallest font which matches the name (thus picking "adobe" fonts before - "bitstream" fonts even if the bitstream fonts are earlier in the path, and - also picking 100dpi adobe fonts over 75dpi adobe fonts even though the - 75dpi are in the path earlier) but sometimes appears to be doing something - else entirely (for example, removing the bitstream fonts from the path will - cause the 75dpi adobe fonts to be used instead of the 100dpi, even though - their relative positions in the path (and their names!) have not changed). - - The documentation for XSetFontPath() seems to indicate that the order of - entries in the font path means something, but it's pretty noncommittal about - it, and the spirit of the law is apparently not being obeyed... - - All the fonts I've seen have a property named `FONT' which contains the - truename of the font. However, there are two problems with using this: the - first is that the X Protocol Document is quite explicit that all properties - are optional, so we can't depend on it being there. The second is that - it's conceivable that this alleged truename isn't actually accessible as a - font, due to some difference of opinion between the font designers and - whoever installed the font on the system. - - So, our first attempt is to look for a FONT property, and then verify that - the name there is a valid name by running XListFonts on it. There's still - the potential that this could be true but we could still be being lied to, - but that seems pretty remote. - - Late breaking news: I've gotten reports that SunOS 4.1.3U1 - with OpenWound 3.0 has a font whose truename is really - "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1" - but whose FONT property contains "Courier". - - So we disbelieve the FONT property unless it begins with a dash and - is more than 30 characters long. X Windows: The defacto substandard. - X Windows: Complex nonsolutions to simple nonproblems. X Windows: - Live the nightmare. - - If the FONT property doesn't exist, then we try and construct an XLFD name - out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc). - This is necessary at least for some versions of OpenWound. But who knows - what the future will bring. - - If that doesn't work, then we use XListFonts and either take the first font - (which I think is the most sensible thing) or we find the lexicographically - least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is - defined. This sucks because the two behaviors are a property of the server - being used, not the architecture on which emacs has been compiled. Also, - as I described above, sorting isn't ALWAYS what the server does. Really it - does something seemingly random. There is no reliable way to win if the - FONT property isn't present. - - Another possibility which I haven't bothered to implement would be to map - over all of the matching fonts and find the first one that has the same - character metrics as the font we already have loaded. Even if this didn't - return exactly the same font, it would at least return one whose characters - were the same sizes, which would probably be good enough. - - More late-breaking news: on RS/6000 AIX 3.2.4, the expression - XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1") - actually returns the font - -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1 - which is crazy, because that font doesn't even match that pattern! It is - also not included in the output produced by `xlsfonts' with that pattern. - - So this is yet another example of XListFonts() and XOpenFont() using - completely different algorithms. This, however, is a goofier example of - this bug, because in this case, it's not just the search order that is - different -- the sets don't even intersect. - - If anyone has any better ideas how to do this, or any insights on what it is - that the various servers are actually doing, please let me know! -- jwz. */ - -static int -valid_x_font_name_p (Display *dpy, Extbyte *name) -{ - /* Maybe this should be implemented by calling XLoadFont and trapping - the error. That would be a lot of work, and wasteful as hell, but - might be more correct. - */ - int nnames = 0; - Extbyte **names = 0; - if (! name) - return 0; - names = XListFonts (dpy, name, 1, &nnames); - if (names) - XFreeFontNames (names); - return (nnames != 0); -} - -static Extbyte * -truename_via_FONT_prop (Display *dpy, XFontStruct *font) -{ - unsigned long value = 0; - Extbyte *result = 0; - if (XGetFontProperty (font, XA_FONT, &value)) - result = XGetAtomName (dpy, value); - /* result is now 0, or the string value of the FONT property. */ - if (result) - { - /* Verify that result is an XLFD name (roughly...) */ - if (result [0] != '-' || strlen (result) < 30) - { - XFree (result); - result = 0; - } - } - return result; /* this must be freed by caller if non-0 */ -} - -static Extbyte * -truename_via_random_props (Display *dpy, XFontStruct *font) -{ - struct device *d = get_device_from_display (dpy); - unsigned long value = 0; - Extbyte *foundry, *family, *weight, *slant, *setwidth, *add_style; - unsigned long pixel, point, res_x, res_y; - Extbyte *spacing; - unsigned long avg_width; - Extbyte *registry, *encoding; - Extbyte composed_name [2048]; - int ok = 0; - Extbyte *result; - -#define get_string(atom,var) \ - if (XGetFontProperty (font, (atom), &value)) \ - var = XGetAtomName (dpy, value); \ - else { \ - var = 0; \ - goto FAIL; } -#define get_number(atom,var) \ - if (!XGetFontProperty (font, (atom), &var) || \ - var > 999) \ - goto FAIL; - - foundry = family = weight = slant = setwidth = 0; - add_style = spacing = registry = encoding = 0; - - get_string (DEVICE_XATOM_FOUNDRY (d), foundry); - get_string (DEVICE_XATOM_FAMILY_NAME (d), family); - get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight); - get_string (DEVICE_XATOM_SLANT (d), slant); - get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth); - get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style); - get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel); - get_number (DEVICE_XATOM_POINT_SIZE (d), point); - get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x); - get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y); - get_string (DEVICE_XATOM_SPACING (d), spacing); - get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width); - get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry); - get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding); -#undef get_number -#undef get_string - - sprintf (composed_name, - "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s", - foundry, family, weight, slant, setwidth, add_style, pixel, - point, res_x, res_y, spacing, avg_width, registry, encoding); - ok = 1; - - FAIL: - if (ok) - { - int L = strlen (composed_name) + 1; - result = xnew_extbytes (L); - strncpy (result, composed_name, L); - } - else - result = 0; - - if (foundry) XFree (foundry); - if (family) XFree (family); - if (weight) XFree (weight); - if (slant) XFree (slant); - if (setwidth) XFree (setwidth); - if (add_style) XFree (add_style); - if (spacing) XFree (spacing); - if (registry) XFree (registry); - if (encoding) XFree (encoding); - - return result; -} - -/* XListFonts doesn't allocate memory unconditionally based on this. (For - XFree86 in 2005, at least. */ -#define MAX_FONT_COUNT INT_MAX - -static Extbyte * -truename_via_XListFonts (Display *dpy, Extbyte *font_name) -{ - Extbyte *result = 0; - Extbyte **names; - int count = 0; - -#ifndef XOPENFONT_SORTS - /* In a sensible world, the first font returned by XListFonts() - would be the font that XOpenFont() would use. */ - names = XListFonts (dpy, font_name, 1, &count); - if (count) result = names [0]; -#else - /* But the world I live in is much more perverse. */ - names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count); - /* Find the lexicographic minimum of names[]. - (#### Should we be comparing case-insensitively?) */ - while (count--) - /* [[ !!#### Not Mule-friendly ]] - Doesn't matter, XLFDs are HPC (old) or Latin1 (modern). If they - aren't, who knows what they are? -- sjt */ - if (result == 0 || (strcmp (result, names [count]) < 0)) - result = names [count]; -#endif - - if (result) - result = xstrdup (result); - if (names) - XFreeFontNames (names); - - return result; /* this must be freed by caller if non-0 */ -} - -static Lisp_Object -x_font_truename (Display *dpy, Extbyte *name, XFontStruct *font) -{ - Extbyte *truename_FONT = 0; - Extbyte *truename_random = 0; - Extbyte *truename = 0; - - /* The search order is: - - if FONT property exists, and is a valid name, return it. - - if the other props exist, and add up to a valid name, return it. - - if we find a matching name with XListFonts, return it. - - if FONT property exists, return it regardless. - - if other props exist, return the resultant name regardless. - - else return 0. - */ - - truename = truename_FONT = truename_via_FONT_prop (dpy, font); - if (truename && !valid_x_font_name_p (dpy, truename)) - truename = 0; - if (!truename) - truename = truename_random = truename_via_random_props (dpy, font); - if (truename && !valid_x_font_name_p (dpy, truename)) - truename = 0; - if (!truename && name) - truename = truename_via_XListFonts (dpy, name); - - if (!truename) - { - /* Gag - we weren't able to find a seemingly-valid truename. - Well, maybe we're on one of those braindead systems where - XListFonts() and XLoadFont() are in violent disagreement. - If we were able to compute a truename, try using that even - if evidence suggests that it's not a valid name - because - maybe it is, really, and that's better than nothing. - X Windows: You'll envy the dead. - */ - if (truename_FONT) - truename = truename_FONT; - else if (truename_random) - truename = truename_random; - } - - /* One or both of these are not being used - free them. */ - if (truename_FONT && truename_FONT != truename) - XFree (truename_FONT); - if (truename_random && truename_random != truename) - XFree (truename_random); - - if (truename) - { - Lisp_Object result = build_extstring (truename, Qx_font_name_encoding); - XFree (truename); - return result; - } - else - return Qnil; -} - -static Lisp_Object -x_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb) -{ - struct device *d = XDEVICE (f->device); - Display *dpy = DEVICE_X_DISPLAY (d); - Extbyte *nameext; - - /* #### restructure this so that we return a valid truename at the end, - and otherwise only return when we return something desperate that - doesn't get stored for future use. */ - -#ifdef HAVE_XFT - /* First, try an Xft font. */ - if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f)) - { - /* The font is already open, we just unparse. */ - FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern); - if (! FONT_INSTANCE_X_XFTFONT (f)->pattern) - { - maybe_signal_error (Qgui_error, - "Xft font present but lacks pattern", - wrap_font_instance(f), Qfont, errb); - } - if (res) - { - FONT_INSTANCE_TRUENAME (f) = - build_extstring ((Extbyte *) res, Qfc_font_name_encoding); - free (res); - return FONT_INSTANCE_TRUENAME (f); - } - else - { - maybe_signal_error (Qgui_error, - "Couldn't unparse Xft font to truename", - wrap_font_instance(f), Qfont, errb); - /* used to return Qnil here */ - } - } -#endif /* HAVE_XFT */ - - /* OK, fall back to core font. */ - if (NILP (FONT_INSTANCE_TRUENAME (f)) - && FONT_INSTANCE_X_FONT (f)) - { - nameext = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); - FONT_INSTANCE_TRUENAME (f) = - x_font_truename (dpy, nameext, FONT_INSTANCE_X_FONT (f)); - } - - if (NILP (FONT_INSTANCE_TRUENAME (f))) - { - /* Urk, no luck. Whine about our bad luck and exit. */ - Lisp_Object font_instance = wrap_font_instance (f); - - - maybe_signal_error (Qgui_error, "Couldn't determine font truename", - font_instance, Qfont, errb); - /* Ok, just this once, return the font name as the truename. - (This is only used by Fequal() right now.) */ - return f->name; - } - - /* Return what we found. */ - return FONT_INSTANCE_TRUENAME (f); -} - -static Lisp_Object -x_font_instance_properties (Lisp_Font_Instance *f) -{ - struct device *d = XDEVICE (f->device); - int i; - Lisp_Object result = Qnil; - Display *dpy = DEVICE_X_DISPLAY (d); - XFontProp *props = NULL; - - /* #### really should hack Xft fonts, too - Strategy: fontconfig must have an iterator for this purpose. */ - if (! FONT_INSTANCE_X_FONT (f)) return result; - - props = FONT_INSTANCE_X_FONT (f)->properties; - for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) - { - Lisp_Object name, value; - Atom atom = props [i].name; - Ibyte *name_str = 0; - Bytecount name_len; - Extbyte *namestrext = XGetAtomName (dpy, atom); - - if (namestrext) - TO_INTERNAL_FORMAT (C_STRING, namestrext, - ALLOCA, (name_str, name_len), - Qx_atom_name_encoding); - - name = (name_str ? intern_istring (name_str) : Qnil); - if (name_str && - (atom == XA_FONT || - atom == DEVICE_XATOM_FOUNDRY (d) || - atom == DEVICE_XATOM_FAMILY_NAME (d) || - atom == DEVICE_XATOM_WEIGHT_NAME (d) || - atom == DEVICE_XATOM_SLANT (d) || - atom == DEVICE_XATOM_SETWIDTH_NAME (d) || - atom == DEVICE_XATOM_ADD_STYLE_NAME (d) || - atom == DEVICE_XATOM_SPACING (d) || - atom == DEVICE_XATOM_CHARSET_REGISTRY (d) || - atom == DEVICE_XATOM_CHARSET_ENCODING (d) || - !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") || - !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") || - !qxestrcmp_ascii (name_str, "CLASSIFICATION") || - !qxestrcmp_ascii (name_str, "COPYRIGHT") || - !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") || - !qxestrcmp_ascii (name_str, "FULL_NAME") || - !qxestrcmp_ascii (name_str, "MONOSPACED") || - !qxestrcmp_ascii (name_str, "QUALITY") || - !qxestrcmp_ascii (name_str, "RELATIVE_SET") || - !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") || - !qxestrcmp_ascii (name_str, "STYLE"))) - { - Extbyte *val_str = XGetAtomName (dpy, props [i].card32); - - value = (val_str ? build_extstring (val_str, Qx_atom_name_encoding) - : Qnil); - } - else - value = make_int (props [i].card32); - if (namestrext) XFree (namestrext); - result = Fcons (Fcons (name, value), result); - } - return result; -} - -static Lisp_Object -x_font_list (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber) -{ - Extbyte **names; - int count = 0; - int max_number = MAX_FONT_COUNT; - Lisp_Object result = Qnil; - const Extbyte *patternext; - - patternext = LISP_STRING_TO_EXTERNAL (pattern, Qx_font_name_encoding); - - if (!NILP(maxnumber) && INTP(maxnumber)) - { - max_number = XINT(maxnumber); - } - - names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)), - patternext, max_number, &count); - while (count--) - result = Fcons (build_extstring (names[count], Qx_font_name_encoding), - result); - if (names) - XFreeFontNames (names); - return result; -} - -/* Include the charset support, shared, for the moment, with GTK. */ -#define THIS_IS_X -#include "objects-xlike-inc.c" - - -/************************************************************************/ -/* initialization */ -/************************************************************************/ - -void -syms_of_objects_x (void) -{ -} - -void -console_type_create_objects_x (void) -{ - /* object methods */ - - CONSOLE_HAS_METHOD (x, initialize_color_instance); - CONSOLE_HAS_METHOD (x, print_color_instance); - CONSOLE_HAS_METHOD (x, finalize_color_instance); - CONSOLE_HAS_METHOD (x, color_instance_equal); - CONSOLE_HAS_METHOD (x, color_instance_hash); - CONSOLE_HAS_METHOD (x, color_instance_rgb_components); - CONSOLE_HAS_METHOD (x, valid_color_name_p); - CONSOLE_HAS_METHOD (x, color_list); - - CONSOLE_HAS_METHOD (x, initialize_font_instance); - CONSOLE_HAS_METHOD (x, print_font_instance); - CONSOLE_HAS_METHOD (x, finalize_font_instance); - CONSOLE_HAS_METHOD (x, font_instance_truename); - CONSOLE_HAS_METHOD (x, font_instance_properties); - CONSOLE_HAS_METHOD (x, font_list); -#ifdef MULE - CONSOLE_HAS_METHOD (x, find_charset_font); - CONSOLE_HAS_METHOD (x, font_spec_matches_charset); -#endif -} - -void -vars_of_objects_x (void) -{ -#ifdef DEBUG_XEMACS - DEFVAR_INT ("debug-x-objects", &debug_x_objects /* -If non-zero, display debug information about X objects -*/ ); - debug_x_objects = 0; -#endif - - DEFVAR_BOOL ("x-handle-non-fully-specified-fonts", - &x_handle_non_fully_specified_fonts /* -If this is true then fonts which do not have all characters specified -will be considered to be proportional width even if they are actually -fixed-width. If this is not done then characters which are supposed to -have 0 width may appear to actually have some width. - -Note: While setting this to t guarantees correct output in all -circumstances, it also causes a noticeable performance hit when using -fixed-width fonts. Since most people don't use characters which could -cause problems this is set to nil by default. -*/ ); - x_handle_non_fully_specified_fonts = 0; - -#ifdef HAVE_XFT - Fprovide (intern ("xft-fonts")); -#endif -} - -void -Xatoms_of_objects_x (struct device *d) -{ - Display *D = DEVICE_X_DISPLAY (d); - - DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False); - DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False); - DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False); - DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False); - DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False); - DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False); - DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False); - DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False); - DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False); - DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False); - DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False); - DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False); - DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False); - DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False); -}
--- a/src/objects-x.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* X-specific Lisp objects. - Copyright (C) 1993, 1994 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* This file Mule-ized (more like Mule-verified) by Ben Wing, 7-10-00. */ - -#ifndef INCLUDED_objects_x_h_ -#define INCLUDED_objects_x_h_ - -#include "objects.h" -#include "../lwlib/lwlib-colors.h" /* for x_allocate_nearest_color */ - -#ifdef HAVE_X_WINDOWS - -#ifdef HAVE_XFT -EXFUN (Ffc_font_real_pattern, 2); -#endif - -/* Lisp_Object Fxlfd_font_name_p; */ - -#endif /* HAVE_X_WINDOWS */ - -#endif /* INCLUDED_objects_x_h_ */
--- a/src/objects-xlike-inc.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,878 +0,0 @@ -/* Common code between X and GTK -- fonts and colors. - Copyright (C) 1991-5, 1997 Free Software Foundation, Inc. - Copyright (C) 1995 Sun Microsystems, Inc. - Copyright (C) 1996, 2001, 2002, 2003, 2010 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -/* Before including this file, you need to define either THIS_IS_X or - THIS_IS_GTK. */ - -/* See comment at top of console-xlike-inc.h for an explanation of - how this file works. */ - -/* Pango is ready for prime-time now, as far as I understand it. The GTK - people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12 - CET 2006) */ - -#include "console-xlike-inc.h" - -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) - -#ifdef DEBUG_XEMACS -# define DEBUG_OBJECTS(FORMAT, ...) \ - do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0) -#else /* DEBUG_XEMACS */ -# define DEBUG_OBJECTS(format, ...) -#endif /* DEBUG_XEMACS */ - -#elif defined(__GNUC__) - -#ifdef DEBUG_XEMACS -# define DEBUG_OBJECTS(format, args...) \ - do { if (debug_x_objects) stderr_out(format, args ); } while (0) -#else /* DEBUG_XEMACS */ -# define DEBUG_OBJECTS(format, args...) -#endif /* DEBUG_XEMACS */ - -#else /* defined(__STDC_VERSION__) [...] */ -# define DEBUG_OBJECTS (void) -#endif - -#ifdef MULE - -/* For some code it's reasonable to have only one copy and conditionalize - at run-time. For other code it isn't. */ - -static int -count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen) -{ - int hyphen_count = 0; - const Ibyte *hyphening = str; - const Ibyte *new_hyphening; - - for (hyphen_count = 0; - NULL != (new_hyphening = (Ibyte *) memchr((const void *)hyphening, '-', length)); - hyphen_count++) - { - ++new_hyphening; - length -= new_hyphening - hyphening; - hyphening = new_hyphening; - } - - if (NULL != last_hyphen) - { - *last_hyphen = (Ibyte *)hyphening; - } - - return hyphen_count; -} - -static int -XFUN (font_spec_matches_charset) (struct device * USED_IF_XFT (d), - Lisp_Object charset, - const Ibyte *nonreloc, Lisp_Object reloc, - Bytecount offset, Bytecount length, - enum font_specifier_matchspec_stages stage) -{ - Lisp_Object registries = Qnil; - long i, registries_len; - const Ibyte *the_nonreloc; - Bytecount the_length; - - the_nonreloc = nonreloc; - the_length = length; - - if (!the_nonreloc) - the_nonreloc = XSTRING_DATA (reloc); - fixup_internal_substring (nonreloc, reloc, offset, &the_length); - the_nonreloc += offset; - -#ifdef USE_XFT - if (stage == STAGE_FINAL) - { - Display *dpy = DEVICE_X_DISPLAY (d); - Extbyte *extname; - XftFont *rf; - const Ibyte *the_nonreloc; - - if (!NILP(reloc)) - { - the_nonreloc = XSTRING_DATA (reloc); - extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding); - rf = xft_open_font_by_name (dpy, extname); - return 0; /* #### maybe this will compile and run ;) */ - /* Jesus, Stephen, what the fuck? */ - } - } -#endif - - /* Hmm, this smells bad. */ - if (NILP (charset)) - return 1; - - /* Hack! Short font names don't have the registry in them, - so we just assume the user knows what they're doing in the - case of ASCII. For other charsets, you gotta give the - long form; sorry buster. - #### FMH: this screws fontconfig/Xft? - STRATEGY: use fontconfig's ability to hack languages and character - sets (lang and charset properties). - #### Maybe we can use the fontconfig model to eliminate the difference - between faces and fonts? No - it looks like that would be an abuse - (fontconfig doesn't know about colors, although Xft does). - */ - if (EQ (charset, Vcharset_ascii) && - (!memchr (the_nonreloc, '*', the_length)) - && (5 > (count_hyphens(the_nonreloc, the_length, NULL)))) - { - return 1; - } - - if (STAGE_FINAL == stage) - { - registries = Qunicode_registries; - } - else if (STAGE_INITIAL == stage) - { - registries = XCHARSET_REGISTRIES (charset); - if (NILP(registries)) - { - return 0; - } - } - else assert(0); - - CHECK_VECTOR (registries); - registries_len = XVECTOR_LENGTH(registries); - - for (i = 0; i < registries_len; ++i) - { - if (!(STRINGP(XVECTOR_DATA(registries)[i])) - || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length)) - { - continue; - } - - /* Check if the font spec ends in the registry specified. X11 says - this comparison is case insensitive: XLFD, section 3.11: - - "Alphabetic case distinctions are allowed but are for human - readability concerns only. Conforming X servers will perform - matching on font name query or open requests independent of case." */ - if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]), - the_nonreloc + (the_length - - XSTRING_LENGTH - (XVECTOR_DATA(registries)[i])))) - { - return 1; - } - } - return 0; -} - -static Lisp_Object -xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd, - Lisp_Object charset, - enum font_specifier_matchspec_stages stage) -{ - Extbyte **names; - Lisp_Object result = Qnil; - int count = 0, i; - DECLARE_EISTRING(ei_single_result); - - names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)), - xlfd, MAX_FONT_COUNT, &count); - - for (i = 0; i < count; ++i) - { - eireset(ei_single_result); - eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding); - - if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset, - (XDEVICE (device), charset, - eidata(ei_single_result), Qnil, 0, - -1, stage), 0)) - { - result = eimake_string(ei_single_result); - DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n", - eidata(ei_single_result)); - break; - } - } - - if (names) - { - XFreeFontNames (names); - } - - return result; -} - -#ifdef USE_XFT -/* #### debug functions: find a better place for us */ -const char *FcResultToString (FcResult r); -const char * -FcResultToString (FcResult r) -{ - static char buffer[256]; - switch (r) - { - case FcResultMatch: - return "FcResultMatch"; - case FcResultNoMatch: - return "FcResultNoMatch"; - case FcResultTypeMismatch: - return "FcResultTypeMismatch"; - case FcResultNoId: - return "FcResultNoId"; - default: - snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r); - return buffer; - } -} - -const char *FcTypeOfValueToString (FcValue v); -const char * -FcTypeOfValueToString (FcValue v) -{ - static char buffer[256]; - switch (v.type) - { - case FcTypeMatrix: - return "FcTypeMatrix"; - case FcTypeString: - return "FcTypeString"; - case FcTypeVoid: - return "FcTypeVoid"; - case FcTypeDouble: - return "FcTypeDouble"; - case FcTypeInteger: - return "FcTypeInteger"; - case FcTypeBool: - return "FcTypeBool"; - case FcTypeCharSet: - return "FcTypeCharSet"; - case FcTypeLangSet: - return "FcTypeLangSet"; - /* #### There is no union member of this type, but there are void* and - FcPattern* members, as of fontconfig.h FC_VERSION 10002 */ - case FcTypeFTFace: - return "FcTypeFTFace"; - default: - snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type); - return buffer; - } -} - -static FcCharSet * -mule_to_fc_charset (Lisp_Object cs) -{ - int ucode, i, j; - FcCharSet *fccs; - - CHECK_CHARSET (cs); - fccs = FcCharSetCreate (); - /* #### do we also need to deal with 94 vs. 96 charsets? - ie, how are SP and DEL treated in ASCII? non-graphic should return -1 */ - if (1 == XCHARSET_DIMENSION (cs)) - /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ - for (i = 0; i < 96; i++) - { - ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i]; - if (ucode >= 0) - /* #### should check for allocation failure */ - FcCharSetAddChar (fccs, (FcChar32) ucode); - } - else if (2 == XCHARSET_DIMENSION (cs)) - /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ - for (i = 0; i < 96; i++) - for (j = 0; j < 96; j++) - { - ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j]; - if (ucode >= 0) - /* #### should check for allocation failure */ - FcCharSetAddChar (fccs, (FcChar32) ucode); - } - else - { - FcCharSetDestroy (fccs); - fccs = NULL; - } - return fccs; -} - -struct charset_reporter { - Lisp_Object *charset; - /* This is a debug facility, require ASCII. */ - const Ascbyte *language; /* ASCII, please */ - /* Technically this is FcChar8, but fsckin' GCC 4 bitches. - RFC 3066 is a combination of ISO 639 and ISO 3166. */ - const Ascbyte *rfc3066; /* ASCII, please */ -}; - -static struct charset_reporter charset_table[] = - { - /* #### It's my branch, my favorite charsets get checked first! - That's a joke, Son. - Ie, I don't know what I'm doing, so my charsets first is as good as - any other arbitrary order. If you have a better idea, speak up! */ - { &Vcharset_ascii, "English", "en" }, - { &Vcharset_japanese_jisx0208, "Japanese", "ja" }, - { &Vcharset_japanese_jisx0212, "Japanese", "ja" }, - { &Vcharset_katakana_jisx0201, "Japanese", "ja" }, - { &Vcharset_latin_jisx0201, "Japanese", "ja" }, - { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" }, - { &Vcharset_greek_iso8859_7, "Greek", "el" }, - /* #### all the Chinese need checking - Damn the blood-sucking ISO anyway. */ - { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-cn" }, - { &Vcharset_korean_ksc5601, "Korean", "ko" }, - { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-tw" }, - { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-tw" }, - /* #### not obvious how to handle these - We could (for experimental purposes) make the last element into - an array of ISO 639 codes, and check for all of them. If a font - provides some but not others, warn. */ - { &Vcharset_latin_iso8859_1, NULL, NULL }, - { &Vcharset_latin_iso8859_2, NULL, NULL }, - { &Vcharset_latin_iso8859_3, NULL, NULL }, - { &Vcharset_latin_iso8859_4, NULL, NULL }, - { &Vcharset_latin_iso8859_9, NULL, NULL }, - { &Vcharset_latin_iso8859_15, NULL, NULL }, - { &Vcharset_thai_tis620, "Thai", "th" }, - /* We don't have an arabic charset. bidi issues, I guess? */ - /* { &Vcharset_arabic_iso8859_6, "Arabic", "ar" }, */ - { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" }, - /* #### probably close enough for Ukraine? */ - { &Vcharset_cyrillic_iso8859_5, "Russian", "ru" }, - /* #### these probably are not quite right */ - { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-tw" }, - { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-tw" }, - { NULL, NULL, NULL } - }; - -/* Choose appropriate font name for debug messages. - Use only in the top half of next function (enforced with #undef). */ -#define DECLARE_DEBUG_FONTNAME(__xemacs_name) \ - Eistring *__xemacs_name; \ - do \ - { \ - __xemacs_name = debug_xft > 2 ? eistr_fullname \ - : debug_xft > 1 ? eistr_longname \ - : eistr_shortname; \ - } while (0) - -static Lisp_Object -xft_find_charset_font (Lisp_Object font, Lisp_Object charset, - enum font_specifier_matchspec_stages stage) -{ - const Extbyte *patternext; - Lisp_Object result = Qnil; - - /* #### with Xft need to handle second stage here -- sjt - Hm. Or maybe not. That would be cool. :-) */ - if (stage == STAGE_FINAL) - return Qnil; - - /* Fontconfig converts all FreeType names to UTF-8 before passing them - back to callers---see fcfreetype.c (FcFreeTypeQuery). - I don't believe this is documented. */ - - DEBUG_XFT1 (1, "confirming charset for font instance %s\n", - XSTRING_DATA(font)); - - /* #### this looks like a fair amount of work, but the basic design - has never been rethought, and it should be - - what really should happen here is that we use FcFontSort (FcFontList?) - to get a list of matching fonts, then pick the first (best) one that - gives language or repertoire coverage. - */ - - FcInit (); /* No-op if already initialized. - In fontconfig 2.3.2, this cannot return - failure, but that looks like a bug. We - check for it with FcGetCurrentConfig(), - which *can* fail. */ - if (!FcConfigGetCurrent()) - stderr_out ("Failed fontconfig initialization\n"); - else - { - FcPattern *fontxft; /* long-lived, freed at end of this block */ - FcResult fcresult; - FcConfig *fcc; - const Ascbyte *lang = "en"; - FcCharSet *fccs = NULL; - DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */ - DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */ - DECLARE_EISTRING (eistr_fullname); /* everything */ - - patternext = LISP_STRING_TO_EXTERNAL (font, Qfc_font_name_encoding); - fcc = FcConfigGetCurrent (); - - /* parse the name, do the substitutions, and match the font */ - - { - FcPattern *p = FcNameParse ((FcChar8 *) patternext); - PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p); - /* #### Next two return FcBool, but what does the return mean? */ - /* The order is correct according the fontconfig docs. */ - FcConfigSubstitute (fcc, p, FcMatchPattern); - PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p); - FcDefaultSubstitute (p); - PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p); - /* #### check fcresult of following match? */ - fcresult = FcResultMatch; - fontxft = FcFontMatch (fcc, p, &fcresult); - switch (fcresult) - { - /* case FcResultOutOfMemory: */ - case FcResultNoMatch: - case FcResultTypeMismatch: - case FcResultNoId: - break; - case FcResultMatch: - /* this prints the long fontconfig name */ - PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft); - break; - } - FcPatternDestroy (p); - } - - /* heuristic to give reasonable-length names for debug reports - - I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's - pointless. We're just going to remove this code once the font/ - face refactoring is done, but until then it could be very useful. - */ - { - FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft); - Extbyte *name; - - /* full name, including language coverage and repertoire */ - name = (Extbyte *) FcNameUnparse (p); - eicpy_ext (eistr_fullname, - (name ? name : "NOT FOUND"), - Qfc_font_name_encoding); - if (name) free (name); - - /* long name, omitting coverage and repertoire, plus a number - of rarely useful properties */ - FcPatternDel (p, FC_CHARSET); - FcPatternDel (p, FC_LANG); -#ifdef FC_WIDTH - FcPatternDel (p, FC_WIDTH); -#endif - FcPatternDel (p, FC_SPACING); - FcPatternDel (p, FC_HINTING); - FcPatternDel (p, FC_VERTICAL_LAYOUT); - FcPatternDel (p, FC_AUTOHINT); - FcPatternDel (p, FC_GLOBAL_ADVANCE); - FcPatternDel (p, FC_INDEX); - FcPatternDel (p, FC_SCALE); - FcPatternDel (p, FC_FONTVERSION); - name = (Extbyte *) FcNameUnparse (p); - eicpy_ext (eistr_longname, - (name ? name : "NOT FOUND"), - Qfc_font_name_encoding); - if (name) free (name); - - /* nickname, just family and size, but - "family" names usually have style, slant, and weight */ - FcPatternDel (p, FC_FOUNDRY); - FcPatternDel (p, FC_STYLE); - FcPatternDel (p, FC_SLANT); - FcPatternDel (p, FC_WEIGHT); - FcPatternDel (p, FC_PIXEL_SIZE); - FcPatternDel (p, FC_OUTLINE); - FcPatternDel (p, FC_SCALABLE); - FcPatternDel (p, FC_DPI); - name = (Extbyte *) FcNameUnparse (p); - eicpy_ext (eistr_shortname, - (name ? name : "NOT FOUND"), - Qfc_font_name_encoding); - if (name) free (name); - - FcPatternDestroy (p); - } - - /* The language approach may better in the long run, but we can't use - it based on Mule charsets; fontconfig doesn't provide a way to test - for unions of languages, etc. That will require support from the - text module. - - Optimization: cache the generated FcCharSet in the Mule charset. - Don't forget to destroy it if the Mule charset gets deallocated. */ - - { - /* This block possibly should be a function, but it generates - multiple values. I find the "pass an address to return the - value in" idiom opaque, so prefer a block. */ - struct charset_reporter *cr; - for (cr = charset_table; - cr->charset && !EQ (*(cr->charset), charset); - cr++) - ; - - if (cr->rfc3066) - { - DECLARE_DEBUG_FONTNAME (name); - CHECKING_LANG (0, eidata(name), cr->language); - lang = cr->rfc3066; - } - else if (cr->charset) - { - /* what the hey, build 'em on the fly */ - /* #### in the case of error this could return NULL! */ - fccs = mule_to_fc_charset (charset); - /* #### Bad idea here */ - lang = (const Ascbyte *) XSTRING_DATA (XSYMBOL (XCHARSET_NAME - (charset))->name); - } - else - { - /* OK, we fell off the end of the table */ - warn_when_safe_lispobj (intern ("xft"), intern ("alert"), - list2 (build_ascstring ("unchecked charset"), - charset)); - /* default to "en" - #### THIS IS WRONG, WRONG, WRONG!! - It is why we never fall through to XLFD-checking. */ - } - - ASSERT_ASCTEXT_ASCII (lang); - - if (fccs) - { - /* check for character set coverage */ - int i = 0; - FcCharSet *v; - FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v); - - if (r == FcResultTypeMismatch) - { - DEBUG_XFT0 (0, "Unexpected type return in charset value\n"); - result = Qnil; - } - else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v)) - { - /* The full pattern with the bitmap coverage is massively - unwieldy, but the shorter names are just *wrong*. We - should have the full thing internally as truename, and - filter stuff the client doesn't want to see on output. - Should we just store it into the truename right here? */ - DECLARE_DEBUG_FONTNAME (name); - DEBUG_XFT2 (0, "Xft font %s supports %s\n", - eidata(name), lang); -#ifdef RETURN_LONG_FONTCONFIG_NAMES - result = eimake_string(eistr_fullname); -#else - result = eimake_string(eistr_longname); -#endif - } - else - { - DECLARE_DEBUG_FONTNAME (name); - DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", - eidata(name), lang); - result = Qnil; - } - - /* clean up */ - FcCharSetDestroy (fccs); - } - else - { - /* check for language coverage */ - int i = 0; - FcValue v; - /* the main event */ - FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v); - - if (r == FcResultMatch) - { - if (v.type != FcTypeLangSet) /* excessive paranoia */ - { - ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v)); - /* Urk! Fall back and punt to core font. */ - DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n", - FcTypeOfValueToString (v)); - result = Qnil; - } - else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang) - != FcLangDifferentLang) - { - DECLARE_DEBUG_FONTNAME (name); - DEBUG_XFT2 (0, "Xft font %s supports %s\n", - eidata(name), lang); -#ifdef RETURN_LONG_FONTCONFIG_NAMES - result = eimake_string(eistr_fullname); -#else - result = eimake_string(eistr_longname); -#endif - } - else - { - DECLARE_DEBUG_FONTNAME (name); - DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", - eidata(name), lang); - result = Qnil; - } - } - else - { - ASSERT_ASCTEXT_ASCII(FcResultToString(r)); - DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n", - FcResultToString (r)); - result = Qnil; - } - } - - /* clean up and maybe return */ - FcPatternDestroy (fontxft); - if (!UNBOUNDP (result)) - return result; - } - } - return Qnil; -} -#undef DECLARE_DEBUG_FONTNAME - -#endif /* USE_XFT */ - -/* find a font spec that matches font spec FONT and also matches - (the registry of) CHARSET. */ -static Lisp_Object -XFUN (find_charset_font) (Lisp_Object device, Lisp_Object font, - Lisp_Object charset, - enum font_specifier_matchspec_stages stage) -{ - Lisp_Object result = Qnil, registries = Qnil; - int j, hyphen_count, registries_len = 0; - Ibyte *hyphening, *new_hyphening; - Bytecount xlfd_length; - - DECLARE_EISTRING(ei_xlfd_without_registry); - DECLARE_EISTRING(ei_xlfd); - -#ifdef USE_XFT - result = xft_find_charset_font(font, charset, stage); - if (!NILP(result)) - { - return result; - } -#endif - - switch (stage) - { - case STAGE_INITIAL: - { - if (!(NILP(XCHARSET_REGISTRIES(charset))) - && VECTORP(XCHARSET_REGISTRIES(charset))) - { - registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset)); - registries = XCHARSET_REGISTRIES(charset); - } - break; - } - case STAGE_FINAL: - { - registries_len = 1; - registries = Qunicode_registries; - break; - } - default: - { - assert(0); - break; - } - } - - eicpy_lstr(ei_xlfd, font); - hyphening = eidata(ei_xlfd); - xlfd_length = eilen(ei_xlfd); - - /* Count the hyphens in the string, moving new_hyphening to just after the - last one. */ - hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening); - - if (0 == registries_len || (5 > hyphen_count && - !(1 == xlfd_length && '*' == *hyphening))) - { - /* No proper XLFD specified, or we can't modify the pattern to change - the registry and encoding to match what we want, or we have no - information on the registry needed. */ - eito_external(ei_xlfd, Qx_font_name_encoding); - DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", - eidata(ei_xlfd)); - result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), - charset, stage); - /* No need to loop through the available registries; return - immediately. */ - return result; - } - else if (1 == xlfd_length && '*' == *hyphening) - { - /* It's a single asterisk. We can add the registry directly to the - end. */ - eicpy_ch(ei_xlfd_without_registry, '*'); - } - else - { - /* It's a fully-specified XLFD. Work out where the registry and - encoding are, and initialise ei_xlfd_without_registry to the string - without them. */ - - /* count_hyphens has set new_hyphening to just after the last - hyphen. Move back to just after the hyphen before it. */ - - for (new_hyphening -= 2; new_hyphening > hyphening - && '-' != *new_hyphening; --new_hyphening) - ; - ++new_hyphening; - - eicpy_ei(ei_xlfd_without_registry, ei_xlfd); - - /* Manipulate ei_xlfd_without_registry, using the information about - ei_xlfd, to which it's identical. */ - eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1, - eilen(ei_xlfd) - (new_hyphening - hyphening), -1); - - } - - /* Now, loop through the registries and encodings defined for this - charset, doing an XListFonts each time with the pattern modified to - specify the regisry and encoding. This avoids huge amounts of IPC and - duplicated searching; now we use the searching the X server was doing - anyway, where before the X server did its search, transferred huge - amounts of data, and then we proceeded to do a regexp search on that - data. */ - for (j = 0; j < registries_len && NILP(result); ++j) - { - eireset(ei_xlfd); - eicpy_ei(ei_xlfd, ei_xlfd_without_registry); - - eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]); - - eito_external(ei_xlfd, Qx_font_name_encoding); - - DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", - eidata(ei_xlfd)); - result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), - charset, stage); - } - - /* In the event that the charset is ASCII and we haven't matched - anything up to now, even with a pattern of "*", add "iso8859-1" - to the charset's registry and try again. Not returning a result - for ASCII means our frame geometry calculations are - inconsistent, and that we may crash. */ - - if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result) - && ('*' == eigetch(ei_xlfd_without_registry, 0))) - - { - int have_latin1 = 0; - - /* Set this to, for example, is08859-1 if you want to see the - error behaviour. */ - -#define FALLBACK_ASCII_REGISTRY "iso8859-1" - - for (j = 0; j < registries_len; ++j) - { - if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]), - (Ibyte *) FALLBACK_ASCII_REGISTRY)) - { - have_latin1 = 1; - break; - } - } - - if (!have_latin1) - { - Lisp_Object new_registries = make_vector(registries_len + 1, Qnil); - - XVECTOR_DATA(new_registries)[0] - = build_ascstring(FALLBACK_ASCII_REGISTRY); - - memcpy(XVECTOR_DATA(new_registries) + 1, - XVECTOR_DATA(registries), - sizeof XVECTOR_DATA(registries)[0] * - XVECTOR_LENGTH(registries)); - - /* Calling set_charset_registries instead of overwriting the - value directly, to allow the charset font caches to be - invalidated and a change to the default face to be - noted. */ - set_charset_registries(charset, new_registries); - - warn_when_safe (Qface, Qwarning, - "Your ASCII charset registries contain nothing " - "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'."); - - /* And recurse. */ - result = - DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font, - (device, font, charset, stage), - result); - } - else - { - DECLARE_EISTRING (ei_connection_name); - - /* We preserve a copy of the connection name for the error message - after the device is deleted. */ - eicpy_lstr (ei_connection_name, - DEVICE_CONNECTION (XDEVICE(device))); - - stderr_out ("Cannot find a font for ASCII, deleting device on %s\n", - eidata (ei_connection_name)); - - io_error_delete_device (device); - - /* Do a normal warning in the event that we have other, non-X - frames available. (If we don't, io_error_delete_device will - have exited.) */ - warn_when_safe - (Qface, Qerror, - "Cannot find a font for ASCII, deleting device on %s.\n" - "\n" - "Your X server fonts appear to be inconsistent; fix them, or\n" - "the next frame you create on that DISPLAY will crash this\n" - "XEmacs. At a minimum, provide one font with an XLFD ending\n" - "in `" FALLBACK_ASCII_REGISTRY "', so we can work out what size\n" - "a frame should be. ", - eidata (ei_connection_name)); - } - - } - - /* This function used to return the font spec, in the case where a font - didn't exist on the X server but it did match the charset. We're not - doing that any more, because none of the other platform code does, and - the old behaviour was badly-judged in other respects, so I don't trust - the original author to have had a good reason for it. */ - - return result; -} - -#endif /* MULE */
--- a/src/objects.c Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1468 +0,0 @@ -/* Generic Objects and Functions. - Copyright (C) 1995 Free Software Foundation, Inc. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002, 2004, 2005, 2010 Ben Wing. - Copyright (C) 2010 Didier Verna - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#include <config.h> -#include "lisp.h" - -#include "buffer.h" -#include "device-impl.h" -#include "elhash.h" -#include "faces.h" -#include "frame.h" -#include "glyphs.h" -#include "objects-impl.h" -#include "specifier.h" -#include "window.h" - -#ifdef HAVE_TTY -#include "console-tty.h" -#endif - -/* Objects that are substituted when an instantiation fails. - If we leave in the Qunbound value, we will probably get crashes. */ -Lisp_Object Vthe_null_color_instance, Vthe_null_font_instance; - -/* Author: Ben Wing; some earlier code from Chuck Thompson, Jamie - Zawinski. */ - -DOESNT_RETURN -finalose (void *ptr) -{ - Lisp_Object obj = wrap_pointer_1 (ptr); - - invalid_operation - ("Can't dump an emacs containing window system objects", obj); -} - - -/**************************************************************************** - * Color-Instance Object * - ****************************************************************************/ - -Lisp_Object Qcolor_instancep; - -static const struct memory_description color_instance_data_description_1 []= { -#ifdef HAVE_TTY -#ifdef NEW_GC - { XD_LISP_OBJECT, tty_console }, -#else /* not NEW_GC */ - { XD_BLOCK_PTR, tty_console, 1, { &tty_color_instance_data_description } }, -#endif /* not NEW_GC */ -#endif - { XD_END } -}; - -static const struct sized_memory_description color_instance_data_description = { - sizeof (void *), color_instance_data_description_1 -}; - -static const struct memory_description color_instance_description[] = { - { XD_INT, offsetof (Lisp_Color_Instance, color_instance_type) }, - { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, name)}, - { XD_LISP_OBJECT, offsetof (Lisp_Color_Instance, device)}, - { XD_UNION, offsetof (Lisp_Color_Instance, data), - XD_INDIRECT (0, 0), { &color_instance_data_description } }, - {XD_END} -}; - -static Lisp_Object -mark_color_instance (Lisp_Object obj) -{ - Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); - mark_object (c->name); - if (!NILP (c->device)) /* Vthe_null_color_instance */ - MAYBE_DEVMETH (XDEVICE (c->device), mark_color_instance, (c)); - - return c->device; -} - -static void -print_color_instance (Lisp_Object obj, Lisp_Object printcharfun, - int escapeflag) -{ - Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); - if (print_readably) - printing_unreadable_lisp_object (obj, 0); - write_fmt_string_lisp (printcharfun, "#<color-instance %s", 1, c->name); - write_fmt_string_lisp (printcharfun, " on %s", 1, c->device); - if (!NILP (c->device)) /* Vthe_null_color_instance */ - MAYBE_DEVMETH (XDEVICE (c->device), print_color_instance, - (c, printcharfun, escapeflag)); - write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); -} - -static void -finalize_color_instance (Lisp_Object obj) -{ - Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); - - if (!NILP (c->device)) - MAYBE_DEVMETH (XDEVICE (c->device), finalize_color_instance, (c)); -} - -static int -color_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, - int UNUSED (foldcase)) -{ - Lisp_Color_Instance *c1 = XCOLOR_INSTANCE (obj1); - Lisp_Color_Instance *c2 = XCOLOR_INSTANCE (obj2); - - return (c1 == c2) || - (EQ (c1->device, c2->device) && - DEVICEP (c1->device) && - HAS_DEVMETH_P (XDEVICE (c1->device), color_instance_equal) && - DEVMETH (XDEVICE (c1->device), color_instance_equal, (c1, c2, depth))); -} - -static Hashcode -color_instance_hash (Lisp_Object obj, int depth) -{ - Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); - struct device *d = DEVICEP (c->device) ? XDEVICE (c->device) : 0; - - return HASH2 ((Hashcode) d, - !d ? LISP_HASH (obj) - : DEVMETH_OR_GIVEN (d, color_instance_hash, (c, depth), - LISP_HASH (obj))); -} - -DEFINE_NODUMP_LISP_OBJECT ("color-instance", color_instance, - mark_color_instance, print_color_instance, - finalize_color_instance, color_instance_equal, - color_instance_hash, - color_instance_description, - Lisp_Color_Instance); - -DEFUN ("make-color-instance", Fmake_color_instance, 1, 3, 0, /* -Return a new `color-instance' object named NAME (a string). - -Optional argument DEVICE specifies the device this object applies to -and defaults to the selected device. - -An error is signaled if the color is unknown or cannot be allocated; -however, if optional argument NOERROR is non-nil, nil is simply -returned in this case. (And if NOERROR is other than t, a warning may -be issued.) - -The returned object is a normal, first-class lisp object. The way you -`deallocate' the color is the way you deallocate any other lisp object: -you drop all pointers to it and allow it to be garbage collected. When -these objects are GCed, the underlying window-system data (e.g. X object) -is deallocated as well. -*/ - (name, device, noerror)) -{ - Lisp_Object obj; - Lisp_Color_Instance *c; - int retval; - - CHECK_STRING (name); - device = wrap_device (decode_device (device)); - - obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); - c = XCOLOR_INSTANCE (obj); - c->name = name; - c->device = device; - c->data = 0; - c->color_instance_type = get_console_variant (XDEVICE_TYPE (c->device)); - - retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_color_instance, - (c, name, device, - decode_error_behavior_flag (noerror))); - if (!retval) - return Qnil; - - return obj; -} - -DEFUN ("color-instance-p", Fcolor_instance_p, 1, 1, 0, /* -Return non-nil if OBJECT is a color instance. -*/ - (object)) -{ - return COLOR_INSTANCEP (object) ? Qt : Qnil; -} - -DEFUN ("color-instance-name", Fcolor_instance_name, 1, 1, 0, /* -Return the name used to allocate COLOR-INSTANCE. -*/ - (color_instance)) -{ - CHECK_COLOR_INSTANCE (color_instance); - return XCOLOR_INSTANCE (color_instance)->name; -} - -DEFUN ("color-instance-rgb-components", Fcolor_instance_rgb_components, 1, 1, 0, /* -Return a three element list containing the red, green, and blue -color components of COLOR-INSTANCE, or nil if unknown. -Component values range from 0 to 65535. -*/ - (color_instance)) -{ - Lisp_Color_Instance *c; - - CHECK_COLOR_INSTANCE (color_instance); - c = XCOLOR_INSTANCE (color_instance); - - if (NILP (c->device)) - return Qnil; - - return MAYBE_LISP_DEVMETH (XDEVICE (c->device), - color_instance_rgb_components, - (c)); -} - -DEFUN ("valid-color-name-p", Fvalid_color_name_p, 1, 2, 0, /* -Return true if COLOR names a valid color for the current device. - -Valid color names for X are listed in the file /usr/lib/X11/rgb.txt, or -whatever the equivalent is on your system. - -Valid color names for TTY are those which have an ISO 6429 (ANSI) sequence. -In addition to being a color this may be one of a number of attributes -such as `blink'. -*/ - (color, device)) -{ - struct device *d = decode_device (device); - - CHECK_STRING (color); - return MAYBE_INT_DEVMETH (d, valid_color_name_p, (d, color)) ? Qt : Qnil; -} - -DEFUN ("color-list", Fcolor_list, 0, 1, 0, /* -Return a list of color names. -DEVICE specifies which device to return names for, and defaults to the -currently selected device. -*/ - (device)) -{ - device = wrap_device (decode_device (device)); - - return MAYBE_LISP_DEVMETH (XDEVICE (device), color_list, ()); -} - - -/*************************************************************************** - * Font-Instance Object * - ***************************************************************************/ - -Lisp_Object Qfont_instancep; - -static Lisp_Object font_instance_truename_internal (Lisp_Object xfont, - Error_Behavior errb); - -static const struct memory_description font_instance_data_description_1 []= { -#ifdef HAVE_TTY -#ifdef NEW_GC - { XD_LISP_OBJECT, tty_console }, -#else /* not NEW_GC */ - { XD_BLOCK_PTR, tty_console, 1, { &tty_font_instance_data_description } }, -#endif /* not NEW_GC */ -#endif - { XD_END } -}; - -static const struct sized_memory_description font_instance_data_description = { - sizeof (void *), font_instance_data_description_1 -}; - -static const struct memory_description font_instance_description[] = { - { XD_INT, offsetof (Lisp_Font_Instance, font_instance_type) }, - { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, name)}, - { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, truename)}, - { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, device)}, - { XD_LISP_OBJECT, offsetof (Lisp_Font_Instance, charset)}, - { XD_UNION, offsetof (Lisp_Font_Instance, data), - XD_INDIRECT (0, 0), { &font_instance_data_description } }, - { XD_END } -}; - - -static Lisp_Object -mark_font_instance (Lisp_Object obj) -{ - Lisp_Font_Instance *f = XFONT_INSTANCE (obj); - - mark_object (f->name); - mark_object (f->truename); - if (!NILP (f->device)) /* Vthe_null_font_instance */ - MAYBE_DEVMETH (XDEVICE (f->device), mark_font_instance, (f)); - - return f->device; -} - -static void -print_font_instance (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) -{ - Lisp_Font_Instance *f = XFONT_INSTANCE (obj); - if (print_readably) - printing_unreadable_lisp_object (obj, 0); - write_fmt_string_lisp (printcharfun, "#<font-instance %S", 1, f->name); - write_fmt_string_lisp (printcharfun, " on %s", 1, f->device); - if (!NILP (f->device)) - { - MAYBE_DEVMETH (XDEVICE (f->device), print_font_instance, - (f, printcharfun, escapeflag)); - - } - write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); -} - -static void -finalize_font_instance (Lisp_Object obj) -{ - Lisp_Font_Instance *f = XFONT_INSTANCE (obj); - - if (!NILP (f->device)) - { - MAYBE_DEVMETH (XDEVICE (f->device), finalize_font_instance, (f)); - } -} - -/* Fonts are equal if they resolve to the same name. - Since we call `font-truename' to do this, and since font-truename is lazy, - this means the `equal' could cause XListFonts to be run the first time. - */ -static int -font_instance_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, - int UNUSED (foldcase)) -{ - /* #### should this be moved into a device method? */ - return internal_equal (font_instance_truename_internal - (obj1, ERROR_ME_DEBUG_WARN), - font_instance_truename_internal - (obj2, ERROR_ME_DEBUG_WARN), - depth + 1); -} - -static Hashcode -font_instance_hash (Lisp_Object obj, int depth) -{ - return internal_hash (font_instance_truename_internal - (obj, ERROR_ME_DEBUG_WARN), - depth + 1); -} - -DEFINE_NODUMP_LISP_OBJECT ("font-instance", font_instance, - mark_font_instance, print_font_instance, - finalize_font_instance, font_instance_equal, - font_instance_hash, font_instance_description, - Lisp_Font_Instance); - - -/* #### Why is this exposed to Lisp? Used in: -x-frob-font-size, gtk-font-menu-load-font, x-font-menu-load-font-xft, -x-font-menu-load-font-core, mswindows-font-menu-load-font, -mswindows-frob-font-style-and-sizify, mswindows-frob-font-size. */ -DEFUN ("make-font-instance", Fmake_font_instance, 1, 4, 0, /* -Return a new `font-instance' object named NAME. -DEVICE specifies the device this object applies to and defaults to the -selected device. An error is signalled if the font is unknown or cannot -be allocated; however, if NOERROR is non-nil, nil is simply returned in -this case. CHARSET is used internally. #### make helper function? - -The returned object is a normal, first-class lisp object. The way you -`deallocate' the font is the way you deallocate any other lisp object: -you drop all pointers to it and allow it to be garbage collected. When -these objects are GCed, the underlying GUI data is deallocated as well. -*/ - (name, device, noerror, charset)) -{ - Lisp_Object obj; - Lisp_Font_Instance *f; - int retval = 0; - Error_Behavior errb = decode_error_behavior_flag (noerror); - - if (ERRB_EQ (errb, ERROR_ME)) - CHECK_STRING (name); - else if (!STRINGP (name)) - return Qnil; - - device = wrap_device (decode_device (device)); - - obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); - f = XFONT_INSTANCE (obj); - f->name = name; - f->truename = Qnil; - f->device = device; - - f->data = 0; - f->font_instance_type = get_console_variant (XDEVICE_TYPE (f->device)); - - /* Stick some default values here ... */ - f->ascent = f->height = 1; - f->descent = 0; - f->width = 1; - f->charset = charset; - f->proportional_p = 0; - - retval = MAYBE_INT_DEVMETH (XDEVICE (device), initialize_font_instance, - (f, name, device, errb)); - - if (!retval) - return Qnil; - - return obj; -} - -DEFUN ("font-instance-p", Ffont_instance_p, 1, 1, 0, /* -Return non-nil if OBJECT is a font instance. -*/ - (object)) -{ - return FONT_INSTANCEP (object) ? Qt : Qnil; -} - -DEFUN ("font-instance-name", Ffont_instance_name, 1, 1, 0, /* -Return the name used to allocate FONT-INSTANCE. -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return XFONT_INSTANCE (font_instance)->name; -} - -DEFUN ("font-instance-ascent", Ffont_instance_ascent, 1, 1, 0, /* -Return the ascent in pixels of FONT-INSTANCE. -The returned value is the maximum ascent for all characters in the font, -where a character's ascent is the number of pixels above (and including) -the baseline. -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return make_int (XFONT_INSTANCE (font_instance)->ascent); -} - -DEFUN ("font-instance-descent", Ffont_instance_descent, 1, 1, 0, /* -Return the descent in pixels of FONT-INSTANCE. -The returned value is the maximum descent for all characters in the font, -where a character's descent is the number of pixels below the baseline. -\(Many characters to do not have any descent. Typical characters with a -descent are lowercase p and lowercase g.) -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return make_int (XFONT_INSTANCE (font_instance)->descent); -} - -DEFUN ("font-instance-width", Ffont_instance_width, 1, 1, 0, /* -Return the width in pixels of FONT-INSTANCE. -The returned value is the average width for all characters in the font. -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return make_int (XFONT_INSTANCE (font_instance)->width); -} - -DEFUN ("font-instance-proportional-p", Ffont_instance_proportional_p, 1, 1, 0, /* -Return whether FONT-INSTANCE is proportional. -This means that different characters in the font have different widths. -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return XFONT_INSTANCE (font_instance)->proportional_p ? Qt : Qnil; -} - -static Lisp_Object -font_instance_truename_internal (Lisp_Object font_instance, - Error_Behavior errb) -{ - Lisp_Font_Instance *f = XFONT_INSTANCE (font_instance); - - if (NILP (f->device)) - { - maybe_signal_error (Qgui_error, - "can't determine truename: " - "no device for font instance", - font_instance, Qfont, errb); - return Qnil; - } - - return DEVMETH_OR_GIVEN (XDEVICE (f->device), - font_instance_truename, (f, errb), f->name); -} - -DEFUN ("font-instance-truename", Ffont_instance_truename, 1, 1, 0, /* -Return the canonical name of FONT-INSTANCE. -Font names are patterns which may match any number of fonts, of which -the first found is used. This returns an unambiguous name for that font -\(but not necessarily its only unambiguous name). -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return font_instance_truename_internal (font_instance, ERROR_ME); -} - -DEFUN ("font-instance-charset", Ffont_instance_charset, 1, 1, 0, /* -Return the Mule charset that FONT-INSTANCE was allocated to handle. -*/ - (font_instance)) -{ - CHECK_FONT_INSTANCE (font_instance); - return XFONT_INSTANCE (font_instance)->charset; -} - -DEFUN ("font-instance-properties", Ffont_instance_properties, 1, 1, 0, /* -Return the properties (an alist or nil) of FONT-INSTANCE. -*/ - (font_instance)) -{ - Lisp_Font_Instance *f; - - CHECK_FONT_INSTANCE (font_instance); - f = XFONT_INSTANCE (font_instance); - - if (NILP (f->device)) - return Qnil; - - return MAYBE_LISP_DEVMETH (XDEVICE (f->device), - font_instance_properties, (f)); -} - -DEFUN ("font-list", Ffont_list, 1, 3, 0, /* -Return a list of font names matching the given pattern. -DEVICE specifies which device to search for names, and defaults to the -currently selected device. -*/ - (pattern, device, maxnumber)) -{ - CHECK_STRING (pattern); - device = wrap_device (decode_device (device)); - - return MAYBE_LISP_DEVMETH (XDEVICE (device), font_list, (pattern, device, - maxnumber)); -} - - -/**************************************************************************** - Color Object - ***************************************************************************/ - -static const struct memory_description color_specifier_description[] = { - { XD_LISP_OBJECT, offsetof (struct color_specifier, face) }, - { XD_LISP_OBJECT, offsetof (struct color_specifier, face_property) }, - { XD_END } -}; - -DEFINE_SPECIFIER_TYPE_WITH_DATA (color); -/* Qcolor defined in general.c */ - -static void -color_create (Lisp_Object obj) -{ - Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); - - COLOR_SPECIFIER_FACE (color) = Qnil; - COLOR_SPECIFIER_FACE_PROPERTY (color) = Qnil; -} - -static void -color_mark (Lisp_Object obj) -{ - Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); - - mark_object (COLOR_SPECIFIER_FACE (color)); - mark_object (COLOR_SPECIFIER_FACE_PROPERTY (color)); -} - -/* No equal or hash methods; ignore the face the color is based off - of for `equal' */ - -static Lisp_Object -color_instantiate (Lisp_Object specifier, Lisp_Object UNUSED (matchspec), - Lisp_Object domain, Lisp_Object instantiator, - Lisp_Object depth, int no_fallback) -{ - /* When called, we're inside of call_with_suspended_errors(), - so we can freely error. */ - Lisp_Object device = DOMAIN_DEVICE (domain); - struct device *d = XDEVICE (device); - - if (COLOR_INSTANCEP (instantiator)) - { - /* If we are on the same device then we're done. Otherwise change - the instantiator to the name used to generate the pixel and let the - STRINGP case deal with it. */ - if (NILP (device) /* Vthe_null_color_instance */ - || EQ (device, XCOLOR_INSTANCE (instantiator)->device)) - return instantiator; - else - instantiator = Fcolor_instance_name (instantiator); - } - - if (STRINGP (instantiator)) - { - /* First, look to see if we can retrieve a cached value. */ - Lisp_Object instance = - Fgethash (instantiator, d->color_instance_cache, Qunbound); - /* Otherwise, make a new one. */ - if (UNBOUNDP (instance)) - { - /* make sure we cache the failures, too. */ - instance = Fmake_color_instance (instantiator, device, Qt); - Fputhash (instantiator, instance, d->color_instance_cache); - } - - return NILP (instance) ? Qunbound : instance; - } - else if (VECTORP (instantiator)) - { - switch (XVECTOR_LENGTH (instantiator)) - { - case 0: - if (DEVICE_TTY_P (d)) - return Vthe_null_color_instance; - else - gui_error ("Color instantiator [] only valid on TTY's", - device); - - case 1: - if (NILP (COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)))) - gui_error ("Color specifier not attached to a face", - instantiator); - return (FACE_PROPERTY_INSTANCE_1 - (Fget_face (XVECTOR_DATA (instantiator)[0]), - COLOR_SPECIFIER_FACE_PROPERTY - (XCOLOR_SPECIFIER (specifier)), - domain, ERROR_ME, no_fallback, depth)); - - case 2: - return (FACE_PROPERTY_INSTANCE_1 - (Fget_face (XVECTOR_DATA (instantiator)[0]), - XVECTOR_DATA (instantiator)[1], domain, ERROR_ME, - no_fallback, depth)); - - default: - ABORT (); - } - } - else if (NILP (instantiator)) - { - if (DEVICE_TTY_P (d)) - return Vthe_null_color_instance; - else - gui_error ("Color instantiator [] only valid on TTY's", - device); - } - else - ABORT (); /* The spec validation routines are screwed up. */ - - return Qunbound; -} - -static void -color_validate (Lisp_Object instantiator) -{ - if (COLOR_INSTANCEP (instantiator) || STRINGP (instantiator)) - return; - if (VECTORP (instantiator)) - { - if (XVECTOR_LENGTH (instantiator) > 2) - sferror ("Inheritance vector must be of size 0 - 2", - instantiator); - else if (XVECTOR_LENGTH (instantiator) > 0) - { - Lisp_Object face = XVECTOR_DATA (instantiator)[0]; - - Fget_face (face); - if (XVECTOR_LENGTH (instantiator) == 2) - { - Lisp_Object field = XVECTOR_DATA (instantiator)[1]; - if (!EQ (field, Qforeground) && !EQ (field, Qbackground)) - invalid_constant - ("Inheritance field must be `foreground' or `background'", - field); - } - } - } - else - invalid_argument ("Invalid color instantiator", instantiator); -} - -static void -color_after_change (Lisp_Object specifier, Lisp_Object locale) -{ - Lisp_Object face = COLOR_SPECIFIER_FACE (XCOLOR_SPECIFIER (specifier)); - Lisp_Object property = - COLOR_SPECIFIER_FACE_PROPERTY (XCOLOR_SPECIFIER (specifier)); - if (!NILP (face)) - { - face_property_was_changed (face, property, locale); - if (BUFFERP (locale)) - XBUFFER (locale)->buffer_local_face_property = 1; - } -} - -void -set_color_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) -{ - Lisp_Specifier *color = XCOLOR_SPECIFIER (obj); - - COLOR_SPECIFIER_FACE (color) = face; - COLOR_SPECIFIER_FACE_PROPERTY (color) = property; -} - -DEFUN ("color-specifier-p", Fcolor_specifier_p, 1, 1, 0, /* -Return t if OBJECT is a color specifier. - -See `make-color-specifier' for a description of possible color instantiators. -*/ - (object)) -{ - return COLOR_SPECIFIERP (object) ? Qt : Qnil; -} - - -/**************************************************************************** - Font Object - ***************************************************************************/ - -static const struct memory_description font_specifier_description[] = { - { XD_LISP_OBJECT, offsetof (struct font_specifier, face) }, - { XD_LISP_OBJECT, offsetof (struct font_specifier, face_property) }, - { XD_END } -}; - -DEFINE_SPECIFIER_TYPE_WITH_DATA (font); -/* Qfont defined in general.c */ - -static void -font_create (Lisp_Object obj) -{ - Lisp_Specifier *font = XFONT_SPECIFIER (obj); - - FONT_SPECIFIER_FACE (font) = Qnil; - FONT_SPECIFIER_FACE_PROPERTY (font) = Qnil; -} - -static void -font_mark (Lisp_Object obj) -{ - Lisp_Specifier *font = XFONT_SPECIFIER (obj); - - mark_object (FONT_SPECIFIER_FACE (font)); - mark_object (FONT_SPECIFIER_FACE_PROPERTY (font)); -} - -/* No equal or hash methods; ignore the face the font is based off - of for `equal' */ - -#ifdef MULE - -/* Given a truename font spec (i.e. the font spec should have its registry - field filled in), does it support displaying characters from CHARSET? */ - -static int -font_spec_matches_charset (struct device *d, Lisp_Object charset, - const Ibyte *nonreloc, Lisp_Object reloc, - Bytecount offset, Bytecount length, - enum font_specifier_matchspec_stages stage) -{ - return DEVMETH_OR_GIVEN (d, font_spec_matches_charset, - (d, charset, nonreloc, reloc, offset, length, - stage), - 1); -} - -static void -font_validate_matchspec (Lisp_Object matchspec) -{ - CHECK_CONS (matchspec); - Fget_charset (XCAR (matchspec)); - - do - { - if (EQ(XCDR(matchspec), Qinitial)) - { - break; - } - if (EQ(XCDR(matchspec), Qfinal)) - { - break; - } - - invalid_argument("Invalid font matchspec stage", - XCDR(matchspec)); - } while (0); -} - -void -initialize_charset_font_caches (struct device *d) -{ - /* Note that the following tables are bi-level. */ - d->charset_font_cache_stage_1 = - make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); - d->charset_font_cache_stage_2 = - make_lisp_hash_table (20, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); -} - -void -invalidate_charset_font_caches (Lisp_Object charset) -{ - /* Invalidate font cache entries for charset on all devices. */ - Lisp_Object devcons, concons, hash_table; - DEVICE_LOOP_NO_BREAK (devcons, concons) - { - struct device *d = XDEVICE (XCAR (devcons)); - hash_table = Fgethash (charset, d->charset_font_cache_stage_1, - Qunbound); - if (!UNBOUNDP (hash_table)) - Fclrhash (hash_table); - hash_table = Fgethash (charset, d->charset_font_cache_stage_2, - Qunbound); - if (!UNBOUNDP (hash_table)) - Fclrhash (hash_table); - } -} - -#endif /* MULE */ - -/* It's a little non-obvious what's going on here. Specifically: - - MATCHSPEC is a somewhat bogus way in the specifier mechanism of passing - in additional information needed to instantiate some object. For fonts, - it's a cons of (CHARSET . SECOND-STAGE-P). SECOND-STAGE-P, if set, - means "try harder to find an appropriate font" and is a very bogus way - of dealing with the fact that it may not be possible to may a charset - directly onto a font; it's used esp. under Windows. @@#### We need to - change this so that MATCHSPEC is just a character. - - When redisplay is building up its structure, and needs font info, it - calls functions in faces.c such as ensure_face_cachel_complete() (map - fonts needed for a string of text) or - ensure_face_cachel_contains_charset() (map fonts needed for a charset - derived from a single character). The former function calls the latter; - the latter calls face_property_matching_instance(); this constructs the - MATCHSPEC and calls specifier_instance_no_quit() twice (first stage and - second stage, updating MATCHSPEC appropriately). That function, in - turn, looks up the appropriate specifier method to do the instantiation, - which, lo and behold, is this function here (because we set it in - initialization using `SPECIFIER_HAS_METHOD (font, instantiate);'). We - in turn call the device method `find_charset_font', which maps to - mswindows_find_charset_font(), x_find_charset_font(), or similar, in - objects-msw.c or the like. - - --ben */ - -static Lisp_Object -font_instantiate (Lisp_Object UNUSED (specifier), - Lisp_Object USED_IF_MULE (matchspec), - Lisp_Object domain, Lisp_Object instantiator, - Lisp_Object depth, int no_fallback) -{ - /* When called, we're inside of call_with_suspended_errors(), - so we can freely error. */ - Lisp_Object device = DOMAIN_DEVICE (domain); - struct device *d = XDEVICE (device); - Lisp_Object instance; - Lisp_Object charset = Qnil; -#ifdef MULE - enum font_specifier_matchspec_stages stage = STAGE_INITIAL; - - if (!UNBOUNDP (matchspec)) - { - charset = Fget_charset (XCAR (matchspec)); - -#define FROB(new_stage, enumstage) \ - if (EQ(Q##new_stage, XCDR(matchspec))) \ - { \ - stage = enumstage; \ - } - - FROB (initial, STAGE_INITIAL) - else FROB (final, STAGE_FINAL) - else assert(0); - -#undef FROB - - } -#endif - - if (FONT_INSTANCEP (instantiator)) - { - if (NILP (device) - || EQ (device, XFONT_INSTANCE (instantiator)->device)) - { -#ifdef MULE - if (font_spec_matches_charset (d, charset, 0, - Ffont_instance_truename - (instantiator), - 0, -1, stage)) -#endif - return instantiator; - } - instantiator = Ffont_instance_name (instantiator); - } - - if (STRINGP (instantiator)) - { -#ifdef MULE - /* #### rename these caches. */ - Lisp_Object cache = stage == STAGE_FINAL ? - d->charset_font_cache_stage_2 : - d->charset_font_cache_stage_1; -#else - Lisp_Object cache = d->font_instance_cache; -#endif - -#ifdef MULE - if (!NILP (charset)) - { - /* The instantiator is a font spec that could match many - different fonts. We need to find one of those fonts - whose registry matches the registry of the charset in - MATCHSPEC. This is potentially a very slow operation, - as it involves doing an XListFonts() or equivalent to - iterate over all possible fonts, and a regexp match - on each one. So we cache the results. */ - Lisp_Object matching_font = Qunbound; - Lisp_Object hash_table = Fgethash (charset, cache, Qunbound); - if (UNBOUNDP (hash_table)) - { - /* need to make a sub hash table. */ - hash_table = make_lisp_hash_table (20, HASH_TABLE_KEY_WEAK, - HASH_TABLE_EQUAL); - Fputhash (charset, hash_table, cache); - } - else - matching_font = Fgethash (instantiator, hash_table, Qunbound); - - if (UNBOUNDP (matching_font)) - { - /* make sure we cache the failures, too. */ - matching_font = - DEVMETH_OR_GIVEN (d, find_charset_font, - (device, instantiator, charset, stage), - instantiator); - Fputhash (instantiator, matching_font, hash_table); - } - if (NILP (matching_font)) - return Qunbound; - instantiator = matching_font; - } -#endif /* MULE */ - - /* First, look to see if we can retrieve a cached value. */ - instance = Fgethash (instantiator, cache, Qunbound); - /* Otherwise, make a new one. */ - if (UNBOUNDP (instance)) - { - /* make sure we cache the failures, too. */ - instance = Fmake_font_instance (instantiator, device, Qt, charset); - Fputhash (instantiator, instance, cache); - } - - return NILP (instance) ? Qunbound : instance; - } - else if (VECTORP (instantiator)) - { - Lisp_Object match_inst = Qunbound; - assert (XVECTOR_LENGTH (instantiator) == 1); - - match_inst = face_property_matching_instance - (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, - charset, domain, ERROR_ME, no_fallback, depth, STAGE_INITIAL); - - if (UNBOUNDP(match_inst)) - { - match_inst = face_property_matching_instance - (Fget_face (XVECTOR_DATA (instantiator)[0]), Qfont, - charset, domain, ERROR_ME, no_fallback, depth, STAGE_FINAL); - } - - return match_inst; - - } - else if (NILP (instantiator)) - return Qunbound; - else - ABORT (); /* Eh? */ - - return Qunbound; -} - -static void -font_validate (Lisp_Object instantiator) -{ - if (FONT_INSTANCEP (instantiator) || STRINGP (instantiator)) - return; - if (VECTORP (instantiator)) - { - if (XVECTOR_LENGTH (instantiator) != 1) - { - sferror - ("Vector length must be one for font inheritance", instantiator); - } - Fget_face (XVECTOR_DATA (instantiator)[0]); - } - else - invalid_argument ("Must be string, vector, or font-instance", - instantiator); -} - -static void -font_after_change (Lisp_Object specifier, Lisp_Object locale) -{ - Lisp_Object face = FONT_SPECIFIER_FACE (XFONT_SPECIFIER (specifier)); - Lisp_Object property = - FONT_SPECIFIER_FACE_PROPERTY (XFONT_SPECIFIER (specifier)); - if (!NILP (face)) - { - face_property_was_changed (face, property, locale); - if (BUFFERP (locale)) - XBUFFER (locale)->buffer_local_face_property = 1; - } -} - -void -set_font_attached_to (Lisp_Object obj, Lisp_Object face, Lisp_Object property) -{ - Lisp_Specifier *font = XFONT_SPECIFIER (obj); - - FONT_SPECIFIER_FACE (font) = face; - FONT_SPECIFIER_FACE_PROPERTY (font) = property; -} - -DEFUN ("font-specifier-p", Ffont_specifier_p, 1, 1, 0, /* -Return non-nil if OBJECT is a font specifier. - -See `make-font-specifier' for a description of possible font instantiators. -*/ - (object)) -{ - return FONT_SPECIFIERP (object) ? Qt : Qnil; -} - - -/***************************************************************************** - Face Boolean Object - ****************************************************************************/ - -static const struct memory_description face_boolean_specifier_description[] = { - { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face) }, - { XD_LISP_OBJECT, offsetof (struct face_boolean_specifier, face_property) }, - { XD_END } -}; - -DEFINE_SPECIFIER_TYPE_WITH_DATA (face_boolean); -Lisp_Object Qface_boolean; - -static void -face_boolean_create (Lisp_Object obj) -{ - Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); - - FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = Qnil; - FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = Qnil; -} - -static void -face_boolean_mark (Lisp_Object obj) -{ - Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); - - mark_object (FACE_BOOLEAN_SPECIFIER_FACE (face_boolean)); - mark_object (FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean)); -} - -/* No equal or hash methods; ignore the face the face-boolean is based off - of for `equal' */ - -static Lisp_Object -face_boolean_instantiate (Lisp_Object specifier, - Lisp_Object UNUSED (matchspec), - Lisp_Object domain, Lisp_Object instantiator, - Lisp_Object depth, int no_fallback) -{ - /* When called, we're inside of call_with_suspended_errors(), - so we can freely error. */ - if (NILP (instantiator) || EQ (instantiator, Qt)) - return instantiator; - else if (VECTORP (instantiator)) - { - Lisp_Object retval; - Lisp_Object prop; - int instantiator_len = XVECTOR_LENGTH (instantiator); - - assert (instantiator_len >= 1 && instantiator_len <= 3); - if (instantiator_len > 1) - prop = XVECTOR_DATA (instantiator)[1]; - else - { - if (NILP (FACE_BOOLEAN_SPECIFIER_FACE - (XFACE_BOOLEAN_SPECIFIER (specifier)))) - gui_error - ("Face-boolean specifier not attached to a face", instantiator); - prop = FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY - (XFACE_BOOLEAN_SPECIFIER (specifier)); - } - - retval = (FACE_PROPERTY_INSTANCE_1 - (Fget_face (XVECTOR_DATA (instantiator)[0]), - prop, domain, ERROR_ME, no_fallback, depth)); - - if (instantiator_len == 3 && !NILP (XVECTOR_DATA (instantiator)[2])) - retval = NILP (retval) ? Qt : Qnil; - - return retval; - } - else - ABORT (); /* Eh? */ - - return Qunbound; -} - -static void -face_boolean_validate (Lisp_Object instantiator) -{ - if (NILP (instantiator) || EQ (instantiator, Qt)) - return; - else if (VECTORP (instantiator) && - (XVECTOR_LENGTH (instantiator) >= 1 && - XVECTOR_LENGTH (instantiator) <= 3)) - { - Lisp_Object face = XVECTOR_DATA (instantiator)[0]; - - Fget_face (face); - - if (XVECTOR_LENGTH (instantiator) > 1) - { - Lisp_Object field = XVECTOR_DATA (instantiator)[1]; - if (!EQ (field, Qunderline) - && !EQ (field, Qstrikethru) - && !EQ (field, Qhighlight) - && !EQ (field, Qdim) - && !EQ (field, Qblinking) - && !EQ (field, Qreverse)) - invalid_constant ("Invalid face-boolean inheritance field", - field); - } - } - else if (VECTORP (instantiator)) - sferror ("Wrong length for face-boolean inheritance spec", - instantiator); - else - invalid_argument ("Face-boolean instantiator must be nil, t, or vector", - instantiator); -} - -static void -face_boolean_after_change (Lisp_Object specifier, Lisp_Object locale) -{ - Lisp_Object face = - FACE_BOOLEAN_SPECIFIER_FACE (XFACE_BOOLEAN_SPECIFIER (specifier)); - Lisp_Object property = - FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (XFACE_BOOLEAN_SPECIFIER (specifier)); - if (!NILP (face)) - { - face_property_was_changed (face, property, locale); - if (BUFFERP (locale)) - XBUFFER (locale)->buffer_local_face_property = 1; - } -} - -void -set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face, - Lisp_Object property) -{ - Lisp_Specifier *face_boolean = XFACE_BOOLEAN_SPECIFIER (obj); - - FACE_BOOLEAN_SPECIFIER_FACE (face_boolean) = face; - FACE_BOOLEAN_SPECIFIER_FACE_PROPERTY (face_boolean) = property; -} - -DEFUN ("face-boolean-specifier-p", Fface_boolean_specifier_p, 1, 1, 0, /* -Return non-nil if OBJECT is a face-boolean specifier. - -See `make-face-boolean-specifier' for a description of possible -face-boolean instantiators. -*/ - (object)) -{ - return FACE_BOOLEAN_SPECIFIERP (object) ? Qt : Qnil; -} - - -/***************************************************************************** - Face Background Placement Object - ****************************************************************************/ -Lisp_Object Qabsolute, Qrelative; - -static const struct memory_description -face_background_placement_specifier_description[] = { - { XD_LISP_OBJECT, offsetof (struct face_background_placement_specifier, - face) }, - { XD_END } -}; - -DEFINE_SPECIFIER_TYPE_WITH_DATA (face_background_placement); -Lisp_Object Qface_background_placement; - -static void -face_background_placement_create (Lisp_Object obj) -{ - Lisp_Specifier *face_background_placement - = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); - - FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = Qnil; -} - -static void -face_background_placement_mark (Lisp_Object obj) -{ - Lisp_Specifier *face_background_placement - = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); - - mark_object - (FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement)); -} - -/* No equal or hash methods; ignore the face the background-placement is based - off of for `equal' */ - -extern Lisp_Object Qbackground_placement; - -static Lisp_Object -face_background_placement_instantiate (Lisp_Object UNUSED (specifier), - Lisp_Object UNUSED (matchspec), - Lisp_Object domain, - Lisp_Object instantiator, - Lisp_Object depth, - int no_fallback) -{ - /* When called, we're inside of call_with_suspended_errors(), - so we can freely error. */ - if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative)) - return instantiator; - else if (VECTORP (instantiator)) - { - assert (XVECTOR_LENGTH (instantiator) == 1); - - return FACE_PROPERTY_INSTANCE_1 - (Fget_face (XVECTOR_DATA (instantiator)[0]), - Qbackground_placement, domain, ERROR_ME, no_fallback, depth); - } - else - ABORT (); /* Eh? */ - - return Qunbound; -} - -static void -face_background_placement_validate (Lisp_Object instantiator) -{ - if (EQ (instantiator, Qabsolute) || EQ (instantiator, Qrelative)) - return; - else if (VECTORP (instantiator) && - (XVECTOR_LENGTH (instantiator) == 1)) - { - Lisp_Object face = XVECTOR_DATA (instantiator)[0]; - - Fget_face (face); /* just to check that the face exists -- dvl */ - } - else if (VECTORP (instantiator)) - sferror ("Wrong length for background-placement inheritance spec", - instantiator); - else - invalid_argument - ("\ -Background-placement instantiator must be absolute, relative or vector", - instantiator); -} - -static void -face_background_placement_after_change (Lisp_Object specifier, - Lisp_Object locale) -{ - Lisp_Object face - = FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE - (XFACE_BACKGROUND_PLACEMENT_SPECIFIER (specifier)); - - if (!NILP (face)) - { - face_property_was_changed (face, Qbackground_placement, locale); - if (BUFFERP (locale)) - XBUFFER (locale)->buffer_local_face_property = 1; - } -} - -void -set_face_background_placement_attached_to (Lisp_Object obj, Lisp_Object face) -{ - Lisp_Specifier *face_background_placement - = XFACE_BACKGROUND_PLACEMENT_SPECIFIER (obj); - - FACE_BACKGROUND_PLACEMENT_SPECIFIER_FACE (face_background_placement) = face; -} - -DEFUN ("face-background-placement-specifier-p", Fface_background_placement_specifier_p, 1, 1, 0, /* -Return non-nil if OBJECT is a face-background-placement specifier. - -See `make-face-background-placement-specifier' for a description of possible -face-background-placement instantiators. -*/ - (object)) -{ - return FACE_BACKGROUND_PLACEMENT_SPECIFIERP (object) ? Qt : Qnil; -} - - -/************************************************************************/ -/* initialization */ -/************************************************************************/ - -void -syms_of_objects (void) -{ - INIT_LISP_OBJECT (color_instance); - INIT_LISP_OBJECT (font_instance); - - DEFSUBR (Fcolor_specifier_p); - DEFSUBR (Ffont_specifier_p); - DEFSUBR (Fface_boolean_specifier_p); - DEFSUBR (Fface_background_placement_specifier_p); - - DEFSYMBOL_MULTIWORD_PREDICATE (Qcolor_instancep); - DEFSUBR (Fmake_color_instance); - DEFSUBR (Fcolor_instance_p); - DEFSUBR (Fcolor_instance_name); - DEFSUBR (Fcolor_instance_rgb_components); - DEFSUBR (Fvalid_color_name_p); - DEFSUBR (Fcolor_list); - - DEFSYMBOL_MULTIWORD_PREDICATE (Qfont_instancep); - DEFSUBR (Fmake_font_instance); - DEFSUBR (Ffont_instance_p); - DEFSUBR (Ffont_instance_name); - DEFSUBR (Ffont_instance_ascent); - DEFSUBR (Ffont_instance_descent); - DEFSUBR (Ffont_instance_width); - DEFSUBR (Ffont_instance_charset); - DEFSUBR (Ffont_instance_proportional_p); - DEFSUBR (Ffont_instance_truename); - DEFSUBR (Ffont_instance_properties); - DEFSUBR (Ffont_list); - - /* Qcolor, Qfont defined in general.c */ - DEFSYMBOL (Qface_boolean); - - DEFSYMBOL (Qface_background_placement); - DEFSYMBOL (Qabsolute); - DEFSYMBOL (Qrelative); -} - -void -specifier_type_create_objects (void) -{ - INITIALIZE_SPECIFIER_TYPE_WITH_DATA (color, "color", "color-specifier-p"); - INITIALIZE_SPECIFIER_TYPE_WITH_DATA (font, "font", "font-specifier-p"); - INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_boolean, "face-boolean", - "face-boolean-specifier-p"); - INITIALIZE_SPECIFIER_TYPE_WITH_DATA (face_background_placement, - "face-background-placement", - "\ -face-background-placement-specifier-p"); - - SPECIFIER_HAS_METHOD (color, instantiate); - SPECIFIER_HAS_METHOD (font, instantiate); - SPECIFIER_HAS_METHOD (face_boolean, instantiate); - SPECIFIER_HAS_METHOD (face_background_placement, instantiate); - - SPECIFIER_HAS_METHOD (color, validate); - SPECIFIER_HAS_METHOD (font, validate); - SPECIFIER_HAS_METHOD (face_boolean, validate); - SPECIFIER_HAS_METHOD (face_background_placement, validate); - - SPECIFIER_HAS_METHOD (color, create); - SPECIFIER_HAS_METHOD (font, create); - SPECIFIER_HAS_METHOD (face_boolean, create); - SPECIFIER_HAS_METHOD (face_background_placement, create); - - SPECIFIER_HAS_METHOD (color, mark); - SPECIFIER_HAS_METHOD (font, mark); - SPECIFIER_HAS_METHOD (face_boolean, mark); - SPECIFIER_HAS_METHOD (face_background_placement, mark); - - SPECIFIER_HAS_METHOD (color, after_change); - SPECIFIER_HAS_METHOD (font, after_change); - SPECIFIER_HAS_METHOD (face_boolean, after_change); - SPECIFIER_HAS_METHOD (face_background_placement, after_change); - -#ifdef MULE - SPECIFIER_HAS_METHOD (font, validate_matchspec); -#endif -} - -void -reinit_specifier_type_create_objects (void) -{ - REINITIALIZE_SPECIFIER_TYPE (color); - REINITIALIZE_SPECIFIER_TYPE (font); - REINITIALIZE_SPECIFIER_TYPE (face_boolean); - REINITIALIZE_SPECIFIER_TYPE (face_background_placement); -} - -void -reinit_vars_of_objects (void) -{ - { - Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (color_instance); - Lisp_Color_Instance *c = XCOLOR_INSTANCE (obj); - c->name = Qnil; - c->device = Qnil; - c->data = 0; - - Vthe_null_color_instance = obj; - staticpro_nodump (&Vthe_null_color_instance); - } - - { - Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (font_instance); - Lisp_Font_Instance *f = XFONT_INSTANCE (obj); - f->name = Qnil; - f->truename = Qnil; - f->device = Qnil; - f->data = 0; - - f->ascent = f->height = 0; - f->descent = 0; - f->width = 0; - f->proportional_p = 0; - - Vthe_null_font_instance = obj; - staticpro_nodump (&Vthe_null_font_instance); - } -} - -void -vars_of_objects (void) -{ -}
--- a/src/objects.h Mon Mar 29 22:47:55 2010 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/* Generic object functions -- interface. - Copyright (C) 1995 Board of Trustees, University of Illinois. - Copyright (C) 1995, 1996, 2002 Ben Wing. - -This file is part of XEmacs. - -XEmacs is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -XEmacs is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with XEmacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ - -/* Synched up with: Not in FSF. */ - -#ifndef INCLUDED_objects_h_ -#define INCLUDED_objects_h_ - -DECLARE_DOESNT_RETURN (finalose (void *ptr)); - -/**************************************************************************** - * Color Instance Object * - ****************************************************************************/ - -DECLARE_LISP_OBJECT (color_instance, Lisp_Color_Instance); -#define XCOLOR_INSTANCE(x) XRECORD (x, color_instance, Lisp_Color_Instance) -#define wrap_color_instance(p) wrap_record (p, color_instance) -#define COLOR_INSTANCEP(x) RECORDP (x, color_instance) -#define CHECK_COLOR_INSTANCE(x) CHECK_RECORD (x, color_instance) -#define CONCHECK_COLOR_INSTANCE(x) CONCHECK_RECORD (x, color_instance) - -EXFUN (Fmake_color_instance, 3); - -extern Lisp_Object Vthe_null_color_instance; - -void set_color_attached_to (Lisp_Object obj, Lisp_Object face, - Lisp_Object property); - -/**************************************************************************** - * Font Instance Object * - ****************************************************************************/ - -void initialize_charset_font_caches (struct device *d); -void invalidate_charset_font_caches (Lisp_Object charset); - -DECLARE_LISP_OBJECT (font_instance, Lisp_Font_Instance); -#define XFONT_INSTANCE(x) XRECORD (x, font_instance, Lisp_Font_Instance) -#define wrap_font_instance(p) wrap_record (p, font_instance) -#define FONT_INSTANCEP(x) RECORDP (x, font_instance) -#define CHECK_FONT_INSTANCE(x) CHECK_RECORD (x, font_instance) -#define CONCHECK_FONT_INSTANCE(x) CONCHECK_RECORD (x, font_instance) - -EXFUN (Fmake_font_instance, 4); -EXFUN (Ffont_instance_name, 1); -EXFUN (Ffont_instance_p, 1); -EXFUN (Ffont_instance_truename, 1); -EXFUN (Ffont_instance_charset, 1); - -extern Lisp_Object Vthe_null_font_instance; - -void set_font_attached_to (Lisp_Object obj, Lisp_Object face, - Lisp_Object property); - -/***************************************************************************** - * Face Boolean Specifier Object * - *****************************************************************************/ - -void set_face_boolean_attached_to (Lisp_Object obj, Lisp_Object face, - Lisp_Object property); - -/***************************************************************************** - * Face Background Placement Specifier Object * - *****************************************************************************/ - -void set_face_background_placement_attached_to -(Lisp_Object obj, Lisp_Object face); - - -#endif /* INCLUDED_objects_h_ */
--- a/src/redisplay-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/redisplay-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -51,7 +51,7 @@ #include "console-msw-impl.h" #include "glyphs-msw.h" -#include "objects-msw-impl.h" +#include "fontcolor-msw-impl.h" #define MSWINDOWS_EOL_CURSOR_WIDTH 5
--- a/src/redisplay-tty.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/redisplay-tty.c Mon Mar 29 22:52:01 2010 -0500 @@ -44,7 +44,7 @@ #include "window.h" #include "console-tty-impl.h" -#include "objects-tty-impl.h" +#include "fontcolor-tty-impl.h" #include "syssignal.h"
--- a/src/redisplay.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/redisplay.c Mon Mar 29 22:52:01 2010 -0500 @@ -61,7 +61,7 @@ #include "gutter.h" #include "insdel.h" #include "menubar.h" -#include "objects-impl.h" +#include "fontcolor-impl.h" #include "opaque.h" #include "process.h" #include "profile.h"
--- a/src/select-x.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/select-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -33,7 +33,7 @@ #include "select.h" #include "console-x-impl.h" -#include "objects-x.h" +#include "fontcolor-x.h" #include "systime.h"
--- a/src/select.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/select.c Mon Mar 29 22:52:01 2010 -0500 @@ -28,7 +28,7 @@ #include "device-impl.h" #include "extents.h" #include "console.h" -#include "objects.h" +#include "fontcolor.h" #include "frame.h" #include "opaque.h"
--- a/src/symsinit.h Mon Mar 29 22:47:55 2010 -0500 +++ b/src/symsinit.h Mon Mar 29 22:52:01 2010 -0500 @@ -165,11 +165,11 @@ void syms_of_mule_wnn (void); void syms_of_nt (void); void syms_of_number (void); -void syms_of_objects (void); -void syms_of_objects_gtk (void); -void syms_of_objects_mswindows (void); -void syms_of_objects_tty (void); -void syms_of_objects_x (void); +void syms_of_fontcolor (void); +void syms_of_fontcolor_gtk (void); +void syms_of_fontcolor_mswindows (void); +void syms_of_fontcolor_tty (void); +void syms_of_fontcolor_x (void); EXTERN_C void syms_of_postgresql (void); void syms_of_print (void); void syms_of_process (void); @@ -248,10 +248,10 @@ void console_type_create_menubar_x (void); void console_type_create_mswindows (void); void reinit_console_type_create_mswindows (void); -void console_type_create_objects_gtk (void); -void console_type_create_objects_mswindows (void); -void console_type_create_objects_tty (void); -void console_type_create_objects_x (void); +void console_type_create_fontcolor_gtk (void); +void console_type_create_fontcolor_mswindows (void); +void console_type_create_fontcolor_tty (void); +void console_type_create_fontcolor_x (void); void console_type_create_redisplay_gtk (void); void console_type_create_redisplay_mswindows (void); void console_type_create_redisplay_tty (void); @@ -281,8 +281,8 @@ void reinit_specifier_type_create_gutter (void); void specifier_type_create_image (void); void reinit_specifier_type_create_image (void); -void specifier_type_create_objects (void); -void reinit_specifier_type_create_objects (void); +void specifier_type_create_fontcolor (void); +void reinit_specifier_type_create_fontcolor (void); void specifier_type_create_toolbar (void); void reinit_specifier_type_create_toolbar (void); @@ -472,13 +472,13 @@ void vars_of_nt (void); void vars_of_number (void); void reinit_vars_of_number (void); -void reinit_vars_of_object_mswindows (void); -void vars_of_objects (void); -void reinit_vars_of_objects (void); -void vars_of_objects_gtk (void); -void vars_of_objects_mswindows (void); -void vars_of_objects_tty (void); -void vars_of_objects_x (void); +void reinit_vars_of_fontcolor_mswindows (void); +void vars_of_fontcolor (void); +void reinit_vars_of_fontcolor (void); +void vars_of_fontcolor_gtk (void); +void vars_of_fontcolor_mswindows (void); +void vars_of_fontcolor_tty (void); +void vars_of_fontcolor_x (void); EXTERN_C void vars_of_postgresql (void); void vars_of_print (void); void reinit_vars_of_print (void);
--- a/src/toolbar-msw.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/toolbar-msw.c Mon Mar 29 22:52:01 2010 -0500 @@ -45,7 +45,7 @@ #include "console-msw-impl.h" #include "glyphs-msw.h" -/* #include "objects-msw.h" */ +/* #include "fontcolor-msw.h" */ #define TOOLBAR_ITEM_ID_MIN 0x4000 #define TOOLBAR_ITEM_ID_MAX 0x7FFF
--- a/src/toolbar-x.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/toolbar-x.c Mon Mar 29 22:52:01 2010 -0500 @@ -37,7 +37,7 @@ #include "console-x-impl.h" #include "glyphs-x.h" -#include "objects-x.h" +#include "fontcolor-x.h" #include "EmacsFrame.h" #include "EmacsFrameP.h"
--- a/src/ui-gtk.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/ui-gtk.c Mon Mar 29 22:52:01 2010 -0500 @@ -37,7 +37,7 @@ #include "console-gtk-impl.h" #include "glyphs-gtk.h" -#include "objects-gtk.h" +#include "fontcolor-gtk.h" #include "ui-gtk.h" /* XEmacs specific GTK types */
--- a/src/window.c Mon Mar 29 22:47:55 2010 -0500 +++ b/src/window.c Mon Mar 29 22:52:01 2010 -0500 @@ -47,7 +47,7 @@ #include "frame-impl.h" #include "glyphs.h" #include "gutter.h" -#include "objects.h" +#include "fontcolor.h" #include "redisplay.h" #include "window-impl.h"
--- a/tests/ChangeLog Mon Mar 29 22:47:55 2010 -0500 +++ b/tests/ChangeLog Mon Mar 29 22:52:01 2010 -0500 @@ -113,6 +113,11 @@ 2010-02-22 Ben Wing <ben@xemacs.org> + * reproduce-crashes.el (8): + objects*.[ch] -> fontcolor*.[ch]. + +2010-02-22 Ben Wing <ben@xemacs.org> + * automated/syntax-tests.el: Use Known-Bug-Expect-Error, not Known-Bug-Expect-Failure, when error expected; else test suite will abort this file.
--- a/tests/reproduce-crashes.el Mon Mar 29 22:47:55 2010 -0500 +++ b/tests/reproduce-crashes.el Mon Mar 29 22:52:01 2010 -0500 @@ -206,7 +206,7 @@ (defbug 8 current "Crashes in debug version only -Fatal error: assertion failed, file src/objects.h, line 149, +Fatal error: assertion failed, file src/fontcolor.h, line 149, RECORD_TYPEP (_obj, lrecord_font_instance) || MARKED_RECORD_P (_obj)" (let (glyph ext) (make-face 'adobe-symbol-face)