diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc
index a5cc07f..760da7f 100644
--- a/src/HTMLRenderer/text.cc
+++ b/src/HTMLRenderer/text.cc
@@ -182,6 +182,11 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
cerr << "TODO: non-zero origins" << endl;
}
+ if (n == 1 && *p == ' ')
+ {
+ ++nSpaces;
+ }
+
if(uLen == 0)
{
// TODO
@@ -208,11 +213,6 @@ void HTMLRenderer::drawString(GfxState * state, GooString * s)
dx += dx1;
dy += dy1;
- if (n == 1 && *p == ' ')
- {
- ++nSpaces;
- }
-
++nChars;
p += n;
len -= n;