mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Made symbol font size and alignment scriptable.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1091 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,12 +7,12 @@ A reference to a [[type:symbol font]].
|
||||
In [[type:stylesheet]]s the symbol fonts are not included inline, instead they are referenced by their package name.
|
||||
|
||||
--Properties--
|
||||
! Property Type Default Description
|
||||
! Property Type Default Description
|
||||
| @name@ [[type:scriptable]] Name of a [[type:symbol font]]
|
||||
''required'' Name of the symbol font package to use (without the extension).
|
||||
| @size@ [[type:double]] 12 Size in points to render the symbols with.
|
||||
| @scale down to@ [[type:double]] 1 Minimum size in points to scale the size down to.
|
||||
| @alignment@ [[type:alignment]] @"middle center"@ Alignment of symbols in a line of text.
|
||||
''required'' Name of the symbol font package to use (without the extension).
|
||||
| @size@ [[type:scriptable]] [[type:double]] 12 Size in points to render the symbols with.
|
||||
| @scale down to@ [[type:double]] 1 Minimum size in points to scale the size down to.
|
||||
| @alignment@ [[type:scriptable]] [[type:alignment]] @"middle center"@ Alignment of symbols in a line of text.
|
||||
|
||||
--Example--
|
||||
>symbol font:
|
||||
|
||||
@@ -550,17 +550,22 @@ bool SymbolFontRef::valid() const {
|
||||
}
|
||||
|
||||
bool SymbolFontRef::update(Context& ctx) {
|
||||
bool changes = false;
|
||||
if (name.update(ctx)) {
|
||||
// font name changed, load another font
|
||||
loadFont(ctx);
|
||||
return true;
|
||||
} else {
|
||||
if (!font) loadFont(ctx);
|
||||
return false;
|
||||
changes = true;
|
||||
} else if (!font) {
|
||||
loadFont(ctx);
|
||||
}
|
||||
changes |= size.update(ctx);
|
||||
changes |= alignment.update(ctx);
|
||||
return changes;
|
||||
}
|
||||
void SymbolFontRef::initDependencies(Context& ctx, const Dependency& dep) const {
|
||||
name.initDependencies(ctx, dep);
|
||||
size.initDependencies(ctx, dep);
|
||||
alignment.initDependencies(ctx, dep);
|
||||
}
|
||||
|
||||
void SymbolFontRef::loadFont(Context& ctx) {
|
||||
|
||||
@@ -154,11 +154,11 @@ class SymbolFontRef {
|
||||
/// Is a font loaded?
|
||||
bool valid() const;
|
||||
|
||||
Scriptable<String> name; ///< Font package name, can be changed with script
|
||||
double size; ///< Size of the font
|
||||
double scale_down_to; ///< Mimumum size of the font
|
||||
Alignment alignment; ///< Alignment of symbols in a line of text
|
||||
SymbolFontP font; ///< The font, if it is loaded
|
||||
Scriptable<String> name; ///< Font package name, can be changed with script
|
||||
Scriptable<double> size; ///< Size of the font
|
||||
double scale_down_to; ///< Mimumum size of the font
|
||||
Scriptable<Alignment> alignment; ///< Alignment of symbols in a line of text
|
||||
SymbolFontP font; ///< The font, if it is loaded
|
||||
|
||||
private:
|
||||
DECLARE_REFLECTION();
|
||||
|
||||
@@ -26,7 +26,7 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo
|
||||
}
|
||||
|
||||
double SymbolTextElement::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 SymbolTextElement::scaleStep() const {
|
||||
return 1. / max(font.size * 4, 1.);
|
||||
|
||||
Reference in New Issue
Block a user