diff --git a/data/magic-firepenguinmaster.mse-style/style b/data/magic-firepenguinmaster.mse-style/style index e20f2848..c14d520a 100644 --- a/data/magic-firepenguinmaster.mse-style/style +++ b/data/magic-firepenguinmaster.mse-style/style @@ -196,7 +196,7 @@ card style: width: 220 height: 20 alignment: top shrink-overflow - z index: 1 + z index: 2 padding top: 2 font: name: Matrix diff --git a/data/magic-future-textless.mse-style/style b/data/magic-future-textless.mse-style/style index fd2d1645..29b02021 100644 --- a/data/magic-future-textless.mse-style/style +++ b/data/magic-future-textless.mse-style/style @@ -175,7 +175,6 @@ card style: symbol font: name: magic-mana-future size: 22 - scale down to: 22 alignment: bottom right always symbol: true mask: costmask.png diff --git a/data/magic-mana-beveled.mse-symbol-font/symbol-font b/data/magic-mana-beveled.mse-symbol-font/symbol-font index 67775c89..56f7a550 100644 --- a/data/magic-mana-beveled.mse-symbol-font/symbol-font +++ b/data/magic-mana-beveled.mse-symbol-font/symbol-font @@ -178,9 +178,10 @@ symbol: as text: .|[0-9]+(?!/) text font: name: MPlantin - size: 15 + size: 1 color: rgb(0,0,0) -text margin left: 3 -text margin right: 2 -text margin top: -1 -text margin bottom: -1 \ No newline at end of file + max stretch: 0.5 +text margin left: .26 +text margin right: .2 +text margin top: -.12 +text margin bottom: -.12 diff --git a/data/magic-mana-future.mse-symbol-font/mana_1_half.png b/data/magic-mana-future.mse-symbol-font/mana_1_half.png index 86e80248..d6226e64 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_1_half.png and b/data/magic-mana-future.mse-symbol-font/mana_1_half.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle.png b/data/magic-mana-future.mse-symbol-font/mana_circle.png index f6f0e678..34d1b896 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle.png and b/data/magic-mana-future.mse-symbol-font/mana_circle.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle_b.png b/data/magic-mana-future.mse-symbol-font/mana_circle_b.png index 2a5d8771..8ca97f70 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle_b.png and b/data/magic-mana-future.mse-symbol-font/mana_circle_b.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle_g.png b/data/magic-mana-future.mse-symbol-font/mana_circle_g.png index 03a81043..144168b1 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle_g.png and b/data/magic-mana-future.mse-symbol-font/mana_circle_g.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle_r.png b/data/magic-mana-future.mse-symbol-font/mana_circle_r.png index ea0e8d5b..5346de54 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle_r.png and b/data/magic-mana-future.mse-symbol-font/mana_circle_r.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle_u.png b/data/magic-mana-future.mse-symbol-font/mana_circle_u.png index 7ebf2c32..20aca0d8 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle_u.png and b/data/magic-mana-future.mse-symbol-font/mana_circle_u.png differ diff --git a/data/magic-mana-future.mse-symbol-font/mana_circle_w.png b/data/magic-mana-future.mse-symbol-font/mana_circle_w.png index ed977d45..9c1b84c8 100644 Binary files a/data/magic-mana-future.mse-symbol-font/mana_circle_w.png and b/data/magic-mana-future.mse-symbol-font/mana_circle_w.png differ diff --git a/data/magic-mana-future.mse-symbol-font/symbol-font b/data/magic-mana-future.mse-symbol-font/symbol-font index 4a6ed489..64fb1e07 100644 --- a/data/magic-mana-future.mse-symbol-font/symbol-font +++ b/data/magic-mana-future.mse-symbol-font/symbol-font @@ -139,9 +139,10 @@ symbol: as text: .|[0-9]+(?!/) text font: name: MPlantin - size: 16 + size: 1 color: rgb(0,0,0) -text margin left: 3 -text margin right: 2 -text margin top: -1 -text margin bottom: -1 \ No newline at end of file + max stretch: 0.5 +text margin left: .35 +text margin right: .3 +text margin top: 0.1 +text margin bottom: 0.1 diff --git a/data/magic-mana-large.mse-symbol-font/symbol-font b/data/magic-mana-large.mse-symbol-font/symbol-font index 0f14699f..f51db2f8 100644 --- a/data/magic-mana-large.mse-symbol-font/symbol-font +++ b/data/magic-mana-large.mse-symbol-font/symbol-font @@ -191,12 +191,13 @@ symbol: as text: .|[0-9]+(?!/) text font: name: MPlantin - size: 15 + size: 1 color: rgb(0,0,0) -text margin left: 3 -text margin right: 2 -text margin top: -1 -text margin bottom: -1 + max stretch: 0.5 +text margin left: .28 +text margin right: .2 +text margin top: -.12 +text margin bottom: -.06 ############################################################## # Insert-symbol menu diff --git a/data/magic-mana-small.mse-symbol-font/symbol-font b/data/magic-mana-small.mse-symbol-font/symbol-font index 329dc431..a491a656 100644 --- a/data/magic-mana-small.mse-symbol-font/symbol-font +++ b/data/magic-mana-small.mse-symbol-font/symbol-font @@ -198,12 +198,13 @@ symbol: as text: .|[0-9]+(?!/) text font: name: MPlantin - size: 15 + size: 1 color: rgb(0,0,0) -text margin left: 3 -text margin right: 2 -text margin top: -1 -text margin bottom: -1 + max stretch: 0.5 +text margin left: .26 +text margin right: .2 +text margin top: -.12 +text margin bottom: -.12 ############################################################## # Insert-symbol menu diff --git a/data/vanguard.mse-game/game b/data/vanguard.mse-game/game index 791a2d13..24ccc766 100644 --- a/data/vanguard.mse-game/game +++ b/data/vanguard.mse-game/game @@ -60,9 +60,9 @@ init script: # Converted mana cost cmc := to_text + { - 1 * number_of_items(in: sort(order:"SWUBRG")) # colored mana - - 1 * number_of_items(in: sort(order:"/")) # guild mana, W/U -> 2 - 1 - + 1 * sort(order: "[0123456789]") # colorless mana + 1 * number_of_items(in: sort_text(order:"SWUBRG")) # colored mana + - 1 * number_of_items(in: sort_text(order:"/")) # guild mana, W/U -> 2 - 1 + + 1 * sort_text(order: "[0123456789]") # colorless mana } ############################################################## The text box diff --git a/data/vs.mse-game/game b/data/vs.mse-game/game index 196b7487..85d7ecf3 100644 --- a/data/vs.mse-game/game +++ b/data/vs.mse-game/game @@ -293,12 +293,15 @@ card field: ) identifying: true show statistics: false + card list visible: true card list column: 1 + card list width: 200 description: The name of the card, use @ for a diamond card field: type: text name: cost script: only_numbers(value) + card list visible: true card list column: 3 card list alignment: right card list width: 37 @@ -391,6 +394,7 @@ card field: hide_when_empty: true, type_over1: " `" ) + card list visible: true card list column: 2 show statistics: false @@ -406,9 +410,11 @@ card field: order_by: { sort_index() + card.team + card.team_2_of_2 + card.team_2 + card.team_2_of_2_2 + card.name + card.version + " • " + card.team_affiliation }) + card list visible: true card list column: 6 card list width: 55 card list name: # + card list alignment: right editable: false show statistics: false card field: @@ -543,18 +549,22 @@ card field: name: attack script: only_numbers(value) save value: true + card list visible: true card list column: 4 card list width: 33 card list name: ATK + card list alignment: right card field: type: text name: defence script: only_numbers(value) save value: true + card list visible: true card list column: 5 card list width: 33 card list name: DEF + card list alignment: right ############################# Copyright stuff card field: diff --git a/doc/type/font.txt b/doc/type/font.txt index d1d49a43..608b5f21 100644 --- a/doc/type/font.txt +++ b/doc/type/font.txt @@ -10,6 +10,7 @@ A reference to a normal [[type:font]] for drawing text. | @italic name@ [[type:scriptable]] [[type:string]] Optionally, a different font to use for italic text instead of the normal italic version of the font. | @size@ [[type:scriptable]] [[type:double]] ''required'' Size of the font in points on a 96 DPI display. | @scale down to@ [[type:double]] ∞ Minimum size in points to scale the size down to. +| @max stretch@ [[type:double]] @1.0@ Maximum multiplier by which the width of the text is compressed, so @max width: 0.5@ means the text can be compressed to half the normal width. | @weight@ [[type:scriptable]] font weight @"normal"@ Weight of the font, one of @"normal"@ or @"bold"@. This can be changed locally by [[type:tagged string|tags]]. | @style@ [[type:scriptable]] font style @"normal"@ Style of the font, one of @"normal"@ or @"italic"@. This can be changed locally by [[type:tagged string|tags]]. | @underline@ [[type:scriptable]] [[type:boolean]] @false@ Should the font be underlined? diff --git a/doc/type/symbol_font.txt b/doc/type/symbol_font.txt index 6d5a0569..28033832 100644 --- a/doc/type/symbol_font.txt +++ b/doc/type/symbol_font.txt @@ -23,6 +23,10 @@ This resulution could correspond to a point size of for instance 150pt. When the symbol is drawn at for instance 12pt the image well then be scalled down to @200/150*12 == 16@ pixels. +Sizes like margin, padding and font size are given in 'pixels per point'. If for instance +> text margin left: 0.1 +is specified, and the symbol is rendered at 12pt, the margin will be @12*0.1 == 1.2@ pixels. + --Package format-- A symbol font is described in a [[file:package]] with the .mse-symbol-font file extension. @@ -44,15 +48,15 @@ Such a package contains a [[file:format|data file]] called symbol-font | @horizontal space@ [[type:double]] @0@ Horizontal spacing between symbols, in pixels. | @vertical space@ [[type:double]] @0@ Vertical spacing between symbols, in pixels. | @symbols@ [[type:list]] of [[type:symbol font symbol]]s Symbols that make up this font. -| @text font@ [[type:font]] Font to use for drawing text on symbols, only used if there is a default symbol. +| @text font@ [[type:font]] Font to use for drawing text on symbols, only used if there is a default symbol. The font size is in points per point. | @scale text@ [[type:boolean]] @false@ Should text be scaled down to fit in a symbol? | @merge numbers@ [[type:boolean]] @false@ Should a numeric value of multiple digits be rendered as a single symbol?
Note: @merge numbers@ is deprecated, use @as text: [0-9]+@ instead. | @as text@ [[type:regex]] @"."@ What should be rendered as a single piece of text? -| @text margin left@ [[type:double]] @0@ Margin on the left of the text in pixels. -| @text margin right@ [[type:double]] @0@ Margin on the right of the text in pixels. -| @text margin top@ [[type:double]] @0@ Margin on the top of the text in pixels. -| @text margin bottom@ [[type:double]] @0@ Margin on the bottom of the text in pixels. +| @text margin left@ [[type:double]] @0@ Margin on the left of the text in pixels per point. +| @text margin right@ [[type:double]] @0@ Margin on the right of the text in pixels per point. +| @text margin top@ [[type:double]] @0@ Margin on the top of the text in pixels per point. +| @text margin bottom@ [[type:double]] @0@ Margin on the bottom of the text in pixels per point. | @text alignment@ [[type:alignment]] @"middle center"@ How should text be aligned on symbols? | @insert symbol menu@ [[type:insert symbol menu|"insert symbol" menu]] ''none'' A description of the menu to insert a symbol into the text. diff --git a/doc/type/word_list_word.txt b/doc/type/word_list_word.txt index 125b3e73..0198321e 100644 --- a/doc/type/word_list_word.txt +++ b/doc/type/word_list_word.txt @@ -4,11 +4,14 @@ A word in a [[type:word list]]. --Properties-- ! Property Type Default Description -| @name@ [[type:string]] ''Required'' The word +| @name@ [[type:string]] ''Required'' The word. | @line below@ [[type:boolean]] @false@ Display a line below this item in the list? | @is prefix@ [[type:boolean]] @false@ Should this word be used as a prefix before another word from the list?
Think "Legendary ". Note the space after it, words are directly concatenated. -| @words@ [[type:list]] of [[type:word list word]]s A submenu +| @words@ [[type:list]] of [[type:word list word]]s A submenu. If given, the @name@ of this word is only used as a label for the menu. +| @script@ [[type:script]] ''Optional'' A script that determines zero or more words.
+ The result should be a list of comma separated words, for example @"x,y,z"@ specifies three words. + The words are included in the parent menu, not a sub menu. A word can also be given in a short form, in that case only the name is specified. @@ -18,3 +21,14 @@ In short form: Is the same as: >word: > name: xyz + +Using a script, +>word: +> script: "red,green,blue" +> line below: true +Is the same as +>word: blue +>word: green +>word: +> name: red +> line below: true diff --git a/src/data/font.cpp b/src/data/font.cpp index 762fd454..20eaf8bf 100644 --- a/src/data/font.cpp +++ b/src/data/font.cpp @@ -15,6 +15,7 @@ Font::Font() , size(1) , underline(false) , scale_down_to(100000) + , max_stretch(1.0) , shadow_displacement(0,0) , separator_color(128,128,128) , flags(FONT_NORMAL) @@ -70,7 +71,7 @@ FontP Font::make(int add_flags, Color* other_color) const { } wxFont Font::toWxFont(double scale) const { - int size_i = scale * size; + int size_i = to_int(scale * size); int weight_i = flags & FONT_BOLD ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL; int style_i = flags & FONT_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL; // make font @@ -108,6 +109,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Font) { REFLECT(italic_name); REFLECT(color); REFLECT(scale_down_to); + REFLECT(max_stretch); REFLECT_N("shadow_displacement_x", shadow_displacement.width); REFLECT_N("shadow_displacement_y", shadow_displacement.height); REFLECT(shadow_color); diff --git a/src/data/font.hpp b/src/data/font.hpp index 53f591a7..9b10d92a 100644 --- a/src/data/font.hpp +++ b/src/data/font.hpp @@ -39,6 +39,7 @@ class Font : public IntrusivePtrBase { Scriptable weight, style; ///< Weight and style of the font (bold/italic) Scriptable underline; ///< Underlined? double scale_down_to; ///< Smallest size to scale down to + double max_stretch; ///< How much should the font be stretched before scaling down? Scriptable color; ///< Color to use Scriptable shadow_color; ///< Color for shadow RealSize shadow_displacement; ///< Position of the shadow diff --git a/src/data/symbol_font.cpp b/src/data/symbol_font.cpp index 2937f815..9c5d301e 100644 --- a/src/data/symbol_font.cpp +++ b/src/data/symbol_font.cpp @@ -268,33 +268,39 @@ void SymbolFont::drawWithText(RotatedDC& dc, const RealRect& rect, double font_s // 2. draw text if (!text_font) return; // subtract margins from size - sym_rect.x += text_margin_left; - sym_rect.y += text_margin_top; - sym_rect.width -= text_margin_left + text_margin_right; - sym_rect.height -= text_margin_top + text_margin_bottom; + sym_rect.x += font_size * text_margin_left; + sym_rect.y += font_size * text_margin_top; + sym_rect.width -= font_size * (text_margin_left + text_margin_right); + sym_rect.height -= font_size * (text_margin_top + text_margin_bottom); // setup text, shrink it - double size = text_font->size; // TODO : incorporate shrink factor? + double size = font_size * text_font->size; + double stretch = 1.0; RealSize ts; while (true) { if (size <= 0) return; // text too small dc.SetFont(*text_font, size / text_font->size); ts = dc.GetTextExtent(text); - if (ts.width <= sym_rect.width && ts.height <= sym_rect.height) { - break; // text fits - } else { - // text doesn't fit - size -= dc.getFontSizeStep(); + if (ts.height <= sym_rect.height) { + if (ts.width <= sym_rect.width) { + break; // text fits + } else if (ts.width * text_font->max_stretch <= sym_rect.width) { + stretch = sym_rect.width / ts.width; + ts.width = sym_rect.width; // for alignment + break; + } } + // text doesn't fit + size -= dc.getFontSizeStep(); } // align text RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); // draw text if (text_font->hasShadow()) { dc.SetTextForeground(text_font->shadow_color); - dc.DrawText(text, text_pos + text_font->shadow_displacement); + dc.DrawText(text, text_pos + text_font->shadow_displacement * font_size, 0, 1, stretch); } dc.SetTextForeground(text_font->color); - dc.DrawText(text, text_pos); + dc.DrawText(text, text_pos, 0, 1, stretch); } Image SymbolFont::getImage(double font_size, const DrawableSymbol& sym) { @@ -312,33 +318,39 @@ Image SymbolFont::getImage(double font_size, const DrawableSymbol& sym) { RealRect sym_rect(0,0,bmp.GetWidth(),bmp.GetHeight()); RotatedDC rdc(dc, 0, sym_rect, 1, QUALITY_AA); // subtract margins from size - sym_rect.x += text_margin_left; - sym_rect.y += text_margin_top; - sym_rect.width -= text_margin_left + text_margin_right; - sym_rect.height -= text_margin_top + text_margin_bottom; + sym_rect.x += font_size * text_margin_left; + sym_rect.y += font_size * text_margin_top; + sym_rect.width -= font_size * (text_margin_left + text_margin_right); + sym_rect.height -= font_size * (text_margin_top + text_margin_bottom); // setup text, shrink it - double size = text_font->size; // TODO : incorporate shrink factor? + double size = font_size * text_font->size; + double stretch = 1.0; RealSize ts; while (true) { if (size <= 0) return def->getImage(*this, font_size); // text too small rdc.SetFont(*text_font, size / text_font->size); ts = rdc.GetTextExtent(sym.text); - if (ts.width <= sym_rect.width && ts.height <= sym_rect.height) { - break; // text fits - } else { - // text doesn't fit - size -= rdc.getFontSizeStep(); + if (ts.height <= sym_rect.height) { + if (ts.width <= sym_rect.width) { + break; // text fits + } else if (ts.width * text_font->max_stretch <= sym_rect.width) { + stretch = sym_rect.width / ts.width; + ts.width = sym_rect.width; // for alignment + break; + } } + // text doesn't fit + size -= rdc.getFontSizeStep(); } // align text RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); // draw text if (text_font->hasShadow()) { rdc.SetTextForeground(text_font->shadow_color); - rdc.DrawText(sym.text, text_pos + text_font->shadow_displacement); + rdc.DrawText(sym.text, text_pos + text_font->shadow_displacement * font_size, 0, 1, stretch); } rdc.SetTextForeground(text_font->color); - rdc.DrawText(sym.text, text_pos); + rdc.DrawText(sym.text, text_pos, 0, 1, stretch); // done dc.SelectObject(wxNullBitmap); return bmp.ConvertToImage(); diff --git a/src/gfx/resample_text.cpp b/src/gfx/resample_text.cpp index eb4cad3d..515f98b0 100644 --- a/src/gfx/resample_text.cpp +++ b/src/gfx/resample_text.cpp @@ -43,6 +43,8 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { int w1 = img_in.GetWidth(), w2 = img_out.GetWidth(), h = img_in.GetHeight(); int out_fact = (w2 << shift) / w1; // how much to output for 256 input = 1 pixel int out_rest = (w2 << shift) % w1; + // make the image 'bolder' to compensate for compressing it + int mul = 128 + min(256, 128*w1/(text_scaling*w2)); for (int y = 0 ; y < h ; ++y) { int in_rem = out_fact + out_rest; for (int x = 0 ; x < w2 ; ++x) { @@ -61,7 +63,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { in_rem -= out_rem; } // store - *out = tot >> shift; + *out = top(((tot >> shift) * mul) >> 8); out += 1; } } @@ -89,6 +91,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { int h1 = img_in.GetHeight(), w = img_out.GetWidth(); int out_fact = (h << shift) / h1; // how much to output for 256 input = 1 pixel int out_rest = (h << shift) % h1; + int mul = 128 + min(256, 128*h1/(text_scaling*h)); for (int x = 0 ; x < w ; ++x) { int in_rem = out_fact + out_rest; for (int y = 0 ; y < h ; ++y) { @@ -107,7 +110,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { in_rem -= out_rem; } // store - *out = tot >> shift; + *out = top(((tot >> shift) * mul) >> 8); out += line_size; } in = in - h1 * line_size + 1; diff --git a/src/util/rotation.cpp b/src/util/rotation.cpp index dadee2a0..59ad6e76 100644 --- a/src/util/rotation.cpp +++ b/src/util/rotation.cpp @@ -131,12 +131,12 @@ RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, RenderQuality quality) // ----------------------------------------------------------------------------- : RotatedDC : Drawing -void RotatedDC::DrawText (const String& text, const RealPoint& pos, int blur_radius, int boldness) { +void RotatedDC::DrawText (const String& text, const RealPoint& pos, int blur_radius, int boldness, double stretch_) { if (text.empty()) return; if (quality == QUALITY_AA) { RealRect r(pos, GetTextExtent(text)); RealRect r_ext = trNoNeg(r); - draw_resampled_text(dc, r_ext, stretch(), revX(), revY(), angle, text, blur_radius, boldness); + draw_resampled_text(dc, r_ext, stretch_ * stretch(), revX(), revY(), angle, text, blur_radius, boldness); } else if (quality == QUALITY_SUB_PIXEL) { RealPoint p_ext = tr(pos)*text_scaling; double usx,usy; diff --git a/src/util/rotation.hpp b/src/util/rotation.hpp index 44fef421..149dd811 100644 --- a/src/util/rotation.hpp +++ b/src/util/rotation.hpp @@ -151,7 +151,7 @@ class RotatedDC : public Rotation { // --------------------------------------------------- : Drawing - void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, int boldness = 1); + void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, int boldness = 1, double stretch = 1.0); /// Draw abitmap, it must already be zoomed! void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos); /// Draw an image using the given combining mode, the image must already be zoomed!