Mercurial > hg > xemacs-beta
annotate src/font-mgr.c @ 5127:a9c41067dd88 ben-lisp-object
more cleanups, terminology clarification, lots of doc work
-------------------- ChangeLog entries follow: --------------------
man/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* internals/internals.texi (Introduction to Allocation):
* internals/internals.texi (Integers and Characters):
* internals/internals.texi (Allocation from Frob Blocks):
* internals/internals.texi (lrecords):
* internals/internals.texi (Low-level allocation):
Rewrite section on allocation of Lisp objects to reflect the new
reality. Remove references to nonexistent XSETINT and XSETCHAR.
modules/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* postgresql/postgresql.c (allocate_pgconn):
* postgresql/postgresql.c (allocate_pgresult):
* postgresql/postgresql.h (struct Lisp_PGconn):
* postgresql/postgresql.h (struct Lisp_PGresult):
* ldap/eldap.c (allocate_ldap):
* ldap/eldap.h (struct Lisp_LDAP):
Same changes as in src/ dir. See large log there in ChangeLog,
but basically:
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
../hlo/src/ChangeLog addition:
2010-03-05 Ben Wing <ben@xemacs.org>
* alloc.c:
* alloc.c (old_alloc_sized_lcrecord):
* alloc.c (very_old_free_lcrecord):
* alloc.c (copy_lisp_object):
* alloc.c (zero_sized_lisp_object):
* alloc.c (zero_nonsized_lisp_object):
* alloc.c (lisp_object_storage_size):
* alloc.c (free_normal_lisp_object):
* alloc.c (FREE_FIXED_TYPE_WHEN_NOT_IN_GC):
* alloc.c (ALLOC_FROB_BLOCK_LISP_OBJECT):
* alloc.c (Fcons):
* alloc.c (noseeum_cons):
* alloc.c (make_float):
* alloc.c (make_bignum):
* alloc.c (make_bignum_bg):
* alloc.c (make_ratio):
* alloc.c (make_ratio_bg):
* alloc.c (make_ratio_rt):
* alloc.c (make_bigfloat):
* alloc.c (make_bigfloat_bf):
* alloc.c (size_vector):
* alloc.c (make_compiled_function):
* alloc.c (Fmake_symbol):
* alloc.c (allocate_extent):
* alloc.c (allocate_event):
* alloc.c (make_key_data):
* alloc.c (make_button_data):
* alloc.c (make_motion_data):
* alloc.c (make_process_data):
* alloc.c (make_timeout_data):
* alloc.c (make_magic_data):
* alloc.c (make_magic_eval_data):
* alloc.c (make_eval_data):
* alloc.c (make_misc_user_data):
* alloc.c (Fmake_marker):
* alloc.c (noseeum_make_marker):
* alloc.c (size_string_direct_data):
* alloc.c (make_uninit_string):
* alloc.c (make_string_nocopy):
* alloc.c (mark_lcrecord_list):
* alloc.c (alloc_managed_lcrecord):
* alloc.c (free_managed_lcrecord):
* alloc.c (sweep_lcrecords_1):
* alloc.c (malloced_storage_size):
* buffer.c (allocate_buffer):
* buffer.c (compute_buffer_usage):
* buffer.c (DEFVAR_BUFFER_LOCAL_1):
* buffer.c (nuke_all_buffer_slots):
* buffer.c (common_init_complex_vars_of_buffer):
* buffer.h (struct buffer_text):
* buffer.h (struct buffer):
* bytecode.c:
* bytecode.c (make_compiled_function_args):
* bytecode.c (size_compiled_function_args):
* bytecode.h (struct compiled_function_args):
* casetab.c (allocate_case_table):
* casetab.h (struct Lisp_Case_Table):
* charset.h (struct Lisp_Charset):
* chartab.c (fill_char_table):
* chartab.c (Fmake_char_table):
* chartab.c (make_char_table_entry):
* chartab.c (copy_char_table_entry):
* chartab.c (Fcopy_char_table):
* chartab.c (put_char_table):
* chartab.h (struct Lisp_Char_Table_Entry):
* chartab.h (struct Lisp_Char_Table):
* console-gtk-impl.h (struct gtk_device):
* console-gtk-impl.h (struct gtk_frame):
* console-impl.h (struct console):
* console-msw-impl.h (struct Lisp_Devmode):
* console-msw-impl.h (struct mswindows_device):
* console-msw-impl.h (struct msprinter_device):
* console-msw-impl.h (struct mswindows_frame):
* console-msw-impl.h (struct mswindows_dialog_id):
* console-stream-impl.h (struct stream_console):
* console-stream.c (stream_init_console):
* console-tty-impl.h (struct tty_console):
* console-tty-impl.h (struct tty_device):
* console-tty.c (allocate_tty_console_struct):
* console-x-impl.h (struct x_device):
* console-x-impl.h (struct x_frame):
* console.c (allocate_console):
* console.c (nuke_all_console_slots):
* console.c (DEFVAR_CONSOLE_LOCAL_1):
* console.c (common_init_complex_vars_of_console):
* data.c (make_weak_list):
* data.c (make_weak_box):
* data.c (make_ephemeron):
* database.c:
* database.c (struct Lisp_Database):
* database.c (allocate_database):
* database.c (finalize_database):
* device-gtk.c (allocate_gtk_device_struct):
* device-impl.h (struct device):
* device-msw.c:
* device-msw.c (mswindows_init_device):
* device-msw.c (msprinter_init_device):
* device-msw.c (finalize_devmode):
* device-msw.c (allocate_devmode):
* device-tty.c (allocate_tty_device_struct):
* device-x.c (allocate_x_device_struct):
* device.c:
* device.c (nuke_all_device_slots):
* device.c (allocate_device):
* dialog-msw.c (handle_question_dialog_box):
* elhash.c:
* elhash.c (struct Lisp_Hash_Table):
* elhash.c (finalize_hash_table):
* elhash.c (make_general_lisp_hash_table):
* elhash.c (Fcopy_hash_table):
* elhash.h (htentry):
* emacs.c (main_1):
* eval.c:
* eval.c (size_multiple_value):
* event-stream.c (finalize_command_builder):
* event-stream.c (allocate_command_builder):
* event-stream.c (free_command_builder):
* event-stream.c (event_stream_generate_wakeup):
* event-stream.c (event_stream_resignal_wakeup):
* event-stream.c (event_stream_disable_wakeup):
* event-stream.c (event_stream_wakeup_pending_p):
* events.h (struct Lisp_Timeout):
* events.h (struct command_builder):
* extents-impl.h:
* extents-impl.h (struct extent_auxiliary):
* extents-impl.h (struct extent_info):
* extents-impl.h (set_extent_no_chase_aux_field):
* extents-impl.h (set_extent_no_chase_normal_field):
* extents.c:
* extents.c (gap_array_marker):
* extents.c (gap_array):
* extents.c (extent_list_marker):
* extents.c (extent_list):
* extents.c (stack_of_extents):
* extents.c (gap_array_make_marker):
* extents.c (extent_list_make_marker):
* extents.c (allocate_extent_list):
* extents.c (SLOT):
* extents.c (mark_extent_auxiliary):
* extents.c (allocate_extent_auxiliary):
* extents.c (attach_extent_auxiliary):
* extents.c (size_gap_array):
* extents.c (finalize_extent_info):
* extents.c (allocate_extent_info):
* extents.c (uninit_buffer_extents):
* extents.c (allocate_soe):
* extents.c (copy_extent):
* extents.c (vars_of_extents):
* extents.h:
* faces.c (allocate_face):
* faces.h (struct Lisp_Face):
* faces.h (struct face_cachel):
* file-coding.c:
* file-coding.c (finalize_coding_system):
* file-coding.c (sizeof_coding_system):
* file-coding.c (Fcopy_coding_system):
* file-coding.h (struct Lisp_Coding_System):
* file-coding.h (MARKED_SLOT):
* fns.c (size_bit_vector):
* font-mgr.c:
* font-mgr.c (finalize_fc_pattern):
* font-mgr.c (print_fc_pattern):
* font-mgr.c (Ffc_pattern_p):
* font-mgr.c (Ffc_pattern_create):
* font-mgr.c (Ffc_name_parse):
* font-mgr.c (Ffc_name_unparse):
* font-mgr.c (Ffc_pattern_duplicate):
* font-mgr.c (Ffc_pattern_add):
* font-mgr.c (Ffc_pattern_del):
* font-mgr.c (Ffc_pattern_get):
* font-mgr.c (fc_config_create_using):
* font-mgr.c (fc_strlist_to_lisp_using):
* font-mgr.c (fontset_to_list):
* font-mgr.c (Ffc_config_p):
* font-mgr.c (Ffc_config_up_to_date):
* font-mgr.c (Ffc_config_build_fonts):
* font-mgr.c (Ffc_config_get_cache):
* font-mgr.c (Ffc_config_get_fonts):
* font-mgr.c (Ffc_config_set_current):
* font-mgr.c (Ffc_config_get_blanks):
* font-mgr.c (Ffc_config_get_rescan_interval):
* font-mgr.c (Ffc_config_set_rescan_interval):
* font-mgr.c (Ffc_config_app_font_add_file):
* font-mgr.c (Ffc_config_app_font_add_dir):
* font-mgr.c (Ffc_config_app_font_clear):
* font-mgr.c (size):
* font-mgr.c (Ffc_config_substitute):
* font-mgr.c (Ffc_font_render_prepare):
* font-mgr.c (Ffc_font_match):
* font-mgr.c (Ffc_font_sort):
* font-mgr.c (finalize_fc_config):
* font-mgr.c (print_fc_config):
* font-mgr.h:
* font-mgr.h (struct fc_pattern):
* font-mgr.h (XFC_PATTERN):
* font-mgr.h (struct fc_config):
* font-mgr.h (XFC_CONFIG):
* frame-gtk.c (allocate_gtk_frame_struct):
* frame-impl.h (struct frame):
* frame-msw.c (mswindows_init_frame_1):
* frame-x.c (allocate_x_frame_struct):
* frame.c (nuke_all_frame_slots):
* frame.c (allocate_frame_core):
* gc.c:
* gc.c (GC_CHECK_NOT_FREE):
* glyphs.c (finalize_image_instance):
* glyphs.c (allocate_image_instance):
* glyphs.c (Fcolorize_image_instance):
* glyphs.c (allocate_glyph):
* glyphs.c (unmap_subwindow_instance_cache_mapper):
* glyphs.c (register_ignored_expose):
* glyphs.h (struct Lisp_Image_Instance):
* glyphs.h (struct Lisp_Glyph):
* glyphs.h (struct glyph_cachel):
* glyphs.h (struct expose_ignore):
* gui.c (allocate_gui_item):
* gui.h (struct Lisp_Gui_Item):
* keymap.c (struct Lisp_Keymap):
* keymap.c (make_keymap):
* lisp.h:
* lisp.h (struct Lisp_String_Direct_Data):
* lisp.h (struct Lisp_String_Indirect_Data):
* lisp.h (struct Lisp_Vector):
* lisp.h (struct Lisp_Bit_Vector):
* lisp.h (DECLARE_INLINE_LISP_BIT_VECTOR):
* lisp.h (struct weak_box):
* lisp.h (struct ephemeron):
* lisp.h (struct weak_list):
* lrecord.h:
* lrecord.h (struct lrecord_implementation):
* lrecord.h (MC_ALLOC_CALL_FINALIZER):
* lrecord.h (struct lcrecord_list):
* lstream.c (finalize_lstream):
* lstream.c (sizeof_lstream):
* lstream.c (Lstream_new):
* lstream.c (Lstream_delete):
* lstream.h (struct lstream):
* marker.c:
* marker.c (finalize_marker):
* marker.c (compute_buffer_marker_usage):
* mule-charset.c:
* mule-charset.c (make_charset):
* mule-charset.c (compute_charset_usage):
* objects-impl.h (struct Lisp_Color_Instance):
* objects-impl.h (struct Lisp_Font_Instance):
* objects-tty-impl.h (struct tty_color_instance_data):
* objects-tty-impl.h (struct tty_font_instance_data):
* objects-tty.c (tty_initialize_color_instance):
* objects-tty.c (tty_initialize_font_instance):
* objects.c (finalize_color_instance):
* objects.c (Fmake_color_instance):
* objects.c (finalize_font_instance):
* objects.c (Fmake_font_instance):
* objects.c (reinit_vars_of_objects):
* opaque.c:
* opaque.c (sizeof_opaque):
* opaque.c (make_opaque_ptr):
* opaque.c (free_opaque_ptr):
* opaque.h:
* opaque.h (Lisp_Opaque):
* opaque.h (Lisp_Opaque_Ptr):
* print.c (printing_unreadable_lcrecord):
* print.c (external_object_printer):
* print.c (debug_p4):
* process.c (finalize_process):
* process.c (make_process_internal):
* procimpl.h (struct Lisp_Process):
* rangetab.c (Fmake_range_table):
* rangetab.c (Fcopy_range_table):
* rangetab.h (struct Lisp_Range_Table):
* scrollbar.c:
* scrollbar.c (create_scrollbar_instance):
* scrollbar.c (compute_scrollbar_instance_usage):
* scrollbar.h (struct scrollbar_instance):
* specifier.c (finalize_specifier):
* specifier.c (sizeof_specifier):
* specifier.c (set_specifier_caching):
* specifier.h (struct Lisp_Specifier):
* specifier.h (struct specifier_caching):
* symeval.h:
* symeval.h (SYMBOL_VALUE_MAGIC_P):
* symeval.h (DEFVAR_SYMVAL_FWD):
* symsinit.h:
* syntax.c (init_buffer_syntax_cache):
* syntax.h (struct syntax_cache):
* toolbar.c:
* toolbar.c (allocate_toolbar_button):
* toolbar.c (update_toolbar_button):
* toolbar.h (struct toolbar_button):
* tooltalk.c (struct Lisp_Tooltalk_Message):
* tooltalk.c (make_tooltalk_message):
* tooltalk.c (struct Lisp_Tooltalk_Pattern):
* tooltalk.c (make_tooltalk_pattern):
* ui-gtk.c:
* ui-gtk.c (allocate_ffi_data):
* ui-gtk.c (emacs_gtk_object_finalizer):
* ui-gtk.c (allocate_emacs_gtk_object_data):
* ui-gtk.c (allocate_emacs_gtk_boxed_data):
* ui-gtk.h:
* window-impl.h (struct window):
* window-impl.h (struct window_mirror):
* window.c (finalize_window):
* window.c (allocate_window):
* window.c (new_window_mirror):
* window.c (mark_window_as_deleted):
* window.c (make_dummy_parent):
* window.c (compute_window_mirror_usage):
* window.c (compute_window_usage):
Overall point of this change and previous ones in this repository:
(1) Introduce new, clearer terminology: everything other than int
or char is a "record" object, which comes in two types: "normal
objects" and "frob-block objects". Fix up all places that
referred to frob-block objects as "simple", "basic", etc.
(2) Provide an advertised interface for doing operations on Lisp
objects, including creating new types, that is clean and
consistent in its naming, uses the above-referenced terms and
avoids referencing "lrecords", "old lcrecords", etc., which should
hide under the surface.
(3) Make the size_in_bytes and finalizer methods take a
Lisp_Object rather than a void * for consistency with other methods.
(4) Separate finalizer method into finalizer and disksaver, so
that normal finalize methods don't have to worry about disksaving.
Other specifics:
(1) Renaming:
LISP_OBJECT_HEADER -> NORMAL_LISP_OBJECT_HEADER
ALLOC_LISP_OBJECT -> ALLOC_NORMAL_LISP_OBJECT
implementation->basic_p -> implementation->frob_block_p
ALLOCATE_FIXED_TYPE_AND_SET_IMPL -> ALLOC_FROB_BLOCK_LISP_OBJECT
*FCCONFIG*, wrap_fcconfig -> *FC_CONFIG*, wrap_fc_config
*FCPATTERN*, wrap_fcpattern -> *FC_PATTERN*, wrap_fc_pattern
(the last two changes make the naming of these macros consistent
with the naming of all other macros, since the objects are named
fc-config and fc-pattern with a hyphen)
(2) Lots of documentation fixes in lrecord.h.
(3) Eliminate macros for copying, freeing, zeroing objects, getting
their storage size. Instead, new functions:
zero_sized_lisp_object()
zero_nonsized_lisp_object()
lisp_object_storage_size()
free_normal_lisp_object()
(copy_lisp_object() already exists)
LISP_OBJECT_FROB_BLOCK_P() (actually a macro)
Eliminated:
free_lrecord()
zero_lrecord()
copy_lrecord()
copy_sized_lrecord()
old_copy_lcrecord()
old_copy_sized_lcrecord()
old_zero_lcrecord()
old_zero_sized_lcrecord()
LISP_OBJECT_STORAGE_SIZE()
COPY_SIZED_LISP_OBJECT()
COPY_SIZED_LCRECORD()
COPY_LISP_OBJECT()
ZERO_LISP_OBJECT()
FREE_LISP_OBJECT()
(4) Catch the remaining places where lrecord stuff was used directly
and use the advertised interface, e.g. alloc_sized_lrecord() ->
ALLOC_SIZED_LISP_OBJECT().
(5) Make certain statically-declared pseudo-objects
(buffer_local_flags, console_local_flags) have their lheader
initialized correctly, so things like copy_lisp_object() can work
on them. Make extent_auxiliary_defaults a proper heap object
Vextent_auxiliary_defaults, and make extent auxiliaries dumpable
so that this object can be dumped. allocate_extent_auxiliary()
now just creates the object, and attach_extent_auxiliary()
creates an extent auxiliary and attaches to an extent, like the
old allocate_extent_auxiliary().
(6) Create EXTENT_AUXILIARY_SLOTS macro, similar to the foo-slots.h
files but in a macro instead of a file. The purpose is to avoid
duplication when iterating over all the slots in an extent auxiliary.
Use it.
(7) In lstream.c, don't zero out object after allocation because
allocation routines take care of this.
(8) In marker.c, fix a mistake in computing marker overhead.
(9) In print.c, clean up printing_unreadable_lcrecord(),
external_object_printer() to avoid lots of ifdef NEW_GC's.
(10) Separate toolbar-button allocation into a separate
allocate_toolbar_button() function for use in the example code
in lrecord.h.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Fri, 05 Mar 2010 04:08:17 -0600 |
parents | b5df3737028a |
children | f965e31a35f0 |
rev | line source |
---|---|
3354 | 1 /* Lisp font handling implementation for X with Xft. |
2 | |
3 Copyright (C) 2003 Eric Knauel and Matthias Neubauer | |
4 Copyright (C) 2005 Eric Knauel | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
5 Copyright (C) 2004-2009 Free Software Foundation, Inc. |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
6 Copyright (C) 2010 Ben Wing. |
3354 | 7 |
8 Authors: Eric Knauel <knauel@informatik.uni-tuebingen.de> | |
9 Matthias Neubauer <neubauer@informatik.uni-freiburg.de> | |
10 Stephen J. Turnbull <stephen@xemacs.org> | |
11 Created: 27 Oct 2003 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
12 Updated: 18 November 2009 by Stephen J. Turnbull |
3354 | 13 |
14 This file is part of XEmacs. | |
15 | |
16 XEmacs is free software; you can redistribute it and/or modify it | |
17 under the terms of the GNU General Public License as published by the | |
18 Free Software Foundation; either version 2, or (at your option) any | |
19 later version. | |
20 | |
21 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
23 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
24 for more details. | |
25 | |
26 You should have received a copy of the GNU General Public License | |
27 along with XEmacs; see the file COPYING. If not, write to | |
28 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
29 Boston, MA 02111-1307, USA. */ | |
30 | |
31 /* Synched up with: Not in GNU Emacs. */ | |
32 | |
33 /* This module provides the Lisp interface to fonts in X11, including Xft, | |
34 but (at least at first) not GTK+ or Qt. | |
35 | |
36 Sealevel code should be in ../lwlib/lwlib-fonts.c or | |
37 ../lwlib/lwlib-colors.c. | |
38 */ | |
39 | |
40 #include <config.h> | |
41 #include "lisp.h" | |
42 #include "device.h" | |
43 #include "device-impl.h" | |
44 #include "console-x-impl.h" | |
45 #include "objects-x.h" | |
46 #include "objects-x-impl.h" | |
47 #include "hash.h" | |
48 #include "font-mgr.h" | |
49 | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
50 #include "sysfile.h" |
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
51 |
3354 | 52 /* #### TO DO #### |
53 . The "x-xft-*" and "x_xft_*" nomenclature is mostly redundant, especially | |
54 if we separate X fonts from Xft fonts, and use fontconfig more generally. | |
55 . We should support the most recent Xft first, old Xft libraries later. | |
56 . We may (think about it) wish to use fontconfig generally, even if we're | |
57 not using Xft. Either way, names that are really from fontconfig should | |
58 use the Fc* namespace. | |
59 . Mule-ize this file. | |
60 . Separate X Font Struct ops from Xft Font ops; give precedence to Xft but | |
61 allow fallback to X. | |
62 . Push decisions about font choice, defaults, fallbacks to Lisp; if we | |
63 really need efficiency, can reimplement in C later. | |
64 . Implement symbols interned in this file in the Q* namespace. | |
65 . Implement FcMatrix (Lisp vector). | |
66 . Implement FcCharSets (Lisp chartable? For implementation hints, see | |
67 FcCharSetFirstPage and FcCharSetNextPage). | |
68 . Implement FcConfigs. | |
69 DONE | |
70 . Fontconfig fontnames are encoded in UTF-8. | |
71 */ | |
72 | |
3360 | 73 Lisp_Object Qfont_mgr; |
3354 | 74 Lisp_Object Qfc_patternp; |
75 /* Lisp_Object Qfc_result_match; */ /* FcResultMatch */ | |
76 Lisp_Object Qfc_result_type_mismatch; /* FcResultTypeMismatch */ | |
77 Lisp_Object Qfc_result_no_match; /* FcResultNoMatch */ | |
78 Lisp_Object Qfc_result_no_id; /* FcResultNoId */ | |
79 Lisp_Object Qfc_internal_error; | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
80 Lisp_Object Qfc_match_pattern; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
81 Lisp_Object Qfc_match_font; |
3354 | 82 Lisp_Object Vxlfd_font_name_regexp; /* #### Really needed? */ |
3935 | 83 Fixnum xft_version; |
84 Fixnum fc_version; | |
3354 | 85 Fixnum debug_xft; /* Set to 1 enables lots of obnoxious messages. |
86 Setting it to 2 or 3 enables even more. */ | |
3931 | 87 #ifdef FONTCONFIG_EXPOSE_CONFIG |
88 Lisp_Object Qfc_configp; | |
89 static Lisp_Object Vfc_config_weak_list; | |
90 #endif | |
3354 | 91 |
92 /**************************************************************** | |
93 * FcPattern objects * | |
94 ****************************************************************/ | |
95 | |
96 static void | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
97 finalize_fc_pattern (Lisp_Object obj) |
3354 | 98 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
99 struct fc_pattern *p = XFC_PATTERN (obj); |
3354 | 100 if (p->fcpatPtr) |
101 { | |
102 FcPatternDestroy (p->fcpatPtr); | |
103 p->fcpatPtr = 0; | |
104 } | |
105 } | |
106 | |
3906 | 107 static void |
108 print_fc_pattern (Lisp_Object obj, Lisp_Object printcharfun, | |
109 int UNUSED(escapeflag)) | |
110 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
111 struct fc_pattern *c = XFC_PATTERN (obj); |
3906 | 112 if (print_readably) |
113 printing_unreadable_object ("#<fc-pattern 0x%x>", c->header.uid); | |
114 write_fmt_string (printcharfun, "#<fc-pattern 0x%x>", c->header.uid); | |
115 } | |
116 | |
117 /* #### We really need an equal method and a hash method (required if you | |
118 have an equal method). For the equal method, we can probably use one | |
119 or both of | |
120 | |
121 -- Function: FcBool FcPatternEqual (const FcPattern *pa, const | |
122 FcPattern *pb); | |
123 Returns whether PA and PB are exactly alike. | |
124 | |
125 -- Function: FcBool FcPatternEqualSubset (const FcPattern *pa, const | |
126 FcPattern *pb, const FcObjectSet *os) | |
127 Returns whether PA and PB have exactly the same values for all of | |
128 the objects in OS. | |
129 | |
130 For the hash, we'll have to extract some subset of attributes. | |
131 | |
132 #### Crap. It's altogether unobvious what we need. x_color_instance | |
133 does have a hash method, but fonts are apparently special. I get the | |
134 feeling that for this to work properly we're going to need to switch | |
135 to fontconfig-based font specifications (although we can allow the | |
136 platform syntaxes, the underlying specification object will need to | |
137 conform to the fontconfig API, or more precisely the font-mgr API). | |
138 | |
139 I think the whole `font-truename' interface needs to be dropped. */ | |
140 | |
3354 | 141 static const struct memory_description fcpattern_description [] = { |
142 /* #### nothing here, is this right?? */ | |
143 { XD_END } | |
144 }; | |
145 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
146 DEFINE_NODUMP_LISP_OBJECT ("fc-pattern", fc_pattern, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
147 0, print_fc_pattern, finalize_fc_pattern, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
148 0, 0, fcpattern_description, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
149 struct fc_pattern); |
3354 | 150 |
151 /* | |
152 * Helper Functions | |
153 */ | |
154 static Lisp_Object make_xlfd_font_regexp (void); | |
155 static void string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os); | |
156 | |
157 /* | |
158 extract the C representation of the Lisp string STR and convert it | |
159 to the encoding used by the Fontconfig API for property and font | |
160 names. I suppose that Qnative is the right encoding, the manual | |
161 doesn't say much about this topic. This functions assumes that STR | |
162 is a Lisp string. | |
163 */ | |
164 #define extract_fcapi_string(str) \ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
165 (LISP_STRING_TO_EXTERNAL ((str), Qfc_font_name_encoding)) |
3354 | 166 |
3906 | 167 #define build_fcapi_string(str) \ |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
168 (build_extstring ((Extbyte *) (str), Qfc_font_name_encoding)) |
3906 | 169 |
3360 | 170 /* #### This homebrew lashup should be replaced with FcConstants. |
171 | |
172 fontconfig assumes that objects (property names) are statically allocated, | |
3354 | 173 and you will get bizarre results if you pass Lisp string data or strings |
174 allocated on the stack as objects. fontconfig _does_ copy values, so we | |
175 (I hope) don't have to worry about that member. | |
176 | |
177 Probably these functions don't get called so often that the memory leak | |
178 due to strdup'ing every time we add a property would matter, but XEmacs | |
179 _is_ a long-running process. So we hash them. | |
180 | |
181 I suspect that using symbol names or even keywords does not provide | |
182 assurance that the string won't move in memory. So we hash them | |
3360 | 183 ourselves; hash.c hashtables do not interpret the value pointers. |
184 | |
185 This array should be FcChar8**, but GCC 4.x bitches about signedness. */ | |
4932 | 186 static const Extbyte *fc_standard_properties[] = { |
3360 | 187 /* treated specially, ordered first */ |
188 "family", "size", | |
189 /* remaining are alphabetized by group */ | |
190 /* standard properties in fontconfig and Xft v.2 */ | |
191 "antialias", "aspect", "autohint", "charset", "dpi", "file", | |
3354 | 192 "foundry", "ftface", "globaladvance", "hinting", "index", "lang", |
193 "minspace", "outline", "pixelsize", "rasterizer", "rgba", "scalable", | |
3360 | 194 "scale", "slant", "spacing", "style", "verticallayout", "weight", |
195 /* common in modern fonts */ | |
196 "fontformat", "fontversion", | |
3354 | 197 /* obsolete after Xft v. 1 */ |
198 "charwidth", "charheight", "core", "encoding", "render" | |
199 }; | |
200 | |
201 static struct hash_table *fc_property_name_hash_table; | |
202 | |
203 /* #### Maybe fc_intern should be exposed to LISP? The idea is that | |
204 fc-pattern-add could warn or error if the property isn't interned. */ | |
205 | |
3469 | 206 static const Extbyte * |
3354 | 207 fc_intern (Lisp_Object property) |
208 { | |
209 const void *dummy; | |
3469 | 210 const Extbyte *prop = extract_fcapi_string (property); |
3354 | 211 const void *val = gethash (prop, fc_property_name_hash_table, &dummy); |
212 | |
213 /* extract_fcapi_string returns something alloca'd | |
214 so we can just drop the old value of prop on the floor */ | |
215 if (val) | |
3469 | 216 prop = (const Extbyte *) val; |
3354 | 217 else |
218 { | |
3469 | 219 prop = (const Extbyte *) FcStrCopy ((FcChar8 *) prop); |
3354 | 220 puthash (prop, NULL, fc_property_name_hash_table); |
221 } | |
222 return prop; | |
223 } | |
224 | |
225 DEFUN("fc-pattern-p", Ffc_pattern_p, 1, 1, 0, /* | |
226 Returns t if OBJECT is of type fc-pattern, nil otherwise. | |
227 */ | |
228 (object)) | |
229 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
230 return FC_PATTERNP(object) ? Qt : Qnil; |
3354 | 231 } |
232 | |
233 DEFUN("fc-pattern-create", Ffc_pattern_create, 0, 0, 0, /* | |
234 Return a new, empty fc-pattern object. | |
235 */ | |
236 ()) | |
237 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
238 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 239 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
240 fcpat->fcpatPtr = FcPatternCreate (); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
241 return wrap_fc_pattern (fcpat); |
3354 | 242 } |
243 | |
244 DEFUN("fc-name-parse", Ffc_name_parse, 1, 1, 0, /* | |
245 Parse an Fc font name and return its representation as a fc pattern object. | |
246 */ | |
247 (name)) | |
248 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
249 fc_pattern *fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 250 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
251 CHECK_STRING (name); |
3354 | 252 |
3469 | 253 fcpat->fcpatPtr = FcNameParse ((FcChar8 *) extract_fcapi_string (name)); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
254 return wrap_fc_pattern (fcpat); |
3354 | 255 } |
256 | |
257 /* #### Ga-a-ack! Xft's similar function is actually a different API. | |
258 We provide both. */ | |
259 DEFUN("fc-name-unparse", Ffc_name_unparse, 1, 1, 0, /* | |
260 Unparse an fc pattern object to a string. | |
261 */ | |
262 (pattern)) | |
263 { | |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
264 FcChar8 *name; |
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
265 Lisp_Object result; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
266 CHECK_FC_PATTERN(pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
267 name = FcNameUnparse (XFC_PATTERN_PTR (pattern)); |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
268 result = build_fcapi_string (name); |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
269 xfree (name); |
4799
ca99a807b025
Free, rather than discard, the return value of FcNameUnparse. See message
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
270 return result; |
3354 | 271 } |
272 | |
273 DEFUN("fc-pattern-duplicate", Ffc_pattern_duplicate, 1, 1, 0, /* | |
274 Make a copy of the fc pattern object PATTERN and return it. | |
275 */ | |
276 (pattern)) | |
277 { | |
278 struct fc_pattern *copy = NULL; | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
279 CHECK_FC_PATTERN (pattern); |
3354 | 280 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
281 copy = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
282 copy->fcpatPtr = FcPatternDuplicate (XFC_PATTERN_PTR (pattern)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
283 return wrap_fc_pattern (copy); |
3354 | 284 } |
285 | |
286 DEFUN("fc-pattern-add", Ffc_pattern_add, 3, 3, 0, /* | |
287 Add attributes to the pattern object PATTERN. PROPERTY is a string naming | |
288 the attribute to add, VALUE the value for this attribute. | |
289 | |
290 VALUE may be a string, integer, float, or symbol, in which case the value | |
291 will be added as an FcChar8[], int, double, or FcBool respectively. | |
292 */ | |
293 (pattern, property, value)) | |
294 { | |
295 Bool res = 0; | |
3469 | 296 const Extbyte *obj; |
3354 | 297 FcPattern *fcpat; |
298 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
299 CHECK_FC_PATTERN (pattern); |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
300 CHECK_STRING (property); |
3354 | 301 |
302 obj = fc_intern (property); | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
303 fcpat = XFC_PATTERN_PTR (pattern); |
3354 | 304 |
305 if (STRINGP(value)) | |
306 { | |
307 FcChar8 *str = (FcChar8 *) extract_fcapi_string (value); | |
308 res = FcPatternAddString (fcpat, obj, str); | |
309 } | |
310 else if (INTP(value)) | |
311 { | |
312 res = FcPatternAddInteger (fcpat, obj, XINT(value)); | |
313 } | |
314 else if (FLOATP(value)) | |
315 { | |
316 res = FcPatternAddDouble (fcpat, obj, (double) XFLOAT_DATA(value)); | |
317 } | |
318 else if (SYMBOLP(value)) | |
319 { | |
320 res = FcPatternAddBool (fcpat, obj, !NILP(value)); | |
321 } | |
322 /* else ... maybe we should wta here? */ | |
323 | |
324 return res ? Qt : Qnil; | |
325 } | |
326 | |
327 DEFUN("fc-pattern-del", Ffc_pattern_del, 2, 2, 0, /* | |
328 Remove attribute PROPERTY from fc pattern object OBJECT. | |
329 */ | |
330 (pattern, property)) | |
331 { | |
332 Bool res; | |
333 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
334 CHECK_FC_PATTERN(pattern); |
3354 | 335 CHECK_STRING(property); |
336 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
337 res = FcPatternDel(XFC_PATTERN_PTR(pattern), extract_fcapi_string (property)); |
3354 | 338 return res ? Qt : Qnil; |
339 } | |
340 | |
341 /* Generic interface to FcPatternGet() | |
342 * Don't support the losing symbol-for-property interface. | |
343 */ | |
344 DEFUN("fc-pattern-get", Ffc_pattern_get, 2, 4, 0, /* | |
345 From PATTERN, extract PROPERTY for the ID'th member, of type TYPE. | |
346 | |
347 PATTERN is an Xft (fontconfig) pattern object. | |
348 PROPERTY is a string naming an fontconfig font property. | |
349 Optional ID is a nonnegative integer indexing the list of values for PROPERTY | |
350 stored in PATTERN, defaulting to 0 (the first value). | |
351 Optional TYPE is a symbol, one of 'string, 'boolean, 'integer, 'float, | |
352 'double, 'matrix, 'charset, or 'void, corresponding to the FcValue types. | |
353 ('float is an alias for 'double). | |
354 | |
355 The Lisp types returned will conform to TYPE: | |
356 string string | |
357 boolean `t' or `nil' | |
358 integer integer | |
359 double (float) float | |
360 matrix not implemented | |
361 charset not implemented | |
362 void not implemented | |
363 | |
364 Symbols with names of the form "fc-result-DESCRIPTION" are returned when | |
365 the desired value is not available. These are | |
366 | |
367 fc-result-type-mismatch the value found has an unexpected type | |
368 fc-result-no-match there is no such attribute | |
369 fc-result-no-id there is no value for the requested ID | |
370 | |
371 The types of the following standard properties are predefined by fontconfig. | |
372 The symbol 'fc-result-type-mismatch will be returned if the object exists but | |
373 TYPE does not match the predefined type. It is best not to specify a type | |
374 for predefined properties, as a mistake here ensures error returns on the | |
375 correct type. | |
376 | |
377 Each standard property has a convenience accessor defined in fontconfig.el, | |
378 named in the form "fc-pattern-get-PROPERTY". The convenience functions are | |
379 preferred to `fc-pattern-get' since a typo in the string naming a property | |
380 will result in a silent null return, while a typo in a function name will | |
381 usually result in a compiler or runtime \"not fboundp\" error. You may use | |
382 `defsubst' to define convenience functions for non-standard properties. | |
383 | |
384 family String Font family name | |
385 style String Font style. Overrides weight and slant | |
386 slant Int Italic, oblique or roman | |
387 weight Int Light, medium, demibold, bold or black | |
388 size Double Point size | |
389 aspect Double Stretches glyphs horizontally before hinting | |
390 pixelsize Double Pixel size | |
391 spacing Int Proportional, monospace or charcell | |
392 foundry String Font foundry name | |
393 antialias Bool Whether glyphs can be antialiased | |
394 hinting Bool Whether the rasterizer should use hinting | |
395 verticallayout Bool Use vertical layout | |
396 autohint Bool Use autohinter instead of normal hinter | |
397 globaladvance Bool Use font global advance data | |
398 file String The filename holding the font | |
399 index Int The index of the font within the file | |
400 ftface FT_Face Use the specified FreeType face object | |
401 rasterizer String Which rasterizer is in use | |
402 outline Bool Whether the glyphs are outlines | |
403 scalable Bool Whether glyphs can be scaled | |
404 scale Double Scale factor for point->pixel conversions | |
405 dpi Double Target dots per inch | |
406 rgba Int unknown, rgb, bgr, vrgb, vbgr, none - subpixel geometry | |
407 minspace Bool Eliminate leading from line spacing | |
408 charset CharSet Unicode chars encoded by the font | |
409 lang String List of RFC-3066-style languages this font supports | |
410 | |
411 The FT_Face, Matrix, CharSet types are unimplemented, so the corresponding | |
412 properties are not accessible from Lisp at this time. If the value of a | |
413 property returned has type FT_Face, FcCharSet, or FcMatrix, | |
414 `fc-result-type-mismatch' is returned. | |
415 | |
416 The following properties which were standard in Xft v.1 are obsolete in | |
417 Xft v.2: encoding, charwidth, charheight, core, and render. */ | |
418 (pattern, property, id, type)) | |
419 { | |
3469 | 420 Extbyte *fc_property; |
3354 | 421 FcResult fc_result; |
422 FcValue fc_value; | |
423 | |
424 /* | |
425 process arguments | |
426 */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
427 CHECK_FC_PATTERN (pattern); |
3354 | 428 |
429 #if 0 | |
430 /* Don't support the losing symbol-for-property interface. */ | |
431 property = SYMBOLP (property) ? symbol_name (XSYMBOL (property)) : property; | |
432 #endif | |
433 if (STRINGP (property)) | |
434 { | |
3469 | 435 fc_property = extract_fcapi_string (property); |
3354 | 436 } |
437 else | |
438 { | |
439 /* if we allow symbols, this would need to be | |
440 list3 (Qlambda, list1 (Qobject), | |
441 list3 (Qor, list2 (Qstringp, Qobject), | |
442 list2 (Qsymbolp, Qobject))) | |
443 or something like that? */ | |
444 dead_wrong_type_argument (Qstringp, property); | |
445 } | |
446 | |
447 if (!NILP (id)) CHECK_NATNUM (id); | |
448 if (!NILP (type)) CHECK_SYMBOL (type); | |
449 | |
450 /* get property */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
451 fc_result = FcPatternGet (XFC_PATTERN_PTR (pattern), |
3354 | 452 fc_property, |
453 NILP (id) ? 0 : XINT(id), | |
454 &fc_value); | |
455 | |
456 switch (fc_result) | |
457 { | |
458 case FcResultMatch: | |
459 /* wrap it and return */ | |
460 switch (fc_value.type) | |
461 { | |
462 case FcTypeInteger: | |
463 return ((!NILP (type) && !EQ (type, Qinteger)) | |
464 ? Qfc_result_type_mismatch : make_int (fc_value.u.i)); | |
465 case FcTypeDouble: | |
466 return ((!NILP (type) && !EQ (type, intern ("double")) | |
467 && !EQ (type, Qfloat)) | |
468 ? Qfc_result_type_mismatch : make_float (fc_value.u.d)); | |
469 case FcTypeString: | |
470 return ((!NILP (type) && !EQ (type, Qstring)) | |
471 ? Qfc_result_type_mismatch | |
3906 | 472 : build_fcapi_string (fc_value.u.s)); |
3354 | 473 case FcTypeBool: |
474 return ((!NILP (type) && !EQ (type, Qboolean)) | |
475 ? Qfc_result_type_mismatch : fc_value.u.b ? Qt : Qnil); | |
476 case FcTypeMatrix: | |
477 return Qfc_result_type_mismatch; | |
478 /* #### unimplemented | |
479 return ((!NILP (type) && !EQ (type, intern ("matrix"))) | |
480 ? Qfc_result_type_mismatch : make_int (fc_value.u.m)); | |
481 */ | |
482 case FcTypeCharSet: | |
483 return Qfc_result_type_mismatch; | |
484 /* #### unimplemented | |
485 return ((!NILP (type) && !EQ (type, intern ("charset"))) | |
486 ? Qfc_result_type_mismatch : make_int (fc_value.u.c)); | |
487 */ | |
488 } | |
489 case FcResultTypeMismatch: | |
490 return Qfc_result_type_mismatch; | |
491 case FcResultNoMatch: | |
492 return Qfc_result_no_match; | |
493 case FcResultNoId: | |
494 return Qfc_result_no_id; | |
495 default: | |
496 return Qfc_internal_error; | |
497 } | |
498 } | |
499 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
500 /* FcConfig handling functions. */ |
3354 | 501 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
502 /* We obviously need to be careful about garbage collecting the current |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
503 FcConfig. I infer from the documentation of FcConfigDestroy that that |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
504 is the only reference maintained by fontconfig. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
505 So we keep track of our own references on a weak list, and only cons a |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
506 new object if we don't already have a reference to it there. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
507 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
508 enum DestroyFontsetP { DestroyNo = 0, DestroyYes = 1 }; |
3354 | 509 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
510 static Lisp_Object |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
511 fc_config_create_using (FcConfig * (*create_function) ()) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
512 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
513 FcConfig *fc = (*create_function) (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
514 Lisp_Object configs = XWEAK_LIST_LIST (Vfc_config_weak_list); |
3354 | 515 |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
516 /* Linear search: fc_configs are not going to multiply like conses. */ |
3360 | 517 { |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
518 LIST_LOOP_2 (cfg, configs) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
519 if (fc == XFC_CONFIG_PTR (cfg)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
520 return cfg; |
3360 | 521 } |
522 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
523 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
524 fc_config *fccfg = XFC_CONFIG (ALLOC_NORMAL_LISP_OBJECT (fc_config)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
525 fccfg->fccfgPtr = fc; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
526 configs = Fcons (wrap_fc_config (fccfg), configs); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
527 XWEAK_LIST_LIST (Vfc_config_weak_list) = configs; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
528 return wrap_fc_config (fccfg); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
529 } |
3354 | 530 } |
531 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
532 static Lisp_Object |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
533 fc_strlist_to_lisp_using (FcStrList * (*getter) (FcConfig *), |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
534 Lisp_Object config) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
535 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
536 FcChar8 *thing; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
537 Lisp_Object value = Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
538 FcStrList *thing_list; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
539 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
540 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
541 thing_list = (*getter) (XFC_CONFIG_PTR(config)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
542 /* Yes, we need to do this check -- sheesh, Keith! */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
543 if (!thing_list) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
544 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
545 while ((thing = FcStrListNext (thing_list))) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
546 value = Fcons (build_fcapi_string (thing), value); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
547 FcStrListDone (thing_list); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
548 return value; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
549 } |
3931 | 550 |
3354 | 551 static Lisp_Object |
3931 | 552 fontset_to_list (FcFontSet *fontset, enum DestroyFontsetP destroyp) |
3354 | 553 { |
554 int idx; | |
555 Lisp_Object fontlist = Qnil; | |
556 fc_pattern *fcpat; | |
557 | |
558 /* #### improve this error message */ | |
559 if (!fontset) | |
4860 | 560 invalid_state ("failed to create FcFontSet", Qunbound); |
3354 | 561 for (idx = 0; idx < fontset->nfont; ++idx) |
562 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
563 fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
3354 | 564 fcpat->fcpatPtr = FcPatternDuplicate (fontset->fonts[idx]); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
565 fontlist = Fcons (wrap_fc_pattern(fcpat), fontlist); |
3354 | 566 } |
3931 | 567 if (destroyp) |
568 FcFontSetDestroy (fontset); | |
3354 | 569 return fontlist; |
570 } | |
571 | |
3931 | 572 DEFUN("fc-config-p", Ffc_config_p, 1, 1, 0, /* |
573 Returns t if OBJECT is of type fc-config, nil otherwise. | |
574 */ | |
575 (object)) | |
576 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
577 return FC_CONFIGP (object) ? Qt : Qnil; |
3931 | 578 } |
579 | |
580 DEFUN("fc-config-create", Ffc_config_create, 0, 0, 0, /* | |
581 -- Function: FcConfig *FcConfigCreate (void) | |
582 Creates an empty configuration. */ | |
583 ()) | |
584 { | |
585 return fc_config_create_using (&FcConfigCreate); | |
586 } | |
587 | |
588 #if 0 | |
589 /* I'm sorry, but we just don't do this in Lisp, OK? | |
590 Don't even think about implementing this. */ | |
591 DEFUN("fc-config-destroy", Ffc_config_destroy, 1, 1, 0, /* | |
592 -- Function: void FcConfigDestroy (FcConfig *config) | |
593 Destroys a configuration and any data associated with it. Note | |
594 that calling this function with the return value from | |
595 FcConfigGetCurrent will place the library in an indeterminate | |
596 state. */ | |
597 (config)) | |
598 { | |
599 signal_error (Qunimplemented, "No user-servicable parts!", | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
600 intern ("fc-config-destroy")); |
3931 | 601 } |
602 #endif | |
603 | |
604 DEFUN("fc-config-up-to-date", Ffc_config_up_to_date, 1, 1, 0, /* | |
605 -- Function: FcBool FcConfigUptoDate (FcConfig *config) | |
606 Checks all of the files related to 'config' and returns whether the | |
607 in-memory version is in sync with the disk version. */ | |
608 (config)) | |
609 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
610 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
611 return FcConfigUptoDate (XFC_CONFIG_PTR (config)) == FcFalse ? Qnil : Qt; |
3931 | 612 } |
613 | |
614 DEFUN("fc-config-build-fonts", Ffc_config_build_fonts, 1, 1, 0, /* | |
615 -- Function: FcBool FcConfigBuildFonts (FcConfig *config) | |
616 Builds the set of available fonts for the given configuration. | |
617 Note that any changes to the configuration after this call have | |
618 indeterminate effects. Returns FcFalse if this operation runs out | |
619 of memory. | |
620 XEmacs: signal out-of-memory, or return nil on success. */ | |
621 (config)) | |
622 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
623 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
624 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 625 out_of_memory ("FcConfigBuildFonts failed", config); |
626 return Qnil; | |
627 } | |
628 | |
629 DEFUN("fc-config-get-config-dirs", Ffc_config_get_config_dirs, 1, 1, 0, /* | |
630 -- Function: FcStrList *FcConfigGetConfigDirs (FcConfig *config) | |
631 Returns the list of font directories specified in the | |
632 configuration files for 'config'. Does not include any | |
633 subdirectories. */ | |
634 (config)) | |
635 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
636 return fc_strlist_to_lisp_using (&FcConfigGetConfigDirs, config); |
3931 | 637 } |
638 | |
639 DEFUN("fc-config-get-font-dirs", Ffc_config_get_font_dirs, 1, 1, 0, /* | |
640 -- Function: FcStrList *FcConfigGetFontDirs (FcConfig *config) | |
641 Returns the list of font directories in 'config'. This includes the | |
642 configured font directories along with any directories below those | |
643 in the filesystem. */ | |
644 (config)) | |
645 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
646 return fc_strlist_to_lisp_using (&FcConfigGetFontDirs, config); |
3931 | 647 } |
648 | |
649 DEFUN("fc-config-get-config-files", Ffc_config_get_config_files, 1, 1, 0, /* | |
650 -- Function: FcStrList *FcConfigGetConfigFiles (FcConfig *config) | |
651 Returns the list of known configuration files used to generate | |
652 'config'. Note that this will not include any configuration done | |
653 with FcConfigParse. */ | |
654 (config)) | |
655 { | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
656 return fc_strlist_to_lisp_using (&FcConfigGetConfigFiles, config); |
3931 | 657 } |
658 | |
659 DEFUN("fc-config-get-cache", Ffc_config_get_cache, 1, 1, 0, /* | |
660 -- Function: char *FcConfigGetCache (FcConfig *config) | |
661 Returns the name of the file used to store per-user font | |
662 information. */ | |
663 (config)) | |
664 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
665 CHECK_FC_CONFIG (config); |
3931 | 666 /* Surely FcConfigGetCache just casts an FcChar8* to char*. */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
667 return build_fcapi_string ((FcChar8 *) FcConfigGetCache (XFC_CONFIG_PTR (config))); |
3931 | 668 } |
669 | |
670 DEFUN("fc-config-get-fonts", Ffc_config_get_fonts, 2, 2, 0, /* | |
671 -- Function: FcFontSet *FcConfigGetFonts (FcConfig *config, FcSetName set) | |
672 Returns one of the two sets of fonts from the configuration as | |
673 specified by 'set'. | |
674 `FcSetName' | |
675 Specifies one of the two sets of fonts available in a | |
676 configuration; FcSetSystem for those fonts specified in the | |
677 configuration and FcSetApplication which holds fonts provided by | |
678 the application. */ | |
679 (config, set)) | |
680 { | |
681 FcSetName name = FcSetSystem; | |
682 FcFontSet *fs = NULL; | |
683 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
684 CHECK_FC_CONFIG (config); |
3931 | 685 CHECK_SYMBOL (set); |
686 | |
687 if (EQ (set, intern ("fc-set-system"))) | |
688 name = FcSetSystem; | |
689 else if (EQ (set, intern ("fc-set-application"))) | |
690 name = FcSetApplication; | |
691 else | |
692 wtaerror ("must be in (fc-set-system fc-set-application)", set); | |
693 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
694 fs = FcConfigGetFonts (XFC_CONFIG_PTR (config), name); |
3931 | 695 return fs ? fontset_to_list (fs, DestroyNo) : Qnil; |
696 } | |
697 | |
698 DEFUN("fc-config-set-current", Ffc_config_set_current, 1, 1, 0, /* | |
699 -- Function: FcBool FcConfigSetCurrent (FcConfig *config) | |
700 Sets the current default configuration to 'config'. Implicitly | |
701 calls FcConfigBuildFonts if necessary, returning FcFalse if that | |
702 call fails. | |
703 XEmacs: signals out-of-memory if FcConfigBuildFonts fails, or args-out-of-range | |
704 if the resulting FcConfig has no fonts (which would crash XEmacs if installed). | |
705 */ | |
706 (config)) | |
707 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
708 CHECK_FC_CONFIG (config); |
3931 | 709 /* *sigh* "Success" DOES NOT mean you have any fonts available. It is |
710 easy to crash fontconfig, and XEmacs with it. Without the following | |
711 check, this will do it: | |
712 (progn | |
713 (fc-config-set-current (fc-config-create)) | |
714 (set-face-font 'default "serif-12")) | |
715 */ | |
716 | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
717 if (FcConfigBuildFonts (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 718 out_of_memory ("FcConfigBuildFonts failed", config); |
719 /* #### We'd like to avoid this consing, and FcConfigGetFonts sometimes | |
720 returns NULL, but it doesn't always. This will do for now .... */ | |
721 if (NILP (Ffc_config_get_fonts (config, intern ("fc-set-system"))) | |
722 && NILP (Ffc_config_get_fonts (config, intern ("fc-set-application")))) | |
723 signal_error (intern ("args-out-of-range"), "no fonts found", config); | |
724 /* Should never happen, but I don't trust Keith anymore .... */ | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
725 if (FcConfigSetCurrent (XFC_CONFIG_PTR (config)) == FcFalse) |
3931 | 726 out_of_memory ("FcConfigBuildFonts failed in set", config); |
727 return Qnil; | |
728 } | |
729 | |
730 DEFUN("fc-config-get-blanks", Ffc_config_get_blanks, 1, 1, 0, /* | |
731 -- Function: FcBlanks *FcConfigGetBlanks (FcConfig *config) | |
732 Returns the FcBlanks object associated with the given | |
733 configuration, if no blanks were present in the configuration, | |
734 this function will return 0. | |
735 XEmacs: should convert to a chartable. | |
736 #### Unimplemented. */ | |
737 (config)) | |
738 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
739 CHECK_FC_CONFIG (config); |
3931 | 740 signal_error (Qunimplemented, "no method to convert FcBlanks object", |
741 intern ("fc-config-get-blanks")); | |
742 } | |
743 | |
744 DEFUN("fc-config-get-rescan-interval", Ffc_config_get_rescan_interval, 1, 1, 0, /* | |
4328
dfd878799ef0
Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3935
diff
changeset
|
745 -- Function: int FcConfigGetRescanInterval (FcConfig *config) |
3931 | 746 Returns the interval between automatic checks of the configuration |
747 (in seconds) specified in 'config'. The configuration is checked | |
748 during a call to FcFontList when this interval has passed since | |
749 the last check. */ | |
750 (config)) | |
751 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
752 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
753 return make_int (FcConfigGetRescanInterval (XFC_CONFIG_PTR (config))); |
3931 | 754 } |
755 | |
756 DEFUN("fc-config-set-rescan-interval", Ffc_config_set_rescan_interval, 2, 2, 0, /* | |
4328
dfd878799ef0
Autoconfiscate the recent fontconfig spelling change.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3935
diff
changeset
|
757 -- Function: FcBool FcConfigSetRescanInterval (FcConfig *config, int |
3931 | 758 rescanInterval) |
759 Sets the rescan interval; returns FcFalse if an error occurred. | |
760 XEmacs: signal such error, or return nil on success. */ | |
761 (config, rescan_interval)) | |
762 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
763 CHECK_FC_CONFIG (config); |
3931 | 764 CHECK_INT (rescan_interval); |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
765 if (FcConfigSetRescanInterval (XFC_CONFIG_PTR (config), |
3931 | 766 XINT (rescan_interval)) == FcFalse) |
767 signal_error (Qio_error, "FcConfigSetRescanInverval barfed", | |
768 intern ("fc-config-set-rescan-interval")); | |
769 return Qnil; | |
770 } | |
771 | |
772 /* #### This might usefully be made interactive. */ | |
773 DEFUN("fc-config-app-font-add-file", Ffc_config_app_font_add_file, 2, 2, 0, /* | |
774 -- Function: FcBool FcConfigAppFontAddFile (FcConfig *config, const | |
775 char *file) | |
776 Adds an application-specific font to the configuration. */ | |
777 (config, file)) | |
778 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
779 CHECK_FC_CONFIG (config); |
3931 | 780 CHECK_STRING (file); |
781 if (FcConfigAppFontAddFile | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
782 (XFC_CONFIG_PTR (config), |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
783 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
784 (FcChar8 *) LISP_STRING_TO_EXTERNAL (file, Qfile_name)) == FcFalse) |
3931 | 785 return Qnil; |
786 else | |
787 return Qt; | |
788 } | |
789 | |
790 /* #### This might usefully be made interactive. */ | |
791 DEFUN("fc-config-app-font-add-dir", Ffc_config_app_font_add_dir, 2, 2, 0, /* | |
792 -- Function: FcBool FcConfigAppFontAddDir (FcConfig *config, const | |
793 char *dir) | |
794 Scans the specified directory for fonts, adding each one found to | |
795 the application-specific set of fonts. */ | |
796 (config, dir)) | |
797 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
798 CHECK_FC_CONFIG (config); |
3931 | 799 CHECK_STRING (dir); |
800 if (FcConfigAppFontAddDir | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
801 (XFC_CONFIG_PTR (config), |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
802 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
803 (FcChar8 *) LISP_STRING_TO_EXTERNAL (dir, Qfile_name)) == FcFalse) |
3931 | 804 return Qnil; |
805 else | |
806 return Qt; | |
807 } | |
808 | |
809 /* #### This might usefully be made interactive. */ | |
810 DEFUN("fc-config-app-font-clear", Ffc_config_app_font_clear, 1, 1, 0, /* | |
811 -- Function: void FcConfigAppFontClear (FcConfig *config) | |
812 Clears the set of application-specific fonts. */ | |
813 (config)) | |
814 { | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
815 CHECK_FC_CONFIG (config); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
816 FcConfigAppFontClear (XFC_CONFIG_PTR (config)); |
3931 | 817 return Qnil; |
818 } | |
819 | |
820 /* These functions provide some control over how the default | |
821 configuration of the library is initialized. (This configuration is | |
822 normally implicitly initialized.) */ | |
823 | |
824 DEFUN("fc-config-filename", Ffc_config_filename, 1, 1, 0, /* | |
825 -- Function: char *FcConfigFilename (const char *name) | |
826 Given the specified external entity name, return the associated | |
827 filename. This provides applications a way to convert various | |
828 configuration file references into filename form. | |
829 | |
830 A null or empty 'name' indicates that the default configuration | |
831 file should be used; which file this references can be overridden | |
832 with the FC_CONFIG_FILE environment variable. Next, if the name | |
833 starts with '~', it refers to a file in the current users home | |
834 directory. Otherwise if the name doesn't start with '/', it | |
835 refers to a file in the default configuration directory; the | |
836 built-in default directory can be overridden with the | |
837 FC_CONFIG_DIR environment variable. */ | |
838 (name)) | |
839 { | |
4932 | 840 const Ascbyte *fcname = ""; |
3931 | 841 |
842 if (!NILP (name)) | |
843 { | |
844 CHECK_STRING (name); | |
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
845 /* #### FIXME! is Qfile_name right? */ |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
846 LISP_PATHNAME_CONVERT_OUT (name, fcname); |
3931 | 847 } |
848 return (build_fcapi_string (FcConfigFilename ((FcChar8 *) fcname))); | |
849 } | |
850 | |
851 DEFUN("fc-init-load-config", Ffc_init_load_config, 0, 0, 0, /* | |
852 -- Function: FcConfig *FcInitLoadConfig (void) | |
853 Loads the default configuration file and returns the resulting | |
854 configuration. Does not load any font information. */ | |
855 ()) | |
856 { | |
857 return fc_config_create_using (&FcInitLoadConfig); | |
858 } | |
859 | |
860 DEFUN("fc-init-load-config-and-fonts", Ffc_init_load_config_and_fonts, 0, 0, 0, /* | |
861 -- Function: FcConfig *FcInitLoadConfigAndFonts (void) | |
862 Loads the default configuration file and builds information about | |
863 the available fonts. Returns the resulting configuration. */ | |
864 ()) | |
865 { | |
866 return fc_config_create_using (&FcInitLoadConfigAndFonts); | |
867 } | |
868 | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
869 DEFUN("fc-config-get-current", Ffc_config_get_current, 0, 0, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
870 -- Function: FcConfig *FcConfigGetCurrent (void) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
871 Returns the current default configuration. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
872 ()) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
873 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
874 return fc_config_create_using (&FcConfigGetCurrent); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
875 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
876 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
877 /* Pattern manipulation functions. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
878 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
879 DEFUN("fc-default-substitute", Ffc_default_substitute, 1, 1, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
880 Adds defaults for certain attributes if not specified in PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
881 FcPattern PATTERN is modified in-place, and nil is returned. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
882 * Patterns without a specified style or weight are set to Medium |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
883 * Patterns without a specified style or slant are set to Roman |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
884 * Patterns without a specified pixel size are given one computed from any |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
885 specified point size (default 12), dpi (default 75) and scale (default 1). */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
886 (pattern)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
887 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
888 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
889 FcDefaultSubstitute (XFC_PATTERN_PTR (pattern)); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
890 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
891 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
892 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
893 /* -- Function: FcBool FcConfigSubstituteWithPat (FcConfig *config, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
894 FcPattern *p, FcPattern *p_pat FcMatchKind kind) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
895 OMITTED: use optional arguments in `fc-config-substitute'. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
896 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
897 DEFUN("fc-config-substitute", Ffc_config_substitute, 1, 4, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
898 Modifies PATTERN according to KIND and TESTPAT using operations from CONFIG. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
899 PATTERN is modified in-place. Returns an undocumented Boolean value. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
900 If optional KIND is `fc-match-pattern', then those tagged as pattern operations |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
901 are applied, else if KIND is `fc-match-font', those tagged as font operations |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
902 are applied and TESTPAT is used for <test> elements with target=pattern. KIND |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
903 defaults to `fc-match-font'. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
904 If optional TESTPAT is nil, it is ignored. Otherwise it must be an FcPattern. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
905 Optional CONFIG must be an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
906 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
907 Note that this function actually corresponds to FcConfigSubstituteWithPat, and |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
908 the argument order is changed to take advantage of Lisp optional arguments. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
909 (pattern, kind, testpat, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
910 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
911 FcMatchKind knd; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
912 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
913 /* There ought to be a standard idiom for this.... */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
914 if (NILP (kind) |
4860 | 915 || EQ (kind, Qfc_match_font)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
916 knd = FcMatchFont; |
4860 | 917 else if (EQ (kind, Qfc_match_pattern)) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
918 knd = FcMatchPattern; |
4860 | 919 else |
920 wtaerror ("need `fc-match-pattern' or `fc-match-font'", kind); | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
921 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
922 /* Typecheck arguments */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
923 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
924 if (!NILP (testpat)) CHECK_FC_PATTERN (testpat); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
925 if (!NILP (config)) CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
926 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
927 return (FcConfigSubstituteWithPat |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
928 (NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
929 XFC_PATTERN_PTR (pattern), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
930 NILP (testpat) ? NULL : XFC_PATTERN_PTR (testpat), |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
931 knd) == FcTrue) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
932 ? Qt : Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
933 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
934 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
935 /* Pattern matching functions. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
936 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
937 /* The following functions return fonts that match a certain pattern. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
938 `FcFontRenderPrepare' and `FcFontMatch' always return a single best |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
939 match. `FcFontList' returns the list of fonts that match a given |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
940 pattern on a certain set of properties. `FcFontSort' returns the |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
941 entire list of fonts, sorted in order of match quality, possibly |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
942 filtering out fonts that do not provide additional characters beyond |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
943 those provided by preferred fonts. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
944 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
945 DEFUN("fc-font-render-prepare", Ffc_font_render_prepare, 2, 3, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
946 Return a new pattern blending PATTERN and FONT. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
947 Optional CONFIG is an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
948 The returned pattern consists of elements of FONT not appearing in PATTERN, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
949 elements of PATTERN not appearing in FONT, and the best matching value from |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
950 PATTERN for elements appearing in both. The result is passed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
951 FcConfigSubstitute with 'kind' FcMatchFont and then returned. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
952 (pattern, font, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
953 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
954 if (NILP (config)) { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
955 config = Ffc_config_get_current (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
956 } |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
957 CHECK_FC_PATTERN (pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
958 CHECK_FC_PATTERN (font); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
959 CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
960 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
961 /* I don't think this can fail? */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
962 return wrap_fc_pattern (FcFontRenderPrepare (XFC_CONFIG_PTR(config), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
963 XFC_PATTERN_PTR(font), |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
964 XFC_PATTERN_PTR(pattern))); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
965 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
966 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
967 DEFUN("fc-font-match", Ffc_font_match, 2, 3, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
968 Return the font on DEVICE that most closely matches PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
969 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
970 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
971 PATTERN is a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
972 Optional CONFIG is an FcConfig, defaulting to the current one. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
973 Returns a fontconfig pattern object representing the closest match to the |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
974 given pattern, or an error code. Possible error codes are |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
975 `fc-result-no-match' and `fc-result-no-id'. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
976 PATTERN is massaged with FcConfigSubstitute and FcDefaultSubstitute before |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
977 being processed by FcFontMatch. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
978 (device, pattern, config)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
979 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
980 FcResult res; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
981 struct fc_pattern *res_fcpat; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
982 FcPattern *p; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
983 FcConfig *fcc; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
984 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
985 CHECK_FC_PATTERN(pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
986 if (NILP(device)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
987 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
988 CHECK_X_DEVICE(device); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
989 if (!DEVICE_LIVE_P(XDEVICE(device))) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
990 return Qnil; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
991 if (!NILP (config)) |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
992 CHECK_FC_CONFIG (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
993 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
994 res_fcpat = XFC_PATTERN (ALLOC_NORMAL_LISP_OBJECT (fc_pattern)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
995 p = XFC_PATTERN_PTR(pattern); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
996 fcc = NILP (config) ? FcConfigGetCurrent () : XFC_CONFIG_PTR (config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
997 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
998 FcConfigSubstitute (fcc, p, FcMatchPattern); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
999 FcDefaultSubstitute (p); |
4809
0d3ccd5a2509
Initialize the result variable passed to FcFontMatch. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
4799
diff
changeset
|
1000 res = FcResultMatch; |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1001 res_fcpat->fcpatPtr = FcFontMatch (fcc, p, &res); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1002 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1003 if (res_fcpat->fcpatPtr == NULL) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1004 switch (res) { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1005 case FcResultNoMatch: |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1006 return Qfc_result_no_match; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1007 case FcResultNoId: |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1008 return Qfc_result_no_id; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1009 default: |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1010 return Qfc_internal_error; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1011 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1012 else |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1013 return wrap_fc_pattern(res_fcpat); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1014 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1015 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1016 /* #### fix this name to correspond to Ben's new nomenclature */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1017 DEFUN("fc-list-fonts-pattern-objects", Ffc_list_fonts_pattern_objects, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1018 3, 3, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1019 Return a list of fonts on DEVICE that match PATTERN for PROPERTIES. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1020 Each font is represented by a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1021 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1022 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1023 PATTERN is a fontconfig pattern to be matched. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1024 PROPERTIES is a list of property names (strings) that should match. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1025 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1026 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1027 match other font-listing APIs. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1028 (UNUSED (device), pattern, properties)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1029 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1030 FcObjectSet *os; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1031 FcFontSet *fontset; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1032 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1033 CHECK_FC_PATTERN (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1034 CHECK_LIST (properties); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1035 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1036 os = FcObjectSetCreate (); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1037 string_list_to_fcobjectset (properties, os); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1038 /* #### why don't we need to do the "usual substitutions"? */ |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1039 fontset = FcFontList (NULL, XFC_PATTERN_PTR (pattern), os); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1040 FcObjectSetDestroy (os); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1041 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1042 return fontset_to_list (fontset, DestroyYes); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1043 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1044 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1045 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1046 /* #### maybe this can/should be folded into fc-list-fonts-pattern-objects? */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1047 DEFUN("fc-font-sort", Ffc_font_sort, 2, 4, 0, /* |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1048 Return a list of all fonts sorted by proximity to PATTERN. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1049 Each font is represented by a fontconfig pattern object. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1050 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1051 DEVICE is an X11 device. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1052 PATTERN is a fontconfig pattern to be matched. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1053 Optional argument TRIM, if non-nil, means to trim trailing fonts that do not |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1054 contribute new characters to the union repertoire. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1055 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1056 #### Optional argument NOSUB, if non-nil, suppresses some of the usual |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1057 property substitutions. DON'T USE THIS in production code, it is intended |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1058 for exploring behavior of fontconfig and will be removed when this code is |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1059 stable. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1060 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1061 #### DEVICE is unused, ignored, and may be removed if it's not needed to |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1062 match other font-listing APIs. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1063 (UNUSED (device), pattern, trim, nosub)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1064 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1065 CHECK_FC_PATTERN (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1066 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1067 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1068 FcConfig *fcc = FcConfigGetCurrent(); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1069 FcFontSet *fontset; |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1070 FcPattern *p = XFC_PATTERN_PTR (pattern); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1071 FcResult fcresult; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1072 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1073 if (NILP(nosub)) /* #### temporary debug hack */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1074 FcDefaultSubstitute (p); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1075 FcConfigSubstitute (fcc, p, FcMatchPattern); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1076 fontset = FcFontSort (fcc, p, !NILP(trim), NULL, &fcresult); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1077 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1078 return fontset_to_list (fontset, DestroyYes); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1079 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1080 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1081 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1082 #ifdef FONTCONFIG_EXPOSE_CONFIG |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1083 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1084 /* Configuration routines --- for debugging |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1085 Don't depend on these routines being available in the future! |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1086 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1087 3.2.10 Initialization |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1088 --------------------- |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1089 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1090 An FcConfig object holds the internal representation of a configuration. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1091 There is a default configuration which applications may use by passing |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1092 0 to any function using the data within an FcConfig. |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1093 */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1094 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1095 static void |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1096 finalize_fc_config (Lisp_Object obj) |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1097 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1098 struct fc_config *p = XFC_CONFIG (obj); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1099 if (p->fccfgPtr && p->fccfgPtr != FcConfigGetCurrent()) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1100 { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1101 /* If we get here, all of *our* references are garbage (see comment on |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1102 fc_config_create_using() for why), and the only reference that |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1103 fontconfig keeps is the current FcConfig. */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1104 FcConfigDestroy (p->fccfgPtr); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1105 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1106 p->fccfgPtr = 0; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1107 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1108 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1109 static void |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1110 print_fc_config (Lisp_Object obj, Lisp_Object printcharfun, |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1111 int UNUSED(escapeflag)) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1112 { |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5125
diff
changeset
|
1113 struct fc_config *c = XFC_CONFIG (obj); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1114 if (print_readably) |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1115 printing_unreadable_object ("#<fc-config 0x%x>", c->header.uid); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1116 write_fmt_string (printcharfun, "#<fc-config 0x%x>", c->header.uid); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1117 } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1118 |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1119 static const struct memory_description fcconfig_description [] = { |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1120 /* #### nothing here, is this right?? */ |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1121 { XD_END } |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1122 }; |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1123 |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1124 DEFINE_NODUMP_LISP_OBJECT ("fc-config", fc_config, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1125 0, print_fc_config, finalize_fc_config, 0, 0, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1126 fcconfig_description, |
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1127 struct fc_config); |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1128 |
3931 | 1129 DEFUN("fc-init", Ffc_init, 0, 0, 0, /* |
1130 -- Function: FcBool FcInit (void) | |
1131 Loads the default configuration file and the fonts referenced | |
1132 therein and sets the default configuration to that result. | |
1133 Returns whether this process succeeded or not. If the default | |
1134 configuration has already been loaded, this routine does nothing | |
1135 and returns FcTrue. */ | |
1136 ()) | |
1137 { | |
1138 return (FcInit () == FcTrue) ? Qt : Qnil; | |
1139 } | |
1140 | |
1141 DEFUN("fc-get-version", Ffc_get_version, 0, 0, 0, /* | |
1142 -- Function: int FcGetVersion (void) | |
1143 Returns the version number of the library. | |
3935 | 1144 XEmacs: No, this should NOT return a pretty string. |
3931 | 1145 (let ((i (fc-get-version))) |
1146 (format "%d.%d.%d" (/ i 10000) (mod (/ i 100) 100) (mod i 100))) | |
3935 | 1147 gives the usual x.y.z format. This is the version of the .so. It can be |
1148 checked against `fc-version', which is the version of fontconfig.h. | |
1149 It's probably not a disaster if `(> (fc-get-version) fc-version)'. */ | |
3931 | 1150 ()) |
1151 { | |
1152 return make_int (FcGetVersion ()); | |
1153 } | |
1154 | |
1155 DEFUN("fc-init-reinitialize", Ffc_init_reinitialize, 0, 0, 0, /* | |
1156 -- Function: FcBool FcInitReinitialize (void) | |
1157 Forces the default configuration file to be reloaded and resets | |
1158 the default configuration. */ | |
1159 ()) | |
1160 { | |
1161 return (FcInitReinitialize () == FcTrue) ? Qt : Qnil; | |
1162 } | |
1163 | |
1164 DEFUN("fc-init-bring-up-to-date", Ffc_init_bring_up_to_date, 0, 0, 0, /* | |
1165 -- Function: FcBool FcInitBringUptoDate (void) | |
1166 Checks the rescan interval in the default configuration, checking | |
1167 the configuration if the interval has passed and reloading the | |
1168 configuration when any changes are detected. */ | |
1169 ()) | |
1170 { | |
1171 return (FcInitBringUptoDate () == FcTrue) ? Qt : Qnil; | |
1172 } | |
1173 | |
1174 #endif /* FONTCONFIG_EXPOSE_CONFIG */ | |
1175 | |
3354 | 1176 DEFUN("xlfd-font-name-p", Fxlfd_font_name_p, 1, 1, 0, /* |
1177 Check whether the string FONTNAME is a XLFD font name. */ | |
1178 (fontname)) | |
1179 { | |
1180 CHECK_STRING(fontname); | |
1181 /* #### should bind `case-fold-search' here? */ | |
1182 return Fstring_match(Vxlfd_font_name_regexp, fontname, Qnil, Qnil); | |
1183 } | |
1184 | |
1185 /* FcPatternPrint: there is no point in having wrappers fc-pattern-print, | |
1186 Ffc_pattern_print since this function prints to stdout. */ | |
1187 | |
1188 /* Initialization of font-mgr */ | |
1189 | |
1190 #define XE_XLFD_SEPARATOR "-" | |
1191 /* XLFD specifies ISO 8859-1 encoding, but we can't handle non-ASCII | |
1192 in Mule when this function is called. So use HPC. */ | |
1193 #if 0 | |
1194 #define XE_XLFD_PREFIX "\\(\\+[\040-\176\240-\377]*\\)?-" | |
1195 #define XE_XLFD_OPT_TEXT "\\([\040-\044\046-\176\240-\377]*\\)" | |
1196 #define XE_XLFD_TEXT "\\([\040-\044\046-\176\240-\377]+\\)" | |
1197 #else | |
1198 #define XE_XLFD_PREFIX "\\(\\+[\040-\176]*\\)?-" | |
1199 #define XE_XLFD_OPT_TEXT "\\([^-]*\\)" | |
1200 #define XE_XLFD_TEXT "\\([^-]+\\)" | |
1201 #endif | |
1202 | |
1203 #define XE_XLFD_SLANT "\\([0-9ior?*][iot]?\\)" | |
1204 #define XE_XLFD_SPACING "\\([cmp?*]\\)" | |
1205 /* Hyphen as minus conflicts with use as separator. */ | |
1206 #define XE_XLFD_OPT_NEGATE "~?" | |
1207 #define XE_XLFD_NUMBER "\\([0-9?*]+\\)" | |
1208 #define XE_XLFD_PSIZE "\\([0-9?*]+\\|\\[[ 0-9+~.e?*]+\\]\\)" | |
1209 | |
1210 /* Call this only from the init code | |
1211 #### This is really horrible, let's get rid of it, please. */ | |
1212 static Lisp_Object | |
1213 make_xlfd_font_regexp (void) | |
1214 { | |
1215 struct gcpro gcpro1; | |
1216 unsigned i; | |
1217 Lisp_Object reg = Qnil; | |
1218 const Extbyte *re[] = /* #### This could just be catenated by | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1219 cpp and passed to build_extstring. */ |
3354 | 1220 { |
1221 /* Regular expression matching XLFDs as defined by XLFD v. 1.5. | |
1222 Matches must be case-insensitive. | |
1223 PSIZE is a pixel or point size, which may be a "matrix". The | |
1224 syntax of a matrix is not checked, just some lexical properties. | |
1225 AFAICT none of the TEXT fields except adstyle is optional. | |
1226 | |
1227 NB. It should not be a problem if this matches "too much", since | |
1228 an "old" server will simply not be able to find a matching font. */ | |
1229 "\\`", | |
1230 XE_XLFD_PREFIX, /* prefix */ | |
1231 XE_XLFD_TEXT, /* foundry */ | |
1232 XE_XLFD_SEPARATOR, | |
1233 XE_XLFD_TEXT, /* family */ | |
1234 XE_XLFD_SEPARATOR, | |
1235 XE_XLFD_TEXT, /* weight */ | |
1236 XE_XLFD_SEPARATOR, | |
1237 XE_XLFD_SLANT, /* slant */ | |
1238 XE_XLFD_SEPARATOR, | |
1239 XE_XLFD_TEXT, /* swidth */ | |
1240 XE_XLFD_SEPARATOR, | |
1241 XE_XLFD_OPT_TEXT, /* adstyle */ | |
1242 XE_XLFD_SEPARATOR, | |
1243 XE_XLFD_PSIZE, /* pixelsize */ | |
1244 XE_XLFD_SEPARATOR, | |
1245 XE_XLFD_PSIZE, /* pointsize */ | |
1246 XE_XLFD_SEPARATOR, | |
1247 XE_XLFD_NUMBER, /* resx */ | |
1248 XE_XLFD_SEPARATOR, | |
1249 XE_XLFD_NUMBER, /* resy */ | |
1250 XE_XLFD_SEPARATOR, | |
1251 XE_XLFD_SPACING, /* spacing */ | |
1252 XE_XLFD_SEPARATOR, | |
1253 XE_XLFD_OPT_NEGATE, /* avgwidth */ | |
1254 XE_XLFD_NUMBER, | |
1255 XE_XLFD_SEPARATOR, | |
1256 XE_XLFD_TEXT, /* registry */ | |
1257 XE_XLFD_SEPARATOR, | |
1258 XE_XLFD_TEXT, /* encoding */ | |
1259 "\\'" | |
1260 }; | |
1261 | |
1262 GCPRO1 (reg); | |
1263 for (i = 0; i < sizeof(re)/sizeof(Extbyte *); i++) | |
1264 { | |
1265 /* #### Currently this is Host Portable Coding, not ISO 8859-1. */ | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1266 reg = concat2(reg, build_extstring (re[i], Qx_font_name_encoding)); |
3354 | 1267 } |
1268 | |
1269 RETURN_UNGCPRO (reg); | |
1270 } | |
1271 #undef XE_XLFD_SEPARATOR | |
1272 #undef XE_XLFD_PREFIX | |
1273 #undef XE_XLFD_OPT_TEXT | |
1274 #undef XE_XLFD_TEXT | |
1275 #undef XE_XLFD_OPT_SLANT | |
1276 #undef XE_XLFD_OPT_SPACING | |
1277 #undef XE_XLFD_OPT_NEGATE | |
1278 #undef XE_XLFD_NUMBER | |
1279 #undef XE_XLFD_PSIZE | |
1280 | |
1281 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ | |
1282 ? ((unsigned long) (x)) : ((unsigned long) (y))) | |
1283 | |
1284 static void | |
1285 string_list_to_fcobjectset (Lisp_Object list, FcObjectSet *os) | |
1286 { | |
1287 EXTERNAL_LIST_LOOP_2 (elt, list) | |
1288 { | |
3469 | 1289 const Extbyte *s; |
3354 | 1290 |
1291 CHECK_STRING (elt); | |
1292 s = fc_intern (elt); | |
1293 FcObjectSetAdd (os, s); | |
1294 } | |
1295 } | |
1296 | |
1297 void | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1298 syms_of_font_mgr (void) { |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1299 INIT_LISP_OBJECT(fc_pattern); |
3354 | 1300 |
1301 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_patternp); | |
1302 | |
1303 DEFSYMBOL(Qfc_result_type_mismatch); | |
1304 DEFSYMBOL(Qfc_result_no_match); | |
1305 DEFSYMBOL(Qfc_result_no_id); | |
1306 DEFSYMBOL(Qfc_internal_error); | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1307 DEFSYMBOL(Qfc_match_pattern); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1308 DEFSYMBOL(Qfc_match_font); |
3360 | 1309 DEFSYMBOL(Qfont_mgr); |
3354 | 1310 |
1311 DEFSUBR(Ffc_pattern_p); | |
1312 DEFSUBR(Ffc_pattern_create); | |
1313 DEFSUBR(Ffc_name_parse); | |
1314 DEFSUBR(Ffc_name_unparse); | |
1315 DEFSUBR(Ffc_pattern_duplicate); | |
1316 DEFSUBR(Ffc_pattern_add); | |
1317 DEFSUBR(Ffc_pattern_del); | |
1318 DEFSUBR(Ffc_pattern_get); | |
1319 DEFSUBR(Ffc_list_fonts_pattern_objects); | |
1320 DEFSUBR(Ffc_font_sort); | |
1321 DEFSUBR(Ffc_font_match); | |
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1322 DEFSUBR(Ffc_default_substitute); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1323 DEFSUBR(Ffc_config_substitute); |
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
1324 DEFSUBR(Ffc_font_render_prepare); |
3354 | 1325 DEFSUBR(Fxlfd_font_name_p); |
3931 | 1326 |
1327 #ifdef FONTCONFIG_EXPOSE_CONFIG | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
4758
diff
changeset
|
1328 INIT_LISP_OBJECT(fc_config); |
3931 | 1329 |
1330 DEFSYMBOL_MULTIWORD_PREDICATE(Qfc_configp); | |
1331 | |
1332 DEFSUBR(Ffc_config_p); | |
1333 DEFSUBR(Ffc_config_create); | |
1334 #if 0 | |
1335 DEFSUBR(Ffc_config_destroy); | |
1336 #endif | |
1337 DEFSUBR(Ffc_config_set_current); | |
1338 DEFSUBR(Ffc_config_get_current); | |
1339 DEFSUBR(Ffc_config_up_to_date); | |
1340 DEFSUBR(Ffc_config_build_fonts); | |
1341 DEFSUBR(Ffc_config_get_config_dirs); | |
1342 DEFSUBR(Ffc_config_get_font_dirs); | |
1343 DEFSUBR(Ffc_config_get_config_files); | |
1344 DEFSUBR(Ffc_config_get_cache); | |
1345 DEFSUBR(Ffc_config_get_fonts); | |
1346 DEFSUBR(Ffc_config_get_blanks); | |
1347 DEFSUBR(Ffc_config_get_rescan_interval); | |
1348 DEFSUBR(Ffc_config_set_rescan_interval); | |
1349 DEFSUBR(Ffc_config_app_font_add_file); | |
1350 DEFSUBR(Ffc_config_app_font_add_dir); | |
1351 DEFSUBR(Ffc_config_app_font_clear); | |
1352 DEFSUBR(Ffc_config_filename); | |
1353 DEFSUBR(Ffc_init_load_config); | |
1354 DEFSUBR(Ffc_init_load_config_and_fonts); | |
1355 DEFSUBR(Ffc_init); | |
1356 DEFSUBR(Ffc_get_version); | |
1357 DEFSUBR(Ffc_init_reinitialize); | |
1358 DEFSUBR(Ffc_init_bring_up_to_date); | |
1359 #endif /* FONTCONFIG_EXPOSE_CONFIG */ | |
3354 | 1360 } |
1361 | |
1362 void | |
1363 vars_of_font_mgr (void) | |
1364 { | |
3935 | 1365 /* #### The next two DEFVARs belong somewhere else. */ |
3354 | 1366 |
1367 /* #### I know, but the right fix is use the generic debug facility. */ | |
1368 DEFVAR_INT ("xft-debug-level", &debug_xft /* | |
1369 Level of debugging messages to issue to stderr for Xft. | |
1370 A nonnegative integer. Set to 0 to suppress all warnings. | |
1371 Default is 1 to ensure a minimum of debugging output at initialization. | |
1372 Higher levels give even more information. | |
1373 */ ); | |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4328
diff
changeset
|
1374 debug_xft = 0; |
3354 | 1375 |
3935 | 1376 DEFVAR_CONST_INT("xft-version", &xft_version /* |
3354 | 1377 The major version number of the Xft library being used. |
1378 */ ); | |
3935 | 1379 xft_version = XFT_VERSION; |
1380 | |
1381 DEFVAR_CONST_INT("fc-version", &fc_version /* | |
1382 The version number of fontconfig.h. It can be checked against | |
1383 `(fc-get-version)', which is the version of the .so. | |
1384 It's probably not a disaster if `(> (fc-get-version) fc-version)'. | |
1385 */ ); | |
1386 fc_version = FC_VERSION; | |
3354 | 1387 |
3360 | 1388 Fprovide (intern ("font-mgr")); |
3354 | 1389 } |
1390 | |
1391 void | |
1392 complex_vars_of_font_mgr (void) | |
1393 { | |
3931 | 1394 #ifdef FONTCONFIG_EXPOSE_CONFIG |
1395 Vfc_config_weak_list = make_weak_list (WEAK_LIST_SIMPLE); | |
1396 staticpro (&Vfc_config_weak_list); | |
1397 #endif | |
1398 | |
3354 | 1399 DEFVAR_LISP("xft-xlfd-font-regexp", &Vxlfd_font_name_regexp /* |
1400 The regular expression used to match XLFD font names. */ | |
1401 ); | |
1402 Vxlfd_font_name_regexp = make_xlfd_font_regexp(); | |
1403 } | |
1404 | |
1405 void | |
1406 reinit_vars_of_font_mgr (void) | |
1407 { | |
1408 int i, size = (int) countof (fc_standard_properties); | |
1409 | |
1410 FcInit (); | |
1411 | |
1412 fc_property_name_hash_table = make_string_hash_table (size); | |
1413 for (i = 0; i < size; ++i) | |
1414 puthash (fc_standard_properties[i], NULL, fc_property_name_hash_table); | |
1415 } | |
1416 |