Commit 92cfba20 authored by twanvl's avatar twanvl

Symbol font measurments (margin/fontsize) now scaled by font size, this...

Symbol font measurments (margin/fontsize) now scaled by font size, this requires all symbol files to change (or you get really large margins);
Symbol fonts now support stretching/compressing of text;
Made the default symbols of mana-future lighter (compare with real cards);
Use sort_text instead of sort for vanguard;
Fixed initial card list for vs
parent 80ca27b5
...@@ -196,7 +196,7 @@ card style: ...@@ -196,7 +196,7 @@ card style:
width: 220 width: 220
height: 20 height: 20
alignment: top shrink-overflow alignment: top shrink-overflow
z index: 1 z index: 2
padding top: 2 padding top: 2
font: font:
name: Matrix name: Matrix
......
...@@ -175,7 +175,6 @@ card style: ...@@ -175,7 +175,6 @@ card style:
symbol font: symbol font:
name: magic-mana-future name: magic-mana-future
size: 22 size: 22
scale down to: 22
alignment: bottom right alignment: bottom right
always symbol: true always symbol: true
mask: costmask.png mask: costmask.png
......
...@@ -178,9 +178,10 @@ symbol: ...@@ -178,9 +178,10 @@ symbol:
as text: .|[0-9]+(?!/) as text: .|[0-9]+(?!/)
text font: text font:
name: MPlantin name: MPlantin
size: 15 size: 1
color: rgb(0,0,0) color: rgb(0,0,0)
text margin left: 3 max stretch: 0.5
text margin right: 2 text margin left: .26
text margin top: -1 text margin right: .2
text margin bottom: -1 text margin top: -.12
\ No newline at end of file text margin bottom: -.12
...@@ -139,9 +139,10 @@ symbol: ...@@ -139,9 +139,10 @@ symbol:
as text: .|[0-9]+(?!/) as text: .|[0-9]+(?!/)
text font: text font:
name: MPlantin name: MPlantin
size: 16 size: 1
color: rgb(0,0,0) color: rgb(0,0,0)
text margin left: 3 max stretch: 0.5
text margin right: 2 text margin left: .35
text margin top: -1 text margin right: .3
text margin bottom: -1 text margin top: 0.1
\ No newline at end of file text margin bottom: 0.1
...@@ -191,12 +191,13 @@ symbol: ...@@ -191,12 +191,13 @@ symbol:
as text: .|[0-9]+(?!/) as text: .|[0-9]+(?!/)
text font: text font:
name: MPlantin name: MPlantin
size: 15 size: 1
color: rgb(0,0,0) color: rgb(0,0,0)
text margin left: 3 max stretch: 0.5
text margin right: 2 text margin left: .28
text margin top: -1 text margin right: .2
text margin bottom: -1 text margin top: -.12
text margin bottom: -.06
############################################################## ##############################################################
# Insert-symbol menu # Insert-symbol menu
......
...@@ -198,12 +198,13 @@ symbol: ...@@ -198,12 +198,13 @@ symbol:
as text: .|[0-9]+(?!/) as text: .|[0-9]+(?!/)
text font: text font:
name: MPlantin name: MPlantin
size: 15 size: 1
color: rgb(0,0,0) color: rgb(0,0,0)
text margin left: 3 max stretch: 0.5
text margin right: 2 text margin left: .26
text margin top: -1 text margin right: .2
text margin bottom: -1 text margin top: -.12
text margin bottom: -.12
############################################################## ##############################################################
# Insert-symbol menu # Insert-symbol menu
......
...@@ -60,9 +60,9 @@ init script: ...@@ -60,9 +60,9 @@ init script:
# Converted mana cost # Converted mana cost
cmc := to_text + { cmc := to_text + {
1 * number_of_items(in: sort(order:"SWUBRG")) # colored mana 1 * number_of_items(in: sort_text(order:"SWUBRG")) # colored mana
- 1 * number_of_items(in: sort(order:"/")) # guild mana, W/U -> 2 - 1 - 1 * number_of_items(in: sort_text(order:"/")) # guild mana, W/U -> 2 - 1
+ 1 * sort(order: "[0123456789]") # colorless mana + 1 * sort_text(order: "[0123456789]") # colorless mana
} }
############################################################## The text box ############################################################## The text box
......
...@@ -293,12 +293,15 @@ card field: ...@@ -293,12 +293,15 @@ card field:
) )
identifying: true identifying: true
show statistics: false show statistics: false
card list visible: true
card list column: 1 card list column: 1
card list width: 200
description: The name of the card, use @ for a diamond description: The name of the card, use @ for a diamond
card field: card field:
type: text type: text
name: cost name: cost
script: only_numbers(value) script: only_numbers(value)
card list visible: true
card list column: 3 card list column: 3
card list alignment: right card list alignment: right
card list width: 37 card list width: 37
...@@ -391,6 +394,7 @@ card field: ...@@ -391,6 +394,7 @@ card field:
hide_when_empty: true, hide_when_empty: true,
type_over1: " `" type_over1: " `"
) )
card list visible: true
card list column: 2 card list column: 2
show statistics: false show statistics: false
...@@ -406,9 +410,11 @@ card field: ...@@ -406,9 +410,11 @@ card field:
order_by: { 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 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 column: 6
card list width: 55 card list width: 55
card list name: # card list name: #
card list alignment: right
editable: false editable: false
show statistics: false show statistics: false
card field: card field:
...@@ -543,18 +549,22 @@ card field: ...@@ -543,18 +549,22 @@ card field:
name: attack name: attack
script: only_numbers(value) script: only_numbers(value)
save value: true save value: true
card list visible: true
card list column: 4 card list column: 4
card list width: 33 card list width: 33
card list name: ATK card list name: ATK
card list alignment: right
card field: card field:
type: text type: text
name: defence name: defence
script: only_numbers(value) script: only_numbers(value)
save value: true save value: true
card list visible: true
card list column: 5 card list column: 5
card list width: 33 card list width: 33
card list name: DEF card list name: DEF
card list alignment: right
############################# Copyright stuff ############################# Copyright stuff
card field: card field:
......
...@@ -10,6 +10,7 @@ A reference to a normal [[type:font]] for drawing text. ...@@ -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. | @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. | @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. | @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]]. | @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]]. | @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? | @underline@ [[type:scriptable]] [[type:boolean]] @false@ Should the font be underlined?
......
...@@ -23,6 +23,10 @@ This resulution could correspond to a point size of for instance 150pt. ...@@ -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. 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-- --Package format--
A symbol font is described in a [[file:package]] with the <tt>.mse-symbol-font</tt> file extension. A symbol font is described in a [[file:package]] with the <tt>.mse-symbol-font</tt> file extension.
...@@ -44,15 +48,15 @@ Such a package contains a [[file:format|data file]] called <tt>symbol-font</tt> ...@@ -44,15 +48,15 @@ Such a package contains a [[file:format|data file]] called <tt>symbol-font</tt>
| @horizontal space@ [[type:double]] @0@ Horizontal spacing between symbols, in pixels. | @horizontal space@ [[type:double]] @0@ Horizontal spacing between symbols, in pixels.
| @vertical space@ [[type:double]] @0@ Vertical 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. | @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? | @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?<br/> | @merge numbers@ [[type:boolean]] @false@ Should a numeric value of multiple digits be rendered as a single symbol?<br/>
Note: @merge numbers@ is deprecated, use @as text: [0-9]+@ instead. 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? | @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 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. | @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. | @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. | @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? | @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. | @insert symbol menu@ [[type:insert symbol menu|"insert symbol" menu]] ''none'' A description of the menu to insert a symbol into the text.
......
...@@ -4,11 +4,14 @@ A word in a [[type:word list]]. ...@@ -4,11 +4,14 @@ A word in a [[type:word list]].
--Properties-- --Properties--
! Property Type Default Description ! 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? | @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?<br/> | @is prefix@ [[type:boolean]] @false@ Should this word be used as a prefix before another word from the list?<br/>
Think "Legendary ". Note the space after it, words are directly concatenated. 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.<br/>
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. 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: ...@@ -18,3 +21,14 @@ In short form:
Is the same as: Is the same as:
>word: >word:
> name: xyz > 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
...@@ -15,6 +15,7 @@ Font::Font() ...@@ -15,6 +15,7 @@ Font::Font()
, size(1) , size(1)
, underline(false) , underline(false)
, scale_down_to(100000) , scale_down_to(100000)
, max_stretch(1.0)
, shadow_displacement(0,0) , shadow_displacement(0,0)
, separator_color(128,128,128) , separator_color(128,128,128)
, flags(FONT_NORMAL) , flags(FONT_NORMAL)
...@@ -70,7 +71,7 @@ FontP Font::make(int add_flags, Color* other_color) const { ...@@ -70,7 +71,7 @@ FontP Font::make(int add_flags, Color* other_color) const {
} }
wxFont Font::toWxFont(double scale) 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 weight_i = flags & FONT_BOLD ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL;
int style_i = flags & FONT_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL; int style_i = flags & FONT_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL;
// make font // make font
...@@ -108,6 +109,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Font) { ...@@ -108,6 +109,7 @@ IMPLEMENT_REFLECTION_NO_SCRIPT(Font) {
REFLECT(italic_name); REFLECT(italic_name);
REFLECT(color); REFLECT(color);
REFLECT(scale_down_to); REFLECT(scale_down_to);
REFLECT(max_stretch);
REFLECT_N("shadow_displacement_x", shadow_displacement.width); REFLECT_N("shadow_displacement_x", shadow_displacement.width);
REFLECT_N("shadow_displacement_y", shadow_displacement.height); REFLECT_N("shadow_displacement_y", shadow_displacement.height);
REFLECT(shadow_color); REFLECT(shadow_color);
......
...@@ -39,6 +39,7 @@ class Font : public IntrusivePtrBase<Font> { ...@@ -39,6 +39,7 @@ class Font : public IntrusivePtrBase<Font> {
Scriptable<String> weight, style; ///< Weight and style of the font (bold/italic) Scriptable<String> weight, style; ///< Weight and style of the font (bold/italic)
Scriptable<bool> underline; ///< Underlined? Scriptable<bool> underline; ///< Underlined?
double scale_down_to; ///< Smallest size to scale down to 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; ///< Color to use Scriptable<Color> color; ///< Color to use
Scriptable<Color> shadow_color; ///< Color for shadow Scriptable<Color> shadow_color; ///< Color for shadow
RealSize shadow_displacement; ///< Position of the shadow RealSize shadow_displacement; ///< Position of the shadow
......
...@@ -268,33 +268,39 @@ void SymbolFont::drawWithText(RotatedDC& dc, const RealRect& rect, double font_s ...@@ -268,33 +268,39 @@ void SymbolFont::drawWithText(RotatedDC& dc, const RealRect& rect, double font_s
// 2. draw text // 2. draw text
if (!text_font) return; if (!text_font) return;
// subtract margins from size // subtract margins from size
sym_rect.x += text_margin_left; sym_rect.x += font_size * text_margin_left;
sym_rect.y += text_margin_top; sym_rect.y += font_size * text_margin_top;
sym_rect.width -= text_margin_left + text_margin_right; sym_rect.width -= font_size * (text_margin_left + text_margin_right);
sym_rect.height -= text_margin_top + text_margin_bottom; sym_rect.height -= font_size * (text_margin_top + text_margin_bottom);
// setup text, shrink it // 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; RealSize ts;
while (true) { while (true) {
if (size <= 0) return; // text too small if (size <= 0) return; // text too small
dc.SetFont(*text_font, size / text_font->size); dc.SetFont(*text_font, size / text_font->size);
ts = dc.GetTextExtent(text); ts = dc.GetTextExtent(text);
if (ts.width <= sym_rect.width && ts.height <= sym_rect.height) { if (ts.height <= sym_rect.height) {
break; // text fits if (ts.width <= sym_rect.width) {
} else { break; // text fits
// text doesn't fit } else if (ts.width * text_font->max_stretch <= sym_rect.width) {
size -= dc.getFontSizeStep(); stretch = sym_rect.width / ts.width;
ts.width = sym_rect.width; // for alignment
break;
}
} }
// text doesn't fit
size -= dc.getFontSizeStep();
} }
// align text // align text
RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect);
// draw text // draw text
if (text_font->hasShadow()) { if (text_font->hasShadow()) {
dc.SetTextForeground(text_font->shadow_color); 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.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) { Image SymbolFont::getImage(double font_size, const DrawableSymbol& sym) {
...@@ -312,33 +318,39 @@ 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()); RealRect sym_rect(0,0,bmp.GetWidth(),bmp.GetHeight());
RotatedDC rdc(dc, 0, sym_rect, 1, QUALITY_AA); RotatedDC rdc(dc, 0, sym_rect, 1, QUALITY_AA);
// subtract margins from size // subtract margins from size
sym_rect.x += text_margin_left; sym_rect.x += font_size * text_margin_left;
sym_rect.y += text_margin_top; sym_rect.y += font_size * text_margin_top;
sym_rect.width -= text_margin_left + text_margin_right; sym_rect.width -= font_size * (text_margin_left + text_margin_right);
sym_rect.height -= text_margin_top + text_margin_bottom; sym_rect.height -= font_size * (text_margin_top + text_margin_bottom);
// setup text, shrink it // 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; RealSize ts;
while (true) { while (true) {
if (size <= 0) return def->getImage(*this, font_size); // text too small if (size <= 0) return def->getImage(*this, font_size); // text too small
rdc.SetFont(*text_font, size / text_font->size); rdc.SetFont(*text_font, size / text_font->size);
ts = rdc.GetTextExtent(sym.text); ts = rdc.GetTextExtent(sym.text);
if (ts.width <= sym_rect.width && ts.height <= sym_rect.height) { if (ts.height <= sym_rect.height) {
break; // text fits if (ts.width <= sym_rect.width) {
} else { break; // text fits
// text doesn't fit } else if (ts.width * text_font->max_stretch <= sym_rect.width) {
size -= rdc.getFontSizeStep(); stretch = sym_rect.width / ts.width;
ts.width = sym_rect.width; // for alignment
break;
}
} }
// text doesn't fit
size -= rdc.getFontSizeStep();
} }
// align text // align text
RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect); RealPoint text_pos = align_in_rect(text_alignment, ts, sym_rect);
// draw text // draw text
if (text_font->hasShadow()) { if (text_font->hasShadow()) {
rdc.SetTextForeground(text_font->shadow_color); 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.SetTextForeground(text_font->color);
rdc.DrawText(sym.text, text_pos); rdc.DrawText(sym.text, text_pos, 0, 1, stretch);
// done // done
dc.SelectObject(wxNullBitmap); dc.SelectObject(wxNullBitmap);
return bmp.ConvertToImage(); return bmp.ConvertToImage();
......
...@@ -43,6 +43,8 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { ...@@ -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 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_fact = (w2 << shift) / w1; // how much to output for 256 input = 1 pixel
int out_rest = (w2 << shift) % w1; 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) { for (int y = 0 ; y < h ; ++y) {
int in_rem = out_fact + out_rest; int in_rem = out_fact + out_rest;
for (int x = 0 ; x < w2 ; ++x) { for (int x = 0 ; x < w2 ; ++x) {
...@@ -61,7 +63,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { ...@@ -61,7 +63,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) {
in_rem -= out_rem; in_rem -= out_rem;
} }
// store // store
*out = tot >> shift; *out = top(((tot >> shift) * mul) >> 8);
out += 1; out += 1;
} }
} }
...@@ -89,6 +91,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { ...@@ -89,6 +91,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) {
int h1 = img_in.GetHeight(), w = img_out.GetWidth(); 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_fact = (h << shift) / h1; // how much to output for 256 input = 1 pixel
int out_rest = (h << shift) % h1; int out_rest = (h << shift) % h1;
int mul = 128 + min(256, 128*h1/(text_scaling*h));
for (int x = 0 ; x < w ; ++x) { for (int x = 0 ; x < w ; ++x) {
int in_rem = out_fact + out_rest; int in_rem = out_fact + out_rest;
for (int y = 0 ; y < h ; ++y) { for (int y = 0 ; y < h ; ++y) {
...@@ -107,7 +110,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) { ...@@ -107,7 +110,7 @@ void downsample_to_alpha(Image& img_in, Image& img_out) {
in_rem -= out_rem; in_rem -= out_rem;
} }
// store // store
*out = tot >> shift; *out = top(((tot >> shift) * mul) >> 8);
out += line_size; out += line_size;
} }
in = in - h1 * line_size + 1; in = in - h1 * line_size + 1;
......
...@@ -131,12 +131,12 @@ RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, RenderQuality quality) ...@@ -131,12 +131,12 @@ RotatedDC::RotatedDC(DC& dc, const Rotation& rotation, RenderQuality quality)
// ----------------------------------------------------------------------------- : RotatedDC : Drawing // ----------------------------------------------------------------------------- : 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 (text.empty()) return;
if (quality == QUALITY_AA) { if (quality == QUALITY_AA) {
RealRect r(pos, GetTextExtent(text)); RealRect r(pos, GetTextExtent(text));
RealRect r_ext = trNoNeg(r); 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) { } else if (quality == QUALITY_SUB_PIXEL) {
RealPoint p_ext = tr(pos)*text_scaling; RealPoint p_ext = tr(pos)*text_scaling;
double usx,usy; double usx,usy;
......
...@@ -151,7 +151,7 @@ class RotatedDC : public Rotation { ...@@ -151,7 +151,7 @@ class RotatedDC : public Rotation {
// --------------------------------------------------- : Drawing // --------------------------------------------------- : 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! /// Draw abitmap, it must already be zoomed!
void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos); void DrawBitmap(const Bitmap& bitmap, const RealPoint& pos);
/// Draw an image using the given combining mode, the image must already be zoomed! /// Draw an image using the given combining mode, the image must already be zoomed!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment