-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EmptyFontMgr when LAF_BACKEND=none
- Loading branch information
Showing
6 changed files
with
86 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// LAF Text Library | ||
// Copyright (c) 2024 Igara Studio S.A. | ||
// | ||
// This file is released under the terms of the MIT license. | ||
// Read LICENSE.txt for more information. | ||
|
||
#include "text/font_mgr.h" | ||
|
||
#include "text/font.h" | ||
#include "text/font_style.h" | ||
#include "text/font_style_set.h" | ||
#include "text/typeface.h" | ||
|
||
namespace text { | ||
|
||
class EmptyTypeface : public Typeface { | ||
public: | ||
EmptyTypeface() { } | ||
FontStyle fontStyle() const override { return FontStyle(); } | ||
}; | ||
|
||
class EmptyFont : public Font { | ||
public: | ||
EmptyFont() { } | ||
FontType type() override { return FontType::Unknown; } | ||
int height() const override { return 0; } | ||
int textLength(const std::string& str) const override { return 0; }; | ||
bool isScalable() const override { return false; } | ||
void setSize(int size) override { } | ||
void setAntialias(bool antialias) override { } | ||
bool hasCodePoint(int codepoint) const override { return false; } | ||
}; | ||
|
||
class EmptyFontStyleSet : public FontStyleSet { | ||
public: | ||
EmptyFontStyleSet() { } | ||
int count() override { return 0; } | ||
void getStyle(int index, | ||
FontStyle& style, | ||
std::string& name) override { } | ||
TypefaceRef typeface(int index) override { | ||
return base::make_ref<EmptyTypeface>(); | ||
} | ||
TypefaceRef matchStyle(const FontStyle& style) override { | ||
return base::make_ref<EmptyTypeface>(); | ||
} | ||
}; | ||
|
||
class EmptyFontMgr : public FontMgr { | ||
public: | ||
EmptyFontMgr() { } | ||
~EmptyFontMgr() { } | ||
FontRef defaultFont(float size) const override { | ||
return base::make_ref<EmptyFont>(); | ||
} | ||
int countFamilies() const override { return 0; } | ||
std::string familyName(int i) const override { return std::string(); } | ||
FontStyleSetRef familyStyleSet(int i) const override { | ||
return base::make_ref<EmptyFontStyleSet>(); | ||
} | ||
FontStyleSetRef matchFamily(const std::string& familyName) const override { | ||
return base::make_ref<EmptyFontStyleSet>(); | ||
} | ||
}; | ||
|
||
// static | ||
FontMgrRef FontMgr::Make() | ||
{ | ||
return base::make_ref<EmptyFontMgr>(); | ||
} | ||
|
||
} // namespace text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters