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