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