implemented symbol font

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@81 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2006-11-20 14:48:53 +00:00
parent dd34042c07
commit 141400d8aa
18 changed files with 346 additions and 44 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ struct TextElementsFromString {
} else {
// add a new element for this text
if (symbol > 0 && style.symbol_font.valid()) {
te.elements.push_back(new_shared4<SymbolTextElement>(text, pos, pos + 1, style.symbol_font));
te.elements.push_back(new_shared5<SymbolTextElement>(text, pos, pos + 1, style.symbol_font, &ctx));
} else {
te.elements.push_back(new_shared4<FontTextElement> (text, pos, pos + 1, style.font.make(bold > 0, italic > 0)));
}
+3 -2
View File
@@ -142,9 +142,9 @@ class FontTextElement : public SimpleTextElement {
/// A text element that uses a symbol font
class SymbolTextElement : public SimpleTextElement {
public:
SymbolTextElement(const String& text, size_t start ,size_t end, const SymbolFontRef& font)
SymbolTextElement(const String& text, size_t start ,size_t end, const SymbolFontRef& font, Context* ctx)
: SimpleTextElement(text, start, end)
, font(font)
, font(font), ctx(*ctx)
{}
virtual void draw (RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const;
@@ -152,6 +152,7 @@ class SymbolTextElement : public SimpleTextElement {
virtual double minScale() const;
private:
const SymbolFontRef& font; // owned by TextStyle
Context& ctx;
};
// ----------------------------------------------------------------------------- : CompoundTextElement
+8 -3
View File
@@ -7,17 +7,22 @@
// ----------------------------------------------------------------------------- : Includes
#include <render/text/element.hpp>
#include <data/symbol_font.hpp>
// ----------------------------------------------------------------------------- : SymbolTextElement
void SymbolTextElement::draw(RotatedDC& dc, double scale, const RealRect& rect, double* xs, DrawWhat what, size_t start, size_t end) const {
// TODO
if (font.font) {
font.font->draw(dc, ctx, rect, font.size * scale, font.alignment, text.substr(start, end-start));
}
}
void SymbolTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>& out) const {
// TODO
if (font.font) {
font.font->getCharInfo(dc, ctx, font.size * scale, text.substr(start, end-start), out);
}
}
double SymbolTextElement::minScale() const {
return 1; // TODO
return font.size / min(0.001, min(font.size, font.scale_down_to));
}
+6 -1
View File
@@ -129,7 +129,12 @@ const TextViewer::Line& TextViewer::findLine(size_t index) const {
// ----------------------------------------------------------------------------- : Elements
void TextViewer::prepareElements(const String& text, const TextStyle& style, Context& ctx) {
elements.fromString(text, 0, text.size(), style, ctx);
if (style.always_symbol) {
elements.elements.clear();
elements.elements.push_back(new_shared5<SymbolTextElement>(text, 0, text.size(), style.symbol_font, &ctx));
} else {
elements.fromString(text, 0, text.size(), style, ctx);
}
}