forked from Mirror/libstarlight
added FontNull, should hopefully prevent crashes from trying to load fonts with no fallback
This commit is contained in:
parent
15dbabd917
commit
e183532747
@ -19,6 +19,7 @@
|
|||||||
#include "starlight/gfx/DrawableNinePatch.h"
|
#include "starlight/gfx/DrawableNinePatch.h"
|
||||||
#include "starlight/gfx/DrawableTest.h"
|
#include "starlight/gfx/DrawableTest.h"
|
||||||
#include "starlight/gfx/FontBMF.h"
|
#include "starlight/gfx/FontBMF.h"
|
||||||
|
#include "starlight/gfx/FontNull.h"
|
||||||
|
|
||||||
#include "starlight/gfx/RenderCore.h"
|
#include "starlight/gfx/RenderCore.h"
|
||||||
#include "starlight/gfx/BitmapFont.h"
|
#include "starlight/gfx/BitmapFont.h"
|
||||||
@ -264,6 +265,10 @@ shared_ptr<Drawable> ThemeManager::LoadAsset(string& path, ThemeRefContainer<Dra
|
|||||||
|
|
||||||
void ThemeManager::Fulfill(ThemeRefContainer<Font>& ref) {
|
void ThemeManager::Fulfill(ThemeRefContainer<Font>& ref) {
|
||||||
string path = ResolveFontPath(ref.name);
|
string path = ResolveFontPath(ref.name);
|
||||||
|
if (path == "") { // no fonts found, emergency fallback
|
||||||
|
ref.ptr = make_shared<starlight::gfx::FontNull>();
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto font = make_shared<starlight::gfx::FontBMF>();
|
auto font = make_shared<starlight::gfx::FontBMF>();
|
||||||
{ // using:
|
{ // using:
|
||||||
json j;
|
json j;
|
||||||
|
@ -14,8 +14,6 @@ namespace starlight {
|
|||||||
namespace gfx {
|
namespace gfx {
|
||||||
class Font {
|
class Font {
|
||||||
public:
|
public:
|
||||||
static constexpr const int defaultSize = 16;
|
|
||||||
|
|
||||||
Font() { }
|
Font() { }
|
||||||
virtual ~Font() { }
|
virtual ~Font() { }
|
||||||
|
|
||||||
|
21
libstarlight/source/starlight/gfx/FontNull.h
Normal file
21
libstarlight/source/starlight/gfx/FontNull.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "starlight/_global.h"
|
||||||
|
|
||||||
|
namespace starlight {
|
||||||
|
namespace gfx {
|
||||||
|
class FontNull : public Font {
|
||||||
|
public:
|
||||||
|
FontNull() { }
|
||||||
|
~FontNull() override { }
|
||||||
|
|
||||||
|
void Print(Vector2 position, const std::string& text, float scale = 1, Color color = Color::white, Vector2 justification = Vector2::zero, OptRef<Color> borderColor = nullptr) override {}
|
||||||
|
void Print(VRect rect, const std::string& text, float scale = 1, Color color = Color::white, Vector2 justification = Vector2::zero, OptRef<Color> borderColor = nullptr) override {}
|
||||||
|
|
||||||
|
Vector2 Measure(const std::string& text, float scale = 1, float maxWidth = 400) override { return Vector2::zero; }
|
||||||
|
|
||||||
|
Vector2 GetCursorPosition(VRect rect, const std::string& text, unsigned int end, float scale = 1) override { return Vector2::zero; }
|
||||||
|
unsigned int GetCursorFromPoint(VRect rect, const std::string& text, Vector2 pt, float scale = 1) override { return Vector2::zero; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
roadmap to v0.5.1 {
|
roadmap to v0.5.1 {
|
||||||
make font-not-found not outright crash the app
|
- make font-not-found not outright crash the app (hopefully)
|
||||||
make asset gc actually sweep every 5sec
|
make asset gc actually sweep every 5sec
|
||||||
maybe entirely replace clearing with transparent knockout on bind?
|
maybe entirely replace clearing with transparent knockout on bind?
|
||||||
implement more blend modes??
|
implement more blend modes??
|
||||||
|
Loading…
x
Reference in New Issue
Block a user