Added more default fonts, and fixed issue with font selector at different GUI scales
This commit is contained in:
parent
e451e8b181
commit
5e8016b504
19 changed files with 438 additions and 21 deletions
|
|
@ -771,6 +771,11 @@ void TextBox::set_width(float newWidth) {
|
|||
}
|
||||
}
|
||||
|
||||
float TextBox::get_height() {
|
||||
rebuild();
|
||||
return paragraphs.back().heightOffset + paragraphs.back().p->getHeight();
|
||||
}
|
||||
|
||||
void TextBox::set_allow_newlines(bool allow) {
|
||||
newlinesAllowed = allow;
|
||||
}
|
||||
|
|
@ -795,6 +800,16 @@ void TextBox::rebuild() {
|
|||
ParagraphData& pData = paragraphs[pIndex];
|
||||
skia::textlayout::ParagraphStyle pStyle = pData.pStyleData.get_paragraph_style();
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
||||
if(!newlinesAllowed) {
|
||||
pStyle.setTextHeightBehavior(skia::textlayout::kDisableAll);
|
||||
|
||||
skia::textlayout::StrutStyle strutStyle;
|
||||
strutStyle.setStrutEnabled(true);
|
||||
strutStyle.setForceStrutHeight(true);
|
||||
pStyle.setStrutStyle(strutStyle);
|
||||
}
|
||||
|
||||
size_t tIndex = 0;
|
||||
skia::textlayout::ParagraphBuilderImpl a(pStyle, fontCollection, SkUnicodes::ICU::Make());
|
||||
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ class TextBox {
|
|||
void set_font_collection(const sk_sp<skia::textlayout::FontCollection>& fC);
|
||||
void paint(SkCanvas* canvas, const PaintOpts& paintOpts);
|
||||
void set_allow_newlines(bool allow);
|
||||
float get_height();
|
||||
|
||||
enum class InputKey {
|
||||
LEFT,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <Helpers/Serializers.hpp>
|
||||
#include <include/core/SkFontStyle.h>
|
||||
#include <modules/skparagraph/include/TextStyle.h>
|
||||
#include "../FontData.hpp"
|
||||
|
||||
#define WEIGHT_VALUE_MODIFIER 100
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ void FontFamiliesTextStyleModifier::load(cereal::PortableBinaryInputArchive& a)
|
|||
|
||||
void FontFamiliesTextStyleModifier::modify_text_style(skia::textlayout::TextStyle& style) const {
|
||||
auto familiesToPush = families;
|
||||
familiesToPush.emplace_back("Roboto");
|
||||
push_default_font_families(familiesToPush);
|
||||
style.setFontFamilies(familiesToPush);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue