From 01a220f19936d1f3defc2643303089898a88d54b Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 8 Aug 2008 00:35:53 +0000 Subject: [PATCH] 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 --- doc/type/symbol_font_reference.txt | 10 +++++----- src/data/symbol_font.cpp | 13 +++++++++---- src/data/symbol_font.hpp | 10 +++++----- src/render/text/symbol.cpp | 2 +- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/doc/type/symbol_font_reference.txt b/doc/type/symbol_font_reference.txt index f6615d5a..f9f4efd7 100644 --- a/doc/type/symbol_font_reference.txt +++ b/doc/type/symbol_font_reference.txt @@ -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: diff --git a/src/data/symbol_font.cpp b/src/data/symbol_font.cpp index 44071b25..d887f9e5 100644 --- a/src/data/symbol_font.cpp +++ b/src/data/symbol_font.cpp @@ -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) { diff --git a/src/data/symbol_font.hpp b/src/data/symbol_font.hpp index 1c3faf15..4a464c4a 100644 --- a/src/data/symbol_font.hpp +++ b/src/data/symbol_font.hpp @@ -154,11 +154,11 @@ class SymbolFontRef { /// Is a font loaded? bool valid() const; - Scriptable 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 name; ///< Font package name, can be changed with script + Scriptable size; ///< Size of the font + double scale_down_to; ///< Mimumum size of the font + Scriptable alignment; ///< Alignment of symbols in a line of text + SymbolFontP font; ///< The font, if it is loaded private: DECLARE_REFLECTION(); diff --git a/src/render/text/symbol.cpp b/src/render/text/symbol.cpp index 8605dab3..44ad3fcf 100644 --- a/src/render/text/symbol.cpp +++ b/src/render/text/symbol.cpp @@ -26,7 +26,7 @@ void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector