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,2022 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  Mono = 1,
172  Variable = 2,
173  Dual = 4,
174  Cell = 8,
175  Fixed = Mono|Cell
176  };
177 
179  enum {
180  Decorative = 16,
181  Modern = 32,
182  Roman = 64,
183  Script = 128,
184  Swiss = 256,
185  System = 512,
186  X11 = 1024,
187  Scalable = 2048,
188  Polymorphic = 4096,
189  Rotatable = 8192
190  };
191 
193  enum {
194  ReverseOblique = 1,
195  ReverseItalic = 2,
196  Straight = 5,
197  Italic = 8,
198  Oblique = 9
199  };
200 
202  enum {
203  Thin = 10,
204  ExtraLight = 20,
205  Light = 30,
206  Normal = 40,
207  Medium = 50,
208  DemiBold = 60,
209  Bold = 70,
210  ExtraBold = 80,
211  Black = 90
212  };
213 
215  enum {
216  UltraCondensed = 50,
217  ExtraCondensed = 63,
218  Condensed = 75,
219  SemiCondensed = 87,
220  NonExpanded = 100,
221  SemiExpanded = 113,
222  Expanded = 125,
223  ExtraExpanded = 150,
224  UltraExpanded = 200
225  };
226 
227 public:
228 
246  FXFont(FXApp* a,const FXString& string);
247 
254  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);
255 
257  FXFont(FXApp* a,const FXFontDesc& fontdesc);
258 
260  virtual void create();
261 
263  virtual void detach();
264 
266  virtual void destroy();
267 
269  FXString getFamily() const;
270 
272  FXString getFoundry() const;
273 
275  const FXString& getName() const { return wantedName; }
276 
278  const FXString& getActualName() const { return actualName; }
279 
281  FXuint getSize() const { return wantedSize; }
282 
284  FXuint getActualSize() const { return actualSize; }
285 
287  FXuint getWeight() const { return wantedWeight; }
288 
290  FXuint getActualWeight() const { return actualWeight; }
291 
293  FXuint getSlant() const { return wantedSlant; }
294 
296  FXuint getActualSlant() const { return actualSlant; }
297 
299  FXuint getEncoding() const { return wantedEncoding; }
300 
302  FXuint getActualEncoding() const { return actualEncoding; }
303 
305  FXuint getSetWidth() const { return wantedSetwidth; }
306 
308  FXuint getActualSetWidth() const { return actualSetwidth; }
309 
311  FXuint getHints() const { return hints; }
312 
314  FXuint getFlags() const { return flags; }
315 
317  virtual void setFontDesc(const FXFontDesc& fontdesc);
318 
320  FXFontDesc getFontDesc() const;
321 
323  FXFontDesc getActualFontDesc() const;
324 
326  FXint getAngle() const { return angle; }
327 
329  virtual void setAngle(FXint ang);
330 
335  FXString getFont() const;
336 
340  virtual void setFont(const FXString& string);
341 
343  virtual FXbool isFontMono() const;
344 
346  virtual FXbool hasChar(FXwchar ch) const;
347 
349  virtual FXwchar getMinChar() const;
350 
352  virtual FXwchar getMaxChar() const;
353 
355  virtual FXint leftBearing(FXwchar ch) const;
356 
358  virtual FXint rightBearing(FXwchar ch) const;
359 
361  virtual FXint getFontWidth() const;
362 
364  virtual FXint getFontHeight() const;
365 
367  virtual FXint getFontAscent() const;
368 
370  virtual FXint getFontDescent() const;
371 
373  virtual FXint getFontLeading() const;
374 
376  virtual FXint getFontSpacing() const;
377 
379  virtual FXint getCharWidth(const FXwchar ch) const;
380 
382  virtual FXint getTextWidth(const FXString& string) const;
383 
385  virtual FXint getTextWidth(const FXchar* string,FXuint length) const;
386 
388  virtual FXint getTextHeight(const FXString& string) const;
389 
391  virtual FXint getTextHeight(const FXchar *string,FXuint length) const;
392 
394  static FXuint styleFromString(const FXString& str);
395  static FXString stringFromStyle(FXuint style);
396 
398  static FXuint slantFromString(const FXString& str);
399  static FXString stringFromSlant(FXuint slant);
400 
402  static FXuint weightFromString(const FXString& str);
403  static FXString stringFromWeight(FXuint weight);
404 
406  static FXuint setWidthFromString(const FXString& str);
407  static FXString stringFromSetWidth(FXuint setwidth);
408 
410  static FXuint encodingFromString(const FXString& str);
411  static FXString stringFromEncoding(FXuint encoding);
412 
418  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);
419 
421  virtual void save(FXStream& store) const;
422 
424  virtual void load(FXStream& store);
425 
427  virtual ~FXFont();
428  };
429 
430 
431 }
432 
433 #endif
FXuint getActualEncoding() const
Get actual encoding.
Definition: FXFont.h:302
FXuint getEncoding() const
Get character set encoding.
Definition: FXFont.h:299
FXushort size
Face name.
Definition: FXFont.h:117
Light.
Definition: FXFont.h:206
FXint getAngle() const
Return angle.
Definition: FXFont.h:326
FXuint getActualSize() const
Get actual size in deci-points.
Definition: FXFont.h:284
const FXString & getActualName() const
Get actual family name.
Definition: FXFont.h:278
void setFont(const FXString &string)
Flags.
FXuint getHints() const
Get hints.
Definition: FXFont.h:311
FXString getFont() const
Get string of font description.
FXuint getSize() const
Get size in deci-points.
Definition: FXFont.h:281
The Application object is the central point of a FOX user-interface.
Definition: FXApp.h:134
const FXString & getName() const
Get font family name.
Definition: FXFont.h:275
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXuint getSlant() const
Get slant.
Definition: FXFont.h:293
FXuint getActualSetWidth() const
Get actual setwidth.
Definition: FXFont.h:308
Abstract Device Context.
Definition: FXDC.h:153
FXuint getActualSlant() const
Get actual slant.
Definition: FXFont.h:296
Font description.
Definition: FXFont.h:115
Reversed italic.
Definition: FXFont.h:196
Encapsulates server side resource.
Definition: FXId.h:34
FXushort flags
Encoding of character set.
Definition: FXFont.h:122
FXuint getActualWeight() const
Get actual font weight.
Definition: FXFont.h:290
Definition: FX4Splitter.h:28
FXushort encoding
Set width [normal, condensed, expanded, ...].
Definition: FXFont.h:121
FXushort setwidth
Slant [normal, italic, oblique, ...].
Definition: FXFont.h:120
FXuint getFlags() const
Get flags.
Definition: FXFont.h:314
FXuint getSetWidth() const
Get setwidth.
Definition: FXFont.h:305
Window Device Context.
Definition: FXDCWindow.h:48
FXushort weight
Size in deci-points (one point is 1/72 inch)
Definition: FXFont.h:118
Semi-condensed.
Definition: FXFont.h:220
FXushort slant
Weight [light, normal, bold, ...].
Definition: FXFont.h:119
FXuint getWeight() const
Get font weight.
Definition: FXFont.h:287
Font class.
Definition: FXFont.h:137
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp