Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXFont.h
1 /********************************************************************************
2 * *
3 * F o n t O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This 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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXFONT_H
22 #define FXFONT_H
23 
24 #ifndef FXID_H
25 #include "FXId.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum FXFontEncoding {
33  FONTENCODING_DEFAULT,
34 
35  FONTENCODING_ISO_8859_1 = 1,
36  FONTENCODING_ISO_8859_2 = 2,
37  FONTENCODING_ISO_8859_3 = 3,
38  FONTENCODING_ISO_8859_4 = 4,
39  FONTENCODING_ISO_8859_5 = 5,
40  FONTENCODING_ISO_8859_6 = 6,
41  FONTENCODING_ISO_8859_7 = 7,
42  FONTENCODING_ISO_8859_8 = 8,
43  FONTENCODING_ISO_8859_9 = 9,
44  FONTENCODING_ISO_8859_10 = 10,
45  FONTENCODING_ISO_8859_11 = 11,
46  FONTENCODING_ISO_8859_13 = 13,
47  FONTENCODING_ISO_8859_14 = 14,
48  FONTENCODING_ISO_8859_15 = 15,
49  FONTENCODING_ISO_8859_16 = 16,
50  FONTENCODING_KOI8 = 17,
51  FONTENCODING_KOI8_R = 18,
52  FONTENCODING_KOI8_U = 19,
53  FONTENCODING_KOI8_UNIFIED = 20,
54 
55  FONTENCODING_CP437 = 437,
56  FONTENCODING_CP850 = 850,
57  FONTENCODING_CP851 = 851,
58  FONTENCODING_CP852 = 852,
59  FONTENCODING_CP855 = 855,
60  FONTENCODING_CP856 = 856,
61  FONTENCODING_CP857 = 857,
62  FONTENCODING_CP860 = 860,
63  FONTENCODING_CP861 = 861,
64  FONTENCODING_CP862 = 862,
65  FONTENCODING_CP863 = 863,
66  FONTENCODING_CP864 = 864,
67  FONTENCODING_CP865 = 865,
68  FONTENCODING_CP866 = 866,
69  FONTENCODING_CP869 = 869,
70  FONTENCODING_CP870 = 870,
71 
72  FONTENCODING_CP1250 = 1250,
73  FONTENCODING_CP1251 = 1251,
74  FONTENCODING_CP1252 = 1252,
75  FONTENCODING_CP1253 = 1253,
76  FONTENCODING_CP1254 = 1254,
77  FONTENCODING_CP1255 = 1255,
78  FONTENCODING_CP1256 = 1256,
79  FONTENCODING_CP1257 = 1257,
80  FONTENCODING_CP1258 = 1258,
81  FONTENCODING_CP874 = 874,
82 
83  FONTENCODING_UNICODE = 9999,
84 
85  FONTENCODING_LATIN1 = FONTENCODING_ISO_8859_1,
86  FONTENCODING_LATIN2 = FONTENCODING_ISO_8859_2,
87  FONTENCODING_LATIN3 = FONTENCODING_ISO_8859_3,
88  FONTENCODING_LATIN4 = FONTENCODING_ISO_8859_4,
89  FONTENCODING_LATIN5 = FONTENCODING_ISO_8859_9,
90  FONTENCODING_LATIN6 = FONTENCODING_ISO_8859_10,
91  FONTENCODING_LATIN7 = FONTENCODING_ISO_8859_13,
92  FONTENCODING_LATIN8 = FONTENCODING_ISO_8859_14,
93  FONTENCODING_LATIN9 = FONTENCODING_ISO_8859_15,
94  FONTENCODING_LATIN10 = FONTENCODING_ISO_8859_16,
95 
96  FONTENCODING_USASCII = FONTENCODING_ISO_8859_1,
97  FONTENCODING_WESTEUROPE = FONTENCODING_ISO_8859_1,
98  FONTENCODING_EASTEUROPE = FONTENCODING_ISO_8859_2,
99  FONTENCODING_SOUTHEUROPE = FONTENCODING_ISO_8859_3,
100  FONTENCODING_NORTHEUROPE = FONTENCODING_ISO_8859_4,
101  FONTENCODING_CYRILLIC = FONTENCODING_ISO_8859_5,
102  FONTENCODING_RUSSIAN = FONTENCODING_KOI8,
103  FONTENCODING_ARABIC = FONTENCODING_ISO_8859_6,
104  FONTENCODING_GREEK = FONTENCODING_ISO_8859_7,
105  FONTENCODING_HEBREW = FONTENCODING_ISO_8859_8,
106  FONTENCODING_TURKISH = FONTENCODING_ISO_8859_9,
107  FONTENCODING_NORDIC = FONTENCODING_ISO_8859_10,
108  FONTENCODING_THAI = FONTENCODING_ISO_8859_11,
109  FONTENCODING_BALTIC = FONTENCODING_ISO_8859_13,
110  FONTENCODING_CELTIC = FONTENCODING_ISO_8859_14
111  };
112 
113 
115 struct FXFontDesc {
116  FXchar face[116];
117  FXushort size;
118  FXushort weight;
119  FXushort slant;
120  FXushort setwidth;
121  FXushort encoding;
122  FXushort flags;
123 
125  void setFont(const FXString& string);
126 
128  FXString getFont() const;
129  };
130 
131 
132 class FXDC;
133 class FXDCWindow;
134 
135 
137 class FXAPI FXFont : public FXId {
138  friend class FXDCWindow;
139  FXDECLARE(FXFont)
140 protected:
141  FXString wantedName; // Desired font font name
142  FXString actualName; // Matched font font name
143  FXushort wantedSize; // Font size (points*10)
144  FXushort actualSize; // Actual size that was matched
145  FXushort wantedWeight; // Font weight
146  FXushort actualWeight; // Font weight
147  FXushort wantedSlant; // Font slant
148  FXushort actualSlant; // Font slant
149  FXushort wantedSetwidth; // Relative setwidth
150  FXushort actualSetwidth; // Relative setwidth
151  FXushort wantedEncoding; // Character set encoding
152  FXushort actualEncoding; // Character set encoding
153  FXushort hints; // Matching hint flags
154  FXushort flags; // Actual flags
155  FXshort angle; // Angle
156  void *font; // Info about the font
157 private:
158 #ifdef WIN32
159  FXID dc;
160 #endif
161 protected:
162  FXFont();
163  void* match(const FXString& wantfamily,const FXString& wantforge,FXuint wantsize,FXuint wantweight,FXuint wantslant,FXuint wantsetwidth,FXuint wantencoding,FXuint wanthints,FXint res);
164 private:
165  FXFont(const FXFont&);
166  FXFont &operator=(const FXFont&);
167 public:
168 
170  enum {
171  Fixed = 1,
172  Variable = 2
173  };
174 
176  enum {
177  Decorative = 4,
178  Modern = 8,
179  Roman = 16,
180  Script = 32,
181  Swiss = 64,
182  System = 128,
183  X11 = 256,
184  Scalable = 512,
185  Polymorphic = 1024,
186  Rotatable = 2048
187  };
188 
190  enum {
191  ReverseOblique = 1,
192  ReverseItalic = 2,
193  Straight = 5,
194  Italic = 8,
195  Oblique = 9
196  };
197 
199  enum {
200  Thin = 10,
201  ExtraLight = 20,
202  Light = 30,
203  Normal = 40,
204  Medium = 50,
205  DemiBold = 60,
206  Bold = 70,
207  ExtraBold = 80,
208  Black = 90
209  };
210 
212  enum {
213  UltraCondensed = 50,
214  ExtraCondensed = 63,
215  Condensed = 75,
216  SemiCondensed = 87,
217  NonExpanded = 100,
218  SemiExpanded = 113,
219  Expanded = 125,
220  ExtraExpanded = 150,
221  UltraExpanded = 200
222  };
223 
224 public:
225 
243  FXFont(FXApp* a,const FXString& string);
244 
251  FXFont(FXApp* a,const FXString& face,FXuint size,FXuint weight=FXFont::Normal,FXuint slant=FXFont::Straight,FXuint encoding=FONTENCODING_DEFAULT,FXuint setwidth=FXFont::NonExpanded,FXuint h=0);
252 
254  FXFont(FXApp* a,const FXFontDesc& fontdesc);
255 
257  virtual void create();
258 
260  virtual void detach();
261 
263  virtual void destroy();
264 
266  FXString getFamily() const;
267 
269  FXString getFoundry() const;
270 
272  const FXString& getName() const { return wantedName; }
273 
275  const FXString& getActualName() const { return actualName; }
276 
278  FXuint getSize() const { return wantedSize; }
279 
281  FXuint getActualSize() const { return actualSize; }
282 
284  FXuint getWeight() const { return wantedWeight; }
285 
287  FXuint getActualWeight() const { return actualWeight; }
288 
290  FXuint getSlant() const { return wantedSlant; }
291 
293  FXuint getActualSlant() const { return actualSlant; }
294 
296  FXuint getEncoding() const { return wantedEncoding; }
297 
299  FXuint getActualEncoding() const { return actualEncoding; }
300 
302  FXuint getSetWidth() const { return wantedSetwidth; }
303 
305  FXuint getActualSetWidth() const { return actualSetwidth; }
306 
308  FXuint getHints() const { return hints; }
309 
311  FXuint getFlags() const { return flags; }
312 
314  virtual void setFontDesc(const FXFontDesc& fontdesc);
315 
317  FXFontDesc getFontDesc() const;
318 
320  FXFontDesc getActualFontDesc() const;
321 
323  FXint getAngle() const { return angle; }
324 
326  virtual void setAngle(FXint ang);
327 
332  FXString getFont() const;
333 
337  virtual void setFont(const FXString& string);
338 
340  virtual FXbool isFontMono() const;
341 
343  virtual FXbool hasChar(FXwchar ch) const;
344 
346  virtual FXwchar getMinChar() const;
347 
349  virtual FXwchar getMaxChar() const;
350 
352  virtual FXint leftBearing(FXwchar ch) const;
353 
355  virtual FXint rightBearing(FXwchar ch) const;
356 
358  virtual FXint getFontWidth() const;
359 
361  virtual FXint getFontHeight() const;
362 
364  virtual FXint getFontAscent() const;
365 
367  virtual FXint getFontDescent() const;
368 
370  virtual FXint getFontLeading() const;
371 
373  virtual FXint getFontSpacing() const;
374 
376  virtual FXint getCharWidth(const FXwchar ch) const;
377 
379  virtual FXint getTextWidth(const FXString& string) const;
380 
382  virtual FXint getTextWidth(const FXchar* string,FXuint length) const;
383 
385  virtual FXint getTextHeight(const FXString& string) const;
386 
388  virtual FXint getTextHeight(const FXchar *string,FXuint length) const;
389 
391  static FXuint styleFromString(const FXString& str);
392  static FXString stringFromStyle(FXuint style);
393 
395  static FXuint slantFromString(const FXString& str);
396  static FXString stringFromSlant(FXuint slant);
397 
399  static FXuint weightFromString(const FXString& str);
400  static FXString stringFromWeight(FXuint weight);
401 
403  static FXuint setWidthFromString(const FXString& str);
404  static FXString stringFromSetWidth(FXuint setwidth);
405 
407  static FXuint encodingFromString(const FXString& str);
408  static FXString stringFromEncoding(FXuint encoding);
409 
415  static FXbool listFonts(FXFontDesc*& fonts,FXuint& numfonts,const FXString& face,FXuint wt=0,FXuint sl=0,FXuint sw=0,FXuint en=0,FXuint h=0);
416 
418  virtual void save(FXStream& store) const;
419 
421  virtual void load(FXStream& store);
422 
424  virtual ~FXFont();
425  };
426 
427 
428 }
429 
430 #endif

Copyright © 1997-2016 Jeroen van der Zijp