31e326c0ef82339b1c7b2e03cceffb199d9478f5
[m17n/m17n-lib.git] / src / face.h
1 /* face.h -- header file for the face module.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 #ifndef _M17N_FACE_H_
24 #define _M17N_FACE_H_
25
26 enum MFaceProperty
27   {
28     /** The font related properties.  */
29     /* The order of MFACE_FOUNDRY to MFACE_ADSTYLE must be the same as
30        MFONT_FOUNDRY to MFONT_ADSTYLE of enum MFontProperty.  */
31     MFACE_FOUNDRY,
32     MFACE_FAMILY,
33     MFACE_WEIGHT,
34     MFACE_STYLE,
35     MFACE_STRETCH,
36     MFACE_ADSTYLE,
37     MFACE_SIZE,
38     MFACE_FONTSET,
39
40     /** The color related properties.   */
41     MFACE_FOREGROUND,
42     MFACE_BACKGROUND,
43
44     /** The other properties.   */
45     MFACE_HLINE,
46     MFACE_BOX,
47     MFACE_VIDEOMODE,
48
49     /* In a realized face, this is ignored because it is already
50        reflected in MFACE_SIZE.  */
51     MFACE_RATIO,
52
53     MFACE_HOOK_ARG,
54
55     MFACE_PROPERTY_MAX
56   };
57
58 struct MFace
59 {
60   M17NObject control;
61
62   /** Properties of the face.  */
63   void *property[MFACE_PROPERTY_MAX];
64
65   MFaceHookFunc hook;
66
67   /** List of frames affected by the face modification.  */
68   MPlist *frame_list;
69 };
70
71
72 /** A realized face is registered in MFrame->face_list, thus it does
73     not have to be a managed object.  */
74
75 struct MRealizedFace
76 {
77   /** Frame on which this realized face is created.  */
78   MFrame *frame;
79
80   /** Properties of all stacked faces are merged into here.  */
81   MFace face;
82
83   /** Font explicitly specified for the face (maybe NULL).  */
84   MFont *font;
85
86   /** From what faces this is realized.  Keys are Mface and values are
87      (MFace *).  */
88   MPlist *base_face_list;
89
90   /* Realized font, one of <frame>->realized_font_list.  */
91   MRealizedFont *rfont;
92
93   /* Realized fontset, one of <frame>->realized_fontset_list.  */
94   MRealizedFontset *rfontset;
95
96   MSymbol layouter;
97
98   MFaceHLineProp *hline;
99
100   MFaceBoxProp *box;
101
102   /** Realized face for ASCII chars that has the same face
103       properties. */
104   MRealizedFace *ascii_rface;
105
106   /** List of realized faces that have the same face properties.  */
107   MPlist *non_ascii_list;
108
109   int ascent, descent;
110   int space_width;
111   int average_width;
112
113   /** Pointer to a window system dependent object.  */
114   void *info;
115 };
116
117
118 extern MFace *mface__default;
119
120 extern MRealizedFace *mface__realize (MFrame *frame, MFace **faces, int num,
121                                       int limitted_size, MFont *font);
122
123 extern MGlyph *mface__for_chars (MSymbol script, MSymbol language,
124                                  MSymbol charset, MGlyph *from_g, MGlyph *to_g,
125                                  int size);
126
127 extern void mface__free_realized (MRealizedFace *rface);
128
129 extern void mface__update_frame_face (MFrame *frame);
130
131 #endif /* _M17N_FACE_H_ */