(mface__realize): Handle the case of font->size < 0.
[m17n/m17n-lib.git] / src / face.c
1 /* face.c -- face module.
2    Copyright (C) 2003, 2004
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    Lesser General Public License for more details.
17
18    You should have received a copy of the GNU Lesser General Public
19    License along with the m17n library; if not, write to the Free
20    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21    02111-1307, USA.  */
22
23 /***en
24     @addtogroup m17nFace
25     @brief A face is an object to control appearance of M-text.
26
27     A @e face is an object of the type #MFace and controls how to
28     draw M-texts.  A face has a fixed number of @e face @e properties.
29     Like other types of properties, a face property consists of a key
30     and a value.  A key is one of the following symbols:
31
32     #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
33     #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
34     #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
35
36     "The face property that belongs to face F and whose key is @c xxx"
37     may be shortened to "the xxx property of F".
38
39     The M-text drawing functions first search an M-text for the text
40     property whose key is the symbol #Mface, then draw the M-text
41     using the value of that text property.  This value must be a
42     pointer to a face object.
43
44     If there are multiple text properties whose key is @c Mface, and
45     they are not conflicting one another, properties of those faces
46     are merged and used.
47
48     If no faces specify a certain property, the value of the default
49     face is used.  */
50
51 /***ja
52     @addtogroup m17nFace
53     @brief ¥Õ¥§¡¼¥¹¤È¤Ï¡¢M-text ¤Î¸«±É¤¨¤òÀ©¸æ¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë.
54
55     @e ¥Õ¥§¡¼¥¹ ¤Ï #MFace ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ê¡¢M-text 
56     ¤Îɽ¼¨ÊýË¡¤òÀ©¸æ¤¹¤ë¡£¥Õ¥§¡¼¥¹¤Ï¸ÇÄê¸Ä¤Î @e ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£ ¤ò»ý¤Ä¡£
57     Â¾¤Î¥×¥í¥Ñ¥Æ¥£Æ±ÍÍ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Ï¥­¡¼¤ÈÃͤ«¤é¤Ê¤ê¡¢¥­¡¼¤Ï°Ê²¼¤Î¥·¥ó¥Ü¥ë¤Î¤¤¤º¤ì¤«¤Ç¤¢¤ë¡£
58
59     #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox, 
60     #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle, 
61     #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
62
63     ¡Ö¥Õ¥§¡¼¥¹ F ¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¤¦¤Á¥­¡¼¤¬ @c Mxxx 
64     ¤Ç¤¢¤ë¤â¤Î¡×¤Î¤³¤È¤ò´Êñ¤Ë¡ÖF ¤Î xxx ¥×¥í¥Ñ¥Æ¥£¡×¤È¸Æ¤Ö¤³¤È¤¬¤¢¤ë¡£
65
66     M-text ¤Îɽ¼¨´Ø¿ô¤Ï¡¢¤Þ¤ººÇ½é¤Ë¤½¤Î M-text ¤«¤é¥­¡¼¤¬¥·¥ó¥Ü¥ë 
67     #Mface ¤Ç¤¢¤ë¤è¤¦¤Ê¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤òõ¤·¡¢¼¡¤Ë¤½¤ÎÃͤ˽¾¤Ã¤Æ 
68     M-text ¤òɽ¼¨¤¹¤ë¡£¤³¤ÎÃͤϥե§¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
69
70     M-text ¤¬¡¢#Mface 
71     ¤ò¥­¡¼¤È¤¹¤ë¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤òÊ£¿ô»ý¤Ã¤Æ¤ª¤ê¡¢¤«¤Ä¤½¤ì¤é¤ÎÃͤ¬¾×Æͤ·¤Ê¤¤¤Ê¤é¤Ð¡¢¥Õ¥§¡¼¥¹¾ðÊó¤ÏÁȤ߹ç¤ï¤µ¤ì¤ÆÍѤ¤¤é¤ì¤ë¡£
72
73     ¤¢¤ë¥Æ¥­¥¹¥È°À­¤¬¤É¤Î¥Õ¥§¡¼¥¹¤Ë¤è¤Ã¤Æ¤â»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¥Õ¥§¡¼¥¹¤ÎÃͤ¬ÍѤ¤¤é¤ì¤ë¡£  */
74
75 /*=*/
76
77 #if !defined (FOR_DOXYGEN) || defined (DOXYGEN_INTERNAL_MODULE)
78 /*** @addtogroup m17nInternal
79      @{ */
80
81 #include <stdio.h>
82 #include <stdlib.h>
83 #include <string.h>
84 #include <ctype.h>
85
86 #include "config.h"
87 #include "m17n-gui.h"
88 #include "m17n-misc.h"
89 #include "internal.h"
90 #include "charset.h"
91 #include "symbol.h"
92 #include "plist.h"
93 #include "mtext.h"
94 #include "textprop.h"
95 #include "internal-gui.h"
96 #include "face.h"
97 #include "font.h"
98 #include "fontset.h"
99
100 static M17NObjectArray face_table;
101
102 MSymbol Mlatin;
103
104 static MSymbol M_face_prop_index;
105
106 static MPlist *hline_prop_list;
107 static MPlist *box_prop_list;
108
109 /** Special hook function pointer that does nothing.  */
110 static MFaceHookFunc noop_hook;
111
112 /**  */
113 static MFaceHLineProp *
114 get_hline_create (MFaceHLineProp *prop)
115 {
116   MPlist *plist;
117   MFaceHLineProp *hline;
118
119   if (prop->width == 0)
120     return MPLIST_VAL (hline_prop_list);
121   MPLIST_DO (plist, MPLIST_NEXT (hline_prop_list))
122     {
123       hline = MPLIST_VAL (plist);
124       if (prop->type == hline->type
125           && prop->width == hline->width
126           && prop->color == hline->color)
127         return hline;
128     }
129   MSTRUCT_MALLOC (hline, MERROR_FACE);
130   *hline = *prop;
131   mplist_push (plist, Mt, hline);
132   return hline;
133 }
134
135 static MFaceBoxProp *
136 get_box_create (MFaceBoxProp *prop)
137 {
138   MPlist *plist;
139   MFaceBoxProp *box;
140
141   if (prop->width == 0)
142     return MPLIST_VAL (box_prop_list);
143   MPLIST_DO (plist, MPLIST_NEXT (box_prop_list))
144     {
145       box = MPLIST_VAL (plist);
146       if (prop->width == box->width
147           && prop->color_top == box->color_top
148           && prop->color_bottom == box->color_bottom
149           && prop->color_left == box->color_left
150           && prop->color_right == box->color_right
151           && prop->inner_hmargin == box->inner_hmargin
152           && prop->inner_vmargin == box->inner_vmargin
153           && prop->outer_hmargin == box->inner_hmargin
154           && prop->inner_vmargin == box->inner_vmargin)
155         return box;
156     }
157   MSTRUCT_MALLOC (box, MERROR_FACE);
158   *box = *prop;
159   mplist_push (plist, Mt, box);
160   return box;
161 }
162
163 /** From FRAME->realized_face_list, find a realized face based on
164     FACE.  */
165
166 static MRealizedFace *
167 find_realized_face (MFrame *frame, MFace *face, MFont *font)
168 {
169   MPlist *plist;
170
171   MPLIST_DO (plist, frame->realized_face_list)
172     {
173       MRealizedFace *rface = MPLIST_VAL (plist);
174
175       if (memcmp (rface->face.property, face->property,
176                   sizeof face->property) == 0
177           && (rface->font
178               ? (font && ! memcmp (rface->font, font, sizeof (MFont)))
179               : ! font))
180         return rface;
181     }
182   return NULL;
183 }
184
185 static void
186 free_face (void *object)
187 {
188   MFace *face = (MFace *) object;
189
190   if (face->property[MFACE_FONTSET])
191     M17N_OBJECT_UNREF (face->property[MFACE_FONTSET]);
192   M17N_OBJECT_UNREF (face->frame_list);
193   M17N_OBJECT_UNREGISTER (face_table, face);
194   free (object);
195 }
196
197
198 static MPlist *
199 serialize_hline (MPlist *plist, MFaceHLineProp *hline)
200 {
201   if (hline->width > 0)
202     {
203       MPlist *pl = mplist ();
204
205       mplist_add (pl, Minteger, (void *) hline->type);
206       mplist_add (pl, Minteger, (void *) hline->width);
207       mplist_add (pl, Msymbol, hline->color);
208       plist = mplist_add (plist, Mplist, pl);
209       M17N_OBJECT_UNREF (pl);
210     }
211   return plist;
212 }
213
214 static MPlist *
215 serialize_box (MPlist *plist, MFaceBoxProp *box)
216 {
217   if (box->width > 0)
218     {
219       MPlist *pl = mplist ();
220
221       mplist_add (pl, Minteger, (void *) box->width);
222       mplist_add (pl, Minteger, (void *) box->inner_hmargin);
223       mplist_add (pl, Minteger, (void *) box->inner_vmargin);
224       mplist_add (pl, Minteger, (void *) box->outer_hmargin);
225       mplist_add (pl, Minteger, (void *) box->outer_vmargin);
226       mplist_add (pl, Msymbol, box->color_top);
227       mplist_add (pl, Msymbol, box->color_bottom);
228       mplist_add (pl, Msymbol, box->color_left);
229       mplist_add (pl, Msymbol, box->color_right);
230       plist = mplist_add (plist, Mplist, pl);
231       M17N_OBJECT_UNREF (pl);
232     }
233   return plist;
234 }
235
236 static MPlist *
237 serialize_face (void *val)
238 {
239   MFace *face = val;
240   MPlist *plist = mplist (), *pl = plist;
241   int i;
242   struct {
243     MSymbol *key;
244     MSymbol *type;
245     MPlist *(*func) (MPlist *plist, void *val);
246   } serializer[MFACE_PROPERTY_MAX]
247       = { { &Mfoundry,          &Msymbol },
248           { &Mfamily,           &Msymbol },
249           { &Mweight,           &Msymbol },
250           { &Mstyle,            &Msymbol },
251           { &Mstretch,          &Msymbol },
252           { &Madstyle,          &Msymbol },
253           { &Msize,             &Minteger },
254           { &Mfontset,          NULL },
255           { &Mforeground,       &Msymbol },
256           { &Mbackground,       &Msymbol },
257           { &Mhline,            NULL },
258           { &Mbox,              NULL },
259           { &Mvideomode,        &Msymbol },
260           { NULL,               NULL}, /* MFACE_HOOK_FUNC */
261           { NULL,               NULL}, /* MFACE_HOOK_ARG */
262           { &Mratio,            &Minteger } };
263   
264   for (i = 0; i < MFACE_PROPERTY_MAX; i++)
265     if (face->property[i] && serializer[i].key)
266       {
267         pl = mplist_add (pl, Msymbol, *serializer[i].key);
268         if (serializer[i].type)
269           pl = mplist_add (pl, *serializer[i].type, face->property[i]);
270         else if (i == MFACE_FONTSET)
271           pl = mplist_add (pl, Msymbol, mfontset_name ((MFontset *)
272                                                        face->property[i]));
273         else if (i == MFACE_HLINE)
274           pl = serialize_hline (pl, (MFaceHLineProp *) face->property[i]);
275         else if (i == MFACE_BOX)
276           pl = serialize_box (pl, (MFaceBoxProp *) face->property[i]);
277       }
278
279   return plist;
280 }
281
282 static void *
283 deserialize_hline (MPlist *plist)
284 {
285   MFaceHLineProp hline, *hline_ret;
286
287   if (! MPLIST_INTEGER_P (plist))
288     MERROR (MERROR_FACE, NULL);
289   hline.type = MPLIST_INTEGER_P (plist);
290   plist = MPLIST_NEXT (plist);
291   if (! MPLIST_INTEGER_P (plist))
292     MERROR (MERROR_FACE, NULL);
293   hline.width = MPLIST_INTEGER_P (plist);
294   plist = MPLIST_NEXT (plist);
295   if (! MPLIST_SYMBOL_P (plist))
296     MERROR (MERROR_FACE, NULL);
297   hline.color = MPLIST_SYMBOL (plist);
298   MSTRUCT_MALLOC (hline_ret, MERROR_FACE);
299   *hline_ret = hline;
300   return hline_ret;
301 }
302
303 static void *
304 deserialize_box (MPlist *plist)
305 {
306   MFaceBoxProp box, *box_ret;
307
308   if (! MPLIST_INTEGER_P (plist))
309     MERROR (MERROR_FACE, NULL);
310   box.width = MPLIST_INTEGER (plist);
311   plist = MPLIST_NEXT (plist);
312   if (! MPLIST_INTEGER_P (plist))
313     MERROR (MERROR_FACE, NULL);
314   box.inner_hmargin = MPLIST_INTEGER (plist);
315   plist = MPLIST_NEXT (plist);
316   if (! MPLIST_INTEGER_P (plist))
317     MERROR (MERROR_FACE, NULL);
318   box.inner_vmargin = MPLIST_INTEGER (plist);
319   plist = MPLIST_NEXT (plist);
320   if (! MPLIST_INTEGER_P (plist))
321     MERROR (MERROR_FACE, NULL);
322   box.outer_hmargin = MPLIST_INTEGER (plist);
323   plist = MPLIST_NEXT (plist);
324   if (! MPLIST_INTEGER_P (plist))
325     MERROR (MERROR_FACE, NULL);
326   box.outer_vmargin = MPLIST_INTEGER (plist);
327   plist = MPLIST_NEXT (plist);
328   if (! MPLIST_SYMBOL_P (plist))
329     MERROR (MERROR_FACE, NULL);
330   box.color_top = MPLIST_SYMBOL (plist);
331   plist = MPLIST_NEXT (plist);
332   if (! MPLIST_SYMBOL_P (plist))
333     MERROR (MERROR_FACE, NULL);
334   box.color_bottom = MPLIST_SYMBOL (plist);
335   plist = MPLIST_NEXT (plist);
336   if (! MPLIST_SYMBOL_P (plist))
337     MERROR (MERROR_FACE, NULL);
338   box.color_left = MPLIST_SYMBOL (plist);
339   plist = MPLIST_NEXT (plist);
340   if (! MPLIST_SYMBOL_P (plist))
341     MERROR (MERROR_FACE, NULL);
342   box.color_right = MPLIST_SYMBOL (plist);
343   MSTRUCT_MALLOC (box_ret, MERROR_FACE);
344   *box_ret = box;
345   return box_ret;
346 }
347
348 static void *
349 deserialize_face (MPlist *plist)
350 {
351   MFace *face = mface ();
352
353   MPLIST_DO (plist, plist)
354     {
355       MSymbol key;
356       int index;
357       void *val;
358
359       if (! MPLIST_SYMBOL_P (plist))
360         break;
361       key = MPLIST_SYMBOL (plist);
362       index = (int) msymbol_get (key, M_face_prop_index) - 1;
363       plist = MPLIST_NEXT (plist);
364       if (MPLIST_TAIL_P (plist))
365         break;
366       if (index < 0 || index >= MFACE_PROPERTY_MAX)
367         continue;
368       if (key == Mfoundry || key == Mfamily || key == Mweight || key == Mstyle
369           || key == Mstretch || key == Madstyle
370           || key == Mforeground || key == Mbackground || key == Mvideomode)
371         {
372           if (! MPLIST_SYMBOL_P (plist))
373             continue;
374           val = MPLIST_VAL (plist);
375         }
376       else if (key == Msize || key == Mratio)
377         {
378           if (! MPLIST_INTEGER_P (plist))
379             continue;
380           val = MPLIST_VAL (plist);
381         }
382       else if (key == Mfontset)
383         {
384           if (! MPLIST_SYMBOL_P (plist))
385             continue;
386           val = mfontset (MSYMBOL_NAME (MPLIST_SYMBOL (plist)));
387         }
388       else if (key == Mhline)
389         {
390           if (! MPLIST_PLIST_P (plist))
391             continue;
392           val = deserialize_hline (MPLIST_PLIST (plist));
393         }
394       else if (key == Mbox)
395         {
396           if (! MPLIST_PLIST_P (plist))
397             continue;
398           val = deserialize_box (MPLIST_PLIST (plist));
399         }
400       face->property[index] = val;
401     }
402   return face;
403 }
404
405 static MGlyphString work_gstring;
406
407 \f
408
409 /* Internal API */
410
411 MFace *mface__default;
412
413 int
414 mface__init ()
415 {
416   int i;
417   MFaceHLineProp *hline;
418   MFaceBoxProp *box;
419
420   M17N_OBJECT_ADD_ARRAY (face_table, "Face");
421   Mface = msymbol_as_managing_key ("face");
422   msymbol_put (Mface, Mtext_prop_serializer, (void *) serialize_face);
423   msymbol_put (Mface, Mtext_prop_deserializer, (void *) deserialize_face);
424
425   Mforeground = msymbol ("foreground");
426   Mbackground = msymbol ("background");
427   Mvideomode = msymbol ("videomode");
428   Mnormal = msymbol ("normal");
429   Mreverse = msymbol ("reverse");
430   Mratio = msymbol ("ratio");
431   Mhline = msymbol ("hline");
432   Mbox = msymbol ("box");
433   Mhook_func = msymbol ("hook-func");
434   Mhook_arg = msymbol ("hook-arg");
435
436   Mlatin = msymbol ("latin");
437   M_face_prop_index = msymbol ("  face-prop-index");
438
439   {
440     struct {
441       /* Pointer to the key symbol of the face property.  */
442       MSymbol *key;
443       /* Index (enum face_property) of the face property. */
444       int index;
445     } mface_prop_data[MFACE_PROPERTY_MAX] =
446         { { &Mfoundry,          MFACE_FOUNDRY },
447           { &Mfamily,           MFACE_FAMILY },
448           { &Mweight,           MFACE_WEIGHT },
449           { &Mstyle,            MFACE_STYLE },
450           { &Mstretch,          MFACE_STRETCH },
451           { &Madstyle,          MFACE_ADSTYLE },
452           { &Msize,             MFACE_SIZE },
453           { &Mfontset,          MFACE_FONTSET },
454           { &Mforeground,       MFACE_FOREGROUND },
455           { &Mbackground,       MFACE_BACKGROUND },
456           { &Mhline,            MFACE_HLINE },
457           { &Mbox,              MFACE_BOX },
458           { &Mvideomode,        MFACE_VIDEOMODE },
459           { &Mhook_func,        MFACE_HOOK_FUNC },
460           { &Mhook_arg,         MFACE_HOOK_ARG },
461           { &Mratio,            MFACE_RATIO },
462         };
463
464     for (i = 0; i < MFACE_PROPERTY_MAX; i++)
465       /* We add one to distinguish it from no-property.  */
466       msymbol_put (*mface_prop_data[i].key, M_face_prop_index,
467                    (void *) (mface_prop_data[i].index + 1));
468   }
469
470   hline_prop_list = mplist ();
471   MSTRUCT_CALLOC (hline, MERROR_FACE);
472   mplist_push (hline_prop_list, Mt, hline);
473   box_prop_list = mplist ();
474   MSTRUCT_CALLOC (box, MERROR_FACE);
475   mplist_push (box_prop_list, Mt, box);
476
477   mface__default = mface ();
478   mface__default->property[MFACE_FOUNDRY] = msymbol ("misc");
479   mface__default->property[MFACE_FAMILY] = msymbol ("fixed");
480   mface__default->property[MFACE_WEIGHT] = msymbol ("medium");
481   mface__default->property[MFACE_STYLE] = msymbol ("r");
482   mface__default->property[MFACE_STRETCH] = msymbol ("normal");
483   mface__default->property[MFACE_ADSTYLE] = msymbol ("");
484   mface__default->property[MFACE_SIZE] = (void *) 120;
485   mface__default->property[MFACE_FONTSET] = mfontset (NULL);
486   mface__default->property[MFACE_FOREGROUND] = msymbol ("black");
487   mface__default->property[MFACE_BACKGROUND] = msymbol ("white");
488   mface__default->property[MFACE_HLINE] = hline;
489   mface__default->property[MFACE_BOX] = box;
490   mface__default->property[MFACE_VIDEOMODE] = Mnormal;
491   mface__default->property[MFACE_HOOK_FUNC] = (void *) noop_hook;
492
493   mface_normal_video = mface ();
494   mface_normal_video->property[MFACE_VIDEOMODE] = (void *) Mnormal;
495
496   mface_reverse_video = mface ();
497   mface_reverse_video->property[MFACE_VIDEOMODE] = (void *) Mreverse;
498
499   {
500     MFaceHLineProp hline_prop;
501
502     hline_prop.type = MFACE_HLINE_UNDER;
503     hline_prop.width = 1;
504     hline_prop.color = Mnil;
505     mface_underline = mface ();
506     mface_put_prop (mface_underline, Mhline, &hline_prop);
507   }
508
509   mface_medium = mface ();
510   mface_medium->property[MFACE_WEIGHT] = (void *) msymbol ("medium");
511   mface_bold = mface ();
512   mface_bold->property[MFACE_WEIGHT] = (void *) msymbol ("bold");
513   mface_italic = mface ();
514   mface_italic->property[MFACE_STYLE] = (void *) msymbol ("i");
515   mface_bold_italic = mface_copy (mface_bold);
516   mface_bold_italic->property[MFACE_STYLE]
517     = mface_italic->property[MFACE_STYLE];
518
519   mface_xx_small = mface ();
520   mface_xx_small->property[MFACE_RATIO] = (void *) 50;
521   mface_x_small = mface ();
522   mface_x_small->property[MFACE_RATIO] = (void *) 67;
523   mface_small = mface ();
524   mface_small->property[MFACE_RATIO] = (void *) 75;
525   mface_normalsize = mface ();
526   mface_normalsize->property[MFACE_RATIO] = (void *) 100;
527   mface_large = mface ();
528   mface_large->property[MFACE_RATIO] = (void *) 120;
529   mface_x_large = mface ();
530   mface_x_large->property[MFACE_RATIO] = (void *) 150;
531   mface_xx_large = mface ();
532   mface_xx_large->property[MFACE_RATIO] = (void *) 200;
533
534   mface_black = mface ();
535   mface_black->property[MFACE_FOREGROUND] = (void *) msymbol ("black");
536   mface_white = mface ();
537   mface_white->property[MFACE_FOREGROUND] = (void *) msymbol ("white");
538   mface_red = mface ();
539   mface_red->property[MFACE_FOREGROUND] = (void *) msymbol ("red");
540   mface_green = mface ();
541   mface_green->property[MFACE_FOREGROUND] = (void *) msymbol ("green");
542   mface_blue = mface ();
543   mface_blue->property[MFACE_FOREGROUND] = (void *) msymbol ("blue");
544   mface_cyan = mface ();
545   mface_cyan->property[MFACE_FOREGROUND] = (void *) msymbol ("cyan");
546   mface_yellow = mface ();
547   mface_yellow->property[MFACE_FOREGROUND] = (void *) msymbol ("yellow");
548   mface_magenta = mface ();
549   mface_magenta->property[MFACE_FOREGROUND] = (void *) msymbol ("magenta");
550
551   work_gstring.glyphs = malloc (sizeof (MGlyph) * 2);
552   work_gstring.size = 2;
553   work_gstring.used = 0;
554   work_gstring.inc = 1;
555   return 0;
556 }
557
558 void
559 mface__fini ()
560 {
561   MPlist *plist;
562
563   M17N_OBJECT_UNREF (mface__default);
564   M17N_OBJECT_UNREF (mface_normal_video);
565   M17N_OBJECT_UNREF (mface_reverse_video);
566   M17N_OBJECT_UNREF (mface_underline);
567   M17N_OBJECT_UNREF (mface_medium);
568   M17N_OBJECT_UNREF (mface_bold);
569   M17N_OBJECT_UNREF (mface_italic);
570   M17N_OBJECT_UNREF (mface_bold_italic);
571   M17N_OBJECT_UNREF (mface_xx_small);
572   M17N_OBJECT_UNREF (mface_x_small);
573   M17N_OBJECT_UNREF (mface_small);
574   M17N_OBJECT_UNREF (mface_normalsize);
575   M17N_OBJECT_UNREF (mface_large);
576   M17N_OBJECT_UNREF (mface_x_large);
577   M17N_OBJECT_UNREF (mface_xx_large);
578   M17N_OBJECT_UNREF (mface_black);
579   M17N_OBJECT_UNREF (mface_white);
580   M17N_OBJECT_UNREF (mface_red);
581   M17N_OBJECT_UNREF (mface_green);
582   M17N_OBJECT_UNREF (mface_blue);
583   M17N_OBJECT_UNREF (mface_cyan);
584   M17N_OBJECT_UNREF (mface_yellow);
585   M17N_OBJECT_UNREF (mface_magenta);
586
587   MPLIST_DO (plist, hline_prop_list)
588     free (MPLIST_VAL (plist));
589   M17N_OBJECT_UNREF (hline_prop_list);
590   MPLIST_DO (plist, box_prop_list)
591     free (MPLIST_VAL (plist));
592   M17N_OBJECT_UNREF (box_prop_list);
593
594   free (work_gstring.glyphs);
595 }
596
597 /** Return a face realized from NUM number of base faces pointed by
598     FACES on the frame FRAME.  If SIZE is nonzero, it specifies the
599     maximum font size.  */
600
601 MRealizedFace *
602 mface__realize (MFrame *frame, MFace **faces, int num, int size, MFont *font)
603 {
604   MRealizedFace *rface;
605   MRealizedFont *rfont;
606   MFace merged_face = *(frame->face);
607   void **props;
608   int i, j;
609   MFaceHookFunc func;
610   MFont adjusted;
611
612   if (num == 0 && frame->rface && ! font)
613     return frame->rface;
614
615   for (i = 0; i < MFACE_PROPERTY_MAX; i++)
616     for (j = num - 1; j >= 0; j--)
617       if (faces[j]->property[i])
618         {
619           merged_face.property[i] = faces[j]->property[i];
620           break;
621         }
622   if (font)
623     {
624       for (i = 0; i <= MFACE_ADSTYLE; i++)
625         if (font->property[i])
626           merged_face.property[i] = FONT_PROPERTY (font, i);
627       if (font->size)
628         {
629           if (font->size < 0)
630             {
631               double pt = - font->size;
632
633               adjusted = *font;
634               adjusted.size = pt * frame->dpi / 72.27 + 0.5;
635               font = &adjusted;
636             }
637           merged_face.property[MFACE_SIZE] = (void *) font->size;
638         }
639     }
640
641   if (! mplist_find_by_value (frame->face->frame_list, frame))
642     mplist_push (frame->face->frame_list, Mt, frame);
643   for (i = 0; i < num; i++)
644     if (! mplist_find_by_value (faces[i]->frame_list, frame))
645       mplist_push (faces[i]->frame_list, Mt, frame);
646
647   if ((int) merged_face.property[MFACE_SIZE] < 0
648       || (int) merged_face.property[MFACE_RATIO] != 100)
649     {
650       double font_size = (int) merged_face.property[MFACE_SIZE];
651       int ifont_size;
652
653       if (font_size < 0)
654         font_size = - font_size * frame->dpi / 72.27;
655       if ((int) merged_face.property[MFACE_RATIO] != 100)
656         {
657           font_size *= (int) merged_face.property[MFACE_RATIO];
658           font_size /= 100;
659           merged_face.property[MFACE_RATIO] = 0;
660         }
661       ifont_size = font_size + 0.5;
662       merged_face.property[MFACE_SIZE] = (void *) ifont_size;
663     }
664
665   merged_face.property[MFACE_FOUNDRY] = Mnil;
666   rface = find_realized_face (frame, &merged_face, font);
667   if (rface)
668     return rface;
669
670   MSTRUCT_CALLOC (rface, MERROR_FACE);
671   mplist_push (frame->realized_face_list, Mt, rface);
672   rface->frame = frame;
673   rface->face = merged_face;
674   if (font)
675     {
676       rface->font = mfont ();
677       *rface->font = *font;
678     }
679   props = merged_face.property;
680   rface->rfontset = mfont__realize_fontset (frame,
681                                             (MFontset *) props[MFACE_FONTSET],
682                                             &merged_face, font);
683   num = 0;
684   rfont = NULL;
685   if (! font)
686     {
687       MFont spec;
688
689       mfont__set_spec_from_face (&spec, &merged_face);
690       mfont_put_prop (&spec, Mregistry, Miso8859_1);
691       spec.source = MFONT_SOURCE_X;
692       font = mfont__select (frame, &spec, 0);
693       if (! font)
694         {
695           mfont_put_prop (&spec, Mregistry, Municode_bmp);
696           spec.source = MFONT_SOURCE_FT;
697           font = mfont__select (frame, &spec, 0);
698         }
699       if (font)
700         rfont = mfont__open (frame, font, &spec);
701     }
702   if (! rfont)
703     rfont = mfont__lookup_fontset (rface->rfontset, NULL, &num,
704                                    Mlatin, Mnil, Mnil, size, 0);
705   if (rfont)
706     {
707       rface->rfont = rfont;
708       rface->layouter = rfont->layouter;
709       work_gstring.glyphs[0].rface = rface;
710       work_gstring.glyphs[0].code = MCHAR_INVALID_CODE;
711       mfont__get_metric (&work_gstring, 0, 1);
712       rface->ascent = work_gstring.glyphs[0].ascent;
713       rface->descent = work_gstring.glyphs[0].descent;
714       work_gstring.glyphs[0].code
715         = mfont__encode_char (frame, (MFont *) rfont, NULL, ' ');
716       if (work_gstring.glyphs[0].code != MCHAR_INVALID_CODE)
717         {
718           mfont__get_metric (&work_gstring, 0, 1);
719           rface->space_width = work_gstring.glyphs[0].width;
720         }
721       else
722         rface->space_width = rfont->spec.size / 10;
723     }
724   else
725     {
726       rface->rfont = NULL;
727       rface->space_width = frame->space_width;
728     }
729
730   rface->hline = (MFaceHLineProp *) props[MFACE_HLINE];
731   if (rface->hline && rface->hline->width == 0)
732     rface->hline = NULL;
733   rface->box = (MFaceBoxProp *) props[MFACE_BOX];
734   if (rface->box && rface->box->width == 0)
735     rface->box = NULL;
736   rface->ascii_rface = rface;
737   (*frame->driver->realize_face) (rface);
738
739   func = (MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC];
740   if (func && func != noop_hook)
741     (func) (&(rface->face), rface->info, rface->face.property[MFACE_HOOK_ARG]);
742
743   rface->non_ascii_list = mplist ();
744   if (rface->rfont)
745     {
746       MRealizedFace *nofont;
747
748       MSTRUCT_CALLOC (nofont, MERROR_FACE);
749       *nofont = *rface;
750       nofont->non_ascii_list = NULL;
751       nofont->rfont = NULL;
752       mplist_add (rface->non_ascii_list, Mt, nofont);
753     }
754
755   return rface;
756 }
757
758
759 MGlyph *
760 mface__for_chars (MSymbol script, MSymbol language, MSymbol charset,
761                   MGlyph *from_g, MGlyph *to_g, int size)
762 {
763   MRealizedFont *rfont;
764   MSymbol layouter;
765   int num = to_g - from_g;
766   int i;
767
768   rfont = from_g->rface->rfont;
769   if (script == Mlatin)
770     {
771       for (i = 0; i < num; i++)
772         {
773           unsigned code = mfont__encode_char (rfont->frame, (MFont *) rfont,
774                                               NULL, from_g[i].c);
775           if (code == MCHAR_INVALID_CODE)
776             break;
777           from_g[i].code = code;
778         }
779       if (i == num)
780         return to_g;
781     }
782
783   rfont = mfont__lookup_fontset (from_g->rface->rfontset, from_g, &num,
784                                  script, language, charset, size, 0);
785   if (rfont)
786     layouter = rfont->layouter;
787   else
788     {
789       from_g->code = MCHAR_INVALID_CODE;
790       num = 1;
791       rfont = NULL;
792       layouter = Mnil;
793     }
794   
795   to_g = from_g + num;
796   while (from_g < to_g)
797     {
798       MGlyph *g = from_g;
799       MRealizedFace *rface = from_g++->rface;
800
801       while (from_g < to_g && rface == from_g->rface) from_g++;
802       if (rface->rfont != rfont
803           || rface->layouter != layouter)
804         {
805           MPlist *plist = mplist_find_by_value (rface->non_ascii_list, rfont);
806           MRealizedFace *new = NULL;
807
808           while (plist)
809             {
810               new = MPLIST_VAL (plist);
811               if (new->layouter == layouter)
812                 break;
813               plist = mplist_find_by_value (MPLIST_NEXT (plist), rfont);
814             }
815           if (! plist)
816             {
817               MSTRUCT_MALLOC (new, MERROR_FACE);
818               mplist_push (rface->non_ascii_list, Mt, new);
819               *new = *rface;
820               new->rfont = rfont;
821               new->layouter = layouter;
822               new->non_ascii_list = NULL;
823               if (rfont)
824                 {
825                   new->ascent = rfont->ascent;
826                   new->descent = rfont->descent;
827                 }
828             }
829           while (g < from_g)
830             g++->rface = new;
831         }
832     }
833   return to_g;
834 }
835
836
837 void
838 mface__free_realized (MRealizedFace *rface)
839 {
840   MPlist *plist;
841
842   MPLIST_DO (plist, rface->non_ascii_list)
843     free (MPLIST_VAL (plist));
844   M17N_OBJECT_UNREF (rface->non_ascii_list);
845   if (rface->font)
846     free (rface->font);
847   free (rface);
848 }
849
850 void
851 mface__update_frame_face (MFrame *frame)
852 {
853   frame->rface = NULL;
854   frame->rface = mface__realize (frame, NULL, 0, 0, NULL);
855   frame->space_width = frame->rface->space_width;
856   frame->ascent = frame->rface->ascent;
857   frame->descent = frame->rface->descent;
858 }
859
860 /*** @} */
861 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
862
863 \f
864 /* External API  */
865 /*** @addtogroup m17nFace */
866 /*** @{ */
867 /*=*/
868
869 /***en @name Variables: Keys of face property */
870 /***ja @name ÊÑ¿ô: ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼  */
871 /*** @{ */
872 /*=*/
873
874 /***en
875     @brief Key of a face property specifying foreground color.
876
877     The variable #Mforeground is used as a key of face property.  The
878     property value must be a symbol whose name is a color name, or
879     #Mnil.
880
881     #Mnil means that the face does not specify a foreground color.
882     Otherwise, the foreground of an M-text is drawn by the specified
883     color.  */
884 /***ja
885     @brief Á°·Ê¿§¤ò»ØÄꤹ¤ë¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
886
887     ÊÑ¿ô #Mforeground ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
888     ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¿§Ì¾¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë¤« #Mnil ¤Ç¤¢¤ë¡£
889
890     #Mnil ¤Î¾ì¹ç¡¢Á°·Ê¿§¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð M-text 
891     ¤ÎÁ°·Ê¤Ï»ØÄꤵ¤ì¤¿¿§¤Çɽ¼¨¤µ¤ì¤ë¡£  */
892
893 MSymbol Mforeground;
894
895 /***en
896     @brief Key of a face property specifying background color.
897
898     The variable #Mbackground is used as a key of face property.  The
899     property value must be a symbol whose name is a color name, or
900     #Mnil.
901
902     #Mnil means that the face does not specify a background color.
903     Otherwise, the background of an M-text is drawn by the specified
904     color.  */
905 /***ja
906     @brief ÇØ·Ê¿§¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
907
908     ÊÑ¿ô #Mbackground ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
909     ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¿§Ì¾¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë¤« #Mnil ¤Ç¤¢¤ë¡£
910
911     #Mnil ¤Î¾ì¹ç¡¢ÇØ·Ê¿§¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð M-text 
912     ¤ÎÇطʤϻØÄꤵ¤ì¤¿¿§¤Çɽ¼¨¤µ¤ì¤ë¡£  */
913
914 MSymbol Mbackground;
915
916 /***en
917     @brief Key of a face property specifying video mode.
918
919     The variable #Mvideomode is used as a key of face property.  The
920     property value must be #Mnormal, #Mreverse, or #Mnil.
921
922     #Mnormal means that an M-text is drawn in normal video mode
923     (i.e. the foreground is drawn by foreground color, the background
924     is drawn by background color).
925
926     #Mreverse means that an M-text is drawn in reverse video mode
927     (i.e. the foreground is drawn by background color, the background
928     is drawn by foreground color).
929
930     #Mnil means that the face does not specify a video mode.  */
931 /***ja
932     @brief ¥Ó¥Ç¥ª¥â¡¼¥É¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
933
934     ÊÑ¿ô #Mvideomode ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢
935     #Mnormal, #Mreverse, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
936
937     #Mnormal ¤Î¾ì¹ç¤Ï¡¢M-text 
938     ¤òɸ½à¤Î¥Ó¥Ç¥ª¥â¡¼¥É¡ÊÁ°·Ê¤òÁ°·Ê¿§¤Ç¡¢ÇطʤòÇØ·Ê¿§¤Ç¡Ë¤Çɽ¼¨¤¹¤ë¡£
939
940     #Mreverse ¤Î¾ì¹ç¤Ï¥ê¥Ð¡¼¥¹¥Ó¥Ç¥ª¥â¡¼¥É¤Ç¡ÊÁ°·Ê¤òÇØ·Ê¿§¤Ç¡¢ÇطʤòÁ°·Ê¿§¤Ç¡Ëɽ¼¨¤¹¤ë¡£
941
942     #Mnil ¤Î¾ì¹ç¤Ï¥Ó¥Ç¥ª¥â¡¼¥É¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
943     */
944
945 MSymbol Mvideomode;
946
947 /***en
948     @brief Key of a face property specifying font size ratio.
949
950     The variable #Mratio is used as a key of face property.  The value
951     RATIO must be an integer.
952
953     The value 0 means that the face does not specify a font size
954     ratio.  Otherwise, an M-text is drawn by a font of size (FONTSIZE
955     * RATIO / 100) where FONTSIZE is a font size specified by the face
956     property #Msize.  */
957 /***ja
958     @brief ¥Õ¥©¥ó¥È¤Î¥µ¥¤¥º¤ÎÈæΨ¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
959
960     ÊÑ¿ô #Mratio ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃÍ RATIO 
961     ¤ÏÀ°¿ôÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
962
963     Ãͤ¬0¤Ê¤é¤Ð¡¢¥Õ¥©¥ó¥È¥µ¥¤¥º¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢M-text 
964     ¤Ï(FONTSIZE * RATIO / 100) ¤È¤¤¤¦¥µ¥¤¥º¤Î¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£
965     FONTSIZE ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼#Msize ¤Ç»ØÄꤵ¤ì¤¿¥µ¥¤¥º¤Ç¤¢¤ë¡£ */
966
967 MSymbol Mratio;
968
969 /***en
970     @brief Key of a face property specifying horizontal line.
971
972     The variable #Mhline is used as a key of face property.  The value
973     must be a pointer to an object of type #MFaceHLineProp, or @c
974     NULL.
975
976     The value @c NULL means that the face does not specify this
977     property.  Otherwise, an M-text is drawn with a horizontal line by
978     a way specified by the object that the value points to.  */
979 /***ja
980     @brief ¿åÊ¿Àþ¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
981
982     ÊÑ¿ô #Mhline ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
983     #MFaceHLineProp ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
984
985     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
986     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¤è¤¦¤Ë¿åÊ¿Àþ¤òÉղ䷤ƠM-text 
987     ¤òɽ¼¨¤¹¤ë¡£*/
988
989 MSymbol Mhline;
990
991 /***en
992     @brief Key of a face property specifying box.
993
994     The variable #Mbox is used as a key of face property.  The value
995     must be a pointer to an object of type #MFaceBoxProp, or @c NULL.
996
997     The value @c NULL means that the face does not specify a box.
998     Otherwise, an M-text is drawn with a surrounding box by a way
999     specified by the object that the value points to.  */
1000 /***ja
1001     @brief °Ï¤ßÏȤò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1002
1003     ÊÑ¿ô #Mbox ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1004     #MFaceBoxProp ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1005
1006     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¤³¤Î¥Õ¥§¡¼¥¹¤Ï°Ï¤ßÏȤò»ØÄꤷ¤Æ¤¤¤Ê¤¤¡£
1007     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¤è¤¦¤Ë°Ï¤ßÏȤòÉղ䷤Ơ
1008     M-text ¤òɽ¼¨¤¹¤ë¡£*/
1009
1010 MSymbol Mbox;
1011
1012 /***en
1013     @brief Key of a face property specifying fontset.
1014
1015     The variable #Mfontset is used as a key of face property.  The
1016     value must be a pointer to an object of type #Mfontset, or @c
1017     NULL.
1018
1019     The value @c NULL means that the face does not specify a fontset.
1020     Otherwise, an M-text is drawn with a font selected from what
1021     specified in the fontset.  */
1022 /***ja
1023     @brief ¥Õ¥©¥ó¥È¥»¥Ã¥È¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1024
1025     ÊÑ¿ô #Mfontset ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1026     #Mfontset ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1027
1028     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1029     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¥Õ¥©¥ó¥È¥»¥Ã¥È¤«¤éÁª¤ó¤À¥Õ¥©¥ó¥È¤Ç 
1030     M-text ¤òɽ¼¨¤¹¤ë¡£*/
1031     
1032 MSymbol Mfontset;
1033
1034 /***en
1035     @brief Key of a face property specifying hook.
1036
1037     The variable #Mhook_func is used as a key of face property.  The
1038     value must be a function of type #MFaceHookFunc, or @c NULL.
1039
1040     The value @c NULL means that the face does not specify a hook.
1041     Otherwise, the specified function is called before the face is
1042     realized.  */
1043 /***ja
1044     @brief ¥Õ¥Ã¥¯¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1045
1046     ÊÑ¿ô #Mhook_func ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1047     #MFaceHookFunc ·¿¤Î´Ø¿ô¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1048
1049     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¥Õ¥Ã¥¯¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1050     ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¥Õ¥§¡¼¥¹¤ò¼Â¸½¤¹¤ëÁ°¤Ë»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¸Æ¤Ð¤ì¤ë¡£      */
1051 MSymbol Mhook_func;
1052
1053 /***en
1054     @brief Key of a face property specifying argument of hook.
1055
1056     The variable #Mhook_arg is used as a key of face property.  The
1057     value can be anything that is passed a hook function specified by
1058     the face property #Mhook_func.  */
1059 /***ja
1060     @brief ¥Õ¥Ã¥¯¤Î°ú¿ô¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1061
1062     ÊÑ¿ô #Mhook_arg ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
1063     Ãͤϲ¿¤Ç¤â¤è¤¯¡¢¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£ #Mhook_func ¤Ç»ØÄꤵ¤ì¤ë´Ø¿ô¤ËÅϤµ¤ì¤ë¡£ */
1064 MSymbol Mhook_arg;
1065
1066 /*** @} */
1067 /*=*/
1068
1069 /*** @ingroup m17nFace */
1070 /***en @name Variables: Possible values of #Mvideomode property of face */
1071 /***ja @name ÊÑ¿ô¡§  ¥Õ¥§¡¼¥¹¤Î #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤Î²Äǽ¤ÊÃÍ */
1072 /*** @{ */
1073 /*=*/
1074
1075 /***en
1076     See the documentation of the variable #Mvideomode.  */ 
1077 /***ja
1078     ÊÑ¿ô #Mvideomode ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£  */ 
1079 MSymbol Mnormal;
1080 MSymbol Mreverse;
1081 /*** @} */
1082 /*=*/
1083
1084 /*** @ingroup m17nFace */
1085 /***en @name Variables: Predefined faces  */
1086 /***ja @name ÊÑ¿ô: ÄêµÁºÑ¤ß¥Õ¥§¡¼¥¹  */
1087 /*** @{ */
1088 /*=*/
1089
1090 /***en
1091     @brief Normal video face.
1092
1093     The variable #mface_normal_video points to a face that has the
1094     #Mvideomode property with value #Mnormal.  The other properties
1095     are not specified.  An M-text drawn with this face appear normal
1096     colors (i.e. the foreground is drawn by foreground color, and
1097     background is drawn by background color).  */
1098 /***ja
1099     @brief É¸½à¥Ó¥Ç¥ª¥Õ¥§¡¼¥¹.
1100
1101     ÊÑ¿ô #mface_normal_video ¤Ï #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ #Mnormal 
1102     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1103     ¤³¤Î¥Õ¥§¡¼¥¹¤Çɽ¼¨¤µ¤ì¤ëM-text 
1104     ¤Ïɸ½à¤Î¿§ (¤¹¤Ê¤ï¤ÁÁ°·Ê¤ÏÁ°·Ê¿§¡¢ÇطʤÏÇØ·Ê¿§¡Ë¤ÇÉÁ¤«¤ì¤ë¡£  */
1105
1106 MFace *mface_normal_video;
1107
1108 /***en
1109     @brief Reverse video face.
1110
1111     The variable #mface_reverse_video points to a face that has the
1112     #Mvideomode property with value #Mreverse.  The other properties
1113     are not specified.  An M-text drawn with this face appear in
1114     reversed colors (i.e. the foreground is drawn by background
1115     color, and background is drawn by foreground color).  */
1116 /***ja
1117     @brief ¥ê¥Ð¡¼¥¹¥Ó¥Ç¥ª¥Õ¥§¡¼¥¹.
1118
1119     ÊÑ¿ô #mface_reverse_video ¤Ï #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 
1120     #Mreverse ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1121     ¤³¤Î¥Õ¥§¡¼¥¹¤Çɽ¼¨¤µ¤ì¤ëM-text 
1122     ¤ÏÁ°·Ê¿§¤ÈÇØ·Ê¿§¤¬Æþ¤ìÂؤï¤Ã¤Æ (¤¹¤Ê¤ï¤ÁÁ°·Ê¤ÏÇØ·Ê¿§¡¢ÇطʤÏÁ°·Ê¿§¡ËÉÁ¤«¤ì¤ë¡£  */
1123
1124 MFace *mface_reverse_video;
1125
1126 /***en
1127     @brief Underline face.
1128
1129     The variable #mface_underline points to a face that has the
1130     #Mhline property with value a pointer to an object of type
1131     #MFaceHLineProp.  The members of the object are as follows:
1132
1133 @verbatim
1134     member  value
1135     -----   -----
1136     type    MFACE_HLINE_UNDER
1137     width   1
1138     color   Mnil
1139 @endverbatim
1140
1141     The other properties are not specified.  An M-text that has this
1142     face is drawn with an underline.  */ 
1143 /***ja
1144     @brief ²¼Àþ¥Õ¥§¡¼¥¹.
1145
1146     ÊÑ¿ô #mface_underline ¤Ï #Mhline ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ #MFaceHLineProp 
1147     ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£¥ª¥Ö¥¸¥§¥¯¥È¤Î¥á¥ó¥Ð¤Ï°Ê²¼¤ÎÄ̤ꡣ
1148
1149 @verbatim
1150     ¥á¥ó¥Ð  ÃÍ
1151     -----   -----
1152     type    MFACE_HLINE_UNDER
1153     width   1
1154     color   Mnil
1155 @endverbatim
1156
1157     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ï²¼ÀþÉÕ¤­¤Çɽ¼¨¤µ¤ì¤ë¡£*/ 
1158
1159 MFace *mface_underline;
1160
1161 /***en
1162     @brief Medium face.
1163
1164     The variable #mface_medium points to a face that has the #Mweight
1165     property with value a symbol of name "medium".  The other
1166     properties are not specified.  An M-text that has this face is
1167     drawn with a font of medium weight.  */
1168 /***ja
1169     @brief ¥ß¥Ç¥£¥¢¥à¥Õ¥§¡¼¥¹.
1170
1171     ÊÑ¿ô #mface_medium ¤Ï #Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "medium" 
1172     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1173     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text
1174     ¤Ï¡¢¥ß¥Ç¥£¥¢¥à¥¦¥§¥¤¥È¤Î¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£  */
1175 MFace *mface_medium;
1176
1177 /***en
1178     @brief Bold face.
1179
1180     The variable #mface_bold points to a face that has the #Mweight
1181     property with value a symbol of name "bold".  The other properties
1182     are not specified.  An M-text that has this face is drawn with a
1183     font of bold weight.  */
1184 /***ja
1185     @brief ¥Ü¡¼¥ë¥É¥Õ¥§¡¼¥¹.
1186
1187     ÊÑ¿ô #mface_bold ¤Ï #Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "bold" 
1188     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1189     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1190     ¤Ï¡¢¥Ü¡¼¥ë¥É¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£    */
1191
1192 MFace *mface_bold;
1193
1194 /***en
1195     @brief Italic face.
1196
1197     The variable #mface_italic points to a face that has the #Mstyle
1198     property with value a symbol of name "italic".  The other
1199     properties are not specified.  An M-text that has this face is
1200     drawn with a font of italic style.  */
1201 /***ja
1202     @brief ¥¤¥¿¥ê¥Ã¥¯¥Õ¥§¡¼¥¹.
1203
1204     ÊÑ¿ô #mface_italic ¤Ï #Mstyle ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "italic" 
1205     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1206     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text
1207     ¤Ï¡¢¥¤¥¿¥ê¥Ã¥¯ÂΤÇɽ¼¨¤µ¤ì¤ë¡£    */
1208
1209 MFace *mface_italic;
1210
1211 /***en
1212     @brief Bold italic face.
1213
1214     The variable #mface_bold_italic points to a face that has the
1215     #Mweight property with value a symbol of name "bold", and #Mstyle
1216     property with value a symbol of name "italic".  The other
1217     properties are not specified.  An M-text that has this face is
1218     drawn with a font of bold weight and italic style.  */
1219 /***ja
1220     @brief ¥Ü¡¼¥ë¥É¥¤¥¿¥ê¥Ã¥¯¥Õ¥§¡¼¥¹.
1221
1222     ÊÑ¿ô #mface_bold_italic ¤Ï¡¢#Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "bold" 
1223     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢¤«¤Ä #Mstyle ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "italic" 
1224     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1225     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1226     ¤Ï¡¢¥Ü¡¼¥ë¥É¥¤¥¿¥ê¥Ã¥¯ÂΤÇɽ¼¨¤µ¤ì¤ë¡£    */
1227
1228 MFace *mface_bold_italic;
1229
1230 /***en
1231     @brief Smallest face.
1232
1233     The variable #mface_xx_small points to a face that has the #Mratio
1234     property with value 50.  The other properties are not specified.
1235     An M-text that has this face is drawn with a font whose size is
1236     50% of a normal font.  */
1237 /***ja
1238     @brief ºÇ¾®¤Î¥Õ¥§¡¼¥¹.
1239
1240     ÊÑ¿ô #mface_xx_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 50 
1241     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1242     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 50% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1243      */
1244
1245 MFace *mface_xx_small;
1246
1247 /***en
1248     @brief Smaller face.
1249
1250     The variable #mface_x_small points to a face that has the #Mratio
1251     property with value 66.  The other properties are not specified.
1252     An M-text that has this face is drawn with a font whose size is
1253     66% of a normal font.  */
1254 /***ja
1255     @brief ¤è¤ê¾®¤µ¤¤¥Õ¥§¡¼¥¹.
1256
1257     ÊÑ¿ô #mface_x_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 66 
1258     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1259     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 66% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1260      */
1261
1262 MFace *mface_x_small;
1263
1264 /***en
1265     @brief Small face.
1266
1267     The variable #mface_x_small points to a face that has the #Mratio
1268     property with value 75.  The other properties are not specified.
1269     An M-text that has this face is drawn with a font whose size is
1270     75% of a normal font.  */
1271 /***ja
1272     @brief ¾®¤µ¤¤¥Õ¥§¡¼¥¹.
1273
1274     ÊÑ¿ô #mface_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 75 
1275     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1276     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 75% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1277      */
1278
1279 MFace *mface_small;
1280
1281 /***en
1282     @brief Normalsize face.
1283
1284     The variable #mface_normalsize points to a face that has the
1285     #Mratio property with value 100.  The other properties are not
1286     specified.  An M-text that has this face is drawn with a font
1287     whose size is the same as a normal font.  */
1288 /***ja
1289     @brief É¸½à¤ÎÂ礭¤µ¤Î¥Õ¥§¡¼¥¹.
1290
1291     ÊÑ¿ô #mface_normalsize ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 100 
1292     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1293     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤ÈƱ¤¸Â礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1294      */
1295
1296 MFace *mface_normalsize;
1297
1298 /***en
1299     @brief Large face.
1300
1301     The variable #mface_large points to a face that has the #Mratio
1302     property with value 120.  The other properties are not specified.
1303     An M-text that has this face is drawn with a font whose size is
1304     120% of a normal font.  */
1305 /***ja
1306     @brief Â礭¤¤¥Õ¥§¡¼¥¹.
1307
1308     ÊÑ¿ô #mface_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 120 
1309     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1310     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 120% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1311      */
1312
1313 MFace *mface_large;
1314
1315 /***en
1316     @brief Larger face.
1317
1318     The variable #mface_x_large points to a face that has the #Mratio
1319     property with value 150.  The other properties are not specified.
1320     An M-text that has this face is drawn with a font whose size is
1321     150% of a normal font.  */
1322 /***ja
1323     @brief ¤â¤Ã¤ÈÂ礭¤¤¥Õ¥§¡¼¥¹.
1324
1325     ÊÑ¿ô #mface_x_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 150 
1326     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1327     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 150% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1328      */
1329
1330 MFace *mface_x_large;
1331
1332 /***en
1333     @brief Largest face.
1334
1335     The variable #mface_xx_large points to a face that has the #Mratio
1336     property with value 200.  The other properties are not specified.
1337     An M-text that has this face is drawn with a font whose size is
1338     200% of a normal font.  */
1339 /***ja
1340     @brief ºÇÂç¤Î¥Õ¥§¡¼¥¹.
1341
1342     ÊÑ¿ô #mface_xx_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 200 
1343     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1344     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 200% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1345      */
1346
1347 MFace *mface_xx_large;
1348
1349 /***en
1350     @brief Black face.
1351
1352     The variable #mface_black points to a face that has the
1353     #Mforeground property with value a symbol of name "black".  The
1354     other properties are not specified.  An M-text that has this face
1355     is drawn with black foreground.  */
1356 /***ja 
1357     @brief ¹õ¥Õ¥§¡¼¥¹.
1358
1359     ÊÑ¿ô #mface_black ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "black" 
1360     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1361     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1362     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¹õ¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£     */
1363
1364 MFace *mface_black;
1365
1366 /***en
1367     @brief White face.
1368
1369     The variable #mface_white points to a face that has the
1370     #Mforeground property with value a symbol of name "white".  The
1371     other properties are not specified.  An M-text that has this face
1372     is drawn with white foreground.  */
1373 /***ja
1374     @brief Çò¥Õ¥§¡¼¥¹.
1375
1376     ÊÑ¿ô #mface_white ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "white" 
1377     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1378     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1379     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÇò¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£     */
1380
1381 MFace *mface_white;
1382
1383 /***en
1384     @brief Red face.
1385
1386     The variable #mface_red points to a face that has the
1387     #Mforeground property with value a symbol of name "red".  The
1388     other properties are not specified.  An M-text that has this face
1389     is drawn with red foreground.  */
1390 /***ja
1391     @brief ÀÖ¥Õ¥§¡¼¥¹.
1392
1393     ÊÑ¿ô #mface_red ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "red" 
1394     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1395     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1396     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÀÖ¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1397
1398 MFace *mface_red;
1399
1400 /***en
1401     @brief Green face.
1402
1403     The variable #mface_green points to a face that has the
1404     #Mforeground property with value a symbol of name "green".  The
1405     other properties are not specified.  An M-text that has this face
1406     is drawn with green foreground.  */
1407 /***ja
1408     @brief ÎÐ¥Õ¥§¡¼¥¹.
1409
1410     ÊÑ¿ô #mface_green ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "green" 
1411     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1412     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1413     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÎФòÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1414
1415 MFace *mface_green;
1416
1417 /***en
1418     @brief Blue face.
1419
1420     The variable #mface_blue points to a face that has the
1421     #Mforeground property with value a symbol of name "blue".  The
1422     other properties are not specified.  An M-text that has this face
1423     is drawn with blue foreground.  */
1424 /***ja
1425     @brief ÀÄ¥Õ¥§¡¼¥¹.
1426
1427     ÊÑ¿ô #mface_blue ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "blue" 
1428     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1429     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1430     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÀĤòÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1431
1432 MFace *mface_blue;
1433
1434 /***en
1435     @brief Cyan face.
1436
1437     The variable #mface_cyan points to a face that has the
1438     #Mforeground property with value a symbol of name "cyan".  The
1439     other properties are not specified.  An M-text that has this face
1440     is drawn with cyan foreground.  */
1441 /***ja
1442     @brief ¥·¥¢¥ó¥Õ¥§¡¼¥¹.
1443
1444     ÊÑ¿ô #mface_cyan ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "cyan"
1445     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1446     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1447     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¥·¥¢¥ó¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1448
1449 MFace *mface_cyan;
1450
1451 /***en
1452     @brief yellow face.
1453
1454     The variable #mface_yellow points to a face that has the
1455     #Mforeground property with value a symbol of name "yellow".  The
1456     other properties are not specified.  An M-text that has this face
1457     is drawn with yellow foreground.  */
1458
1459 /***ja
1460     @brief ²«¥Õ¥§¡¼¥¹.
1461
1462     ÊÑ¿ô #mface_yellow ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "yellow" 
1463     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1464     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1465     ¤ÏÁ°·Ê¿§¤È¤·¤Æ²«¿§¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1466
1467 MFace *mface_yellow;
1468
1469 /***en
1470     @brief Magenta face.
1471
1472     The variable #mface_magenta points to a face that has the
1473     #Mforeground property with value a symbol of name "magenta".  The
1474     other properties are not specified.  An M-text that has this face
1475     is drawn with magenta foreground.  */
1476
1477 /***ja
1478     @brief ¥Þ¥¼¥ó¥¿¥Õ¥§¡¼¥¹.
1479
1480     ÊÑ¿ô #mface_magenta ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ 
1481     "magenta" ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1482     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1483     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¥Þ¥¼¥ó¥¿¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1484
1485 MFace *mface_magenta;
1486
1487 /*** @} */
1488 /*=*/
1489
1490 /***en @name Variables: The other symbols for face handling.  */
1491 /***ja @name ÊÑ¿ô: ¥Õ¥§¡¼¥¹¤ò¼è¤ê°·¤¦¤¿¤á¤Î¤½¤Î¾¤Î¥·¥ó¥Ü¥ë  */
1492 /*** @{ */
1493 /*=*/
1494
1495 /***en
1496     @brief Key of a text property specifying a face.
1497
1498     The variable #Mface is a symbol of name <tt>"face"</tt>.  A text
1499     property whose key is this symbol must have a pointer to an object
1500     of type #MFace.  This is a managing key.  */
1501
1502 /***ja
1503     @brief ¥Õ¥§¡¼¥¹¤ò»ØÄꤹ¤ë¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼.
1504
1505     ÊÑ¿ô #Mface ¤Ï <tt>"face"</tt> 
1506     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£¤³¤Î¥·¥ó¥Ü¥ë¤ò¥­¡¼¤È¤¹¤ë¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¡¢
1507     #MFace ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1508     ¤³¤ì¤Ï´ÉÍý¥­¡¼¤Ç¤¢¤ë¡£  */
1509
1510 MSymbol Mface;
1511 /*=*/
1512 /*** @} */
1513 /*=*/
1514
1515 /***en
1516     @brief Create a new face.
1517
1518     The mface () function creates a new face object that specifies no
1519     property.
1520
1521     @return
1522     This function returns a pointer to the created face.  */
1523
1524 /***ja
1525     @brief ¿·¤·¤¤¥Õ¥§¡¼¥¹¤ò¤Ä¤¯¤ë.
1526
1527     ´Ø¿ô mface () 
1528     ¤Ï¥×¥í¥Ñ¥Æ¥£¤ò°ìÀÚ»ý¤¿¤Ê¤¤¿·¤·¤¤¥Õ¥§¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë¡£
1529
1530     @return
1531     ¤³¤Î´Ø¿ô¤Ïºî¤Ã¤¿¥Õ¥§¡¼¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£  */
1532
1533 MFace *
1534 mface ()
1535 {
1536   MFace *face;
1537
1538   M17N_OBJECT (face, free_face, MERROR_FACE);
1539   face->frame_list = mplist ();
1540   M17N_OBJECT_REGISTER (face_table, face);
1541   return face;
1542 }
1543
1544 /*=*/
1545
1546 /***en
1547     @brief Make a copy of a face.
1548
1549     The mface_copy () function makes a copy of $FACE and returns a
1550     pointer to the created copy.  */
1551
1552 /***ja
1553     @brief ¥Õ¥§¡¼¥¹¤Î¥³¥Ô¡¼¤òºî¤ë.
1554
1555     ´Ø¿ô mface_copy () ¤Ï¥Õ¥§¡¼¥¹ $FACE 
1556     ¤Î¥³¥Ô¡¼¤òºî¤ê¡¢¤½¤Î¥³¥Ô¡¼¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£  */
1557
1558 MFace *
1559 mface_copy (MFace *face)
1560 {
1561   MFace *copy;
1562
1563   MSTRUCT_CALLOC (copy, MERROR_FACE);
1564   *copy = *face;
1565   copy->control.ref_count = 1;
1566   M17N_OBJECT_REGISTER (face_table, copy);
1567   copy->frame_list = mplist ();
1568   if (copy->property[MFACE_FONTSET])
1569     M17N_OBJECT_REF (copy->property[MFACE_FONTSET]);
1570   return copy;
1571 }
1572
1573 /*=*/
1574 /***en
1575     @brief Compare faces.
1576
1577     The mface_equal () function compares faces $FACE1 and $FACE2.
1578
1579     @return If two faces have the same property values, return 1.
1580     Otherwise return 0.  */
1581
1582 int
1583 mface_equal (MFace *face1, MFace *face2)
1584 {
1585   MFaceHLineProp *hline1, *hline2;
1586   MFaceBoxProp *box1, *box2;
1587   int i;
1588
1589   if (face1 == face2)
1590     return 1;
1591   if (memcmp (face1->property, face2->property, sizeof face1->property) == 0)
1592     return 1;
1593   for (i = MFACE_FOUNDRY; i <= MFACE_BACKGROUND; i++)
1594     if (face1->property[i] != face2->property[i])
1595       return 0;
1596   for (i = MFACE_VIDEOMODE; i <= MFACE_RATIO; i++)
1597     if (face1->property[i] != face2->property[i])
1598       return 0;
1599   hline1 = (MFaceHLineProp *) face1->property[MFACE_HLINE];
1600   hline2 = (MFaceHLineProp *) face2->property[MFACE_HLINE];
1601   if (hline1 != hline2)
1602     {
1603       if (! hline1 || ! hline2)
1604         return 0;
1605       if (memcmp (hline1, hline2, sizeof (MFaceHLineProp)) != 0)
1606         return 0;
1607     }
1608   box1 = (MFaceBoxProp *) face1->property[MFACE_BOX];
1609   box2 = (MFaceBoxProp *) face2->property[MFACE_BOX];
1610   if (box1 != box2)
1611     {
1612       if (! box1 || ! box2)
1613         return 0;
1614       if (memcmp (box1, box2, sizeof (MFaceBoxProp)) != 0)
1615         return 0;
1616     }
1617   return 1;
1618 }
1619
1620
1621 /*=*/
1622 /***en
1623     @brief Merge faces.
1624
1625     The mface_merge () functions merges the properties of face $SRC
1626     into $DST.
1627
1628     @return
1629     This function returns $DST.  */
1630
1631 /***ja
1632     @brief ¥Õ¥§¡¼¥¹¤òÅý¹ç¤¹¤ë.
1633
1634     ´Ø¿ô mface_merge () ¤Ï¡¢¥Õ¥§¡¼¥¹ $SRC ¤Î¥×¥í¥Ñ¥Æ¥£¤ò¥Õ¥§¡¼¥¹ $DST 
1635     ¤ËÅý¹ç¤¹¤ë¡£
1636
1637     @return
1638     ¤³¤Î´Ø¿ô¤Ï $DST ¤òÊÖ¤¹¡£  */
1639
1640 MFace *
1641 mface_merge (MFace *dst, MFace *src)
1642 {
1643   int i;
1644   MPlist *plist;
1645
1646   for (i = 0; i < MFACE_PROPERTY_MAX; i++)
1647     if (src->property[i])
1648       {
1649         if (i == MFACE_FONTSET)
1650           {
1651             M17N_OBJECT_UNREF (dst->property[i]);
1652             M17N_OBJECT_REF (src->property[i]);
1653           }
1654         dst->property[i] = src->property[i];
1655       }
1656
1657   MPLIST_DO (plist, dst->frame_list)
1658     {
1659       MFrame *frame = MPLIST_VAL (plist);
1660
1661       frame->tick++;
1662       if (dst == frame->face)
1663         mface__update_frame_face (frame);
1664     }
1665
1666   return dst;
1667 }
1668
1669 /*=*/
1670
1671 /***en
1672     @brief Make a face from a font.
1673
1674     The mface_from_font () function return a newly created face while
1675     reflecting the properties of $FONT in its properties.   */
1676
1677 /***ja
1678     @brief ¥Õ¥©¥ó¥È¤«¤é¥Õ¥§¡¼¥¹¤òºî¤ë.
1679
1680     ´Ø¿ô mface_from_font () ¤Ï¥Õ¥©¥ó¥È $FONT 
1681     ¤Î¥×¥í¥Ñ¥Æ¥£¤ò¥×¥í¥Ñ¥Æ¥£¤È¤·¤Æ»ý¤Ä¿·¤·¤¤¥Õ¥§¡¼¥¹¤òºî¤ê¡¢¤½¤ì¤òÊÖ¤¹¡£  */
1682
1683 MFace *
1684 mface_from_font (MFont *font)
1685 {
1686   MFace *face = mface ();
1687
1688   face->property[MFACE_FOUNDRY] = mfont_get_prop (font, Mfoundry);
1689   face->property[MFACE_FAMILY] = mfont_get_prop (font, Mfamily);
1690   face->property[MFACE_WEIGHT] = mfont_get_prop (font, Mweight);
1691   face->property[MFACE_STYLE] = mfont_get_prop (font, Mstyle);
1692   face->property[MFACE_STRETCH] = mfont_get_prop (font, Mstretch);
1693   face->property[MFACE_ADSTYLE] = mfont_get_prop (font, Madstyle);
1694   face->property[MFACE_SIZE] = mfont_get_prop (font, Msize);
1695   return face;
1696 }
1697
1698 /*=*/
1699
1700 /***en
1701     @brief Get the value of a face property.
1702
1703     The mface_get_prop () function returns the value of the face
1704     property whose key is $KEY in face $FACE.  $KEY must be one of the
1705     followings:
1706
1707         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1708         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1709         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1710
1711     @return
1712     The actual type of the returned value depends of $KEY.  See
1713     documentation of the above keys.  If an error is detected, it
1714     returns @c NULL and assigns an error code to the external variable
1715     #merror_code.  */
1716
1717 /***ja
1718     @brief ¥Õ¥§¡¼¥¹¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
1719
1720     ´Ø¿ô mface_get_prop () ¤Ï¡¢¥Õ¥§¡¼¥¹ $FACE 
1721     ¤¬»ý¤Ä¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤ÎÆâ¡¢¥­¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤ÎÃͤòÊÖ¤¹¡£
1722     $KEY ¤Ï²¼µ­¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1723
1724         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1725         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1726         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1727
1728     @return 
1729     Ìá¤êÃͤη¿¤Ï $KEY ¤Ë°Í¸¤¹¤ë¡£¾åµ­¤Î¥­¡¼¤ÎÀâÌÀ¤ò»²¾È¤¹¤ë¤³¤È¡£
1730     ¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code 
1731     ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£  */
1732
1733 /***
1734     @seealso
1735     mface_put_prop ()
1736
1737     @errors
1738     @c MERROR_FACE  */
1739
1740 void *
1741 mface_get_prop (MFace *face, MSymbol key)
1742 {
1743   int index = (int) msymbol_get (key, M_face_prop_index) - 1;
1744
1745   if (index < 0)
1746     MERROR (MERROR_FACE, NULL);
1747   return face->property[index];
1748 }
1749
1750 /*=*/
1751
1752 /***en
1753     @brief Set a value of a face property.
1754
1755     The mface_put_prop () function assigns $VAL to the property whose
1756     key is $KEY in face $FACE.  $KEY must be one the followings:
1757
1758         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1759         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1760         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1761
1762     Among them, font related properties (#Mfoundry through #Msize) are
1763     used as the default values when a font in the fontset of $FACE
1764     does not specify those values.
1765
1766     The actual type of the returned value depends of $KEY.  See
1767     documentation of the above keys.
1768
1769     @return
1770     If the operation was successful, mface_put_prop () returns 0.
1771     Otherwise it returns -1 and assigns an error code to the external
1772     variable #merror_code.  */
1773
1774 /***ja
1775     @brief ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
1776
1777     ´Ø¿ô mface_put_prop () ¤Ï¡¢¥Õ¥§¡¼¥¹ $FACE Æâ¤Ç¥­¡¼¤¬ $KEY 
1778     ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤò $VAL ¤ËÀßÄꤹ¤ë¡£$KEY 
1779     ¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1780
1781         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1782         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1783         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg.
1784
1785     ¤³¤ì¤é¤Î¤¦¤Á¤Î¡¢¥Õ¥©¥ó¥È´ØÏ¢¤Î¥×¥í¥Ñ¥Æ¥£ (#Mfamily ¤«¤é #Msize 
1786     ¤Þ¤Ç) ¤Ï¡¢¥Õ¥§¡¼¥¹¤Î¥Õ¥©¥ó¥È¥»¥Ã¥ÈÃæ¤Î¥Õ¥©¥ó¥È¤Ë´Ø¤¹¤ë¥Ç¥Õ¥©¥ë¥ÈÃͤȤʤꡢ¸Ä¡¹¤Î¥Õ¥©¥ó¥È¤¬Ãͤò»ØÄꤷ¤Ê¤«¤Ã¤¿¾ì¹ç¤ËÍѤ¤¤é¤ì¤ë¡£
1787
1788     Ìá¤êÃͤη¿¤Ï $KEY ¤Ë°Í¸¤¹¤ë¡£¾åµ­¤Î¥­¡¼¤ÎÀâÌÀ¤ò»²¾È¤¹¤ë¤³¤È¡£
1789
1790     @return
1791     ½èÍý¤¬À®¸ù¤·¤¿¾ì¹ç¡¢mface_put_prop () ¤Ï 0 ¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï 
1792     -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£  */
1793
1794 /***
1795     @seealso
1796     mface_get_prop ()
1797
1798     @errors
1799     @c MERROR_FACE  */
1800
1801 int
1802 mface_put_prop (MFace *face, MSymbol key, void *val)
1803 {
1804   int index = (int) msymbol_get (key, M_face_prop_index) - 1;
1805   MPlist *plist;
1806
1807   if (index < 0)
1808     MERROR (MERROR_FACE, -1);
1809   if (key == Mfontset)
1810     {
1811       if (face->property[index])
1812         M17N_OBJECT_UNREF (face->property[index]);
1813       M17N_OBJECT_REF (val);
1814     }
1815   else if (key == Mhline)
1816     val = get_hline_create (val);
1817   else if (key == Mbox)
1818     val = get_box_create (val);
1819
1820   if (face->property[index] == val)
1821     return 0;
1822   face->property[index] = val;
1823
1824   MPLIST_DO (plist, face->frame_list)
1825     {
1826       MFrame *frame = MPLIST_VAL (plist);
1827
1828       frame->tick++;
1829       if (face == frame->face)
1830         mface__update_frame_face (frame);
1831     }
1832
1833   return 0;
1834 }
1835
1836 /*=*/
1837
1838 /***en
1839     @brief Update a face.
1840
1841     The mface_update () function update face $FACE on frame $FRAME by
1842     calling a hook function of $FACE (if any).  */
1843
1844 /***ja
1845     @brief ¥Õ¥§¡¼¥¹¤ò¹¹¿·¤¹¤ë.
1846
1847     ´Ø¿ô mface_update () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥Õ¥§¡¼¥¹ $FACE ¤ò $FACE 
1848     ¤Î¥Õ¥Ã¥¯´Ø¿ô¤ò¡Ê¤¢¤ì¤Ð¡Ë¸Æ¤ó¤Ç¹¹¿·¤¹¤ë¡£  */
1849
1850 void
1851 mface_update (MFrame *frame, MFace *face)
1852 {
1853   MFaceHookFunc func = (MFaceHookFunc) face->property[MFACE_HOOK_FUNC];
1854   MPlist *rface_list;
1855   MRealizedFace *rface;
1856
1857   if (func && func != noop_hook)
1858     {
1859       MPLIST_DO (rface_list, frame->realized_face_list)
1860         {
1861           rface = MPLIST_VAL (rface_list);
1862           if ((MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC] == func)
1863             (func) (&(rface->face), rface->face.property[MFACE_HOOK_ARG],
1864                     rface->info);
1865         }
1866     }
1867 }
1868 /*=*/
1869
1870 /*** @} */
1871 /*=*/
1872
1873 /*** @addtogroup m17nDebug */
1874 /*** @{  */
1875 /*=*/
1876
1877 /***en
1878     @brief Dump a face.
1879
1880     The mdebug_dump_face () function prints face $FACE in a human readable
1881     way to the stderr.  $INDENT specifies how many columns to indent
1882     the lines but the first one.
1883
1884     @return
1885     This function returns $FACE.  */
1886
1887 /***ja
1888     @brief ¥Õ¥§¡¼¥¹¤ò¥À¥ó¥×¤¹¤ë.
1889
1890     ´Ø¿ô mdebug_dump_face () ¤Ï¥Õ¥§¡¼¥¹ $FACE ¤ò stderr 
1891     ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
1892
1893     @return
1894     ¤³¤Î´Ø¿ô¤Ï $FACE ¤òÊÖ¤¹¡£  */
1895
1896 MFace *
1897 mdebug_dump_face (MFace *face, int indent)
1898 {
1899   char *prefix = (char *) alloca (indent + 1);
1900   MFont spec;
1901
1902   memset (prefix, 32, indent);
1903   prefix[indent] = 0;
1904   mfont__set_spec_from_face (&spec, face);
1905   fprintf (stderr, "(face font:\"");
1906   mdebug_dump_font (&spec);
1907   fprintf (stderr, "\"\n %s  fore:%s back:%s", prefix,
1908            msymbol_name ((MSymbol) face->property[MFACE_FOREGROUND]),
1909            msymbol_name ((MSymbol) face->property[MFACE_BACKGROUND]));
1910   if (face->property[MFACE_FONTSET])
1911     fprintf (stderr, " non-default-fontset");
1912   fprintf (stderr, " hline:%s", face->property[MFACE_HLINE] ? "yes" : "no");
1913   fprintf (stderr, " box:%s)", face->property[MFACE_BOX] ? "yes" : "no");
1914   return face;
1915 }
1916
1917 /*** @} */
1918
1919 /*
1920   Local Variables:
1921   coding: euc-japan
1922   End:
1923 */