MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_indexed_font_resource.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_INDEXED_FONT_RESOURCE_H_1682214465
12#define INCGUARD_MGL_INDEXED_FONT_RESOURCE_H_1682214465
13
14#include <climits>
15
17
19
20namespace MGL::Render
21{
24{
25public:
26 IndexedFontResource(FontOrigin originType) noexcept;
27
28 ~IndexedFontResource() noexcept override = default;
29
30 /* ------------------------------------------------------------------------- */
37 /* ------------------------------------------------------------------------- */
38 [[nodiscard]] virtual size_t GetIndex(char32_t character, FontFaceType faceType) const noexcept = 0;
39
40 /* ------------------------------------------------------------------------- */
48 /* ------------------------------------------------------------------------- */
49 [[nodiscard]] virtual const FontGlyph *GetGlyph(size_t index, FontFaceType faceType, const FontOption &option) const noexcept = 0;
50
51 /* ------------------------------------------------------------------------- */
58 /* ------------------------------------------------------------------------- */
59 [[nodiscard]] bool HasFontFace(FontFaceType faceType) const noexcept override = 0;
60
61 /* ------------------------------------------------------------------------- */
67 /* ------------------------------------------------------------------------- */
68 [[nodiscard]] bool IsValid() const noexcept override = 0;
69
70 /* ------------------------------------------------------------------------- */
75 /* ------------------------------------------------------------------------- */
76 [[nodiscard]] virtual float GetLineAdvance() const noexcept = 0;
77
78 /* ------------------------------------------------------------------------- */
83 /* ------------------------------------------------------------------------- */
84 [[nodiscard]] virtual float GetRubyOffset() const noexcept
85 {
86 return 0.0f;
87 }
88
89private:
90 bool Print(
91 FontWorkdata &workdata,
92 const FontOption &option,
93 const char *text,
94 const Text::FormatArgs &formatArgs) noexcept final;
95
96 bool Print(
97 FontWorkdata &workdata,
98 const FontOption &option,
99 const Text::IndexedCharacter *indexedString,
100 const Text::FormatArgs &formatArgs) noexcept final;
101
102 [[nodiscard]] Text::IndexedCharacter ToIndexedCharacter(char32_t character, FontFaceType faceType) const noexcept final;
103 [[nodiscard]] char32_t ToUTF32(Text::IndexedCharacter indexedCharacter, FontFaceType faceType) const noexcept final;
104
105 [[nodiscard]] const FontGlyph *GetGlyph(char32_t character, FontFaceType faceType, const FontOption &option) const noexcept final;
106 [[nodiscard]] const FontGlyph *GetGlyph(Text::IndexedCharacter character, FontFaceType faceType, const FontOption &option) const noexcept final;
107
108 // 表示用パラメータの構造体
109 struct Work
110 {
111 Renderer2D &renderer; // 2Dレンダラ
112 DrawOption2D drawOption; // 2Dレンダラの描画オプション
113 Vector2 position; // 表示位置
114 FontFaceType faceType{FontFaceType::Default}; // フェイスタイプ
115 int32_t remainCount{-1}; // 残り表示数
116
117 // コンストラクタ
118 constexpr Work(Renderer2D &renderer_) noexcept
119 : renderer(renderer_)
120 {
121 }
122 };
123
124 const Text::IndexedCharacter *PrintLine(
125 Work &work,
126 const FontOption &fontOption,
127 const Text::IndexedCharacter *indexedString) noexcept;
128
129 const Text::IndexedCharacter *PrintRuby(
130 Work &work,
131 const FontOption &fontOption,
132 const Text::IndexedCharacter *indexedString) noexcept;
133
134 float GetLineWidth(
135 const Work &work,
136 const FontOption &fontOption,
137 const Text::IndexedCharacter *indexedString) noexcept;
138
139 const Text::IndexedCharacter *GetRubyWidth(
140 float &baseTextWidth,
141 float &rubyTextWidth,
142 uint32_t &baseTextCount,
143 const Text::IndexedCharacter *indexedString,
144 FontFaceType faceType,
145 const FontOption &fontOption) const noexcept;
146
147 [[nodiscard]] static FontFaceType GetFontFaceType(Text::FaceTypeIndex index) noexcept;
148};
149} // namespace MGL::Render
150
151#endif // INCGUARD_MGL_INDEXED_FONT_RESOURCE_H_1682214465
152
153// vim: et ts=4 sw=4 sts=4
2D描画オプション
Definition mgl_draw_option_2d.h:23
フォントリソースクラス
Definition mgl_font_resource.h:24
MGL インデックス化対応のフォントリソース基底クラス
Definition mgl_indexed_font_resource.h:24
virtual float GetRubyOffset() const noexcept
ルビのオフセット値を取得
Definition mgl_indexed_font_resource.h:84
bool HasFontFace(FontFaceType faceType) const noexcept override=0
指定した書体を保持しているかを取得
virtual const FontGlyph * GetGlyph(size_t index, FontFaceType faceType, const FontOption &option) const noexcept=0
グリフを取得
IndexedFontResource(FontOrigin originType) noexcept
コンストラクタ
Definition mgl_indexed_font_resource.cc:21
bool IsValid() const noexcept override=0
このフォントリソースが有効かどうかを取得
virtual float GetLineAdvance() const noexcept=0
改行の送りサイズを取得
virtual size_t GetIndex(char32_t character, FontFaceType faceType) const noexcept=0
グリフのインデックスを取得
2Dレンダラクラス
Definition mgl_renderer_2d.h:24
FontOrigin
フォントの原点
Definition mgl_font_defs.h:52
FontFaceType
フォントのフェイスタイプ
Definition mgl_font_defs.h:21
MGL フォントリソース
MGL 2Dレンダラ
uint16_t IndexedCharacter
インデックス化文字
Definition mgl_text_defs.h:30
STL::vector< FormatArgument > FormatArgs
テキストフォーマットの引数の配列
Definition mgl_text_format_argument.h:282
グリフ情報
Definition mgl_font_glyph.h:20
フォント描画オプション
Definition mgl_font_option.h:22
フォント描画のワークデータ
Definition mgl_font_defs.h:59
2Dベクトル
Definition mgl_vector2.h:23