patch: spacing fix up for remapGlyph work


Subject: patch: spacing fix up for remapGlyph work
From: WJCarpenter (bill-abisource@carpenter.ORG)
Date: Mon Jul 10 2000 - 11:56:54 CDT


Oops. The attached patch (against 071000 nightly sources) fixes
something I missed through an oversight (one hesitates to say blunder)
in yesterday's patch for remapGlyph stuff. In a nutshell, the
remapping is always applied correctly when the rendering is done, but
it is sometimes missed when the character positions are calculated, so
you sometimes see the right things in the wrong places.

Although it doesn't look it, the patch is actually all XP. The change
is in the XP GR_Graphics::measureString(), but I also coded fixes to
some platform-specific measureString() functions. All such functions
have been surrounded by "#if 0" since I factored them out to XP some
time ago. Tested on Linux.

-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3

diff -ru abi-071000/src/af/gr/unix/gr_UnixGraphics.cpp abi-071000-NEW/src/af/gr/unix/gr_UnixGraphics.cpp --- abi-071000/src/af/gr/unix/gr_UnixGraphics.cpp Sun Jul 9 13:54:11 2000 +++ abi-071000-NEW/src/af/gr/unix/gr_UnixGraphics.cpp Sun Jul 9 22:30:24 2000 @@ -230,15 +230,8 @@ for (int i = 0; i < num; i++) { - cChar = s[i + iOffset]; - + cChar = remapGlyph(s[i + iOffset], UT_TRUE); width = gdk_char_width_wc (pFont, cChar); - if (width == 0) - { - cChar = remapGlyph(s[i + iOffset], UT_TRUE); - width = gdk_char_width_wc (pFont, cChar); - } - charWidth += width; if (pWidths) pWidths[i] = width; diff -ru abi-071000/src/af/gr/win/gr_Win32Graphics.cpp abi-071000-NEW/src/af/gr/win/gr_Win32Graphics.cpp --- abi-071000/src/af/gr/win/gr_Win32Graphics.cpp Sat Jul 8 22:23:56 2000 +++ abi-071000-NEW/src/af/gr/win/gr_Win32Graphics.cpp Sun Jul 9 22:31:48 2000 @@ -726,17 +726,12 @@ // if that fails, the char is probably not defined in // the font, so we substitute the default char width. UT_UCSChar currentChar; - currentChar = s[i + iOffset]; + currentChar = remapGlyph(s[i + iOffset]); iWidth = m_cw.getWidth(currentChar); if (!iWidth) { m_cw.setCharWidthsOfRange(m_oldHDC,currentChar,currentChar); iWidth = m_cw.getWidth(currentChar); - if (!iWidth) - { - currentChar = remapGlyph(currentChar, UT_TRUE); - iWidth = measureUnRemappedChar(currentChar); - } } iCharWidth += iWidth; diff -ru abi-071000/src/af/gr/xp/gr_Graphics.cpp abi-071000-NEW/src/af/gr/xp/gr_Graphics.cpp --- abi-071000/src/af/gr/xp/gr_Graphics.cpp Sun Jul 9 13:54:11 2000 +++ abi-071000-NEW/src/af/gr/xp/gr_Graphics.cpp Sun Jul 9 22:21:01 2000 @@ -93,26 +93,15 @@ // Platform versions can roll their own if it makes a performance difference. UT_ASSERT(s); - int charWidth = 0, width; - + int stringWidth = 0, charWidth; for (int i = 0; i < num; i++) { - UT_UCSChar currentChar = s[i + iOffset]; - - width = measureUnRemappedChar(currentChar); - if (width == 0) - { - xxx_UT_DEBUGMSG(("GR_Graphics::measureString remapping 0x%04X\n", currentChar)); - currentChar = remapGlyph(currentChar, UT_TRUE); - width = measureUnRemappedChar(currentChar); - } - - charWidth += width; - if (pWidths) - pWidths[i] = width; + UT_UCSChar currentChar = remapGlyph(s[i + iOffset], UT_FALSE); + charWidth = measureUnRemappedChar(currentChar); + stringWidth += charWidth; + if (pWidths) pWidths[i] = charWidth; } - - return charWidth; + return stringWidth; } UT_UCSChar GR_Graphics::remapGlyph(const UT_UCSChar actual, UT_Bool noMatterWhat) diff -ru abi-071000/src/af/xap/unix/xap_UnixPSGraphics.cpp abi-071000-NEW/src/af/xap/unix/xap_UnixPSGraphics.cpp --- abi-071000/src/af/xap/unix/xap_UnixPSGraphics.cpp Fri Jul 7 16:46:48 2000 +++ abi-071000-NEW/src/af/xap/unix/xap_UnixPSGraphics.cpp Sun Jul 9 22:34:49 2000 @@ -178,12 +178,8 @@ //UT_ASSERT(p[k] < 256); // TODO deal with Unicode register int x; UT_UCSChar currentChar; - currentChar = p[k]; - if (currentChar >= 256 || !(_scale(cwi[currentChar]))) - { - currentChar = remapGlyph(currentChar, UT_TRUE); - } - x = _scale(cwi[currentChar]); + currentChar = remapGlyph(p[k], UT_FALSE); + x = (currentChar < 256 ? _scale(cwi[currentChar]) : 0; iCharWidth += x; pWidths[k] = x;



This archive was generated by hypermail 2b25 : Mon Jul 10 2000 - 11:59:01 CDT