annotate lisp/font-mgr.el @ 5170:5ddbab03b0e6

various fixes to memory-usage stats -------------------- ChangeLog entries follow: -------------------- lisp/ChangeLog addition: 2010-03-25 Ben Wing <ben@xemacs.org> * diagnose.el (show-memory-usage): * diagnose.el (show-object-memory-usage-stats): Further changes to correspond with changes in the C code; add an additional column in show-object-memory-usage-stats showing the ancillary Lisp overhead used with each type; shrink columns for windows in show-memory-usage to get it to fit in 79 chars. src/ChangeLog addition: 2010-03-25 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (struct): * alloc.c (finish_object_memory_usage_stats): * alloc.c (object_memory_usage_stats): * alloc.c (Fobject_memory_usage): * alloc.c (lisp_object_memory_usage_full): * alloc.c (compute_memusage_stats_length): * lrecord.h: * lrecord.h (struct lrecord_implementation): Add fields to the `lrecord_implementation' structure to list an offset into the array of extra statistics in a `struct generic_usage_stats' and a length, listing the first slice of ancillary Lisp-object memory. Compute automatically in compute_memusage_stats_length(). Use to add an entry `FOO-lisp-ancillary-storage' for object type FOO. Don't crash when an int or char is given to object-memory-usage, signal an error instead. Add functions lisp_object_memory_usage_full() and lisp_object_memory_usage() to compute the total memory usage of an object (sum of object, non-Lisp attached, and Lisp ancillary memory). * array.c: * array.c (gap_array_memory_usage): * array.h: Add function to return memory usage of a gap array. * buffer.c (struct buffer_stats): * buffer.c (compute_buffer_usage): * buffer.c (vars_of_buffer): * extents.c (compute_buffer_extent_usage): * marker.c: * marker.c (compute_buffer_marker_usage): * extents.h: * lisp.h: Remove `struct usage_stats' arg from compute_buffer_marker_usage() and compute_buffer_extent_usage() -- these are ancillary Lisp objects and don't get accumulated into `struct usage_stats'; change the value of `memusage_stats_list' so that `markers' and `extents' memory is in Lisp-ancillary, where it belongs. In compute_buffer_marker_usage(), use lisp_object_memory_usage() rather than lisp_object_storage_size(). * casetab.c: * casetab.c (case_table_memory_usage): * casetab.c (vars_of_casetab): * emacs.c (main_1): Add memory usage stats for case tables. * lisp.h: Add comment explaining the `struct generic_usage_stats' more, as well as the new fields in lrecord_implementation. * console-impl.h: * console-impl.h (struct console_methods): * scrollbar-gtk.c: * scrollbar-gtk.c (gtk_compute_scrollbar_instance_usage): * scrollbar-msw.c: * scrollbar-msw.c (mswindows_compute_scrollbar_instance_usage): * scrollbar-x.c: * scrollbar-x.c (x_compute_scrollbar_instance_usage): * scrollbar.c: * scrollbar.c (struct scrollbar_instance_stats): * scrollbar.c (compute_all_scrollbar_instance_usage): * scrollbar.c (scrollbar_instance_memory_usage): * scrollbar.c (scrollbar_objects_create): * scrollbar.c (vars_of_scrollbar): * scrollbar.h: * symsinit.h: * window.c: * window.c (find_window_mirror_maybe): * window.c (struct window_mirror_stats): * window.c (compute_window_mirror_usage): * window.c (window_mirror_memory_usage): * window.c (compute_window_usage): * window.c (window_objects_create): * window.c (syms_of_window): * window.c (vars_of_window): Redo memory-usage associated with windows, window mirrors, and scrollbar instances. Should fix crash in find_window_mirror, among other things. Properly assign memo ry to object memory, non-Lisp extra memory, and Lisp ancillary memory. For example, redisplay structures are non-Lisp memory hanging off a window mirror, not a window; make it an ancillary Lisp-object field. Window mirrors and scrollbar instances have their own statistics, among other things.
author Ben Wing <ben@xemacs.org>
date Thu, 25 Mar 2010 06:07:25 -0500
parents 316fddbf58e2
children 91b3aa59f49b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3354
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
1 ;;; font-mgr.el --- Lisp emulation of fontconfig for X fonts.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
2
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
3 ;; Copyright (C) 2006 Free Software Foundation, Inc.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
4
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
5 ;; Author: Stephen J. Turnbull <stephen@xemacs.org>
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
6 ;; Created: 12 Apr 2006 by Stephen J. Turnbull
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
7
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
8 ;; This file is part of XEmacs.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
9
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
12 ;; Free Software Foundation; either version 2, or (at your option) any
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
13 ;; later version.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
14
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
18 ;; for more details.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
19
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
24
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
25 ;; Synched up with: Not in GNU Emacs.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
26
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
27 ;; Commentary
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
28 ;; This module provides the Lisp interface to fonts in X11, including Xft,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
29 ;; but (at least at first) not GTK+ or Qt. It is a substitute for the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
30 ;; C library fontconfig, whose interface is provided in ../src/font-mgr.c.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
31
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
32 ;; static FcChar8 *fc_standard_properties[] = {
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
33 ;; "antialias", "aspect", "autohint", "charset", "dpi", "family", "file",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
34 ;; "foundry", "ftface", "globaladvance", "hinting", "index", "lang",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
35 ;; "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
36 ;; "scale", "size", "slant", "spacing", "style", "verticallayout", "weight",
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
37 ;; /* obsolete after Xft v. 1 */
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
38 ;; "charwidth", "charheight", "core", "encoding", "render"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
39
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
40 ;; #### should we wrap the world in `(unless (featurep 'font-mgr) ... )'?
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
41
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
42 (provide 'font-mgr)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
43
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
44 (defvar xft-xlfd-font-regexp
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
45 (concat
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
46 ;; XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
47 ;; in Mule when this function is called. So use HPC.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
48 ;; (xe_xlfd_prefix "\\(\\+[\040-\176\240-\377]*\\)?-")
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
49 ;; (xe_xlfd_opt_text "\\([\040-\044\046-\176\240-\377]*\\)")
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
50 ;; (xe_xlfd_text "\\([\040-\044\046-\176\240-\377]+\\)")
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
51 "\\`"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
52 "\\(\\+[\040-\176]*\\)?-" ; prefix
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
53 "\\([^-]+\\)" ; foundry
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
54 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
55 "\\([^-]+\\)" ; family
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
56 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
57 "\\([^-]+\\)" ; weight
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
58 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
59 "\\([0-9ior?*][iot]?\\)" ; slant
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
60 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
61 "\\([^-]+\\)" ; swidth
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
62 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
63 "\\([^-]*\\)" ; adstyle
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
64 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
65 "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)" ; pixelsize
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
66 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
67 "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)" ; pointsize
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
68 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
69 "\\([0-9?*]+\\)" ; resx
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
70 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
71 "\\([0-9?*]+\\)" ; resy
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
72 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
73 "\\([cmp?*]\\)" ; spacing
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
74 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
75 "~?" ; avgwidth
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
76 "\\([0-9?*]+\\)"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
77 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
78 "\\([^-]+\\)" ; registry
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
79 "-"
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
80 "\\([^-]+\\)" ; encoding
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
81 "\\'")
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
82 "The regular expression used to match XLFD font names.")
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
83
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
84 (defun fc-pattern-p (object)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
85 "Returns t if OBJECT is of type fc-pattern, nil otherwise."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
86 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
87
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
88 (defun fc-pattern-create ()
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
89 "Return a new, empty fc-pattern object."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
90 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
91
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
92 (defun fc-name-parse (fontname)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
93 "Parse an Fc font name and return its representation as a fc pattern object."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
94 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
95
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
96 (defun fc-name-unparse (pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
97 "Unparse an fc pattern object to a string."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
98 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
99
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
100 (defun fc-pattern-duplicate (pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
101 "Make a copy of the fc pattern object PATTERN and return it."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
102 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
103
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
104 (defun fc-pattern-add (pattern property value)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
105 "Add attributes to the pattern object PATTERN. PROPERTY is a string naming
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
106 the attribute to add, VALUE the value for this attribute.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
107
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
108 VALUE may be a string, integer, float, or symbol, in which case the value
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
109 will be added as an FcChar8[], int, double, or FcBool respectively."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
110 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
111
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
112 (defun fc-pattern-del (pattern property)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
113 "Remove attribute PROPERTY from fc pattern object PATTERN."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
114 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
115
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
116 ;; Generic interface to FcPatternGet()
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
117 ;; Don't support the losing symbol-for-property interface.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
118
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
119 (defun fc-pattern-get (pattern property &optional id type)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
120 "From PATTERN, extract PROPERTY for the ID'th member, of type TYPE.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
121
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
122 PATTERN is an Xft \(fontconfig) pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
123 PROPERTY is a string naming an fontconfig font property.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
124 Optional ID is a nonnegative integer indexing the list of values for PROPERTY
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
125 stored in PATTERN, defaulting to 0 (the first value).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
126 Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
127 'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
128 \('float is an alias for 'double).
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
129
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
130 The Lisp types returned will conform to TYPE:
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
131 string string
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
132 boolean `t' or `nil'
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
133 integer integer
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
134 double \(float) float
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
135 matrix not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
136 charset not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
137 void not implemented
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
138
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
139 Symbols with names of the form \"fc-result-DESCRIPTION\" are returned when
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
140 the desired value is not available. These are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
141
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
142 fc-result-type-mismatch the value found has an unexpected type
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
143 fc-result-no-match there is no such attribute
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
144 fc-result-no-id there is no value for the requested ID
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
145
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
146 The types of the following standard properties are predefined by fontconfig.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
147 The symbol 'fc-result-type-mismatch will be returned if the object exists but
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
148 TYPE does not match the predefined type. It is best not to specify a type
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
149 for predefined properties, as a mistake here ensures error returns on the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
150 correct type.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
151
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
152 Each standard property has a convenience accessor defined in fontconfig.el,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
153 named in the form \"fc-pattern-get-PROPERTY\". The convenience functions are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
154 preferred to `fc-pattern-get' since a typo in the string naming a property
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
155 will result in a silent null return, while a typo in a function name will
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
156 usually result in a compiler or runtime \"not fboundp\" error. You may use
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
157 `defsubst' to define convenience functions for non-standard properties.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
158
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
159 family String Font family name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
160 style String Font style. Overrides weight and slant
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
161 slant Int Italic, oblique or roman
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
162 weight Int Light, medium, demibold, bold or black
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
163 size Double Point size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
164 aspect Double Stretches glyphs horizontally before hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
165 pixelsize Double Pixel size
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
166 spacing Int Proportional, monospace or charcell
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
167 foundry String Font foundry name
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
168 antialias Bool Whether glyphs can be antialiased
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
169 hinting Bool Whether the rasterizer should use hinting
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
170 verticallayout Bool Use vertical layout
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
171 autohint Bool Use autohinter instead of normal hinter
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
172 globaladvance Bool Use font global advance data
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
173 file String The filename holding the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
174 index Int The index of the font within the file
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
175 ftface FT_Face Use the specified FreeType face object
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
176 rasterizer String Which rasterizer is in use
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
177 outline Bool Whether the glyphs are outlines
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
178 scalable Bool Whether glyphs can be scaled
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
179 scale Double Scale factor for point->pixel conversions
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
180 dpi Double Target dots per inch
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
181 rgba Int unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
182 minspace Bool Eliminate leading from line spacing
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
183 charset CharSet Unicode chars encoded by the font
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
184 lang String List of RFC-3066-style languages this font supports
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
185
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
186 The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
187 properties are not accessible from Lisp at this time. If the value of a
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
188 property returned has type FT_Face, FcCharSet, or FcMatrix,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
189 `fc-result-type-mismatch' is returned.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
190
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
191 The following properties which were standard in Xft v.1 are obsolete in
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
192 Xft v.2: encoding, charwidth, charheight, core, and render."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
193 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
194
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
195 (defun fc-font-match (device pattern)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
196 "Return the font on DEVICE that most closely matches PATTERN.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
197
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
198 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
199 PATTERN is a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
200 Returns a fontconfig pattern object representing the closest match to the
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
201 given pattern, or an error code. Possible error codes are
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
202 `fc-result-no-match' and `fc-result-no-id'."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
203 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
204
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
205 ;; #### fix this name to correspond to Ben's new nomenclature
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
206 (defun fc-list-fonts-pattern-objects (device pattern properties)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
207 "Return a list of fonts on DEVICE that match PATTERN for PROPERTIES.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
208 Each font is represented by a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
209
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
210 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
211 PATTERN is a fontconfig pattern to be matched.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
212 PROPERTIES is a list of property names (strings) that should match.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
213
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
214 #### DEVICE is unused, ignored, and may be removed if it's not needed to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
215 match other font-listing APIs."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
216 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
217
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
218 ;; #### maybe this can/should be folded into fc-list-fonts-pattern-objects?
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
219 (defun fc-font-sort (device pattern &optional trim nosub)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
220 "Return a list of all fonts sorted by proximity to PATTERN.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
221 Each font is represented by a fontconfig pattern object.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
222
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
223 DEVICE is an X11 device.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
224 PATTERN is a fontconfig pattern to be matched.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
225 Optional argument TRIM, if non-nil, means to trim trailing fonts that do not
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
226 contribute new characters to the union repertoire.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
227
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
228 #### Optional argument NOSUB, if non-nil, suppresses some of the usual
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
229 property substitutions. DON'T USE THIS in production code, it is intended
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
230 for exploring behavior of fontconfig and will be removed when this code is
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
231 stable.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
232
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
233 #### DEVICE is unused, ignored, and may be removed if it's not needed to
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
234 match other font-listing APIs."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
235 (error 'unimplemented "font-mgr library is experimental and incomplete"))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
236
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
237 (defun xlfd-font-name-p (fontname)
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
238 "Check whether the string FONTNAME is a XLFD font name."
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
239 (save-match-data
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
240 (string-match xft-xlfd-font-regexp fontname)))
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
241
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
242 ;; FcPatternPrint: there is no point in having wrappers fc-pattern-print,
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
243 ;; Ffc_pattern_print since this function prints to stdout.
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
244
15fb91e3a115 [xemacs-hg @ 2006-04-23 16:11:16 by stephent]
stephent
parents:
diff changeset
245 ;;; end font-mgr.el