3#include "mc/_HeaderOutputPredefine.h"
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"
25namespace Core {
class Path; }
30class Font :
public ::std::enable_shared_from_this<::Font> {
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;
64 ::ll::TypedStorage<8, 552, ::mce::Mesh> mMesh;
65 ::ll::TypedStorage<8, 32, ::mce::TexturePtr> mTexture;
66 ::ll::TypedStorage<4, 4, int> mSheet;
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;
83 ::ScreenContext& screenContext,
85 ::mce::MaterialPtr
const* optionalMat,
88 ::UIActorOffscreenCaptureDescription,
89 ::UIThumbnailMeshOffscreenCaptureDescription,
90 ::UIMeshOffscreenCaptureDescription,
91 ::UIStructureVolumeOffscreenCaptureDescription>
const& offscreenCaptureDescription
104 using CurrentLineCallback = ::std::function<bool(::std::string_view
const&, ::std::string&,
float, uint&)>
const;
106 using StringCacheStoredKey = ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>;
108 using StringCacheLookupKey = ::std::tuple<::std::string_view, ::mce::Color, float, float, bool, bool>;
110 using StringCache = ::std::map<
111 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
112 ::std::vector<::std::shared_ptr<::Font::TextObject>>,
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;
126 ::std::tuple<::std::string, ::mce::Color, float, float, bool, bool>,
127 ::std::vector<::std::shared_ptr<::Font::TextObject>>,
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;
150 Font& operator=(Font
const&);
158 virtual void switchFontsource(::Core::Path
const& asciiName, ::Core::Path
const& unicodeName) = 0;
160 virtual ::std::pair<::Core::PathBuffer<::std::string>
const&, ::Core::PathBuffer<::std::string>
const&>
161 getFontSources()
const = 0;
163 virtual void fetchPage(
int page);
165 virtual void drawCached(
166 ::ScreenContext& screenContext,
167 ::std::string_view str,
170 ::mce::Color
const& color,
171 bool ignoreColorFormatting,
173 bool drawColorSymbol,
174 ::mce::MaterialPtr
const* optionalMat,
178 ::mce::Color
const& resetColorOverride,
179 ::mce::Color
const& shaderDarkColor,
184 ::UIActorOffscreenCaptureDescription,
185 ::UIThumbnailMeshOffscreenCaptureDescription,
186 ::UIMeshOffscreenCaptureDescription,
187 ::UIStructureVolumeOffscreenCaptureDescription>
const& offscreenCaptureDescription,
188 bool autoGenNormalsAndTangents
191 virtual bool supportsChar(
int const& character) = 0;
193 virtual int getLineLength(::std::string_view str,
float fontSize,
bool showColorSymbol);
195 virtual float getWrapHeight()
const = 0;
197 virtual float getScaleFactor()
const = 0;
199 virtual float getScaleFactor(
int c)
const;
201 virtual ::Vec2 getTranslationFactor()
const;
203 virtual bool isScreenPixelAligned()
const = 0;
205 virtual bool materialCanBeOverridden()
const = 0;
207 virtual void uploadTextureToGPU() = 0;
209 virtual void setTextConstantsInScreenContext(
210 ::ScreenContext& screenContext,
213 ::mce::Color
const& textColor,
217 virtual ::mce::Font::Type getType(
int glyphSheet)
const;
219 virtual ::std::optional<::mce::Font::RenderingParameters> tryGetRenderingParameters(
220 ::ScreenContext
const& screenContext,
223 ::mce::Color
const& textColor,
229 virtual void onAppSuspended();
231 virtual void onDeviceLost();
234 reloadFontTextures(::Bedrock::NonOwnerPointer<::ResourceLoadManager>
const& resourceLoadManager,
bool blockingLoad);
236 virtual bool isReloadingTextures();
238 virtual void unloadTextures();
240 virtual void onLanguageChanged(::std::string_view languageCode);
242 virtual float buildChar(
243 ::std::vector<::Font::GlyphQuad>& quads,
245 ::mce::Color
const& color,
252 virtual ::mce::MaterialPtr
const& getMaterial(
int sheet,
bool isOddGuiScale)
const = 0;
254 virtual void loadFontData(
bool uploadTextureImmediately) = 0;
256 virtual int _getReplacementCharacter();
258 virtual bool _supportsShadowInSingleDraw() = 0;
260 virtual float _getCharWidth(
int uniChar,
bool forceUnicode) = 0;
262 virtual void _scanUnicodeCharacterSize(
int character,
int sheet,
bool forceUnicode) = 0;
264 virtual ::ResourceLocation _getFontSheetLocation(
int sheet,
bool forceUnicode)
const = 0;
266 virtual ::std::string _remapString(::std::string_view str)
const;
272 MCAPI Font(::Font
const& rhs);
274 MCAPI
explicit Font(::std::shared_ptr<::mce::TextureGroup> textureGroup);
276 MCAPI
bool _chopString(
277 ::std::string& currentLine,
278 ::std::string& activeFormatting,
280 uint& remainingLineCount,
282 bool showColorSymbol,
284 float currentLineCallback,
285 ::std::function<
bool(::std::string_view
const&, ::std::string&,
float, uint&)>
288 MCAPI
void _drawTextSegment(
289 ::ScreenContext& screenContext,
290 ::std::string_view str,
293 ::mce::Color
const& centered,
295 bool showColorSymbol,
300 MCAPI
int _drawWordWrap(
301 ::ScreenContext& screenContext,
302 ::std::string_view str,
306 ::mce::Color
const& color,
311 bool showColorSymbol,
312 ::mce::MaterialPtr* optionalMat
315 MCAPI
int _getSheet(
int uniChar,
int& replacementC,
bool forceUnicode);
317 MCAPI
int _getStringChopAmount(::std::string_view currentLine,
bool showColorSymbol,
float maxWidth);
319 MCAPI
bool _isSpace(
int codepoint)
const;
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,
331 ::mce::Color
const& resetColorOverride,
335 bool autoGenNormalsAndTangents
338 MCAPI
int _processHeightWrap(
339 ::std::string_view str,
343 uint showColorSymbol,
346 float currentLineCallback,
347 ::std::function<
bool(::std::string_view
const&, ::std::string&,
float, uint&)>
350 MCAPI
void calculateTextWidths(::std::string_view text, ::std::vector<int>& widths);
352 MCFOLD
void clearCache();
355 ::ScreenContext& screenContext,
356 ::std::string_view str,
359 ::mce::Color
const& color,
360 bool showColorSymbol,
361 ::mce::MaterialPtr* optionalMat,
366 ::UIActorOffscreenCaptureDescription,
367 ::UIThumbnailMeshOffscreenCaptureDescription,
368 ::UIMeshOffscreenCaptureDescription,
369 ::UIStructureVolumeOffscreenCaptureDescription>
const& offscreenCaptureDescription
372 MCAPI
void drawOutline(
373 ::ScreenContext& screenContext,
374 ::std::string_view str,
377 ::mce::Color
const& textColor,
378 ::mce::Color
const& outlineColor,
379 bool showColorSymbol,
380 ::mce::MaterialPtr* optionalMat,
384 MCAPI
void drawShadow(
385 ::ScreenContext& screenContext,
386 ::std::string_view str,
389 ::mce::Color
const& color,
390 bool showColorSymbol,
391 ::mce::MaterialPtr* optionalMat,
395 MCAPI
void drawTransformed(
396 ::ScreenContext& screenContext,
397 ::std::string_view str,
400 ::mce::Color
const& color,
408 MCAPI
void drawWithColorResetOverride(
409 ::ScreenContext& screenContext,
410 ::std::string_view str,
413 ::mce::Color
const& color,
414 ::mce::Color
const& resetColor,
415 bool showColorSymbol,
416 ::mce::MaterialPtr* optionalMat,
422 MCAPI
int drawWordWrap(
423 ::ScreenContext& screenContext,
424 ::std::string_view str,
428 ::mce::Color
const& color,
432 bool showColorSymbol,
433 ::mce::MaterialPtr* optionalMat
436 MCAPI
int drawWordWrapMaxLine(
437 ::ScreenContext& screenContext,
438 ::std::string_view str,
442 ::mce::Color
const& color,
447 bool showColorSymbol,
448 ::mce::MaterialPtr* optionalMat
451 MCFOLD
bool getAlwaysUnicode()
const;
453 MCAPI
float getBaseFontHeight()
const;
455 MCFOLD ::Vec2
const& getCaretRenderPosition()
const;
457 MCFOLD ::Vec2
const& getCaretRenderSize()
const;
459 MCAPI ::std::unordered_set<::ResourceLocation>
const& getGlyphLocations()
const;
461 MCAPI ::std::vector<::ResourceLocation> getReloadFontTextures()
const;
463 MCAPI
int getTextHeight(::std::string_view str,
float fontSize);
465 MCAPI
int getTextHeight(::std::string_view str,
int w,
float fontSize,
bool showColorSymbol);
467 MCAPI
bool hasFormattingCodes(::std::string_view str)
const;
469 MCAPI
bool hasGlyphLocation(::ResourceLocation
const& location)
const;
471 MCAPI
void notifyStringChange(
472 ::std::string_view str,
473 ::mce::Color
const& color,
477 bool hasNormalsAndTangents
480 MCAPI
int processLinesInBox(
481 ::std::string_view str,
484 bool showColorSymbol,
485 ::std::function<
bool(::std::string_view
const&, ::std::string&,
float, uint&)> currentLineCallback
488 MCAPI
void resetFontData(
bool uploadTextureImmediately);
490 MCAPI
void resetFormat(::mce::Color
const& color);
492 MCFOLD
void setAlwaysUnicode(
bool isAlwaysUnicode);
494 MCAPI
bool supportsString(::std::string_view str);
496 MCAPI
void tickObfuscatedTextIndex(
float deltaTime,
float obfuscateSwitchTime);
502 MCAPI
static bool containsWideChar(::std::string_view str);
504 MCAPI
static bool isNonSpacingMark(uint c);
510 MCAPI
static int const& DEFAULT_FONT_HEIGHT();
512 MCAPI
static int const& DEFAULT_WRAP_HEIGHT();
514 MCAPI static ::Core::PathBuffer<::std::string>
const& NOT_FOUND_PAGE();
516 MCAPI
static float const& OBFUSCATED_TIME_SWITCH();
518 MCAPI
static int const& UNICODE_REPLACEMENT_CHARACTER_CODE();
524 MCAPI
void* $ctor(::Font
const& rhs);
526 MCAPI
void* $ctor(::std::shared_ptr<::mce::TextureGroup> textureGroup);
538 MCFOLD
void $fetchPage(
int page);
540 MCAPI
void $drawCached(
541 ::ScreenContext& screenContext,
542 ::std::string_view str,
545 ::mce::Color
const& color,
546 bool ignoreColorFormatting,
548 bool drawColorSymbol,
549 ::mce::MaterialPtr
const* optionalMat,
553 ::mce::Color
const& resetColorOverride,
554 ::mce::Color
const& shaderDarkColor,
559 ::UIActorOffscreenCaptureDescription,
560 ::UIThumbnailMeshOffscreenCaptureDescription,
561 ::UIMeshOffscreenCaptureDescription,
562 ::UIStructureVolumeOffscreenCaptureDescription>
const& offscreenCaptureDescription,
563 bool autoGenNormalsAndTangents
566 MCAPI
int $getLineLength(::std::string_view str,
float fontSize,
bool showColorSymbol);
568 MCAPI
float $getScaleFactor(
int c)
const;
570 MCFOLD ::Vec2 $getTranslationFactor()
const;
572 MCFOLD
void $setTextConstantsInScreenContext(
573 ::ScreenContext& screenContext,
576 ::mce::Color
const& textColor,
580 MCFOLD ::mce::Font::Type $getType(
int glyphSheet)
const;
582 MCAPI ::std::optional<::mce::Font::RenderingParameters> $tryGetRenderingParameters(
583 ::ScreenContext
const& screenContext,
586 ::mce::Color
const& textColor,
592 MCFOLD
void $onAppSuspended();
594 MCFOLD
void $onDeviceLost();
596 MCAPI
void $reloadFontTextures(
597 ::Bedrock::NonOwnerPointer<::ResourceLoadManager>
const& resourceLoadManager,
601 MCAPI
bool $isReloadingTextures();
603 MCFOLD
void $unloadTextures();
605 MCFOLD
void $onLanguageChanged(::std::string_view languageCode);
607 MCAPI
int $_getReplacementCharacter();
609 MCAPI ::std::string $_remapString(::std::string_view str)
const;
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 UIActorOffscreenCaptureDescription.h:5
Definition UIMeshOffscreenCaptureDescription.h:5
Definition UIStructureVolumeOffscreenCaptureDescription.h:5
Definition UIThumbnailMeshOffscreenCaptureDescription.h:5
Definition RenderingParameters.h:7