Commit ed535ee2 authored by twanvl's avatar twanvl

Made symbol font size and alignment scriptable.

parent 67e0732b
...@@ -10,9 +10,9 @@ In [[type:stylesheet]]s the symbol fonts are not included inline, instead they a ...@@ -10,9 +10,9 @@ In [[type:stylesheet]]s the symbol fonts are not included inline, instead they a
! Property Type Default Description ! Property Type Default Description
| @name@ [[type:scriptable]] Name of a [[type:symbol font]] | @name@ [[type:scriptable]] Name of a [[type:symbol font]]
''required'' Name of the symbol font package to use (without the extension). ''required'' Name of the symbol font package to use (without the extension).
| @size@ [[type:double]] 12 Size in points to render the symbols with. | @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. | @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. | @alignment@ [[type:scriptable]] [[type:alignment]] @"middle center"@ Alignment of symbols in a line of text.
--Example-- --Example--
>symbol font: >symbol font:
......
...@@ -550,17 +550,22 @@ bool SymbolFontRef::valid() const { ...@@ -550,17 +550,22 @@ bool SymbolFontRef::valid() const {
} }
bool SymbolFontRef::update(Context& ctx) { bool SymbolFontRef::update(Context& ctx) {
bool changes = false;
if (name.update(ctx)) { if (name.update(ctx)) {
// font name changed, load another font // font name changed, load another font
loadFont(ctx); loadFont(ctx);
return true; changes = true;
} else { } else if (!font) {
if (!font) loadFont(ctx); loadFont(ctx);
return false;
} }
changes |= size.update(ctx);
changes |= alignment.update(ctx);
return changes;
} }
void SymbolFontRef::initDependencies(Context& ctx, const Dependency& dep) const { void SymbolFontRef::initDependencies(Context& ctx, const Dependency& dep) const {
name.initDependencies(ctx, dep); name.initDependencies(ctx, dep);
size.initDependencies(ctx, dep);
alignment.initDependencies(ctx, dep);
} }
void SymbolFontRef::loadFont(Context& ctx) { void SymbolFontRef::loadFont(Context& ctx) {
......
...@@ -155,9 +155,9 @@ class SymbolFontRef { ...@@ -155,9 +155,9 @@ class SymbolFontRef {
bool valid() const; bool valid() const;
Scriptable<String> name; ///< Font package name, can be changed with script Scriptable<String> name; ///< Font package name, can be changed with script
double size; ///< Size of the font Scriptable<double> size; ///< Size of the font
double scale_down_to; ///< Mimumum size of the font double scale_down_to; ///< Mimumum size of the font
Alignment alignment; ///< Alignment of symbols in a line of text Scriptable<Alignment> alignment; ///< Alignment of symbols in a line of text
SymbolFontP font; ///< The font, if it is loaded SymbolFontP font; ///< The font, if it is loaded
private: private:
......
...@@ -26,7 +26,7 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo ...@@ -26,7 +26,7 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo
} }
double SymbolTextElement::minScale() const { 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 { double SymbolTextElement::scaleStep() const {
return 1. / max(font.size * 4, 1.); return 1. / max(font.size * 4, 1.);
......
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