FineKernelToolKit
2.8.10
|
00001 /**************************************************************************** 00002 * 00003 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, 00006 * with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 00009 * - Redistributions of source code must retain the above 00010 * copyright notice, this list of conditions and the 00011 * following disclaimer. 00012 * 00013 * - Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the 00015 * following disclaimer in the documentation and/or 00016 * other materials provided with the distribution. 00017 * 00018 * - Neither the name of the copyright holders nor the names 00019 * of its contributors may be used to endorse or promote 00020 * products derived from this software without specific 00021 * prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00031 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00032 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00033 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************/ 00037 /**************************************************************************** 00038 * 00039 * Copyright (c) 1999-2011, Fine Kernel Project, All rights reserved. 00040 * 00041 * 本ソフトウェアおよびソースコードのライセンスは、基本的に 00042 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。 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 virtual ~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__