Implemented exporting symbol fonts;

Rendering symbols to an image always uses anti-aliassing (by downsampling from a large size);
Finished the spoiler export template;
Added <soft-line> tag to make line breaks use the line height for soft line breaks

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@440 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-27 18:58:43 +00:00
parent ef1ac8fd5b
commit 31b7380d99
19 changed files with 532 additions and 132 deletions
+6 -3
View File
@@ -72,13 +72,13 @@ const size_t param_colors_count = sizeof(param_colors) / sizeof(param_colors[0])
struct TextElementsFromString {
// What formatting is enabled?
int bold, italic, symbol;
int soft, kwpph, param, line;
int soft, kwpph, param, line, soft_line;
int code, code_kw, code_string, param_ref, error;
int param_id;
bool bracket;
TextElementsFromString()
: bold(0), italic(0), symbol(0), soft(0), kwpph(0), param(0), line(0)
: bold(0), italic(0), symbol(0), soft(0), kwpph(0), param(0), line(0), soft_line(0)
, code(0), code_kw(0), code_string(0), param_ref(0), error(0)
, param_id(0), bracket(false) {}
@@ -125,6 +125,8 @@ struct TextElementsFromString {
else if (is_substr(text, tag_start, _("</atom-param"))) param -= 1;
else if (is_substr(text, tag_start, _( "<line"))) line += 1;
else if (is_substr(text, tag_start, _("</line"))) line -= 1;
else if (is_substr(text, tag_start, _( "<soft-line"))) soft_line += 1;
else if (is_substr(text, tag_start, _("</soft-line"))) soft_line -= 1;
else if (is_substr(text, tag_start, _("<atom"))) {
// 'atomic' indicator
size_t end_tag = min(end, match_close_tag(text, tag_start));
@@ -178,7 +180,8 @@ struct TextElementsFromString {
bracket ? pos + 2 : pos + 1,
font,
soft > 0 ? DRAW_ACTIVE : DRAW_NORMAL,
line > 0 ? BREAK_LINE : BREAK_HARD);
line > 0 ? BREAK_LINE :
soft_line > 0 ? BREAK_SOFT : BREAK_HARD);
}
if (bracket) {
e->content = String(LEFT_ANGLE_BRACKET) + c + RIGHT_ANGLE_BRACKET;
+2 -1
View File
@@ -34,7 +34,8 @@ enum DrawWhat
enum LineBreak
{ BREAK_NO // no line break ever
, BREAK_MAYBE // break here when in "direction:vertical" mode
, BREAK_SOFT // optional line break (' ')
, BREAK_SPACE // optional line break (' ')
, BREAK_SOFT // always a line break, spacing as a soft break
, BREAK_HARD // always a line break ('\n')
, BREAK_LINE // line break with a separator line (<line>)
};
+1 -1
View File
@@ -43,7 +43,7 @@ void FontTextElement::getCharInfo(RotatedDC& dc, double scale, vector<CharInfo>&
} else {
RealSize s = dc.GetTextExtent(content.substr(line_start - this->start, i - line_start + 1));
out.push_back(CharInfo(RealSize(s.width - prev_width, s.height),
c == _(' ') ? BREAK_SOFT : BREAK_MAYBE
c == _(' ') ? BREAK_SPACE : BREAK_MAYBE
));
prev_width = s.width;
}
+8 -4
View File
@@ -419,7 +419,11 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
bool accept_word = false; // the current word should be added to the line
bool hide_breaker = true; // hide the \n or _(' ') that caused a line break
double line_height_multiplier = 1; // multiplier for line height for next line top
if (c.break_after == BREAK_HARD) {
if (c.break_after == BREAK_SOFT) {
break_now = true;
accept_word = true;
line_height_multiplier = style.line_height_soft;
} else if (c.break_after == BREAK_HARD) {
break_now = true;
accept_word = true;
line_height_multiplier = style.line_height_hard;
@@ -428,7 +432,7 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars,
break_now = true;
accept_word = true;
line_height_multiplier = style.line_height_line;
} else if (c.break_after == BREAK_SOFT && style.field().multi_line) {
} else if (c.break_after == BREAK_SPACE && style.field().multi_line) {
// Soft break == end of word
accept_word = true;
} else if (c.break_after == BREAK_MAYBE && style.direction == TOP_TO_BOTTOM) {
@@ -563,13 +567,13 @@ void TextViewer::alignLines(RotatedDC& dc, const vector<CharInfo>& chars, const
double hdelta = s.width - width; // amount of space to distribute
int count = 0; // distribute it among this many words
for (size_t k = l.start + 1 ; k < l.end() - 1 ; ++k) {
if (chars[k].break_after == BREAK_SOFT) ++count;
if (chars[k].break_after == BREAK_SPACE) ++count;
}
if (count == 0) count = 1; // prevent div by 0
int i = 0; size_t j = l.start;
FOR_EACH(c, l.positions) {
c += hdelta * i / count;
if (j < l.end() && chars[j++].break_after == BREAK_SOFT) i++;
if (j < l.end() && chars[j++].break_after == BREAK_SPACE) i++;
}
} else {
// simple alignment