mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
rename Font to FontRef
for consistency with SymbolFontRef
This commit is contained in:
@@ -167,7 +167,7 @@ public:
|
|||||||
|
|
||||||
ChoicePopupStyle popup_style; ///< Style of popups/menus
|
ChoicePopupStyle popup_style; ///< Style of popups/menus
|
||||||
ChoiceRenderStyle render_style; ///< Style of rendering
|
ChoiceRenderStyle render_style; ///< Style of rendering
|
||||||
Font font; ///< Font for drawing text (when RENDER_TEXT)
|
FontRef font; ///< Font for drawing text (when RENDER_TEXT)
|
||||||
CachedScriptableImage image; ///< Image to draw (when RENDER_IMAGE)
|
CachedScriptableImage image; ///< Image to draw (when RENDER_IMAGE)
|
||||||
map<String,ScriptableImage> choice_images; ///< Images for the various choices (when RENDER_IMAGE)
|
map<String,ScriptableImage> choice_images; ///< Images for the various choices (when RENDER_IMAGE)
|
||||||
bool choice_images_initialized;
|
bool choice_images_initialized;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public:
|
|||||||
InfoStyle(const InfoFieldP&);
|
InfoStyle(const InfoFieldP&);
|
||||||
DECLARE_STYLE_TYPE(Info);
|
DECLARE_STYLE_TYPE(Info);
|
||||||
|
|
||||||
Font font; ///< Font to use for the text
|
FontRef font; ///< Font to use for the text
|
||||||
Alignment alignment; ///< Alignment inside the box
|
Alignment alignment; ///< Alignment inside the box
|
||||||
double padding_left, padding_right; ///< Padding
|
double padding_left, padding_right; ///< Padding
|
||||||
double padding_top, padding_bottom;
|
double padding_top, padding_bottom;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
PackageChoiceStyle(const PackageChoiceFieldP& field);
|
PackageChoiceStyle(const PackageChoiceFieldP& field);
|
||||||
DECLARE_STYLE_TYPE(PackageChoice);
|
DECLARE_STYLE_TYPE(PackageChoice);
|
||||||
|
|
||||||
Font font; ///< Font to use for the text
|
FontRef font; ///< Font to use for the text
|
||||||
|
|
||||||
int update(Context&) override;
|
int update(Context&) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
TextStyle(const TextFieldP&);
|
TextStyle(const TextFieldP&);
|
||||||
DECLARE_STYLE_TYPE(Text);
|
DECLARE_STYLE_TYPE(Text);
|
||||||
|
|
||||||
Font font; ///< Font to use for the text
|
FontRef font; ///< Font to use for the text
|
||||||
SymbolFontRef symbol_font; ///< Symbol font for symbols in the text
|
SymbolFontRef symbol_font; ///< Symbol font for symbols in the text
|
||||||
bool always_symbol; ///< Should everything be drawn as symbols?
|
bool always_symbol; ///< Should everything be drawn as symbols?
|
||||||
bool allow_formating; ///< Is formating (bold/italic/..) allowed?
|
bool allow_formating; ///< Is formating (bold/italic/..) allowed?
|
||||||
|
|||||||
+9
-9
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Font
|
// ----------------------------------------------------------------------------- : Font
|
||||||
|
|
||||||
Font::Font()
|
FontRef::FontRef()
|
||||||
: name()
|
: name()
|
||||||
, size(1)
|
, size(1)
|
||||||
, underline(false)
|
, underline(false)
|
||||||
@@ -33,7 +33,7 @@ Font::Font()
|
|||||||
, flags(FONT_NORMAL)
|
, flags(FONT_NORMAL)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool Font::PreloadResourceFonts(bool recursive) {
|
bool FontRef::PreloadResourceFonts(bool recursive) {
|
||||||
#if wxUSE_PRIVATE_FONTS
|
#if wxUSE_PRIVATE_FONTS
|
||||||
String pathSeparator(wxFileName::GetPathSeparator());
|
String pathSeparator(wxFileName::GetPathSeparator());
|
||||||
String appPath(wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath());
|
String appPath(wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath());
|
||||||
@@ -68,7 +68,7 @@ bool Font::PreloadResourceFonts(bool recursive) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
void FontRef::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFilePaths, bool recursive) {
|
||||||
wxDir fontsDirectory(fontsDirectoryPath);
|
wxDir fontsDirectory(fontsDirectoryPath);
|
||||||
String fontFileName = _("");
|
String fontFileName = _("");
|
||||||
bool hasNext = fontsDirectory.GetFirst(&fontFileName);
|
bool hasNext = fontsDirectory.GetFirst(&fontFileName);
|
||||||
@@ -86,7 +86,7 @@ void Font::TallyResourceFonts(String fontsDirectoryPath, vector<String>& fontFil
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Font::update(Context& ctx) {
|
bool FontRef::update(Context& ctx) {
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
changes |= name .update(ctx);
|
changes |= name .update(ctx);
|
||||||
changes |= italic_name .update(ctx);
|
changes |= italic_name .update(ctx);
|
||||||
@@ -108,7 +108,7 @@ bool Font::update(Context& ctx) {
|
|||||||
| (style() == _("italic") ? FONT_ITALIC : FONT_NORMAL);
|
| (style() == _("italic") ? FONT_ITALIC : FONT_NORMAL);
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
void FontRef::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||||
name .initDependencies(ctx, dep);
|
name .initDependencies(ctx, dep);
|
||||||
italic_name .initDependencies(ctx, dep);
|
italic_name .initDependencies(ctx, dep);
|
||||||
size .initDependencies(ctx, dep);
|
size .initDependencies(ctx, dep);
|
||||||
@@ -126,8 +126,8 @@ void Font::initDependencies(Context& ctx, const Dependency& dep) const {
|
|||||||
stroke_radius .initDependencies(ctx, dep);
|
stroke_radius .initDependencies(ctx, dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontP Font::make(int add_flags, bool add_underline, bool add_strikethrough, String const* other_family, Color const* other_color, double const* other_size) const {
|
FontRefP FontRef::make(int add_flags, bool add_underline, bool add_strikethrough, String const* other_family, Color const* other_color, double const* other_size) const {
|
||||||
FontP f(new Font(*this));
|
FontRefP f(new FontRef(*this));
|
||||||
f->flags |= add_flags;
|
f->flags |= add_flags;
|
||||||
if (add_flags & FONT_CODE_STRING) {
|
if (add_flags & FONT_CODE_STRING) {
|
||||||
f->color = Color(0,0,100);
|
f->color = Color(0,0,100);
|
||||||
@@ -163,7 +163,7 @@ FontP Font::make(int add_flags, bool add_underline, bool add_strikethrough, Stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const String BOLD_STRING = _(" Bold");
|
static const String BOLD_STRING = _(" Bold");
|
||||||
wxFont Font::toWxFont(double scale) const {
|
wxFont FontRef::toWxFont(double scale) const {
|
||||||
int size_i = to_int(scale * size);
|
int size_i = to_int(scale * size);
|
||||||
wxFontWeight weight_i = flags & FONT_BOLD ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL;
|
wxFontWeight weight_i = flags & FONT_BOLD ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL;
|
||||||
wxFontStyle style_i = flags & FONT_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL;
|
wxFontStyle style_i = flags & FONT_ITALIC ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL;
|
||||||
@@ -203,7 +203,7 @@ wxFont Font::toWxFont(double scale) const {
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPLEMENT_REFLECTION_NO_SCRIPT(Font) {
|
IMPLEMENT_REFLECTION_NO_SCRIPT(FontRef) {
|
||||||
REFLECT(name);
|
REFLECT(name);
|
||||||
REFLECT(size);
|
REFLECT(size);
|
||||||
REFLECT(weight);
|
REFLECT(weight);
|
||||||
|
|||||||
+5
-5
@@ -13,11 +13,11 @@
|
|||||||
#include <script/scriptable.hpp>
|
#include <script/scriptable.hpp>
|
||||||
#include <gfx/color.hpp>
|
#include <gfx/color.hpp>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(Font);
|
DECLARE_POINTER_TYPE(FontRef);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Font
|
// ----------------------------------------------------------------------------- : Font
|
||||||
|
|
||||||
enum FontFlags
|
enum FontRefFlags
|
||||||
{ FONT_NORMAL = 0
|
{ FONT_NORMAL = 0
|
||||||
, FONT_BOLD = 0x01
|
, FONT_BOLD = 0x01
|
||||||
, FONT_ITALIC = 0x02
|
, FONT_ITALIC = 0x02
|
||||||
@@ -32,7 +32,7 @@ enum FontFlags
|
|||||||
|
|
||||||
/// A reference to a font for rendering text
|
/// A reference to a font for rendering text
|
||||||
/** Contains additional information about scaling, color and shadow */
|
/** Contains additional information about scaling, color and shadow */
|
||||||
class Font : public IntrusivePtrBase<Font> {
|
class FontRef : public IntrusivePtrBase<FontRef> {
|
||||||
public:
|
public:
|
||||||
Scriptable<String> name; ///< Name of the referenced font
|
Scriptable<String> name; ///< Name of the referenced font
|
||||||
Scriptable<String> italic_name; ///< Font name for italic text (optional)
|
Scriptable<String> italic_name; ///< Font name for italic text (optional)
|
||||||
@@ -53,7 +53,7 @@ public:
|
|||||||
Color separator_color; ///< Color for <sep> text
|
Color separator_color; ///< Color for <sep> text
|
||||||
int flags; ///< FontFlags for this font
|
int flags; ///< FontFlags for this font
|
||||||
|
|
||||||
Font();
|
FontRef();
|
||||||
|
|
||||||
/// Load fonts (.ttf or .otf) from all directories in the app directory that contain "fonts" in their names,
|
/// Load fonts (.ttf or .otf) from all directories in the app directory that contain "fonts" in their names,
|
||||||
/// and optionaly their subdirectories, returns true if there were errors
|
/// and optionaly their subdirectories, returns true if there were errors
|
||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Add style, and optionally change the font family, color and size
|
/// Add style, and optionally change the font family, color and size
|
||||||
FontP make(int add_flags, bool add_underline, bool add_strikethrough, String const* other_family, Color const* other_color, double const* other_size) const;
|
FontRefP make(int add_flags, bool add_underline, bool add_strikethrough, String const* other_family, Color const* other_color, double const* other_size) const;
|
||||||
|
|
||||||
/// Convert this font reference to a wxFont
|
/// Convert this font reference to a wxFont
|
||||||
wxFont toWxFont(double scale) const;
|
wxFont toWxFont(double scale) const;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
bool regex; ///< Should this symbol be matched by a regex?
|
bool regex; ///< Should this symbol be matched by a regex?
|
||||||
int draw_text; ///< The index of the captured regex expression to draw, or -1 to not draw text
|
int draw_text; ///< The index of the captured regex expression to draw, or -1 to not draw text
|
||||||
Regex code_regex; ///< Regex for matching the symbol code
|
Regex code_regex; ///< Regex for matching the symbol code
|
||||||
FontP text_font; ///< Font to draw text in.
|
FontRefP text_font; ///< Font to draw text in.
|
||||||
Alignment text_alignment;
|
Alignment text_alignment;
|
||||||
double text_margin_left;
|
double text_margin_left;
|
||||||
double text_margin_right;
|
double text_margin_right;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include <data/font.hpp>
|
#include <data/font.hpp>
|
||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
|
|
||||||
DECLARE_POINTER_TYPE(Font);
|
DECLARE_POINTER_TYPE(FontRef);
|
||||||
DECLARE_POINTER_TYPE(SymbolFont);
|
DECLARE_POINTER_TYPE(SymbolFont);
|
||||||
DECLARE_POINTER_TYPE(SymbolInFont);
|
DECLARE_POINTER_TYPE(SymbolInFont);
|
||||||
DECLARE_POINTER_TYPE(InsertSymbolMenu);
|
DECLARE_POINTER_TYPE(InsertSymbolMenu);
|
||||||
|
|||||||
+1
-1
@@ -87,7 +87,7 @@ int MSE::OnRun() {
|
|||||||
// Platform friendly appname
|
// Platform friendly appname
|
||||||
SetAppName(_("magicseteditor"));
|
SetAppName(_("magicseteditor"));
|
||||||
#endif
|
#endif
|
||||||
Font::PreloadResourceFonts(true);
|
FontRef::PreloadResourceFonts(true);
|
||||||
wxInitAllImageHandlers();
|
wxInitAllImageHandlers();
|
||||||
wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker
|
wxFileSystem::AddHandler(new wxInternetFSHandler); // needed for update checker
|
||||||
wxSocketBase::Initialize();
|
wxSocketBase::Initialize();
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ private:
|
|||||||
// mixed symbols/text, autodetected by symbol font
|
// mixed symbols/text, autodetected by symbol font
|
||||||
size_t text_pos = 0;
|
size_t text_pos = 0;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
FontP font;
|
FontRefP font;
|
||||||
while (pos < end-start) {
|
while (pos < end-start) {
|
||||||
if (size_t n = style.symbol_font.font->recognizePrefix(content,pos)) {
|
if (size_t n = style.symbol_font.font->recognizePrefix(content,pos)) {
|
||||||
// at 'pos' there are n symbol font characters
|
// at 'pos' there are n symbol font characters
|
||||||
@@ -308,7 +308,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FontP makeFont(const TextStyle& style) {
|
FontRefP makeFont(const TextStyle& style) {
|
||||||
return style.font.make(
|
return style.font.make(
|
||||||
(bold > 0 ? FONT_BOLD : FONT_NORMAL) |
|
(bold > 0 ? FONT_BOLD : FONT_NORMAL) |
|
||||||
(italic > 0 ? FONT_ITALIC : FONT_NORMAL) |
|
(italic > 0 ? FONT_ITALIC : FONT_NORMAL) |
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public:
|
|||||||
/// A text element that uses a normal font
|
/// A text element that uses a normal font
|
||||||
class FontTextElement : public TextElement {
|
class FontTextElement : public TextElement {
|
||||||
public:
|
public:
|
||||||
FontTextElement(const String& content, size_t start, size_t end, const FontP& font, DrawWhat draw_as, LineBreak break_style)
|
FontTextElement(const String& content, size_t start, size_t end, const FontRefP& font, DrawWhat draw_as, LineBreak break_style)
|
||||||
: TextElement(start, end), content(content)
|
: TextElement(start, end), content(content)
|
||||||
, font(font), draw_as(draw_as), break_style(break_style)
|
, font(font), draw_as(draw_as), break_style(break_style)
|
||||||
{}
|
{}
|
||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
double scaleStep() const override;
|
double scaleStep() const override;
|
||||||
private:
|
private:
|
||||||
String content; ///< Text to show
|
String content; ///< Text to show
|
||||||
FontP font;
|
FontRefP font;
|
||||||
DrawWhat draw_as;
|
DrawWhat draw_as;
|
||||||
LineBreak break_style;
|
LineBreak break_style;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style,
|
|||||||
if (style.render_style & RENDER_IMAGE) {
|
if (style.render_style & RENDER_IMAGE) {
|
||||||
text_align = ALIGN_MIDDLE_LEFT; // can't align both text and image in the same way
|
text_align = ALIGN_MIDDLE_LEFT; // can't align both text and image in the same way
|
||||||
}
|
}
|
||||||
Font& font = style.font;
|
FontRef& font = style.font;
|
||||||
Color font_color = font.color;
|
Color font_color = font.color;
|
||||||
if (viewer.nativeLook()) {
|
if (viewer.nativeLook()) {
|
||||||
font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
font.color = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
|
|||||||
}
|
}
|
||||||
if (style().render_style & RENDER_TEXT) {
|
if (style().render_style & RENDER_TEXT) {
|
||||||
// draw text
|
// draw text
|
||||||
Font& font = style().font;
|
FontRef& font = style().font;
|
||||||
Color font_color = font.color;
|
Color font_color = font.color;
|
||||||
RealSize margin(0, 0);
|
RealSize margin(0, 0);
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ void PackageChoiceValueViewer::draw(RotatedDC& dc) {
|
|||||||
dc.DrawBitmap(image, RealPoint(0,0));
|
dc.DrawBitmap(image, RealPoint(0,0));
|
||||||
}
|
}
|
||||||
// draw text
|
// draw text
|
||||||
Font& font = style().font;
|
FontRef& font = style().font;
|
||||||
Color font_color = font.color;
|
Color font_color = font.color;
|
||||||
RealSize margin(0, 0);
|
RealSize margin(0, 0);
|
||||||
if (nativeLook()) {
|
if (nativeLook()) {
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ void RotatedDC::DrawText(const String& text, const RealPoint& pos, Color color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotatedDC::DrawTextWithShadowOrStroke(const String& text, const Font& font, const RealPoint& pos, double scale, double stretch) {
|
void RotatedDC::DrawTextWithShadowOrStroke(const String& text, const FontRef& font, const RealPoint& pos, double scale, double stretch) {
|
||||||
double s_scale = scale * dc.GetFont().GetPointSize() / text_scaling / 15.;
|
double s_scale = scale * dc.GetFont().GetPointSize() / text_scaling / 15.;
|
||||||
if (font.hasShadow() && !font.hasStroke()) {
|
if (font.hasShadow() && !font.hasStroke()) {
|
||||||
RealSize shadow_displacement = trInvS(RealSize(font.shadow_displacement_x, font.shadow_displacement_y) * s_scale);
|
RealSize shadow_displacement = trInvS(RealSize(font.shadow_displacement_x, font.shadow_displacement_y) * s_scale);
|
||||||
@@ -326,7 +326,7 @@ void RotatedDC::SetFont(const wxFont& font) {
|
|||||||
dc.SetFont(scaled);
|
dc.SetFont(scaled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RotatedDC::SetFont(const Font& font, double scale) {
|
void RotatedDC::SetFont(const FontRef& font, double scale) {
|
||||||
dc.SetFont(font.toWxFont(trS(scale) * (quality == QUALITY_LOW ? 1 : text_scaling)));
|
dc.SetFont(font.toWxFont(trS(scale) * (quality == QUALITY_LOW ? 1 : text_scaling)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <util/real_point.hpp>
|
#include <util/real_point.hpp>
|
||||||
#include <gfx/gfx.hpp>
|
#include <gfx/gfx.hpp>
|
||||||
|
|
||||||
class Font;
|
class FontRef;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Rotation
|
// ----------------------------------------------------------------------------- : Rotation
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ public:
|
|||||||
void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, Color stroke_color = Color(0,0,0), int stroke_radius = 0, double stretch = 1.0);
|
void DrawText (const String& text, const RealPoint& pos, int blur_radius = 0, Color stroke_color = Color(0,0,0), int stroke_radius = 0, double stretch = 1.0);
|
||||||
void DrawText (const String& text, const RealPoint& pos, Color color, int blur_radius = 0, Color stroke_color = Color(0,0,0), int stroke_radius = 0, double stretch = 1.0);
|
void DrawText (const String& text, const RealPoint& pos, Color color, int blur_radius = 0, Color stroke_color = Color(0,0,0), int stroke_radius = 0, double stretch = 1.0);
|
||||||
/// Draw text with a shadow or stroke, and color settings of the given font
|
/// Draw text with a shadow or stroke, and color settings of the given font
|
||||||
void DrawTextWithShadowOrStroke(const String& text, const Font& font, const RealPoint& pos, double scale = 1.0, double stretch = 1.0);
|
void DrawTextWithShadowOrStroke(const String& text, const FontRef& font, const RealPoint& pos, double scale = 1.0, 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!
|
||||||
@@ -194,7 +194,7 @@ public:
|
|||||||
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 size will be multiplied by 'scale' */
|
/** The font size will be multiplied by 'scale' */
|
||||||
void SetFont(const Font& font, double scale);
|
void SetFont(const FontRef& 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