Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Unified Diff: core/fxge/win32/fx_win32_print.cpp

Issue 2197553002: Fix CGdiPrinterDriver::DrawDeviceText() to draw multiple characters. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/win32/fx_win32_print.cpp
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 9e19873577604c967dee5c79b6f6607c66835570..ed9b781943b4ec86e9e1fa120d20d421fbc61951 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -282,23 +282,31 @@ FX_BOOL CGdiPrinterDriver::DrawDeviceText(int nChars,
// Text
CFX_WideString wsText;
+ std::vector<INT> spacing(nChars);
+ FX_FLOAT fPreviousOriginX = 0;
for (int i = 0; i < nChars; ++i) {
// Only works with PDFs from Skia's PDF generator. Cannot handle arbitrary
// values from PDFs.
const FXTEXT_CHARPOS& charpos = pCharPos[i];
- ASSERT(charpos.m_OriginX == 0);
- ASSERT(charpos.m_OriginY == 0);
ASSERT(charpos.m_AdjustMatrix[0] == 0);
ASSERT(charpos.m_AdjustMatrix[1] == 0);
ASSERT(charpos.m_AdjustMatrix[2] == 0);
ASSERT(charpos.m_AdjustMatrix[3] == 0);
+ ASSERT(charpos.m_OriginY == 0);
hal.canary 2016/07/29 15:26:21 why is this true?
Lei Zhang 2016/07/29 15:55:52 It's held up so far with my test cases. Do you hav
+
+ // Round the spacing to the nearest integer, but keep track of the rounding
+ // error for calculating the next spacing value.
+ FX_FLOAT fPixelSpacing = charpos.m_OriginX - fPreviousOriginX;
+ spacing[i] = FXSYS_round(fPixelSpacing);
Lei Zhang 2016/07/29 22:42:08 I printed a random page from Wikipedia and there a
+ fPreviousOriginX = charpos.m_OriginX - (fPixelSpacing - spacing[i]);
+
wsText += charpos.m_GlyphIndex;
}
// Draw
SetTextAlign(m_hDC, TA_LEFT | TA_BASELINE);
if (ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(), nChars,
- nullptr)) {
+ nChars > 1 ? &spacing[1] : nullptr)) {
return TRUE;
}
@@ -309,7 +317,7 @@ FX_BOOL CGdiPrinterDriver::DrawDeviceText(int nChars,
// Try to get the font and draw again.
g_pdfium_typeface_accessible_func(&lf, wsText.c_str(), nChars);
return ExtTextOutW(m_hDC, 0, 0, ETO_GLYPH_INDEX, nullptr, wsText.c_str(),
- nChars, nullptr);
+ nChars, nChars > 1 ? &spacing[1] : nullptr);
#else
return FALSE;
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698