00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXFONT_H
00022 #define FXFONT_H
00023
00024 #ifndef FXID_H
00025 #include "FXId.h"
00026 #endif
00027
00028 namespace FX {
00029
00030
00032 enum FXFontEncoding {
00033 FONTENCODING_DEFAULT,
00034
00035 FONTENCODING_ISO_8859_1 = 1,
00036 FONTENCODING_ISO_8859_2 = 2,
00037 FONTENCODING_ISO_8859_3 = 3,
00038 FONTENCODING_ISO_8859_4 = 4,
00039 FONTENCODING_ISO_8859_5 = 5,
00040 FONTENCODING_ISO_8859_6 = 6,
00041 FONTENCODING_ISO_8859_7 = 7,
00042 FONTENCODING_ISO_8859_8 = 8,
00043 FONTENCODING_ISO_8859_9 = 9,
00044 FONTENCODING_ISO_8859_10 = 10,
00045 FONTENCODING_ISO_8859_11 = 11,
00046 FONTENCODING_ISO_8859_13 = 13,
00047 FONTENCODING_ISO_8859_14 = 14,
00048 FONTENCODING_ISO_8859_15 = 15,
00049 FONTENCODING_ISO_8859_16 = 16,
00050 FONTENCODING_KOI8 = 17,
00051 FONTENCODING_KOI8_R = 18,
00052 FONTENCODING_KOI8_U = 19,
00053 FONTENCODING_KOI8_UNIFIED = 20,
00054
00055 FONTENCODING_CP437 = 437,
00056 FONTENCODING_CP850 = 850,
00057 FONTENCODING_CP851 = 851,
00058 FONTENCODING_CP852 = 852,
00059 FONTENCODING_CP855 = 855,
00060 FONTENCODING_CP856 = 856,
00061 FONTENCODING_CP857 = 857,
00062 FONTENCODING_CP860 = 860,
00063 FONTENCODING_CP861 = 861,
00064 FONTENCODING_CP862 = 862,
00065 FONTENCODING_CP863 = 863,
00066 FONTENCODING_CP864 = 864,
00067 FONTENCODING_CP865 = 865,
00068 FONTENCODING_CP866 = 866,
00069 FONTENCODING_CP869 = 869,
00070 FONTENCODING_CP870 = 870,
00071
00072 FONTENCODING_CP1250 = 1250,
00073 FONTENCODING_CP1251 = 1251,
00074 FONTENCODING_CP1252 = 1252,
00075 FONTENCODING_CP1253 = 1253,
00076 FONTENCODING_CP1254 = 1254,
00077 FONTENCODING_CP1255 = 1255,
00078 FONTENCODING_CP1256 = 1256,
00079 FONTENCODING_CP1257 = 1257,
00080 FONTENCODING_CP1258 = 1258,
00081 FONTENCODING_CP874 = 874,
00082
00083 FONTENCODING_UNICODE = 9999,
00084
00085 FONTENCODING_LATIN1 = FONTENCODING_ISO_8859_1,
00086 FONTENCODING_LATIN2 = FONTENCODING_ISO_8859_2,
00087 FONTENCODING_LATIN3 = FONTENCODING_ISO_8859_3,
00088 FONTENCODING_LATIN4 = FONTENCODING_ISO_8859_4,
00089 FONTENCODING_LATIN5 = FONTENCODING_ISO_8859_9,
00090 FONTENCODING_LATIN6 = FONTENCODING_ISO_8859_10,
00091 FONTENCODING_LATIN7 = FONTENCODING_ISO_8859_13,
00092 FONTENCODING_LATIN8 = FONTENCODING_ISO_8859_14,
00093 FONTENCODING_LATIN9 = FONTENCODING_ISO_8859_15,
00094 FONTENCODING_LATIN10 = FONTENCODING_ISO_8859_16,
00095
00096 FONTENCODING_USASCII = FONTENCODING_ISO_8859_1,
00097 FONTENCODING_WESTEUROPE = FONTENCODING_ISO_8859_1,
00098 FONTENCODING_EASTEUROPE = FONTENCODING_ISO_8859_2,
00099 FONTENCODING_SOUTHEUROPE = FONTENCODING_ISO_8859_3,
00100 FONTENCODING_NORTHEUROPE = FONTENCODING_ISO_8859_4,
00101 FONTENCODING_CYRILLIC = FONTENCODING_ISO_8859_5,
00102 FONTENCODING_RUSSIAN = FONTENCODING_KOI8,
00103 FONTENCODING_ARABIC = FONTENCODING_ISO_8859_6,
00104 FONTENCODING_GREEK = FONTENCODING_ISO_8859_7,
00105 FONTENCODING_HEBREW = FONTENCODING_ISO_8859_8,
00106 FONTENCODING_TURKISH = FONTENCODING_ISO_8859_9,
00107 FONTENCODING_NORDIC = FONTENCODING_ISO_8859_10,
00108 FONTENCODING_THAI = FONTENCODING_ISO_8859_11,
00109 FONTENCODING_BALTIC = FONTENCODING_ISO_8859_13,
00110 FONTENCODING_CELTIC = FONTENCODING_ISO_8859_14
00111 };
00112
00113
00115 struct FXFontDesc {
00116 FXchar face[116];
00117 FXushort size;
00118 FXushort weight;
00119 FXushort slant;
00120 FXushort setwidth;
00121 FXushort encoding;
00122 FXushort flags;
00123
00125 void setFont(const FXString& string);
00126
00128 FXString getFont() const;
00129 };
00130
00131
00132 class FXDC;
00133 class FXDCWindow;
00134
00135
00137 class FXAPI FXFont : public FXId {
00138 friend class FXDCWindow;
00139 FXDECLARE(FXFont)
00140 protected:
00141 FXString wantedName;
00142 FXString actualName;
00143 FXushort wantedSize;
00144 FXushort actualSize;
00145 FXushort wantedWeight;
00146 FXushort actualWeight;
00147 FXushort wantedSlant;
00148 FXushort actualSlant;
00149 FXushort wantedSetwidth;
00150 FXushort actualSetwidth;
00151 FXushort wantedEncoding;
00152 FXushort actualEncoding;
00153 FXushort hints;
00154 FXushort flags;
00155 FXshort angle;
00156 void *font;
00157 private:
00158 #ifdef WIN32
00159 FXID dc;
00160 #endif
00161 protected:
00162 FXFont();
00163 void* match(const FXString& wantfamily,const FXString& wantforge,FXuint wantsize,FXuint wantweight,FXuint wantslant,FXuint wantsetwidth,FXuint wantencoding,FXuint wanthints,FXint res);
00164 private:
00165 FXFont(const FXFont&);
00166 FXFont &operator=(const FXFont&);
00167 public:
00168
00170 enum {
00171 Fixed = 1,
00172 Variable = 2
00173 };
00174
00176 enum {
00177 Decorative = 4,
00178 Modern = 8,
00179 Roman = 16,
00180 Script = 32,
00181 Swiss = 64,
00182 System = 128,
00183 X11 = 256,
00184 Scalable = 512,
00185 Polymorphic = 1024,
00186 Rotatable = 2048
00187 };
00188
00190 enum {
00191 ReverseOblique = 1,
00192 ReverseItalic = 2,
00193 Straight = 5,
00194 Italic = 8,
00195 Oblique = 9
00196 };
00197
00199 enum {
00200 Thin = 10,
00201 ExtraLight = 20,
00202 Light = 30,
00203 Normal = 40,
00204 Medium = 50,
00205 DemiBold = 60,
00206 Bold = 70,
00207 ExtraBold = 80,
00208 Black = 90
00209 };
00210
00212 enum {
00213 UltraCondensed = 50,
00214 ExtraCondensed = 63,
00215 Condensed = 75,
00216 SemiCondensed = 87,
00217 NonExpanded = 100,
00218 SemiExpanded = 113,
00219 Expanded = 125,
00220 ExtraExpanded = 150,
00221 UltraExpanded = 200
00222 };
00223
00224 public:
00225
00243 FXFont(FXApp* a,const FXString& string);
00244
00251 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);
00252
00254 FXFont(FXApp* a,const FXFontDesc& fontdesc);
00255
00257 virtual void create();
00258
00260 virtual void detach();
00261
00263 virtual void destroy();
00264
00266 FXString getFamily() const;
00267
00269 FXString getFoundry() const;
00270
00272 const FXString& getName() const { return wantedName; }
00273
00275 const FXString& getActualName() const { return actualName; }
00276
00278 FXuint getSize() const { return wantedSize; }
00279
00281 FXuint getActualSize() const { return actualSize; }
00282
00284 FXuint getWeight() const { return wantedWeight; }
00285
00287 FXuint getActualWeight() const { return actualWeight; }
00288
00290 FXuint getSlant() const { return wantedSlant; }
00291
00293 FXuint getActualSlant() const { return actualSlant; }
00294
00296 FXuint getEncoding() const { return wantedEncoding; }
00297
00299 FXuint getActualEncoding() const { return actualEncoding; }
00300
00302 FXuint getSetWidth() const { return wantedSetwidth; }
00303
00305 FXuint getActualSetWidth() const { return actualSetwidth; }
00306
00308 FXuint getHints() const { return hints; }
00309
00311 FXuint getFlags() const { return flags; }
00312
00314 virtual void setFontDesc(const FXFontDesc& fontdesc);
00315
00317 FXFontDesc getFontDesc() const;
00318
00320 FXFontDesc getActualFontDesc() const;
00321
00323 FXint getAngle() const { return angle; }
00324
00326 virtual void setAngle(FXint ang);
00327
00332 FXString getFont() const;
00333
00337 virtual void setFont(const FXString& string);
00338
00340 virtual FXbool isFontMono() const;
00341
00343 virtual FXbool hasChar(FXwchar ch) const;
00344
00346 virtual FXwchar getMinChar() const;
00347
00349 virtual FXwchar getMaxChar() const;
00350
00352 virtual FXint leftBearing(FXwchar ch) const;
00353
00355 virtual FXint rightBearing(FXwchar ch) const;
00356
00358 virtual FXint getFontWidth() const;
00359
00361 virtual FXint getFontHeight() const;
00362
00364 virtual FXint getFontAscent() const;
00365
00367 virtual FXint getFontDescent() const;
00368
00370 virtual FXint getFontLeading() const;
00371
00373 virtual FXint getFontSpacing() const;
00374
00376 virtual FXint getCharWidth(const FXwchar ch) const;
00377
00379 virtual FXint getTextWidth(const FXString& string) const;
00380
00382 virtual FXint getTextWidth(const FXchar* string,FXuint length) const;
00383
00385 virtual FXint getTextHeight(const FXString& string) const;
00386
00388 virtual FXint getTextHeight(const FXchar *string,FXuint length) const;
00389
00391 static FXuint styleFromString(const FXString& str);
00392 static FXString stringFromStyle(FXuint style);
00393
00395 static FXuint slantFromString(const FXString& str);
00396 static FXString stringFromSlant(FXuint slant);
00397
00399 static FXuint weightFromString(const FXString& str);
00400 static FXString stringFromWeight(FXuint weight);
00401
00403 static FXuint setWidthFromString(const FXString& str);
00404 static FXString stringFromSetWidth(FXuint setwidth);
00405
00407 static FXuint encodingFromString(const FXString& str);
00408 static FXString stringFromEncoding(FXuint encoding);
00409
00415 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);
00416
00418 virtual void save(FXStream& store) const;
00419
00421 virtual void load(FXStream& store);
00422
00424 virtual ~FXFont();
00425 };
00426
00427
00428 }
00429
00430 #endif