(mface__realize): Set rfont->layouter to Mnil.
[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   int i, j;
608   MFaceHookFunc func;
609   MFont spec;
610
611   if (num == 0 && frame->rface && ! font)
612     return frame->rface;
613
614   if (! mplist_find_by_value (frame->face->frame_list, frame))
615     mplist_push (frame->face->frame_list, Mt, frame);
616   for (i = 0; i < num; i++)
617     if (! mplist_find_by_value (faces[i]->frame_list, frame))
618       mplist_push (faces[i]->frame_list, Mt, frame);
619
620   for (i = 0; i < MFACE_PROPERTY_MAX; i++)
621     for (j = num - 1; j >= 0; j--)
622       if (faces[j]->property[i])
623         {
624           merged_face.property[i] = faces[j]->property[i];
625           break;
626         }
627
628   if (font)
629     {
630       if (font->type != MFONT_TYPE_REALIZED)
631         font = mfont_copy (font);
632       for (i = 0; i <= MFACE_ADSTYLE; i++)
633         if (font->property[i])
634           merged_face.property[i] = FONT_PROPERTY (font, i);
635       if (font->size)
636         {
637           if (font->size < 0)
638             font->size = ((double) (- font->size)) * frame->dpi / 72.27 + 0.5;
639           merged_face.property[MFACE_SIZE] = (void *) font->size;
640           merged_face.property[MFACE_RATIO] = (void *) 0;
641         }
642     }
643
644   if (! font || ! font->size)
645     {
646       double font_size = (int) merged_face.property[MFACE_SIZE];
647       int ifont_size;
648
649       if (font_size < 0)
650         font_size = - font_size * frame->dpi / 72.27;
651       if (merged_face.property[MFACE_RATIO]
652           && (int) merged_face.property[MFACE_RATIO] != 100)
653         {
654           font_size *= (int) merged_face.property[MFACE_RATIO];
655           font_size /= 100;
656         }
657       ifont_size = font_size + 0.5;
658       merged_face.property[MFACE_SIZE] = (void *) ifont_size;
659       merged_face.property[MFACE_RATIO] = (void *) 0;
660     }
661
662   merged_face.property[MFACE_FOUNDRY] = Mnil;
663   rface = find_realized_face (frame, &merged_face, font);
664   if (rface)
665     {
666       if (font && font->type != MFONT_TYPE_REALIZED)
667         free (font);
668       return rface;
669     }
670
671   MSTRUCT_CALLOC (rface, MERROR_FACE);
672   mplist_push (frame->realized_face_list, Mt, rface);
673   rface->frame = frame;
674   rface->face = merged_face;
675   rface->font = font;
676
677   if (font)
678     {
679       if (font->type == MFONT_TYPE_SPEC)
680         rfont = (MRealizedFont *) mfont_find (frame, font, NULL, 0);
681       else if (font->type == MFONT_TYPE_OBJECT)
682         {
683           MFONT_INIT (&spec);
684           spec.size = (int) merged_face.property[MFONT_SIZE];
685           if (font->property[MFONT_REGISTRY])
686             spec.property[MFONT_REGISTRY] = font->property[MFONT_REGISTRY];
687           else
688             mfont_put_prop (&spec, Mregistry,
689                             (font->source == MFONT_SOURCE_X
690                              ? Miso8859_1 : Municode_bmp));
691           rfont = mfont__open (frame, font, &spec);
692         }
693       else
694         rfont = (MRealizedFont *) font;
695     }
696   else
697     {
698       MFontset *fontset = (MFontset *) merged_face.property[MFACE_FONTSET];
699
700       rface->rfontset = mfont__realize_fontset (frame, fontset, &merged_face,
701                                                 font);
702       rfont = NULL;
703       mfont__set_spec_from_face (&spec, &merged_face);
704       mfont_put_prop (&spec, Mregistry, Miso8859_1);
705       spec.source = MFONT_SOURCE_X;
706       font = mfont__select (frame, &spec, 0);
707       if (font)
708         rfont = mfont__open (frame, font, &spec);
709       if (! rfont)
710         {
711           mfont_put_prop (&spec, Mregistry, Municode_bmp);
712           spec.source = MFONT_SOURCE_FT;
713           font = mfont__select (frame, &spec, 0);
714           if (font)
715             rfont = mfont__open (frame, font, &spec);
716         }
717       if (! rfont)
718         {
719           num = 0;
720           rfont = mfont__lookup_fontset (rface->rfontset, NULL, &num,
721                                          Mlatin, Mnil, Mnil, size, 0);
722         }
723     }
724
725   if (rfont)
726     {
727       rface->rfont = rfont;
728       rface->layouter = rfont->layouter;
729       rfont->layouter = Mnil;
730       work_gstring.glyphs[0].rface = rface;
731       work_gstring.glyphs[0].code = MCHAR_INVALID_CODE;
732       mfont__get_metric (&work_gstring, 0, 1);
733       rface->ascent = work_gstring.glyphs[0].ascent;
734       rface->descent = work_gstring.glyphs[0].descent;
735       work_gstring.glyphs[0].code
736         = mfont__encode_char (frame, (MFont *) rfont, NULL, ' ');
737       if (work_gstring.glyphs[0].code != MCHAR_INVALID_CODE)
738         {
739           mfont__get_metric (&work_gstring, 0, 1);
740           rface->space_width = work_gstring.glyphs[0].width;
741         }
742       else
743         rface->space_width = rfont->spec.size / 10;
744       if (rfont->average_width)
745         rface->average_width = rfont->average_width;
746       else
747         {
748           work_gstring.glyphs[0].code
749             = mfont__encode_char (frame, (MFont *) rfont, NULL, 'x');
750           if (work_gstring.glyphs[0].code != MCHAR_INVALID_CODE)
751             {
752               mfont__get_metric (&work_gstring, 0, 1);
753               rface->average_width = work_gstring.glyphs[0].width;
754             }
755           else
756             rface->average_width = rface->space_width;
757         }
758     }
759   else
760     {
761       rface->rfont = NULL;
762       rface->space_width = frame->space_width;
763     }
764
765   rface->hline = (MFaceHLineProp *) merged_face.property[MFACE_HLINE];
766   if (rface->hline && rface->hline->width == 0)
767     rface->hline = NULL;
768   rface->box = (MFaceBoxProp *) merged_face.property[MFACE_BOX];
769   if (rface->box && rface->box->width == 0)
770     rface->box = NULL;
771   rface->ascii_rface = rface;
772   (*frame->driver->realize_face) (rface);
773
774   func = (MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC];
775   if (func && func != noop_hook)
776     (func) (&(rface->face), rface->info, rface->face.property[MFACE_HOOK_ARG]);
777
778   rface->non_ascii_list = mplist ();
779   if (rface->rfont)
780     {
781       MRealizedFace *nofont;
782
783       MSTRUCT_CALLOC (nofont, MERROR_FACE);
784       *nofont = *rface;
785       nofont->non_ascii_list = NULL;
786       nofont->rfont = NULL;
787       mplist_add (rface->non_ascii_list, Mt, nofont);
788     }
789
790   return rface;
791 }
792
793
794 MGlyph *
795 mface__for_chars (MSymbol script, MSymbol language, MSymbol charset,
796                   MGlyph *from_g, MGlyph *to_g, int size)
797 {
798   MRealizedFont *rfont = from_g->rface->rfont;
799   MSymbol layouter;
800   int num = to_g - from_g;
801   int i;
802
803   if (from_g->rface->font)
804     {
805       MRealizedFace *rface = from_g->rface, *new;
806
807       if (! rfont)
808         rfont = mfontset__get_font (rface->frame,
809                                     rface->face.property[MFACE_FONTSET], 
810                                     script, language,
811                                     rface->font, NULL);
812       else if (script != Mlatin)
813         rfont = mfontset__get_font (rface->frame,
814                                     rface->face.property[MFACE_FONTSET],
815                                     script, language,
816                                     (MFont *) rfont, NULL);
817       if (! rfont)
818         {
819           for (; from_g < to_g && from_g->rface->font; from_g++)
820             from_g->code = MCHAR_INVALID_CODE;
821         }
822       else
823         {
824           if (rface->rfont == rfont && rfont->layouter == Mnil)
825             new = rface;
826           else
827             {
828               MSTRUCT_MALLOC (new, MERROR_FACE);
829               mplist_push (rface->non_ascii_list, Mt, new);
830               *new = *rface;
831               new->rfont = rfont;
832               new->layouter = rfont->layouter;
833               rfont->layouter = Mnil;
834               new->non_ascii_list = NULL;
835               new->ascent = rfont->ascent;
836               new->descent = rfont->descent;
837             } 
838           for (; from_g < to_g && from_g->rface->font; from_g++)
839             {
840               from_g->rface = new;
841               from_g->code
842                 = (new->layouter
843                    ? mfont__flt_encode_char (new->layouter, from_g->c)
844                    : mfont__encode_char (rfont->frame, (MFont *) rfont, NULL,
845                                          from_g->c));
846             }
847         }
848       return from_g;
849     }
850
851   if (rfont && script == Mlatin)
852     {
853       for (i = 0; i < num; i++)
854         {
855           unsigned code = mfont__encode_char (rfont->frame, (MFont *) rfont,
856                                               NULL, from_g[i].c);
857           if (code == MCHAR_INVALID_CODE)
858             break;
859           from_g[i].code = code;
860         }
861       if (i == num || from_g[i].rface->font)
862         return from_g + i;
863     }
864
865   rfont = mfont__lookup_fontset (from_g->rface->rfontset, from_g, &num,
866                                  script, language, charset, size, 0);
867   if (rfont)
868     {
869       layouter = rfont->layouter;
870       rfont->layouter = Mnil;
871     }
872   else
873     {
874       from_g->code = MCHAR_INVALID_CODE;
875       num = 1;
876       rfont = NULL;
877       layouter = Mnil;
878     }
879   
880   to_g = from_g + num;
881   while (from_g < to_g)
882     {
883       MGlyph *g = from_g;
884       MRealizedFace *rface = from_g++->rface;
885
886       while (from_g < to_g && rface == from_g->rface) from_g++;
887       if (rface->rfont != rfont
888           || rface->layouter != layouter)
889         {
890           MPlist *plist = mplist_find_by_value (rface->non_ascii_list, rfont);
891           MRealizedFace *new = NULL;
892
893           while (plist)
894             {
895               new = MPLIST_VAL (plist);
896               if (new->layouter == layouter)
897                 break;
898               plist = mplist_find_by_value (MPLIST_NEXT (plist), rfont);
899             }
900           if (! plist)
901             {
902               MSTRUCT_MALLOC (new, MERROR_FACE);
903               mplist_push (rface->non_ascii_list, Mt, new);
904               *new = *rface;
905               new->rfont = rfont;
906               new->layouter = layouter;
907               new->non_ascii_list = NULL;
908               if (rfont)
909                 {
910                   new->ascent = rfont->ascent;
911                   new->descent = rfont->descent;
912                 }
913             }
914           while (g < from_g)
915             g++->rface = new;
916         }
917     }
918   return to_g;
919 }
920
921
922 void
923 mface__free_realized (MRealizedFace *rface)
924 {
925   MPlist *plist;
926
927   MPLIST_DO (plist, rface->non_ascii_list)
928     free (MPLIST_VAL (plist));
929   M17N_OBJECT_UNREF (rface->non_ascii_list);
930   if (rface->font)
931     free (rface->font);
932   free (rface);
933 }
934
935 void
936 mface__update_frame_face (MFrame *frame)
937 {
938   frame->rface = NULL;
939   frame->rface = mface__realize (frame, NULL, 0, 0, NULL);
940   frame->space_width = frame->rface->space_width;
941   frame->average_width = frame->rface->average_width;
942   frame->ascent = frame->rface->ascent;
943   frame->descent = frame->rface->descent;
944 }
945
946 /*** @} */
947 #endif /* !FOR_DOXYGEN || DOXYGEN_INTERNAL_MODULE */
948
949 \f
950 /* External API  */
951 /*** @addtogroup m17nFace */
952 /*** @{ */
953 /*=*/
954
955 /***en @name Variables: Keys of face property */
956 /***ja @name ÊÑ¿ô: ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼  */
957 /*** @{ */
958 /*=*/
959
960 /***en
961     @brief Key of a face property specifying foreground color.
962
963     The variable #Mforeground is used as a key of face property.  The
964     property value must be a symbol whose name is a color name, or
965     #Mnil.
966
967     #Mnil means that the face does not specify a foreground color.
968     Otherwise, the foreground of an M-text is drawn by the specified
969     color.  */
970 /***ja
971     @brief Á°·Ê¿§¤ò»ØÄꤹ¤ë¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
972
973     ÊÑ¿ô #Mforeground ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
974     ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¿§Ì¾¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë¤« #Mnil ¤Ç¤¢¤ë¡£
975
976     #Mnil ¤Î¾ì¹ç¡¢Á°·Ê¿§¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð M-text 
977     ¤ÎÁ°·Ê¤Ï»ØÄꤵ¤ì¤¿¿§¤Çɽ¼¨¤µ¤ì¤ë¡£  */
978
979 MSymbol Mforeground;
980
981 /***en
982     @brief Key of a face property specifying background color.
983
984     The variable #Mbackground is used as a key of face property.  The
985     property value must be a symbol whose name is a color name, or
986     #Mnil.
987
988     #Mnil means that the face does not specify a background color.
989     Otherwise, the background of an M-text is drawn by the specified
990     color.  */
991 /***ja
992     @brief ÇØ·Ê¿§¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
993
994     ÊÑ¿ô #Mbackground ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
995     ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢¿§Ì¾¤ò̾Á°¤È¤·¤Æ»ý¤Ä¥·¥ó¥Ü¥ë¤« #Mnil ¤Ç¤¢¤ë¡£
996
997     #Mnil ¤Î¾ì¹ç¡¢ÇØ·Ê¿§¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð M-text 
998     ¤ÎÇطʤϻØÄꤵ¤ì¤¿¿§¤Çɽ¼¨¤µ¤ì¤ë¡£  */
999
1000 MSymbol Mbackground;
1001
1002 /***en
1003     @brief Key of a face property specifying video mode.
1004
1005     The variable #Mvideomode is used as a key of face property.  The
1006     property value must be #Mnormal, #Mreverse, or #Mnil.
1007
1008     #Mnormal means that an M-text is drawn in normal video mode
1009     (i.e. the foreground is drawn by foreground color, the background
1010     is drawn by background color).
1011
1012     #Mreverse means that an M-text is drawn in reverse video mode
1013     (i.e. the foreground is drawn by background color, the background
1014     is drawn by foreground color).
1015
1016     #Mnil means that the face does not specify a video mode.  */
1017 /***ja
1018     @brief ¥Ó¥Ç¥ª¥â¡¼¥É¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1019
1020     ÊÑ¿ô #Mvideomode ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£¥×¥í¥Ñ¥Æ¥£¤ÎÃͤϡ¢
1021     #Mnormal, #Mreverse, #Mnil ¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1022
1023     #Mnormal ¤Î¾ì¹ç¤Ï¡¢M-text 
1024     ¤òɸ½à¤Î¥Ó¥Ç¥ª¥â¡¼¥É¡ÊÁ°·Ê¤òÁ°·Ê¿§¤Ç¡¢ÇطʤòÇØ·Ê¿§¤Ç¡Ë¤Çɽ¼¨¤¹¤ë¡£
1025
1026     #Mreverse ¤Î¾ì¹ç¤Ï¥ê¥Ð¡¼¥¹¥Ó¥Ç¥ª¥â¡¼¥É¤Ç¡ÊÁ°·Ê¤òÇØ·Ê¿§¤Ç¡¢ÇطʤòÁ°·Ê¿§¤Ç¡Ëɽ¼¨¤¹¤ë¡£
1027
1028     #Mnil ¤Î¾ì¹ç¤Ï¥Ó¥Ç¥ª¥â¡¼¥É¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1029     */
1030
1031 MSymbol Mvideomode;
1032
1033 /***en
1034     @brief Key of a face property specifying font size ratio.
1035
1036     The variable #Mratio is used as a key of face property.  The value
1037     RATIO must be an integer.
1038
1039     The value 0 means that the face does not specify a font size
1040     ratio.  Otherwise, an M-text is drawn by a font of size (FONTSIZE
1041     * RATIO / 100) where FONTSIZE is a font size specified by the face
1042     property #Msize.  */
1043 /***ja
1044     @brief ¥Õ¥©¥ó¥È¤Î¥µ¥¤¥º¤ÎÈæΨ¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1045
1046     ÊÑ¿ô #Mratio ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃÍ RATIO 
1047     ¤ÏÀ°¿ôÃͤǤʤ¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1048
1049     Ãͤ¬0¤Ê¤é¤Ð¡¢¥Õ¥©¥ó¥È¥µ¥¤¥º¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢M-text 
1050     ¤Ï(FONTSIZE * RATIO / 100) ¤È¤¤¤¦¥µ¥¤¥º¤Î¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£
1051     FONTSIZE ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼#Msize ¤Ç»ØÄꤵ¤ì¤¿¥µ¥¤¥º¤Ç¤¢¤ë¡£ */
1052
1053 MSymbol Mratio;
1054
1055 /***en
1056     @brief Key of a face property specifying horizontal line.
1057
1058     The variable #Mhline is used as a key of face property.  The value
1059     must be a pointer to an object of type #MFaceHLineProp, or @c
1060     NULL.
1061
1062     The value @c NULL means that the face does not specify this
1063     property.  Otherwise, an M-text is drawn with a horizontal line by
1064     a way specified by the object that the value points to.  */
1065 /***ja
1066     @brief ¿åÊ¿Àþ¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1067
1068     ÊÑ¿ô #Mhline ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1069     #MFaceHLineProp ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1070
1071     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¤³¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1072     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¤è¤¦¤Ë¿åÊ¿Àþ¤òÉղ䷤ƠM-text 
1073     ¤òɽ¼¨¤¹¤ë¡£*/
1074
1075 MSymbol Mhline;
1076
1077 /***en
1078     @brief Key of a face property specifying box.
1079
1080     The variable #Mbox is used as a key of face property.  The value
1081     must be a pointer to an object of type #MFaceBoxProp, or @c NULL.
1082
1083     The value @c NULL means that the face does not specify a box.
1084     Otherwise, an M-text is drawn with a surrounding box by a way
1085     specified by the object that the value points to.  */
1086 /***ja
1087     @brief °Ï¤ßÏȤò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1088
1089     ÊÑ¿ô #Mbox ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1090     #MFaceBoxProp ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1091
1092     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¤³¤Î¥Õ¥§¡¼¥¹¤Ï°Ï¤ßÏȤò»ØÄꤷ¤Æ¤¤¤Ê¤¤¡£
1093     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¤è¤¦¤Ë°Ï¤ßÏȤòÉղ䷤Ơ
1094     M-text ¤òɽ¼¨¤¹¤ë¡£*/
1095
1096 MSymbol Mbox;
1097
1098 /***en
1099     @brief Key of a face property specifying fontset.
1100
1101     The variable #Mfontset is used as a key of face property.  The
1102     value must be a pointer to an object of type #Mfontset, or @c
1103     NULL.
1104
1105     The value @c NULL means that the face does not specify a fontset.
1106     Otherwise, an M-text is drawn with a font selected from what
1107     specified in the fontset.  */
1108 /***ja
1109     @brief ¥Õ¥©¥ó¥È¥»¥Ã¥È¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1110
1111     ÊÑ¿ô #Mfontset ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1112     #Mfontset ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1113
1114     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¥Õ¥©¥ó¥È¥»¥Ã¥È¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1115     ¤½¤¦¤Ç¤Ê¤±¤ì¤ÐÃͤ¬»Ø¤¹¥ª¥Ö¥¸¥§¥¯¥È¤Ë»ØÄꤵ¤ì¤¿¥Õ¥©¥ó¥È¥»¥Ã¥È¤«¤éÁª¤ó¤À¥Õ¥©¥ó¥È¤Ç 
1116     M-text ¤òɽ¼¨¤¹¤ë¡£*/
1117     
1118 MSymbol Mfontset;
1119
1120 /***en
1121     @brief Key of a face property specifying hook.
1122
1123     The variable #Mhook_func is used as a key of face property.  The
1124     value must be a function of type #MFaceHookFunc, or @c NULL.
1125
1126     The value @c NULL means that the face does not specify a hook.
1127     Otherwise, the specified function is called before the face is
1128     realized.  */
1129 /***ja
1130     @brief ¥Õ¥Ã¥¯¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1131
1132     ÊÑ¿ô #Mhook_func ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£ÃͤϠ
1133     #MFaceHookFunc ·¿¤Î´Ø¿ô¤« @c NULL ¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1134
1135     Ãͤ¬ @c NULL ¤Ê¤é¤Ð¡¢¥Õ¥Ã¥¯¤Ï»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
1136     ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¥Õ¥§¡¼¥¹¤ò¼Â¸½¤¹¤ëÁ°¤Ë»ØÄꤵ¤ì¤¿´Ø¿ô¤¬¸Æ¤Ð¤ì¤ë¡£      */
1137 MSymbol Mhook_func;
1138
1139 /***en
1140     @brief Key of a face property specifying argument of hook.
1141
1142     The variable #Mhook_arg is used as a key of face property.  The
1143     value can be anything that is passed a hook function specified by
1144     the face property #Mhook_func.  */
1145 /***ja
1146     @brief ¥Õ¥Ã¥¯¤Î°ú¿ô¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¡¼¤Î¥­¡¼.
1147
1148     ÊÑ¿ô #Mhook_arg ¤Ï¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼¤È¤·¤ÆÍѤ¤¤é¤ì¤ë¡£
1149     Ãͤϲ¿¤Ç¤â¤è¤¯¡¢¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£ #Mhook_func ¤Ç»ØÄꤵ¤ì¤ë´Ø¿ô¤ËÅϤµ¤ì¤ë¡£ */
1150 MSymbol Mhook_arg;
1151
1152 /*** @} */
1153 /*=*/
1154
1155 /*** @ingroup m17nFace */
1156 /***en @name Variables: Possible values of #Mvideomode property of face */
1157 /***ja @name ÊÑ¿ô¡§  ¥Õ¥§¡¼¥¹¤Î #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤Î²Äǽ¤ÊÃÍ */
1158 /*** @{ */
1159 /*=*/
1160
1161 /***en
1162     See the documentation of the variable #Mvideomode.  */ 
1163 /***ja
1164     ÊÑ¿ô #Mvideomode ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£  */ 
1165 MSymbol Mnormal;
1166 MSymbol Mreverse;
1167 /*** @} */
1168 /*=*/
1169
1170 /*** @ingroup m17nFace */
1171 /***en @name Variables: Predefined faces  */
1172 /***ja @name ÊÑ¿ô: ÄêµÁºÑ¤ß¥Õ¥§¡¼¥¹  */
1173 /*** @{ */
1174 /*=*/
1175
1176 /***en
1177     @brief Normal video face.
1178
1179     The variable #mface_normal_video points to a face that has the
1180     #Mvideomode property with value #Mnormal.  The other properties
1181     are not specified.  An M-text drawn with this face appear normal
1182     colors (i.e. the foreground is drawn by foreground color, and
1183     background is drawn by background color).  */
1184 /***ja
1185     @brief É¸½à¥Ó¥Ç¥ª¥Õ¥§¡¼¥¹.
1186
1187     ÊÑ¿ô #mface_normal_video ¤Ï #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ #Mnormal 
1188     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1189     ¤³¤Î¥Õ¥§¡¼¥¹¤Çɽ¼¨¤µ¤ì¤ëM-text 
1190     ¤Ïɸ½à¤Î¿§ (¤¹¤Ê¤ï¤ÁÁ°·Ê¤ÏÁ°·Ê¿§¡¢ÇطʤÏÇØ·Ê¿§¡Ë¤ÇÉÁ¤«¤ì¤ë¡£  */
1191
1192 MFace *mface_normal_video;
1193
1194 /***en
1195     @brief Reverse video face.
1196
1197     The variable #mface_reverse_video points to a face that has the
1198     #Mvideomode property with value #Mreverse.  The other properties
1199     are not specified.  An M-text drawn with this face appear in
1200     reversed colors (i.e. the foreground is drawn by background
1201     color, and background is drawn by foreground color).  */
1202 /***ja
1203     @brief ¥ê¥Ð¡¼¥¹¥Ó¥Ç¥ª¥Õ¥§¡¼¥¹.
1204
1205     ÊÑ¿ô #mface_reverse_video ¤Ï #Mvideomode ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 
1206     #Mreverse ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1207     ¤³¤Î¥Õ¥§¡¼¥¹¤Çɽ¼¨¤µ¤ì¤ëM-text 
1208     ¤ÏÁ°·Ê¿§¤ÈÇØ·Ê¿§¤¬Æþ¤ìÂؤï¤Ã¤Æ (¤¹¤Ê¤ï¤ÁÁ°·Ê¤ÏÇØ·Ê¿§¡¢ÇطʤÏÁ°·Ê¿§¡ËÉÁ¤«¤ì¤ë¡£  */
1209
1210 MFace *mface_reverse_video;
1211
1212 /***en
1213     @brief Underline face.
1214
1215     The variable #mface_underline points to a face that has the
1216     #Mhline property with value a pointer to an object of type
1217     #MFaceHLineProp.  The members of the object are as follows:
1218
1219 @verbatim
1220     member  value
1221     -----   -----
1222     type    MFACE_HLINE_UNDER
1223     width   1
1224     color   Mnil
1225 @endverbatim
1226
1227     The other properties are not specified.  An M-text that has this
1228     face is drawn with an underline.  */ 
1229 /***ja
1230     @brief ²¼Àþ¥Õ¥§¡¼¥¹.
1231
1232     ÊÑ¿ô #mface_underline ¤Ï #Mhline ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ #MFaceHLineProp 
1233     ·¿¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£¥ª¥Ö¥¸¥§¥¯¥È¤Î¥á¥ó¥Ð¤Ï°Ê²¼¤ÎÄ̤ꡣ
1234
1235 @verbatim
1236     ¥á¥ó¥Ð  ÃÍ
1237     -----   -----
1238     type    MFACE_HLINE_UNDER
1239     width   1
1240     color   Mnil
1241 @endverbatim
1242
1243     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ï²¼ÀþÉÕ¤­¤Çɽ¼¨¤µ¤ì¤ë¡£*/ 
1244
1245 MFace *mface_underline;
1246
1247 /***en
1248     @brief Medium face.
1249
1250     The variable #mface_medium points to a face that has the #Mweight
1251     property with value a symbol of name "medium".  The other
1252     properties are not specified.  An M-text that has this face is
1253     drawn with a font of medium weight.  */
1254 /***ja
1255     @brief ¥ß¥Ç¥£¥¢¥à¥Õ¥§¡¼¥¹.
1256
1257     ÊÑ¿ô #mface_medium ¤Ï #Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "medium" 
1258     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1259     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text
1260     ¤Ï¡¢¥ß¥Ç¥£¥¢¥à¥¦¥§¥¤¥È¤Î¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£  */
1261 MFace *mface_medium;
1262
1263 /***en
1264     @brief Bold face.
1265
1266     The variable #mface_bold points to a face that has the #Mweight
1267     property with value a symbol of name "bold".  The other properties
1268     are not specified.  An M-text that has this face is drawn with a
1269     font of bold weight.  */
1270 /***ja
1271     @brief ¥Ü¡¼¥ë¥É¥Õ¥§¡¼¥¹.
1272
1273     ÊÑ¿ô #mface_bold ¤Ï #Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "bold" 
1274     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1275     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1276     ¤Ï¡¢¥Ü¡¼¥ë¥É¥Õ¥©¥ó¥È¤Çɽ¼¨¤µ¤ì¤ë¡£    */
1277
1278 MFace *mface_bold;
1279
1280 /***en
1281     @brief Italic face.
1282
1283     The variable #mface_italic points to a face that has the #Mstyle
1284     property with value a symbol of name "italic".  The other
1285     properties are not specified.  An M-text that has this face is
1286     drawn with a font of italic style.  */
1287 /***ja
1288     @brief ¥¤¥¿¥ê¥Ã¥¯¥Õ¥§¡¼¥¹.
1289
1290     ÊÑ¿ô #mface_italic ¤Ï #Mstyle ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "italic" 
1291     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1292     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text
1293     ¤Ï¡¢¥¤¥¿¥ê¥Ã¥¯ÂΤÇɽ¼¨¤µ¤ì¤ë¡£    */
1294
1295 MFace *mface_italic;
1296
1297 /***en
1298     @brief Bold italic face.
1299
1300     The variable #mface_bold_italic points to a face that has the
1301     #Mweight property with value a symbol of name "bold", and #Mstyle
1302     property with value a symbol of name "italic".  The other
1303     properties are not specified.  An M-text that has this face is
1304     drawn with a font of bold weight and italic style.  */
1305 /***ja
1306     @brief ¥Ü¡¼¥ë¥É¥¤¥¿¥ê¥Ã¥¯¥Õ¥§¡¼¥¹.
1307
1308     ÊÑ¿ô #mface_bold_italic ¤Ï¡¢#Mweight ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "bold" 
1309     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ê¡¢¤«¤Ä #Mstyle ¥×¥í¥Ñ¥Æ¥¤¤ÎÃͤ¬ "italic" 
1310     ¤È¤¤¤¦Ì¾Á°¤ò¤â¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1311     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1312     ¤Ï¡¢¥Ü¡¼¥ë¥É¥¤¥¿¥ê¥Ã¥¯ÂΤÇɽ¼¨¤µ¤ì¤ë¡£    */
1313
1314 MFace *mface_bold_italic;
1315
1316 /***en
1317     @brief Smallest face.
1318
1319     The variable #mface_xx_small points to a face that has the #Mratio
1320     property with value 50.  The other properties are not specified.
1321     An M-text that has this face is drawn with a font whose size is
1322     50% of a normal font.  */
1323 /***ja
1324     @brief ºÇ¾®¤Î¥Õ¥§¡¼¥¹.
1325
1326     ÊÑ¿ô #mface_xx_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 50 
1327     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1328     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 50% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1329      */
1330
1331 MFace *mface_xx_small;
1332
1333 /***en
1334     @brief Smaller face.
1335
1336     The variable #mface_x_small points to a face that has the #Mratio
1337     property with value 66.  The other properties are not specified.
1338     An M-text that has this face is drawn with a font whose size is
1339     66% of a normal font.  */
1340 /***ja
1341     @brief ¤è¤ê¾®¤µ¤¤¥Õ¥§¡¼¥¹.
1342
1343     ÊÑ¿ô #mface_x_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 66 
1344     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1345     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 66% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1346      */
1347
1348 MFace *mface_x_small;
1349
1350 /***en
1351     @brief Small face.
1352
1353     The variable #mface_x_small points to a face that has the #Mratio
1354     property with value 75.  The other properties are not specified.
1355     An M-text that has this face is drawn with a font whose size is
1356     75% of a normal font.  */
1357 /***ja
1358     @brief ¾®¤µ¤¤¥Õ¥§¡¼¥¹.
1359
1360     ÊÑ¿ô #mface_small ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 75 
1361     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1362     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 75% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1363      */
1364
1365 MFace *mface_small;
1366
1367 /***en
1368     @brief Normalsize face.
1369
1370     The variable #mface_normalsize points to a face that has the
1371     #Mratio property with value 100.  The other properties are not
1372     specified.  An M-text that has this face is drawn with a font
1373     whose size is the same as a normal font.  */
1374 /***ja
1375     @brief É¸½à¤ÎÂ礭¤µ¤Î¥Õ¥§¡¼¥¹.
1376
1377     ÊÑ¿ô #mface_normalsize ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 100 
1378     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1379     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤ÈƱ¤¸Â礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1380      */
1381
1382 MFace *mface_normalsize;
1383
1384 /***en
1385     @brief Large face.
1386
1387     The variable #mface_large points to a face that has the #Mratio
1388     property with value 120.  The other properties are not specified.
1389     An M-text that has this face is drawn with a font whose size is
1390     120% of a normal font.  */
1391 /***ja
1392     @brief Â礭¤¤¥Õ¥§¡¼¥¹.
1393
1394     ÊÑ¿ô #mface_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 120 
1395     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1396     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 120% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1397      */
1398
1399 MFace *mface_large;
1400
1401 /***en
1402     @brief Larger face.
1403
1404     The variable #mface_x_large points to a face that has the #Mratio
1405     property with value 150.  The other properties are not specified.
1406     An M-text that has this face is drawn with a font whose size is
1407     150% of a normal font.  */
1408 /***ja
1409     @brief ¤â¤Ã¤ÈÂ礭¤¤¥Õ¥§¡¼¥¹.
1410
1411     ÊÑ¿ô #mface_x_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 150 
1412     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1413     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 150% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1414      */
1415
1416 MFace *mface_x_large;
1417
1418 /***en
1419     @brief Largest face.
1420
1421     The variable #mface_xx_large points to a face that has the #Mratio
1422     property with value 200.  The other properties are not specified.
1423     An M-text that has this face is drawn with a font whose size is
1424     200% of a normal font.  */
1425 /***ja
1426     @brief ºÇÂç¤Î¥Õ¥§¡¼¥¹.
1427
1428     ÊÑ¿ô #mface_xx_large ¤Ï¡¢#Mratio ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤ¬ 200 
1429     ¤Ç¤¢¤ë¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£
1430     ¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text ¤Ïɸ½à¥Õ¥©¥ó¥È¤Î 200% ¤ÎÂ礭¤µ¤Î¥Õ¥©¥ó¥È¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£
1431      */
1432
1433 MFace *mface_xx_large;
1434
1435 /***en
1436     @brief Black face.
1437
1438     The variable #mface_black points to a face that has the
1439     #Mforeground property with value a symbol of name "black".  The
1440     other properties are not specified.  An M-text that has this face
1441     is drawn with black foreground.  */
1442 /***ja 
1443     @brief ¹õ¥Õ¥§¡¼¥¹.
1444
1445     ÊÑ¿ô #mface_black ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "black" 
1446     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1447     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1448     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¹õ¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£     */
1449
1450 MFace *mface_black;
1451
1452 /***en
1453     @brief White face.
1454
1455     The variable #mface_white points to a face that has the
1456     #Mforeground property with value a symbol of name "white".  The
1457     other properties are not specified.  An M-text that has this face
1458     is drawn with white foreground.  */
1459 /***ja
1460     @brief Çò¥Õ¥§¡¼¥¹.
1461
1462     ÊÑ¿ô #mface_white ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "white" 
1463     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1464     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1465     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÇò¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£     */
1466
1467 MFace *mface_white;
1468
1469 /***en
1470     @brief Red face.
1471
1472     The variable #mface_red points to a face that has the
1473     #Mforeground property with value a symbol of name "red".  The
1474     other properties are not specified.  An M-text that has this face
1475     is drawn with red foreground.  */
1476 /***ja
1477     @brief ÀÖ¥Õ¥§¡¼¥¹.
1478
1479     ÊÑ¿ô #mface_red ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "red" 
1480     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1481     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1482     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÀÖ¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1483
1484 MFace *mface_red;
1485
1486 /***en
1487     @brief Green face.
1488
1489     The variable #mface_green points to a face that has the
1490     #Mforeground property with value a symbol of name "green".  The
1491     other properties are not specified.  An M-text that has this face
1492     is drawn with green foreground.  */
1493 /***ja
1494     @brief ÎÐ¥Õ¥§¡¼¥¹.
1495
1496     ÊÑ¿ô #mface_green ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "green" 
1497     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1498     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1499     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÎФòÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1500
1501 MFace *mface_green;
1502
1503 /***en
1504     @brief Blue face.
1505
1506     The variable #mface_blue points to a face that has the
1507     #Mforeground property with value a symbol of name "blue".  The
1508     other properties are not specified.  An M-text that has this face
1509     is drawn with blue foreground.  */
1510 /***ja
1511     @brief ÀÄ¥Õ¥§¡¼¥¹.
1512
1513     ÊÑ¿ô #mface_blue ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "blue" 
1514     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1515     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1516     ¤ÏÁ°·Ê¿§¤È¤·¤ÆÀĤòÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1517
1518 MFace *mface_blue;
1519
1520 /***en
1521     @brief Cyan face.
1522
1523     The variable #mface_cyan points to a face that has the
1524     #Mforeground property with value a symbol of name "cyan".  The
1525     other properties are not specified.  An M-text that has this face
1526     is drawn with cyan foreground.  */
1527 /***ja
1528     @brief ¥·¥¢¥ó¥Õ¥§¡¼¥¹.
1529
1530     ÊÑ¿ô #mface_cyan ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "cyan"
1531     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1532     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1533     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¥·¥¢¥ó¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1534
1535 MFace *mface_cyan;
1536
1537 /***en
1538     @brief yellow face.
1539
1540     The variable #mface_yellow points to a face that has the
1541     #Mforeground property with value a symbol of name "yellow".  The
1542     other properties are not specified.  An M-text that has this face
1543     is drawn with yellow foreground.  */
1544
1545 /***ja
1546     @brief ²«¥Õ¥§¡¼¥¹.
1547
1548     ÊÑ¿ô #mface_yellow ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ "yellow" 
1549     ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1550     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1551     ¤ÏÁ°·Ê¿§¤È¤·¤Æ²«¿§¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1552
1553 MFace *mface_yellow;
1554
1555 /***en
1556     @brief Magenta face.
1557
1558     The variable #mface_magenta points to a face that has the
1559     #Mforeground property with value a symbol of name "magenta".  The
1560     other properties are not specified.  An M-text that has this face
1561     is drawn with magenta foreground.  */
1562
1563 /***ja
1564     @brief ¥Þ¥¼¥ó¥¿¥Õ¥§¡¼¥¹.
1565
1566     ÊÑ¿ô #mface_magenta ¤Ï¡¢#Mforeground ¥×¥í¥Ñ¥Æ¥£¤ÎÃͤȤ·¤Æ 
1567     "magenta" ¤È¤¤¤¦Ì¾Á°¤Î¥·¥ó¥Ü¥ë¤ò»ý¤Ä¤è¤¦¤Ê¥Õ¥§¡¼¥¹¤ò»Ø¤¹¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
1568     Â¾¤Î¥×¥í¥Ñ¥Æ¥£¤Ï»ØÄꤵ¤ì¤Ê¤¤¡£¤³¤Î¥Õ¥§¡¼¥¹¤ò»ý¤Ä M-text 
1569     ¤ÏÁ°·Ê¿§¤È¤·¤Æ¥Þ¥¼¥ó¥¿¤òÍѤ¤¤Æɽ¼¨¤µ¤ì¤ë¡£  */
1570
1571 MFace *mface_magenta;
1572
1573 /*** @} */
1574 /*=*/
1575
1576 /***en @name Variables: The other symbols for face handling.  */
1577 /***ja @name ÊÑ¿ô: ¥Õ¥§¡¼¥¹¤ò¼è¤ê°·¤¦¤¿¤á¤Î¤½¤Î¾¤Î¥·¥ó¥Ü¥ë  */
1578 /*** @{ */
1579 /*=*/
1580
1581 /***en
1582     @brief Key of a text property specifying a face.
1583
1584     The variable #Mface is a symbol of name <tt>"face"</tt>.  A text
1585     property whose key is this symbol must have a pointer to an object
1586     of type #MFace.  This is a managing key.  */
1587
1588 /***ja
1589     @brief ¥Õ¥§¡¼¥¹¤ò»ØÄꤹ¤ë¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Î¥­¡¼.
1590
1591     ÊÑ¿ô #Mface ¤Ï <tt>"face"</tt> 
1592     ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë¤Ç¤¢¤ë¡£¤³¤Î¥·¥ó¥Ü¥ë¤ò¥­¡¼¤È¤¹¤ë¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤Ï¡¢
1593     #MFace ·¿¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1594     ¤³¤ì¤Ï´ÉÍý¥­¡¼¤Ç¤¢¤ë¡£  */
1595
1596 MSymbol Mface;
1597 /*=*/
1598 /*** @} */
1599 /*=*/
1600
1601 /***en
1602     @brief Create a new face.
1603
1604     The mface () function creates a new face object that specifies no
1605     property.
1606
1607     @return
1608     This function returns a pointer to the created face.  */
1609
1610 /***ja
1611     @brief ¿·¤·¤¤¥Õ¥§¡¼¥¹¤ò¤Ä¤¯¤ë.
1612
1613     ´Ø¿ô mface () 
1614     ¤Ï¥×¥í¥Ñ¥Æ¥£¤ò°ìÀÚ»ý¤¿¤Ê¤¤¿·¤·¤¤¥Õ¥§¡¼¥¹¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë¡£
1615
1616     @return
1617     ¤³¤Î´Ø¿ô¤Ïºî¤Ã¤¿¥Õ¥§¡¼¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£  */
1618
1619 MFace *
1620 mface ()
1621 {
1622   MFace *face;
1623
1624   M17N_OBJECT (face, free_face, MERROR_FACE);
1625   face->frame_list = mplist ();
1626   M17N_OBJECT_REGISTER (face_table, face);
1627   return face;
1628 }
1629
1630 /*=*/
1631
1632 /***en
1633     @brief Make a copy of a face.
1634
1635     The mface_copy () function makes a copy of $FACE and returns a
1636     pointer to the created copy.  */
1637
1638 /***ja
1639     @brief ¥Õ¥§¡¼¥¹¤Î¥³¥Ô¡¼¤òºî¤ë.
1640
1641     ´Ø¿ô mface_copy () ¤Ï¥Õ¥§¡¼¥¹ $FACE 
1642     ¤Î¥³¥Ô¡¼¤òºî¤ê¡¢¤½¤Î¥³¥Ô¡¼¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£  */
1643
1644 MFace *
1645 mface_copy (MFace *face)
1646 {
1647   MFace *copy;
1648
1649   MSTRUCT_CALLOC (copy, MERROR_FACE);
1650   *copy = *face;
1651   copy->control.ref_count = 1;
1652   M17N_OBJECT_REGISTER (face_table, copy);
1653   copy->frame_list = mplist ();
1654   if (copy->property[MFACE_FONTSET])
1655     M17N_OBJECT_REF (copy->property[MFACE_FONTSET]);
1656   return copy;
1657 }
1658
1659 /*=*/
1660 /***en
1661     @brief Compare faces.
1662
1663     The mface_equal () function compares faces $FACE1 and $FACE2.
1664
1665     @return If two faces have the same property values, return 1.
1666     Otherwise return 0.  */
1667
1668 int
1669 mface_equal (MFace *face1, MFace *face2)
1670 {
1671   MFaceHLineProp *hline1, *hline2;
1672   MFaceBoxProp *box1, *box2;
1673   int i;
1674
1675   if (face1 == face2)
1676     return 1;
1677   if (memcmp (face1->property, face2->property, sizeof face1->property) == 0)
1678     return 1;
1679   for (i = MFACE_FOUNDRY; i <= MFACE_BACKGROUND; i++)
1680     if (face1->property[i] != face2->property[i])
1681       return 0;
1682   for (i = MFACE_VIDEOMODE; i <= MFACE_RATIO; i++)
1683     if (face1->property[i] != face2->property[i])
1684       return 0;
1685   hline1 = (MFaceHLineProp *) face1->property[MFACE_HLINE];
1686   hline2 = (MFaceHLineProp *) face2->property[MFACE_HLINE];
1687   if (hline1 != hline2)
1688     {
1689       if (! hline1 || ! hline2)
1690         return 0;
1691       if (memcmp (hline1, hline2, sizeof (MFaceHLineProp)) != 0)
1692         return 0;
1693     }
1694   box1 = (MFaceBoxProp *) face1->property[MFACE_BOX];
1695   box2 = (MFaceBoxProp *) face2->property[MFACE_BOX];
1696   if (box1 != box2)
1697     {
1698       if (! box1 || ! box2)
1699         return 0;
1700       if (memcmp (box1, box2, sizeof (MFaceBoxProp)) != 0)
1701         return 0;
1702     }
1703   return 1;
1704 }
1705
1706
1707 /*=*/
1708 /***en
1709     @brief Merge faces.
1710
1711     The mface_merge () functions merges the properties of face $SRC
1712     into $DST.
1713
1714     @return
1715     This function returns $DST.  */
1716
1717 /***ja
1718     @brief ¥Õ¥§¡¼¥¹¤òÅý¹ç¤¹¤ë.
1719
1720     ´Ø¿ô mface_merge () ¤Ï¡¢¥Õ¥§¡¼¥¹ $SRC ¤Î¥×¥í¥Ñ¥Æ¥£¤ò¥Õ¥§¡¼¥¹ $DST 
1721     ¤ËÅý¹ç¤¹¤ë¡£
1722
1723     @return
1724     ¤³¤Î´Ø¿ô¤Ï $DST ¤òÊÖ¤¹¡£  */
1725
1726 MFace *
1727 mface_merge (MFace *dst, MFace *src)
1728 {
1729   int i;
1730   MPlist *plist;
1731
1732   for (i = 0; i < MFACE_PROPERTY_MAX; i++)
1733     if (src->property[i])
1734       {
1735         if (i == MFACE_FONTSET)
1736           {
1737             M17N_OBJECT_UNREF (dst->property[i]);
1738             M17N_OBJECT_REF (src->property[i]);
1739           }
1740         dst->property[i] = src->property[i];
1741       }
1742
1743   MPLIST_DO (plist, dst->frame_list)
1744     {
1745       MFrame *frame = MPLIST_VAL (plist);
1746
1747       frame->tick++;
1748       if (dst == frame->face)
1749         mface__update_frame_face (frame);
1750     }
1751
1752   return dst;
1753 }
1754
1755 /*=*/
1756
1757 /***en
1758     @brief Make a face from a font.
1759
1760     The mface_from_font () function return a newly created face while
1761     reflecting the properties of $FONT in its properties.   */
1762
1763 /***ja
1764     @brief ¥Õ¥©¥ó¥È¤«¤é¥Õ¥§¡¼¥¹¤òºî¤ë.
1765
1766     ´Ø¿ô mface_from_font () ¤Ï¥Õ¥©¥ó¥È $FONT 
1767     ¤Î¥×¥í¥Ñ¥Æ¥£¤ò¥×¥í¥Ñ¥Æ¥£¤È¤·¤Æ»ý¤Ä¿·¤·¤¤¥Õ¥§¡¼¥¹¤òºî¤ê¡¢¤½¤ì¤òÊÖ¤¹¡£  */
1768
1769 MFace *
1770 mface_from_font (MFont *font)
1771 {
1772   MFace *face = mface ();
1773
1774   face->property[MFACE_FOUNDRY] = mfont_get_prop (font, Mfoundry);
1775   face->property[MFACE_FAMILY] = mfont_get_prop (font, Mfamily);
1776   face->property[MFACE_WEIGHT] = mfont_get_prop (font, Mweight);
1777   face->property[MFACE_STYLE] = mfont_get_prop (font, Mstyle);
1778   face->property[MFACE_STRETCH] = mfont_get_prop (font, Mstretch);
1779   face->property[MFACE_ADSTYLE] = mfont_get_prop (font, Madstyle);
1780   face->property[MFACE_SIZE] = mfont_get_prop (font, Msize);
1781   return face;
1782 }
1783
1784 /*=*/
1785
1786 /***en
1787     @brief Get the value of a face property.
1788
1789     The mface_get_prop () function returns the value of the face
1790     property whose key is $KEY in face $FACE.  $KEY must be one of the
1791     followings:
1792
1793         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1794         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1795         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1796
1797     @return
1798     The actual type of the returned value depends of $KEY.  See
1799     documentation of the above keys.  If an error is detected, it
1800     returns @c NULL and assigns an error code to the external variable
1801     #merror_code.  */
1802
1803 /***ja
1804     @brief ¥Õ¥§¡¼¥¹¤Î¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÆÀ¤ë.
1805
1806     ´Ø¿ô mface_get_prop () ¤Ï¡¢¥Õ¥§¡¼¥¹ $FACE 
1807     ¤¬»ý¤Ä¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤ÎÆâ¡¢¥­¡¼¤¬ $KEY ¤Ç¤¢¤ë¤â¤Î¤ÎÃͤòÊÖ¤¹¡£
1808     $KEY ¤Ï²¼µ­¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
1809
1810         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1811         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1812         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1813
1814     @return 
1815     Ìá¤êÃͤη¿¤Ï $KEY ¤Ë°Í¸¤¹¤ë¡£¾åµ­¤Î¥­¡¼¤ÎÀâÌÀ¤ò»²¾È¤¹¤ë¤³¤È¡£
1816     ¥¨¥é¡¼¤¬¸¡½Ð¤µ¤ì¤¿¾ì¹ç¤Ï @c NULL ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code 
1817     ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£  */
1818
1819 /***
1820     @seealso
1821     mface_put_prop ()
1822
1823     @errors
1824     @c MERROR_FACE  */
1825
1826 void *
1827 mface_get_prop (MFace *face, MSymbol key)
1828 {
1829   int index = (int) msymbol_get (key, M_face_prop_index) - 1;
1830
1831   if (index < 0)
1832     MERROR (MERROR_FACE, NULL);
1833   return face->property[index];
1834 }
1835
1836 /*=*/
1837
1838 /***en
1839     @brief Set a value of a face property.
1840
1841     The mface_put_prop () function assigns $VAL to the property whose
1842     key is $KEY in face $FACE.  $KEY must be one the followings:
1843
1844         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1845         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1846         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg
1847
1848     Among them, font related properties (#Mfoundry through #Msize) are
1849     used as the default values when a font in the fontset of $FACE
1850     does not specify those values.
1851
1852     The actual type of the returned value depends of $KEY.  See
1853     documentation of the above keys.
1854
1855     @return
1856     If the operation was successful, mface_put_prop () returns 0.
1857     Otherwise it returns -1 and assigns an error code to the external
1858     variable #merror_code.  */
1859
1860 /***ja
1861     @brief ¥Õ¥§¡¼¥¹¥×¥í¥Ñ¥Æ¥£¤ÎÃͤòÀßÄꤹ¤ë.
1862
1863     ´Ø¿ô mface_put_prop () ¤Ï¡¢¥Õ¥§¡¼¥¹ $FACE Æâ¤Ç¥­¡¼¤¬ $KEY 
1864     ¤Ç¤¢¤ë¥×¥í¥Ñ¥Æ¥£¤ÎÃͤò $VAL ¤ËÀßÄꤹ¤ë¡£$KEY 
1865     ¤Ï°Ê²¼¤Î¤¤¤º¤ì¤«¤Ç¤Ê¤¯¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
1866
1867         #Mforeground, #Mbackground, #Mvideomode, #Mhline, #Mbox,
1868         #Mfoundry, #Mfamily, #Mweight, #Mstyle, #Mstretch, #Madstyle,
1869         #Msize, #Mfontset, #Mratio, #Mhook_func, #Mhook_arg.
1870
1871     ¤³¤ì¤é¤Î¤¦¤Á¤Î¡¢¥Õ¥©¥ó¥È´ØÏ¢¤Î¥×¥í¥Ñ¥Æ¥£ (#Mfamily ¤«¤é #Msize 
1872     ¤Þ¤Ç) ¤Ï¡¢¥Õ¥§¡¼¥¹¤Î¥Õ¥©¥ó¥È¥»¥Ã¥ÈÃæ¤Î¥Õ¥©¥ó¥È¤Ë´Ø¤¹¤ë¥Ç¥Õ¥©¥ë¥ÈÃͤȤʤꡢ¸Ä¡¹¤Î¥Õ¥©¥ó¥È¤¬Ãͤò»ØÄꤷ¤Ê¤«¤Ã¤¿¾ì¹ç¤ËÍѤ¤¤é¤ì¤ë¡£
1873
1874     Ìá¤êÃͤη¿¤Ï $KEY ¤Ë°Í¸¤¹¤ë¡£¾åµ­¤Î¥­¡¼¤ÎÀâÌÀ¤ò»²¾È¤¹¤ë¤³¤È¡£
1875
1876     @return
1877     ½èÍý¤¬À®¸ù¤·¤¿¾ì¹ç¡¢mface_put_prop () ¤Ï 0 ¤òÊÖ¤¹¡£¼ºÇÔ¤·¤¿¾ì¹ç¤Ï 
1878     -1 ¤òÊÖ¤·¡¢³°ÉôÊÑ¿ô #merror_code ¤Ë¥¨¥é¡¼¥³¡¼¥É¤òÀßÄꤹ¤ë¡£  */
1879
1880 /***
1881     @seealso
1882     mface_get_prop ()
1883
1884     @errors
1885     @c MERROR_FACE  */
1886
1887 int
1888 mface_put_prop (MFace *face, MSymbol key, void *val)
1889 {
1890   int index = (int) msymbol_get (key, M_face_prop_index) - 1;
1891   MPlist *plist;
1892
1893   if (index < 0)
1894     MERROR (MERROR_FACE, -1);
1895   if (key == Mfontset)
1896     {
1897       if (face->property[index])
1898         M17N_OBJECT_UNREF (face->property[index]);
1899       M17N_OBJECT_REF (val);
1900     }
1901   else if (key == Mhline)
1902     val = get_hline_create (val);
1903   else if (key == Mbox)
1904     val = get_box_create (val);
1905
1906   if (face->property[index] == val)
1907     return 0;
1908   face->property[index] = val;
1909
1910   MPLIST_DO (plist, face->frame_list)
1911     {
1912       MFrame *frame = MPLIST_VAL (plist);
1913
1914       frame->tick++;
1915       if (face == frame->face)
1916         mface__update_frame_face (frame);
1917     }
1918
1919   return 0;
1920 }
1921
1922 /*=*/
1923
1924 /***en
1925     @brief Update a face.
1926
1927     The mface_update () function update face $FACE on frame $FRAME by
1928     calling a hook function of $FACE (if any).  */
1929
1930 /***ja
1931     @brief ¥Õ¥§¡¼¥¹¤ò¹¹¿·¤¹¤ë.
1932
1933     ´Ø¿ô mface_update () ¤Ï¥Õ¥ì¡¼¥à $FRAME ¤Î¥Õ¥§¡¼¥¹ $FACE ¤ò $FACE 
1934     ¤Î¥Õ¥Ã¥¯´Ø¿ô¤ò¡Ê¤¢¤ì¤Ð¡Ë¸Æ¤ó¤Ç¹¹¿·¤¹¤ë¡£  */
1935
1936 void
1937 mface_update (MFrame *frame, MFace *face)
1938 {
1939   MFaceHookFunc func = (MFaceHookFunc) face->property[MFACE_HOOK_FUNC];
1940   MPlist *rface_list;
1941   MRealizedFace *rface;
1942
1943   if (func && func != noop_hook)
1944     {
1945       MPLIST_DO (rface_list, frame->realized_face_list)
1946         {
1947           rface = MPLIST_VAL (rface_list);
1948           if ((MFaceHookFunc) rface->face.property[MFACE_HOOK_FUNC] == func)
1949             (func) (&(rface->face), rface->face.property[MFACE_HOOK_ARG],
1950                     rface->info);
1951         }
1952     }
1953 }
1954 /*=*/
1955
1956 /*** @} */
1957 /*=*/
1958
1959 /*** @addtogroup m17nDebug */
1960 /*** @{  */
1961 /*=*/
1962
1963 /***en
1964     @brief Dump a face.
1965
1966     The mdebug_dump_face () function prints face $FACE in a human readable
1967     way to the stderr.  $INDENT specifies how many columns to indent
1968     the lines but the first one.
1969
1970     @return
1971     This function returns $FACE.  */
1972
1973 /***ja
1974     @brief ¥Õ¥§¡¼¥¹¤ò¥À¥ó¥×¤¹¤ë.
1975
1976     ´Ø¿ô mdebug_dump_face () ¤Ï¥Õ¥§¡¼¥¹ $FACE ¤ò stderr 
1977     ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
1978
1979     @return
1980     ¤³¤Î´Ø¿ô¤Ï $FACE ¤òÊÖ¤¹¡£  */
1981
1982 MFace *
1983 mdebug_dump_face (MFace *face, int indent)
1984 {
1985   char *prefix = (char *) alloca (indent + 1);
1986   MFont spec;
1987
1988   memset (prefix, 32, indent);
1989   prefix[indent] = 0;
1990   mfont__set_spec_from_face (&spec, face);
1991   fprintf (stderr, "(face font:\"");
1992   mdebug_dump_font (&spec);
1993   fprintf (stderr, "\"\n %s  fore:%s back:%s", prefix,
1994            msymbol_name ((MSymbol) face->property[MFACE_FOREGROUND]),
1995            msymbol_name ((MSymbol) face->property[MFACE_BACKGROUND]));
1996   if (face->property[MFACE_FONTSET])
1997     fprintf (stderr, " non-default-fontset");
1998   fprintf (stderr, " hline:%s", face->property[MFACE_HLINE] ? "yes" : "no");
1999   fprintf (stderr, " box:%s)", face->property[MFACE_BOX] ? "yes" : "no");
2000   return face;
2001 }
2002
2003 /*** @} */
2004
2005 /*
2006   Local Variables:
2007   coding: euc-japan
2008   End:
2009 */