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;
25namespace Core { class Path; }
26namespace mce { class TextureGroup; }
27namespace mce::Font { struct RenderingParameters; }
28// clang-format on
29
30class Font : public ::std::enable_shared_from_this<::Font> {
31public:
32 // Font inner types declare
33 // clang-format off
34 struct GlyphQuad;
35 struct TextObject;
36 // clang-format on
37
38 // Font inner types define
39 struct GlyphQuad {
40 public:
41 // member variables
42 // NOLINTBEGIN
43 ::ll::TypedStorage<4, 8, ::Vec2> meshUpperLeft;
44 ::ll::TypedStorage<4, 8, ::Vec2> meshSize;
45 ::ll::TypedStorage<4, 8, ::Vec2> textureUpperLeft;
46 ::ll::TypedStorage<4, 8, ::Vec2> textureBottomRight;
47 ::ll::TypedStorage<4, 4, int> shear;
48 ::ll::TypedStorage<4, 16, ::mce::Color> color;
49 // NOLINTEND
50 };
51
52 struct TextObject {
53 public:
54 // TextObject inner types declare
55 // clang-format off
56 struct Page;
57 // clang-format on
58
59 // TextObject inner types define
60 struct Page {
61 public:
62 // member variables
63 // NOLINTBEGIN
64 ::ll::TypedStorage<8, 552, ::mce::Mesh> mMesh;
65 ::ll::TypedStorage<8, 32, ::mce::TexturePtr> mTexture;
66 ::ll::TypedStorage<4, 4, int> mSheet;
67 // NOLINTEND
68 };
69
70 public:
71 // member variables
72 // NOLINTBEGIN
73 ::ll::TypedStorage<8, 24, ::std::vector<::Font::TextObject::Page>> mPages;
74 ::ll::TypedStorage<4, 16, ::mce::Color> mColor;
75 ::ll::TypedStorage<1, 1, bool> mContainsUnicode;
76 ::ll::TypedStorage<1, 1, bool> mShadow;
77 // NOLINTEND
78
79 public:
80 // member functions
81 // NOLINTBEGIN
82 MCAPI void render(
83 ::ScreenContext& screenContext,
84 ::Font const& font,
85 ::mce::MaterialPtr const* optionalMat,
86 ::std::variant<
87 ::std::monostate,
88 ::UIActorOffscreenCaptureDescription,
89 ::UIThumbnailMeshOffscreenCaptureDescription,
90 ::UIMeshOffscreenCaptureDescription,
91 ::UIStructureVolumeOffscreenCaptureDescription> const& offscreenCaptureDescription
92 ) const;
93
94 MCAPI ~TextObject();
95 // NOLINTEND
96
97 public:
98 // destructor thunk
99 // NOLINTBEGIN
100 MCAPI void $dtor();
101 // NOLINTEND
102 };
103
104 using CurrentLineCallback = ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> const;
105
106 using StringCacheStoredKey = ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>;
107
108 using StringCacheLookupKey = ::std::tuple<::std::string_view, ::mce::Color, float, float, bool, bool>;
109
110 using StringCache = ::std::map<
111 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
112 ::std::vector<::std::shared_ptr<::Font::TextObject>>,
113 ::std::less<void>>;
114
115public:
116 // member variables
117 // NOLINTBEGIN
118 ::ll::TypedStorage<4, 512, ::mce::Color[32]> mColors;
119 ::ll::TypedStorage<4, 4, float> mScalarOverride;
120 ::ll::TypedStorage<8, 24, ::std::vector<::std::tuple<int, int, float>>> mScaleOverrideCharacter;
121 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::mce::TextureGroup>> mTextureGroup;
122 ::ll::TypedStorage<
123 8,
124 16,
125 ::std::map<
126 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
127 ::std::vector<::std::shared_ptr<::Font::TextObject>>,
128 ::std::less<void>>>
129 mStringCache;
130 ::ll::TypedStorage<4, 4, int> mObfuscatedIndex;
131 ::ll::TypedStorage<4, 4, float> mObfuscatedTextTime;
132 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderPosition;
133 ::ll::TypedStorage<4, 8, ::Vec2> mCaretRenderSize;
134 ::ll::TypedStorage<1, 1, bool> mAlwaysUnicode;
135 ::ll::TypedStorage<1, 1, bool> mAutoResetFormat;
136 ::ll::TypedStorage<1, 1, bool> mUseCache;
137 ::ll::TypedStorage<4, 16, ::mce::Color> mCurrentColor;
138 ::ll::TypedStorage<4, 4, int> mFontTexture;
139 ::ll::TypedStorage<4, 16, ::mce::Color> mCaretColor;
140 ::ll::TypedStorage<1, 1, bool> mItalic;
141 ::ll::TypedStorage<1, 1, bool> mBold;
142 ::ll::TypedStorage<1, 1, bool> mStrikethrough;
143 ::ll::TypedStorage<1, 1, bool> mUnderlined;
144 ::ll::TypedStorage<1, 1, bool> mObfuscated;
145 ::ll::TypedStorage<8, 16, ::mce::MaterialPtr> mFontMat;
146 // NOLINTEND
147
148public:
149 // prevent constructor by default
150 Font& operator=(Font const&);
151 Font();
152
153public:
154 // virtual functions
155 // NOLINTBEGIN
156 virtual ~Font();
157
158 virtual void switchFontsource(::Core::Path const& asciiName, ::Core::Path const& unicodeName) = 0;
159
160 virtual ::std::pair<::Core::PathBuffer<::std::string> const&, ::Core::PathBuffer<::std::string> const&>
161 getFontSources() const = 0;
162
163 virtual void fetchPage(int page);
164
165 virtual void drawCached(
166 ::ScreenContext& screenContext,
167 ::std::string_view str,
168 float x,
169 float y,
170 ::mce::Color const& color,
171 bool ignoreColorFormatting,
172 bool darken,
173 bool drawColorSymbol,
174 ::mce::MaterialPtr const* optionalMat,
175 int caretPosition,
176 bool shadow,
177 float linePadding,
178 ::mce::Color const& resetColorOverride,
179 ::mce::Color const& shaderDarkColor,
180 float outlineWidth,
181 float yCaretOffset,
182 ::std::variant<
183 ::std::monostate,
184 ::UIActorOffscreenCaptureDescription,
185 ::UIThumbnailMeshOffscreenCaptureDescription,
186 ::UIMeshOffscreenCaptureDescription,
187 ::UIStructureVolumeOffscreenCaptureDescription> const& offscreenCaptureDescription,
188 bool autoGenNormalsAndTangents
189 );
190
191 virtual bool supportsChar(int const& character) = 0;
192
193 virtual int getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
194
195 virtual float getWrapHeight() const = 0;
196
197 virtual float getScaleFactor() const = 0;
198
199 virtual float getScaleFactor(int c) const;
200
201 virtual ::Vec2 getTranslationFactor() const;
202
203 virtual bool isScreenPixelAligned() const = 0;
204
205 virtual bool materialCanBeOverridden() const = 0;
206
207 virtual void uploadTextureToGPU() = 0;
208
209 virtual void setTextConstantsInScreenContext(
210 ::ScreenContext& screenContext,
211 int glyphSheet,
212 float guiScale,
213 ::mce::Color const& textColor,
214 bool hasShadow
215 ) const;
216
217 virtual ::mce::Font::Type getType(int glyphSheet) const;
218
219 virtual ::std::optional<::mce::Font::RenderingParameters> tryGetRenderingParameters(
220 ::ScreenContext const& screenContext,
221 int glyphSheet,
222 float guiScale,
223 ::mce::Color const& textColor,
224 bool hasShadow,
225 uint textureWidth,
226 uint textureHeight
227 ) const;
228
229 virtual void onAppSuspended();
230
231 virtual void onDeviceLost();
232
233 virtual void
234 reloadFontTextures(::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager, bool blockingLoad);
235
236 virtual bool isReloadingTextures();
237
238 virtual void unloadTextures();
239
240 virtual void onLanguageChanged(::std::string_view languageCode);
241
242 virtual float buildChar(
243 ::std::vector<::Font::GlyphQuad>& quads,
244 int i,
245 ::mce::Color const& color,
246 bool italic,
247 float x,
248 float y,
249 bool unicode
250 ) = 0;
251
252 virtual ::mce::MaterialPtr const& getMaterial(int sheet, bool isOddGuiScale) const = 0;
253
254 virtual void loadFontData(bool uploadTextureImmediately) = 0;
255
256 virtual int _getReplacementCharacter();
257
258 virtual bool _supportsShadowInSingleDraw() = 0;
259
260 virtual float _getCharWidth(int uniChar, bool forceUnicode) = 0;
261
262 virtual void _scanUnicodeCharacterSize(int character, int sheet, bool forceUnicode) = 0;
263
264 virtual ::ResourceLocation _getFontSheetLocation(int sheet, bool forceUnicode) const = 0;
265
266 virtual ::std::string _remapString(::std::string_view str) const;
267 // NOLINTEND
268
269public:
270 // member functions
271 // NOLINTBEGIN
272 MCAPI Font(::Font const& rhs);
273
274 MCAPI explicit Font(::std::shared_ptr<::mce::TextureGroup> textureGroup);
275
276 MCAPI bool _chopString(
277 ::std::string& currentLine,
278 ::std::string& activeFormatting,
279 float& totalHeight,
280 uint& remainingLineCount,
281 float maxWidth,
282 bool showColorSymbol,
283 bool fontSize,
284 float currentLineCallback,
285 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)>
286 );
287
288 MCAPI void _drawTextSegment(
289 ::ScreenContext& screenContext,
290 ::std::string_view str,
291 float startX,
292 float startY,
293 ::mce::Color const& centered,
294 bool shadow,
295 bool showColorSymbol,
296 bool optionalMat,
297 ::mce::MaterialPtr*
298 );
299
300 MCAPI int _drawWordWrap(
301 ::ScreenContext& screenContext,
302 ::std::string_view str,
303 float x,
304 float y,
305 float w,
306 ::mce::Color const& color,
307 uint maxLine,
308 float fontSize,
309 bool shadow,
310 bool centered,
311 bool showColorSymbol,
312 ::mce::MaterialPtr* optionalMat
313 );
314
315 MCAPI int _getSheet(int uniChar, int& replacementC, bool forceUnicode);
316
317 MCAPI int _getStringChopAmount(::std::string_view currentLine, bool showColorSymbol, float maxWidth);
318
319 MCAPI bool _isSpace(int codepoint) const;
320
321 MCAPI ::std::shared_ptr<::Font::TextObject> _makeTextObject(
322 ::Tessellator& tessellator,
323 ::std::string_view str,
324 ::mce::Color const& ccolor,
325 bool showColorSymbol,
326 bool ignoreColorFormatting,
327 int caretPosition,
328 bool shadow,
329 float linePadding,
330 bool isOddGuiScale,
331 ::mce::Color const& resetColorOverride,
332 bool uiMaterial,
333 float outlineWidth,
334 float yCaretOffset,
335 bool autoGenNormalsAndTangents
336 );
337
338 MCAPI int _processHeightWrap(
339 ::std::string_view str,
340 float startY,
341 float maxWidth,
342 float maxLine,
343 uint showColorSymbol,
344 bool centered,
345 bool fontSize,
346 float currentLineCallback,
347 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)>
348 );
349
350 MCAPI void calculateTextWidths(::std::string_view text, ::std::vector<int>& widths);
351
352 MCFOLD void clearCache();
353
354 MCAPI void draw(
355 ::ScreenContext& screenContext,
356 ::std::string_view str,
357 float x,
358 float y,
359 ::mce::Color const& color,
360 bool showColorSymbol,
361 ::mce::MaterialPtr* optionalMat,
362 int caretPosition,
363 float linePadding,
364 ::std::variant<
365 ::std::monostate,
366 ::UIActorOffscreenCaptureDescription,
367 ::UIThumbnailMeshOffscreenCaptureDescription,
368 ::UIMeshOffscreenCaptureDescription,
369 ::UIStructureVolumeOffscreenCaptureDescription> const& offscreenCaptureDescription
370 );
371
372 MCAPI void drawOutline(
373 ::ScreenContext& screenContext,
374 ::std::string_view str,
375 float x,
376 float y,
377 ::mce::Color const& textColor,
378 ::mce::Color const& outlineColor,
379 bool showColorSymbol,
380 ::mce::MaterialPtr* optionalMat,
381 float linePadding
382 );
383
384 MCAPI void drawShadow(
385 ::ScreenContext& screenContext,
386 ::std::string_view str,
387 float x,
388 float y,
389 ::mce::Color const& color,
390 bool showColorSymbol,
391 ::mce::MaterialPtr* optionalMat,
392 float linePadding
393 );
394
395 MCAPI void drawTransformed(
396 ::ScreenContext& screenContext,
397 ::std::string_view str,
398 float x,
399 float y,
400 ::mce::Color const& color,
401 float angle,
402 float s,
403 bool centered,
404 float maxWidth,
405 bool shadow
406 );
407
408 MCAPI void drawWithColorResetOverride(
409 ::ScreenContext& screenContext,
410 ::std::string_view str,
411 float x,
412 float y,
413 ::mce::Color const& color,
414 ::mce::Color const& resetColor,
415 bool showColorSymbol,
416 ::mce::MaterialPtr* optionalMat,
417 int caretPosition,
418 float linePadding,
419 float yCaretOffset
420 );
421
422 MCAPI int drawWordWrap(
423 ::ScreenContext& screenContext,
424 ::std::string_view str,
425 float x,
426 float y,
427 float w,
428 ::mce::Color const& color,
429 float fontSize,
430 bool shadow,
431 bool centered,
432 bool showColorSymbol,
433 ::mce::MaterialPtr* optionalMat
434 );
435
436 MCAPI int drawWordWrapMaxLine(
437 ::ScreenContext& screenContext,
438 ::std::string_view str,
439 float x,
440 float y,
441 float w,
442 ::mce::Color const& color,
443 int maxLine,
444 float fontSize,
445 bool shadow,
446 bool centered,
447 bool showColorSymbol,
448 ::mce::MaterialPtr* optionalMat
449 );
450
451 MCFOLD bool getAlwaysUnicode() const;
452
453 MCAPI float getBaseFontHeight() const;
454
455 MCFOLD ::Vec2 const& getCaretRenderPosition() const;
456
457 MCFOLD ::Vec2 const& getCaretRenderSize() const;
458
459 MCAPI ::std::unordered_set<::ResourceLocation> const& getGlyphLocations() const;
460
461 MCAPI ::std::vector<::ResourceLocation> getReloadFontTextures() const;
462
463 MCAPI int getTextHeight(::std::string_view str, float fontSize);
464
465 MCAPI int getTextHeight(::std::string_view str, int w, float fontSize, bool showColorSymbol);
466
467 MCAPI bool hasFormattingCodes(::std::string_view str) const;
468
469 MCAPI bool hasGlyphLocation(::ResourceLocation const& location) const;
470
471 MCAPI void notifyStringChange(
472 ::std::string_view str,
473 ::mce::Color const& color,
474 float linePadding,
475 float outlineWidth,
476 bool uiMaterial,
477 bool hasNormalsAndTangents
478 );
479
480 MCAPI int processLinesInBox(
481 ::std::string_view str,
482 float maxWidth,
483 uint maxLines,
484 bool showColorSymbol,
485 ::std::function<bool(::std::string_view const&, ::std::string&, float, uint&)> currentLineCallback
486 );
487
488 MCAPI void resetFontData(bool uploadTextureImmediately);
489
490 MCAPI void resetFormat(::mce::Color const& color);
491
492 MCFOLD void setAlwaysUnicode(bool isAlwaysUnicode);
493
494 MCAPI bool supportsString(::std::string_view str);
495
496 MCAPI void tickObfuscatedTextIndex(float deltaTime, float obfuscateSwitchTime);
497 // NOLINTEND
498
499public:
500 // static functions
501 // NOLINTBEGIN
502 MCAPI static bool containsWideChar(::std::string_view str);
503
504 MCAPI static bool isNonSpacingMark(uint c);
505 // NOLINTEND
506
507public:
508 // static variables
509 // NOLINTBEGIN
510 MCAPI static int const& DEFAULT_FONT_HEIGHT();
511
512 MCAPI static int const& DEFAULT_WRAP_HEIGHT();
513
514 MCAPI static ::Core::PathBuffer<::std::string> const& NOT_FOUND_PAGE();
515
516 MCAPI static float const& OBFUSCATED_TIME_SWITCH();
517
518 MCAPI static int const& UNICODE_REPLACEMENT_CHARACTER_CODE();
519 // NOLINTEND
520
521public:
522 // constructor thunks
523 // NOLINTBEGIN
524 MCAPI void* $ctor(::Font const& rhs);
525
526 MCAPI void* $ctor(::std::shared_ptr<::mce::TextureGroup> textureGroup);
527 // NOLINTEND
528
529public:
530 // destructor thunk
531 // NOLINTBEGIN
532 MCAPI void $dtor();
533 // NOLINTEND
534
535public:
536 // virtual function thunks
537 // NOLINTBEGIN
538 MCFOLD void $fetchPage(int page);
539
540 MCAPI void $drawCached(
541 ::ScreenContext& screenContext,
542 ::std::string_view str,
543 float x,
544 float y,
545 ::mce::Color const& color,
546 bool ignoreColorFormatting,
547 bool darken,
548 bool drawColorSymbol,
549 ::mce::MaterialPtr const* optionalMat,
550 int caretPosition,
551 bool shadow,
552 float linePadding,
553 ::mce::Color const& resetColorOverride,
554 ::mce::Color const& shaderDarkColor,
555 float outlineWidth,
556 float yCaretOffset,
557 ::std::variant<
558 ::std::monostate,
559 ::UIActorOffscreenCaptureDescription,
560 ::UIThumbnailMeshOffscreenCaptureDescription,
561 ::UIMeshOffscreenCaptureDescription,
562 ::UIStructureVolumeOffscreenCaptureDescription> const& offscreenCaptureDescription,
563 bool autoGenNormalsAndTangents
564 );
565
566 MCAPI int $getLineLength(::std::string_view str, float fontSize, bool showColorSymbol);
567
568 MCAPI float $getScaleFactor(int c) const;
569
570 MCFOLD ::Vec2 $getTranslationFactor() const;
571
572 MCFOLD void $setTextConstantsInScreenContext(
573 ::ScreenContext& screenContext,
574 int glyphSheet,
575 float guiScale,
576 ::mce::Color const& textColor,
577 bool hasShadow
578 ) const;
579
580 MCFOLD ::mce::Font::Type $getType(int glyphSheet) const;
581
582 MCAPI ::std::optional<::mce::Font::RenderingParameters> $tryGetRenderingParameters(
583 ::ScreenContext const& screenContext,
584 int glyphSheet,
585 float guiScale,
586 ::mce::Color const& textColor,
587 bool hasShadow,
588 uint textureWidth,
589 uint textureHeight
590 ) const;
591
592 MCFOLD void $onAppSuspended();
593
594 MCFOLD void $onDeviceLost();
595
596 MCAPI void $reloadFontTextures(
597 ::Bedrock::NonOwnerPointer<::ResourceLoadManager> const& resourceLoadManager,
598 bool blockingLoad
599 );
600
601 MCAPI bool $isReloadingTextures();
602
603 MCFOLD void $unloadTextures();
604
605 MCFOLD void $onLanguageChanged(::std::string_view languageCode);
606
607 MCAPI int $_getReplacementCharacter();
608
609 MCAPI ::std::string $_remapString(::std::string_view str) const;
610 // NOLINTEND
611
612public:
613 // vftables
614 // NOLINTBEGIN
615 MCNAPI static void** $vftable();
616 // NOLINTEND
617};
Definition Path.h:12
Definition Font.h:5
static MCAPI void ** $vftable()
Definition ResourceLoadManager.h:19
Definition ResourceLocation.h:15
Definition ScreenContext.h:5
Definition Tessellator.h:5
Definition TextureGroup.h:7
Definition Font.h:14
Definition Font.h:24
Definition Font.h:16
Definition UIActorOffscreenCaptureDescription.h:5
Definition UIMeshOffscreenCaptureDescription.h:5
Definition UIStructureVolumeOffscreenCaptureDescription.h:5
Definition UIThumbnailMeshOffscreenCaptureDescription.h:5
Definition RenderingParameters.h:7