← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3089: Fix DPI conversion problems

 

------------------------------------------------------------
revno: 3089
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2012-10-27 16:16:21 +0200
message:
  Fix DPI conversion problems
modified:
  changelog.txt
  win32/HtmlToRtf.cpp
  win32/WinUtil.cpp


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2012-10-21 22:03:59 +0000
+++ changelog.txt	2012-10-27 14:16:21 +0000
@@ -1,4 +1,6 @@
 * Fix a race condition on file list download (thanks bigmuscle)
+* [L#668548] Fix a potential infinite loop in BufferedSocket->setDataMode (crise)
+* Add "chunked" transfer encoding as per the HTTP/1.1 spec (crise)
 
 -- 0.802 2012-10-20 --
 * Perf improvements using lock-free queues, requires P6 CPUs (poy)
@@ -8,8 +10,7 @@
 * Plug resource leaks (poy)
 * [L#411484] [ADC] Fix BLOM when h > 32 (thanks yorhel)
 * [L#198416] Fix a crash when closing the download queue (poy)
-* [L#668548] Fix a potential infinite loop in BufferedSocket->setDataMode (crise)
-* Add "chunked" transfer encoding as per the HTTP/1.1 Spec
+* [L#1072041] Fix DPI conversion problems (poy)
 
 -- 0.801 2012-09-29 --
 * [L#1029629] Prevent crashes on heavy use by updating Boost.Atomic

=== modified file 'win32/HtmlToRtf.cpp'
--- win32/HtmlToRtf.cpp	2012-06-18 15:56:01 +0000
+++ win32/HtmlToRtf.cpp	2012-10-27 14:16:21 +0000
@@ -238,9 +238,9 @@
 }
 
 int Parser::rtfFontSize(float px) {
-	return px * 72.0 / 96.0 // px -> font points
-		* dwt::util::dpiFactor() // respect DPI settings
-		* 2.0; // RTF font sizes are expressed in half-points
+	return std::floor(px
+		* 72.0 / 96.0 // px -> font points
+		* 2.0); // RTF font sizes are expressed in half-points
 }
 
 size_t Parser::addColor(COLORREF color) {
@@ -283,7 +283,7 @@
 	/// @todo handle more than px sizes
 	auto& size = *(l.end() - 2);
 	if(size.size() > 2 && *(size.end() - 2) == 'p' && *(size.end() - 1) == 'x') { // 16px
-		contexts.back().fontSize = rtfFontSize(Util::toFloat(size.substr(0, size.size() - 2)));
+		contexts.back().fontSize = rtfFontSize(Util::toFloat(size.substr(0, size.size() - 2)) * dwt::util::dpiFactor());
 	}
 
 	// parse the optional third to last param (font weight).

=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp	2012-09-12 18:50:31 +0000
+++ win32/WinUtil.cpp	2012-10-27 14:16:21 +0000
@@ -386,7 +386,7 @@
 tstring WinUtil::encodeFont(LOGFONT const& font) {
 	tstring res(font.lfFaceName);
 	res += _T(',');
-	res += Text::toT(Util::toString(static_cast<int>(font.lfHeight / dwt::util::dpiFactor())));
+	res += Text::toT(Util::toString(static_cast<int>(std::floor(static_cast<float>(font.lfHeight) / dwt::util::dpiFactor()))));
 	res += _T(',');
 	res += Text::toT(Util::toString(font.lfWeight));
 	res += _T(',');
@@ -418,7 +418,7 @@
 	tstring face;
 	if(sl.size() >= 4) {
 		face = sl[0];
-		dest.lfHeight = Util::toInt(Text::fromT(sl[1])) * dwt::util::dpiFactor();
+		dest.lfHeight = std::ceil(static_cast<float>(Util::toInt(Text::fromT(sl[1]))) * dwt::util::dpiFactor());
 		dest.lfWeight = Util::toInt(Text::fromT(sl[2]));
 		dest.lfItalic = static_cast<BYTE>(Util::toInt(Text::fromT(sl[3])));
 		if(sl.size() >= 5) {