mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Add <font:$family> tag, closes #24
This commit is contained in:
+4
-1
@@ -17,6 +17,9 @@ Bug fixes:
|
|||||||
* length function now gives correct results for maps
|
* length function now gives correct results for maps
|
||||||
* substr("foo",begin:3) now returns "" instead of true
|
* substr("foo",begin:3) now returns "" instead of true
|
||||||
|
|
||||||
|
Template features:
|
||||||
|
* Added <font:...> tag to change the font inside a text field.
|
||||||
|
|
||||||
Scripting:
|
Scripting:
|
||||||
* Added type_name function
|
* Added type_name function
|
||||||
* nil != "", so missing values are no longer equal to the empty string
|
* nil != "", so missing values are no longer equal to the empty string
|
||||||
@@ -26,7 +29,7 @@ Scripting:
|
|||||||
|
|
||||||
Internal:
|
Internal:
|
||||||
* Switch build system to to CMake
|
* Switch build system to to CMake
|
||||||
* Update code to work with wxWidgets 3.0/3.1 and C++ 17
|
* Update code to work with wxWidgets 3.1 and C++ 17
|
||||||
* Lots of code cleanup
|
* Lots of code cleanup
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ This is written as the character with code 1 in files.
|
|||||||
| @<sym>@ The text inside the tag is rendered as symbols, if a [[prop:style:symbol font]] is set for the text box.
|
| @<sym>@ The text inside the tag is rendered as symbols, if a [[prop:style:symbol font]] is set for the text box.
|
||||||
| @<color:???>@ The text inside the tag is rendered with the given [[type:color]].
|
| @<color:???>@ The text inside the tag is rendered with the given [[type:color]].
|
||||||
| @<size:???>@ The text inside the tag is rendered with the given font size in points, for example @"<size:12>text</size>"@ makes the text 12 points. The text is scaled down proportionally when it does not fit in a text box and the @scale down to@ attribute allows it.
|
| @<size:???>@ The text inside the tag is rendered with the given font size in points, for example @"<size:12>text</size>"@ makes the text 12 points. The text is scaled down proportionally when it does not fit in a text box and the @scale down to@ attribute allows it.
|
||||||
|
| @<font:???>@ The text inside the tag is rendered with the given font family.
|
||||||
| @<line>@ Line breaks inside this tag use the [[prop:style:line height line]], and they show a horizontal line.
|
| @<line>@ Line breaks inside this tag use the [[prop:style:line height line]], and they show a horizontal line.
|
||||||
| @<soft-line>@ Line breaks inside this tag use the [[prop:style:soft line height]].
|
| @<soft-line>@ Line breaks inside this tag use the [[prop:style:soft line height]].
|
||||||
| @<atom>@ An atomic piece of text. The cursor can never be inside it; it is selected as a whole.
|
| @<atom>@ An atomic piece of text. The cursor can never be inside it; it is selected as a whole.
|
||||||
|
|||||||
+4
-1
@@ -50,7 +50,7 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
|||||||
shadow_color.initDependencies(ctx, dep);
|
shadow_color.initDependencies(ctx, dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontP Font::make(int add_flags, Color* other_color, double* other_size) const {
|
FontP Font::make(int add_flags, String const* other_family, Color const* other_color, double const* other_size) const {
|
||||||
FontP f(new Font(*this));
|
FontP f(new Font(*this));
|
||||||
f->flags |= add_flags;
|
f->flags |= add_flags;
|
||||||
if (add_flags & FONT_CODE_STRING) {
|
if (add_flags & FONT_CODE_STRING) {
|
||||||
@@ -73,6 +73,9 @@ FontP Font::make(int add_flags, Color* other_color, double* other_size) const {
|
|||||||
if (other_size) {
|
if (other_size) {
|
||||||
f->size = *other_size;
|
f->size = *other_size;
|
||||||
}
|
}
|
||||||
|
if (other_family && !other_family->empty()) {
|
||||||
|
f->name = *other_family;
|
||||||
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -59,8 +59,8 @@ public:
|
|||||||
return shadow_displacement.width != 0 || shadow_displacement.height != 0;
|
return shadow_displacement.width != 0 || shadow_displacement.height != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add style to a font, and optionally change the color and size
|
/// Add style to a font, and optionally change the font family, color and size
|
||||||
FontP make(int add_flags, Color* other_color, double* other_size) const;
|
FontP make(int add_flags, String const* other_family, Color const* other_color, double const* other_size) const;
|
||||||
|
|
||||||
/// Convert this font to a wxFont
|
/// Convert this font to a wxFont
|
||||||
wxFont toWxFont(double scale) const;
|
wxFont toWxFont(double scale) const;
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ struct TextElementsFromString {
|
|||||||
int param_id;
|
int param_id;
|
||||||
vector<Color> colors;
|
vector<Color> colors;
|
||||||
vector<double> sizes;
|
vector<double> sizes;
|
||||||
|
vector<String> fonts;
|
||||||
/// put angle brackets around the text?
|
/// put angle brackets around the text?
|
||||||
bool bracket;
|
bool bracket;
|
||||||
|
|
||||||
@@ -138,6 +139,14 @@ struct TextElementsFromString {
|
|||||||
} else if (is_substr(text, tag_start, _("</color"))) {
|
} else if (is_substr(text, tag_start, _("</color"))) {
|
||||||
if (!colors.empty()) colors.pop_back();
|
if (!colors.empty()) colors.pop_back();
|
||||||
}
|
}
|
||||||
|
else if (is_substr(text, tag_start, _( "<font"))) {
|
||||||
|
size_t colon = text.find_first_of(_(">:"), tag_start);
|
||||||
|
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
|
||||||
|
fonts.push_back(text.substr(colon+1, pos-colon-2));
|
||||||
|
}
|
||||||
|
} else if (is_substr(text, tag_start, _("</font"))) {
|
||||||
|
if (!fonts.empty()) fonts.pop_back();
|
||||||
|
}
|
||||||
else if (is_substr(text, tag_start, _( "<size"))) {
|
else if (is_substr(text, tag_start, _( "<size"))) {
|
||||||
size_t colon = text.find_first_of(_(">:"), tag_start);
|
size_t colon = text.find_first_of(_(">:"), tag_start);
|
||||||
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
|
if (colon < pos - 1 && text.GetChar(colon) == _(':')) {
|
||||||
@@ -251,6 +260,7 @@ private:
|
|||||||
(code > 0 ? FONT_CODE : FONT_NORMAL) |
|
(code > 0 ? FONT_CODE : FONT_NORMAL) |
|
||||||
(code_kw > 0 ? FONT_CODE_KW : FONT_NORMAL) |
|
(code_kw > 0 ? FONT_CODE_KW : FONT_NORMAL) |
|
||||||
(code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL),
|
(code_string > 0 ? FONT_CODE_STRING : FONT_NORMAL),
|
||||||
|
fonts.empty() ? nullptr : &fonts.back(),
|
||||||
param > 0 || param_ref > 0
|
param > 0 || param_ref > 0
|
||||||
? ¶m_colors[(param_id++) % param_colors_count]
|
? ¶m_colors[(param_id++) % param_colors_count]
|
||||||
: !colors.empty()
|
: !colors.empty()
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ void check_tagged(const String& str, bool check_balance) {
|
|||||||
}
|
}
|
||||||
for (size_t j = i + 1 ; j + 1 < end ; ++j) {
|
for (size_t j = i + 1 ; j + 1 < end ; ++j) {
|
||||||
Char c = str.GetChar(j);
|
Char c = str.GetChar(j);
|
||||||
if (c == _(' ') || c == _('<')) {
|
if (c == ESCAPED_LANGLE || c == _('<')) {
|
||||||
queue_message(MESSAGE_WARNING, _("Invalid character in tag"));
|
queue_message(MESSAGE_WARNING, _("Invalid character in tag"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user