|
|
@@ -75,7 +75,7 @@ class TextLines
|
|
|
}
|
|
|
|
|
|
std::vector<TextItem> lines;
|
|
|
- int getHeight() { return height + lineSpacing*lines.size(); }
|
|
|
+ int getHeight() { return height + (lines.empty() ? 0 : (lineSpacing*(lines.size() -1))); }
|
|
|
int getLineSpacing() { return lineSpacing; }
|
|
|
|
|
|
private:
|
|
|
@@ -193,7 +193,10 @@ void ImageWriter::WriteDryRun(pngwriter &writer, pngwriterfont& font, char fontS
|
|
|
int written = 0;
|
|
|
|
|
|
do {
|
|
|
- lines.push_back(TextItem(writer, font, str.c_str(), written, written +maxLen, left +marginSize, top -marginSize -lines.getHeight() -fontSize, fontSize));
|
|
|
+ int py = top -lines.getHeight() -fontSize;
|
|
|
+ if (!lines.lines.empty())
|
|
|
+ py -= lines.getLineSpacing();
|
|
|
+ lines.push_back(TextItem(writer, font, str.c_str(), written, written +maxLen, left +marginSize, py, fontSize));
|
|
|
written += maxLen;
|
|
|
} while (written < str.length());
|
|
|
}
|
|
|
@@ -223,7 +226,9 @@ bool ImageWriter::Build(User *u)
|
|
|
TextLines lines(fontSize * 0.55);
|
|
|
for (const Anope::string& str: text)
|
|
|
WriteDryRun(writer, font, fontSize, str, lines, fgColor);
|
|
|
- int offsetY = lines.getHeight() > (bottom -top) ? 0 : (bottom -lines.getHeight() +lines.getLineSpacing()) /2;
|
|
|
+ int offsetY = -((top -bottom -lines.getHeight() -lines.getLineSpacing()) /2);
|
|
|
+ if (offsetY > 0)
|
|
|
+ offsetY = 0;
|
|
|
for (const TextItem& line: lines.lines)
|
|
|
WriteText(writer, font, fontSize, line, offsetY, fgColor);
|
|
|
writer.close();
|