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