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 FXFontEncoding {
00036 FONTENCODING_DEFAULT,
00037
00038 FONTENCODING_ISO_8859_1 = 1,
00039 FONTENCODING_ISO_8859_2 = 2,
00040 FONTENCODING_ISO_8859_3 = 3,
00041 FONTENCODING_ISO_8859_4 = 4,
00042 FONTENCODING_ISO_8859_5 = 5,
00043 FONTENCODING_ISO_8859_6 = 6,
00044 FONTENCODING_ISO_8859_7 = 7,
00045 FONTENCODING_ISO_8859_8 = 8,
00046 FONTENCODING_ISO_8859_9 = 9,
00047 FONTENCODING_ISO_8859_10 = 10,
00048 FONTENCODING_ISO_8859_11 = 11,
00049 FONTENCODING_ISO_8859_13 = 13,
00050 FONTENCODING_ISO_8859_14 = 14,
00051 FONTENCODING_ISO_8859_15 = 15,
00052 FONTENCODING_ISO_8859_16 = 16,
00053 FONTENCODING_KOI8 = 17,
00054 FONTENCODING_KOI8_R = 18,
00055 FONTENCODING_KOI8_U = 19,
00056 FONTENCODING_KOI8_UNIFIED = 20,
00057
00058 FONTENCODING_CP437 = 437,
00059 FONTENCODING_CP850 = 850,
00060 FONTENCODING_CP851 = 851,
00061 FONTENCODING_CP852 = 852,
00062 FONTENCODING_CP855 = 855,
00063 FONTENCODING_CP856 = 856,
00064 FONTENCODING_CP857 = 857,
00065 FONTENCODING_CP860 = 860,
00066 FONTENCODING_CP861 = 861,
00067 FONTENCODING_CP862 = 862,
00068 FONTENCODING_CP863 = 863,
00069 FONTENCODING_CP864 = 864,
00070 FONTENCODING_CP865 = 865,
00071 FONTENCODING_CP866 = 866,
00072 FONTENCODING_CP869 = 869,
00073 FONTENCODING_CP870 = 870,
00074
00075 FONTENCODING_CP1250 = 1250,
00076 FONTENCODING_CP1251 = 1251,
00077 FONTENCODING_CP1252 = 1252,
00078 FONTENCODING_CP1253 = 1253,
00079 FONTENCODING_CP1254 = 1254,
00080 FONTENCODING_CP1255 = 1255,
00081 FONTENCODING_CP1256 = 1256,
00082 FONTENCODING_CP1257 = 1257,
00083 FONTENCODING_CP1258 = 1258,
00084 FONTENCODING_CP874 = 874,
00085
00086 FONTENCODING_UNICODE = 9999,
00087
00088 FONTENCODING_LATIN1 = FONTENCODING_ISO_8859_1,
00089 FONTENCODING_LATIN2 = FONTENCODING_ISO_8859_2,
00090 FONTENCODING_LATIN3 = FONTENCODING_ISO_8859_3,
00091 FONTENCODING_LATIN4 = FONTENCODING_ISO_8859_4,
00092 FONTENCODING_LATIN5 = FONTENCODING_ISO_8859_9,
00093 FONTENCODING_LATIN6 = FONTENCODING_ISO_8859_10,
00094 FONTENCODING_LATIN7 = FONTENCODING_ISO_8859_13,
00095 FONTENCODING_LATIN8 = FONTENCODING_ISO_8859_14,
00096 FONTENCODING_LATIN9 = FONTENCODING_ISO_8859_15,
00097 FONTENCODING_LATIN10 = FONTENCODING_ISO_8859_16,
00098
00099 FONTENCODING_USASCII = FONTENCODING_ISO_8859_1,
00100 FONTENCODING_WESTEUROPE = FONTENCODING_ISO_8859_1,
00101 FONTENCODING_EASTEUROPE = FONTENCODING_ISO_8859_2,
00102 FONTENCODING_SOUTHEUROPE = FONTENCODING_ISO_8859_3,
00103 FONTENCODING_NORTHEUROPE = FONTENCODING_ISO_8859_4,
00104 FONTENCODING_CYRILLIC = FONTENCODING_ISO_8859_5,
00105 FONTENCODING_RUSSIAN = FONTENCODING_KOI8,
00106 FONTENCODING_ARABIC = FONTENCODING_ISO_8859_6,
00107 FONTENCODING_GREEK = FONTENCODING_ISO_8859_7,
00108 FONTENCODING_HEBREW = FONTENCODING_ISO_8859_8,
00109 FONTENCODING_TURKISH = FONTENCODING_ISO_8859_9,
00110 FONTENCODING_NORDIC = FONTENCODING_ISO_8859_10,
00111 FONTENCODING_THAI = FONTENCODING_ISO_8859_11,
00112 FONTENCODING_BALTIC = FONTENCODING_ISO_8859_13,
00113 FONTENCODING_CELTIC = FONTENCODING_ISO_8859_14
00114 };
00115
00116
00117
00118 struct FXFontDesc {
00119 FXchar face[116];
00120 FXushort size;
00121 FXushort weight;
00122 FXushort slant;
00123 FXushort setwidth;
00124 FXushort encoding;
00125 FXushort flags;
00126 };
00127
00128
00129 class FXDC;
00130 class FXDCWindow;
00131
00132
00133
00134 class FXAPI FXFont : public FXId {
00135 friend class FXDCWindow;
00136 FXDECLARE(FXFont)
00137 protected:
00138 FXString wantedName;
00139 FXString actualName;
00140 FXushort wantedSize;
00141 FXushort actualSize;
00142 FXushort wantedWeight;
00143 FXushort actualWeight;
00144 FXushort wantedSlant;
00145 FXushort actualSlant;
00146 FXushort wantedSetwidth;
00147 FXushort actualSetwidth;
00148 FXushort wantedEncoding;
00149 FXushort actualEncoding;
00150 FXushort hints;
00151 FXushort flags;
00152 FXshort angle;
00153 void *font;
00154 private:
00155 #ifdef WIN32
00156 FXID dc;
00157 #endif
00158 protected:
00159 FXFont();
00160 void* match(const FXString& wantfamily,const FXString& wantforge,FXuint wantsize,FXuint wantweight,FXuint wantslant,FXuint wantsetwidth,FXuint wantencoding,FXuint wanthints,FXint res);
00161 private:
00162 FXFont(const FXFont&);
00163 FXFont &operator=(const FXFont&);
00164 public:
00165
00166
00167 enum {
00168 Fixed = 1,
00169 Variable = 2
00170 };
00171
00172
00173 enum {
00174 Decorative = 4,
00175 Modern = 8,
00176 Roman = 16,
00177 Script = 32,
00178 Swiss = 64,
00179 System = 128,
00180 X11 = 256,
00181 Scalable = 512,
00182 Polymorphic = 1024,
00183 Rotatable = 2048
00184 };
00185
00186
00187 enum {
00188 ReverseOblique = 1,
00189 ReverseItalic = 2,
00190 Straight = 5,
00191 Italic = 8,
00192 Oblique = 9
00193 };
00194
00195
00196 enum {
00197 Thin = 10,
00198 ExtraLight = 20,
00199 Light = 30,
00200 Normal = 40,
00201 Medium = 50,
00202 DemiBold = 60,
00203 Bold = 70,
00204 ExtraBold = 80,
00205 Black = 90
00206 };
00207
00208
00209 enum {
00210 UltraCondensed = 50,
00211 ExtraCondensed = 63,
00212 Condensed = 75,
00213 SemiCondensed = 87,
00214 NonExpanded = 100,
00215 SemiExpanded = 113,
00216 Expanded = 125,
00217 ExtraExpanded = 150,
00218 UltraExpanded = 200
00219 };
00220
00221 public:
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 FXFont(FXApp* a,const FXString& string);
00241
00242
00243
00244
00245
00246
00247
00248 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);
00249
00250
00251 FXFont(FXApp* a,const FXFontDesc& fontdesc);
00252
00253
00254 virtual void create();
00255
00256
00257 virtual void detach();
00258
00259
00260 virtual void destroy();
00261
00262
00263 FXString getFamily() const;
00264
00265
00266 FXString getFoundry() const;
00267
00268
00269 const FXString& getName() const { return wantedName; }
00270
00271
00272 const FXString& getActualName() const { return actualName; }
00273
00274
00275 FXuint getSize() const { return wantedSize; }
00276
00277
00278 FXuint getActualSize() const { return actualSize; }
00279
00280
00281 FXuint getWeight() const { return wantedWeight; }
00282
00283
00284 FXuint getActualWeight() const { return actualWeight; }
00285
00286
00287 FXuint getSlant() const { return wantedSlant; }
00288
00289
00290 FXuint getActualSlant() const { return actualSlant; }
00291
00292
00293 FXuint getEncoding() const { return wantedEncoding; }
00294
00295
00296 FXuint getActualEncoding() const { return actualEncoding; }
00297
00298
00299 FXuint getSetWidth() const { return wantedSetwidth; }
00300
00301
00302 FXuint getActualSetWidth() const { return actualSetwidth; }
00303
00304
00305 FXuint getHints() const { return hints; }
00306
00307
00308 FXuint getFlags() const { return flags; }
00309
00310
00311 void getFontDesc(FXFontDesc& fontdesc) const;
00312
00313
00314 virtual void setFontDesc(const FXFontDesc& fontdesc);
00315
00316
00317 FXint getAngle() const { return angle; }
00318
00319
00320 virtual void setAngle(FXint ang);
00321
00322
00323
00324
00325
00326 FXString getFont() const;
00327
00328
00329
00330
00331 virtual void setFont(const FXString& string);
00332
00333
00334 virtual FXbool isFontMono() const;
00335
00336
00337 virtual FXbool hasChar(FXwchar ch) const;
00338
00339
00340 virtual FXwchar getMinChar() const;
00341
00342
00343 virtual FXwchar getMaxChar() const;
00344
00345
00346 virtual FXint leftBearing(FXwchar ch) const;
00347
00348
00349 virtual FXint rightBearing(FXwchar ch) const;
00350
00351
00352 virtual FXint getFontWidth() const;
00353
00354
00355 virtual FXint getFontHeight() const;
00356
00357
00358 virtual FXint getFontAscent() const;
00359
00360
00361 virtual FXint getFontDescent() const;
00362
00363
00364 virtual FXint getFontLeading() const;
00365
00366
00367 virtual FXint getFontSpacing() const;
00368
00369
00370 virtual FXint getCharWidth(const FXwchar ch) const;
00371
00372
00373 virtual FXint getTextWidth(const FXString& string) const;
00374
00375
00376 virtual FXint getTextWidth(const FXchar* string,FXuint length) const;
00377
00378
00379 virtual FXint getTextHeight(const FXString& string) const;
00380
00381
00382 virtual FXint getTextHeight(const FXchar *string,FXuint length) const;
00383
00384
00385
00386
00387
00388
00389 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);
00390
00391
00392 virtual void save(FXStream& store) const;
00393
00394
00395 virtual void load(FXStream& store);
00396
00397
00398 virtual ~FXFont();
00399 };
00400
00401
00402 }
00403
00404 #endif