Skip to content
LeviMC
English
AutoLightDark
LeviLamina
Loading...
Searching...
No Matches
Font.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/file/PathBuffer.h"
7#include "mc/deps/core/math/Color.h"
8#include "mc/deps/core/math/Vec2.h"
9#include "mc/deps/core/utility/NonOwnerPointer.h"
10#include "mc/deps/minecraft_renderer/renderer/MaterialPtr.h"
11#include "mc/deps/minecraft_renderer/renderer/Mesh.h"
12#include "mc/deps/minecraft_renderer/renderer/TexturePtr.h"
13#include "mc/deps/minecraft_renderer/renderer/Type.h"
14
15// auto generated forward declare list
16// clang-format off
19class ScreenContext;
20class Tessellator;
22namespace Core { class Path; }
23namespace mce { class TextureGroup; }
24namespace mce::Font { struct RenderingParameters; }
25// clang-format on
26
27class Font : public ::std::enable_shared_from_this<::Font> {
28public:
29 // Font inner types declare
30 // clang-format off
31 struct GlyphQuad;
32 struct TextObject;
33 class TextObjectCache;
34 // clang-format on
35
36 // Font inner types define
37 struct GlyphQuad {
38 public:
39 // member variables
40 // NOLINTBEGIN
41 ::ll::TypedStorage<4, 8, ::Vec2> meshUpperLeft;
42 ::ll::TypedStorage<4, 8, ::Vec2> meshSize;
43 ::ll::TypedStorage<4, 8, ::Vec2> textureUpperLeft;
44 ::ll::TypedStorage<4, 8, ::Vec2> textureBottomRight;
45 ::ll::TypedStorage<4, 4, int> shear;
46 ::ll::TypedStorage<4, 16, ::mce::Color> color;
47 // NOLINTEND
48 };
49
50 struct TextObject {
51 public:
52 // TextObject inner types declare
53 // clang-format off
54 struct Page;
55 // clang-format on
56
57 // TextObject inner types define
58 struct Page {
59 public:
60 // member variables
61 // NOLINTBEGIN
62 ::ll::TypedStorage<8, 608, ::mce::Mesh> mMesh;
63 ::ll::TypedStorage<8, 32, ::mce::TexturePtr> mTexture;
64 ::ll::TypedStorage<4, 4, int> mSheet;
65 // NOLINTEND
66 };
67
68 public:
69 // member variables
70 // NOLINTBEGIN
71 ::ll::TypedStorage<8, 24, ::std::vector<::Font::TextObject::Page>> mPages;
72 ::ll::TypedStorage<4, 16, ::mce::Color> mColor;
73 ::ll::TypedStorage<1, 1, bool> mContainsUnicode;
74 ::ll::TypedStorage<1, 1, bool> mShadow;
75 // NOLINTEND
76
77 public:
78 // member functions
79 // NOLINTBEGIN
80 MCNAPI void render(
81 ::ScreenContext& screenContext,
82 ::Font const& font,
83 ::mce::MaterialPtr const* optionalMat,
84 ::OffscreenCaptureDescription const& offscreenCaptureDescription
85 ) const;
86 // NOLINTEND
87 };
88
89 class TextObjectCache {
90 public:
91 // TextObjectCache inner types define
92 using TextObjects = ::std::vector<::std::shared_ptr<::Font::TextObject>>;
93
94 using TextObjectsPtr = ::std::shared_ptr<::std::vector<::std::shared_ptr<::Font::TextObject>>>;
95
96 public:
97 // member variables
98 // NOLINTBEGIN
99 ::ll::TypedStorage<
100 8,
101 16,
102 ::std::map<
103 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
104 ::std::shared_ptr<::std::vector<::std::shared_ptr<::Font::TextObject>>>,
105 ::std::less<void>>>
106 mEntries;
107 // NOLINTEND
108 };
109
110 using CurrentLineCallback = ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> const;
111
112 using StringCacheStoredKey = ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>;
113
114 using StringCacheLookupKey = ::std::tuple<::std::string_view, ::mce::Color, float, float, bool, bool>;
115
116public:
117 // member variables
118 // NOLINTBEGIN
119 ::ll::TypedStorage<4, 512, ::mce::Color[32]> mColors;
120 ::ll::TypedStorage<4, 4, float> mScalarOverride;
121 ::ll::TypedStorage<8, 24, ::std::vector<::std::tuple<int, int, float>>> mScaleOverrideCharacter;
122 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::mce::TextureGroup>> mTextureGroup;
123 ::ll::TypedStorage<8, 16, ::Font::TextObjectCache> mStringCache;
124 ::ll::TypedStorage<4, 4, int> mObfuscatedIndex;
125 ::ll::TypedStorage<4, 4, float> mObfuscatedTextTime;
126 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderPosition;
127 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderSize;
128 ::ll::TypedStorage<1, 1, bool> mAlwaysUnicode;
129 ::ll::TypedStorage<1, 1, bool> mAutoResetFormat;
130 ::ll::TypedStorage<1, 1, bool> mUseCache;
131 ::ll::TypedStorage<4, 16, ::mce::Color> mCurrentColor;
132 ::ll::TypedStorage<4, 4, int> mFontTexture;
133 ::ll::TypedStorage<4, 16, ::mce::Color> mCaretColor;
134 ::ll::TypedStorage<1, 1, bool> mItalic;
135 ::ll::TypedStorage<1, 1, bool> mBold;
136 ::ll::TypedStorage<1, 1, bool> mStrikethrough;
137 ::ll::TypedStorage<1, 1, bool> mUnderlined;
138 ::ll::TypedStorage<1, 1, bool> mObfuscated;
139 ::ll::TypedStorage<8, 16, ::mce::MaterialPtr> mFontMat;
140 // NOLINTEND
141
142public:
143 // prevent constructor by default
144 Font& operator=(Font const&);
145 Font();
146
147public:
148 // virtual functions
149 // NOLINTBEGIN
150 virtual ~Font();
151
152 virtual void switchFontsource(::Core::Path const& asciiName, ::Core::Path const& unicodeName) = 0;
153
154 virtual ::std::pair<::Core::PathBuffer<::std::string> const&, ::Core::PathBuffer<::std::string> const&>
155 getFontSources() const = 0;
156
157 virtual void fetchPage(int page);
158
159 virtual void drawCached(
160 ::ScreenContext& screenContext,
161 ::std::string_view str,
162 float x,
163 float y,
164 ::mce::Color const& color,
165 bool ignoreColorFormatting,
166 bool darken,
167 bool drawColorSymbol,
168 ::mce::MaterialPtr const* optionalMat,
169 int caretPosition,
170 bool shadow,
171 float linePadding,
172 ::mce::Color const& resetColorOverride,
173 ::mce::Color const& shaderDarkColor,
174 float outlineWidth,
175 float yCaretOffset,
176 ::OffscreenCaptureDescription const& offscreenCaptureDescription,
177 bool autoGenNormalsAndTangents
178 );
179
180 virtual bool supportsChar(int const& character) = 0;
181
182 virtual int getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
183
184 virtual float getWrapHeight() const = 0;
185
186 virtual float getScaleFactor() const = 0;
187
188 virtual float getScaleFactor(int uniChar) const;
189
190 virtual ::Vec2 getTranslationFactor() const;
191
192 virtual bool isScreenPixelAligned() const = 0;
193
194 virtual bool materialCanBeOverridden() const = 0;
195
196 virtual void uploadTextureToGPU() = 0;
197
198 virtual void setTextConstantsInScreenContext(
199 ::ScreenContext& screenContext,
200 int glyphSheet,
201 float guiScale,
202 ::mce::Color const& textColor,
203 bool hasShadow
204 ) const;
205
206 virtual ::mce::Font::Type getType(int glyphSheet) const;
207
208 virtual ::std::optional<::mce::Font::RenderingParameters> tryGetRenderingParameters(
209 ::ScreenContext const& screenContext,
210 int glyphSheet,
211 float guiScale,
212 ::mce::Color const& textColor,
213 bool hasShadow,
214 uint textureWidth,
215 uint textureHeight,
216 bool isUnicode
217 ) const;
218
219 virtual void onAppSuspended();
220
221 virtual void onDeviceLost();
222
223 virtual void
224 reloadFontTextures(::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager, bool blockingLoad);
225
226 virtual bool isReloadingTextures();
227
228 virtual void unloadTextures();
229
230 virtual void onLanguageChanged(::std::string_view languageCode);
231
232 virtual float buildChar(
233 ::std::vector<::Font::GlyphQuad>& quads,
234 int i,
235 ::mce::Color const& color,
236 bool italic,
237 float x,
238 float y,
239 bool unicode
240 ) = 0;
241
242 virtual ::mce::MaterialPtr const& getMaterial(int sheet, bool isOddGuiScale) const = 0;
243
244 virtual float getGlyphHeight(int glyphSheet, bool isUnicode) const;
245
246 virtual void loadFontData(bool uploadTextureImmediately) = 0;
247
248 virtual int _getReplacementCharacter();
249
250 virtual bool _supportsShadowInSingleDraw() = 0;
251
252 virtual float _getCharWidth(int uniChar, bool forceUnicode) = 0;
253
254 virtual void _scanUnicodeCharacterSize(int character, int sheet, bool forceUnicode) = 0;
255
256 virtual ::ResourceLocation _getFontSheetLocation(int sheet, bool forceUnicode) const = 0;
257
258 virtual ::std::string _remapString(::std::string_view str) const;
259
260 virtual uchar _getAsciiSheetCount() const;
261
262 virtual int _getAsciiGlyphsPerPage() const;
263
264 virtual bool _usesLegacyAsciiMapping() const;
265 // NOLINTEND
266
267public:
268 // member functions
269 // NOLINTBEGIN
270 MCNAPI Font(::Font const& rhs);
271
272 MCNAPI explicit Font(::std::shared_ptr<::mce::TextureGroup> textureGroup);
273
274 MCNAPI bool _chopString(
275 ::std::string& currentLine,
276 ::std::string& activeFormatting,
277 float& totalHeight,
278 uint& remainingLineCount,
279 float maxWidth,
280 bool showColorSymbol,
281 bool centered,
282 float fontSize,
283 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> const currentLineCallback,
284 int& outRemainingCharacterCount
285 );
286
287 MCNAPI int _drawWordWrap(
288 ::ScreenContext& screenContext,
289 ::std::string_view str,
290 float x,
291 float y,
292 float w,
293 ::mce::Color const& color,
294 uint maxLine,
295 float fontSize,
296 bool shadow,
297 bool centered,
298 bool showColorSymbol,
299 ::mce::MaterialPtr* optionalMat
300 );
301
302 MCNAPI int _getSheet(int uniChar, int& replacementC, bool forceUnicode);
303
304 MCNAPI int
305 _getStringChopAmount(::std::string_view currentLine, bool showColorSymbol, float maxWidth, bool reserveHyphenWidth);
306
307 MCNAPI ::std::shared_ptr<::Font::TextObject> _makeTextObject(
308 ::Tessellator& tessellator,
309 ::std::string_view str,
310 ::mce::Color const& ccolor,
311 bool showColorSymbol,
312 bool ignoreColorFormatting,
313 int caretPosition,
314 bool shadow,
315 float linePadding,
316 bool isOddGuiScale,
317 ::mce::Color const& resetColorOverride,
318 bool uiMaterial,
319 float outlineWidth,
320 float yCaretOffset,
321 bool autoGenNormalsAndTangents
322 );
323
325 ::std::string_view str,
326 float startX,
327 float startY,
328 float maxWidth,
329 uint maxLine,
330 bool showColorSymbol,
331 bool centered,
332 float fontSize,
333 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> currentLineCallback
334 );
335
336 MCAPI void calculateTextWidths(::std::string_view text, ::std::vector<int>& widths);
337
338 MCNAPI bool containsWideChar(::std::string_view str);
339
340 MCNAPI void drawShadow(
341 ::ScreenContext& screenContext,
342 ::std::string_view str,
343 float x,
344 float y,
345 ::mce::Color const& color,
346 bool showColorSymbol,
347 ::mce::MaterialPtr* optionalMat,
348 float linePadding
349 );
350
351 MCNAPI void drawTransformed(
352 ::ScreenContext& screenContext,
353 ::std::string_view str,
354 float x,
355 float y,
356 ::mce::Color const& color,
357 float angle,
358 float s,
359 bool centered,
360 float maxWidth,
361 bool shadow
362 );
363
365 ::ScreenContext& screenContext,
366 ::std::string_view str,
367 float x,
368 float y,
369 ::mce::Color const& color,
370 ::mce::Color const& resetColor,
371 bool showColorSymbol,
372 ::mce::MaterialPtr* optionalMat,
373 int caretPosition,
374 float linePadding,
375 float yCaretOffset
376 );
377
378 MCNAPI ::std::unordered_set<::ResourceLocation> const& getGlyphLocations() const;
379
380 MCNAPI ::std::vector<::ResourceLocation> getReloadFontTextures() const;
381
383 ::std::string_view str,
384 float maxWidth,
385 uint maxLines,
386 bool showColorSymbol,
387 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> currentLineCallback
388 );
389
390 MCNAPI void resetFontData(bool uploadTextureImmediately);
391
392 MCNAPI bool supportsString(::std::string_view str);
393 // NOLINTEND
394
395public:
396 // static functions
397 // NOLINTBEGIN
399 ::std::string_view textBeforeBreak,
400 ::std::string_view textAfterBreak,
401 bool languageSupportsHyphenSplitting
402 );
403 // NOLINTEND
404
405public:
406 // static variables
407 // NOLINTBEGIN
408 MCNAPI static ::Core::PathBuffer<::std::string> const& NOT_FOUND_PAGE();
409
410 MCNAPI static int const& UNICODE_REPLACEMENT_CHARACTER_CODE();
411 // NOLINTEND
412
413public:
414 // constructor thunks
415 // NOLINTBEGIN
416 MCNAPI void* $ctor(::Font const& rhs);
417
418 MCNAPI void* $ctor(::std::shared_ptr<::mce::TextureGroup> textureGroup);
419 // NOLINTEND
420
421public:
422 // destructor thunk
423 // NOLINTBEGIN
424 MCNAPI void $dtor();
425 // NOLINTEND
426
427public:
428 // virtual function thunks
429 // NOLINTBEGIN
430 MCNAPI void $fetchPage(int page);
431
432 MCAPI void $drawCached(
433 ::ScreenContext& screenContext,
434 ::std::string_view str,
435 float x,
436 float y,
437 ::mce::Color const& color,
438 bool ignoreColorFormatting,
439 bool darken,
440 bool drawColorSymbol,
441 ::mce::MaterialPtr const* optionalMat,
442 int caretPosition,
443 bool shadow,
444 float linePadding,
445 ::mce::Color const& resetColorOverride,
446 ::mce::Color const& shaderDarkColor,
447 float outlineWidth,
448 float yCaretOffset,
449 ::OffscreenCaptureDescription const& offscreenCaptureDescription,
450 bool autoGenNormalsAndTangents
451 );
452
453 MCNAPI int $getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
454
455 MCNAPI float $getScaleFactor(int uniChar) const;
456
457 MCNAPI ::Vec2 $getTranslationFactor() const;
458
460 ::ScreenContext& screenContext,
461 int glyphSheet,
462 float guiScale,
463 ::mce::Color const& textColor,
464 bool hasShadow
465 ) const;
466
467 MCNAPI ::mce::Font::Type $getType(int glyphSheet) const;
468
469 MCNAPI ::std::optional<::mce::Font::RenderingParameters> $tryGetRenderingParameters(
470 ::ScreenContext const& screenContext,
471 int glyphSheet,
472 float guiScale,
473 ::mce::Color const& textColor,
474 bool hasShadow,
475 uint textureWidth,
476 uint textureHeight,
477 bool isUnicode
478 ) const;
479
480 MCNAPI void $onAppSuspended();
481
482 MCNAPI void $onDeviceLost();
483
485 ::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager,
486 bool blockingLoad
487 );
488
489 MCNAPI bool $isReloadingTextures();
490
491 MCNAPI void $unloadTextures();
492
493 MCNAPI void $onLanguageChanged(::std::string_view languageCode);
494
495 MCNAPI float $getGlyphHeight(int glyphSheet, bool isUnicode) const;
496
498
499 MCNAPI ::std::string $_remapString(::std::string_view str) const;
500
501 MCNAPI uchar $_getAsciiSheetCount() const;
502
503 MCNAPI int $_getAsciiGlyphsPerPage() const;
504
505 MCNAPI bool $_usesLegacyAsciiMapping() const;
506 // NOLINTEND
507
508public:
509 // vftables
510 // NOLINTBEGIN
511 MCNAPI static void** $vftable();
512 // NOLINTEND
513};
Definition NonOwnerPointer.h:9
Definition PathBuffer.h:8
Definition Path.h:10
Definition Font.h:28
Definition Font.h:5
MCAPI float $getScaleFactor(int uniChar) const
MCAPI::mce::Font::Type $getType(int glyphSheet) const
MCAPI void $onAppSuspended()
MCAPI void $onDeviceLost()
MCAPI::Vec2 $getTranslationFactor() const
static MCAPI ::Core::PathBuffer<::std::string > const & NOT_FOUND_PAGE()
MCAPI int $_getReplacementCharacter()
MCAPI void * $ctor(::std::shared_ptr<::mce::TextureGroup > textureGroup)
MCAPI int $getLineLength(::std::string_view str, float fontSize, bool showColorSymbol)
MCAPI int _drawWordWrap(::ScreenContext &screenContext, ::std::string_view str, float x, float y, float w, ::mce::Color const &color, uint maxLine, float fontSize, bool shadow, bool centered, bool showColorSymbol, ::mce::MaterialPtr *optionalMat)
MCAPI void drawTransformed(::ScreenContext &screenContext, ::std::string_view str, float x, float y, ::mce::Color const &color, float angle, float s, bool centered, float maxWidth, bool shadow)
MCAPI bool containsWideChar(::std::string_view str)
MCAPI bool supportsString(::std::string_view str)
MCAPI float $getGlyphHeight(int glyphSheet, bool isUnicode) const
MCAPI int processLinesInBox(::std::string_view str, float maxWidth, uint maxLines, bool showColorSymbol, ::std::function< bool(::std::string_view const &, ::std::string &, float, uint &)> currentLineCallback)
MCAPI Font(::Font const &rhs)
MCAPI ::std::shared_ptr<::Font::TextObject > _makeTextObject(::Tessellator &tessellator, ::std::string_view str, ::mce::Color const &ccolor, bool showColorSymbol, bool ignoreColorFormatting, int caretPosition, bool shadow, float linePadding, bool isOddGuiScale, ::mce::Color const &resetColorOverride, bool uiMaterial, float outlineWidth, float yCaretOffset, bool autoGenNormalsAndTangents)
MCAPI void resetFontData(bool uploadTextureImmediately)
MCAPI void $dtor()
MCAPI void $onLanguageChanged(::std::string_view languageCode)
MCAPI::std::string $_remapString(::std::string_view str) const
MCAPI void drawWithColorResetOverride(::ScreenContext &screenContext, ::std::string_view str, float x, float y, ::mce::Color const &color, ::mce::Color const &resetColor, bool showColorSymbol, ::mce::MaterialPtr *optionalMat, int caretPosition, float linePadding, float yCaretOffset)
MCAPI void $setTextConstantsInScreenContext(::ScreenContext &screenContext, int glyphSheet, float guiScale, ::mce::Color const &textColor, bool hasShadow) const
MCAPI ::std::vector<::ResourceLocation > getReloadFontTextures() const
MCAPI uchar $_getAsciiSheetCount() const
MCAPI void $fetchPage(int page)
MCAPI int _getStringChopAmount(::std::string_view currentLine, bool showColorSymbol, float maxWidth, bool reserveHyphenWidth)
MCAPI int $_getAsciiGlyphsPerPage() const
static MCAPI bool shouldInsertHyphenAtLineBreak(::std::string_view textBeforeBreak, ::std::string_view textAfterBreak, bool languageSupportsHyphenSplitting)
MCAPI ::std::optional<::mce::Font::RenderingParameters > $tryGetRenderingParameters(::ScreenContext const &screenContext, int glyphSheet, float guiScale, ::mce::Color const &textColor, bool hasShadow, uint textureWidth, uint textureHeight, bool isUnicode) const
MCAPI ::std::unordered_set<::ResourceLocation > const & getGlyphLocations() const
MCAPI void * $ctor(::Font const &rhs)
MCAPI void $reloadFontTextures(::Bedrock::NonOwnerPointer<::ResourceLoadManager > const &resourceLoadManager, bool blockingLoad)
MCAPI bool $isReloadingTextures()
static MCAPI int const & UNICODE_REPLACEMENT_CHARACTER_CODE()
MCAPI void drawShadow(::ScreenContext &screenContext, ::std::string_view str, float x, float y, ::mce::Color const &color, bool showColorSymbol, ::mce::MaterialPtr *optionalMat, float linePadding)
MCAPI void $unloadTextures()
MCAPI bool _chopString(::std::string &currentLine, ::std::string &activeFormatting, float &totalHeight, uint &remainingLineCount, float maxWidth, bool showColorSymbol, bool centered, float fontSize, ::std::function< bool(::std::string_view const &, ::std::string &, float, uint &)> const currentLineCallback, int &outRemainingCharacterCount)
MCAPI bool $_usesLegacyAsciiMapping() const
static MCAPI void ** $vftable()
MCAPI int _processHeightWrap(::std::string_view str, float startX, float startY, float maxWidth, uint maxLine, bool showColorSymbol, bool centered, float fontSize, ::std::function< bool(::std::string_view const &, ::std::string &, float, uint &)> currentLineCallback)
MCAPI int _getSheet(int uniChar, int &replacementC, bool forceUnicode)
MCAPI Font(::std::shared_ptr<::mce::TextureGroup > textureGroup)
Definition ResourceLoadManager.h:22
Definition ResourceLocation.h:15
Definition ScreenContext.h:5
Definition Tessellator.h:5
Definition Color.h:13
Definition MaterialPtr.h:14
Definition TextureGroup.h:7
Definition Font.h:15
Definition Font.h:25
Definition Font.h:17
MCAPI void render(::ScreenContext &screenContext, ::Font const &font, ::mce::MaterialPtr const *optionalMat, ::OffscreenCaptureDescription const &offscreenCaptureDescription) const
Definition OffscreenCaptureDescription.h:5
Definition RenderingParameters.h:7