Use FontData everywhere
This commit is contained in:
parent
4fe52ef7f6
commit
a99b0e920d
14 changed files with 51 additions and 46 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <include/core/SkFont.h>
|
||||
#include <include/core/SkFontMgr.h>
|
||||
#include <include/core/SkTypeface.h>
|
||||
#include "../../FontData.hpp"
|
||||
#include <modules/skparagraph/include/FontCollection.h>
|
||||
#include <modules/svg/include/SkSVGDOM.h>
|
||||
#include <Helpers/SCollision.hpp>
|
||||
|
|
@ -110,15 +111,12 @@ struct UpdateInputData {
|
|||
|
||||
uint16_t fontSize = 16;
|
||||
|
||||
sk_sp<skia::textlayout::FontCollection> fontCollection;
|
||||
|
||||
std::string textInput;
|
||||
bool hoverObstructed = false;
|
||||
bool acceptingTextInput = false;
|
||||
float deltaTime = 0.0f;
|
||||
|
||||
sk_sp<SkFontMgr> textFontMgrLocal;
|
||||
sk_sp<SkFontMgr> textFontMgrFallback;
|
||||
std::shared_ptr<FontData> fonts;
|
||||
sk_sp<SkTypeface> textTypeface;
|
||||
|
||||
DefaultStringArena* strArena;
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ bool GUIStuff::FontPicker::update(UpdateInputData& io, std::string* fontName, GU
|
|||
auto icu = SkUnicodes::ICU::Make();
|
||||
std::set<std::string> sortedFontSet;
|
||||
|
||||
for(int i = 0; i < io.textFontMgrLocal->countFamilies(); i++) {
|
||||
for(int i = 0; i < io.fonts->localFontMgr->countFamilies(); i++) {
|
||||
SkString familyNameSkString;
|
||||
io.textFontMgrLocal->getFamilyName(i, &familyNameSkString);
|
||||
io.fonts->localFontMgr->getFamilyName(i, &familyNameSkString);
|
||||
if(familyNameSkString.isEmpty())
|
||||
continue;
|
||||
std::string familyName(familyNameSkString.c_str(), familyNameSkString.size());
|
||||
sortedFontSet.emplace(familyName);
|
||||
}
|
||||
for(int i = 0; i < io.textFontMgrFallback->countFamilies(); i++) {
|
||||
for(int i = 0; i < io.fonts->defaultFontMgr->countFamilies(); i++) {
|
||||
SkString familyNameSkString;
|
||||
io.textFontMgrFallback->getFamilyName(i, &familyNameSkString);
|
||||
io.fonts->defaultFontMgr->getFamilyName(i, &familyNameSkString);
|
||||
if(familyNameSkString.isEmpty())
|
||||
continue;
|
||||
std::string familyName(familyNameSkString.c_str(), familyNameSkString.size());
|
||||
|
|
@ -115,7 +115,7 @@ bool GUIStuff::FontPicker::update(UpdateInputData& io, std::string* fontName, GU
|
|||
tStyle.setForegroundColor(SkPaint{io.theme->frontColor1});
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
||||
skia::textlayout::ParagraphBuilderImpl pBuilder(pStyle, io.fontCollection, SkUnicodes::ICU::Make());
|
||||
skia::textlayout::ParagraphBuilderImpl pBuilder(pStyle, io.fonts->collection, SkUnicodes::ICU::Make());
|
||||
tStyle.setFontStyle(SkFontStyle::Normal());
|
||||
|
||||
pBuilder.pushStyle(tStyle);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ template <typename T> class TextBox : public Element {
|
|||
paintOpts.cursorColor = {io.theme->fillColor1.fR, io.theme->fillColor1.fG, io.theme->fillColor1.fB};
|
||||
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
tStyle.setFontFamilies(get_default_font_families());
|
||||
tStyle.setFontFamilies(io.fonts->get_default_font_families());
|
||||
tStyle.setFontSize(io.fontSize);
|
||||
tStyle.setForegroundPaint(SkPaint{io.theme->frontColor1});
|
||||
textbox->set_initial_text_style(tStyle);
|
||||
|
|
@ -103,7 +103,7 @@ template <typename T> class TextBox : public Element {
|
|||
return;
|
||||
|
||||
textbox = std::make_shared<RichText::TextBox>();
|
||||
textbox->set_font_collection(io.fontCollection);
|
||||
textbox->set_font_data(io.fonts);
|
||||
textbox->set_allow_newlines(false);
|
||||
|
||||
cur = std::make_shared<RichText::TextBox::Cursor>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue