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