mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 21:47:00 -04:00
Font name can now be scripted
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@291 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+41
-32
@@ -11,36 +11,47 @@
|
|||||||
// ----------------------------------------------------------------------------- : Font
|
// ----------------------------------------------------------------------------- : Font
|
||||||
|
|
||||||
Font::Font()
|
Font::Font()
|
||||||
: font(*wxNORMAL_FONT)
|
: name()
|
||||||
, size(font.GetPointSize())
|
, size(1)
|
||||||
|
, underline(false)
|
||||||
|
, weight_i(wxFONTWEIGHT_NORMAL), style_i(wxFONTSTYLE_NORMAL)
|
||||||
, scale_down_to(100000)
|
, scale_down_to(100000)
|
||||||
, shadow_displacement(0,0)
|
, shadow_displacement(0,0)
|
||||||
, separator_color(128,128,128)
|
, separator_color(128,128,128)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool Font::update(Context& ctx) {
|
bool Font::update(Context& ctx) {
|
||||||
return color .update(ctx)
|
bool changes
|
||||||
|
= name .update(ctx)
|
||||||
|
| italic_name .update(ctx)
|
||||||
|
| size .update(ctx)
|
||||||
|
| weight .update(ctx)
|
||||||
|
| style .update(ctx)
|
||||||
|
| underline .update(ctx)
|
||||||
|
| color .update(ctx)
|
||||||
| shadow_color.update(ctx);
|
| shadow_color.update(ctx);
|
||||||
|
weight_i = weight() == _("bold") ? wxBOLD : wxNORMAL;
|
||||||
|
style_i = style() == _("italic") ? wxITALIC : wxNORMAL;
|
||||||
|
return changes;
|
||||||
}
|
}
|
||||||
void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||||
|
name .initDependencies(ctx, dep);
|
||||||
|
italic_name .initDependencies(ctx, dep);
|
||||||
|
size .initDependencies(ctx, dep);
|
||||||
|
weight .initDependencies(ctx, dep);
|
||||||
|
style .initDependencies(ctx, dep);
|
||||||
|
underline .initDependencies(ctx, dep);
|
||||||
color .initDependencies(ctx, dep);
|
color .initDependencies(ctx, dep);
|
||||||
shadow_color.initDependencies(ctx, dep);
|
shadow_color.initDependencies(ctx, dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontP Font::make(bool bold, bool italic, bool placeholder_color, bool code_color, Color* other_color) const {
|
FontP Font::make(bool bold, bool italic, bool placeholder_color, bool code_color, Color* other_color) const {
|
||||||
FontP f(new Font(*this));
|
FontP f(new Font(*this));
|
||||||
if (bold) f->font.SetWeight(wxBOLD);
|
if (bold) f->weight_i = wxFONTWEIGHT_BOLD;
|
||||||
if (italic) {
|
if (italic) f->style_i = wxFONTSTYLE_ITALIC;
|
||||||
if (!italic_name.empty()) {
|
|
||||||
f->font.SetFaceName(italic_name);
|
|
||||||
} else {
|
|
||||||
f->font.SetWeight(wxBOLD);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (code_color) {
|
if (code_color) {
|
||||||
f->color = Color(128,0,0);
|
f->color = Color(128,0,0);
|
||||||
f->font.SetFamily(wxFONTFAMILY_TELETYPE);
|
f->type = TYPEWRITER;
|
||||||
f->font.SetFaceName(_("Courier New"));
|
|
||||||
}
|
}
|
||||||
if (placeholder_color) {
|
if (placeholder_color) {
|
||||||
f->color = f->separator_color;
|
f->color = f->separator_color;
|
||||||
@@ -52,29 +63,27 @@ FontP Font::make(bool bold, bool italic, bool placeholder_color, bool code_color
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reflect_font(Reader& tag, Font& font) {
|
wxFont Font::toWxFont(double scale) const {
|
||||||
String name, weight, style;
|
int size_i = scale * size;
|
||||||
double size = -1;
|
if (name().empty()) {
|
||||||
|
wxFont font = *wxNORMAL_FONT;
|
||||||
|
font.SetPointSize(size > 1 ? size_i : scale * font.GetPointSize());
|
||||||
|
return font;
|
||||||
|
} else if (type == TYPEWRITER) {
|
||||||
|
return wxFont(size_i, wxFONTFAMILY_TELETYPE, weight_i, underline(), _("Courier New"));
|
||||||
|
} else if (style_i == wxFONTSTYLE_ITALIC && !italic_name().empty()) {
|
||||||
|
return wxFont(size_i, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, weight_i, underline(), italic_name());
|
||||||
|
} else {
|
||||||
|
return wxFont(size_i, wxFONTFAMILY_DEFAULT, style_i, weight_i, underline(), name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLEMENT_REFLECTION(Font) {
|
||||||
REFLECT(name);
|
REFLECT(name);
|
||||||
REFLECT(size);
|
REFLECT(size);
|
||||||
REFLECT(weight);
|
REFLECT(weight);
|
||||||
REFLECT(style);
|
REFLECT(style);
|
||||||
if (!name.empty()) font.font.SetFaceName(name);
|
REFLECT(underline);
|
||||||
if (size > 0) font.font.SetPointSize((int) (font.size = size));
|
|
||||||
if (!weight.empty()) font.font.SetWeight(weight == _("bold") ? wxBOLD : wxNORMAL);
|
|
||||||
if (!style.empty()) font.font.SetWeight(style == _("italic") ? wxITALIC : wxNORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Tag>
|
|
||||||
void reflect_font(Tag& tag, const Font& font) {
|
|
||||||
REFLECT_N("name", font.font.GetFaceName());
|
|
||||||
REFLECT_N("size", font.size);
|
|
||||||
REFLECT_N("weight", font.font.GetWeight() == wxBOLD ? _("bold") : _("normal"));
|
|
||||||
REFLECT_N("style", font.font.GetStyle() == wxITALIC ? _("italic") : _("normal"));
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(Font) {
|
|
||||||
reflect_font(tag, *this);
|
|
||||||
REFLECT(italic_name);
|
REFLECT(italic_name);
|
||||||
REFLECT(color);
|
REFLECT(color);
|
||||||
REFLECT(scale_down_to);
|
REFLECT(scale_down_to);
|
||||||
|
|||||||
+18
-8
@@ -21,14 +21,21 @@ DECLARE_POINTER_TYPE(Font);
|
|||||||
/** Contains additional information about scaling, color and shadow */
|
/** Contains additional information about scaling, color and shadow */
|
||||||
class Font {
|
class Font {
|
||||||
public:
|
public:
|
||||||
wxFont font; ///< The actual wxFont to use
|
Scriptable<String> name; ///< Name of the font
|
||||||
double size; ///< Size of the font
|
Scriptable<String> italic_name; ///< Font name for italic text (optional)
|
||||||
double scale_down_to; ///< Smallest size to scale down to
|
Scriptable<double> size; ///< Size of the font
|
||||||
Scriptable<Color> color; ///< Color to use
|
Scriptable<String> weight, style; ///< Weight and style of the font (bold/italic)
|
||||||
Scriptable<Color> shadow_color; ///< Color for shadow
|
Scriptable<bool> underline; ///< Underlined?
|
||||||
RealSize shadow_displacement; ///< Position of the shadow
|
int weight_i, style_i; ///< wx constants for weight and style
|
||||||
String italic_name; ///< Font name for italic text (optional)
|
double scale_down_to; ///< Smallest size to scale down to
|
||||||
Color separator_color; ///< Color for <sep> text
|
Scriptable<Color> color; ///< Color to use
|
||||||
|
Scriptable<Color> shadow_color; ///< Color for shadow
|
||||||
|
RealSize shadow_displacement; ///< Position of the shadow
|
||||||
|
Color separator_color; ///< Color for <sep> text
|
||||||
|
enum {
|
||||||
|
NORMAL,
|
||||||
|
TYPEWRITER, ///< Use a typewriter font
|
||||||
|
} type;
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
|
|
||||||
@@ -43,6 +50,9 @@ class Font {
|
|||||||
/// Make a bold/italic/placeholder version of this font
|
/// Make a bold/italic/placeholder version of this font
|
||||||
FontP make(bool bold, bool italic, bool placeholder_color, bool code_color, Color* other_color) const;
|
FontP make(bool bold, bool italic, bool placeholder_color, bool code_color, Color* other_color) const;
|
||||||
|
|
||||||
|
/// Convert this font to a wxFont
|
||||||
|
wxFont toWxFont(double scale) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_REFLECTION();
|
DECLARE_REFLECTION();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ void ApprenticeExportWindow::onOk(wxCommandEvent& ev) {
|
|||||||
if (set->apprentice_code != new_set_code) {
|
if (set->apprentice_code != new_set_code) {
|
||||||
// changed something in the set
|
// changed something in the set
|
||||||
set->apprentice_code = new_set_code;
|
set->apprentice_code = new_set_code;
|
||||||
//%%set->actions.atSavePoint = false; // tell the user he needs to save
|
//set->actions.atSavePoint = false; // TODO: tell the user he needs to save
|
||||||
}
|
}
|
||||||
// Check if apprentice exists
|
// Check if apprentice exists
|
||||||
if (!wxFileExists(settings.apprentice_location + _("\\appr.exe"))) {
|
if (!wxFileExists(settings.apprentice_location + _("\\appr.exe"))) {
|
||||||
|
|||||||
@@ -151,6 +151,15 @@ RealSize SymbolInFont::size(Context& ctx, Package& pkg, double size) {
|
|||||||
void SymbolInFont::update(Context& ctx) {
|
void SymbolInFont::update(Context& ctx) {
|
||||||
enabled.update(ctx);
|
enabled.update(ctx);
|
||||||
}
|
}
|
||||||
|
void SymbolFont::update(Context& ctx) const {
|
||||||
|
// update all symbol-in-fonts
|
||||||
|
FOR_EACH_CONST(sym, symbols) {
|
||||||
|
sym->update(ctx);
|
||||||
|
}
|
||||||
|
if (text_font) {
|
||||||
|
text_font->update(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION(SymbolInFont) {
|
IMPLEMENT_REFLECTION(SymbolInFont) {
|
||||||
REFLECT(code);
|
REFLECT(code);
|
||||||
@@ -172,10 +181,7 @@ class SymbolFont::DrawableSymbol {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void SymbolFont::split(const String& text, Context& ctx, SplitSymbols& out) const {
|
void SymbolFont::split(const String& text, Context& ctx, SplitSymbols& out) const {
|
||||||
// update all symbol-in-fonts
|
update(ctx);
|
||||||
FOR_EACH_CONST(sym, symbols) {
|
|
||||||
sym->update(ctx);
|
|
||||||
}
|
|
||||||
// read a single symbol until we are done with the text
|
// read a single symbol until we are done with the text
|
||||||
for (size_t pos = 0 ; pos < text.size() ; ) {
|
for (size_t pos = 0 ; pos < text.size() ; ) {
|
||||||
// 1. check merged numbers
|
// 1. check merged numbers
|
||||||
@@ -264,7 +270,7 @@ void SymbolFont::drawWithText(RotatedDC& dc, Context& ctx, const RealRect& rect,
|
|||||||
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->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.width <= sym_rect.width && ts.height <= sym_rect.height) {
|
||||||
break; // text fits
|
break; // text fits
|
||||||
@@ -326,10 +332,7 @@ RealSize SymbolFont::defaultSymbolSize(Context& ctx, double font_size) {
|
|||||||
|
|
||||||
wxMenu* SymbolFont::insertSymbolMenu(Context& ctx) {
|
wxMenu* SymbolFont::insertSymbolMenu(Context& ctx) {
|
||||||
if (!processed_insert_symbol_menu && insert_symbol_menu) {
|
if (!processed_insert_symbol_menu && insert_symbol_menu) {
|
||||||
// update all symbol-in-fonts
|
update(ctx);
|
||||||
FOR_EACH_CONST(sym, symbols) {
|
|
||||||
sym->update(ctx);
|
|
||||||
}
|
|
||||||
// Make menu
|
// Make menu
|
||||||
processed_insert_symbol_menu = insert_symbol_menu->makeMenu(ID_INSERT_SYMBOL_MENU_MIN, ctx, *this);
|
processed_insert_symbol_menu = insert_symbol_menu->makeMenu(ID_INSERT_SYMBOL_MENU_MIN, ctx, *this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class SymbolFont : public Packaged {
|
|||||||
/// Process a choice from the insert symbol menu
|
/// Process a choice from the insert symbol menu
|
||||||
/** Return the code representing the symbol */
|
/** Return the code representing the symbol */
|
||||||
String insertSymbolCode(int menu_id) const;
|
String insertSymbolCode(int menu_id) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt img_size; ///< Font size that the images use
|
UInt img_size; ///< Font size that the images use
|
||||||
UInt min_size; ///< Minimum font size
|
UInt min_size; ///< Minimum font size
|
||||||
@@ -80,6 +80,9 @@ class SymbolFont : public Packaged {
|
|||||||
friend class InsertSymbolMenu;
|
friend class InsertSymbolMenu;
|
||||||
vector<SymbolInFontP> symbols; ///< The individual symbols
|
vector<SymbolInFontP> symbols; ///< The individual symbols
|
||||||
|
|
||||||
|
// Script update
|
||||||
|
void update(Context& ctx) const;
|
||||||
|
|
||||||
/// Find the default symbol
|
/// Find the default symbol
|
||||||
/** may return nullptr */
|
/** may return nullptr */
|
||||||
SymbolInFont* defaultSymbol() const;
|
SymbolInFont* defaultSymbol() const;
|
||||||
|
|||||||
@@ -231,18 +231,15 @@ void KeywordsPanel::onChangeSet() {
|
|||||||
// init text controls
|
// init text controls
|
||||||
keyword ->setSet(set);
|
keyword ->setSet(set);
|
||||||
keyword ->getStyle().font.size = 16;
|
keyword ->getStyle().font.size = 16;
|
||||||
keyword ->getStyle().font.font.SetPointSize(16);
|
|
||||||
keyword ->getStyle().padding_bottom = 1;
|
keyword ->getStyle().padding_bottom = 1;
|
||||||
keyword ->updateSize();
|
keyword ->updateSize();
|
||||||
match ->setSet(set);
|
match ->setSet(set);
|
||||||
match ->getStyle().font.size = 12;
|
match ->getStyle().font.size = 12;
|
||||||
match ->getStyle().font.font.SetPointSize(12);
|
|
||||||
match ->getStyle().padding_bottom = 1;
|
match ->getStyle().padding_bottom = 1;
|
||||||
match ->updateSize();
|
match ->updateSize();
|
||||||
reminder->setSet(set);
|
reminder->setSet(set);
|
||||||
reminder->getStyle().padding_bottom = 2;
|
reminder->getStyle().padding_bottom = 2;
|
||||||
match ->getStyle().font.size = 10;
|
match ->getStyle().font.size = 10;
|
||||||
match ->getStyle().font.font.SetPointSize(10);
|
|
||||||
reminder->updateSize();
|
reminder->updateSize();
|
||||||
rules ->setSet(set);
|
rules ->setSet(set);
|
||||||
// parameter & mode lists
|
// parameter & mode lists
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ void TextValueEditor::showCaret() {
|
|||||||
if (cursor.height == 0) {
|
if (cursor.height == 0) {
|
||||||
wxClientDC dc(&editor());
|
wxClientDC dc(&editor());
|
||||||
// TODO : high quality?
|
// TODO : high quality?
|
||||||
dc.SetFont(style().font.font);
|
dc.SetFont(style().font.toWxFont(1.0));
|
||||||
int hi;
|
int hi;
|
||||||
dc.GetTextExtent(_(" "), 0, &hi);
|
dc.GetTextExtent(_(" "), 0, &hi);
|
||||||
cursor.height = rot.trS(hi);
|
cursor.height = rot.trS(hi);
|
||||||
@@ -678,7 +678,7 @@ void TextValueEditor::determineSize(bool force_fit) {
|
|||||||
wxMemoryDC dc;
|
wxMemoryDC dc;
|
||||||
Bitmap bmp(1,1);
|
Bitmap bmp(1,1);
|
||||||
dc.SelectObject(bmp);
|
dc.SelectObject(bmp);
|
||||||
dc.SetFont(style().font.font);
|
dc.SetFont(style().font.toWxFont(1.0));
|
||||||
style().height = dc.GetCharHeight() + 2 + style().padding_top + style().padding_bottom;
|
style().height = dc.GetCharHeight() + 2 + style().padding_top + style().padding_bottom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, const double* xs, DrawWhat what, size_t start, size_t end) const {
|
||||||
if ((what & draw_as) != draw_as) return; // don't draw
|
if ((what & draw_as) != draw_as) return; // don't draw
|
||||||
dc.SetFont(font->font, font->size * scale);
|
dc.SetFont(*font, scale);
|
||||||
// draw shadow
|
// draw shadow
|
||||||
String text = content.substr(start - this->start, end - start);
|
String text = content.substr(start - this->start, end - start);
|
||||||
if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) {
|
if (!text.empty() && text.GetChar(text.size() - 1) == _('\n')) {
|
||||||
@@ -30,7 +30,7 @@ void FontTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, co
|
|||||||
|
|
||||||
void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
|
void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
|
||||||
// font
|
// font
|
||||||
dc.SetFont(font->font, font->size * scale);
|
dc.SetFont(*font, scale);
|
||||||
// find sizes & breaks
|
// find sizes & breaks
|
||||||
double prev_width = 0;
|
double prev_width = 0;
|
||||||
for (size_t i = start ; i < end ; ++i) {
|
for (size_t i = start ; i < end ; ++i) {
|
||||||
@@ -45,8 +45,8 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
double FontTextElement::minScale() const {
|
double FontTextElement::minScale() const {
|
||||||
return min(font->size, font->scale_down_to) / max(0.01, font->size);
|
return min(font->size(), font->scale_down_to) / max(0.01, font->size());
|
||||||
}
|
}
|
||||||
double FontTextElement::scaleStep() const {
|
double FontTextElement::scaleStep() const {
|
||||||
return 1. / max(font->size, 1.);
|
return 1. / max(font->size(), 1.);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle
|
|||||||
if (style.always_symbol && style.symbol_font.valid()) {
|
if (style.always_symbol && style.symbol_font.valid()) {
|
||||||
lines[0].line_height = style.symbol_font.font->defaultSymbolSize(ctx, style.symbol_font.size).height;
|
lines[0].line_height = style.symbol_font.font->defaultSymbolSize(ctx, style.symbol_font.size).height;
|
||||||
} else {
|
} else {
|
||||||
dc.SetFont(style.font.font);
|
dc.SetFont(style.font, scale);
|
||||||
lines[0].line_height = dc.GetTextExtent(_(" ")).height;
|
lines[0].line_height = dc.GetTextExtent(_(" ")).height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,7 +378,7 @@ void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle
|
|||||||
|
|
||||||
// HACK : fix empty first line before <line>, do this after align, so layout is not affected
|
// HACK : fix empty first line before <line>, do this after align, so layout is not affected
|
||||||
if (lines.size() > 1 && lines[0].line_height == 0) {
|
if (lines.size() > 1 && lines[0].line_height == 0) {
|
||||||
dc.SetFont(style.font.font);
|
dc.SetFont(style.font, scale);
|
||||||
double h = dc.GetCharHeight();
|
double h = dc.GetCharHeight();
|
||||||
lines[0].line_height = h;
|
lines[0].line_height = h;
|
||||||
lines[0].top -= h;
|
lines[0].top -= h;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void InfoValueViewer::draw(RotatedDC& dc) {
|
|||||||
} else {
|
} else {
|
||||||
dc.SetTextForeground(style().font.color);
|
dc.SetTextForeground(style().font.color);
|
||||||
dc.SetBrush(style().background_color);
|
dc.SetBrush(style().background_color);
|
||||||
dc.SetFont(style().font.font, style().font.size);
|
dc.SetFont(style().font, 1.0);
|
||||||
}
|
}
|
||||||
// draw background
|
// draw background
|
||||||
RealRect rect = style().getRect();
|
RealRect rect = style().getRect();
|
||||||
|
|||||||
+11
-9
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <util/rotation.hpp>
|
#include <util/rotation.hpp>
|
||||||
#include <gfx/gfx.hpp>
|
#include <gfx/gfx.hpp>
|
||||||
|
#include <data/font.hpp>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Rotation
|
// ----------------------------------------------------------------------------- : Rotation
|
||||||
|
|
||||||
@@ -179,19 +180,20 @@ void RotatedDC::SetTextForeground(const Color& color) { dc.SetTextForeground(col
|
|||||||
void RotatedDC::SetLogicalFunction(int function) { dc.SetLogicalFunction(function); }
|
void RotatedDC::SetLogicalFunction(int function) { dc.SetLogicalFunction(function); }
|
||||||
|
|
||||||
void RotatedDC::SetFont(const wxFont& font) {
|
void RotatedDC::SetFont(const wxFont& font) {
|
||||||
if (quality == QUALITY_LOW) {
|
if (quality == QUALITY_LOW && zoom == 1) {
|
||||||
dc.SetFont(font);
|
dc.SetFont(font);
|
||||||
} else {
|
} else {
|
||||||
SetFont(font, font.GetPointSize());
|
wxFont scaled = font;
|
||||||
|
if (quality == QUALITY_LOW) {
|
||||||
|
scaled.SetPointSize((int) trS(font.GetPointSize()));
|
||||||
|
} else {
|
||||||
|
scaled.SetPointSize((int) (trS(font.GetPointSize()) * text_scaling));
|
||||||
|
}
|
||||||
|
dc.SetFont(scaled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RotatedDC::SetFont(wxFont font, double size) {
|
void RotatedDC::SetFont(const Font& font, double scale) {
|
||||||
if (quality == QUALITY_LOW) {
|
dc.SetFont(font.toWxFont(trS(scale) * (quality == QUALITY_LOW ? 1 : text_scaling)));
|
||||||
font.SetPointSize((int) trS(size));
|
|
||||||
} else {
|
|
||||||
font.SetPointSize((int) (trS(size) * text_scaling));
|
|
||||||
}
|
|
||||||
dc.SetFont(font);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double RotatedDC::getFontSizeStep() const {
|
double RotatedDC::getFontSizeStep() const {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <util/real_point.hpp>
|
#include <util/real_point.hpp>
|
||||||
#include <gfx/gfx.hpp>
|
#include <gfx/gfx.hpp>
|
||||||
|
|
||||||
|
class Font;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Rotation
|
// ----------------------------------------------------------------------------- : Rotation
|
||||||
|
|
||||||
/// An object that can rotate coordinates inside a specified rectangle
|
/// An object that can rotate coordinates inside a specified rectangle
|
||||||
@@ -158,8 +160,8 @@ class RotatedDC : public Rotation {
|
|||||||
|
|
||||||
void SetFont(const wxFont& font);
|
void SetFont(const wxFont& font);
|
||||||
/// Set the font, scales for zoom and high_quality
|
/// Set the font, scales for zoom and high_quality
|
||||||
/** The font will get the given (internal) point size */
|
/** The font size will be multiplied by 'scale' */
|
||||||
void SetFont(wxFont font, double size);
|
void SetFont(const Font& font, double scale);
|
||||||
/// Steps to use when decrementing font size
|
/// Steps to use when decrementing font size
|
||||||
double getFontSizeStep() const;
|
double getFontSizeStep() const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user