00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef __FK_TEXTIMAGE_HEADER__
00073 #define __FK_TEXTIMAGE_HEADER__
00074
00075 #include <FK/Image.h>
00076 #include <FK/UniCode.h>
00077 #include <FK/Material.h>
00078
00079 #include <string>
00080 #include <vector>
00081
00082 class fk_FTGlyph;
00083 class fk_FTFace;
00084
00086 enum fk_TextAlign {
00087 FK_ALIGN_LEFT,
00088 FK_ALIGN_CENTER,
00089 FK_ALIGN_RIGHT
00090 };
00091
00093 enum fk_TextSendingMode {
00094 FK_SENDING_ALL,
00095 FK_SENDING_CHAR,
00096 FK_SENDING_LINE
00097 };
00098
00099
00101
00136 class fk_TextImage : public fk_Image {
00137 private:
00138
00139 fk_FTFace *face;
00140 int dpi, ptsize;
00141 int boldStrength;
00142 int lineSkip, charSkip, spaceLineSkip;
00143 int maxHeight, maxWidth;
00144 std::vector<fk_Rect> lineArray;
00145 std::vector<fk_Rect> charArray;
00146 std::vector<int> lineMap;
00147 int minWidth;
00148 int upOffset, downOffset, leftOffset, rightOffset;
00149 bool smoothFlg;
00150 fk_Color fgColor, bgColor, shadowColor;
00151 fk_TextAlign alignMode;
00152 std::vector<fk_Image *> charImages;
00153 fk_TextSendingMode sendingMode;
00154 int sendPos;
00155 bool shadowMode;
00156 fk_Dimension shadowOffset;
00157 fk_UniStr strData;
00158
00159 int LayoutGlyphs(std::vector<fk_FTGlyph *> *);
00160 void DumpRasterMap(int, int *, int *,
00161 std::vector<fk_FTGlyph *> *);
00162 void FreeGlyph(std::vector<fk_FTGlyph *> *);
00163
00164 void CalcTextOffset(void);
00165 void ReCalcCharOffset(void);
00166 void InitTextImage(void);
00167 void CopyCharImage(int);
00168 void ClearCharImages(void);
00169 void MakeColorScale(const fk_Color &,
00170 const fk_Color &,
00171 int *);
00172 public:
00174 fk_TextImage(void);
00175
00177 ~fk_TextImage();
00178
00179
00181
00182
00184
00203 bool initFont(const std::string fontFileName);
00204
00206
00221 void setDPI(int dpi);
00222
00224
00231 int getDPI(void) const;
00232
00234
00249 void setPTSize(int size);
00250
00252
00259 int getPTSize(void) const;
00260
00262
00273 void setBoldStrength(int str);
00274
00276
00283 int getBoldStrength(void) const;
00284
00286
00295 void setShadowMode(bool mode);
00296
00298
00305 bool getShadowMode(void) const;
00306
00308
00320 void setShadowOffset(int x, int y);
00321
00323
00330 fk_Dimension getShadowOffset(void) const;
00331
00333
00340 void setShadowColor(fk_Color col);
00341
00343
00354 void setShadowColor(float r, float g, float b, float a);
00355
00357
00368 void setShadowColor(double r, double g, double b, double a);
00369
00371
00378 fk_Color getShadowColor(void) const;
00379
00380
00382
00383
00385
00392 void setForeColor(fk_Color col);
00393
00395
00407 void setForeColor(float r, float g, float b, float a);
00408
00410
00422 void setForeColor(double r, double g, double b, double a);
00423
00425
00432 fk_Color getForeColor(void) const;
00433
00435
00442 void setBackColor(fk_Color col);
00443
00445
00457 void setBackColor(float r, float g, float b, float a);
00458
00460
00472 void setBackColor(double r, double g, double b, double a);
00473
00475
00482 fk_Color getBackColor(void) const;
00483
00485
00497 void setSmoothMode(bool mode);
00498
00500
00507 bool getSmoothMode(void) const;
00508
00509 #ifndef FK_DOXYGEN_USER_PROCESS
00510 void setSmoothFlg(bool);
00511 bool getSmoothFlg(void) const;
00512 #endif
00513
00514
00515
00517
00519
00535 void setCharSkip(int skip);
00536
00538
00546 int getCharSkip(void) const;
00547
00549
00565 void setLineSkip(int skip);
00566
00568
00576 int getLineSkip(void) const;
00577
00579
00595 void setSpaceLineSkip(int skip);
00596
00598
00606 int getSpaceLineSkip(void) const;
00607
00609
00628 void setOffset(int up, int down, int left, int right);
00629
00631
00639 int getUpOffset(void) const;
00640
00642
00650 int getDownOffset(void) const;
00651
00653
00661 int getLeftOffset(void) const;
00662
00664
00672 int getRightOffset(void) const;
00673
00675
00688 void setAlign(fk_TextAlign align);
00689
00691
00698 fk_TextAlign getAlign(void) const;
00699
00701
00723 void setMinLineWidth(int width);
00724
00726
00734 int getMinLineWidth(void) const;
00735
00736
00737
00739
00740
00742
00758 bool loadUniStr(fk_UniStr *str);
00759
00761
00779 bool loadStrFile(const std::string fileName,
00780 fk_StringCode code = FK_STR_UTF16);
00781
00782
00784
00785
00787
00794 int getLineNum(void) const;
00795
00797
00806 int getLineCharNum(int num) const;
00807
00809
00816 int getAllCharNum(void) const;
00817
00819
00830 int getMaxLineWidth(void) const;
00831
00833
00849 int getMaxLineHeight(void) const;
00850
00852
00862 int getLineWidth(int num) const;
00863
00865
00880 int getLineHeight(int num) const;
00881
00883
00894 int getLineStartXPos(int num) const;
00895
00897
00908 int getLineStartYPos(int num) const;
00909
00910
00911
00913
00914
00916
00939 void setSendingMode(fk_TextSendingMode mode);
00940
00942
00949 fk_TextSendingMode getSendingMode(void) const;
00950
00952
00963 bool send(void);
00964
00966
00978 bool finish(void);
00979
00981
00993 bool clear(void);
00994
00995
00996
00998
01000
01029 static void setCacheMode(bool mode);
01030
01032
01040 static bool getCacheMode(void);
01041
01043
01049 static void clearCache(void);
01050
01051 };
01052
01053 #endif // !__FK_TEXTIMAGE_HEADER__