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
BIN
data/fonts/Inconsolata-VariableFont_wdth,wght.ttf
Normal file
BIN
data/fonts/Inconsolata-VariableFont_wdth,wght.ttf
Normal file
Binary file not shown.
BIN
data/fonts/IndieFlower-Regular.ttf
Normal file
BIN
data/fonts/IndieFlower-Regular.ttf
Normal file
Binary file not shown.
BIN
data/fonts/NotoEmoji-VariableFont_wght.ttf
Normal file
BIN
data/fonts/NotoEmoji-VariableFont_wght.ttf
Normal file
Binary file not shown.
BIN
data/fonts/NotoKufiArabic-VariableFont_wght.ttf
Normal file
BIN
data/fonts/NotoKufiArabic-VariableFont_wght.ttf
Normal file
Binary file not shown.
93
data/third_party_licenses/Inconsolata
Normal file
93
data/third_party_licenses/Inconsolata
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2006 The Inconsolata Project Authors
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
data/third_party_licenses/Indie Flower
Normal file
93
data/third_party_licenses/Indie Flower
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright (c) 2010, Kimberly Geswein (kimberlygeswein.com)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
data/third_party_licenses/Noto Emoji
Normal file
93
data/third_party_licenses/Noto Emoji
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2013 Google LLC
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
93
data/third_party_licenses/Noto Kufi Arabic
Normal file
93
data/third_party_licenses/Noto Kufi Arabic
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/arabic)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
|
@ -15,6 +15,10 @@
|
|||
#include <include/ports/SkFontScanner_FreeType.h>
|
||||
#endif
|
||||
|
||||
#include <src/base/SkUTF.h>
|
||||
|
||||
bool fallbackOnEmoji = false;
|
||||
|
||||
FontData::FontData()
|
||||
{
|
||||
#ifdef __EMSCRIPTEN__
|
||||
|
|
@ -34,8 +38,14 @@ FontData::FontData()
|
|||
map["Roboto"] = defaultFontMgr->makeFromFile("data/fonts/Roboto-variable.ttf");
|
||||
|
||||
collection = sk_make_sp<skia::textlayout::FontCollection>();
|
||||
collection->setDefaultFontManager(defaultFontMgr, {SkString{"Roboto"}});
|
||||
collection->setDefaultFontManager(defaultFontMgr, std::vector<SkString>{SkString{"Roboto"}, SkString{"Noto Emoji"}, SkString{"Noto Kufi Arabic"}});
|
||||
collection->setDynamicFontManager(localFontMgr);
|
||||
std::string s = "🙂";
|
||||
const char* sPtr = s.data();
|
||||
SkFontStyle defaultStyle;
|
||||
SkString defaultLocale("en");
|
||||
auto defaultEmojiFallback = collection->defaultEmojiFallback(SkUTF::NextUTF8(&sPtr, s.c_str() + s.length()), defaultStyle, defaultLocale);
|
||||
fallbackOnEmoji = !defaultEmojiFallback;
|
||||
}
|
||||
|
||||
FontData::~FontData() {
|
||||
|
|
@ -47,3 +57,21 @@ Vector2f get_str_font_bounds(const SkFont& font, const std::string& str) {
|
|||
float nextText = font.measureText(str.data(), str.length(), SkTextEncoding::kUTF8, nullptr);
|
||||
return Vector2f{nextText, - metrics.fAscent + metrics.fDescent};
|
||||
}
|
||||
|
||||
const std::vector<SkString>& get_default_font_families() {
|
||||
static std::vector<SkString> defaultFontFamilies;
|
||||
if(defaultFontFamilies.empty()) {
|
||||
defaultFontFamilies.emplace_back("Roboto");
|
||||
if(fallbackOnEmoji)
|
||||
defaultFontFamilies.emplace_back("Noto Emoji");
|
||||
defaultFontFamilies.emplace_back("Noto Kufi Arabic");
|
||||
}
|
||||
return defaultFontFamilies;
|
||||
}
|
||||
|
||||
void push_default_font_families(std::vector<SkString>& fontFamilies) {
|
||||
fontFamilies.emplace_back("Roboto");
|
||||
if(fallbackOnEmoji)
|
||||
fontFamilies.emplace_back("Noto Emoji");
|
||||
fontFamilies.emplace_back("Noto Kufi Arabic");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,3 +18,5 @@ struct FontData {
|
|||
};
|
||||
|
||||
Vector2f get_str_font_bounds(const SkFont& font, const std::string& str);
|
||||
const std::vector<SkString>& get_default_font_families();
|
||||
void push_default_font_families(std::vector<SkString>& fontFamilies);
|
||||
|
|
|
|||
|
|
@ -140,13 +140,13 @@ bool GUIStuff::FontPicker::update(UpdateInputData& io, std::string* fontName, GU
|
|||
entryColor = io.theme->backColor1;
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIXED(25)},
|
||||
.padding = {.left = 2, .right = 2},
|
||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER}
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(entryColor)
|
||||
}) {
|
||||
gui->text_paragraph("font name", std::move(p), std::numeric_limits<float>::max());
|
||||
gui->text_paragraph("font name", std::move(p), 10000.0f); // Setting width to numeric_limits::max will lead to multiplying it by any number greater than 1 to = infinity, which will cause issues
|
||||
|
||||
if(io.mouse.leftClick && Clay_Hovered()) {
|
||||
*fontName = sortedFontList[i];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "../../RichText/TextBox.hpp"
|
||||
#include <limits>
|
||||
#include <modules/skparagraph/include/TextStyle.h>
|
||||
#include "../../FontData.hpp"
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
|
|
@ -17,14 +18,13 @@ template <typename T> class TextBox : public Element {
|
|||
data = newData;
|
||||
fromStr = newFromStr;
|
||||
toStr = newToStr;
|
||||
singleLine = newSingleLine;
|
||||
force_update_textbox(io, false);
|
||||
|
||||
textbox->set_width(singleLine ? std::numeric_limits<float>::max() : bb.width());
|
||||
textbox->set_width(std::numeric_limits<float>::max());
|
||||
|
||||
CLAY({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 2)), .height = singleLine ? CLAY_SIZING_FIXED(static_cast<float>(io.fontSize * 1.25f)) : CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 1.25f))}
|
||||
.sizing = {.width = CLAY_SIZING_GROW(static_cast<float>(io.fontSize * 2)), .height = CLAY_SIZING_FIXED(static_cast<float>(io.fontSize * 1.25f))}
|
||||
},
|
||||
.custom = { .customData = this }
|
||||
}) {
|
||||
|
|
@ -71,7 +71,9 @@ template <typename T> class TextBox : public Element {
|
|||
|
||||
canvas->clipRect(SkRect::MakeXYWH(bb.min.x(), bb.min.y(), bb.width(), bb.height()));
|
||||
|
||||
canvas->translate(bb.min.x() + 2.0f, bb.min.y());
|
||||
float yOffset = bb.height() * 0.5f;
|
||||
yOffset -= textbox->get_height() * 0.5f;
|
||||
canvas->translate(bb.min.x() + 2.0f, bb.min.y() + yOffset);
|
||||
|
||||
RichText::TextBox::PaintOpts paintOpts;
|
||||
if(selection.selected)
|
||||
|
|
@ -79,9 +81,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;
|
||||
std::vector<SkString> families;
|
||||
families.emplace_back("Roboto");
|
||||
tStyle.setFontFamilies(families);
|
||||
tStyle.setFontFamilies(get_default_font_families());
|
||||
tStyle.setFontSize(io.fontSize);
|
||||
tStyle.setForegroundPaint(SkPaint{io.theme->frontColor1});
|
||||
textbox->set_initial_text_style(tStyle);
|
||||
|
|
@ -99,7 +99,7 @@ template <typename T> class TextBox : public Element {
|
|||
|
||||
textbox = std::make_shared<RichText::TextBox>();
|
||||
textbox->set_font_collection(io.fontCollection);
|
||||
textbox->set_allow_newlines(!singleLine);
|
||||
textbox->set_allow_newlines(false);
|
||||
|
||||
cur = std::make_shared<RichText::TextBox::Cursor>();
|
||||
|
||||
|
|
@ -120,8 +120,6 @@ template <typename T> class TextBox : public Element {
|
|||
T* data = nullptr;
|
||||
T oldData;
|
||||
|
||||
bool singleLine = true;
|
||||
|
||||
std::function<std::optional<T>(const std::string&)> fromStr;
|
||||
std::function<std::string(const T&)> toStr;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <modules/skparagraph/include/TextStyle.h>
|
||||
#include <modules/skunicode/include/SkUnicode_icu.h>
|
||||
#include <Helpers/Random.hpp>
|
||||
#include "../FontData.hpp"
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
|
|
@ -43,7 +44,7 @@ Clay_Dimensions GUIManager::clay_skia_measure_text(Clay_StringSlice str, Clay_Te
|
|||
pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
tStyle.setFontSize(config->fontSize);
|
||||
tStyle.setFontFamilies({SkString{"Roboto"}});
|
||||
tStyle.setFontFamilies(get_default_font_families());
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
||||
skia::textlayout::ParagraphBuilderImpl a(pStyle, window->io->fontCollection, SkUnicodes::ICU::Make());
|
||||
|
|
@ -116,7 +117,7 @@ void GUIManager::draw(SkCanvas* canvas) {
|
|||
pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
tStyle.setFontSize(config->fontSize);
|
||||
tStyle.setFontFamilies({SkString{"Roboto"}});
|
||||
tStyle.setFontFamilies(get_default_font_families());
|
||||
tStyle.setColor(convert_vec4<SkColor4f>(config->textColor).toSkColor());
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
using namespace Eigen;
|
||||
|
||||
|
||||
namespace GUIStuff {
|
||||
|
||||
class GUIManager {
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ InputManager::InputManager() {
|
|||
// Without this, SDL eats the CTRL-V event that initiates the paste event
|
||||
// https://github.com/pthom/hello_imgui/issues/3#issuecomment-1564536870
|
||||
EM_ASM({
|
||||
window.addEventListener('keydown', function(event){
|
||||
if (event.ctrlKey && event.key == 'v') {
|
||||
window.addEventListener('keydown', function(event) {
|
||||
if((event.ctrlKey || event.metaKey) && (event.key == 'v' || event.code == 'KeyV')) {
|
||||
if(Module["ccall"]('is_text_input_happening', 'number', [], []) === 1)
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "Toolbar.hpp"
|
||||
#include "DrawingProgram/DrawingProgramToolBase.hpp"
|
||||
#include "DrawingProgram/ScreenshotTool.hpp"
|
||||
#include "FontData.hpp"
|
||||
#include "Helpers/ConvertVec.hpp"
|
||||
#include "Helpers/FileDownloader.hpp"
|
||||
#include "Helpers/Networking/NetLibrary.hpp"
|
||||
|
|
@ -823,7 +824,7 @@ std::unique_ptr<skia::textlayout::Paragraph> Toolbar::build_paragraph_from_chat_
|
|||
pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
|
||||
skia::textlayout::TextStyle tStyle;
|
||||
tStyle.setFontSize(io->fontSize);
|
||||
tStyle.setFontFamilies({SkString{"Roboto"}});
|
||||
tStyle.setFontFamilies(get_default_font_families());
|
||||
tStyle.setFontStyle(SkFontStyle::Bold());
|
||||
tStyle.setForegroundColor(SkPaint{color_mul_alpha(message.type == ChatMessage::JOIN ? io->theme->warningColor : io->theme->frontColor1, alpha)});
|
||||
pStyle.setTextStyle(tStyle);
|
||||
|
|
@ -1400,7 +1401,6 @@ void Toolbar::options_menu() {
|
|||
gui.push_id("general settings");
|
||||
gui.input_text_field("display name input", "Display Name", &main.displayName);
|
||||
main.update_display_names();
|
||||
gui.text_label_light("Note: Changes in display name dont affect canvases that are connected online");
|
||||
SkColor4f newBackColor{main.defaultCanvasBackgroundColor.x(), main.defaultCanvasBackgroundColor.y(), main.defaultCanvasBackgroundColor.z(), 1.0f};
|
||||
gui.color_picker_button_field("defaultCanvasBackgroundColor", "Default canvas background color", &newBackColor, false);
|
||||
main.defaultCanvasBackgroundColor = convert_vec3<Vector3f>(newBackColor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue