[TD]fix Text sizes not exact

This commit is contained in:
Wanderer Fan
2022-05-14 11:42:27 -04:00
committed by WandererFan
parent 8b4e114b9d
commit 71426aa467
10 changed files with 67 additions and 45 deletions

View File

@@ -127,14 +127,14 @@ void QGIViewAnnotation::drawAnnotation()
}
const std::vector<std::string>& annoText = viewAnno->Text.getValues();
int fontSize = calculateFontPixelSize(viewAnno->TextSize.getValue());
int scaledSize = exactFontSize(viewAnno->Font.getValue(), viewAnno->TextSize.getValue());
//build HTML/CSS formatting around Text lines
std::stringstream ss;
ss << "<html>\n<head>\n<style>\n";
ss << "p {";
ss << "font-family:" << viewAnno->Font.getValue() << "; ";
ss << "font-size:" << fontSize << "px; ";
ss << "font-size:" << scaledSize << "px; ";
if (viewAnno->TextStyle.isValue("Normal")) {
ss << "font-weight:normal; font-style:normal; ";
} else if (viewAnno->TextStyle.isValue("Bold")) {
@@ -160,7 +160,7 @@ void QGIViewAnnotation::drawAnnotation()
std::string lt = std::regex_replace((*it), std::regex("<"), "&lt;");
ss << lt;
}
ss << "<br></p>\n</body>\n</html> ";
ss << "</p>\n</body>\n</html> ";
prepareGeometryChange();
m_textItem->setTextWidth(Rez::guiX(viewAnno->MaxWidth.getValue()));