FineKernelToolKit 4.2.13
読み取り中…
検索中…
一致する文字列を見つけられません
TextImage.h
[詳解]
1#if !defined(__FK_TEXTIMAGE_HEADER__)
2#define __FK_TEXTIMAGE_HEADER__
3
4#include <FK/Image.h>
5#include <FK/UniCode.h>
6#include <FK/Material.h>
7
8#include <string>
9#include <vector>
10
11namespace FK {
12 class fk_FTGlyph;
13 class fk_FTFace;
14
16 enum class fk_TextAlign {
17 LEFT,
18 CENTER,
19 RIGHT
20 };
21
23 enum class fk_TextSendingMode {
24 ALL,
25 CHAR,
26 LINE
27 };
28
29
31
66#if !defined(FK_DOXYGEN_USER_PROCESS)
67 using fk_GlyphBuffer = std::vector<unsigned char>;
68#endif
69
70 class fk_TextImage : public fk_Image {
71
72#if !defined(FK_DOXYGEN_USER_PROCESS)
73 class Member {
74 public:
75 std::unique_ptr<fk_FTFace> face;
76 int dpi, ptsize;
77 int boldStrength;
78 int lineSkip, charSkip, spaceLineSkip;
79 int maxHeight, maxWidth;
80 std::vector<fk_Rect> lineArray;
81 std::vector<fk_Rect> charArray;
82 std::vector<int> lineMap;
83 int minWidth;
84 int upOffset, downOffset, leftOffset, rightOffset;
85 bool smoothFlg;
86 fk_Color fgColor, bgColor, shadowColor;
87 fk_TextAlign alignMode;
88 std::vector<std::unique_ptr<fk_Image>> charImages;
89 fk_TextSendingMode sendingMode;
90 int sendPos;
91 bool shadowMode;
92 fk_Dimension shadowOffset;
93 fk_UniStr strData;
94 bool monospaceMode;
95 int monospaceSize;
96
97 Member(void);
98 };
99#endif
100 public:
103
105 virtual ~fk_TextImage();
106
107
110
112
131 bool initFont(const std::string fontFileName);
132
134
149 void setDPI(int dpi);
150
152
159 int getDPI(void) const;
160
162
177 void setPTSize(int size);
178
180
187 int getPTSize(void) const;
188
190
201 void setBoldStrength(int str);
202
204
211 int getBoldStrength(void) const;
212
214
223 void setShadowMode(bool mode);
224
226
233 bool getShadowMode(void) const;
234
236
248 void setShadowOffset(int x, int y);
249
251
259
261
269
271
282 void setShadowColor(float r, float g, float b, float a);
283
285
296 void setShadowColor(double r, double g, double b, double a);
297
299
308
311
313
321
323
335 void setForeColor(float r, float g, float b, float a);
336
338
350 void setForeColor(double r, double g, double b, double a);
351
353
361
363
371
373
385 void setBackColor(float r, float g, float b, float a);
386
388
400 void setBackColor(double r, double g, double b, double a);
401
403
411
413
425 void setSmoothMode(bool mode);
426
428
435 bool getSmoothMode(void) const;
436
437#if !defined(FK_OLD_NONSUPPORT) && !defined(FK_DOXYGEN_USER_PROCESS)
438 void setSmoothFlg(bool);
439 bool getSmoothFlg(void) const;
440#endif
441
442
444
447
449
464 void setMonospaceMode(bool mode);
465
467
474 bool getMonospaceMode(void) const;
475
477
489 void setMonospaceSize(int size);
490
492
499 int getMonospaceSize(void) const;
500
502
518 void setCharSkip(int skip);
519
521
529 int getCharSkip(void) const;
530
532
548 void setLineSkip(int skip);
549
551
559 int getLineSkip(void) const;
560
562
578 void setSpaceLineSkip(int skip);
579
581
589 int getSpaceLineSkip(void) const;
590
592
611 void setOffset(int up, int down, int left, int right);
612
614
622 int getUpOffset(void) const;
623
625
633 int getDownOffset(void) const;
634
636
644 int getLeftOffset(void) const;
645
647
655 int getRightOffset(void) const;
656
658
672
674
682
684
706 void setMinLineWidth(int width);
707
709
717 int getMinLineWidth(void) const;
718
720
723
725
742
744
763 bool loadStrFile(const std::string fileName,
766
769
771
778 int getLineNum(void) const;
779
781
790 int getLineCharNum(int num) const;
791
793
800 int getAllCharNum(void) const;
801
803
814 int getMaxLineWidth(void) const;
815
817
833 int getMaxLineHeight(void) const;
834
836
846 int getLineWidth(int num) const;
847
849
864 int getLineHeight(int num) const;
865
867
878 int getLineStartXPos(int num) const;
879
881
892 int getLineStartYPos(int num) const;
893
895
898
900
924
926
934
936
947 bool send(void);
948
950
962 bool finish(void);
963
965
977 bool clear(void);
978
980
983
985
1014 static void setCacheMode(bool mode);
1015
1017
1025 static bool getCacheMode(void);
1026
1028
1034 static void clearCache(void);
1036
1037 private:
1038 std::unique_ptr<Member> _m;
1039 static constexpr std::string_view _defaultFont {"./fk_font/rm1b.ttf" };
1040
1041 int LayoutGlyphs(std::vector<std::unique_ptr<fk_FTGlyph>> *);
1042 void DumpRasterMap(int, int *, int *, std::vector<std::unique_ptr<fk_FTGlyph>> *);
1043 void FreeGlyph(std::vector<std::unique_ptr<fk_FTGlyph>> *);
1044
1045 void CalcTextOffset(void);
1046 void ReCalcCharOffset(void);
1047 void InitTextImage(void);
1048 void CopyCharImage(int);
1049 void ClearCharImages(void);
1050 void MakeColorScale(const fk_Color &, const fk_Color &, int *);
1051 int GetPixel(fk_GlyphBuffer *, int, int, int, int);
1052 };
1053}
1054
1055#endif // !__FK_TEXTIMAGE_HEADER__
1056
1057/****************************************************************************
1058 *
1059 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
1060 *
1061 * Redistribution and use in source and binary forms,
1062 * with or without modification, are permitted provided that the
1063 * following conditions are met:
1064 *
1065 * - Redistributions of source code must retain the above
1066 * copyright notice, this list of conditions and the
1067 * following disclaimer.
1068 *
1069 * - Redistributions in binary form must reproduce the above
1070 * copyright notice, this list of conditions and the
1071 * following disclaimer in the documentation and/or
1072 * other materials provided with the distribution.
1073 *
1074 * - Neither the name of the copyright holders nor the names
1075 * of its contributors may be used to endorse or promote
1076 * products derived from this software without specific
1077 * prior written permission.
1078 *
1079 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1080 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1081 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1082 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1083 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
1084 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1085 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1086 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1087 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1088 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1089 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1090 * POSSIBILITY OF SUCH DAMAGE.
1091 *
1092 ****************************************************************************/
1093/****************************************************************************
1094 *
1095 * Copyright (c) 1999-2024, Fine Kernel Project, All rights reserved.
1096 *
1097 * 本ソフトウェアおよびソースコードのライセンスは、基本的に
1098 * 「修正 BSD ライセンス」に従います。以下にその詳細を記します。
1099 *
1100 * ソースコード形式かバイナリ形式か、変更するかしないかを問わず、
1101 * 以下の条件を満たす場合に限り、再頒布および使用が許可されます。
1102 *
1103 * - ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、
1104 * および下記免責条項を含めること。
1105 *
1106 * - バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の
1107 * 資料に、上記の著作権表示、本条件一覧、および下記免責条項を
1108 * 含めること。
1109 *
1110 * - 書面による特別の許可なしに、本ソフトウェアから派生した製品の
1111 * 宣伝または販売促進に、本ソフトウェアの著作権者の名前または
1112 * コントリビューターの名前を使用してはならない。
1113 *
1114 * 本ソフトウェアは、著作権者およびコントリビューターによって「現
1115 * 状のまま」提供されており、明示黙示を問わず、商業的な使用可能性、
1116 * および特定の目的に対する適合性に関す暗黙の保証も含め、またそれ
1117 * に限定されない、いかなる保証もないものとします。著作権者もコン
1118 * トリビューターも、事由のいかんを問わず、損害発生の原因いかんを
1119 * 問わず、かつ責任の根拠が契約であるか厳格責任であるか(過失その
1120 * 他の)不法行為であるかを問わず、仮にそのような損害が発生する可
1121 * 能性を知らされていたとしても、本ソフトウェアの使用によって発生
1122 * した(代替品または代用サービスの調達、使用の喪失、データの喪失、
1123 * 利益の喪失、業務の中断も含め、またそれに限定されない)直接損害、
1124 * 間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害に
1125 * ついて、一切責任を負わないものとします。
1126 *
1127 ****************************************************************************/
RGB色を管理するクラス
Definition Color.h:21
画像サイズを表すクラス
Definition Image.h:67
画像を生成、管理するクラス
Definition Image.h:260
文字列板を管理するクラス
Definition TextImage.h:70
int getDPI(void) const
フォント解像度参照関数
fk_Color getBackColor(void) const
背景色参照関数
bool send(void)
文字送り実行関数
virtual ~fk_TextImage()
デストラクタ
void setSendingMode(fk_TextSendingMode mode)
文字送りモード設定関数
int getLineStartYPos(int num) const
行開始位置 y 成分取得関数
void setAlign(fk_TextAlign align)
文字列寄せ方向(アライメント)設定関数
static void setCacheMode(bool mode)
キャッシュ機能制御関数
fk_TextSendingMode getSendingMode(void) const
文字送りモード参照関数
int getRightOffset(void) const
オフセット右幅参照関数
int getLineHeight(int num) const
行縦幅参照関数
bool finish(void)
文字送り完了関数
void setCharSkip(int skip)
文字間幅設定関数
void setForeColor(double r, double g, double b, double a)
文字色設定関数3
void setShadowOffset(int x, int y)
影付けずらし幅設定関数
int getMaxLineHeight(void) const
最大縦幅参照関数
void setSpaceLineSkip(int skip)
空行縦幅設定関数
int getLineSkip(void) const
行間幅参照関数
void setBackColor(double r, double g, double b, double a)
背景色設定関数3
void setForeColor(float r, float g, float b, float a)
文字色設定関数2
int getDownOffset(void) const
オフセット下幅参照関数
bool loadUniStr(fk_UniStr *str)
文字列データ入力関数
int getLineStartXPos(int num) const
行開始位置 x 成分取得関数
void setPTSize(int size)
フォントサイズ設定関数
void setBoldStrength(int str)
太さ値設定関数
bool loadStrFile(const std::string fileName, fk_StringCode code=fk_StringCode::UTF16)
文字列データファイル入力関数
void setLineSkip(int skip)
行間幅設定関数
void setMonospaceMode(bool mode)
等幅表示設定関数
void setMonospaceSize(int size)
等幅表示文字幅設定関数
fk_Color getShadowColor(void) const
影付け色参照関数
static bool getCacheMode(void)
キャッシュ機能有無効参照関数
void setBackColor(float r, float g, float b, float a)
背景色設定関数2
void setDPI(int dpi)
フォント解像度設定関数
int getAllCharNum(void) const
文字数参照関数
int getLineNum(void) const
行数参照関数
fk_Dimension getShadowOffset(void) const
影付けずらし幅参照関数
void setShadowColor(double r, double g, double b, double a)
影付け色設定関数3
void setForeColor(fk_Color col)
文字色設定関数1
int getUpOffset(void) const
オフセット上幅参照関数
fk_Color getForeColor(void) const
文字色参照関数
int getMinLineWidth(void) const
画像最小横幅参照関数
int getCharSkip(void) const
文字間幅参照関数
void setMinLineWidth(int width)
画像最小横幅設定関数
void setShadowColor(float r, float g, float b, float a)
影付け色設定関数2
int getBoldStrength(void) const
太さ値参照関数
int getMonospaceSize(void) const
等幅表示文字幅参照関数
int getLineWidth(int num) const
行横幅参照関数
fk_TextAlign getAlign(void) const
文字列寄せ方向(アライメント)参照関数
int getSpaceLineSkip(void) const
空行縦幅参照関数
bool getMonospaceMode(void) const
等幅表示設定参照関数
void setOffset(int up, int down, int left, int right)
オフセット設定関数
void setShadowMode(bool mode)
影付け効果設定関数
bool getShadowMode(void) const
影付け効果参照関数
static void clearCache(void)
キャッシュ初期化関数
void setShadowColor(fk_Color col)
影付け色設定関数1
int getMaxLineWidth(void) const
最大横幅参照関数
bool initFont(const std::string fontFileName)
フォント情報入力関数
void setBackColor(fk_Color col)
背景色設定関数1
fk_TextImage(void)
コンストラクタ
bool clear(void)
文字送り初期化関数
int getLeftOffset(void) const
オフセット左幅参照関数
void setSmoothMode(bool mode)
アンチエイリアシング効果設定関数
int getLineCharNum(int num) const
行中文字数参照関数
int getPTSize(void) const
フォントサイズ参照関数
bool getSmoothMode(void) const
アンチエイリアシング効果参照関数
文字列板に表示する文字列を制御するクラス
Definition UniCode.h:125
Fine Kernel Toolkit 名前空間
Definition Angle.h:6
fk_TextAlign
文字列板の文字列配置を表す列挙型
Definition TextImage.h:16
@ CENTER
中寄せ
fk_StringCode
日本語文字コードを表す列挙型
Definition UniCode.h:12
@ UTF16
Unicode (UTF-16)
fk_TextSendingMode
文字列板の文字送りモードを表す列挙型
Definition TextImage.h:23
@ LINE
fk_Line 型