Re: patch: making win32 graphics work again

From: Dom Lachowicz (domlachowicz@yahoo.com)
Date: Mon Sep 15 2003 - 09:36:19 EDT

  • Next message: msevior@physics.unimelb.edu.au: "Re: patch: making win32 graphics work again"

    Jordi,

    Please commit this patch.

    Dom

    --- Jordi Mas <jmas@softcatala.org> wrote:
    > Hello there,
    >
    > This is a proposed patch to make the win32 usable
    > again. It fixes bug 5748. I
    > REVERTS some changes made my Martin.
    >
    > If nobody has a better solution, I think that we
    > should commit this patch and
    > Martin and me or a win32 developer should look very
    > close to what modification
    > need to be done to the win32 graphics class in the
    > future.
    >
    > Thanks,
    >
    > --
    >
    > Jordi Mas i Hernāndez (homepage
    > http://www.softcatala.org/~jmas)
    > http://www.softcatala.org
    >
    >
    > > Index: src/af/gr/win/gr_Win32CharWidths.cpp
    >
    ===================================================================
    > RCS file:
    > /cvsroot/abi/src/af/gr/win/gr_Win32CharWidths.cpp,v
    > retrieving revision 1.23
    > diff -u -r1.23 gr_Win32CharWidths.cpp
    > --- src/af/gr/win/gr_Win32CharWidths.cpp 11 Sep 2003
    > 03:03:31 -0000 1.23
    > +++ src/af/gr/win/gr_Win32CharWidths.cpp 15 Sep 2003
    > 13:24:35 -0000
    > @@ -27,17 +27,10 @@
    > #include "ut_endian.h"
    >
    >
    >
    //////////////////////////////////////////////////////////////////
    > -#if 1
    > -
    > -#define _UL(x) (x)
    > -#define _UUL(x)(x) = (x)
    > -
    > -#else
    >
    > #define _UL(x) pGr->tlu((x))
    > #define _UUL(x) (x) = pGr->tlu((x))
    >
    > -#endif
    > void GR_Win32CharWidths::setCharWidthsOfRange(HDC
    > hdc, UT_UCSChar c0, UT_UCSChar c1, GR_Graphics *
    > pGr)
    > {
    > if(m_vRanges.getItemCount() == 0)
    > Index: src/af/gr/win/gr_Win32CharWidths.h
    >
    ===================================================================
    > RCS file:
    > /cvsroot/abi/src/af/gr/win/gr_Win32CharWidths.h,v
    > retrieving revision 1.3
    > diff -u -r1.3 gr_Win32CharWidths.h
    > --- src/af/gr/win/gr_Win32CharWidths.h 21 Jun 2003
    > 23:26:53 -0000 1.3
    > +++ src/af/gr/win/gr_Win32CharWidths.h 15 Sep 2003
    > 13:24:35 -0000
    > @@ -25,6 +25,11 @@
    > class UT_NumberVector;
    > class GR_Graphics;
    >
    > +#define _UL(x) (x)
    >
    > +#define _UUL(x)(x) = (x)
    >
    > +
    > +
    > +
    >
    >
    //////////////////////////////////////////////////////////////////
    > // the only reason that we subclass is because
    > Win32 provides a
    > // routine to fetch the widths of a whole font in
    > one call.
    > Index: src/af/gr/win/gr_Win32Graphics.cpp
    >
    ===================================================================
    > RCS file:
    > /cvsroot/abi/src/af/gr/win/gr_Win32Graphics.cpp,v
    > retrieving revision 1.152
    > diff -u -r1.152 gr_Win32Graphics.cpp
    > --- src/af/gr/win/gr_Win32Graphics.cpp 11 Sep 2003
    > 03:03:32 -0000 1.152
    > +++ src/af/gr/win/gr_Win32Graphics.cpp 15 Sep 2003
    > 13:24:35 -0000
    > @@ -36,8 +36,12 @@
    > #include "ut_string.h"
    > #include "ut_Win32OS.h"
    >
    > -#define WIN_SCALE_RATIO 1440.0/72.
    > -#define NEW_SCALE 1
    > +
    >
    > +
    > +
    > +
    > +#define WIN_SCALE_RATIO 1440.0/72.
    >
    > +#define NEW_SCALE 0
    >
    >
    > //#define GR_GRAPHICS_DEBUG 1
    >
    > @@ -197,10 +201,10 @@
    > {
    > // lazily grab this (once)
    > HFONT f = (HFONT)
    > GetStockObject(DEFAULT_GUI_FONT);
    > - LOGFONT lf;
    > - int iRes = GetObject(f, sizeof(LOGFONT), &lf);
    > - UT_sint32 iHeight =
    > static_cast<UT_sint32>(lf.lfHeight);
    > - m_pFontGUI = new GR_Win32Font(f, this,iHeight);
    > + LOGFONT lf;
    >
    > + int iRes = GetObject(f, sizeof(LOGFONT), &lf);
    >
    > + UT_sint32 iHeight =
    > static_cast<UT_sint32>(lf.lfHeight);
    >
    >
    > + m_pFontGUI = new GR_Win32Font(f, this,iHeight);
    >
    > UT_ASSERT(m_pFontGUI);
    > }
    >
    > @@ -285,7 +289,7 @@
    > if (!hFont)
    > return 0;
    >
    > - return new GR_Win32Font(hFont, this,iHeight);
    > + return new GR_Win32Font(hFont, this, iHeight);
    > }
    >
    > void GR_Win32Graphics::drawGlyph(UT_uint32 Char,
    > UT_sint32 xoff, UT_sint32 yoff)
    > @@ -342,41 +346,6 @@
    > }
    > }
    >
    > -
    > -UT_uint16* GR_Win32Graphics::_remapGlyphs(const
    > UT_UCSChar* pChars, int iCharOffset, int &iLength)
    > -{
    > - // TODO -- make this handle 32-bit chars properly
    > - if (iLength > (int)m_remapBufferSize)
    > - {
    > - delete [] m_remapBuffer;
    > -
    > - if(XAP_App::getApp()->theOSHasBidiSupport() !=
    > XAP_App::BIDI_SUPPORT_NONE)
    > - {
    > - delete [] m_remapIndices;
    > - m_remapIndices = new UT_UCS2Char[iLength];
    > - }
    > -
    > - m_remapBuffer = new UT_UCS2Char[iLength];
    > - m_remapBufferSize = iLength;
    > - }
    > -
    > - // Need to handle zero-width spaces correctly
    > - int i, j;
    > - for (i = 0, j = 0; i < iLength; ++i, ++j)
    > - {
    > - m_remapBuffer[j] =
    > (UT_UCS2Char)pChars[iCharOffset + i];
    > -
    > - if(m_remapBuffer[j] == 0x200B || m_remapBuffer[j]
    > == 0xFEFF
    > - /*|| m_remapBuffer[j] ==
    > UCS_LIGATURE_PLACEHOLDER*/)
    > - j--;
    > - }
    > -
    > - iLength -= (i - j);
    > -
    > - return m_remapBuffer;
    > -}
    > -
    > -
    > void GR_Win32Graphics::drawChars(const UT_UCSChar*
    > pChars,
    > int iCharOffset, int iLengthOrig,
    > UT_sint32 xoff, UT_sint32 yoff,
    > @@ -390,7 +359,6 @@
    >
    > xoff = tdu(xoff);
    > yoff = tdu(yoff);
    > - int *pCharAdvances = NULL;
    >
    >
    > // iLength can be modified by _remapGlyphs
    > @@ -420,13 +388,13 @@
    > int iConverted = WideCharToMultiByte(CP_ACP,
    > NULL,
    > (LPCWSTR) currentChars, iLength,
    > str, iLength * sizeof(UT_UCSChar), NULL, NULL);
    > -
    > ExtTextOutA(m_hdc, xoff, yoff, 0, NULL, str,
    > iConverted, NULL);
    > delete [] str;
    > }
    > else
    > {
    > int duCharWidths [256];
    > + int *pCharAdvances;
    >
    > if (pCharWidths)
    > {
    > @@ -440,26 +408,19 @@
    > // all 0x200B and 0xFEFF characters, we also
    > have to
    > // remove their entires from the advances
    > UT_sint32 i,j;
    > - UT_sint32 iwidth = 0;
    > - UT_sint32 iadvance = 0;
    > - UT_sint32 inextAdvance = 0;
    > +
    >
    === message truncated ===

    __________________________________
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    http://sitebuilder.yahoo.com



    This archive was generated by hypermail 2.1.4 : Mon Sep 15 2003 - 09:50:07 EDT