00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef FXFONT_H
00025
#define FXFONT_H
00026
00027
#ifndef FXID_H
00028
#include "FXId.h"
00029
#endif
00030
00031
namespace FX {
00032
00033
00034
00035
enum FXFontHint {
00036
FONTPITCH_DEFAULT = 0,
00037
FONTPITCH_FIXED = 1,
00038 FONTPITCH_VARIABLE = 2,
00039 FONTHINT_DONTCARE = 0,
00040 FONTHINT_DECORATIVE = 4,
00041 FONTHINT_MODERN = 8,
00042 FONTHINT_ROMAN = 16,
00043 FONTHINT_SCRIPT = 32,
00044 FONTHINT_SWISS = 64,
00045 FONTHINT_SYSTEM = 128,
00046 FONTHINT_X11 = 256,
00047 FONTHINT_SCALABLE = 512,
00048 FONTHINT_POLYMORPHIC = 1024
00049 };
00050
00051
00052
00053
enum FXFontSlant {
00054 FONTSLANT_DONTCARE = 0,
00055 FONTSLANT_REGULAR = 1,
00056 FONTSLANT_ITALIC = 2,
00057 FONTSLANT_OBLIQUE = 3,
00058 FONTSLANT_REVERSE_ITALIC = 4,
00059 FONTSLANT_REVERSE_OBLIQUE = 5
00060 };
00061
00062
00063
00064
enum FXFontEncoding {
00065 FONTENCODING_DEFAULT,
00066
00067 FONTENCODING_ISO_8859_1 = 1,
00068 FONTENCODING_ISO_8859_2 = 2,
00069 FONTENCODING_ISO_8859_3 = 3,
00070 FONTENCODING_ISO_8859_4 = 4,
00071 FONTENCODING_ISO_8859_5 = 5,
00072 FONTENCODING_ISO_8859_6 = 6,
00073 FONTENCODING_ISO_8859_7 = 7,
00074 FONTENCODING_ISO_8859_8 = 8,
00075 FONTENCODING_ISO_8859_9 = 9,
00076 FONTENCODING_ISO_8859_10 = 10,
00077 FONTENCODING_ISO_8859_11 = 11,
00078 FONTENCODING_ISO_8859_13 = 13,
00079 FONTENCODING_ISO_8859_14 = 14,
00080 FONTENCODING_ISO_8859_15 = 15,
00081 FONTENCODING_ISO_8859_16 = 16,
00082 FONTENCODING_KOI8 = 17,
00083 FONTENCODING_KOI8_R = 18,
00084 FONTENCODING_KOI8_U = 19,
00085 FONTENCODING_KOI8_UNIFIED = 20,
00086
00087 FONTENCODING_CP437 = 437,
00088 FONTENCODING_CP850 = 850,
00089 FONTENCODING_CP851 = 851,
00090 FONTENCODING_CP852 = 852,
00091 FONTENCODING_CP855 = 855,
00092 FONTENCODING_CP856 = 856,
00093 FONTENCODING_CP857 = 857,
00094 FONTENCODING_CP860 = 860,
00095 FONTENCODING_CP861 = 861,
00096 FONTENCODING_CP862 = 862,
00097 FONTENCODING_CP863 = 863,
00098 FONTENCODING_CP864 = 864,
00099 FONTENCODING_CP865 = 865,
00100 FONTENCODING_CP866 = 866,
00101 FONTENCODING_CP869 = 869,
00102 FONTENCODING_CP870 = 870,
00103
00104 FONTENCODING_CP1250 = 1250,
00105 FONTENCODING_CP1251 = 1251,
00106 FONTENCODING_CP1252 = 1252,
00107 FONTENCODING_CP1253 = 1253,
00108 FONTENCODING_CP1254 = 1254,
00109 FONTENCODING_CP1255 = 1255,
00110 FONTENCODING_CP1256 = 1256,
00111 FONTENCODING_CP1257 = 1257,
00112 FONTENCODING_CP1258 = 1258,
00113 FONTENCODING_CP874 = 874,
00114
00115 FONTENCODING_LATIN1 = FONTENCODING_ISO_8859_1,
00116 FONTENCODING_LATIN2 = FONTENCODING_ISO_8859_2,
00117 FONTENCODING_LATIN3 = FONTENCODING_ISO_8859_3,
00118 FONTENCODING_LATIN4 = FONTENCODING_ISO_8859_4,
00119 FONTENCODING_LATIN5 = FONTENCODING_ISO_8859_9,
00120 FONTENCODING_LATIN6 = FONTENCODING_ISO_8859_10,
00121 FONTENCODING_LATIN7 = FONTENCODING_ISO_8859_13,
00122 FONTENCODING_LATIN8 = FONTENCODING_ISO_8859_14,
00123 FONTENCODING_LATIN9 = FONTENCODING_ISO_8859_15,
00124 FONTENCODING_LATIN10 = FONTENCODING_ISO_8859_16,
00125
00126 FONTENCODING_USASCII = FONTENCODING_ISO_8859_1,
00127 FONTENCODING_WESTEUROPE = FONTENCODING_ISO_8859_1,
00128 FONTENCODING_EASTEUROPE = FONTENCODING_ISO_8859_2,
00129 FONTENCODING_SOUTHEUROPE = FONTENCODING_ISO_8859_3,
00130 FONTENCODING_NORTHEUROPE = FONTENCODING_ISO_8859_4,
00131 FONTENCODING_CYRILLIC = FONTENCODING_ISO_8859_5,
00132 FONTENCODING_RUSSIAN = FONTENCODING_KOI8,
00133 FONTENCODING_ARABIC = FONTENCODING_ISO_8859_6,
00134 FONTENCODING_GREEK = FONTENCODING_ISO_8859_7,
00135 FONTENCODING_HEBREW = FONTENCODING_ISO_8859_8,
00136 FONTENCODING_TURKISH = FONTENCODING_ISO_8859_9,
00137 FONTENCODING_NORDIC = FONTENCODING_ISO_8859_10,
00138 FONTENCODING_THAI = FONTENCODING_ISO_8859_11,
00139 FONTENCODING_BALTIC = FONTENCODING_ISO_8859_13,
00140 FONTENCODING_CELTIC = FONTENCODING_ISO_8859_14
00141 };
00142
00143
00144
00145
enum FXFontWeight {
00146 FONTWEIGHT_DONTCARE = 0,
00147 FONTWEIGHT_THIN = 100,
00148 FONTWEIGHT_EXTRALIGHT = 200,
00149 FONTWEIGHT_LIGHT = 300,
00150 FONTWEIGHT_NORMAL = 400,
00151 FONTWEIGHT_REGULAR = 400,
00152 FONTWEIGHT_MEDIUM = 500,
00153 FONTWEIGHT_DEMIBOLD = 600,
00154 FONTWEIGHT_BOLD = 700,
00155 FONTWEIGHT_EXTRABOLD = 800,
00156 FONTWEIGHT_HEAVY = 900,
00157 FONTWEIGHT_BLACK = 900
00158 };
00159
00160
00161
00162
enum FXFontSetWidth {
00163 FONTSETWIDTH_DONTCARE = 0,
00164 FONTSETWIDTH_ULTRACONDENSED = 10,
00165 FONTSETWIDTH_EXTRACONDENSED = 20,
00166 FONTSETWIDTH_CONDENSED = 30,
00167 FONTSETWIDTH_NARROW = 30,
00168 FONTSETWIDTH_COMPRESSED = 30,
00169 FONTSETWIDTH_SEMICONDENSED = 40,
00170 FONTSETWIDTH_MEDIUM = 50,
00171 FONTSETWIDTH_NORMAL = 50,
00172 FONTSETWIDTH_REGULAR = 50,
00173 FONTSETWIDTH_SEMIEXPANDED = 60,
00174 FONTSETWIDTH_EXPANDED = 70,
00175 FONTSETWIDTH_WIDE = 80,
00176 FONTSETWIDTH_EXTRAEXPANDED = 80,
00177 FONTSETWIDTH_ULTRAEXPANDED = 90
00178 };
00179
00180
00181
00182
struct FXFontDesc {
00183 FXchar face[104];
00184 FXuint size;
00185 FXuint weight;
00186 FXuint slant;
00187 FXuint setwidth;
00188 FXuint encoding;
00189 FXuint flags;
00190 };
00191
00192
00193
00194
class FXAPI FXFont :
public FXId {
00195
friend class FXDCWindow;
00196 FXDECLARE(FXFont)
00197 protected:
00198 FXString wantedName;
00199 FXString actualName;
00200 FXuint wantedSize;
00201 FXuint actualSize;
00202 FXuint wantedWeight;
00203 FXuint actualWeight;
00204 FXuint wantedSlant;
00205 FXuint actualSlant;
00206 FXuint wantedSetwidth;
00207 FXuint actualSetwidth;
00208 FXuint wantedEncoding;
00209 FXuint actualEncoding;
00210 FXuint hints;
00211
void *font;
00212 private:
00213 #ifdef WIN32
00214 FXID dc;
00215 #endif
00216 protected:
00217 FXFont();
00218 #ifndef WIN32
00219
char* findbestfont(
char* fontname);
00220
char* findmatch(
char* fontname,const
char* forge,const
char* family);
00221 #endif
00222 private:
00223 FXFont(const FXFont&);
00224 FXFont &operator=(const FXFont&);
00225 public:
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 FXFont(
FXApp* a,const
FXString& string);
00248
00249
00250
00251
00252
00253
00254
00255 FXFont(
FXApp* a,const
FXString& face,FXuint sz,FXuint wt=FONTWEIGHT_NORMAL,FXuint sl=FONTSLANT_REGULAR,FXuint enc=FONTENCODING_DEFAULT,FXuint setw=FONTSETWIDTH_DONTCARE,FXuint h=0);
00256
00257
00258 FXFont(
FXApp* a,const
FXFontDesc& fontdesc);
00259
00260
00261 virtual
void create();
00262
00263
00264 virtual
void detach();
00265
00266
00267 virtual
void destroy();
00268
00269
00270 FXString getName()
const {
return wantedName; }
00271
00272
00273 FXString getActualName()
const {
return actualName; }
00274
00275
00276 FXuint getSize()
const {
return wantedSize; }
00277
00278
00279 FXuint getActualSize()
const {
return actualSize; }
00280
00281
00282 FXuint getWeight()
const {
return wantedWeight; }
00283
00284
00285 FXuint getActualWeight()
const {
return actualWeight; }
00286
00287
00288 FXuint getSlant()
const {
return wantedSlant; }
00289
00290
00291 FXuint getActualSlant()
const {
return actualSlant; }
00292
00293
00294 FXuint getEncoding()
const {
return wantedEncoding; }
00295
00296
00297 FXuint getActualEncoding()
const {
return actualEncoding; }
00298
00299
00300 FXuint getSetWidth()
const {
return wantedSetwidth; }
00301
00302
00303 FXuint getActualSetWidth()
const {
return actualSetwidth; }
00304
00305
00306 FXuint getHints()
const {
return hints; }
00307
00308
00309
void setFontDesc(
const FXFontDesc& fontdesc);
00310
00311
00312
void getFontDesc(
FXFontDesc& fontdesc)
const;
00313
00314
00315
00316
00317 FXbool setFont(
const FXString& string);
00318
00319
00320
00321
00322
00323
FXString getFont() const;
00324
00325
00326 FXbool isFontMono() const;
00327
00328
00329 FXbool hasChar(FXint ch) const;
00330
00331
00332 FXint getMinChar() const;
00333
00334
00335 FXint getMaxChar() const;
00336
00337
00338 FXint leftBearing(FXchar ch) const;
00339
00340
00341 FXint rightBearing(FXchar ch) const;
00342
00343
00344 FXint getFontWidth() const;
00345
00346
00347 FXint getFontHeight() const;
00348
00349
00350 FXint getFontAscent() const;
00351
00352
00353 FXint getFontDescent() const;
00354
00355
00356 FXint getFontLeading() const;
00357
00358
00359 FXint getFontSpacing() const;
00360
00361
00362 FXint getTextWidth(const FXchar *text,FXuint n) const;
00363
00364
00365 FXint getTextWidth(const
FXString& text) const;
00366
00367
00368 FXint getTextHeight(const FXchar *text,FXuint n) const;
00369
00370
00371 FXint getTextHeight(const
FXString& text) const;
00372
00373
00374
00375
00376
00377
00378 static FXbool listFonts(
FXFontDesc*& fonts,FXuint& numfonts,const
FXString& face,FXuint wt=FONTWEIGHT_DONTCARE,FXuint sl=FONTSLANT_DONTCARE,FXuint sw=FONTSETWIDTH_DONTCARE,FXuint en=FONTENCODING_DEFAULT,FXuint h=0);
00379
00380
00381 virtual
void save(
FXStream& store) const;
00382
00383
00384 virtual
void load(
FXStream& store);
00385
00386
00387 virtual ~FXFont();
00388 };
00389
00390
00391
00392
00393 extern FXAPI FXbool fxparsefontdesc(
FXFontDesc& fontdesc,const FXchar* string);
00394
00395
00396 extern FXAPI FXbool fxunparsefontdesc(FXchar *string,const
FXFontDesc& fontdesc);
00397
00398 }
00399
00400 #endif