diff options
Diffstat (limited to 'Build/source')
35 files changed, 5288 insertions, 5089 deletions
diff --git a/Build/source/libs/graphite-engine/Makefile.am b/Build/source/libs/graphite-engine/Makefile.am index de0430e084e..c819a9a33be 100644 --- a/Build/source/libs/graphite-engine/Makefile.am +++ b/Build/source/libs/graphite-engine/Makefile.am @@ -15,7 +15,7 @@ dist-hook: find $(distdir) -name .svn | xargs rm -rf # VC_VERSION is the last released version of the software -VC_VERSION = 2.2.1 +VC_VERSION = 2.3 # D_VERSION gets the number of the current svn revision D_VERSION = `svnversion ${top_srcdir}|sed -e "s/[0-9]*\://g"` SVNDEB_VERSION = $(VC_VERSION)+0$(D_VERSION)svn diff --git a/Build/source/libs/graphite-engine/configure.ac b/Build/source/libs/graphite-engine/configure.ac index bf9ae416f14..7fb2d14a991 100644 --- a/Build/source/libs/graphite-engine/configure.ac +++ b/Build/source/libs/graphite-engine/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ(2.54) -AC_INIT(silgraphite, 2.2.1, silgraphite-devel@lists.sourceforge.net) +AC_INIT(silgraphite, 2.3, silgraphite-devel@lists.sourceforge.net) AC_CONFIG_SRCDIR(src/segment/GrEngine.cpp) AC_CONFIG_AUX_DIR(config) @@ -14,14 +14,18 @@ AC_C_BIGENDIAN # Optional features AC_ARG_ENABLE(tracing, - AC_HELP_STRING([--enable-tracing], - [build with support for trace Graphite logs (default=no)])) + AC_HELP_STRING([--disable-tracing], + [build without support for trace Graphite logs])) + test "x$enable_tracing" != xno && enable_tracing=yes + AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [build with debugging. (default=no)])) AC_ARG_ENABLE(final, - AC_HELP_STRING([--enable-final], - [build with optimizations and no debugging. (default=no)])) + AC_HELP_STRING([--disable-final], + [build without optimizations and no debugging.])) + test "x$enable_final" != xno && enable_final=yes + AC_ARG_ENABLE(profile, AC_HELP_STRING([--enable-profile], [allow profiling (default=no)])) diff --git a/Build/source/libs/graphite-engine/debian/changelog b/Build/source/libs/graphite-engine/debian/changelog index 88b5fd7d7f6..e77c628ef90 100644 --- a/Build/source/libs/graphite-engine/debian/changelog +++ b/Build/source/libs/graphite-engine/debian/changelog @@ -1,3 +1,10 @@ +silgraphite2.0 (1:2.3-1) gutsy; urgency=low + + * Smaller segment and glyphinfo foot prints + * bug fixes + + -- Martin Hosken <martin_hosken@sil.org> Wed, 16 Jan 2008 16:54:26 +0700 + silgraphite2.0 (1:2.2.1-1) feisty; urgency=low * 30% speedup diff --git a/Build/source/libs/graphite-engine/debian/rules b/Build/source/libs/graphite-engine/debian/rules index cc3842b871e..7e5c672aad5 100755 --- a/Build/source/libs/graphite-engine/debian/rules +++ b/Build/source/libs/graphite-engine/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f #DEB_AUTO_UPDATE_DEBIAN_CONTROL:=yes -DEB_TAR_SRCDIR := silgraphite-2.2.1 +DEB_TAR_SRCDIR := silgraphite-2.3 include /usr/share/cdbs/1/rules/tarball.mk include /usr/share/cdbs/1/rules/debhelper.mk diff --git a/Build/source/libs/graphite-engine/doc/V2_TextSource_Interface.odt b/Build/source/libs/graphite-engine/doc/V2_TextSource_Interface.odt Binary files differindex 1cca1508d61..c2f183a1629 100644 --- a/Build/source/libs/graphite-engine/doc/V2_TextSource_Interface.odt +++ b/Build/source/libs/graphite-engine/doc/V2_TextSource_Interface.odt diff --git a/Build/source/libs/graphite-engine/makefile.vc b/Build/source/libs/graphite-engine/makefile.vc index 9cc824becc2..2c5c5a935ef 100644 --- a/Build/source/libs/graphite-engine/makefile.vc +++ b/Build/source/libs/graphite-engine/makefile.vc @@ -3,6 +3,7 @@ TARGET=graphite CPP=cl.exe CPPFLAGS=/nologo /W4 /GR /GX /I "./src/font" /I "./src/painter" /I "./src/segment" /I "./src/textsource" /I "./src/generic" /I "./include/graphite" /I "../wrappers/win32" /D "GR_NAMESPACE" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "TRACING" /Fp"$(INTDIR)\graphite.pch" /YX /Fd"$(INTDIR)\\" /FD /c +# /Wp62 LINK=link.exe LINK_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /pdb:"$(OUTDIR)\\graphite.pdb" /machine:I386 /out:"$(OUTDIR)\\$(TARGET).dll" /implib:"$(OUTDIR)\\$(TARGET).lib" @@ -89,6 +90,7 @@ LINK_OBJS=\ # "$(INTDIR)\TestFSM$(OBJEXT)"\ # "$(INTDIR)\TestPasses$(OBJEXT)"\ "$(INTDIR)\TransductionLog$(OBJEXT)"\ + "$(INTDIR)\XmlTransductionLog$(OBJEXT)"\ "$(INTDIR)\Platform$(OBJEXT)"\ "$(INTDIR)\TtfUtil$(OBJEXT)"\ "$(INTDIR)\WinFont$(OBJEXT)"\ @@ -123,6 +125,7 @@ LINK_DLL_OBJS=\ # "$(INTDIR)\TestFSM_dll$(OBJEXT)"\ # "$(INTDIR)\TestPasses_dll$(OBJEXT)"\ "$(INTDIR)\TransductionLog_dll$(OBJEXT)"\ + "$(INTDIR)\XmlTransductionLog_dll$(OBJEXT)"\ "$(INTDIR)\WinSegmentPainter_dll$(OBJEXT)"\ "$(INTDIR)\Platform_dll$(OBJEXT)"\ "$(INTDIR)\TtfUtil_dll$(OBJEXT)" @@ -159,6 +162,7 @@ BSC32_SBRS=\ # "$(INTDIR)\TestFSM$(SBREXT)"\ # "$(INTDIR)\TestPasses$(SBREXT)"\ "$(INTDIR)\TransductionLog$(SBREXT)"\ + "$(INTDIR)\XmlTransductionLog$(SBREXT)"\ "$(INTDIR)\WinSegmentPainter$(SBREXT)"\ "$(INTDIR)\Platform$(SBREXT)"\ "$(INTDIR)\TtfUtil$(SBREXT)"\ @@ -682,6 +686,22 @@ lib_dll : "$(OUTDIR)/$(TARGET)_dll.lib" !ENDIF !IF "$(CFG)" == "DEBUG" +"$(INTDIR)\XmlTransductionLog$(OBJEXT)" "$(INTDIR)\XmlTransductionLog$(SBREXT)" : "src/segment/XmlTransductionLog.cpp" + @- $(CPP) $(CPPFLAGS) $(CPP_DEBUG) /Fo"$(INTDIR)\XmlTransductionLog$(OBJEXT)" $? + +"$(INTDIR)\XmlTransductionLog_dll$(OBJEXT)" "$(INTDIR)\XmlTransductionLog_dll$(SBREXT)" : "src/segment/XmlTransductionLog.cpp" + @- $(CPP) $(CPPFLAGS) /D "_DLL" $(CPP_DEBUG) /Fo"$(INTDIR)\XmlTransductionLog_dll$(OBJEXT)" $? + +!ELSE +"$(INTDIR)\XmlTransductionLog$(OBJEXT)" : "src/segment/XmlTransductionLog.cpp" + @- $(CPP) $(CPPFLAGS) $(CPP_DEBUG) /Fo"$(INTDIR)\XmlTransductionLog$(OBJEXT)" $? + +"$(INTDIR)\XmlTransductionLog_dll$(OBJEXT)" : "src/segment/XmlTransductionLog.cpp" + @- $(CPP) $(CPPFLAGS) /D "_DLL" /Fo"$(INTDIR)\XmlTransductionLog_dll$(OBJEXT)" $? + +!ENDIF + +!IF "$(CFG)" == "DEBUG" "$(INTDIR)\Platform$(OBJEXT)" "$(INTDIR)\Platform$(SBREXT)" : "src/segment/Platform.cpp" @- $(CPP) $(CPPFLAGS) $(CPP_DEBUG) /Fo"$(INTDIR)\Platform$(OBJEXT)" $? diff --git a/Build/source/libs/graphite-engine/src/font/FileFont.cpp b/Build/source/libs/graphite-engine/src/font/FileFont.cpp index 122a904063f..4600b788ed2 100755 --- a/Build/source/libs/graphite-engine/src/font/FileFont.cpp +++ b/Build/source/libs/graphite-engine/src/font/FileFont.cpp @@ -1,5 +1,5 @@ /*--------------------------------------------------------------------*//*:Ignore this sentence. -Copyright (C) 1999, 2001, 2005 SIL International. All rights reserved. +Copyright (C) 1999 - 2008 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. @@ -198,17 +198,20 @@ FileFont::initializeFromFace() // We could use something like "if (sizeof(std::wstring::value_type) == 4)" here, // but a compile-time switch is preferable. #if SIZEOF_WCHAR_T == 4 - for (int c16 = 0; c16 < cchw; ) + for (int cch16 = 0; cch16 < cchw; ) { - int charUsed = 0; - utf32 cch32 = GrCharStream::Utf16ToUtf32(&(rgchwFace[c16]), - cchw - c16, &charUsed); - m_stuFaceName.push_back(cch32); - c16 += charUsed; + int cch16Used = 0; + utf32 ch32 = GrCharStream::Utf16ToUtf32(&(rgchwFace[cch16]), + cchw - cch16, &cch16Used); + m_stuFaceName.push_back(ch32); + cch16 += cch16Used; } // } #else - m_stuFaceName.assign(rgchwFace); + m_stuFaceName.assign(rgchwFace); + // VS 2005 needs this: + //for (int cch16 = 0; cch16 < cchw; cch16++) + // m_stuFaceName.push_back(rgchwFace[cch16]); #endif pTable = readTable(ktiHead, lSize); if (!m_fIsValid || !pTable) diff --git a/Build/source/libs/graphite-engine/src/font/Font.cpp b/Build/source/libs/graphite-engine/src/font/Font.cpp index 7a7d071763e..666be63ed6f 100644 --- a/Build/source/libs/graphite-engine/src/font/Font.cpp +++ b/Build/source/libs/graphite-engine/src/font/Font.cpp @@ -1,5 +1,5 @@ /*--------------------------------------------------------------------*//*:Ignore this sentence. -Copyright (C) 1999, 2001, 2005 SIL International. All rights reserved. +Copyright (C) 1999 - 2008 SIL International. All rights reserved. Distributable under the terms of either the Common Public License or the GNU Lesser General Public License, as specified in the LICENSING.txt file. @@ -133,7 +133,7 @@ void Font::initialiseFontFace(bool fDumbFallback) } /*---------------------------------------------------------------------------------------------- - Return uniquely identifying information that will be used a the key for this font + Return uniquely identifying information that will be used as the key for this font in the font cache. This includes the font face name and the bold and italic flags. ----------------------------------------------------------------------------------------------*/ void Font::UniqueCacheInfo(std::wstring & stuFace, bool & fBold, bool & fItalic) @@ -154,7 +154,9 @@ void Font::UniqueCacheInfo(std::wstring & stuFace, bool & fBold, bool & fItalic) std::copy(src_start, src_start + cchw, rgchwFace); rgchwFace[cchw] = 0; // zero terminate TtfUtil::SwapWString(rgchwFace, cchw); - stuFace.assign(rgchwFace, rgchwFace + cchw); + for (size_t ich16 = 0; ich16 < cchw; ich16++) // to handle situation where wchar_t is 4 bytes + stuFace.push_back(wchar_t(rgchwFace[ich16])); + ///stuFace.assign(rgchwFace, rgchwFace + cchw); const void * pOs2Tbl = getTable(TtfUtil::TableIdTag(ktiOs2), &cbSize); TtfUtil::FontOs2Style(pOs2Tbl, fBold, fItalic); diff --git a/Build/source/libs/graphite-engine/src/segment/GrEngine.cpp b/Build/source/libs/graphite-engine/src/segment/GrEngine.cpp index 62a33b6a4ed..57d2a2ba16e 100644 --- a/Build/source/libs/graphite-engine/src/segment/GrEngine.cpp +++ b/Build/source/libs/graphite-engine/src/segment/GrEngine.cpp @@ -604,7 +604,7 @@ void GrEngine::MakeSegment( GetWritingSystemDirection(pgts, ichMin); // Find the end of the range to render with the current font. - int nDirDepth; + int nDirDepth = 0; int ichFontLim; int ichStrmLim = 0; int ichSegLim = 0; diff --git a/Build/source/libs/graphite-engine/src/segment/GrPass.cpp b/Build/source/libs/graphite-engine/src/segment/GrPass.cpp index 8e2048f0f6f..26eb3a3deb6 100644 --- a/Build/source/libs/graphite-engine/src/segment/GrPass.cpp +++ b/Build/source/libs/graphite-engine/src/segment/GrPass.cpp @@ -1804,6 +1804,12 @@ int GrBidiPass::Unwind(GrTableManager * ptman, else { islotIn = min(islotChanged, psstrmIn->ReadPos()); islotIn = max(islotIn - 1, 0); + while (islotIn > 0 && !StrongDir(psstrmIn->SlotAt(islotIn)->Directionality())) + { + psstrmIn->SlotAt(islotIn)->ZapDirLevel(); + islotIn--; + } + Assert(islotIn == 0 || psstrmIn->SlotAt(islotIn)->DirHasBeenProcessed()); islotOut = 0; while (islotIn > 0 && (islotOut = psstrmIn->ChunkInNext(islotIn)) == -1) --islotIn; diff --git a/Build/source/libs/graphite-engine/src/segment/GrSlotState.cpp b/Build/source/libs/graphite-engine/src/segment/GrSlotState.cpp index b18ae95a63f..f2d61e45eed 100644 --- a/Build/source/libs/graphite-engine/src/segment/GrSlotState.cpp +++ b/Build/source/libs/graphite-engine/src/segment/GrSlotState.cpp @@ -143,6 +143,9 @@ void GrSlotState::InitializeFrom(GrSlotState * pslotOld, int ipass) m_vpslotAssoc.clear(); m_vpslotAssoc.push_back(pslotOld); + m_dircProc = pslotOld->m_dircProc; + m_fDirProcessed = pslotOld->m_fDirProcessed; + // Since we're going on to a new pass, no point in copying these: m_ipassFsmCol = -1; m_colFsm = -1; diff --git a/Build/source/libs/graphite-engine/src/segment/GrSlotStream.cpp b/Build/source/libs/graphite-engine/src/segment/GrSlotStream.cpp index f71aefdee3a..db6a5c8af7e 100644 --- a/Build/source/libs/graphite-engine/src/segment/GrSlotStream.cpp +++ b/Build/source/libs/graphite-engine/src/segment/GrSlotStream.cpp @@ -832,8 +832,8 @@ int GrSlotStream::GetSlotDirLevel(EngineState * pengst, int islot, dircLB = (dircLB == kdircLlb) ? kdircL : kdircR; for (int iislot = 0; iislot < signed(vislotTrailingWS.size()); iislot++) { - islot = vislotTrailingWS[iislot]; - m_vpslot[islot]->SetDirProcessed(dircLB); + int islotTmp = vislotTrailingWS[iislot]; + m_vpslot[islotTmp]->SetDirProcessed(dircLB); } } diff --git a/Build/source/libs/graphite-engine/src/segment/GrTableManager.cpp b/Build/source/libs/graphite-engine/src/segment/GrTableManager.cpp index dfb49717946..cc125a3d9b3 100644 --- a/Build/source/libs/graphite-engine/src/segment/GrTableManager.cpp +++ b/Build/source/libs/graphite-engine/src/segment/GrTableManager.cpp @@ -1122,7 +1122,6 @@ void GrTableManager::InitializeForNextSeg(Segment * pseg, bool fNextSegNeedsContext, GrCharStream * pchstrm) { byte pbNextSegDat[256]; - int cbNextMax = 256; int cbNextSegDat; int * pcbNextSegDat = &cbNextSegDat; @@ -1964,7 +1963,7 @@ GrResult EngineState::GetGlyphAttrForJustification(int iGlyph, int jgat, int nLe float * pValueRet) { GrResult res; - int valueRetInt; + int valueRetInt = 0; switch(jgat) { case kjgatWeight: diff --git a/Build/source/libs/graphite-engine/src/segment/Segment.cpp b/Build/source/libs/graphite-engine/src/segment/Segment.cpp index 69e5349bca3..db8f2bc8849 100644 --- a/Build/source/libs/graphite-engine/src/segment/Segment.cpp +++ b/Build/source/libs/graphite-engine/src/segment/Segment.cpp @@ -3391,7 +3391,7 @@ int Segment::SelectBb(std::vector<int> & viginf, bool fRTL) // The idea is that it is going to be harder to hit than the bigger glyph. float smallestArea = float(1000000000.0); float largestArea = 0.0; - size_t iiginfSmallest; + size_t iiginfSmallest = 0; size_t iiginf; for (iiginf = 0; iiginf < viginf.size(); iiginf++) { diff --git a/Build/source/libs/graphite-engine/src/segment/TransductionLog.cpp b/Build/source/libs/graphite-engine/src/segment/TransductionLog.cpp index 29a1be2af12..ee528110103 100644 --- a/Build/source/libs/graphite-engine/src/segment/TransductionLog.cpp +++ b/Build/source/libs/graphite-engine/src/segment/TransductionLog.cpp @@ -1620,8 +1620,8 @@ void GrSlotState::LogSlotAttribute(GrTableManager * ptman, pslotPrev = pslotPrev->m_pslotPrevState; // General-purpose variables for em-unit attributes: - int mThis; - int mPrev; + int mThis = 0; + int mPrev = 0; switch (slat) { case kslatShiftX: diff --git a/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.cpp b/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.cpp index 7904b1c6653..30bfac34a9f 100644 --- a/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.cpp +++ b/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.cpp @@ -1,310 +1,310 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: NPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is sila.mozdev.org code.
- *
- * The Initial Developer of the Original Code is
- * Keith Stribley.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the NPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the NPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include <graphite/GrClient.h>
-#include <graphite/ITextSource.h>
-#include <graphite/IGrJustifier.h>
-#include <graphite/IGrEngine.h>
-#include <graphite/SegmentAux.h>
-#include <graphite/Font.h>
-#include <graphite/Segment.h>
-#include <graphite/GraphiteProcess.h>
-#include <graphite/FileFont.h>
-
-#include "GrUtfTextSrc.h"
-
-
-
-GrUtfTextSrc::GrUtfTextSrc()
-: mLength(0),
- mBufferLength8(64), mBufferLength16(64), mBufferLength32(64),
- mData8(NULL), mData16(NULL), mData32(NULL),
- mType(gr::kutf16),
- mForeground(gr::kclrBlack), mBackground(gr::kclrTransparent),
- mSelectForeground(0), mSelectBackground(0),
- mIsSelected(false),
- mFont(NULL),
- mRtl(false)
-{
-
-}
-
-GrUtfTextSrc::~GrUtfTextSrc()
-{
- if (mData8) delete [] mData8;
- if (mData16) delete [] mData16;
- if (mData32) delete [] mData32;
- mSelectionVector.clear();
-}
-
-bool GrUtfTextSrc::setText(const char * pszText, int len)
-{
- return setText((gr::utf8*)pszText, len);
-}
-
-bool GrUtfTextSrc::setText(const gr::utf8 * pszText, int len)
-{
- mType = gr::kutf8;
- mLength = len;
- if (!checkBuffer8()) return false;
-
- for(size_t i = 0; i < mLength; i++)
- {
- mData8[i] = pszText[i];
- // stray line feeds and other control characters from the html file
- // cause artificial truncation of segments
- if (mData8[i] < 0x0020)//(pszText[i] == '\n' || pszText[i] == '\r')
- mData8[i] = 0x20; // ZWSP
- }
- mData8[mLength] = '\0'; // zero-terminate
- mSelectionVector.clear();
- mIsSelected = false;
- return true;
-}
-
-
-bool GrUtfTextSrc::setText(const gr::utf16 * pszText, int len)
-{
- mType = gr::kutf16;
- mLength = len;
- if (!checkBuffer16()) return false;
-
- for(size_t i = 0; i < mLength; i++)
- {
- mData16[i] = pszText[i];
- // stray line feeds and other control characters from the html file
- // cause artificial truncation of segments
- if (mData16[i] < 0x0020)//(pszText[i] == '\n' || pszText[i] == '\r')
- mData16[i] = 0x200B; // ZWSP
- }
- mData16[mLength] = '\0'; // zero-terminate
- mSelectionVector.clear();
- mIsSelected = false;
- return true;
-}
-
-bool GrUtfTextSrc::setText(const gr::utf32 * pszText, int len)
-{
- mType = gr::kutf32;
- mLength = len;
- if (!checkBuffer32()) return false;
-
- for(size_t i = 0; i < mLength; i++)
- {
- mData32[i] = pszText[i];
- }
- mData32[mLength] = '\0'; // zero-terminate
- mSelectionVector.clear();
- mIsSelected = false;
- return true;
-}
-
-bool GrUtfTextSrc::checkBuffer8(void)
-{
- if (!mData8 || mBufferLength8 < mLength + 1)
- {
- do
- {
- mBufferLength8 *= 2;
- } while (mBufferLength8 < mLength + 1);
- if (mData8) delete [] mData8;
- mData8 = new gr::utf8[mBufferLength8];
- }
- return (mData8) ? true : false;
-}
-
-bool GrUtfTextSrc::checkBuffer16(void)
-{
- if (!mData16 || mBufferLength16 < mLength + 1)
- {
- do
- {
- mBufferLength16 *= 2;
- } while (mBufferLength16 < mLength + 1);
- if (mData16) delete [] mData16;
- mData16 = new gr::utf16[mBufferLength16];
- }
- return (mData16) ? true : false;
-}
-
-bool GrUtfTextSrc::checkBuffer32(void)
-{
- if (!mData32 || mBufferLength32 < mLength + 1)
- {
- do
- {
- mBufferLength32 *= 2;
- } while (mBufferLength32 < mLength + 1);
- if (mData32) delete [] mData32;
- mData32 = new gr::utf32[mBufferLength32];
- }
- return (mData32) ? true : false;
-}
-
-size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchwBuffer)
-{
- assert(cch <= mLength);
- if (cch > mLength)
- {
- return 0;
- }
- std::copy(mData8 + ichMin, mData8 + ichMin + cch, prgchwBuffer);
- return (cch - ichMin);
-}
-
-size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer)
-{
- assert(cch <= mLength);
- if (cch > mLength)
- {
- return 0;
- }
- std::copy(mData16 + ichMin, mData16 + ichMin + cch, prgchwBuffer);
- return (cch - ichMin);
-}
-
-size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchwBuffer)
-{
- assert(cch <= mLength);
- if (cch > mLength)
- {
- return 0;
- }
- std::copy(mData32 + ichMin, mData32 + ichMin + cch, prgchwBuffer);
- return (cch - ichMin);
-}
-
-
-bool GrUtfTextSrc::getRightToLeft(gr::toffset ich)
-{
- return mRtl; // assumes src only contains one direction
-}
-
-unsigned int GrUtfTextSrc::getDirectionDepth(gr::toffset ich)
-{
- return (mRtl) ? 1 : 0; // TBD
-}
-
-std::pair<gr::toffset, gr::toffset> GrUtfTextSrc::propertyRange(gr::toffset ich)
-{
- std::pair<gr::toffset, gr::toffset> range(0, mLength);
- if (mIsSelected)
- {
- bool selectState = mSelectionVector[ich];
- // find start
- int s = ich - 1;
- int e = ich + 1;
- if (s > -1)
- for ( ; s >= 0; s--)
- {
- if (mSelectionVector[s] != selectState)
- {
- s++; // backup
- break;
- }
- }
- if (s < 0) s = 0;
- // find end
- for ( ; e < static_cast<int>(mLength); e++)
- {
- if (mSelectionVector[e] != selectState)
- {
- // don't need to backup for end
- break;
- }
- }
- range.first = s;
- range.second = e;
- }
- return range;
-}
-
-size_t GrUtfTextSrc::getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset)
-{
- return 0;
-}
-
-void GrUtfTextSrc::getColors(gr::toffset ich, int * pclrFore, int * pclrBack)
-{
- // selections are handled here
- if (mIsSelected && mSelectionVector[ich])
- {
- *pclrFore = mSelectForeground;
- *pclrBack = mSelectBackground;
- }
- else
- {
- *pclrFore = mForeground;
- *pclrBack = mBackground;
- }
-}
-
-
-// these should be called I hope
-float
-GrUtfTextSrc::getFontSize(gr::toffset ich)
-{
- assert(mFont);
- return mPointSize;
-}
-
-bool
-GrUtfTextSrc::getBold(gr::toffset ich)
-{
- assert(mFont);
-// NS_ASSERTION(false, "unexpected call to getBold");
-// return false;
- return mFont->bold();
-}
-
-bool
-GrUtfTextSrc::getItalic(gr::toffset ich)
-{
- assert(mFont);
- //NS_ASSERTION(false, "unexpected call to getItalic");
- //return false;
- return mFont->italic();
-}
-
-gr::isocode GrUtfTextSrc::getLanguage(gr::toffset ich)
-{
- gr::isocode unknown;
- std::fill_n(unknown.rgch, 4, '\0');
- return unknown;
-}
-
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sila.mozdev.org code. + * + * The Initial Developer of the Original Code is + * Keith Stribley. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include <graphite/GrClient.h> +#include <graphite/ITextSource.h> +#include <graphite/IGrJustifier.h> +#include <graphite/IGrEngine.h> +#include <graphite/SegmentAux.h> +#include <graphite/Font.h> +#include <graphite/Segment.h> +#include <graphite/GraphiteProcess.h> +#include <graphite/FileFont.h> + +#include "GrUtfTextSrc.h" + + + +GrUtfTextSrc::GrUtfTextSrc() +: mLength(0), + mBufferLength8(64), mBufferLength16(64), mBufferLength32(64), + mData8(NULL), mData16(NULL), mData32(NULL), + mType(gr::kutf16), + mForeground(gr::kclrBlack), mBackground(gr::kclrTransparent), + mSelectForeground(0), mSelectBackground(0), + mIsSelected(false), + mFont(NULL), + mRtl(false) +{ + +} + +GrUtfTextSrc::~GrUtfTextSrc() +{ + if (mData8) delete [] mData8; + if (mData16) delete [] mData16; + if (mData32) delete [] mData32; + mSelectionVector.clear(); +} + +bool GrUtfTextSrc::setText(const char * pszText, int len) +{ + return setText((gr::utf8*)pszText, len); +} + +bool GrUtfTextSrc::setText(const gr::utf8 * pszText, int len) +{ + mType = gr::kutf8; + mLength = len; + if (!checkBuffer8()) return false; + + for(size_t i = 0; i < mLength; i++) + { + mData8[i] = pszText[i]; + // stray line feeds and other control characters from the html file + // cause artificial truncation of segments + if (mData8[i] < 0x0020)//(pszText[i] == '\n' || pszText[i] == '\r') + mData8[i] = 0x20; // ZWSP + } + mData8[mLength] = '\0'; // zero-terminate + mSelectionVector.clear(); + mIsSelected = false; + return true; +} + + +bool GrUtfTextSrc::setText(const gr::utf16 * pszText, int len) +{ + mType = gr::kutf16; + mLength = len; + if (!checkBuffer16()) return false; + + for(size_t i = 0; i < mLength; i++) + { + mData16[i] = pszText[i]; + // stray line feeds and other control characters from the html file + // cause artificial truncation of segments + if (mData16[i] < 0x0020)//(pszText[i] == '\n' || pszText[i] == '\r') + mData16[i] = 0x200B; // ZWSP + } + mData16[mLength] = '\0'; // zero-terminate + mSelectionVector.clear(); + mIsSelected = false; + return true; +} + +bool GrUtfTextSrc::setText(const gr::utf32 * pszText, int len) +{ + mType = gr::kutf32; + mLength = len; + if (!checkBuffer32()) return false; + + for(size_t i = 0; i < mLength; i++) + { + mData32[i] = pszText[i]; + } + mData32[mLength] = '\0'; // zero-terminate + mSelectionVector.clear(); + mIsSelected = false; + return true; +} + +bool GrUtfTextSrc::checkBuffer8(void) +{ + if (!mData8 || mBufferLength8 < mLength + 1) + { + do + { + mBufferLength8 *= 2; + } while (mBufferLength8 < mLength + 1); + if (mData8) delete [] mData8; + mData8 = new gr::utf8[mBufferLength8]; + } + return (mData8) ? true : false; +} + +bool GrUtfTextSrc::checkBuffer16(void) +{ + if (!mData16 || mBufferLength16 < mLength + 1) + { + do + { + mBufferLength16 *= 2; + } while (mBufferLength16 < mLength + 1); + if (mData16) delete [] mData16; + mData16 = new gr::utf16[mBufferLength16]; + } + return (mData16) ? true : false; +} + +bool GrUtfTextSrc::checkBuffer32(void) +{ + if (!mData32 || mBufferLength32 < mLength + 1) + { + do + { + mBufferLength32 *= 2; + } while (mBufferLength32 < mLength + 1); + if (mData32) delete [] mData32; + mData32 = new gr::utf32[mBufferLength32]; + } + return (mData32) ? true : false; +} + +size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchwBuffer) +{ + assert(cch <= mLength); + if (cch > mLength) + { + return 0; + } + std::copy(mData8 + ichMin, mData8 + ichMin + cch, prgchwBuffer); + return (cch - ichMin); +} + +size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer) +{ + assert(cch <= mLength); + if (cch > mLength) + { + return 0; + } + std::copy(mData16 + ichMin, mData16 + ichMin + cch, prgchwBuffer); + return (cch - ichMin); +} + +size_t GrUtfTextSrc::fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchwBuffer) +{ + assert(cch <= mLength); + if (cch > mLength) + { + return 0; + } + std::copy(mData32 + ichMin, mData32 + ichMin + cch, prgchwBuffer); + return (cch - ichMin); +} + + +bool GrUtfTextSrc::getRightToLeft(gr::toffset ich) +{ + return mRtl; // assumes src only contains one direction +} + +unsigned int GrUtfTextSrc::getDirectionDepth(gr::toffset ich) +{ + return (mRtl) ? 1 : 0; // TBD +} + +std::pair<gr::toffset, gr::toffset> GrUtfTextSrc::propertyRange(gr::toffset ich) +{ + std::pair<gr::toffset, gr::toffset> range(0, mLength); + if (mIsSelected) + { + bool selectState = mSelectionVector[ich]; + // find start + int s = ich - 1; + int e = ich + 1; + if (s > -1) + for ( ; s >= 0; s--) + { + if (mSelectionVector[s] != selectState) + { + s++; // backup + break; + } + } + if (s < 0) s = 0; + // find end + for ( ; e < static_cast<int>(mLength); e++) + { + if (mSelectionVector[e] != selectState) + { + // don't need to backup for end + break; + } + } + range.first = s; + range.second = e; + } + return range; +} + +size_t GrUtfTextSrc::getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset) +{ + return 0; +} + +void GrUtfTextSrc::getColors(gr::toffset ich, int * pclrFore, int * pclrBack) +{ + // selections are handled here + if (mIsSelected && mSelectionVector[ich]) + { + *pclrFore = mSelectForeground; + *pclrBack = mSelectBackground; + } + else + { + *pclrFore = mForeground; + *pclrBack = mBackground; + } +} + + +// these should be called I hope +float +GrUtfTextSrc::getFontSize(gr::toffset ich) +{ + assert(mFont); + return mPointSize; +} + +bool +GrUtfTextSrc::getBold(gr::toffset ich) +{ + assert(mFont); +// NS_ASSERTION(false, "unexpected call to getBold"); +// return false; + return mFont->bold(); +} + +bool +GrUtfTextSrc::getItalic(gr::toffset ich) +{ + assert(mFont); + //NS_ASSERTION(false, "unexpected call to getItalic"); + //return false; + return mFont->italic(); +} + +gr::isocode GrUtfTextSrc::getLanguage(gr::toffset ich) +{ + gr::isocode unknown; + std::fill_n(unknown.rgch, 4, '\0'); + return unknown; +} + diff --git a/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.h b/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.h index bdcd5fd6caf..cae0a4850b5 100644 --- a/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.h +++ b/Build/source/libs/graphite-engine/test/ProfileHarness/GrUtfTextSrc.h @@ -1,146 +1,146 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: NPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Netscape Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/NPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is sila.mozdev.org code.
- *
- * The Initial Developer of the Original Code is
- * Keith Stribley.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the NPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the NPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#ifdef _MSC_VER
-#pragma once
-#endif
-#ifndef GRUTFTXTSRC_INCLUDED
-#define GRUTFTXTSRC_INCLUDED
-
-#include <vector>
-#include <assert.h>
-
-#include <graphite/GrAppData.h>
-#include <graphite/GrStructs.h>
-#include <graphite/ITextSource.h>
-
-class nsIGrSegWrapper;
-
-/*-----------------------------------------------------------------------------
- Class: ITextSource
- This class provides an interface of a text source for the Graphite engine.
-------------------------------------------------------------------------------*/
-class GrUtfTextSrc : public gr::IColorTextSource
-{
-public:
- GrUtfTextSrc();
- ~GrUtfTextSrc();
- bool setText(const gr::utf8 * pszText, int len);
- bool setText(const char * pszText, int len);
- bool setText(const gr::utf16 * pszText, int len);
- bool setText(const gr::utf32 * pszText, int len);
- void setColors(int foreground, int background)
- {
- mForeground = foreground;
- mBackground = background;
- };
- //void setSelectionDetails(nsIGrSegWrapper * wrapper);
- void setFont(gr::Font * font) { mFont = font; };
- void setPointSize(float & pointSize) { mPointSize = pointSize; };
- // --------------------------------------------------------------------------
- // New V2 interface:
-
- virtual gr::UtfType utfEncodingForm() { return mType; };
- virtual size_t getLength() { return mLength; };
- virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchBuffer);
- virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer);
- virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchsBuffer);
- virtual gr::GrResult getFaceName(int ich, unsigned int cchMax,
- gr::utf16 * prgchFaceName, unsigned int * pcchLen)
- {
- prgchFaceName[0] = 0;
- *pcchLen = 0;
- return gr::kresNotImpl;
- };
- //virtual std::wstring getFaceName(int ich) { return mFont->getFaceName(); };
- virtual float getFontSize(gr::toffset ich);
- virtual bool getBold(gr::toffset ich);
- virtual bool getItalic(gr::toffset ich);
- virtual bool getRightToLeft(gr::toffset ich);
- virtual unsigned int getDirectionDepth(gr::toffset ich);
- virtual float getVerticalOffset(gr::toffset ich) { return 0;};
- virtual gr::isocode getLanguage(gr::toffset ich);
-
- virtual std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich);
- virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset);
- virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2) { return true; };
-
-protected:
- bool checkBuffer8();
- bool checkBuffer16();
- bool checkBuffer32();
-
-private:
- size_t mLength;
- size_t mBufferLength8;
- size_t mBufferLength16;
- size_t mBufferLength32;
- gr::utf8 * mData8;
- gr::utf16 * mData16;
- gr::utf32 * mData32;
- gr::UtfType mType;
- int mForeground;
- int mBackground;
- int mSelectForeground;
- int mSelectBackground;
- bool mIsSelected;
- std::wstring mFaceName;
- std::vector<bool> mSelectionVector;
- gr::Font * mFont;
- bool mRtl;
- float mPointSize;
-
-public: // methods that will go
- // Temporary--eventually these will be of interest only to SegmentPainter.
- virtual void getColors(gr::toffset ich, int * pclrFore, int * pclrBack);
-
- // Shouldn't be here!
- virtual gr::GrResult Fetch(int ichMin, int ichLim, gr::utf16 * prgchBuf) { return gr::kresNotImpl; };
- virtual gr::GrResult get_Length(int * pcch) { return gr::kresNotImpl; };
- virtual gr::GrResult GetFontVariations(int ich,
- wchar_t * prgchFontVar, int ichMax, int * pich,
- int * pichMin, int * pichLim) { return gr::kresNotImpl; };
-
-};
-
-
-#if !defined(GR_NAMESPACE)
-using namespace gr;
-#endif
-
-#endif // !GRUTFTXTSRC_INCLUDED
-
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: NPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Netscape Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is sila.mozdev.org code. + * + * The Initial Developer of the Original Code is + * Keith Stribley. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the NPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the NPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +#ifdef _MSC_VER +#pragma once +#endif +#ifndef GRUTFTXTSRC_INCLUDED +#define GRUTFTXTSRC_INCLUDED + +#include <vector> +#include <assert.h> + +#include <graphite/GrAppData.h> +#include <graphite/GrStructs.h> +#include <graphite/ITextSource.h> + +class nsIGrSegWrapper; + +/*----------------------------------------------------------------------------- + Class: ITextSource + This class provides an interface of a text source for the Graphite engine. +------------------------------------------------------------------------------*/ +class GrUtfTextSrc : public gr::IColorTextSource +{ +public: + GrUtfTextSrc(); + ~GrUtfTextSrc(); + bool setText(const gr::utf8 * pszText, int len); + bool setText(const char * pszText, int len); + bool setText(const gr::utf16 * pszText, int len); + bool setText(const gr::utf32 * pszText, int len); + void setColors(int foreground, int background) + { + mForeground = foreground; + mBackground = background; + }; + //void setSelectionDetails(nsIGrSegWrapper * wrapper); + void setFont(gr::Font * font) { mFont = font; }; + void setPointSize(float & pointSize) { mPointSize = pointSize; }; + // -------------------------------------------------------------------------- + // New V2 interface: + + virtual gr::UtfType utfEncodingForm() { return mType; }; + virtual size_t getLength() { return mLength; }; + virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf32 * prgchBuffer); + virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer); + virtual size_t fetch(gr::toffset ichMin, size_t cch, gr::utf8 * prgchsBuffer); + virtual gr::GrResult getFaceName(int ich, unsigned int cchMax, + gr::utf16 * prgchFaceName, unsigned int * pcchLen) + { + prgchFaceName[0] = 0; + *pcchLen = 0; + return gr::kresNotImpl; + }; + //virtual std::wstring getFaceName(int ich) { return mFont->getFaceName(); }; + virtual float getFontSize(gr::toffset ich); + virtual bool getBold(gr::toffset ich); + virtual bool getItalic(gr::toffset ich); + virtual bool getRightToLeft(gr::toffset ich); + virtual unsigned int getDirectionDepth(gr::toffset ich); + virtual float getVerticalOffset(gr::toffset ich) { return 0;}; + virtual gr::isocode getLanguage(gr::toffset ich); + + virtual std::pair<gr::toffset, gr::toffset> propertyRange(gr::toffset ich); + virtual size_t getFontFeatures(gr::toffset ich, gr::FeatureSetting * prgfset); + virtual bool sameSegment(gr::toffset ich1, gr::toffset ich2) { return true; }; + +protected: + bool checkBuffer8(); + bool checkBuffer16(); + bool checkBuffer32(); + +private: + size_t mLength; + size_t mBufferLength8; + size_t mBufferLength16; + size_t mBufferLength32; + gr::utf8 * mData8; + gr::utf16 * mData16; + gr::utf32 * mData32; + gr::UtfType mType; + int mForeground; + int mBackground; + int mSelectForeground; + int mSelectBackground; + bool mIsSelected; + std::wstring mFaceName; + std::vector<bool> mSelectionVector; + gr::Font * mFont; + bool mRtl; + float mPointSize; + +public: // methods that will go + // Temporary--eventually these will be of interest only to SegmentPainter. + virtual void getColors(gr::toffset ich, int * pclrFore, int * pclrBack); + + // Shouldn't be here! + virtual gr::GrResult Fetch(int ichMin, int ichLim, gr::utf16 * prgchBuf) { return gr::kresNotImpl; }; + virtual gr::GrResult get_Length(int * pcch) { return gr::kresNotImpl; }; + virtual gr::GrResult GetFontVariations(int ich, + wchar_t * prgchFontVar, int ichMax, int * pich, + int * pichMin, int * pichLim) { return gr::kresNotImpl; }; + +}; + + +#if !defined(GR_NAMESPACE) +using namespace gr; +#endif + +#endif // !GRUTFTXTSRC_INCLUDED + diff --git a/Build/source/libs/graphite-engine/test/ProfileHarness/ProfileHarness.cpp b/Build/source/libs/graphite-engine/test/ProfileHarness/ProfileHarness.cpp index bf1f874e9bc..168f22a7250 100644 --- a/Build/source/libs/graphite-engine/test/ProfileHarness/ProfileHarness.cpp +++ b/Build/source/libs/graphite-engine/test/ProfileHarness/ProfileHarness.cpp @@ -1,475 +1,475 @@ -/*-----------------------------------------------------------------------------
-Copyright (C) 2007 SIL International
-
-Distributable under the terms of either the Common Public License or the
-GNU Lesser General Public License, as specified in the LICENSING.txt file.
-
-File:
-Responsibility: Sharon Correll
-Last reviewed: Not yet.
-
-Description:
-A simple console app that creates a segment using FileFont and dumps a
-diagnostic table of the resulting glyph vector to the console.
-If graphite has been built with -DTRACING then it will also produce a
-diagnostic log of the segment creation in grSegmentLog.txt
------------------------------------------------------------------------------*/
-
-//#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <iostream>
-#include <iomanip>
-#include <string>
-#include <sstream>
-
-#include <graphite/GrClient.h>
-#include <graphite/ITextSource.h>
-///#include <graphite/IGrJustifier.h>
-#include <graphite/IGrEngine.h>
-#include <graphite/SegmentAux.h>
-#include <graphite/Font.h>
-#include <graphite/Segment.h>
-#include <graphite/GraphiteProcess.h>
-#include <graphite/FileFont.h>
-
-#include "GrUtfTextSrc.h"
-
-typedef std::pair< gr::GlyphIterator, gr::GlyphIterator > GlyphRange;
-
-#ifndef HAVE_STRTOF
-float strtof(char * text, char ** ignore)
-{
- return static_cast<float>(atof(text));
-}
-#endif
-
-#ifndef HAVE_STRTOL
-long strtol(char * text, char ** ignore)
-{
- return atol(text);
-}
-#endif
-
-struct Parameters
-{
- const char * textFile;
- const char * fontFile;
- float pointSize;
- int dpi;
- bool lineStart;
- bool lineEnd;
- bool useLineFill;
- bool useCodes;
- float width;
- int textArgIndex;
- gr::utf16 * pText16;
- gr::utf32 * pText32;
- size_t charLength;
- size_t offset;
-};
-
-#ifdef HAVE_ICONV
-void
-convertUtf8ToUtf32(char* pText, Parameters & parameters)
-{
- int length = strlen(reinterpret_cast<char*>(pText));
- //gr::utf8 * pText = reinterpret_cast<gr::utf8*>(argv[2]);
- // convert text to utf32 using iconv because its easier to debug string placements
- size_t bytesLeft = length;
- size_t outBytesLeft = (length + 1) * sizeof(gr::utf32);
- size_t outBufferSize = outBytesLeft;
- gr::utf32 * text32 = new gr::utf32[length + 1];
- iconv_t utf8to32 = iconv_open("utf32","utf8");
- assert(utf8to32 != (iconv_t)(-1));
- char * pText32 = reinterpret_cast<char*>(&text32[0]);
- size_t convertLength = iconv(utf8to32, &pText, &bytesLeft, &pText32, &outBytesLeft);
- if (convertLength == size_t(-1)) perror("iconv failed:");
- size_t charLength = (outBufferSize - outBytesLeft) / sizeof(gr::utf32);
- assert(convertLength != size_t(-1));
- // size_t offset = 0;
- // offset by 1 to avoid bom
- if (text32[0] == 0xfeff)
- {
- parameters.offset = 1;
- charLength--;
- }
- std::cout << "String has " << charLength << " characters (" << length << " bytes)" << std::endl;
- size_t ci;
- for (ci = 0; ci < 10 && ci < charLength; ci++)
- {
- std::cout << std::setw(4) << ci << '\t';
- }
- std::cout << std::endl;
- for (ci = 0; ci < charLength; ci++)
- {
- std::cout << std::setw(4) << std::hex
- << text32[ci+parameters.offset] << '\t';
- if (((ci + 1) % 10) == 0) std::cout << std::endl;
- }
- std::cout << std::endl;
- parameters.charLength = charLength;
- parameters.pText32 = text32;
- iconv_close(utf8to32);
-}
-#endif
-
-bool parseArgs(int argc, char *argv[], Parameters & parameters)
-{
- int mainArgOffset = 0;
- bool argError = false;
- char* pText = NULL;
- typedef enum
- {
- NONE,
- POINT_SIZE,
- DPI,
- LINE_START,
- LINE_END,
- LINE_FILL,
- CODES
- } TestOptions;
- TestOptions option = NONE;
- char * pIntEnd = NULL;
- char * pFloatEnd = NULL;
- long lTestSize = 0;
- float fTestSize = 0.0f;
- for (int a = 1; a < argc; a++)
- {
- switch (option)
- {
- case DPI:
- pIntEnd = NULL;
- lTestSize = strtol(argv[a],&pIntEnd, 10);
- if (lTestSize > 0 && lTestSize < INT_MAX && lTestSize != LONG_MAX)
- {
- parameters.dpi = lTestSize;
- }
- else
- {
- fprintf(stderr,"Invalid dpi %s\n", argv[a]);
- }
- option = NONE;
- break;
- case POINT_SIZE:
- pFloatEnd = NULL;
- fTestSize = strtof(argv[a],&pFloatEnd);
- // what is a reasonable maximum here
- if (fTestSize > 0 && fTestSize < 5000.0f)
- {
- parameters.pointSize = fTestSize;
- }
- else
- {
- fprintf(stderr,"Invalid point size %s\n", argv[a]);
- argError = true;
- }
- option = NONE;
- break;
- case LINE_FILL:
- pFloatEnd = NULL;
- fTestSize = strtof(argv[a],&pFloatEnd);
- // what is a good max width?
- if (fTestSize > 0 && fTestSize < 10000)
- {
- parameters.width = fTestSize;
- }
- else
- {
- fprintf(stderr,"Invalid line width %s\n", argv[a]);
- argError = true;
- }
- option = NONE;
- break;
- default:
- option = NONE;
- if (argv[a][0] == '-')
- {
- if (strcmp(argv[a], "-pt") == 0)
- {
- option = POINT_SIZE;
- }
- else if (strcmp(argv[a], "-dpi") == 0)
- {
- option = DPI;
- }
- else if (strcmp(argv[a], "-ls") == 0)
- {
- option = NONE;
- parameters.lineStart = true;
- }
- else if (strcmp(argv[a], "-le") == 0)
- {
- option = NONE;
- parameters.lineEnd = true;
- }
- else if (strcmp(argv[a], "-linefill") == 0)
- {
- option = LINE_FILL;
- parameters.useLineFill = true;
- }
- else if (strcmp(argv[a], "-codes") == 0)
- {
- option = NONE;
- parameters.useCodes = true;
- // must be less than argc
- parameters.pText32 = new gr::utf32[argc];
- printf("\nText codes\n");
- }
- else
- {
- argError = true;
- fprintf(stderr,"Unknown option %s\n",argv[a]);
- }
- }
- else if (mainArgOffset == 0)
- {
- parameters.textFile = argv[a];
- mainArgOffset++;
- }
- else if (mainArgOffset == 1)
- {
- parameters.fontFile = argv[a];
- mainArgOffset++;
- }
- else if (parameters.useCodes)
- {
- pIntEnd = NULL;
- mainArgOffset++;
- gr::utf32 code = strtol(argv[a],&pIntEnd, 16);
- if (code > 0)
- {
- parameters.pText32[parameters.charLength++] = code;
- if (parameters.charLength % 10 == 0)
- printf("%4x\n",code);
- else
- printf("%4x\t",code);
- }
- else
- {
- fprintf(stderr,"Invalid dpi %s\n", argv[a]);
- }
- }
- else if (mainArgOffset == 1)
- {
- mainArgOffset++;
- pText = argv[a];
- parameters.textArgIndex = a;
- }
- else
- {
- argError = true;
- fprintf(stderr,"too many arguments %s\n",argv[a]);
- }
- }
- }
- if (mainArgOffset < 2) argError = true;
- else
- {
- if (!parameters.useCodes && pText != NULL)
- {
-#ifdef HAVE_ICONV
- convertUtf8ToUtf32(pText, parameters);
-#else
- fprintf(stderr,"Only the -codes option is supported on Win32\r\n");
- argError = true;
-#endif
- }
- else
- {
- ///parameters.pText32[parameters.charLength] = 0;
- printf("\n");
- }
- }
- return (argError) ? false : true;
-}
-
-
-void initParameters(Parameters & parameters)
-{
- parameters.textFile = "";
- parameters.fontFile = "";
- parameters.pointSize = 12.0f;
- parameters.dpi = 72;
- parameters.lineStart = false;
- parameters.lineEnd = false;
- parameters.useLineFill = false;
- parameters.useCodes = false;
- parameters.width = 100.0f;
- parameters.pText16 = NULL;
- parameters.pText32 = NULL;
- parameters.textArgIndex = 0;
- parameters.charLength = 0;
- parameters.offset = 0;
-}
-
-
-
-int runGraphite(Parameters parameters)
-{
- int returnCode = 0;
- FILE * file = fopen(parameters.fontFile, "rb");
- gr::FileFont * fileFont = NULL;
-
- // Put the text into an array of string, each string is one paragraph.
- std::ifstream textFileStrm(parameters.textFile);
- std::cout << "FILE: " << parameters.textFile << "\n";
- std::string stringArray[100];
+/*----------------------------------------------------------------------------- +Copyright (C) 2007 SIL International + +Distributable under the terms of either the Common Public License or the +GNU Lesser General Public License, as specified in the LICENSING.txt file. + +File: +Responsibility: Sharon Correll +Last reviewed: Not yet. + +Description: +A simple console app that creates a segment using FileFont and dumps a +diagnostic table of the resulting glyph vector to the console. +If graphite has been built with -DTRACING then it will also produce a +diagnostic log of the segment creation in grSegmentLog.txt +-----------------------------------------------------------------------------*/ + +//#include <stdlib.h> +#include <stdio.h> +#include <assert.h> +#include <iostream> +#include <iomanip> +#include <string> +#include <sstream> + +#include <graphite/GrClient.h> +#include <graphite/ITextSource.h> +///#include <graphite/IGrJustifier.h> +#include <graphite/IGrEngine.h> +#include <graphite/SegmentAux.h> +#include <graphite/Font.h> +#include <graphite/Segment.h> +#include <graphite/GraphiteProcess.h> +#include <graphite/FileFont.h> + +#include "GrUtfTextSrc.h" + +typedef std::pair< gr::GlyphIterator, gr::GlyphIterator > GlyphRange; + +#ifndef HAVE_STRTOF +float strtof(char * text, char ** ignore) +{ + return static_cast<float>(atof(text)); +} +#endif + +#ifndef HAVE_STRTOL +long strtol(char * text, char ** ignore) +{ + return atol(text); +} +#endif + +struct Parameters +{ + const char * textFile; + const char * fontFile; + float pointSize; + int dpi; + bool lineStart; + bool lineEnd; + bool useLineFill; + bool useCodes; + float width; + int textArgIndex; + gr::utf16 * pText16; + gr::utf32 * pText32; + size_t charLength; + size_t offset; +}; + +#ifdef HAVE_ICONV +void +convertUtf8ToUtf32(char* pText, Parameters & parameters) +{ + int length = strlen(reinterpret_cast<char*>(pText)); + //gr::utf8 * pText = reinterpret_cast<gr::utf8*>(argv[2]); + // convert text to utf32 using iconv because its easier to debug string placements + size_t bytesLeft = length; + size_t outBytesLeft = (length + 1) * sizeof(gr::utf32); + size_t outBufferSize = outBytesLeft; + gr::utf32 * text32 = new gr::utf32[length + 1]; + iconv_t utf8to32 = iconv_open("utf32","utf8"); + assert(utf8to32 != (iconv_t)(-1)); + char * pText32 = reinterpret_cast<char*>(&text32[0]); + size_t convertLength = iconv(utf8to32, &pText, &bytesLeft, &pText32, &outBytesLeft); + if (convertLength == size_t(-1)) perror("iconv failed:"); + size_t charLength = (outBufferSize - outBytesLeft) / sizeof(gr::utf32); + assert(convertLength != size_t(-1)); + // size_t offset = 0; + // offset by 1 to avoid bom + if (text32[0] == 0xfeff) + { + parameters.offset = 1; + charLength--; + } + std::cout << "String has " << charLength << " characters (" << length << " bytes)" << std::endl; + size_t ci; + for (ci = 0; ci < 10 && ci < charLength; ci++) + { + std::cout << std::setw(4) << ci << '\t'; + } + std::cout << std::endl; + for (ci = 0; ci < charLength; ci++) + { + std::cout << std::setw(4) << std::hex + << text32[ci+parameters.offset] << '\t'; + if (((ci + 1) % 10) == 0) std::cout << std::endl; + } + std::cout << std::endl; + parameters.charLength = charLength; + parameters.pText32 = text32; + iconv_close(utf8to32); +} +#endif + +bool parseArgs(int argc, char *argv[], Parameters & parameters) +{ + int mainArgOffset = 0; + bool argError = false; + char* pText = NULL; + typedef enum + { + NONE, + POINT_SIZE, + DPI, + LINE_START, + LINE_END, + LINE_FILL, + CODES + } TestOptions; + TestOptions option = NONE; + char * pIntEnd = NULL; + char * pFloatEnd = NULL; + long lTestSize = 0; + float fTestSize = 0.0f; + for (int a = 1; a < argc; a++) + { + switch (option) + { + case DPI: + pIntEnd = NULL; + lTestSize = strtol(argv[a],&pIntEnd, 10); + if (lTestSize > 0 && lTestSize < INT_MAX && lTestSize != LONG_MAX) + { + parameters.dpi = lTestSize; + } + else + { + fprintf(stderr,"Invalid dpi %s\n", argv[a]); + } + option = NONE; + break; + case POINT_SIZE: + pFloatEnd = NULL; + fTestSize = strtof(argv[a],&pFloatEnd); + // what is a reasonable maximum here + if (fTestSize > 0 && fTestSize < 5000.0f) + { + parameters.pointSize = fTestSize; + } + else + { + fprintf(stderr,"Invalid point size %s\n", argv[a]); + argError = true; + } + option = NONE; + break; + case LINE_FILL: + pFloatEnd = NULL; + fTestSize = strtof(argv[a],&pFloatEnd); + // what is a good max width? + if (fTestSize > 0 && fTestSize < 10000) + { + parameters.width = fTestSize; + } + else + { + fprintf(stderr,"Invalid line width %s\n", argv[a]); + argError = true; + } + option = NONE; + break; + default: + option = NONE; + if (argv[a][0] == '-') + { + if (strcmp(argv[a], "-pt") == 0) + { + option = POINT_SIZE; + } + else if (strcmp(argv[a], "-dpi") == 0) + { + option = DPI; + } + else if (strcmp(argv[a], "-ls") == 0) + { + option = NONE; + parameters.lineStart = true; + } + else if (strcmp(argv[a], "-le") == 0) + { + option = NONE; + parameters.lineEnd = true; + } + else if (strcmp(argv[a], "-linefill") == 0) + { + option = LINE_FILL; + parameters.useLineFill = true; + } + else if (strcmp(argv[a], "-codes") == 0) + { + option = NONE; + parameters.useCodes = true; + // must be less than argc + parameters.pText32 = new gr::utf32[argc]; + printf("\nText codes\n"); + } + else + { + argError = true; + fprintf(stderr,"Unknown option %s\n",argv[a]); + } + } + else if (mainArgOffset == 0) + { + parameters.textFile = argv[a]; + mainArgOffset++; + } + else if (mainArgOffset == 1) + { + parameters.fontFile = argv[a]; + mainArgOffset++; + } + else if (parameters.useCodes) + { + pIntEnd = NULL; + mainArgOffset++; + gr::utf32 code = strtol(argv[a],&pIntEnd, 16); + if (code > 0) + { + parameters.pText32[parameters.charLength++] = code; + if (parameters.charLength % 10 == 0) + printf("%4x\n",code); + else + printf("%4x\t",code); + } + else + { + fprintf(stderr,"Invalid dpi %s\n", argv[a]); + } + } + else if (mainArgOffset == 1) + { + mainArgOffset++; + pText = argv[a]; + parameters.textArgIndex = a; + } + else + { + argError = true; + fprintf(stderr,"too many arguments %s\n",argv[a]); + } + } + } + if (mainArgOffset < 2) argError = true; + else + { + if (!parameters.useCodes && pText != NULL) + { +#ifdef HAVE_ICONV + convertUtf8ToUtf32(pText, parameters); +#else + fprintf(stderr,"Only the -codes option is supported on Win32\r\n"); + argError = true; +#endif + } + else + { + ///parameters.pText32[parameters.charLength] = 0; + printf("\n"); + } + } + return (argError) ? false : true; +} + + +void initParameters(Parameters & parameters) +{ + parameters.textFile = ""; + parameters.fontFile = ""; + parameters.pointSize = 12.0f; + parameters.dpi = 72; + parameters.lineStart = false; + parameters.lineEnd = false; + parameters.useLineFill = false; + parameters.useCodes = false; + parameters.width = 100.0f; + parameters.pText16 = NULL; + parameters.pText32 = NULL; + parameters.textArgIndex = 0; + parameters.charLength = 0; + parameters.offset = 0; +} + + + +int runGraphite(Parameters parameters) +{ + int returnCode = 0; + FILE * file = fopen(parameters.fontFile, "rb"); + gr::FileFont * fileFont = NULL; + + // Put the text into an array of string, each string is one paragraph. + std::ifstream textFileStrm(parameters.textFile); + std::cout << "FILE: " << parameters.textFile << "\n"; + std::string stringArray[100]; std::stringbuf buf; textFileStrm >> &buf; std::cout << "read " << buf.str().length() << " characters" << std::endl; std::cout << "====BEGIN===" << buf.str() << "====END====" << std::endl; - const std::string strTemp = buf.str();
- stringArray[0] = strTemp;
- int cpara = 1;
-
- try
- {
- if (file)
- {
- fileFont = new gr::FileFont(file, parameters.pointSize, parameters.dpi);
- if (!fileFont || !fileFont->isValid())
- {
- fprintf(stderr,"graphitejni:Invalid font!");
- delete fileFont;
- fileFont = NULL;
- return 2;
- }
- printf("Font: %s bold=%d italic=%d %4.1fpt dpi %d\n",
- parameters.fontFile,
- fileFont->bold(), fileFont->italic(),
- parameters.pointSize, parameters.dpi);
- bool isGraphite = fileFont->fontHasGraphiteTables();
- if (!isGraphite)
- {
- fprintf(stderr,"graphitejni: %s does not have graphite tables",
- parameters.fontFile);
- delete fileFont;
- fileFont = NULL;
- return 3;
- }
- }
- else
- {
- fprintf(stderr, "Failed to open %s\n", parameters.fontFile);
- return 4;
- }
-
- for (int ipara = 0; ipara < cpara; ipara++)
- {
- GrUtfTextSrc textSrc;
- gr::LayoutEnvironment layout;
-
- textSrc.setText(stringArray[ipara].data(), stringArray[ipara].length());
- textSrc.setPointSize(parameters.pointSize);
- textSrc.setFont(fileFont);
-
- layout.setStartOfLine(parameters.lineStart);
- layout.setEndOfLine(parameters.lineEnd);
- layout.setDumbFallback(true);
- layout.setJustifier(NULL);
-
- gr::Segment * pSegment = NULL;
- //try
- //{
- if (parameters.useLineFill)
- {
- pSegment = new gr::LineFillSegment(fileFont, &textSrc, &layout,
- 0, stringArray[ipara].length(),
- parameters.width);
- printf("LineFillSegment overing char %d - %d\nline start=%d line end=%d\n",
- pSegment->startCharacter(), pSegment->stopCharacter(),
- parameters.lineStart, parameters.lineEnd);
- }
- else
- {
- pSegment = new gr::RangeSegment(fileFont, &textSrc, &layout,
- 0, stringArray[ipara].length());
- printf("RangeSegment covering char %d - %d\nline start=%d line end=%d\n",
- pSegment->startCharacter(), pSegment->stopCharacter(),
- parameters.lineStart, parameters.lineEnd);
- }
- //}
- //catch (...)
- //{
- // printf("Exception occurred while creating segment\n");
- // returnCode = 5;
- // throw;
- //}
-
- if (!pSegment) return returnCode;
-
- // for justifier testing
- /*
- gr::GrJustifier justifier;
- pSegment->SetJustifier(&justifier);
- gr::Segment * justified = gr::Segment::JustifiedSegment(*pSegment, 2.0f * advanceWidth);
- delete justified;
- */
-
- delete pSegment;
- }
- }
- catch (...)
- {
- printf("Exception occurred\n");
- returnCode = 5;
- }
-
- delete fileFont;
-
- return returnCode;
-}
-
-#ifdef WIN32
-
-int _tmain(int argc, _TCHAR* argv[])
-{
- Parameters parameters;
- initParameters(parameters);
-
- if (!parseArgs(argc, argv, parameters))
- {
- fprintf(stderr,"Usage: %s [options] textfile fontfile \n",argv[0]);
- return 1;
- }
- // UTF16 arguments
- //if (parameters.textArgIndex > 0)
- //{
- // parameters.pText16 = reinterpret_cast<wchar_t*>(argv[parameters.textArgIndex]);
- // std::wstring text(parameters.pText16);
- // parameters.charLength = text.size();
- // for (int i = 0; i < text.size(); i++)
- // {
- // if (i % 10 == 0)
- // printf("\r\n%4x", text[i]);
- // else
- // printf("\t%4x", text[i]);
- // }
- //}
- //else
- //{
- // assert(parameters.pText32);
- //}
-
- return runGraphite(parameters);
-}
-
-#else
-
-int main(int argc, char *argv[])
-{
-
- Parameters parameters;
- initParameters(parameters);
-
- if (!parseArgs(argc, argv, parameters))
- {
- fprintf(stderr,"Usage: %s [options] textfile fontfile \n",argv[0]);
- return 1;
- }
- return runGraphite(parameters);
-}
-
-#endif
+ const std::string strTemp = buf.str(); + stringArray[0] = strTemp; + int cpara = 1; + + try + { + if (file) + { + fileFont = new gr::FileFont(file, parameters.pointSize, parameters.dpi); + if (!fileFont || !fileFont->isValid()) + { + fprintf(stderr,"graphitejni:Invalid font!"); + delete fileFont; + fileFont = NULL; + return 2; + } + printf("Font: %s bold=%d italic=%d %4.1fpt dpi %d\n", + parameters.fontFile, + fileFont->bold(), fileFont->italic(), + parameters.pointSize, parameters.dpi); + bool isGraphite = fileFont->fontHasGraphiteTables(); + if (!isGraphite) + { + fprintf(stderr,"graphitejni: %s does not have graphite tables", + parameters.fontFile); + delete fileFont; + fileFont = NULL; + return 3; + } + } + else + { + fprintf(stderr, "Failed to open %s\n", parameters.fontFile); + return 4; + } + + for (int ipara = 0; ipara < cpara; ipara++) + { + GrUtfTextSrc textSrc; + gr::LayoutEnvironment layout; + + textSrc.setText(stringArray[ipara].data(), stringArray[ipara].length()); + textSrc.setPointSize(parameters.pointSize); + textSrc.setFont(fileFont); + + layout.setStartOfLine(parameters.lineStart); + layout.setEndOfLine(parameters.lineEnd); + layout.setDumbFallback(true); + layout.setJustifier(NULL); + + gr::Segment * pSegment = NULL; + //try + //{ + if (parameters.useLineFill) + { + pSegment = new gr::LineFillSegment(fileFont, &textSrc, &layout, + 0, stringArray[ipara].length(), + parameters.width); + printf("LineFillSegment overing char %d - %d\nline start=%d line end=%d\n", + pSegment->startCharacter(), pSegment->stopCharacter(), + parameters.lineStart, parameters.lineEnd); + } + else + { + pSegment = new gr::RangeSegment(fileFont, &textSrc, &layout, + 0, stringArray[ipara].length()); + printf("RangeSegment covering char %d - %d\nline start=%d line end=%d\n", + pSegment->startCharacter(), pSegment->stopCharacter(), + parameters.lineStart, parameters.lineEnd); + } + //} + //catch (...) + //{ + // printf("Exception occurred while creating segment\n"); + // returnCode = 5; + // throw; + //} + + if (!pSegment) return returnCode; + + // for justifier testing + /* + gr::GrJustifier justifier; + pSegment->SetJustifier(&justifier); + gr::Segment * justified = gr::Segment::JustifiedSegment(*pSegment, 2.0f * advanceWidth); + delete justified; + */ + + delete pSegment; + } + } + catch (...) + { + printf("Exception occurred\n"); + returnCode = 5; + } + + delete fileFont; + + return returnCode; +} + +#ifdef WIN32 + +int _tmain(int argc, _TCHAR* argv[]) +{ + Parameters parameters; + initParameters(parameters); + + if (!parseArgs(argc, argv, parameters)) + { + fprintf(stderr,"Usage: %s [options] textfile fontfile \n",argv[0]); + return 1; + } + // UTF16 arguments + //if (parameters.textArgIndex > 0) + //{ + // parameters.pText16 = reinterpret_cast<wchar_t*>(argv[parameters.textArgIndex]); + // std::wstring text(parameters.pText16); + // parameters.charLength = text.size(); + // for (int i = 0; i < text.size(); i++) + // { + // if (i % 10 == 0) + // printf("\r\n%4x", text[i]); + // else + // printf("\t%4x", text[i]); + // } + //} + //else + //{ + // assert(parameters.pText32); + //} + + return runGraphite(parameters); +} + +#else + +int main(int argc, char *argv[]) +{ + + Parameters parameters; + initParameters(parameters); + + if (!parseArgs(argc, argv, parameters)) + { + fprintf(stderr,"Usage: %s [options] textfile fontfile \n",argv[0]); + return 1; + } + return runGraphite(parameters); +} + +#endif diff --git a/Build/source/libs/graphite-engine/test/ProfileHarness/makefile.vc b/Build/source/libs/graphite-engine/test/ProfileHarness/makefile.vc index dadff7cd363..5f42ba97b3b 100644 --- a/Build/source/libs/graphite-engine/test/ProfileHarness/makefile.vc +++ b/Build/source/libs/graphite-engine/test/ProfileHarness/makefile.vc @@ -1,111 +1,111 @@ -!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-!IF "$(CFG)" == ""
-CFG=DEBUG
-!ENDIF
-
-!IF "$(CFG)" == "RELEASE"
-
-OUTDIR=.\release
-INTDIR=.\release_temp
-
-all : "$(OUTDIR)\ProfileHarness.exe"
-
-clean :
- @- rd /s/q .\release_temp
-
-realclean : clean
- @- rd /s/q .\release
-
-CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib uuid.lib graphite.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\ProfileHarness.exe" /libpath:"..\..\release"
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\ProfileHarness.bsc"
-
-!ELSEIF "$(CFG)" == "DEBUG"
-
-OUTDIR=.\debug
-INTDIR=.\debug_temp
-
-all : "$(OUTDIR)\ProfileHarness.exe" "$(OUTDIR)\ProfileHarness.bsc"
-
-clean :
- @- rd /s/q .\debug_temp
-
-realclean : clean
- @- rd /s/q .\debug
-
-CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /GZ /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib uuid.lib graphite.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\ProfileHarness.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ProfileHarness.exe" /libpath:"..\..\debug"
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\ProfileHarness.bsc"
-
-!ENDIF
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(APPLIB)}.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(APPLIB)}.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(TEXTSRCDIR)}.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(TEXTSRCDIR)}.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-
-CPP=cl.exe
-RSC=rc.exe
-BSC32=bscmake.exe
-LINK32=link.exe
-
-LINK32_OBJS= \
- "$(INTDIR)\ProfileHarness.obj" \
- "$(INTDIR)\GrUtfTextSrc.obj" \
-
-"$(OUTDIR)\ProfileHarness.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-BSC32_SBRS= \
- "$(INTDIR)\ProfileHarness.sbr" \
- "$(INTDIR)\GrUtfTextSrc.sbr"
-
-"$(OUTDIR)\ProfileHarness.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
- $(BSC32) @<<
- $(BSC32_FLAGS) $(BSC32_SBRS)
-<<
-
-
-"$(INTDIR)\ProfileHarness.obj" "$(INTDIR)\ProfileHarness.sbr" : ".\ProfileHarness.cpp" "$(INTDIR)"
-"$(INTDIR)\GrTxtSrc.obj" "$(INTDIR)\GrUtfTextSrc.sbr" : ".\GrUtfTextSrc.cpp" "$(INTDIR)"
-
-
+!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +!IF "$(CFG)" == "" +CFG=DEBUG +!ENDIF + +!IF "$(CFG)" == "RELEASE" + +OUTDIR=.\release +INTDIR=.\release_temp + +all : "$(OUTDIR)\ProfileHarness.exe" + +clean : + @- rd /s/q .\release_temp + +realclean : clean + @- rd /s/q .\release + +CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c +LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib uuid.lib graphite.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\ProfileHarness.exe" /libpath:"..\..\release" +BSC32_FLAGS=/nologo /o"$(OUTDIR)\ProfileHarness.bsc" + +!ELSEIF "$(CFG)" == "DEBUG" + +OUTDIR=.\debug +INTDIR=.\debug_temp + +all : "$(OUTDIR)\ProfileHarness.exe" "$(OUTDIR)\ProfileHarness.bsc" + +clean : + @- rd /s/q .\debug_temp + +realclean : clean + @- rd /s/q .\debug + +CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /GZ /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c +LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib uuid.lib graphite.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\ProfileHarness.pdb" /debug /machine:I386 /out:"$(OUTDIR)\ProfileHarness.exe" /libpath:"..\..\debug" +BSC32_FLAGS=/nologo /o"$(OUTDIR)\ProfileHarness.bsc" + +!ENDIF + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +"$(INTDIR)" : + if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(APPLIB)}.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(APPLIB)}.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(TEXTSRCDIR)}.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(TEXTSRCDIR)}.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +CPP=cl.exe +RSC=rc.exe +BSC32=bscmake.exe +LINK32=link.exe + +LINK32_OBJS= \ + "$(INTDIR)\ProfileHarness.obj" \ + "$(INTDIR)\GrUtfTextSrc.obj" \ + +"$(OUTDIR)\ProfileHarness.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +BSC32_SBRS= \ + "$(INTDIR)\ProfileHarness.sbr" \ + "$(INTDIR)\GrUtfTextSrc.sbr" + +"$(OUTDIR)\ProfileHarness.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + + +"$(INTDIR)\ProfileHarness.obj" "$(INTDIR)\ProfileHarness.sbr" : ".\ProfileHarness.cpp" "$(INTDIR)" +"$(INTDIR)\GrTxtSrc.obj" "$(INTDIR)\GrUtfTextSrc.sbr" : ".\GrUtfTextSrc.cpp" "$(INTDIR)" + + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/Makefile.vc b/Build/source/libs/graphite-engine/test/RegressionTest/Makefile.vc index eb0717d8fb2..ff75d7e9e16 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/Makefile.vc +++ b/Build/source/libs/graphite-engine/test/RegressionTest/Makefile.vc @@ -1,121 +1,121 @@ -!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-
-TARGET=RegressionTest
-REGT_SRC=.
-REGT_RES=.
-REGT_APPLIB=..\..\..\examples\applib
-
-
-!IF "$(CFG)" == ""
-CFG=DEBUG
-!ENDIF
-
-!IF "$(CFG)" == "RELEASE"
-
-OUTDIR=.\release
-INTDIR=.\release_temp
-
-all : "$(OUTDIR)\$(TARGET).exe"
-
-clean :
- @- rd /s/q $(INTDIR)
-
-realclean : clean
- @- rd /s/q $(OUTDIR)
-
-CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /I "." /I "../../examples/applib" /I "../../include" /I "../../include/graphite" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)\$(TARGET).res" /d "NDEBUG"
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib graphite.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\$(TARGET).exe" /libpath:"..\..\release"
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\$(TARGET).bsc"
-
-!ELSEIF "$(CFG)" == "DEBUG"
-
-OUTDIR=.\debug
-INTDIR=.\debug_temp
-
-all : "$(OUTDIR)\$(TARGET).exe" "$(OUTDIR)\$(TARGET).bsc"
-
-clean :
- @- rd /s/q $(INTDIR)
-
-realclean : clean
- @- rd /s/q $(OUTDIR)
-
-CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /GZ /ZI /Od /I "." /I "../../examples/applib" /I "../../include" /I "../../include/graphite" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)\$(TARGET).res" /d "_DEBUG"
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib graphite.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\$(TARGET).pdb" /debug /machine:I386 /out:"$(OUTDIR)\$(TARGET).exe" /libpath:"..\..\debug"
-BSC32_FLAGS=/nologo /o"$(OUTDIR)\$(TARGET).bsc"
-
-!ENDIF
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-{$(REGT_SRC)}.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(REGT_SRC)}.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(REGT_APPLIB)}.cpp{$(INTDIR)}.obj::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-{$(REGT_APPLIB)}.cpp{$(INTDIR)}.sbr::
- $(CPP) @<<
- $(CPP_PROJ) $<
-<<
-
-
-
-CPP=cl.exe
-RSC=rc.exe
-BSC32=bscmake.exe
-LINK32=link.exe
-
-LINK32_OBJS= \
- "$(INTDIR)\RegressionTest.obj" \
- "$(INTDIR)\TestCase.obj" \
- "$(INTDIR)\GrJustifier.obj" \
- "$(INTDIR)\SimpleTextSrc.obj" \
-
-# "$(INTDIR)\RegressionTest.res"
-
-"$(OUTDIR)\$(TARGET).exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-BSC32_SBRS= \
- "$(INTDIR)\RegressionTest.sbr" \
- "$(INTDIR)\TestCase.sbr" \
- "$(INTDIR)\GrJustifier.sbr" \
- "$(INTDIR)\SimpleTextSrc.sbr" \
-#
-
-"$(OUTDIR)\$(TARGET).bsc" : "$(OUTDIR)" $(BSC32_SBRS)
- $(BSC32) @<<
- $(BSC32_FLAGS) $(BSC32_SBRS)
-<<
-
-"$(INTDIR)\RegressionTest.obj" "$(INTDIR)\RegressionTest.sbr" : "$(REGT_SRC)\RegressionTest.cpp" "$(INTDIR)"
-"$(INTDIR)\TestCase.obj" "$(INTDIR)\TestCase.sbr" : "$(REGT_SRC)\TestCase.cpp" "$(INTDIR)"
-"$(INTDIR)\GrJustifier.obj" "$(INTDIR)\GrJustifier.sbr" : "$(REGT_APPLIB)\GrJustifier.cpp" "$(INTDIR)"
-"$(INTDIR)\SimpleTextSrc.obj" "$(INTDIR)\SimpleTextSrc.sbr" : "$(REGT_APPLIB)\SimpleTextSrc.cpp" "$(INTDIR)"
-
-
-"$(INTDIR)\$(TARGET).res" : "$(REGT_RES)\$(TARGET).rc" "$(INTDIR)"
- $(RSC) $(RSC_PROJ) "$(REGT_RES)\$(TARGET).rc"
-
+!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +TARGET=RegressionTest +REGT_SRC=. +REGT_RES=. +REGT_APPLIB=..\..\..\examples\applib + + +!IF "$(CFG)" == "" +CFG=DEBUG +!ENDIF + +!IF "$(CFG)" == "RELEASE" + +OUTDIR=.\release +INTDIR=.\release_temp + +all : "$(OUTDIR)\$(TARGET).exe" + +clean : + @- rd /s/q $(INTDIR) + +realclean : clean + @- rd /s/q $(OUTDIR) + +CPP_PROJ=/nologo /MT /W3 /GR /GX /O2 /I "." /I "../../examples/applib" /I "../../include" /I "../../include/graphite" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\$(TARGET).res" /d "NDEBUG" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib graphite.lib /nologo /subsystem:console /incremental:no /machine:I386 /out:"$(OUTDIR)\$(TARGET).exe" /libpath:"..\..\release" +BSC32_FLAGS=/nologo /o"$(OUTDIR)\$(TARGET).bsc" + +!ELSEIF "$(CFG)" == "DEBUG" + +OUTDIR=.\debug +INTDIR=.\debug_temp + +all : "$(OUTDIR)\$(TARGET).exe" "$(OUTDIR)\$(TARGET).bsc" + +clean : + @- rd /s/q $(INTDIR) + +realclean : clean + @- rd /s/q $(OUTDIR) + +CPP_PROJ=/nologo /MTd /W3 /Gm /GR /GX /GZ /ZI /Od /I "." /I "../../examples/applib" /I "../../include" /I "../../include/graphite" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /c +RSC_PROJ=/l 0x409 /fo"$(INTDIR)\$(TARGET).res" /d "_DEBUG" +LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib graphite.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\$(TARGET).pdb" /debug /machine:I386 /out:"$(OUTDIR)\$(TARGET).exe" /libpath:"..\..\debug" +BSC32_FLAGS=/nologo /o"$(OUTDIR)\$(TARGET).bsc" + +!ENDIF + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +"$(INTDIR)" : + if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)" + +{$(REGT_SRC)}.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(REGT_SRC)}.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(REGT_APPLIB)}.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +{$(REGT_APPLIB)}.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + + +CPP=cl.exe +RSC=rc.exe +BSC32=bscmake.exe +LINK32=link.exe + +LINK32_OBJS= \ + "$(INTDIR)\RegressionTest.obj" \ + "$(INTDIR)\TestCase.obj" \ + "$(INTDIR)\GrJustifier.obj" \ + "$(INTDIR)\SimpleTextSrc.obj" \ + +# "$(INTDIR)\RegressionTest.res" + +"$(OUTDIR)\$(TARGET).exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + +BSC32_SBRS= \ + "$(INTDIR)\RegressionTest.sbr" \ + "$(INTDIR)\TestCase.sbr" \ + "$(INTDIR)\GrJustifier.sbr" \ + "$(INTDIR)\SimpleTextSrc.sbr" \ +# + +"$(OUTDIR)\$(TARGET).bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +"$(INTDIR)\RegressionTest.obj" "$(INTDIR)\RegressionTest.sbr" : "$(REGT_SRC)\RegressionTest.cpp" "$(INTDIR)" +"$(INTDIR)\TestCase.obj" "$(INTDIR)\TestCase.sbr" : "$(REGT_SRC)\TestCase.cpp" "$(INTDIR)" +"$(INTDIR)\GrJustifier.obj" "$(INTDIR)\GrJustifier.sbr" : "$(REGT_APPLIB)\GrJustifier.cpp" "$(INTDIR)" +"$(INTDIR)\SimpleTextSrc.obj" "$(INTDIR)\SimpleTextSrc.sbr" : "$(REGT_APPLIB)\SimpleTextSrc.cpp" "$(INTDIR)" + + +"$(INTDIR)\$(TARGET).res" : "$(REGT_RES)\$(TARGET).rc" "$(INTDIR)" + $(RSC) $(RSC_PROJ) "$(REGT_RES)\$(TARGET).rc" + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/RegressionTest.cpp b/Build/source/libs/graphite-engine/test/RegressionTest/RegressionTest.cpp index 33c95da5683..0054e9e1eeb 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/RegressionTest.cpp +++ b/Build/source/libs/graphite-engine/test/RegressionTest/RegressionTest.cpp @@ -1,747 +1,747 @@ -/*--------------------------------------------------------------------*//*:Ignore this sentence.
-Copyright (C) 2004 SIL International. All rights reserved.
-
-Distributable under the terms of either the Common Public License or the
-GNU Lesser General Public License, as specified in the LICENSING.txt file.
-
-File: RegressionTest.cpp
-Responsibility: Sharon Correll
-Last reviewed: Not yet.
-
-Description:
- Main file for the Graphite regression test program.
--------------------------------------------------------------------------------*//*:End Ignore*/
-
-#include "main.h"
-#include "MemoryUsage.h"
-
-//:>********************************************************************************************
-//:> Global variables
-//:>********************************************************************************************
-std::ofstream g_strmLog; // log file output stream
-std::ofstream g_strmTrace; // debugger trace for selected tests
-std::ofstream g_strmMemUsage;
-
-int g_errorCount;
-
-// HDC g_hdc; // device-context for bogus window on which to do drawing
-
-bool g_debugMode = false;
-bool g_silentMode = false;
-
-int g_itcaseStart = 0; // adjust to skip to a certain test
-
-SegmentMemoryUsage g_smu;
-FontMemoryUsage g_fmu;
-
-std::string g_fontPath = ".";
-#ifdef _WIN32
-#define PATH_SEP "\\"
-#else
-#define PATH_SEP "/"
-#endif
-
-// Forward defintions.
-int WriteLog(int);
-void CopyWstringToUtf16(std::wstring textStr, gr::utf16 * utf16Buf, int bufSize);
-
-//:>********************************************************************************************
-//:> Functions
-//:>********************************************************************************************
-
-/*----------------------------------------------------------------------------------------------
- Main function.
-----------------------------------------------------------------------------------------------*/
-
-int main(int argc, char* argv[])
-{
-#ifdef _WIN32
- _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
-#endif // WIN32
-
- int iargc = 1;
- while (iargc < argc)
- {
- if ((strcmp(argv[iargc], "/d") == 0) || (strcmp(argv[iargc], "-d") == 0))
- {
- g_debugMode = true;
- }
- if ((strcmp(argv[iargc], "/s") == 0) || (strcmp(argv[iargc], "-s") == 0))
- {
- g_silentMode = true;
- }
- if ((strcmp(argv[iargc], "/p") == 0) || (strcmp(argv[iargc], "-p") == 0))
- {
- iargc++;
- if (iargc < argc)
- {
- g_fontPath = argv[iargc];
- }
- }
- iargc++;
- }
-
- if (!g_silentMode)
- {
- std::cout << "Graphite Regression Test\n";
- std::cout << "Files path is " << g_fontPath << "\n\n";
- if (g_debugMode)
- std::cout << "In debug mode\n";
- }
-
- // Start a new log.
- g_strmLog.open("grregtest.log");
- if (g_strmLog.fail())
- {
- std::cout << "Unable to open log file.";
- return -1;
- }
-
- g_errorCount = 0;
-
-// g_hdc = ::GetDC(NULL);
-
- WriteToLog("Graphite Regression Test\n\n");
-
- // Initialize the tracelog file.
- g_strmTrace.open("tracelog.txt");
- g_strmTrace.close();
-
- TestCase * ptcaseList = NULL;
- int numberOfTests = TestCase::SetupTests(&ptcaseList);
-
- RunTests(numberOfTests, ptcaseList);
-
- WriteToLog("\n==============================================\n");
- g_strmLog << "\n\nTOTAL NUMBER OF ERRORS: " << g_errorCount << "\n";
- if (!g_silentMode)
- std::cout << "\n\nTOTAL NUMBER OF ERRORS: " << g_errorCount << "\n";
-
- g_strmLog.close();
-
- ////EngineInstance::DeleteEngines();
- TestCase::DeleteTests();
-
-// ::ReleaseDC(NULL, g_hdc);
-
- // Output segment memory usage information.
- //g_strmMemUsage.open("SegMemoryUsage.log");
- //g_smu.prettyPrint(g_strmMemUsage);
- //g_strmMemUsage.close();
-
- return g_errorCount;
-}
-
-/*----------------------------------------------------------------------------------------------
- Run the tests.
-----------------------------------------------------------------------------------------------*/
-void RunTests(int numberOfTests, TestCase * ptcaseList)
-{
- Segment * psegPrev = NULL;
- RtTextSrc * ptsrcPrev = NULL;
- Segment * psegRet = NULL;
- RtTextSrc * ptsrcRet = NULL;
-
- for (int itcase = g_itcaseStart; itcase < numberOfTests; itcase++)
- {
- TestCase * ptcase = ptcaseList + itcase;
- WriteToLog("\n----------------------------------------------\n");
- WriteToLog("Test: ");
-
- if (!g_silentMode)
- std::cout << "Test " << ptcase->TestName() << "...";
- WriteToLog(ptcase->TestName());
- WriteToLog("\n");
-
- RunOneTestCase(ptcase, psegPrev, &psegRet, &ptsrcRet);
-
- delete psegPrev;
- delete ptsrcPrev;
- psegPrev = psegRet;
- ptsrcPrev = ptsrcRet;
- psegRet = NULL;
- ptsrcRet = NULL;
- }
-
- delete psegPrev;
- delete ptsrcPrev;
-}
-
-/*----------------------------------------------------------------------------------------------
- Run a single test case.
-----------------------------------------------------------------------------------------------*/
-int RunOneTestCase(TestCase * ptcase, Segment * psegPrev, Segment ** ppsegRet, RtTextSrc ** pptsrcRet)
+/*--------------------------------------------------------------------*//*:Ignore this sentence. +Copyright (C) 2004 SIL International. All rights reserved. + +Distributable under the terms of either the Common Public License or the +GNU Lesser General Public License, as specified in the LICENSING.txt file. + +File: RegressionTest.cpp +Responsibility: Sharon Correll +Last reviewed: Not yet. + +Description: + Main file for the Graphite regression test program. +-------------------------------------------------------------------------------*//*:End Ignore*/ + +#include "main.h" +#include "MemoryUsage.h" + +//:>******************************************************************************************** +//:> Global variables +//:>******************************************************************************************** +std::ofstream g_strmLog; // log file output stream +std::ofstream g_strmTrace; // debugger trace for selected tests +std::ofstream g_strmMemUsage; + +int g_errorCount; + +// HDC g_hdc; // device-context for bogus window on which to do drawing + +bool g_debugMode = false; +bool g_silentMode = false; + +int g_itcaseStart = 0; // adjust to skip to a certain test + +SegmentMemoryUsage g_smu; +FontMemoryUsage g_fmu; + +std::string g_fontPath = "."; +#ifdef _WIN32 +#define PATH_SEP "\\" +#else +#define PATH_SEP "/" +#endif + +// Forward defintions. +int WriteLog(int); +void CopyWstringToUtf16(std::wstring textStr, gr::utf16 * utf16Buf, int bufSize); + +//:>******************************************************************************************** +//:> Functions +//:>******************************************************************************************** + +/*---------------------------------------------------------------------------------------------- + Main function. +----------------------------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) { -#ifdef _WIN32
- if (ptcase->Skip())
- {
- std::cout << "\nskipped\n";
- g_strmLog << "skipping\n";
- *ppsegRet = NULL;
- return 0;
- }
-
- // Break into the debugger if requested.
- if (ptcase->RunDebugger() && ::IsDebuggerPresent())
- {
- ::DebugBreak();
+#ifdef _WIN32 + _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); +#endif // WIN32 + + int iargc = 1; + while (iargc < argc) + { + if ((strcmp(argv[iargc], "/d") == 0) || (strcmp(argv[iargc], "-d") == 0)) + { + g_debugMode = true; + } + if ((strcmp(argv[iargc], "/s") == 0) || (strcmp(argv[iargc], "-s") == 0)) + { + g_silentMode = true; + } + if ((strcmp(argv[iargc], "/p") == 0) || (strcmp(argv[iargc], "-p") == 0)) + { + iargc++; + if (iargc < argc) + { + g_fontPath = argv[iargc]; + } + } + iargc++; } -#endif
-
- int errorCount = 0;
-
- gr::utf16 text[1024];
- CopyWstringToUtf16(ptcase->Text(), text, 1024);
-
- *ppsegRet = NULL;
- SegmentPainter * ppainter = NULL;
- std::pair<GlyphIterator, GlyphIterator> iterPair;
- GlyphIterator gitBegin;
- GlyphIterator gitEnd;
-
- //LOGFONT lf;
- //memset(&lf, '\0', sizeof(LOGFONT));
- //lf.lfCharSet = DEFAULT_CHARSET;
- //lf.lfHeight = (signed(ptcase->FontSize()) * -96) / 72; // 96 = resolution, 72 = points per inch
- //lf.lfWeight = 400;
- //lf.lfItalic = FALSE;
- //wcscpy(lf.lfFaceName, ptcase->FontName().data());
- //HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
- //HFONT hfont = CreateFontIndirect(&lf);
- //HFONT hfontOld = (HFONT)::SelectObject(hdc, hfont); // restore before destroying the DC.
- //WinFont winfont(hdc);
-
- FileFont font(g_fontPath + PATH_SEP + ptcase->FontFile(), float(signed(ptcase->FontSize())), 96, 96);
-
- if (!font.isValid())
- {
- OutputError(ptcase, std::string("ERROR: reading font file: \"") + ptcase->FontFile() + "\" at path \"" + g_fontPath + "\"; remaining tests skipped");
- *ppsegRet = NULL;
- errorCount++;
- return WriteLog(errorCount);
- }
-
- // Set up the text source.
- *pptsrcRet = new RtTextSrc(&(text[0]));
- RtTextSrc * ptsrc = *pptsrcRet;
- (*pptsrcRet)->setFeatures(ptcase->Features());
- (*pptsrcRet)->setRightToLeft(ptcase->Rtl());
-
- // Generate a segment.
- LayoutEnvironment layout;
- layout.setDumbFallback(ptcase->DumbFallback());
- layout.setStartOfLine(true);
- layout.setRightToLeft(ptcase->ParaRtl());
- if (ptcase->InitWithPrevSeg())
- layout.setPrevSegment(psegPrev);
-
- if (ptcase->TraceLog())
- {
- g_strmTrace.open("tracelog.txt", std::ios::app);
- g_strmTrace << "Test: " << ptcase->TestName() << "\n\n";
- layout.setLoggingStream(&g_strmTrace);
- }
-
- try
- {
- if (ptcase->AvailWidth() < 10000)
- {
- layout.setBestBreak(ptcase->PrefBreak());
- layout.setWorstBreak(ptcase->WorstBreak());
- layout.setTrailingWs(ptcase->Twsh());
- *ppsegRet = new LineFillSegment(&font, ptsrc, &layout,
- ptcase->FirstChar(), ptsrc->getLength(),
- (float)ptcase->AvailWidth(),
- ptcase->Backtrack());
- }
- else
- {
- *ppsegRet = new RangeSegment(&font, ptsrc, &layout);
- }
- }
- catch (...)
- {
- if (!ptcase->NoSegment())
- {
- if (ptcase->BadFont() && !ptcase->DumbFallback())
- // Weird situation.
- OutputError(ptcase, "ERROR: bad font with no fallback, yet a segment was expected???");
- else
- OutputError(ptcase, "ERROR: generating segment; remaining tests skipped");
- errorCount++;
- }
- // else segment creation failed as expected
-
- // NB: failure to create a segment due to throwing an exception seems to result in a memory
- // leak--the FontCache object FontFace::s_pFontCache does not get deleted.
-
- *ppsegRet = NULL;
- return WriteLog(errorCount);
- }
-
- if (ptcase->TraceLog())
- {
- g_strmTrace << "\n\n*********************************************************************************************************************\n\n";
- g_strmTrace.close();
- }
-
- if ((*ppsegRet) && (*ppsegRet)->segmentTermination() == kestNothingFit)
- {
- delete *ppsegRet;
- *ppsegRet = NULL;
- }
-
- if ((*ppsegRet) == NULL && !ptcase->NoSegment())
- {
- OutputError(ptcase, "ERROR: segment not created; remaining tests skipped");
- errorCount++;
- return WriteLog(errorCount);
- }
- else if (ptcase->NoSegment())
- {
- if (*ppsegRet)
- {
- OutputError(ptcase, "ERROR: segment created when none expected");
- errorCount++;
- }
- delete *ppsegRet;
- *ppsegRet = NULL;
- return WriteLog(errorCount);
- }
-
- Segment * pseg = *ppsegRet;
-
- pseg->calculateMemoryUsage(g_smu);
-
- // Calculate and output font memory usage.
- //g_fmu = Font::calculateMemoryUsage();
- //g_strmMemUsage.open("fontMemoryUsage.log");
- //g_fmu.prettyPrint(g_strmMemUsage);
- //g_strmMemUsage.close();
-
- // Test results.
- int segMin = pseg->startCharacter();
- int segLim = pseg->stopCharacter();
- if ((segLim - segMin) != ptcase->CharCount())
- {
- OutputErrorWithValues(ptcase, "ERROR: number of characters in segment", -1,
- (segLim - segMin), ptcase->CharCount());
- errorCount++;
- }
-
- int segWidth = (int)pseg->advanceWidth();
- if (segWidth != ptcase->SegWidth())
- {
- OutputErrorWithValues(ptcase, "ERROR: width of segment", -1,
- segWidth, ptcase->SegWidth());
- errorCount++;
- }
-
- iterPair = pseg->glyphs();
- gitBegin = iterPair.first;
- gitEnd = iterPair.second;
- int cGlyphs = gitEnd - gitBegin;
- if (cGlyphs != ptcase->GlyphCount())
- {
- OutputErrorWithValues(ptcase, "ERROR: number of glyphs", -1,
- cGlyphs, ptcase->GlyphCount());
- errorCount++;
- }
- else
- {
- GlyphIterator gitThis = gitBegin;
- for (int iglyph = 0; gitThis != gitEnd; ++gitThis, iglyph++)
- {
- if ((*gitThis).glyphID() != ptcase->GlyphID(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: glyph id ", iglyph,
- (*gitThis).glyphID(), ptcase->GlyphID(iglyph));
- errorCount++;
- }
- if (int((*gitThis).origin()) != ptcase->XPos(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: glyph x-position ", iglyph,
- int((*gitThis).origin()), ptcase->XPos(iglyph));
- errorCount++;
- }
- if (int((*gitThis).yOffset()) != ptcase->YPos(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: glyph y-position ", iglyph,
- int((*gitThis).yOffset()), ptcase->YPos(iglyph));
- errorCount++;
- }
- if (int((*gitThis).advanceWidth()) != ptcase->AdvWidth(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: advance width ", iglyph,
- int((*gitThis).advanceWidth()), ptcase->AdvWidth(iglyph));
- errorCount++;
- }
- if (ptcase->BbTests())
- {
- gr::Rect rectBb = (*gitThis).bb();
- if (int(rectBb.left) != ptcase->BbLeft(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: bb left ", iglyph,
- int(rectBb.left), ptcase->BbLeft(iglyph));
- errorCount++;
- }
- if (int(rectBb.right) != ptcase->BbRight(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: bb right ", iglyph,
- int(rectBb.right), ptcase->BbRight(iglyph));
- errorCount++;
- }
- if (int(rectBb.top) != ptcase->BbTop(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: bb top ", iglyph,
- int(rectBb.top), ptcase->BbTop(iglyph));
- errorCount++;
- }
- if (int(rectBb.bottom) != ptcase->BbBottom(iglyph))
- {
- OutputErrorWithValues(ptcase, "ERROR: bb bottom ", iglyph,
- int(rectBb.bottom), ptcase->BbBottom(iglyph));
- errorCount++;
- }
- }
- }
- }
-
- ppainter = new SegmentNonPainter(pseg);
-
- if (segLim == ptcase->CharCount())
- {
- for (int ichar = 0; ichar < segLim; ichar++)
- {
- LgIpValidResult ipvr = ppainter->isValidInsertionPoint(ichar);
- if ((ipvr == kipvrOK && !ptcase->InsPtFlag(ichar)) // TODO: handle kipvrUnknown
- || ipvr != kipvrOK && ptcase->InsPtFlag(ichar))
- {
- OutputErrorWithValues(ptcase, "ERROR: valid insertion point ", ichar,
- (ipvr == kipvrOK), ptcase->InsPtFlag(ichar));
- errorCount++;
- }
- }
- }
-
- int c2gi = 0;
- while (c2gi < ptcase->CharToGlyphCount())
- {
- int ichar = ptcase->CharToGlyphItem(c2gi++);
- int glyphCount = ptcase->CharToGlyphItem(c2gi++);
- std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyphSet = pseg->charToGlyphs(ichar);
- gr::GlyphSetIterator gitStart = glyphSet.first;
- gr::GlyphSetIterator gitStop = glyphSet.second;
- if ((gitStop - gitStart) != glyphCount)
- {
- OutputErrorWithValues(ptcase, "ERROR: number of glyphs for char ", ichar,
- gitStop - gitStart, glyphCount);
- errorCount++;
- c2gi += glyphCount;
- }
- else
- {
- GlyphSetIterator glyphLp = glyphSet.first;
- for (int ig = 0; ig < glyphCount; ig++)
- {
- if (static_cast<int>((*glyphLp).logicalIndex()) != ptcase->CharToGlyphItem(c2gi))
- {
- OutputErrorWithValues(ptcase, "ERROR: glyph for char ", ichar,
- (*glyphLp).logicalIndex(), ptcase->CharToGlyphItem(c2gi));
- errorCount++;
- }
- c2gi++;
- glyphLp++;
- }
- }
- }
-
- int att = 0;
- while (att < ptcase->AttachedGlyphCount())
- {
- int iglyph = ptcase->AttachedGlyphItem(att++);
- if (iglyph > cGlyphs)
- {
- OutputError(ptcase, "ERROR: non-existent glyph in attachment test ", iglyph);
- errorCount++;
- att++;
- att += ptcase->AttachedGlyphItem(att) + 1;
- continue;
- }
-
- GlyphIterator gitThis = gitBegin + iglyph;
- GlyphIterator gitBase = gitThis->attachedClusterBase();
- int ibase = gitBase->logicalIndex();
- if (ibase != ptcase->AttachedGlyphItem(att))
- {
- OutputErrorWithValues(ptcase, "ERROR: attachment base for glyph ", iglyph,
- ibase, ptcase->AttachedGlyphItem(att));
- errorCount++;
- }
- att++;
- std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyphSet = gitThis->attachedClusterGlyphs();
- gr::GlyphSetIterator gitStart = glyphSet.first;
- gr::GlyphSetIterator gitStop = glyphSet.second;
- int glyphCount = ptcase->AttachedGlyphItem(att++);
- if ((gitStop - gitStart) != glyphCount)
- {
- OutputErrorWithValues(ptcase, "ERROR: number of attachments for glyph ", iglyph,
- gitStop - gitStart, glyphCount);
- errorCount++;
- att += glyphCount;
- }
- else
- {
- GlyphSetIterator glyphLp = glyphSet.first;
- for (int ig = 0; ig < glyphCount; ig++)
- {
- if (static_cast<int>((*glyphLp).logicalIndex()) != ptcase->AttachedGlyphItem(att))
- {
- OutputErrorWithValues(ptcase, "ERROR: attachment for glyph ", iglyph,
- (*glyphLp).logicalIndex(), ptcase->AttachedGlyphItem(att));
- errorCount++;
- }
- att++;
- glyphLp++;
- }
- }
- }
-
- for (int iclicktest = 0; iclicktest < ptcase->NumberOfClickTests(); iclicktest++)
- {
- gr::Point ptClick;
- ptClick.x = static_cast<float>(ptcase->XClick(iclicktest));
- ptClick.y = static_cast<float>(ptcase->YClick(iclicktest));
- int charIndex;
- bool assocPrev;
- ppainter->pointToChar(ptClick, &charIndex, &assocPrev);
- if (charIndex != ptcase->ClickCharIndex(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: char index from click ", iclicktest,
- charIndex, ptcase->ClickCharIndex(iclicktest));
- errorCount++;
- continue;
- }
- if (assocPrev != ptcase->ClickAssocPrev(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: assoc-prev from click ", iclicktest,
- assocPrev, ptcase->ClickAssocPrev(iclicktest));
- errorCount++;
- }
- gr::Rect rect1, rect2;
- ppainter->positionsOfIP(charIndex, assocPrev,
- false, &rect1, &rect2);
- if (ptcase->Sel1Top(iclicktest) == TestCase::kAbsent)
- {
- if (rect1.top != 0 || rect1.bottom != 0 || rect1.left != 0 || rect1.right != 0)
- {
- OutputError(ptcase, "ERROR: IP prim rect found ", iclicktest);
- errorCount++;
- }
- }
- else if (rect1.top == 0 && rect1.bottom == 0 && rect1.left == 0 && rect1.right == 0)
- {
- OutputError(ptcase, "ERROR: IP prim rect not found ", iclicktest);
- errorCount++;
- }
- else
- {
- if ((int)rect1.top != ptcase->Sel1Top(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP prim rect top ", iclicktest,
- int(rect1.top), ptcase->Sel1Top(iclicktest));
- errorCount++;
- }
- if ((int)rect1.bottom != ptcase->Sel1Bottom(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP prim rect bottom ", iclicktest,
- int(rect1.bottom), ptcase->Sel1Bottom(iclicktest));
- errorCount++;
- }
- if ((int)rect1.left != ptcase->Sel1Left(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP prim rect left ", iclicktest,
- int(rect1.left), ptcase->Sel1Left(iclicktest));
- errorCount++;
- }
- }
-
- if (ptcase->Sel2Top(iclicktest) == TestCase::kAbsent)
- {
- if (rect2.top != 0 || rect2.bottom != 0 || rect2.left != 0 || rect2.right != 0)
- {
- OutputError(ptcase, "ERROR: IP sec rect found when not expected ", iclicktest);
- errorCount++;
- }
- }
- else if (rect2.top == 0 && rect2.bottom == 0 && rect2.left == 0 && rect2.right == 0)
- {
- OutputError(ptcase, "ERROR: IP sec rect not found ", iclicktest);
- errorCount++;
- }
- else
- {
- if ((int)rect2.top != ptcase->Sel2Top(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP sec rect top ", iclicktest,
- int(rect2.top), ptcase->Sel2Top(iclicktest));
- errorCount++;
- }
- if ((int)rect2.bottom != ptcase->Sel2Bottom(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP sec rect bottom ", iclicktest,
- int(rect2.bottom), ptcase->Sel2Bottom(iclicktest));
- errorCount++;
- }
- if ((int)rect2.left != ptcase->Sel2Left(iclicktest))
- {
- OutputErrorWithValues(ptcase, "ERROR: IP sec rect left ", iclicktest,
- int(rect2.left), ptcase->Sel2Left(iclicktest));
- errorCount++;
- }
- }
- }
-
- ////if (contextBlockOut != ptcase->OutputContextBlockSize())
- ////{
- //// OutputErrorWithValues(ptcase, "ERROR: output context block size ", -1,
- //// (int)contextBlockOut, (int)ptcase->OutputContextBlockSize());
- //// errorCount++;
- ////}
- ////else if (!ptcase->CompareContextBlock(pContextBlockOut))
- ////{
- //// OutputError(ptcase, "ERROR: output context block");
- //// errorCount++;
- ////}
- delete ppainter;
-
- return WriteLog(errorCount);
-}
-
-
-/*----------------------------------------------------------------------------------------------
- Write the error count to the log.
-----------------------------------------------------------------------------------------------*/
-int WriteLog(int errorCount)
-{
- WriteToLog("\nError count = ");
- WriteToLog(errorCount);
- WriteToLog("\n");
-
- if (!g_silentMode)
- {
- if (errorCount == 0)
- std::cout << "ok\n";
- else
- std::cout << "FAILED\n";
- }
-
-
- //delete pseg; // don't delete these; they are passed back to the calling method
- //delete ptsrc;
-
- // Delete device context
- //DeleteObject(SelectObject(hdc, hfontOld));
- //DeleteDC(hdc);
-
- g_errorCount += errorCount;
- return errorCount;
-}
-
-/*----------------------------------------------------------------------------------------------
- Copy a std::wstring (whose bytes can be of various sizes on different platforms)
- to a buffer of UTF16.
-----------------------------------------------------------------------------------------------*/
-void CopyWstringToUtf16(std::wstring textStr, gr::utf16 * utf16Buf, int bufSize)
-{
- std::fill_n(utf16Buf, bufSize, 0);
- int cc = textStr.length();
- for (int i = 0; i < cc; i++)
- utf16Buf[i] = textStr[i];
-}
-
-/*----------------------------------------------------------------------------------------------
- Output information about an error.
-----------------------------------------------------------------------------------------------*/
-void OutputError(TestCase * ptcase, std::string strErr, int i)
-{
- OutputErrorAux(ptcase, strErr, i, false, 0, 0);
-}
-
-void OutputErrorWithValues(TestCase * ptcase, std::string strErr, int i,
- int valueFound, int valueExpected)
-{
- OutputErrorAux(ptcase, strErr, i, true, valueFound, valueExpected);
-}
-
-void OutputErrorAux(TestCase * ptcase, std::string strErr, int i,
- bool showValues, int valueFound, int valueExpected)
-{
-// if (g_debugMode)
-// ::DebugBreak();
-
- if (!g_silentMode)
- {
- //std::cout << ptcase->TestName() << ": ";
- std::cout << strErr;
- if (i > -1)
- {
- std::cout << "[" << i << "]";
- }
- std::cout << "\n ";
- }
-
- WriteToLog(strErr, i, showValues, valueFound, valueExpected);
-
- WriteToLog("\n");
-}
-
-/*----------------------------------------------------------------------------------------------
- Write some text to the log file.
-----------------------------------------------------------------------------------------------*/
-bool WriteToLog(std::string str, int i)
-{
- if (g_strmLog.fail())
- {
- std::cout << "Error opening log file.";
- return false;
- }
- g_strmLog << str;
- if (i > -1)
- g_strmLog << "[" << i << "]";
- g_strmLog.flush();
- return true;
-}
-
-bool WriteToLog(std::string str, int i,
- bool showValues, int valueFound, int valueExpected)
-{
- if (g_strmLog.fail())
- {
- std::cout << "Error opening log file.";
- return false;
- }
- g_strmLog << str;
- if (i > -1)
- g_strmLog << "[" << i << "]";
- if (showValues)
- {
- g_strmLog << "; found " << valueFound << " not " << valueExpected;
- }
- g_strmLog.flush();
- return true;
-}
-
-
-bool WriteToLog(int n)
-{
- if (g_strmLog.fail())
- {
- std::cout << "Error opening log file.";
- return false;
- }
- g_strmLog << n;
- g_strmLog.flush();
- return true;
-}
-
+ + if (!g_silentMode) + { + std::cout << "Graphite Regression Test\n"; + std::cout << "Files path is " << g_fontPath << "\n\n"; + if (g_debugMode) + std::cout << "In debug mode\n"; + } + + // Start a new log. + g_strmLog.open("grregtest.log"); + if (g_strmLog.fail()) + { + std::cout << "Unable to open log file."; + return -1; + } + + g_errorCount = 0; + +// g_hdc = ::GetDC(NULL); + + WriteToLog("Graphite Regression Test\n\n"); + + // Initialize the tracelog file. + g_strmTrace.open("tracelog.txt"); + g_strmTrace.close(); + + TestCase * ptcaseList = NULL; + int numberOfTests = TestCase::SetupTests(&ptcaseList); + + RunTests(numberOfTests, ptcaseList); + + WriteToLog("\n==============================================\n"); + g_strmLog << "\n\nTOTAL NUMBER OF ERRORS: " << g_errorCount << "\n"; + if (!g_silentMode) + std::cout << "\n\nTOTAL NUMBER OF ERRORS: " << g_errorCount << "\n"; + + g_strmLog.close(); + + ////EngineInstance::DeleteEngines(); + TestCase::DeleteTests(); + +// ::ReleaseDC(NULL, g_hdc); + + // Output segment memory usage information. + //g_strmMemUsage.open("SegMemoryUsage.log"); + //g_smu.prettyPrint(g_strmMemUsage); + //g_strmMemUsage.close(); + + return g_errorCount; +} + +/*---------------------------------------------------------------------------------------------- + Run the tests. +----------------------------------------------------------------------------------------------*/ +void RunTests(int numberOfTests, TestCase * ptcaseList) +{ + Segment * psegPrev = NULL; + RtTextSrc * ptsrcPrev = NULL; + Segment * psegRet = NULL; + RtTextSrc * ptsrcRet = NULL; + + for (int itcase = g_itcaseStart; itcase < numberOfTests; itcase++) + { + TestCase * ptcase = ptcaseList + itcase; + WriteToLog("\n----------------------------------------------\n"); + WriteToLog("Test: "); + + if (!g_silentMode) + std::cout << "Test " << ptcase->TestName() << "..."; + WriteToLog(ptcase->TestName()); + WriteToLog("\n"); + + RunOneTestCase(ptcase, psegPrev, &psegRet, &ptsrcRet); + + delete psegPrev; + delete ptsrcPrev; + psegPrev = psegRet; + ptsrcPrev = ptsrcRet; + psegRet = NULL; + ptsrcRet = NULL; + } + + delete psegPrev; + delete ptsrcPrev; +} + +/*---------------------------------------------------------------------------------------------- + Run a single test case. +----------------------------------------------------------------------------------------------*/ +int RunOneTestCase(TestCase * ptcase, Segment * psegPrev, Segment ** ppsegRet, RtTextSrc ** pptsrcRet) +{ + if (ptcase->Skip()) + { + std::cout << "\nskipped\n"; + g_strmLog << "skipping\n"; + *ppsegRet = NULL; + return 0; + } + +#ifdef _WIN32 + // Break into the debugger if requested. + if (ptcase->RunDebugger() && ::IsDebuggerPresent()) + { + ::DebugBreak(); + } +#endif + + int errorCount = 0; + + gr::utf16 text[1024]; + CopyWstringToUtf16(ptcase->Text(), text, 1024); + + *ppsegRet = NULL; + SegmentPainter * ppainter = NULL; + std::pair<GlyphIterator, GlyphIterator> iterPair; + GlyphIterator gitBegin; + GlyphIterator gitEnd; + + //LOGFONT lf; + //memset(&lf, '\0', sizeof(LOGFONT)); + //lf.lfCharSet = DEFAULT_CHARSET; + //lf.lfHeight = (signed(ptcase->FontSize()) * -96) / 72; // 96 = resolution, 72 = points per inch + //lf.lfWeight = 400; + //lf.lfItalic = FALSE; + //wcscpy(lf.lfFaceName, ptcase->FontName().data()); + //HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); + //HFONT hfont = CreateFontIndirect(&lf); + //HFONT hfontOld = (HFONT)::SelectObject(hdc, hfont); // restore before destroying the DC. + //WinFont winfont(hdc); + + FileFont font(g_fontPath + PATH_SEP + ptcase->FontFile(), float(signed(ptcase->FontSize())), 96, 96); + + if (!font.isValid()) + { + OutputError(ptcase, std::string("ERROR: reading font file: \"") + ptcase->FontFile() + "\" at path \"" + g_fontPath + "\"; remaining tests skipped"); + *ppsegRet = NULL; + errorCount++; + return WriteLog(errorCount); + } + + // Set up the text source. + *pptsrcRet = new RtTextSrc(&(text[0])); + RtTextSrc * ptsrc = *pptsrcRet; + (*pptsrcRet)->setFeatures(ptcase->Features()); + (*pptsrcRet)->setRightToLeft(ptcase->Rtl()); + + // Generate a segment. + LayoutEnvironment layout; + layout.setDumbFallback(ptcase->DumbFallback()); + layout.setStartOfLine(true); + layout.setRightToLeft(ptcase->ParaRtl()); + if (ptcase->InitWithPrevSeg()) + layout.setPrevSegment(psegPrev); + + if (ptcase->TraceLog()) + { + g_strmTrace.open("tracelog.txt", std::ios::app); + g_strmTrace << "Test: " << ptcase->TestName() << "\n\n"; + layout.setLoggingStream(&g_strmTrace); + } + + try + { + if (ptcase->AvailWidth() < 10000) + { + layout.setBestBreak(ptcase->PrefBreak()); + layout.setWorstBreak(ptcase->WorstBreak()); + layout.setTrailingWs(ptcase->Twsh()); + *ppsegRet = new LineFillSegment(&font, ptsrc, &layout, + ptcase->FirstChar(), ptsrc->getLength(), + (float)ptcase->AvailWidth(), + ptcase->Backtrack()); + } + else + { + *ppsegRet = new RangeSegment(&font, ptsrc, &layout); + } + } + catch (...) + { + if (!ptcase->NoSegment()) + { + if (ptcase->BadFont() && !ptcase->DumbFallback()) + // Weird situation. + OutputError(ptcase, "ERROR: bad font with no fallback, yet a segment was expected???"); + else + OutputError(ptcase, "ERROR: generating segment; remaining tests skipped"); + errorCount++; + } + // else segment creation failed as expected + + // NB: failure to create a segment due to throwing an exception seems to result in a memory + // leak--the FontCache object FontFace::s_pFontCache does not get deleted. + + *ppsegRet = NULL; + return WriteLog(errorCount); + } + + if (ptcase->TraceLog()) + { + g_strmTrace << "\n\n*********************************************************************************************************************\n\n"; + g_strmTrace.close(); + } + + if ((*ppsegRet) && (*ppsegRet)->segmentTermination() == kestNothingFit) + { + delete *ppsegRet; + *ppsegRet = NULL; + } + + if ((*ppsegRet) == NULL && !ptcase->NoSegment()) + { + OutputError(ptcase, "ERROR: segment not created; remaining tests skipped"); + errorCount++; + return WriteLog(errorCount); + } + else if (ptcase->NoSegment()) + { + if (*ppsegRet) + { + OutputError(ptcase, "ERROR: segment created when none expected"); + errorCount++; + } + delete *ppsegRet; + *ppsegRet = NULL; + return WriteLog(errorCount); + } + + Segment * pseg = *ppsegRet; + + pseg->calculateMemoryUsage(g_smu); + + // Calculate and output font memory usage. + //g_fmu = Font::calculateMemoryUsage(); + //g_strmMemUsage.open("fontMemoryUsage.log"); + //g_fmu.prettyPrint(g_strmMemUsage); + //g_strmMemUsage.close(); + + // Test results. + int segMin = pseg->startCharacter(); + int segLim = pseg->stopCharacter(); + if ((segLim - segMin) != ptcase->CharCount()) + { + OutputErrorWithValues(ptcase, "ERROR: number of characters in segment", -1, + (segLim - segMin), ptcase->CharCount()); + errorCount++; + } + + int segWidth = (int)pseg->advanceWidth(); + if (segWidth != ptcase->SegWidth()) + { + OutputErrorWithValues(ptcase, "ERROR: width of segment", -1, + segWidth, ptcase->SegWidth()); + errorCount++; + } + + iterPair = pseg->glyphs(); + gitBegin = iterPair.first; + gitEnd = iterPair.second; + int cGlyphs = gitEnd - gitBegin; + if (cGlyphs != ptcase->GlyphCount()) + { + OutputErrorWithValues(ptcase, "ERROR: number of glyphs", -1, + cGlyphs, ptcase->GlyphCount()); + errorCount++; + } + else + { + GlyphIterator gitThis = gitBegin; + for (int iglyph = 0; gitThis != gitEnd; ++gitThis, iglyph++) + { + if ((*gitThis).glyphID() != ptcase->GlyphID(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: glyph id ", iglyph, + (*gitThis).glyphID(), ptcase->GlyphID(iglyph)); + errorCount++; + } + if (int((*gitThis).origin()) != ptcase->XPos(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: glyph x-position ", iglyph, + int((*gitThis).origin()), ptcase->XPos(iglyph)); + errorCount++; + } + if (int((*gitThis).yOffset()) != ptcase->YPos(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: glyph y-position ", iglyph, + int((*gitThis).yOffset()), ptcase->YPos(iglyph)); + errorCount++; + } + if (int((*gitThis).advanceWidth()) != ptcase->AdvWidth(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: advance width ", iglyph, + int((*gitThis).advanceWidth()), ptcase->AdvWidth(iglyph)); + errorCount++; + } + if (ptcase->BbTests()) + { + gr::Rect rectBb = (*gitThis).bb(); + if (int(rectBb.left) != ptcase->BbLeft(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: bb left ", iglyph, + int(rectBb.left), ptcase->BbLeft(iglyph)); + errorCount++; + } + if (int(rectBb.right) != ptcase->BbRight(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: bb right ", iglyph, + int(rectBb.right), ptcase->BbRight(iglyph)); + errorCount++; + } + if (int(rectBb.top) != ptcase->BbTop(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: bb top ", iglyph, + int(rectBb.top), ptcase->BbTop(iglyph)); + errorCount++; + } + if (int(rectBb.bottom) != ptcase->BbBottom(iglyph)) + { + OutputErrorWithValues(ptcase, "ERROR: bb bottom ", iglyph, + int(rectBb.bottom), ptcase->BbBottom(iglyph)); + errorCount++; + } + } + } + } + + ppainter = new SegmentNonPainter(pseg); + + if (segLim == ptcase->CharCount()) + { + for (int ichar = 0; ichar < segLim; ichar++) + { + LgIpValidResult ipvr = ppainter->isValidInsertionPoint(ichar); + if ((ipvr == kipvrOK && !ptcase->InsPtFlag(ichar)) // TODO: handle kipvrUnknown + || ipvr != kipvrOK && ptcase->InsPtFlag(ichar)) + { + OutputErrorWithValues(ptcase, "ERROR: valid insertion point ", ichar, + (ipvr == kipvrOK), ptcase->InsPtFlag(ichar)); + errorCount++; + } + } + } + + int c2gi = 0; + while (c2gi < ptcase->CharToGlyphCount()) + { + int ichar = ptcase->CharToGlyphItem(c2gi++); + int glyphCount = ptcase->CharToGlyphItem(c2gi++); + std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyphSet = pseg->charToGlyphs(ichar); + gr::GlyphSetIterator gitStart = glyphSet.first; + gr::GlyphSetIterator gitStop = glyphSet.second; + if ((gitStop - gitStart) != glyphCount) + { + OutputErrorWithValues(ptcase, "ERROR: number of glyphs for char ", ichar, + gitStop - gitStart, glyphCount); + errorCount++; + c2gi += glyphCount; + } + else + { + GlyphSetIterator glyphLp = glyphSet.first; + for (int ig = 0; ig < glyphCount; ig++) + { + if (static_cast<int>((*glyphLp).logicalIndex()) != ptcase->CharToGlyphItem(c2gi)) + { + OutputErrorWithValues(ptcase, "ERROR: glyph for char ", ichar, + (*glyphLp).logicalIndex(), ptcase->CharToGlyphItem(c2gi)); + errorCount++; + } + c2gi++; + glyphLp++; + } + } + } + + int att = 0; + while (att < ptcase->AttachedGlyphCount()) + { + int iglyph = ptcase->AttachedGlyphItem(att++); + if (iglyph > cGlyphs) + { + OutputError(ptcase, "ERROR: non-existent glyph in attachment test ", iglyph); + errorCount++; + att++; + att += ptcase->AttachedGlyphItem(att) + 1; + continue; + } + + GlyphIterator gitThis = gitBegin + iglyph; + GlyphIterator gitBase = gitThis->attachedClusterBase(); + int ibase = gitBase->logicalIndex(); + if (ibase != ptcase->AttachedGlyphItem(att)) + { + OutputErrorWithValues(ptcase, "ERROR: attachment base for glyph ", iglyph, + ibase, ptcase->AttachedGlyphItem(att)); + errorCount++; + } + att++; + std::pair<gr::GlyphSetIterator, gr::GlyphSetIterator> glyphSet = gitThis->attachedClusterGlyphs(); + gr::GlyphSetIterator gitStart = glyphSet.first; + gr::GlyphSetIterator gitStop = glyphSet.second; + int glyphCount = ptcase->AttachedGlyphItem(att++); + if ((gitStop - gitStart) != glyphCount) + { + OutputErrorWithValues(ptcase, "ERROR: number of attachments for glyph ", iglyph, + gitStop - gitStart, glyphCount); + errorCount++; + att += glyphCount; + } + else + { + GlyphSetIterator glyphLp = glyphSet.first; + for (int ig = 0; ig < glyphCount; ig++) + { + if (static_cast<int>((*glyphLp).logicalIndex()) != ptcase->AttachedGlyphItem(att)) + { + OutputErrorWithValues(ptcase, "ERROR: attachment for glyph ", iglyph, + (*glyphLp).logicalIndex(), ptcase->AttachedGlyphItem(att)); + errorCount++; + } + att++; + glyphLp++; + } + } + } + + for (int iclicktest = 0; iclicktest < ptcase->NumberOfClickTests(); iclicktest++) + { + gr::Point ptClick; + ptClick.x = static_cast<float>(ptcase->XClick(iclicktest)); + ptClick.y = static_cast<float>(ptcase->YClick(iclicktest)); + int charIndex; + bool assocPrev; + ppainter->pointToChar(ptClick, &charIndex, &assocPrev); + if (charIndex != ptcase->ClickCharIndex(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: char index from click ", iclicktest, + charIndex, ptcase->ClickCharIndex(iclicktest)); + errorCount++; + continue; + } + if (assocPrev != ptcase->ClickAssocPrev(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: assoc-prev from click ", iclicktest, + assocPrev, ptcase->ClickAssocPrev(iclicktest)); + errorCount++; + } + gr::Rect rect1, rect2; + ppainter->positionsOfIP(charIndex, assocPrev, + false, &rect1, &rect2); + if (ptcase->Sel1Top(iclicktest) == TestCase::kAbsent) + { + if (rect1.top != 0 || rect1.bottom != 0 || rect1.left != 0 || rect1.right != 0) + { + OutputError(ptcase, "ERROR: IP prim rect found ", iclicktest); + errorCount++; + } + } + else if (rect1.top == 0 && rect1.bottom == 0 && rect1.left == 0 && rect1.right == 0) + { + OutputError(ptcase, "ERROR: IP prim rect not found ", iclicktest); + errorCount++; + } + else + { + if ((int)rect1.top != ptcase->Sel1Top(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP prim rect top ", iclicktest, + int(rect1.top), ptcase->Sel1Top(iclicktest)); + errorCount++; + } + if ((int)rect1.bottom != ptcase->Sel1Bottom(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP prim rect bottom ", iclicktest, + int(rect1.bottom), ptcase->Sel1Bottom(iclicktest)); + errorCount++; + } + if ((int)rect1.left != ptcase->Sel1Left(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP prim rect left ", iclicktest, + int(rect1.left), ptcase->Sel1Left(iclicktest)); + errorCount++; + } + } + + if (ptcase->Sel2Top(iclicktest) == TestCase::kAbsent) + { + if (rect2.top != 0 || rect2.bottom != 0 || rect2.left != 0 || rect2.right != 0) + { + OutputError(ptcase, "ERROR: IP sec rect found when not expected ", iclicktest); + errorCount++; + } + } + else if (rect2.top == 0 && rect2.bottom == 0 && rect2.left == 0 && rect2.right == 0) + { + OutputError(ptcase, "ERROR: IP sec rect not found ", iclicktest); + errorCount++; + } + else + { + if ((int)rect2.top != ptcase->Sel2Top(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP sec rect top ", iclicktest, + int(rect2.top), ptcase->Sel2Top(iclicktest)); + errorCount++; + } + if ((int)rect2.bottom != ptcase->Sel2Bottom(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP sec rect bottom ", iclicktest, + int(rect2.bottom), ptcase->Sel2Bottom(iclicktest)); + errorCount++; + } + if ((int)rect2.left != ptcase->Sel2Left(iclicktest)) + { + OutputErrorWithValues(ptcase, "ERROR: IP sec rect left ", iclicktest, + int(rect2.left), ptcase->Sel2Left(iclicktest)); + errorCount++; + } + } + } + + ////if (contextBlockOut != ptcase->OutputContextBlockSize()) + ////{ + //// OutputErrorWithValues(ptcase, "ERROR: output context block size ", -1, + //// (int)contextBlockOut, (int)ptcase->OutputContextBlockSize()); + //// errorCount++; + ////} + ////else if (!ptcase->CompareContextBlock(pContextBlockOut)) + ////{ + //// OutputError(ptcase, "ERROR: output context block"); + //// errorCount++; + ////} + delete ppainter; + + return WriteLog(errorCount); +} + + +/*---------------------------------------------------------------------------------------------- + Write the error count to the log. +----------------------------------------------------------------------------------------------*/ +int WriteLog(int errorCount) +{ + WriteToLog("\nError count = "); + WriteToLog(errorCount); + WriteToLog("\n"); + + if (!g_silentMode) + { + if (errorCount == 0) + std::cout << "ok\n"; + else + std::cout << "FAILED\n"; + } + + + //delete pseg; // don't delete these; they are passed back to the calling method + //delete ptsrc; + + // Delete device context + //DeleteObject(SelectObject(hdc, hfontOld)); + //DeleteDC(hdc); + + g_errorCount += errorCount; + return errorCount; +} + +/*---------------------------------------------------------------------------------------------- + Copy a std::wstring (whose bytes can be of various sizes on different platforms) + to a buffer of UTF16. +----------------------------------------------------------------------------------------------*/ +void CopyWstringToUtf16(std::wstring textStr, gr::utf16 * utf16Buf, int bufSize) +{ + std::fill_n(utf16Buf, bufSize, 0); + int cc = textStr.length(); + for (int i = 0; i < cc; i++) + utf16Buf[i] = textStr[i]; +} + +/*---------------------------------------------------------------------------------------------- + Output information about an error. +----------------------------------------------------------------------------------------------*/ +void OutputError(TestCase * ptcase, std::string strErr, int i) +{ + OutputErrorAux(ptcase, strErr, i, false, 0, 0); +} + +void OutputErrorWithValues(TestCase * ptcase, std::string strErr, int i, + int valueFound, int valueExpected) +{ + OutputErrorAux(ptcase, strErr, i, true, valueFound, valueExpected); +} + +void OutputErrorAux(TestCase * ptcase, std::string strErr, int i, + bool showValues, int valueFound, int valueExpected) +{ +// if (g_debugMode) +// ::DebugBreak(); + + if (!g_silentMode) + { + //std::cout << ptcase->TestName() << ": "; + std::cout << strErr; + if (i > -1) + { + std::cout << "[" << i << "]"; + } + std::cout << "\n "; + } + + WriteToLog(strErr, i, showValues, valueFound, valueExpected); + + WriteToLog("\n"); +} + +/*---------------------------------------------------------------------------------------------- + Write some text to the log file. +----------------------------------------------------------------------------------------------*/ +bool WriteToLog(std::string str, int i) +{ + if (g_strmLog.fail()) + { + std::cout << "Error opening log file."; + return false; + } + g_strmLog << str; + if (i > -1) + g_strmLog << "[" << i << "]"; + g_strmLog.flush(); + return true; +} + +bool WriteToLog(std::string str, int i, + bool showValues, int valueFound, int valueExpected) +{ + if (g_strmLog.fail()) + { + std::cout << "Error opening log file."; + return false; + } + g_strmLog << str; + if (i > -1) + g_strmLog << "[" << i << "]"; + if (showValues) + { + g_strmLog << "; found " << valueFound << " not " << valueExpected; + } + g_strmLog.flush(); + return true; +} + + +bool WriteToLog(int n) +{ + if (g_strmLog.fail()) + { + std::cout << "Error opening log file."; + return false; + } + g_strmLog << n; + g_strmLog.flush(); + return true; +} + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.cpp b/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.cpp index 080d2f92dcd..5964b042a3c 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.cpp +++ b/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.cpp @@ -1,1823 +1,1971 @@ -/*--------------------------------------------------------------------*//*:Ignore this sentence.
-Copyright (C) 2004 SIL International. All rights reserved.
-
-Distributable under the terms of either the Common Public License or the
-GNU Lesser General Public License, as specified in the LICENSING.txt file.
-
-File: TestCase.cpp
-Responsibility: Sharon Correll
-Last reviewed: Not yet.
-
-Description:
- File to set up test cases for the Graphite regression test program.
-
-How to add a test:
- 1. Add the name of your test method to the class declaration in TestCase.h.
- 2. Increment the g_numberOfTests constant in this file.
- 3. Add a call to your test method in the SetupTests method in this file.
- 4. Copy one of the existing test methods such as SetupSimpleTest and change the name
- and data.
-
-Things that still need testing:
- Ligatures (there is one small test of this)
- Justification
- Fake italic
--------------------------------------------------------------------------------*//*:End Ignore*/
-
-#include "main.h"
-
-//:>********************************************************************************************
-//:> Test constants and methods
-//:>********************************************************************************************
-
-const int g_numberOfTests = 23; // *** increment as tests are added ***
-
-TestCase * g_ptcaseList; // list of test cases
-
-namespace gr { // and it was SC who got rid of the byte defn in GrPlatform.h!
-typedef unsigned char byte;
-}
-
-
-/*----------------------------------------------------------------------------------------------
- Create the list of tests.
-----------------------------------------------------------------------------------------------*/
-int TestCase::SetupTests(TestCase ** pptcaseList)
-{
- g_ptcaseList = new TestCase[g_numberOfTests];
- int cptcase = 0;
-
- // The number of methods called here should equal g_numberOfTests above.
- g_ptcaseList[0].SetupSimpleTest(); cptcase++;
- g_ptcaseList[1].SetupSimpleBacktrackTest(); cptcase++;
- g_ptcaseList[2].SetupBurmese1(); cptcase++;
- g_ptcaseList[3].SetupBurmese2(); cptcase++;
- g_ptcaseList[4].SetupBurmese3(); cptcase++;
- g_ptcaseList[5].SetupBurmese4(); cptcase++;
- g_ptcaseList[6].SetupRoman(); cptcase++;
- g_ptcaseList[7].SetupRomanFeatures(); cptcase++;
- g_ptcaseList[8].SetupStackingAndBridging(); cptcase++;
- g_ptcaseList[9].SetupNoWhiteSpace(); cptcase++;
- g_ptcaseList[10].SetupNoWhiteSpaceNoSeg(); cptcase++;
- g_ptcaseList[11].SetupOnlyWhiteSpace(); cptcase++;
- g_ptcaseList[12].SetupCrossLine1(); cptcase++;
- g_ptcaseList[13].SetupCrossLine2(); cptcase++;
- g_ptcaseList[14].SetupCrossLine3(); cptcase++;
- g_ptcaseList[15].SetupCrossLine4(); cptcase++;
- g_ptcaseList[16].SetupArabic1(); cptcase++;
- g_ptcaseList[17].SetupArabic2(); cptcase++;
- g_ptcaseList[18].SetupTaiViet1(); cptcase++;
- g_ptcaseList[19].SetupTaiViet2(); cptcase++;
- g_ptcaseList[20].SetupDumbFallback1(); cptcase++;
- g_ptcaseList[21].SetupDumbFallback2(); cptcase++;
- g_ptcaseList[22].SetupBadFont(); cptcase++;
- // *** Add more method calls here. ***
-
- assert(cptcase == g_numberOfTests);
-
- *pptcaseList = g_ptcaseList;
-
- return g_numberOfTests;
-}
-
-/*----------------------------------------------------------------------------------------------
- Set up a simple test.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupSimpleTest()
-{
- m_testName = "Simple";
- //m_debug = true;
- //m_traceLog = false;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = L"This is a test."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 86; // physical width of segment
-
- const int charCnt = 15; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true
- };
-
- const int glyphCnt = 15; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {55, 75, 76, 86, 3, 76, 86, 3, 68, 3, 87, 72, 86, 87, 17};
- int xPositions[] = { 0, 9, 17, 22, 28, 33, 37, 43, 48, 55, 60, 64, 71, 77, 82};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 9, 8, 4, 6, 4, 4, 6, 4, 7, 4, 4, 7, 6, 4, 4};
-
- int bbLefts[] = { 0, 9, 18, 22, 28, 33, 38, 43, 48, 55, 60, 65, 72, 78, 83};
- int bbRights[] = { 9, 17, 21, 27, 33, 37, 43, 48, 55, 60, 64, 71, 77, 82, 85};
- int bbTops[] = {10, 11, 10, 7, 0, 10, 7, 0, 7, 0, 9, 7, 7, 9, 1};
- int bbBottoms[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
- int charsToGlyphs[] = {
- 1, 1, 1, 2, 1, 2, 3, 1, 3, 4, 1, 4, 5, 1, 5, 6, 1, 6, 7, 1, 7
- };
- int c2gCount = 21;
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 3;
- int clickStuff[] = {
- 11, 25, 1, false, 0, 24, 8, kAbsent, kAbsent, kAbsent, // below baseline
- 42, 5, 7, true, 0, 24, 42, kAbsent, kAbsent, kAbsent, // near top of text
- 90, 16, 15, true, 0, 24, 85, kAbsent, kAbsent, kAbsent // near baseline
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(bbLefts, bbRights, bbTops, bbBottoms);
- SetInsPtFlags(insPtFlags);
- SetCharsToGlyphs(charsToGlyphs, c2gCount);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-/*----------------------------------------------------------------------------------------------
- Set up a simple test with backtracking.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupSimpleBacktrackTest()
-{
- m_testName = "Simple Backtrack";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = L"This is a test."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = true;
-
- // Output:
- m_segWidth = 55; // physical width of segment
-
- const int charCnt = 10; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true
- };
-
- const int glyphCnt = 10; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {55, 75, 76, 86, 3, 76, 86, 3, 68, 3};
- int xPositions[] = { 0, 9, 17, 22, 28, 33, 37, 43, 48, 55};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 9, 8, 4, 6, 4, 4, 6, 4, 7, 4};
-
- const int contextBlockOutSize = 10;
- gr::byte contextBlockOut[] = { 15, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests using Burmese, to test complex positioning and non-white-space
- linebreaking.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupBurmese1()
-{
- m_testName = "Burmese 1";
- m_debug = false;
- //m_traceLog = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Burmese";
- m_fontFile = "grtest_burmese.ttf";
- m_text = BurmeseText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 300; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 281; // physical width of segment
-
- SetupBurmeseAux(
- 64, // character count
- 45, // glyph count
- 5); // number of click-tests
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,0, 1,1,0, 2,2,2,3,4, 3,2,0, 4,2,0, 5,5,1,6, 6,5,0, 7,7,3,8,9,10,
- 8,7,0, 9,7,0, 10,7,0, 11,11,0, 12,12,0, 13,13,0, 14,14,0, 15,15,0,
- 16,16,1,17, 17,16,0, 18,18,1,19, 19,18,0, 20,20,1,21, 21,20,0, 22,22,1,23,
- 23,22,0, 24,24,0, 25,25,0
- };
- int attCount = sizeof(attachments) / sizeof(int);
- SetAttachedClusters(attachments, attCount);
-
- const int contextBlockOutSize = 11;
- gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupBurmese2()
-{
- m_testName = "Burmese 2";
- //m_debug = true;
- //m_traceLog = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Burmese";
- m_fontFile = "grtest_burmese.ttf";
-
- m_text = BurmeseText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 275; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 215; // physical width of segment
-
- SetupBurmeseAux(
- 47, // character count
- 33, // glyph count
- 3); // number of click-tests
-
- const int contextBlockOutSize = 11;
- gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupBurmese3()
-{
- m_testName = "Burmese 3";
- //m_debug = true;
- //m_traceLog = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Burmese";
- m_fontFile = "grtest_burmese.ttf";
-
- m_text = BurmeseText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 75; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 73; // physical width of segment
-
- SetupBurmeseAux(
- 19, // character count
- 13, // glyph count
- 2); // number of click-tests
-
- const int contextBlockOutSize = 11;
- gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupBurmese4()
-{
- m_testName = "Burmese 4";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Burmese";
- m_fontFile = "grtest_burmese.ttf";
-
- m_text = BurmeseText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWsBreak; // preferred break-weight
- m_worstBreak = klbHyphenBreak; // worst-case break-weight
- m_availWidth = 30; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_noSegment = true;
- m_segWidth = 0; // physical width of segment
-
- SetupBurmeseAux(
- 0, // character count
- 0, // glyph count
- 0); // number of click-tests
-}
-
-void TestCase::SetupBurmeseAux(int charCnt, int glyphCnt, int clickTestCnt)
-{
- m_rtl = false;
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, false, false, false, true, false, false, false, false, // 0 - 9
- true, false, false, true, false, false, false, true, true, true, // 10 - 19
- true, false, true, true, false, false, true, false, false, false, // 20 - 29
- false, true, false, false, true, false, false, false, true, true, // 30 - 39
- true, true, true, true, true, true, true, true, true, false, // 40 - 49
- true, true, true, false, false, false, true, false, false, true, // 50 - 59
- false, false, false, true
- };
-
- // need glyphCnt elements in these arrays:
- // 0 10 20 30 40
- gid16 glyphList[] = {105,174,158,202,231,162,231,148,223,219,229,248, 3,226,162,173,216,231,177,195,115,231,170,204,243, 3,197,216,172,216, 3,233, 3,226,179,162,216,170,204,158,202,115,231,229, 3};
- int xPositions[] = { 0, 17, 20, 22, 28, 29, 38, 40, 50, 55, 56, 57, 73, 79, 89, 99,102,109,110,111,120,129,130,131,140,143,149,167,174,191,198,205,215,222,232,234,245,252,253,262,264,271,280,278,281};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 17, 2, 9, 4, 0, 10, 0, 17, 2, 0, 0, 15, 6, 10, 10, 2, 7, 0, 10, 9, 9, 0, 10, 7, 2, 6, 17, 7, 17, 7, 6, 10, 6, 10, 2, 10, 7, 10, 7, 9, 4, 9, 0, 0, 6};
-
- int bbLefts[] = { 0, 10, 21, 23, 23, 30, 33, 41, 51, 49, 53, 58, 73, 80, 90, 96,100,103,111,109,121,123,131,132,141,143,150,165,175,189,198,206,215,223,233,235,243,253,254,263,265,272,275,275,281};
- int bbRights[] = { 16, 19, 28, 25, 28, 39, 38, 56, 54, 55, 56, 72, 79, 88, 98,101,109,109,119,119,129,129,139,138,142,149,166,173,190,197,205,214,222,231,244,244,251,261,260,271,267,280,280,278,288};
- int bbTops[] = { 7, 7, 7, -1, 15, 7, 15, 7, -1, 15, -2, 15, 0, 7, 7, 7, 7, 15, 7, -1, 7, 15, 7, -1, 7, 0, 7, 7, 7, 7, 0, 7, 0, 7, 16, 7, 7, 7, -1, 7, -1, 7, 15, -2, 0};
- int bbBottoms[] = { 0, -7, -1, -7, 9, 0, 9, 0, -7, 9, -5, 0, 0, 0, 0, -7, 0, 9, -4, -7, 0, 9, 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, 0, 0, 0, -7, -1, -7, 0, 9, -5, 0};
-
- // Each group = char-index, number of glyphs, glyph-indices.
- int charsToGlyphs[] = {
- 0, 1, 0, 1, 1, 1, 2, 1, 1, 3, 1, 1, 4, 1, 1, 5, 1, 2, 6, 1, 3, 7, 1, 3,
- 8, 1, 4, 9, 1, 4, 10, 1, 5, 11, 1, 6, 12, 1, 6, 13, 1, 7
- };
- int c2gCount = sizeof(charsToGlyphs) / sizeof(int);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- int clickStuff[] = {
- 10, 25, 1, true, 0, 25, 16, kAbsent, kAbsent, kAbsent,
- 40, 5, 13, false, 0, 25, 39, kAbsent, kAbsent, kAbsent,
- 93, 40, 19, false, 0, 25, 88, 0, 25, 77,
- 251, 5, 52, true, 0, 25,251, kAbsent, kAbsent, kAbsent,
- 235, 30, 48, false, -1, 27,230, 7, 19,243,
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetCharsToGlyphs(charsToGlyphs, c2gCount);
- SetBBs(bbLefts, bbRights, bbTops, bbBottoms);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-std::wstring TestCase::BurmeseText()
-{
- std::wstring strRet;
- wchar_t charData[] = {
- 0x1000, 0x1039, 0x101a, 0x1039, 0x101d, 0x1014, 0x1039, 0x101f, 0x1039, 0x200c,
- 0x1015, 0x1039, 0x200c, 0x1010, 0x102f, 0x102d, 0x1037, 0x104f, 0x0020, 0x1015,
- 0x1039, 0x101a, 0x1031, 0x102c, 0x1039, 0x200c, 0x101b, 0x1039, 0x101d, 0x1039,
- 0x101f, 0x1004, 0x1039, 0x200c, 0x1019, 0x1039, 0x101f, 0x102f, 0x104a, 0x0020,
- 0x101e, 0x102c, 0x101a, 0x102c, 0x0020, 0x1040, 0x0020, 0x1015, 0x1039, 0x101b,
- 0x1031, 0x102c, 0x1019, 0x1039, 0x101f, 0x102f, 0x1014, 0x1039, 0x101f, 0x1004,
- 0x1039, 0x200c, 0x1037, 0x0020, 0x1021, 0x1031, 0x102c, 0x1004, 0x1039, 0x200c,
- 0x1019, 0x1039, 0x101b, 0x1004, 0x1039, 0x200c, 0x1019, 0x1039, 0x101f, 0x102f,
- 0x1010, 0x102f, 0x102d, 0x1037, 0x101e, 0x100a, 0x1039, 0x200c, 0x0020, 0x1000,
- 0x1039, 0x101a, 0x1039, 0x101d, 0x1014, 0x102f, 0x1039, 0x200c, 0x1015, 0x1039,
- 0x200c, 0x1010, 0x102f, 0x102d, 0x1037, 0x104f, 0x0000
- };
- strRet.assign(charData);
- return strRet;
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests using Roman script, which tests stacking diacritics, many-to-one glyphs,
- and features.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupRoman()
-{
- m_testName = "Roman";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = RomanText(); // text to render
- m_fontSize = 36; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 278; // physical width of segment
-
- const int charCnt = 26; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true
- };
-
- const int glyphCnt = 24; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- // 0 10 20
- gid16 glyphList[] = {72,1815,1768, 83,1789, 86, 74,1943,1956,1926,1061, 68,1777,1755,805,1815, 44,1815, 80,1833,1768,1855,1838,637};
- int xPositions[] = { 0, 23, 23, 21, 41, 45, 64, 88, 98, 112, 116,148, 171, 171,170, 188,183, 203, 199, 230, 230, 230, 230,236};
- int yPositions[] = { 0, 0, 10, 0, -6, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0};
- int advWidths[] = {21, 0, 0, 24, 0, 18, 24, 13, 13, 4, 31, 21, 0, 0, 13, 0, 15, 0, 37, 0, 0, 0, 0, 41};
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,2,1,2, 1,0,0, 2,0,0, 3,3,0, 4,4,0, 5,5,0, 6,6,0, 7,7,2,8,9,
- 8,7,0, 9,7,0, 10,10,0, 11,11,2,12,13, 12,11,0, 13,11,0, 14,14,1,15, 15,14,0,
- 16,16,1,17, 17,16,0, 18,18,4,19,20,21,22, 19,18,0, 20,18,0, 21,18,0, 22,18,0,
- 23,23,0
- };
- int attCount = sizeof(attachments) / sizeof(int);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 5;
- int clickStuff[] = {
- 10, 15, 2, false, 9, 21, 1, 20, 30, 18,
- 61, 50, 6, true, 0, 72, 63, kAbsent, kAbsent, kAbsent,
- 90, 40, 7, false, 0, 72, 87, kAbsent, kAbsent, kAbsent,
- 260, 40, 25, true, 0, 73,263, kAbsent, kAbsent, kAbsent, // ligature
- 267, 40, 25, false, 0, 73,263, kAbsent, kAbsent, kAbsent, // ligature
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetAttachedClusters(attachments, attCount);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-void TestCase::SetupRomanFeatures()
-{
- m_testName = "Roman Features";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = RomanText(); // text to render
- m_fontSize = 36; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
-
- m_fset[0].id = 1024; m_fset[0].value = 2; // capital eng with tail
- m_fset[1].id = 1026; m_fset[1].value = 1; // tone numbers
- m_fset[2].id = 1029; m_fset[2].value = 1; // vietnamese diacritics
- m_fset[3].id = 1032; m_fset[3].value = 1; // literacy alternates
- m_fset[4].id = 1034; m_fset[4].value = 1; // y-hook alternate (default)
- m_fset[5].id = 1051; m_fset[5].value = 0; // diacritic selection
- m_fset[6].id = 0;
-
- // Output:
- m_segWidth = 307; // physical width of segment
-
- const int charCnt = 26; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, false, false, true, true, true, true, true, true, true,
- true, true, false, false, true, false, true, false, true, false,
- false, false, false, true, true, true
- };
-
- const int glyphCnt = 23; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- // 0 10 20
- gid16 glyphList[] = {72,1815,1768, 83,1789, 86,681,1659,1667,1662,1056,274,1778, 805,1815, 44,1815, 80,1833,1768,1855,1838,637};
- int xPositions[] = { 0, 23, 23, 21, 41, 45, 64, 87, 104, 121, 138,173, 174, 198, 217, 211, 231, 227, 258, 258, 258, 258,265};
- int yPositions[] = { 0, 0, 10, 0, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0};
- int advWidths[] = {21, 0, 0, 24, 0, 18, 23, 17, 17, 17, 34, 24, 24, 13, 0, 15, 0, 37, 0, 0, 0, 0, 41};
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 3;
- int clickStuff[] = {
- 10, 15, 3, true, 0, 72, 20, kAbsent, kAbsent, kAbsent,
- 116, 5, 9, true, 0, 72, 120, kAbsent, kAbsent, kAbsent,
- 90, 40, 7, false, 0, 72, 86, kAbsent, kAbsent, kAbsent
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-std::wstring TestCase::RomanText()
-{
- std::wstring strRet;
- wchar_t charData[] = {
- 0x0065, 0x0303, 0x0300, 0x0070, 0x0361, 0x0073, 0x0067, 0x02e8, 0x02e5, 0x02e7,
- 0x014a, 0x0061, 0x0302, 0x0301, 0x0069, 0x0303, 0x0049, 0x0303, 0x006d, 0x033c,
- 0x0300, 0x0308, 0x0304, 0x0066, 0x0066, 0x0069, 0x0000
- };
- strRet.assign(charData);
- return strRet;
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests for handling complex diacritic stacking and bridging.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupStackingAndBridging()
-{
- m_testName = "Roman Stacking and Bridging";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_fontSize = 36; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
-
- // text to render
- wchar_t charData[] = {
- 0x0061,0x035d,0x0061,0x0020,0x0074,0x035d,0x0061,0x0020,0x0061,0x0300,
- 0x0300,0x035d,0x0061,0x0020,0x0283,0x0300,0x0300,0x035d,0x0061,0x0020,
- 0x0061,0x0316,0x0316,0xf176,0x0061,0x0020,0x0283,0x0300,0x0300,0xf176,
- 0x0061,0x0020,0x0061,0x0316,0x0316,0xf176,0x0061,0x0020,0x0283,0x035d,
- 0xf176,0x0061,0x0000
- };
- m_text.assign(charData);
-
- // Output:
- m_segWidth = 414; // physical width of segment
-
- const int charCnt = 42; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true,
- };
-
- const int glyphCnt = 42; // number of glyphs in the segment
-
- // 68 = a, 97 = t, 1305 = esh, 1768 = upper grave, 1765 = lower grave, 1802 = upper bridge,
- // 1801 = lower bridge
-
- // need glyphCnt elements in these arrays:
- // 0 10 20 30 40
- gid16 glyphList[] = {68,1802, 68, 3, 87,1802, 68, 3, 68,1768,1768,1802, 68, 3,1305,1768,1768,1802, 68, 3, 68,1765,1765,1801, 68, 3,1305,1768,1768,1801, 68, 3, 68,1765,1765,1801, 68, 3,1305,1802,1801, 68};
- int xPositions[] = { 0, 21, 21, 42, 56, 73, 69, 91, 105, 127, 127, 126, 126,147, 161, 181, 181, 178,177,199,212, 235, 235, 234,234,255, 269, 289, 289, 286,285,307,320, 343, 343, 342,342,363, 377, 393, 393,393};
- int yPositions[] = { 0, -7, 0, 0, 0, -1, 0, 0, 0, 0, 10, 12, 0, 0, 0, 10, 20, 23, 0, 0, 0, 0, -9, -17, 0, 0, 0, 10, 20, -6, 0, 0, 0, 0, -9, -17, 0, 0, 0, 3, -6, 0};
- int advWidths[] = {21, 0, 21, 13, 13, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 21};
-
- int bbLefts[] = { 1, 0, 23, 42, 56, 52, 71, 91, 106, 108, 108, 105, 128,147, 159, 162, 162, 157,179,199,214, 217, 217, 213,235,255, 267, 270, 270, 265,287,307,322, 325, 325, 321,343,363, 375, 373, 373,395};
- int bbRights[] = {21, 41, 42, 56, 69, 93, 91,105, 126, 119, 119, 146, 147,161, 178, 173, 173, 198,199,212,234, 228, 228, 254,255,269, 286, 281, 281, 306,306,320,342, 336, 336, 362,363,377, 394, 413, 414,414};
- int bbTops [] = {22, 33, 22, 0, 28, 40, 22, 0, 22, 32, 42, 54, 22, 0, 33, 42, 53, 64, 22, 0, 22, -3, -13, -26, 22, 0, 33, 42, 53, -15, 22, 0, 22, -3, -13, -26, 22, 0, 33, 44, -15, 22};
- int bbBottoms [] = { 0, 26, 0, 0, 0, 33, 0, 0, 0, 24, 34, 47, 0, 0, -10, 34, 44, 57, 0, 0, 0, -11, -21, -32, 0, 0, -10, 34, 44, -21, 0, 0, 0, -11, -21, -32, 0, 0, -10, 38, -21, 0};
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,0, 1,1,0, 2,2,0, 3,3,0, 4,4,0, 5,5,0, 6,6,0, 7,7,0,
- 8,8,2,9,10, 9,8,0, 10,8,0, 11,11,0, 12,12,0, 13,13,0, 14,14,2,15,16,
- 15,14,0, 16,14,0, 17,17,0, 18,18,0, 19,19,0, 20,20,2,21,22, 21,20,0,
- 22,20,0, 23,23,0, 24,24,0, 25,25,0, 26,26,2,27,28, 27,26,0, 28,26,0,
- 29,29,0, 30,30,0, 31,31,0, 32,32,2,33,34, 33,32,0, 34,32,0, 35,35,0,
- 36,36,0, 37,37,0, 38,38,0, 39,39,0, 40,40,0, 41,41,0
- };
- int attCount = sizeof(attachments) / sizeof(int);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 6;
- int clickStuff[] = {
- 109, 25, 9, false, 19, 32, 105, 30, 56, 125, // first grave on 4th a
- 178, 26, 15, true, 19, 66, 176, 9, 21, 159, // top of 1st esh, right side
- 220, 84, 23, false, 78, 89, 210, 65, 77, 228, // first lower bridge diac
- 271, 40, 26, false, 0, 72, 266, kAbsent, kAbsent, kAbsent, // second esh, left side
- 271, 65, 26, false, 0, 72, 266, kAbsent, kAbsent, kAbsent, // just below second esh, left side
- 271, 68, 29, false, 67, 78, 262, 0, 11, 280 // lower bridge diac under esh, left side
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(bbLefts, bbRights, bbTops, bbBottoms);
- SetInsPtFlags(insPtFlags);
- SetAttachedClusters(attachments, attCount);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests for handling trailing whitespace.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupNoWhiteSpace()
-{
- m_testName = "No white space";
- //m_debug = true;
- //m_traceLog = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = L"The quick brown fox."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 150; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_twsh = ktwshNoWs;
- m_paraRtl = true;
-
- // Output:
- m_segWidth = 115; // physical width of segment
-
- const int charCnt = 16; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true
- };
-
- const int glyphCnt = 16; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {55, 75, 72, 3, 3, 84, 88, 76, 70, 78, 3, 69, 85, 82, 90, 81};
- int xPositions[] = { 0, 9, 17, 24, 29, 34, 42, 50, 54, 61, 69, 74, 82, 87, 95,107};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 9, 8, 7, 4, 4, 8, 8, 4, 7, 8, 4, 8, 5, 8, 11, 8};
-
- const int contextBlockOutSize = 10;
- gr::byte contextBlockOut[] = { 15, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(0, NULL);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupNoWhiteSpaceNoSeg()
-{
- m_testName = "No white space - no segment";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = L"The quick brown fox."; // text to render
- m_firstChar = 15; // spaces after brown
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 2; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_twsh = ktwshNoWs;
- m_paraRtl = true;
-
- // Output:
- m_noSegment = true;
- m_segWidth = 0; // physical width of segment
-
- const int charCnt = 0; // number of characters in the segment
-
- const int glyphCnt = 0; // number of glyphs in the segment
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
-}
-
-void TestCase::SetupOnlyWhiteSpace()
-{
- m_testName = "Only white space";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_roman.ttf";
- m_text = L" fox."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 2; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_twsh = ktwshOnlyWs;
- m_paraRtl = true;
-
- // Output:
- m_segWidth = 0; // physical width of segment - visible
-
- const int charCnt = 3; // number of characters in the segment
- // need charCnt elements in this array:
- bool insPtFlags[] = { true, true, true };
-
- const int glyphCnt = 3; // number of glyphs in the segment
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = { 3, 3, 3 };
- int xPositions[] = { -4, -9,-13 };
- int yPositions[] = { 0, 0, 0 };
- int advWidths[] = { 4, 4, 4 };
-
- // TODO: add click tests when the bug fix with upstream tr white space is integrated.
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 6;
- int clickStuff[] = {
- 2, 25, 0, false, 0, 24, -1, kAbsent, kAbsent, kAbsent,
- -1, 5, 0, false, 0, 24, -1, kAbsent, kAbsent, kAbsent,
- -6, -3, 1, false, 0, 24, -5, kAbsent, kAbsent, kAbsent,
- -8, -3, 2, true, 0, 24, -10, kAbsent, kAbsent, kAbsent,
- -13, 40, 3, true, 0, 24, -14, kAbsent, kAbsent, kAbsent,
- -18, 0, 3, true, 0, 24, -14, kAbsent, kAbsent, kAbsent
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests of cross-line contextualization.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupCrossLine1()
-{
- m_testName = "Cross-line 1";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test CrossLine";
- m_fontFile = "grtest_xline.ttf";
- m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww";
- m_fontSize = 30; // font size in points
- m_prefBreak = klbHyphenBreak; // preferred break-weight
- m_availWidth = 350; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 312; // physical width of segment
-
- const int charCnt = 10; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true
- };
-
- const int glyphCnt = 13; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {30, 67, 68, 69, 70, 70, 70, 70, 71, 72, 34, 90, 32 };
- int xPositions[] = { 0, 40, 58, 79, 97,118,139,160,180,199,213,251,272 };
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int advWidths[] = {40, 18, 20, 18, 20, 20, 20, 20, 18, 13, 38, 20, 40 };
-
- // TODO: add click tests
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 0;
- int * clickStuff = NULL;
- //int clickStuff[] = ;
- //{
- // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent,
- //};
-
- const int contextBlockOutSize = 9;
- gr::byte contextBlockOut[] = { 20, 1, 0, 2, 0, 0, 4, 0, 0, 0 };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupCrossLine2()
-{
- m_testName = "Cross-line 2";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test CrossLine";
- m_fontFile = "grtest_xline.ttf";
- m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww";
- m_firstChar = 10;
- m_fontSize = 30; // font size in points
- m_prefBreak = klbHyphenBreak; // preferred break-weight
- m_availWidth = 400; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_initWithPrev = true;
-
- const int contextBlockInSize = 9; // output from Cross-line 1
- gr::byte contextBlockIn[] = { 20, 1, 0, 2, 0, 0, 4, 0, 0, 0 };
-
- // Output:
- m_segWidth = 395; // physical width of segment
-
- const int charCnt = 13; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- false, true, true, true, true, true, true, true, true, true, true, true, true
- };
-
- const int glyphCnt = 15; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {30, 34, 73, 74, 75, 76, 77, 79, 79, 79, 79, 80, 6, 91, 32 };
- int xPositions[] = { 0, 40, 78, 99,119,131,143,163,196,228,260,293,314,334,355 };
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int advWidths[] = {40, 38, 20, 20, 11, 11, 20, 32, 32, 32, 32, 20, 20, 20, 40 };
-
- // TODO: add click tests
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 0;
- int * clickStuff = NULL;
- //int clickStuff[] = ;
- //{
- // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent,
- //};
-
- const int contextBlockOutSize = 9;
- gr::byte contextBlockOut[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
- SetInputContextBlock(contextBlockInSize, contextBlockIn);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupCrossLine3()
-{
- m_testName = "Cross-line 3";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test CrossLine";
- m_fontFile = "grtest_xline.ttf";
- m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww";
- m_firstChar = 23;
- m_fontSize = 30; // font size in points
- m_prefBreak = klbHyphenBreak; // preferred break-weight
- m_availWidth = 400; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_initWithPrev = true;
-
- const int contextBlockInSize = 9; // output from Cross-line 2
- gr::byte contextBlockIn[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 };
-
- // Output:
- m_segWidth = 358; // physical width of segment
-
- const int charCnt = 13; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true, true, false, true
- };
-
- const int glyphCnt = 16; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = {30, 81, 6, 82, 82, 82, 82, 82, 83, 84, 85, 85, 85, 34, 8, 92 };
- int xPositions[] = { 0, 40, 60, 81,102,123,144,164,185,206,220,236,253,269,307,339 };
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int advWidths[] = {40, 20, 20, 20, 20, 20, 20, 20, 20, 14, 16, 16, 16, 38, 32, 18 };
-
- // TODO: add click tests
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 0;
- int * clickStuff = NULL;
- //int clickStuff[] = ;
- //{
- // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent,
- //};
-
- const int contextBlockOutSize = 9;
- gr::byte contextBlockOut[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
- SetInputContextBlock(contextBlockInSize, contextBlockIn);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-void TestCase::SetupCrossLine4()
-{
- m_testName = "Cross-line 4";
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test CrossLine";
- m_fontFile = "grtest_xline.ttf";
- m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww";
- m_firstChar = 36;
- m_fontSize = 30; // font size in points
- m_prefBreak = klbHyphenBreak; // preferred break-weight
- m_availWidth = 400; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_initWithPrev = true;
-
- const int contextBlockInSize = 9; // output from Cross-line 3
- gr::byte contextBlockIn[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 };
-
- // Output:
- m_segWidth = 248; // physical width of segment
-
- const int charCnt = 8; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- false, true, true, true, true, true, true, true
- };
-
- const int glyphCnt = 10; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- gid16 glyphList[] = { 8, 6, 86, 86, 86, 89, 89, 89, 89, 32 };
- int xPositions[] = { 0, 32, 53, 64, 76, 87,117,147,177,208 };
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int advWidths[] = {32, 20, 11, 11, 11, 30, 30, 30, 30, 40 };
-
- // TODO: add click tests
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 0;
- int * clickStuff = NULL;
- //int clickStuff[] = ;
- //{
- // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent,
- //};
-
- const int contextBlockOutSize = 0;
- gr::byte * contextBlockOut = NULL;
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
- SetInputContextBlock(contextBlockInSize, contextBlockIn);
- SetOutputContextBlock(contextBlockOutSize, contextBlockOut);
-}
-
-std::wstring TestCase::CrossLineText()
-{
- // The equivalent data is in the "xlineTest.wpx" file.
- std::wstring strRet;
- strRet.assign(L"abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww");
- return strRet;
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests using Arabic: RTL, bidi, and embedded direction codes.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupArabic1()
-{
- m_testName = "Arabic 1";
- //m_debug = true;
- m_traceLog = false;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Arabic";
- m_fontFile = "grtest_arabic.ttf";
- m_text = ArabicText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 1000; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 409; // physical width of segment
-
- SetupArabicAux(
- 61, // character count
- 61); // glyph count
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,0, 1,1,1,2, 2,1,0, 3,3,4,4,5,6,7, 4,3,0, 5,3,0, 6,3,0, 7,3,0,
- 8,8,0, 9,9,4,10,11,12,13, 10,9,0, 11,9,0, 12,9,0, 13,9,0, 14,14,0,
- 15,15,0, 16,16,1,17, 17,16,0, 18,18,1,19, 19,18,0 // etc
- };
- int attCount = sizeof(attachments) / sizeof(int);
- SetAttachedClusters(attachments, attCount);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- int clickStuff[] = {
- 199, 13, 37, true, 0, 35,196, kAbsent, kAbsent, kAbsent,
- 396, 13, 3, false, 8, 26,399, 10, 17, 397,
- 396, 8, 6, true, 3, 11,391, 9, 22, 394,
- 222, 5, 32, true, 0, 35,225, kAbsent, kAbsent, kAbsent,
- 217, 5, 31, false, 0, 35,215, 0, 35, 246,
- };
- SetClickTests(4, clickStuff);
-}
-
-void TestCase::SetupArabic2()
-{
- m_testName = "Arabic 2";
- m_debug = false;
- m_traceLog = false;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test Arabic";
- m_fontFile = "grtest_arabic.ttf";
- m_text = ArabicText();
- m_fontSize = 20; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 230; // width available for segment-break after number
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
-
- // Output:
- m_segWidth = 193; // physical width of segment
-
- SetupArabicAux(
- 35, // character count
- 35); // glyph count
-
- // The x-positions are different for a shorter segment:
- // 0 10 20 30
- int xPositions[] = {188,183,184,177,178,178,170,169,162,150,154,154,153,155,139,132,127,127,115,118,108,102, 84, 77, 77, 72, 65, 46, 46, 37, 31, 20, 10, 0, -6};
- SetXPositions(xPositions);
-}
-
-void TestCase::SetupArabicAux(int charCnt, int glyphCnt)
-{
- m_rtl = true;
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true, // 0 - 9
- true, true, true, true, true, true, true, true, true, true, // 10 - 19
- true, true, true, true, true, true, true, true, true, true, // 20 - 29
- true, true, true, true, true, true, true, true, true, true, // 30 - 39
- true, true, true, true, true, true, true, true, true, true, // 40 - 49
- true, true, true, true, true, true, true, true, true, true, // 50 - 59
- true
- };
-
- // need glyphCnt elements in these arrays:
- // 0 10 20 30 40 50 60
- gid16 glyphList[] = {785,658,907,1182,913,907,1192,907, 3,811,914,909,911,934,592, 3,785,909,621,911, 12, 3,321, 3,236,659,731,555,925,961, 3,992,991,990, 3,821,924,712,474,882,527, 3,411,924,950, 3,236,990,991,992,993,995,236, 3,821,769,455,290,839,620,961};
- int xPositions[] = {404,400,401, 393,394,394, 386,385,379,366,370,370,370,371,355,348,343,343,331,334,324,318,300,293,293,289,281,263,262,254,247,237,226,216,209,197,197,189,179,172,154,147,135,139,127,120,120,110, 99, 89, 79, 68, 68, 62, 50, 41, 36, 29, 19, 8, 0};
- int yPositions[] = { 0, 0, -5, 0, 0, 4, 0, 0, 0, 0, -5, -3, -2, 4, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 4, 4, 0, 6, 0, 0, 6, 0, 6, 12, 0, 0, 0, 0, 11, 6, 4, 0, 11, 0, 7, 6, 17, 6, 0, 4, 7, 18, 0, 8, 6, 10, 10, 10, 6, 11, 0, 7, 9, 7, 17, 6, 11, 0, 8, 6, 0, 10, 10, 10, 10, 10, 0, 6, 11, 9, 4, 6, 9, 11, 8};
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
-}
-
-std::wstring TestCase::ArabicText()
-{
- std::wstring strRet;
- wchar_t charData[] = {
- 0x0628, 0x0628, 0x064e, 0x0644, 0x064e, 0x0654, 0x0627, 0x064e, 0x0020, 0x0686,
- 0x0650, 0x0652, 0x0655, 0x06e0, 0x06a8, 0x0020, 0x0628, 0x0650, 0x06b9, 0x0652,
- 0x0029, 0x0020, 0x0628, 0x0020, 0x200d, 0x062a, 0x06a8, 0x0633, 0x0670, 0x061b,
- 0x0020, 0x06f1, 0x06f2, 0x06f3, 0x0020, 0x0633, 0x0670, 0x0639, 0x062f, 0x0645,
- 0x067e, 0x0020, 0x0644, 0x0670, 0x060c, 0x0020, 0x202e, 0x06f1, 0x06f2, 0x06f3,
- 0x06f4, 0x06f5, 0x202c, 0x0020, 0x0633, 0x0647, 0x0627, 0x0631, 0x0639, 0x0646,
- 0x061b, 0x0000
- };
- strRet.assign(charData);
- return strRet;
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests that uses Tai Viet script to test positioning.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupTaiViet1()
-{
- m_testName = "Tai Viet Collisions";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test TaiViet";
- m_fontFile = "grtest_taiviet.ttf";
- m_fontSize = 36; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 2000; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_text = TaiVietText();
-
- m_fset[0].id = 2001; m_fset[0].value = 2; // vowel position = final consonant
- m_fset[1].id = 1051; m_fset[1].value = 0; // diacritic selection = off
- m_fset[2].id = 2102; m_fset[2].value = 0; // collision avoidance = off
- m_fset[3].id = 0;
-
- // Output:
- m_segWidth = 946; // physical width of segment
-
- const int charCnt = 46; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, false, true, true, true, false, true, true, true,
- false, false, true, true, false, true, true, false, false, true,
- true, false, false, true, true, false, false, true, true, false,
- false, true, true, false, true, true, false, false, true, true,
- false, true, true, true, false, false
- };
-
- const int glyphCnt = 46; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- // 0 10 20 30 40
- gid16 glyphList[] = {59, 70, 71, 65, 59, 70, 71, 23, 32, 175, 70, 65, 55, 70, 73, 55, 175, 184,185, 55, 76, 184,185, 55, 77, 70, 185, 41, 77, 70, 23, 56,175, 65, 27, 93, 70,185, 53, 69, 81, 50, 27,175, 70, 23};
- int xPositions[] = { 0, 72, 47, 72,101, 174,149,174, 206, 281, 283, 251, 283,352, 316, 352, 418, 425,386,425,493, 495,458, 495,556,559, 528, 559, 623, 623,591,623,706, 676, 706, 776,777,738, 777, 836, 816,843,880,944,946,912};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 5, 13, 0, 0, 5, 22, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 19, 0, 0, 8, 0, 0, 0, 5, 21, 0};
- int advWidths[] = {47, 0, 24, 29, 47, 0, 24, 32, 44, 0, 0, 29, 33, 0, 36, 33, 0, 0, 26, 33, 0, 0, 26, 33, 0, 0, 26, 32, 0, 0, 32, 52, 0, 29, 32, 0, 0, 26, 39, 0, 26, 36, 32, 0, 0, 32};
-
- int bbLefts[] = { 5, 45, 52, 73,106, 147,154,177, 209, 254, 257, 252, 286,326, 322, 355, 391, 414,390,428,463, 484, 462,498,540,532, 532, 562, 607, 597,594,627,679, 677, 709, 744,751,742, 784, 825, 820,849,883,917,919,915};
- int bbRights[] = {72, 72, 63, 97,174, 174,165,211, 277, 281, 283, 276, 349,352, 355, 419, 418, 422,409,491,494, 491, 481,561,553,559, 551, 621, 620, 623,628,681,706, 701, 756, 776,777,761, 835, 833, 840,882,930,944,946,949};
- int bbTops [] = {60, 50, 25, 25, 60, 50, 25, 41, 60, 49, 66, 25, 60, 50, 40, 60, 55, 65, 36, 60, 56, 74, 36, 60, -5, 55, 36, 60, -5, 50, 41, 40, 49, 25, 55, 56, 69, 36, 55, 61, 41, 40, 55, 55, 71, 41};
- int bbBottoms [] = { 0, 35, 0, 0, 0, 35, 0, 0, 0, 34, 50, 0, 0, 35, 0, 0, 39, 51, 0, 0, 40, 60, 0, 0,-27, 40, 0, 0, -27, 35, 0, 0, 34, 0, 0, 40, 54, 0, 0, 45, 0, 0, 0, 39, 56, 0};
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,0, 1,2,0, 2,2,1,1, 3,3,0, 4,4,0, 5,6,0, 6,6,1,5, 7,7,0,
- 8,8,0, 9,11,0, 10,11,0, 11,11,2,9,10, 12,12,0, 13,14,0, 14,14,1,13,
- 15,15,0, 16,18,0, 17,18,0, 18,18,2,16,17, 19,19,0, 20,22,0, 21,22,0,
- 22,22,2,20,21, 23,23,0, 24,26,0, 25,26,0, 26,26,2,24,25, 27,27,0, 28,30,0,
- 29,30,0, 30,30,2,28,29, 31,31,0, 32,33,0, 33,33,1,32, 34,34,0, 35,37,0,
- 36,37,0, 37,37,2,35,36, 38,38,0, 39,40,0, 40,40,1,39, 41,41,0, 42,42,0,
- 43,45,0, 44,45,0, 45,45,2,43,44
- };
- int attCount = sizeof(attachments) / sizeof(int);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel Top, prim sel bottom, prim sel left,
- // sec sel Top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 4;
- int clickStuff[] = {
- 55, 40, 1, true, 0,100, 46, kAbsent, kAbsent, kAbsent,
- 65, 20, 1, false, 0,100, 46, kAbsent, kAbsent, kAbsent, // adjust to the left to get a valid IP?
- 95, 84, 4, true, 0,100, 100, kAbsent, kAbsent, kAbsent,
- 104, 40, 4, false, 0,100, 100, kAbsent, kAbsent, kAbsent
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(bbLefts, bbRights, bbTops, bbBottoms);
- SetInsPtFlags(insPtFlags);
- SetAttachedClusters(attachments, attCount);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-/*----------------------------------------------------------------------------------------------
- A set of tests that uses Tai Viet script to test positioning.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupTaiViet2()
-{
- m_testName = "Tai Viet No Collisions";
- //m_traceLog = true;
- //m_debug = true;
- //m_skip = true;
-
- // Input:
- m_fontName = L"Graphite Test TaiViet";
- m_fontFile = "grtest_taiviet.ttf";
- m_fontSize = 36; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 2000; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_text = TaiVietText();
-
- m_fset[0].id = 2001; m_fset[0].value = 2; // vowel position = final consonant
- m_fset[1].id = 1051; m_fset[1].value = 1; // diacritic selection = on
- m_fset[2].id = 2102; m_fset[2].value = 1; // collision avoidance = off
- m_fset[3].id = 0;
-
- // Output:
- m_segWidth = 947; // physical width of segment
-
- const int charCnt = 46; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true
- };
-
- const int glyphCnt = 46; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- // 0 10 20 30 40
- gid16 glyphList[] = {59, 70, 71, 65, 59, 70, 71, 23, 32, 175, 70, 65, 55, 70, 73, 55, 175, 184,185, 55, 76, 184,185, 55, 77, 70, 185, 41, 77, 70, 23, 56,175, 65, 27, 93, 70,185, 53, 69, 81, 50, 27,175, 70, 23};
- int xPositions[] = { 0, 82, 47, 72,101, 184,149,174, 206, 281, 283, 251, 283,359, 316, 352, 418, 431,386,425,496, 508,458, 497,559,578, 530, 561, 626, 635,593,626,709, 678, 708, 778,780,740, 780, 853, 819,846,882,942,947,914};
- int yPositions[] = { 0, -3, 0, 0, 0, -3, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 9, 0, 0, 2, 20, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -4, 0, 0, 5, 25, 0, 0, 8, 0, 0, 0, 0, 23, 0};
- int advWidths[] = {47, 0, 24, 29, 47, 0, 24, 32, 44, 0, 0, 29, 33, 0, 36, 33, 0, 0, 26, 33, 0, 0, 26, 33, 0, 0, 26, 32, 0, 0, 32, 52, 0, 29, 32, 0, 0, 26, 39, 0, 26, 36, 32, 0, 0, 32};
-
- int bbLefts[] = { 5, 56, 52, 73,106, 158,154,177, 209, 254, 257, 252, 286,333, 322, 355, 391, 420,390,428,466, 497, 462,500,542,552, 534, 564, 609, 609,597,629,682, 679, 711, 747,753,744, 786, 842, 823,851,885,916,921,918};
- int bbRights[] = {72, 82, 63, 97,174, 184,165,211, 277, 281, 283, 276, 349,359, 355, 419, 418, 427,409,491,496, 504, 481,564,555,578, 553, 624, 622, 635,630,684,709, 703, 758, 778,780,763, 837, 850, 842,885,932,942,947,951};
- int bbTops [] = {60, 46, 25, 25, 60, 46, 25, 41, 60, 49, 73, 25, 60, 50, 40, 60, 50, 60, 36, 60, 54, 72, 36, 60, -5, 52, 36, 60, -5, 50, 41, 40, 45, 25, 55, 56, 75, 36, 55, 61, 41, 40, 55, 50, 73, 41};
- int bbBottoms [] = { 0, 31, 0, 0, 0, 31, 0, 0, 0, 34, 57, 0, 0, 35, 0, 0, 34, 46, 0, 0, 37, 57, 0, 0,-27, 36, 0, 0, -27, 35, 0, 0, 29, 0, 0, 40, 60, 0, 0, 45, 0, 0, 0, 34, 58, 0};
-
- // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices
- int attachments[] = {
- 0,0,0, 1,2,0, 2,2,1,1, 3,3,0, 4,4,0, 5,6,0, 6,6,1,5, 7,7,0,
- 8,8,0, 9,11,0, 10,11,0, 11,11,2,9,10, 12,12,0, 13,14,0, 14,14,1,13,
- 15,15,0, 16,18,0, 17,18,0, 18,18,2,16,17, 19,19,0, 20,22,0, 21,22,0,
- 22,22,2,20,21, 23,23,0, 24,26,0, 25,26,0, 26,26,2,24,25, 27,27,0, 28,30,0,
- 29,30,0, 30,30,2,28,29, 31,31,0, 32,33,0, 33,33,1,32, 34,34,0, 35,37,0,
- 36,37,0, 37,37,2,35,36, 38,38,0, 39,40,0, 40,40,1,39, 41,41,0, 42,42,0,
- 43,45,0, 44,45,0, 45,45,2,43,44
- };
- int attCount = sizeof(attachments) / sizeof(int);
-
- // Each line in clickStuff represents one click test with the following items:
- // click x-coord, click y-coord, char index, assoc-prev,
- // prim sel top, prim sel bottom, prim sel left,
- // sec sel top, sec sel bottom, sec sel left
- // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left.
- const int clickTestCnt = 4;
- int clickStuff[] = {
- 55, 40, 2, false, 35, 65, 49, 14, 33, 82,
- 65, 20, 1, false, 0,100, 50, kAbsent, kAbsent, kAbsent,
- 95, 84, 4, true, 0,100, 100, kAbsent, kAbsent, kAbsent,
- 104, 40, 4, false, 0,100, 100, kAbsent, kAbsent, kAbsent
- };
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(bbLefts, bbRights, bbTops, bbBottoms);
- SetInsPtFlags(insPtFlags);
- SetAttachedClusters(attachments, attCount);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-std::wstring TestCase::TaiVietText()
-{
- std::wstring strRet;
- wchar_t charData[] = {
- 0xe00f,0xe042,0xe031,0xe02b,0xe00f,0xe042,0xe031,0xe025,0xe021,0xe033,
- 0xe042,0xe02b,0xe01c,0xe042,0xe03e,0xe01c,0xe033,0xe040,0xe009,0xe01c,
- 0xe039,0xe040,0xe009,0xe01c,0xe035,0xe042,0xe009,0xe024,0xe035,0xe042,
- 0xe025,0xe01b,0xe033,0xe02b,0xe00a,0xe030,0xe042,0xe009,0xe01e,0xe040,
- 0xe03b,0xe019,0xe00a,0xe033,0xe042,0xe025,0x0000
- };
- strRet.assign(charData);
- return strRet;
-}
-
-/*----------------------------------------------------------------------------------------------
- Set up a test where the font is bad and we revert to dumb rendering
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupDumbFallback1()
-{
- m_testName = "Dumb Fallback 1";
- //m_debug = true;
- m_traceLog = false;
- //m_skip = true;
-
- // Input:
- m_fontName = L"GrErr BadVersion";
- m_fontFile = "grtest_badVersion.ttf";
- m_text = RomanText(); // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_dumbFallback = true;
-
- // Output:
- m_badFont = true;
- m_segWidth = 196; // physical width of segment
-
- const int charCnt = 26; // number of characters in the segment
-
- // need charCnt elements in this array:
- bool insPtFlags[] = {
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true, true, true, true, true,
- true, true, true, true, true, true
- };
-
- const int glyphCnt = 26; // number of glyphs in the segment
-
- // need glyphCnt elements in these arrays:
- // 0 10 20
- gid16 glyphList[] = {71, 0, 0, 82, 0, 85, 73, 0, 0, 0, 0, 67, 0, 0, 75, 0, 43, 0, 79, 0, 0, 0, 0, 72, 72, 75};
- int xPositions[] = { 0, 7, 15, 23, 31, 39, 46, 54, 62, 70, 78, 86, 93,101,109,114,122,128,136,149,157,165,173,181,186,192};
- int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- int advWidths[] = { 7, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 7, 8, 8, 4, 8, 5, 8, 12, 8, 8, 8, 8, 5, 5, 4};
-
- const int clickTestCnt = 0;
- int * clickStuff = NULL;
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
- SetGlyphList(glyphList);
- SetXPositions(xPositions);
- SetYPositions(yPositions);
- SetAdvWidths(advWidths);
- SetBBs(NULL, NULL, NULL, NULL);
- SetInsPtFlags(insPtFlags);
- SetClickTests(clickTestCnt, clickStuff);
-}
-
-/*----------------------------------------------------------------------------------------------
- Now make sure we will get a crash when we turn dumb rendering off for the same font.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupDumbFallback2()
-{
- m_testName = "Dumb Fallback 2";
- //m_debug = true;
- m_traceLog = false;
- //m_skip = true;
-
- // Input:
- m_fontName = L"GrErr BadVersion";
- m_fontFile = "grtest_badVersion.ttf";
- m_text = L"This is a test."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_dumbFallback = false;
-
- // Output:
- m_badFont = true;
- m_noSegment = true;
- m_segWidth = 0; // physical width of segment
-
- const int charCnt = 0; // number of characters in the segment
-
- const int glyphCnt = 0; // number of glyphs in the segment
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
-}
-
-/*----------------------------------------------------------------------------------------------
- Now make sure we will get a crash when we turn dumb rendering off for the same font.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetupBadFont()
-{
- m_testName = "Bad Font";
- //m_debug = true;
- m_traceLog = false;
- //m_skip = true;
-
- // Input:
- // The font has been corrupted so that the size of the cmap in the directory is invalid.
- m_fontName = L"Graphite Test Roman";
- m_fontFile = "grtest_badCmap.ttf";
- m_text = L"This is a test."; // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_rtl = false;
- m_backtrack = false;
- m_dumbFallback = true; // wants to do dumb fall-back, but can't because the font is totally invalid
-
- // Output:
- m_badFont = true;
- m_noSegment = true;
- m_segWidth = 0; // physical width of segment
-
- const int charCnt = 0; // number of characters in the segment
-
- const int glyphCnt = 0; // number of glyphs in the segment
-
- // Finish setting up test case.
- SetCharCount(charCnt);
- SetGlyphCount(glyphCnt);
-}
-// *** Add more methods here. ***
-
-
-//:>********************************************************************************************
-//:> Utility methods.
-//:>********************************************************************************************
-
-/*----------------------------------------------------------------------------------------------
- Delete the list of tests.
-----------------------------------------------------------------------------------------------*/
-void TestCase::DeleteTests()
-{
- delete[] g_ptcaseList;
-}
-
-/*----------------------------------------------------------------------------------------------
- Constructor: initialize test case with default values.
-----------------------------------------------------------------------------------------------*/
-TestCase::TestCase()
-{
- m_testName = "Unknown";
- m_debug = false;
- m_traceLog = false;
- m_skip = false;
-
- m_fontName.erase();
- m_fontFile.erase();
- m_text.erase(); // text to render
- m_fontSize = 12; // font size in points
- m_prefBreak = klbWordBreak; // preferred break-weight
- m_worstBreak = klbClipBreak; // worst-case break-weight
- m_availWidth = 500; // width available for segment
- m_bold = false;
- m_italic = false;
- m_backtrack = false;
- m_twsh = ktwshAll;
- m_paraRtl = false;
- m_firstChar = 0;
- m_contextBlockInSize = 0;
- m_contextBlockIn = NULL;
- m_initWithPrev = false;
- memset(m_fset, 0, MAXFEAT * sizeof(FeatureSetting));
- m_dumbFallback = true;
-
- m_badFont = false;
- m_noSegment = false; // yes, a segment should be generated
- m_charCount = 0;
- m_glyphCount = 0;
- m_glyphArray = NULL;
- m_xPositions = NULL;
- m_yPositions = NULL;
- m_advWidths = NULL;
- m_bbLefts = NULL;
- m_bbRights = NULL;
- m_bbTops = NULL;
- m_bbBottoms = NULL;
- m_insPointFlags = NULL;
- m_charsToGlyphs = NULL;
- m_c2gCount = 0;
- m_attGlyphs = NULL;
- m_attGCount = 0;
- m_contextBlockOutSize = 0;
- m_contextBlockOut = NULL;
-
- m_clickTestCount = 0;
- m_clickTests = NULL;
-}
-
-/*----------------------------------------------------------------------------------------------
- Destructor.
-----------------------------------------------------------------------------------------------*/
-TestCase::~TestCase()
-{
- delete[] m_glyphArray;
- delete[] m_xPositions;
- delete[] m_yPositions;
- delete[] m_advWidths;
- delete[] m_bbLefts;
- delete[] m_bbRights;
- delete[] m_bbTops;
- delete[] m_bbBottoms;
- delete[] m_insPointFlags;
- delete[] m_charsToGlyphs;
- delete[] m_attGlyphs;
- delete[] m_clickTests;
- delete[] m_contextBlockIn;
- delete[] m_contextBlockOut;
-}
-
-/*----------------------------------------------------------------------------------------------
- Setters.
-----------------------------------------------------------------------------------------------*/
-void TestCase::SetCharCount(int charCount)
-{
- m_charCount = charCount;
- m_insPointFlags = new bool[charCount];
-}
-
-void TestCase::SetGlyphCount(int glyphCount)
-{
- m_glyphCount = glyphCount;
- m_glyphArray = new gid16[glyphCount];
- m_xPositions = new int[glyphCount];
- m_yPositions = new int[glyphCount];
- m_advWidths = new int[glyphCount];
- m_bbLefts = new int[glyphCount];
- m_bbRights = new int[glyphCount];
- m_bbTops = new int[glyphCount];
- m_bbBottoms = new int[glyphCount];
-}
-
-void TestCase::SetGlyphList(gid16 * glyphList)
-{
- for (int i = 0; i < m_glyphCount; i++)
- m_glyphArray[i] = glyphList[i];
-}
-
-void TestCase::SetXPositions(int * xPosList)
-{
- for (int i = 0; i < m_glyphCount; i++)
- m_xPositions[i] = xPosList[i];
-}
-
-void TestCase::SetYPositions(int * yPosList)
-{
- for (int i = 0; i < m_glyphCount; i++)
- m_yPositions[i] = yPosList[i];
-}
-
-void TestCase::SetAdvWidths(int * advWidths)
-{
- for (int i = 0; i < m_glyphCount; i++)
- m_advWidths[i] = advWidths[i];
-}
-
-void TestCase::SetBBs(int * bbLefts, int * bbRights, int * bbTops, int * bbBottoms)
-{
- if (bbLefts == NULL) // no bb tests
- {
- delete[] m_bbLefts;
- delete[] m_bbRights;
- delete[] m_bbTops;
- delete[] m_bbBottoms;
- m_bbLefts = NULL;
- m_bbRights = NULL;
- m_bbTops = NULL;
- m_bbBottoms = NULL;
- return;
- }
-
- for (int i = 0; i < m_glyphCount; i++)
- {
- m_bbLefts[i] = bbLefts[i];
- m_bbRights[i] = bbRights[i];
- m_bbTops[i] = bbTops[i];
- m_bbBottoms[i] = bbBottoms[i];
- }
-}
-
-void TestCase::SetInsPtFlags(bool * flags)
-{
- for (int i = 0; i < m_charCount; i++)
- m_insPointFlags[i] = flags[i];
-}
-
-void TestCase::SetCharsToGlyphs(int * stuff, int count)
-{
- m_c2gCount = count;
- m_charsToGlyphs = new int[count];
- for (int i = 0; i < count; i++)
- m_charsToGlyphs[i] = stuff[i];
-}
-
-void TestCase::SetAttachedClusters(int * stuff, int count)
-{
- m_attGCount = count;
- m_attGlyphs = new int[count];
- for (int i = 0; i < count; i++)
- m_attGlyphs[i] = stuff[i];
-}
-
-void TestCase::SetClickTests(int clickTestCount, int * clickStuff)
-{
- const int fc = ClickTest::fieldCnt;
-
- m_clickTestCount = clickTestCount;
- m_clickTests = new ClickTest[clickTestCount];
- for (int i = 0; i < clickTestCount; i++)
- {
- m_clickTests[i].xClick = clickStuff[(i * fc) + 0];
- m_clickTests[i].yClick = clickStuff[(i * fc) + 1];
- m_clickTests[i].charIndex = clickStuff[(i * fc) + 2];
- m_clickTests[i].assocPrev = clickStuff[(i * fc) + 3];
- m_clickTests[i].sel1Top = clickStuff[(i * fc) + 4];
- m_clickTests[i].sel1Bottom = clickStuff[(i * fc) + 5];
- m_clickTests[i].sel1Left = clickStuff[(i * fc) + 6];
- m_clickTests[i].sel2Top = clickStuff[(i * fc) + 7];
- m_clickTests[i].sel2Bottom = clickStuff[(i * fc) + 8];
- m_clickTests[i].sel2Left = clickStuff[(i * fc) + 9];
- }
-}
-
-void TestCase::SetInputContextBlock(int contextBlockInSize, gr::byte * pContextBlockIn)
-{
- m_contextBlockInSize = contextBlockInSize;
- if (contextBlockInSize == 0)
- {
- m_contextBlockIn = NULL;
- }
- else
- {
- m_contextBlockIn = new gr::byte[contextBlockInSize];
- std::copy(pContextBlockIn, pContextBlockIn + contextBlockInSize, m_contextBlockIn);
- }
-}
-
-void TestCase::SetOutputContextBlock(int contextBlockOutSize, gr::byte * pContextBlockOut)
-{
- m_contextBlockOutSize = contextBlockOutSize;
- m_contextBlockOut = new gr::byte[contextBlockOutSize];
- std::copy(pContextBlockOut, pContextBlockOut + contextBlockOutSize, m_contextBlockOut);
-}
+/*--------------------------------------------------------------------*//*:Ignore this sentence. +Copyright (C) 2004 SIL International. All rights reserved. + +Distributable under the terms of either the Common Public License or the +GNU Lesser General Public License, as specified in the LICENSING.txt file. + +File: TestCase.cpp +Responsibility: Sharon Correll +Last reviewed: Not yet. + +Description: + File to set up test cases for the Graphite regression test program. + +How to add a test: + 1. Add the name of your test method to the class declaration in TestCase.h. + 2. Increment the g_numberOfTests constant in this file. + 3. Add a call to your test method in the SetupTests method in this file. + 4. Copy one of the existing test methods such as SetupSimpleTest and change the name + and data. + +Things that still need testing: + Ligatures (there is one small test of this) + Justification + Fake italic +-------------------------------------------------------------------------------*//*:End Ignore*/ + +#include "main.h" + +//:>******************************************************************************************** +//:> Test constants and methods +//:>******************************************************************************************** + +const int g_numberOfTests = 25; // *** increment as tests are added *** + +TestCase * g_ptcaseList; // list of test cases + +namespace gr { // and it was SC who got rid of the byte defn in GrPlatform.h! +typedef unsigned char byte; +} + + +/*---------------------------------------------------------------------------------------------- + Create the list of tests. +----------------------------------------------------------------------------------------------*/ +int TestCase::SetupTests(TestCase ** pptcaseList) +{ + g_ptcaseList = new TestCase[g_numberOfTests]; + int cptcase = 0; + + // The number of methods called here should equal g_numberOfTests above. + g_ptcaseList[0].SetupSimpleTest(); cptcase++; + g_ptcaseList[1].SetupSimpleBacktrackTest(); cptcase++; + g_ptcaseList[2].SetupSurrogateTest(); cptcase++; + g_ptcaseList[3].SetupBurmese1(); cptcase++; + g_ptcaseList[4].SetupBurmese2(); cptcase++; + g_ptcaseList[5].SetupBurmese3(); cptcase++; + g_ptcaseList[6].SetupBurmese4(); cptcase++; + g_ptcaseList[7].SetupRoman(); cptcase++; + g_ptcaseList[8].SetupRomanFeatures(); cptcase++; + g_ptcaseList[9].SetupStackingAndBridging(); cptcase++; + g_ptcaseList[10].SetupNoWhiteSpace(); cptcase++; + g_ptcaseList[11].SetupNoWhiteSpaceNoSeg(); cptcase++; + g_ptcaseList[12].SetupOnlyWhiteSpace(); cptcase++; + g_ptcaseList[13].SetupCrossLine1(); cptcase++; + g_ptcaseList[14].SetupCrossLine2(); cptcase++; + g_ptcaseList[15].SetupCrossLine3(); cptcase++; + g_ptcaseList[16].SetupCrossLine4(); cptcase++; + g_ptcaseList[17].SetupArabic1(); cptcase++; + g_ptcaseList[18].SetupArabic2(); cptcase++; + g_ptcaseList[19].SetupTaiViet1(); cptcase++; + g_ptcaseList[20].SetupTaiViet2(); cptcase++; + g_ptcaseList[21].SetupDumbFallback1(); cptcase++; + g_ptcaseList[22].SetupDumbFallback2(); cptcase++; + g_ptcaseList[23].SetupBadFont(); cptcase++; + g_ptcaseList[24].SetupBugTest(); cptcase++; + // *** Add more method calls here. *** + + assert(cptcase == g_numberOfTests); + + *pptcaseList = g_ptcaseList; + + return g_numberOfTests; +} + +/*---------------------------------------------------------------------------------------------- + Set up a simple test. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupSimpleTest() +{ + m_testName = "Simple"; + //m_debug = true; + m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L"This is a test."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + // Output: + m_segWidth = 86; // physical width of segment + + const int charCnt = 15; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true + }; + + const int glyphCnt = 15; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {55, 75, 76, 86, 3, 76, 86, 3, 68, 3, 87, 72, 86, 87, 17}; + int xPositions[] = { 0, 9, 17, 22, 28, 33, 37, 43, 48, 55, 60, 64, 71, 77, 82}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 9, 8, 4, 6, 4, 4, 6, 4, 7, 4, 4, 7, 6, 4, 4}; + + int bbLefts[] = { 0, 9, 18, 22, 28, 33, 38, 43, 48, 55, 60, 65, 72, 78, 83}; + int bbRights[] = { 9, 17, 21, 27, 33, 37, 43, 48, 55, 60, 64, 71, 77, 82, 85}; + int bbTops[] = {10, 11, 10, 7, 0, 10, 7, 0, 7, 0, 9, 7, 7, 9, 1}; + int bbBottoms[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + int charsToGlyphs[] = { + 1, 1, 1, 2, 1, 2, 3, 1, 3, 4, 1, 4, 5, 1, 5, 6, 1, 6, 7, 1, 7 + }; + int c2gCount = 21; + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 3; + int clickStuff[] = { + 11, 25, 1, false, 0, 24, 8, kAbsent, kAbsent, kAbsent, // below baseline + 42, 5, 7, true, 0, 24, 42, kAbsent, kAbsent, kAbsent, // near top of text + 90, 16, 15, true, 0, 24, 85, kAbsent, kAbsent, kAbsent // near baseline + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetCharsToGlyphs(charsToGlyphs, c2gCount); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + Set up a simple test with backtracking. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupSimpleBacktrackTest() +{ + m_testName = "Simple Backtrack"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L"This is a test."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = true; + + // Output: + m_segWidth = 55; // physical width of segment + + const int charCnt = 10; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true + }; + + const int glyphCnt = 10; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {55, 75, 76, 86, 3, 76, 86, 3, 68, 3}; + int xPositions[] = { 0, 9, 17, 22, 28, 33, 37, 43, 48, 55}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 9, 8, 4, 6, 4, 4, 6, 4, 7, 4}; + + const int contextBlockOutSize = 10; + gr::byte contextBlockOut[] = { 15, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +/*---------------------------------------------------------------------------------------------- + Set up a test that includes surrogates. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupSurrogateTest() +{ + m_testName = "Surrogates"; + //m_debug = true; + m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L"abXXcdYYe"; // text to render + m_text[2] = 0xD835; + m_text[3] = 0xDD13; + m_text[6] = 0xD835; + m_text[7] = 0xDD10; + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + // Output: + m_segWidth = 65; // physical width of segment + + const int charCnt = 9; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, false, true, true, true, false, true + }; + + const int glyphCnt = 7; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {68, 69,1227, 70, 71,1015, 72}; + int xPositions[] = { 0, 7, 15, 27, 34, 42, 58}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 7, 8, 12, 7, 8, 15, 7}; + + int bbLefts[] = { 0, 7, 15, 28, 35, 43, 59}; + int bbRights[] = { 7, 14, 26, 34, 42, 57, 65}; + int bbTops[] = { 7, 11, 10, 7, 11, 10, 7}; + int bbBottoms[] = { 0, 0, -3, 0, 0, 0, 0}; + + int charsToGlyphs[] = { + 0, 1, 0, 1, 1, 1, 2, 1, 2, 3, 0, 4, 1, 3, 5, 1, 4, 6, 1, 5, 7, 0, + 8, 1, 6, + }; + int c2gCount = 25; + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 3; + int clickStuff[] = { + 17, 25, 2, false, 0, 24, 14, kAbsent, kAbsent, kAbsent, // below baseline + 25, 5, 4, true, 0, 24, 26, kAbsent, kAbsent, kAbsent, // near top of text + 55, 16, 8, true, 0, 24, 57, kAbsent, kAbsent, kAbsent // near baseline + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetCharsToGlyphs(charsToGlyphs, c2gCount); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + A set of tests using Burmese, to test complex positioning and non-white-space + linebreaking. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupBurmese1() +{ + m_testName = "Burmese 1"; + m_debug = false; + //m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Burmese"; + m_fontFile = "grtest_burmese.ttf"; + m_text = BurmeseText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 300; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_segWidth = 281; // physical width of segment + + SetupBurmeseAux( + 64, // character count + 45, // glyph count + 5); // number of click-tests + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,0, 1,1,0, 2,2,2,3,4, 3,2,0, 4,2,0, 5,5,1,6, 6,5,0, 7,7,3,8,9,10, + 8,7,0, 9,7,0, 10,7,0, 11,11,0, 12,12,0, 13,13,0, 14,14,0, 15,15,0, + 16,16,1,17, 17,16,0, 18,18,1,19, 19,18,0, 20,20,1,21, 21,20,0, 22,22,1,23, + 23,22,0, 24,24,0, 25,25,0 + }; + int attCount = sizeof(attachments) / sizeof(int); + SetAttachedClusters(attachments, attCount); + + const int contextBlockOutSize = 11; + gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupBurmese2() +{ + m_testName = "Burmese 2"; + //m_debug = true; + //m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Burmese"; + m_fontFile = "grtest_burmese.ttf"; + + m_text = BurmeseText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 275; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_segWidth = 215; // physical width of segment + + SetupBurmeseAux( + 47, // character count + 33, // glyph count + 3); // number of click-tests + + const int contextBlockOutSize = 11; + gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupBurmese3() +{ + m_testName = "Burmese 3"; + //m_debug = true; + //m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Burmese"; + m_fontFile = "grtest_burmese.ttf"; + + m_text = BurmeseText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 75; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_segWidth = 73; // physical width of segment + + SetupBurmeseAux( + 19, // character count + 13, // glyph count + 2); // number of click-tests + + const int contextBlockOutSize = 11; + gr::byte contextBlockOut[] = { 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupBurmese4() +{ + m_testName = "Burmese 4"; + //m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Burmese"; + m_fontFile = "grtest_burmese.ttf"; + + m_text = BurmeseText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWsBreak; // preferred break-weight + m_worstBreak = klbHyphenBreak; // worst-case break-weight + m_availWidth = 30; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_noSegment = true; + m_segWidth = 0; // physical width of segment + + SetupBurmeseAux( + 0, // character count + 0, // glyph count + 0); // number of click-tests +} + +void TestCase::SetupBurmeseAux(int charCnt, int glyphCnt, int clickTestCnt) +{ + m_rtl = false; + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, false, false, false, true, false, false, false, false, // 0 - 9 + true, false, false, true, false, false, false, true, true, true, // 10 - 19 + true, false, true, true, false, false, true, false, false, false, // 20 - 29 + false, true, false, false, true, false, false, false, true, true, // 30 - 39 + true, true, true, true, true, true, true, true, true, false, // 40 - 49 + true, true, true, false, false, false, true, false, false, true, // 50 - 59 + false, false, false, true + }; + + // need glyphCnt elements in these arrays: + // 0 10 20 30 40 + gid16 glyphList[] = {105,174,158,202,231,162,231,148,223,219,229,248, 3,226,162,173,216,231,177,195,115,231,170,204,243, 3,197,216,172,216, 3,233, 3,226,179,162,216,170,204,158,202,115,231,229, 3}; + int xPositions[] = { 0, 17, 20, 22, 28, 29, 38, 40, 50, 55, 56, 57, 73, 79, 89, 99,102,109,110,111,120,129,130,131,140,143,149,167,174,191,198,205,215,222,232,234,245,252,253,262,264,271,280,278,281}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 17, 2, 9, 4, 0, 10, 0, 17, 2, 0, 0, 15, 6, 10, 10, 2, 7, 0, 10, 9, 9, 0, 10, 7, 2, 6, 17, 7, 17, 7, 6, 10, 6, 10, 2, 10, 7, 10, 7, 9, 4, 9, 0, 0, 6}; + + int bbLefts[] = { 0, 10, 21, 23, 23, 30, 33, 41, 51, 49, 53, 58, 73, 80, 90, 96,100,103,111,109,121,123,131,132,141,143,150,165,175,189,198,206,215,223,233,235,243,253,254,263,265,272,275,275,281}; + int bbRights[] = { 16, 19, 28, 25, 28, 39, 38, 56, 54, 55, 56, 72, 79, 88, 98,101,109,109,119,119,129,129,139,138,142,149,166,173,190,197,205,214,222,231,244,244,251,261,260,271,267,280,280,278,288}; + int bbTops[] = { 7, 7, 7, -1, 15, 7, 15, 7, -1, 15, -2, 15, 0, 7, 7, 7, 7, 15, 7, -1, 7, 15, 7, -1, 7, 0, 7, 7, 7, 7, 0, 7, 0, 7, 16, 7, 7, 7, -1, 7, -1, 7, 15, -2, 0}; + int bbBottoms[] = { 0, -7, -1, -7, 9, 0, 9, 0, -7, 9, -5, 0, 0, 0, 0, -7, 0, 9, -4, -7, 0, 9, 0, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -7, 0, 0, 0, -7, -1, -7, 0, 9, -5, 0}; + + // Each group = char-index, number of glyphs, glyph-indices. + int charsToGlyphs[] = { + 0, 1, 0, 1, 1, 1, 2, 1, 1, 3, 1, 1, 4, 1, 1, 5, 1, 2, 6, 1, 3, 7, 1, 3, + 8, 1, 4, 9, 1, 4, 10, 1, 5, 11, 1, 6, 12, 1, 6, 13, 1, 7 + }; + int c2gCount = sizeof(charsToGlyphs) / sizeof(int); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + int clickStuff[] = { + 10, 25, 1, true, 0, 25, 16, kAbsent, kAbsent, kAbsent, + 40, 5, 13, false, 0, 25, 39, kAbsent, kAbsent, kAbsent, + 93, 40, 19, false, 0, 25, 88, 0, 25, 77, + 251, 5, 52, true, 0, 25,251, kAbsent, kAbsent, kAbsent, + 235, 30, 48, false, -1, 27,230, 7, 19,243, + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetCharsToGlyphs(charsToGlyphs, c2gCount); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); +} + +std::wstring TestCase::BurmeseText() +{ + std::wstring strRet; + wchar_t charData[] = { + 0x1000, 0x1039, 0x101a, 0x1039, 0x101d, 0x1014, 0x1039, 0x101f, 0x1039, 0x200c, + 0x1015, 0x1039, 0x200c, 0x1010, 0x102f, 0x102d, 0x1037, 0x104f, 0x0020, 0x1015, + 0x1039, 0x101a, 0x1031, 0x102c, 0x1039, 0x200c, 0x101b, 0x1039, 0x101d, 0x1039, + 0x101f, 0x1004, 0x1039, 0x200c, 0x1019, 0x1039, 0x101f, 0x102f, 0x104a, 0x0020, + 0x101e, 0x102c, 0x101a, 0x102c, 0x0020, 0x1040, 0x0020, 0x1015, 0x1039, 0x101b, + 0x1031, 0x102c, 0x1019, 0x1039, 0x101f, 0x102f, 0x1014, 0x1039, 0x101f, 0x1004, + 0x1039, 0x200c, 0x1037, 0x0020, 0x1021, 0x1031, 0x102c, 0x1004, 0x1039, 0x200c, + 0x1019, 0x1039, 0x101b, 0x1004, 0x1039, 0x200c, 0x1019, 0x1039, 0x101f, 0x102f, + 0x1010, 0x102f, 0x102d, 0x1037, 0x101e, 0x100a, 0x1039, 0x200c, 0x0020, 0x1000, + 0x1039, 0x101a, 0x1039, 0x101d, 0x1014, 0x102f, 0x1039, 0x200c, 0x1015, 0x1039, + 0x200c, 0x1010, 0x102f, 0x102d, 0x1037, 0x104f, 0x0000 + }; + strRet.assign(charData); + return strRet; +} + +/*---------------------------------------------------------------------------------------------- + A set of tests using Roman script, which tests stacking diacritics, many-to-one glyphs, + and features. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupRoman() +{ + m_testName = "Roman"; + m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = RomanText(); // text to render + m_fontSize = 36; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + // Output: + m_segWidth = 278; // physical width of segment + + const int charCnt = 26; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true + }; + + const int glyphCnt = 24; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + // 0 10 20 + gid16 glyphList[] = {72,1815,1768, 83,1789, 86, 74,1943,1956,1926,1061, 68,1777,1755,805,1815, 44,1815, 80,1833,1768,1855,1838,637}; + int xPositions[] = { 0, 23, 23, 21, 41, 45, 64, 88, 98, 112, 116,148, 171, 171,170, 188,183, 203, 199, 230, 230, 230, 230,236}; + int yPositions[] = { 0, 0, 10, 0, -6, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0}; + int advWidths[] = {21, 0, 0, 24, 0, 18, 24, 13, 13, 4, 31, 21, 0, 0, 13, 0, 15, 0, 37, 0, 0, 0, 0, 41}; + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,2,1,2, 1,0,0, 2,0,0, 3,3,0, 4,4,0, 5,5,0, 6,6,0, 7,7,2,8,9, + 8,7,0, 9,7,0, 10,10,0, 11,11,2,12,13, 12,11,0, 13,11,0, 14,14,1,15, 15,14,0, + 16,16,1,17, 17,16,0, 18,18,4,19,20,21,22, 19,18,0, 20,18,0, 21,18,0, 22,18,0, + 23,23,0 + }; + int attCount = sizeof(attachments) / sizeof(int); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 5; + int clickStuff[] = { + 10, 15, 2, false, 9, 21, 1, 20, 30, 18, + 61, 50, 6, true, 0, 72, 63, kAbsent, kAbsent, kAbsent, + 90, 40, 7, false, 0, 72, 87, kAbsent, kAbsent, kAbsent, + 260, 40, 25, true, 0, 73,263, kAbsent, kAbsent, kAbsent, // ligature + 267, 40, 25, false, 0, 73,263, kAbsent, kAbsent, kAbsent, // ligature + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetAttachedClusters(attachments, attCount); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); +} + +void TestCase::SetupRomanFeatures() +{ + m_testName = "Roman Features"; + m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = RomanText(); // text to render + m_fontSize = 36; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + m_fset[0].id = 1024; m_fset[0].value = 2; // capital eng with tail + m_fset[1].id = 1026; m_fset[1].value = 1; // tone numbers + m_fset[2].id = 1029; m_fset[2].value = 1; // vietnamese diacritics + m_fset[3].id = 1032; m_fset[3].value = 1; // literacy alternates + m_fset[4].id = 1034; m_fset[4].value = 1; // y-hook alternate (default) + m_fset[5].id = 1051; m_fset[5].value = 0; // diacritic selection + m_fset[6].id = 0; + + // Output: + m_segWidth = 307; // physical width of segment + + const int charCnt = 26; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, false, false, true, true, true, true, true, true, true, + true, true, false, false, true, false, true, false, true, false, + false, false, false, true, true, true + }; + + const int glyphCnt = 23; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + // 0 10 20 + gid16 glyphList[] = {72,1815,1768, 83,1789, 86,681,1659,1667,1662,1056,274,1778, 805,1815, 44,1815, 80,1833,1768,1855,1838,637}; + int xPositions[] = { 0, 23, 23, 21, 41, 45, 64, 87, 104, 121, 138,173, 174, 198, 217, 211, 231, 227, 258, 258, 258, 258,265}; + int yPositions[] = { 0, 0, 10, 0, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 10, 20, 0}; + int advWidths[] = {21, 0, 0, 24, 0, 18, 23, 17, 17, 17, 34, 24, 24, 13, 0, 15, 0, 37, 0, 0, 0, 0, 41}; + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 3; + int clickStuff[] = { + 10, 15, 3, true, 0, 72, 20, kAbsent, kAbsent, kAbsent, + 116, 5, 9, true, 0, 72, 120, kAbsent, kAbsent, kAbsent, + 90, 40, 7, false, 0, 72, 86, kAbsent, kAbsent, kAbsent + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); +} + +std::wstring TestCase::RomanText() +{ + std::wstring strRet; + wchar_t charData[] = { + 0x0065, 0x0303, 0x0300, 0x0070, 0x0361, 0x0073, 0x0067, 0x02e8, 0x02e5, 0x02e7, + 0x014a, 0x0061, 0x0302, 0x0301, 0x0069, 0x0303, 0x0049, 0x0303, 0x006d, 0x033c, + 0x0300, 0x0308, 0x0304, 0x0066, 0x0066, 0x0069, 0x0000 + }; + strRet.assign(charData); + return strRet; +} + +/*---------------------------------------------------------------------------------------------- + A set of tests for handling complex diacritic stacking and bridging. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupStackingAndBridging() +{ + m_testName = "Roman Stacking and Bridging"; + //m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_fontSize = 36; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + // text to render + wchar_t charData[] = { + 0x0061,0x035d,0x0061,0x0020,0x0074,0x035d,0x0061,0x0020,0x0061,0x0300, + 0x0300,0x035d,0x0061,0x0020,0x0283,0x0300,0x0300,0x035d,0x0061,0x0020, + 0x0061,0x0316,0x0316,0xf176,0x0061,0x0020,0x0283,0x0300,0x0300,0xf176, + 0x0061,0x0020,0x0061,0x0316,0x0316,0xf176,0x0061,0x0020,0x0283,0x035d, + 0xf176,0x0061,0x0000 + }; + m_text.assign(charData); + + // Output: + m_segWidth = 414; // physical width of segment + + const int charCnt = 42; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, + }; + + const int glyphCnt = 42; // number of glyphs in the segment + + // 68 = a, 97 = t, 1305 = esh, 1768 = upper grave, 1765 = lower grave, 1802 = upper bridge, + // 1801 = lower bridge + + // need glyphCnt elements in these arrays: + // 0 10 20 30 40 + gid16 glyphList[] = {68,1802, 68, 3, 87,1802, 68, 3, 68,1768,1768,1802, 68, 3,1305,1768,1768,1802, 68, 3, 68,1765,1765,1801, 68, 3,1305,1768,1768,1801, 68, 3, 68,1765,1765,1801, 68, 3,1305,1802,1801, 68}; + int xPositions[] = { 0, 21, 21, 42, 56, 73, 69, 91, 105, 127, 127, 126, 126,147, 161, 181, 181, 178,177,199,212, 235, 235, 234,234,255, 269, 289, 289, 286,285,307,320, 343, 343, 342,342,363, 377, 393, 393,393}; + int yPositions[] = { 0, -7, 0, 0, 0, -1, 0, 0, 0, 0, 10, 12, 0, 0, 0, 10, 20, 23, 0, 0, 0, 0, -9, -17, 0, 0, 0, 10, 20, -6, 0, 0, 0, 0, -9, -17, 0, 0, 0, 3, -6, 0}; + int advWidths[] = {21, 0, 21, 13, 13, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 0, 21, 13, 21, 0, 0, 0, 21, 13, 16, 0, 0, 21}; + + int bbLefts[] = { 1, 0, 23, 42, 56, 52, 71, 91, 106, 108, 108, 105, 128,147, 159, 162, 162, 157,179,199,214, 217, 217, 213,235,255, 267, 270, 270, 265,287,307,322, 325, 325, 321,343,363, 375, 373, 373,395}; + int bbRights[] = {21, 41, 42, 56, 69, 93, 91,105, 126, 119, 119, 146, 147,161, 178, 173, 173, 198,199,212,234, 228, 228, 254,255,269, 286, 281, 281, 306,306,320,342, 336, 336, 362,363,377, 394, 413, 414,414}; + int bbTops [] = {22, 33, 22, 0, 28, 40, 22, 0, 22, 32, 42, 54, 22, 0, 33, 42, 53, 64, 22, 0, 22, -3, -13, -26, 22, 0, 33, 42, 53, -15, 22, 0, 22, -3, -13, -26, 22, 0, 33, 44, -15, 22}; + int bbBottoms [] = { 0, 26, 0, 0, 0, 33, 0, 0, 0, 24, 34, 47, 0, 0, -10, 34, 44, 57, 0, 0, 0, -11, -21, -32, 0, 0, -10, 34, 44, -21, 0, 0, 0, -11, -21, -32, 0, 0, -10, 38, -21, 0}; + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,0, 1,1,0, 2,2,0, 3,3,0, 4,4,0, 5,5,0, 6,6,0, 7,7,0, + 8,8,2,9,10, 9,8,0, 10,8,0, 11,11,0, 12,12,0, 13,13,0, 14,14,2,15,16, + 15,14,0, 16,14,0, 17,17,0, 18,18,0, 19,19,0, 20,20,2,21,22, 21,20,0, + 22,20,0, 23,23,0, 24,24,0, 25,25,0, 26,26,2,27,28, 27,26,0, 28,26,0, + 29,29,0, 30,30,0, 31,31,0, 32,32,2,33,34, 33,32,0, 34,32,0, 35,35,0, + 36,36,0, 37,37,0, 38,38,0, 39,39,0, 40,40,0, 41,41,0 + }; + int attCount = sizeof(attachments) / sizeof(int); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 6; + int clickStuff[] = { + 109, 25, 9, false, 19, 32, 105, 30, 56, 125, // first grave on 4th a + 178, 26, 15, true, 19, 66, 176, 9, 21, 159, // top of 1st esh, right side + 220, 84, 23, false, 78, 89, 210, 65, 77, 228, // first lower bridge diac + 271, 40, 26, false, 0, 72, 266, kAbsent, kAbsent, kAbsent, // second esh, left side + 271, 65, 26, false, 0, 72, 266, kAbsent, kAbsent, kAbsent, // just below second esh, left side + 271, 68, 29, false, 67, 78, 262, 0, 11, 280 // lower bridge diac under esh, left side + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetAttachedClusters(attachments, attCount); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + A set of tests for handling trailing whitespace. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupNoWhiteSpace() +{ + m_testName = "No white space"; + //m_debug = true; + //m_traceLog = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L"The quick brown fox."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 150; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_twsh = ktwshNoWs; + m_paraRtl = true; + + // Output: + m_segWidth = 115; // physical width of segment + + const int charCnt = 16; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true + }; + + const int glyphCnt = 16; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {55, 75, 72, 3, 3, 84, 88, 76, 70, 78, 3, 69, 85, 82, 90, 81}; + int xPositions[] = { 0, 9, 17, 24, 29, 34, 42, 50, 54, 61, 69, 74, 82, 87, 95,107}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 9, 8, 7, 4, 4, 8, 8, 4, 7, 8, 4, 8, 5, 8, 11, 8}; + + const int contextBlockOutSize = 10; + gr::byte contextBlockOut[] = { 15, 1, 0, 0, 0, 0, 0, 0, 0, 0 }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(0, NULL); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupNoWhiteSpaceNoSeg() +{ + m_testName = "No white space - no segment"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L"The quick brown fox."; // text to render + m_firstChar = 15; // spaces after brown + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 2; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_twsh = ktwshNoWs; + m_paraRtl = true; + + // Output: + m_noSegment = true; + m_segWidth = 0; // physical width of segment + + const int charCnt = 0; // number of characters in the segment + + const int glyphCnt = 0; // number of glyphs in the segment + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); +} + +void TestCase::SetupOnlyWhiteSpace() +{ + m_testName = "Only white space"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_roman.ttf"; + m_text = L" fox."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 2; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_twsh = ktwshOnlyWs; + m_paraRtl = true; + + // Output: + m_segWidth = 0; // physical width of segment - visible + + const int charCnt = 3; // number of characters in the segment + // need charCnt elements in this array: + bool insPtFlags[] = { true, true, true }; + + const int glyphCnt = 3; // number of glyphs in the segment + // need glyphCnt elements in these arrays: + gid16 glyphList[] = { 3, 3, 3 }; + int xPositions[] = { -4, -9,-13 }; + int yPositions[] = { 0, 0, 0 }; + int advWidths[] = { 4, 4, 4 }; + + // TODO: add click tests when the bug fix with upstream tr white space is integrated. + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 6; + int clickStuff[] = { + 2, 25, 0, false, 0, 24, -1, kAbsent, kAbsent, kAbsent, + -1, 5, 0, false, 0, 24, -1, kAbsent, kAbsent, kAbsent, + -6, -3, 1, false, 0, 24, -5, kAbsent, kAbsent, kAbsent, + -8, -3, 2, true, 0, 24, -10, kAbsent, kAbsent, kAbsent, + -13, 40, 3, true, 0, 24, -14, kAbsent, kAbsent, kAbsent, + -18, 0, 3, true, 0, 24, -14, kAbsent, kAbsent, kAbsent + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + A set of tests of cross-line contextualization. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupCrossLine1() +{ + m_testName = "Cross-line 1"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test CrossLine"; + m_fontFile = "grtest_xline.ttf"; + m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww"; + m_fontSize = 30; // font size in points + m_prefBreak = klbHyphenBreak; // preferred break-weight + m_availWidth = 350; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + + // Output: + m_segWidth = 312; // physical width of segment + + const int charCnt = 10; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true + }; + + const int glyphCnt = 13; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {30, 67, 68, 69, 70, 70, 70, 70, 71, 72, 34, 90, 32 }; + int xPositions[] = { 0, 40, 58, 79, 97,118,139,160,180,199,213,251,272 }; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int advWidths[] = {40, 18, 20, 18, 20, 20, 20, 20, 18, 13, 38, 20, 40 }; + + // TODO: add click tests + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 0; + int * clickStuff = NULL; + //int clickStuff[] = ; + //{ + // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent, + //}; + + const int contextBlockOutSize = 9; + gr::byte contextBlockOut[] = { 20, 1, 0, 2, 0, 0, 4, 0, 0, 0 }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupCrossLine2() +{ + m_testName = "Cross-line 2"; + //m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test CrossLine"; + m_fontFile = "grtest_xline.ttf"; + m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww"; + m_firstChar = 10; + m_fontSize = 30; // font size in points + m_prefBreak = klbHyphenBreak; // preferred break-weight + m_availWidth = 400; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_initWithPrev = true; + + const int contextBlockInSize = 9; // output from Cross-line 1 + gr::byte contextBlockIn[] = { 20, 1, 0, 2, 0, 0, 4, 0, 0, 0 }; + + // Output: + m_segWidth = 395; // physical width of segment + + const int charCnt = 13; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + false, true, true, true, true, true, true, true, true, true, true, true, true + }; + + const int glyphCnt = 15; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {30, 34, 73, 74, 75, 76, 77, 79, 79, 79, 79, 80, 6, 91, 32 }; + int xPositions[] = { 0, 40, 78, 99,119,131,143,163,196,228,260,293,314,334,355 }; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int advWidths[] = {40, 38, 20, 20, 11, 11, 20, 32, 32, 32, 32, 20, 20, 20, 40 }; + + // TODO: add click tests + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 0; + int * clickStuff = NULL; + //int clickStuff[] = ; + //{ + // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent, + //}; + + const int contextBlockOutSize = 9; + gr::byte contextBlockOut[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); + SetInputContextBlock(contextBlockInSize, contextBlockIn); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupCrossLine3() +{ + m_testName = "Cross-line 3"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test CrossLine"; + m_fontFile = "grtest_xline.ttf"; + m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww"; + m_firstChar = 23; + m_fontSize = 30; // font size in points + m_prefBreak = klbHyphenBreak; // preferred break-weight + m_availWidth = 400; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_initWithPrev = true; + + const int contextBlockInSize = 9; // output from Cross-line 2 + gr::byte contextBlockIn[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 }; + + // Output: + m_segWidth = 358; // physical width of segment + + const int charCnt = 13; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, true, false, true + }; + + const int glyphCnt = 16; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {30, 81, 6, 82, 82, 82, 82, 82, 83, 84, 85, 85, 85, 34, 8, 92 }; + int xPositions[] = { 0, 40, 60, 81,102,123,144,164,185,206,220,236,253,269,307,339 }; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int advWidths[] = {40, 20, 20, 20, 20, 20, 20, 20, 20, 14, 16, 16, 16, 38, 32, 18 }; + + // TODO: add click tests + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 0; + int * clickStuff = NULL; + //int clickStuff[] = ; + //{ + // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent, + //}; + + const int contextBlockOutSize = 9; + gr::byte contextBlockOut[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); + SetInputContextBlock(contextBlockInSize, contextBlockIn); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +void TestCase::SetupCrossLine4() +{ + m_testName = "Cross-line 4"; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test CrossLine"; + m_fontFile = "grtest_xline.ttf"; + m_text = CrossLineText(); // "abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww"; + m_firstChar = 36; + m_fontSize = 30; // font size in points + m_prefBreak = klbHyphenBreak; // preferred break-weight + m_availWidth = 400; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_initWithPrev = true; + + const int contextBlockInSize = 9; // output from Cross-line 3 + gr::byte contextBlockIn[] = { 20, 1, 0, 3, 0, 0, 4, 0, 0, 0 }; + + // Output: + m_segWidth = 248; // physical width of segment + + const int charCnt = 8; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + false, true, true, true, true, true, true, true + }; + + const int glyphCnt = 10; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + gid16 glyphList[] = { 8, 6, 86, 86, 86, 89, 89, 89, 89, 32 }; + int xPositions[] = { 0, 32, 53, 64, 76, 87,117,147,177,208 }; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + int advWidths[] = {32, 20, 11, 11, 11, 30, 30, 30, 30, 40 }; + + // TODO: add click tests + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 0; + int * clickStuff = NULL; + //int clickStuff[] = ; + //{ + // 10, 25, 1, false, 0, 24, 9, kAbsent, kAbsent, kAbsent, + //}; + + const int contextBlockOutSize = 0; + gr::byte * contextBlockOut = NULL; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); + SetInputContextBlock(contextBlockInSize, contextBlockIn); + SetOutputContextBlock(contextBlockOutSize, contextBlockOut); +} + +std::wstring TestCase::CrossLineText() +{ + // The equivalent data is in the "xlineTest.wpx" file. + std::wstring strRet; + strRet.assign(L"abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww"); + return strRet; +} + +/*---------------------------------------------------------------------------------------------- + A set of tests using Arabic: RTL, bidi, and embedded direction codes. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupArabic1() +{ + m_testName = "Arabic 1"; + //m_debug = true; + m_traceLog = false; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Arabic"; + m_fontFile = "grtest_arabic.ttf"; + m_text = ArabicText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 1000; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_segWidth = 409; // physical width of segment + + SetupArabicAux( + 61, // character count + 61); // glyph count + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,0, 1,1,1,2, 2,1,0, 3,3,4,4,5,6,7, 4,3,0, 5,3,0, 6,3,0, 7,3,0, + 8,8,0, 9,9,4,10,11,12,13, 10,9,0, 11,9,0, 12,9,0, 13,9,0, 14,14,0, + 15,15,0, 16,16,1,17, 17,16,0, 18,18,1,19, 19,18,0 // etc + }; + int attCount = sizeof(attachments) / sizeof(int); + SetAttachedClusters(attachments, attCount); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + int clickStuff[] = { + 199, 13, 37, true, 0, 35,196, kAbsent, kAbsent, kAbsent, + 396, 13, 3, false, 8, 26,399, 10, 17, 397, + 396, 8, 6, true, 3, 11,391, 9, 22, 394, + 222, 5, 32, true, 0, 35,225, kAbsent, kAbsent, kAbsent, + 217, 5, 31, false, 0, 35,215, 0, 35, 246, + }; + SetClickTests(4, clickStuff); +} + +void TestCase::SetupArabic2() +{ + m_testName = "Arabic 2"; + m_debug = false; + m_traceLog = false; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test Arabic"; + m_fontFile = "grtest_arabic.ttf"; + m_text = ArabicText(); + m_fontSize = 20; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 230; // width available for segment-break after number + m_bold = false; + m_italic = false; + m_backtrack = false; + + // Output: + m_segWidth = 193; // physical width of segment + + SetupArabicAux( + 35, // character count + 35); // glyph count + + // The x-positions are different for a shorter segment: + // 0 10 20 30 + int xPositions[] = {188,183,184,177,178,178,170,169,162,150,154,154,153,155,139,132,127,127,115,118,108,102, 84, 77, 77, 72, 65, 46, 46, 37, 31, 20, 10, 0, -6}; + SetXPositions(xPositions); +} + +void TestCase::SetupArabicAux(int charCnt, int glyphCnt) +{ + m_rtl = true; + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, // 0 - 9 + true, true, true, true, true, true, true, true, true, true, // 10 - 19 + true, true, true, true, true, true, true, true, true, true, // 20 - 29 + true, true, true, true, true, true, true, true, true, true, // 30 - 39 + true, true, true, true, true, true, true, true, true, true, // 40 - 49 + true, true, true, true, true, true, true, true, true, true, // 50 - 59 + true + }; + + // need glyphCnt elements in these arrays: + // 0 10 20 30 40 50 60 + gid16 glyphList[] = {785,658,907,1182,913,907,1192,907, 3,811,914,909,911,934,592, 3,785,909,621,911, 12, 3,321, 3,236,659,731,555,925,961, 3,992,991,990, 3,821,924,712,474,882,527, 3,411,924,950, 3,236,990,991,992,993,995,236, 3,821,769,455,290,839,620,961}; + int xPositions[] = {404,400,401, 393,394,394, 386,385,379,366,370,370,370,371,355,348,343,343,331,334,324,318,300,293,293,289,281,263,262,254,247,237,226,216,209,197,197,189,179,172,154,147,135,139,127,120,120,110, 99, 89, 79, 68, 68, 62, 50, 41, 36, 29, 19, 8, 0}; + int yPositions[] = { 0, 0, -5, 0, 0, 4, 0, 0, 0, 0, -5, -3, -2, 4, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 4, 4, 0, 6, 0, 0, 6, 0, 6, 12, 0, 0, 0, 0, 11, 6, 4, 0, 11, 0, 7, 6, 17, 6, 0, 4, 7, 18, 0, 8, 6, 10, 10, 10, 6, 11, 0, 7, 9, 7, 17, 6, 11, 0, 8, 6, 0, 10, 10, 10, 10, 10, 0, 6, 11, 9, 4, 6, 9, 11, 8}; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); +} + +std::wstring TestCase::ArabicText() +{ + std::wstring strRet; + wchar_t charData[] = { + 0x0628, 0x0628, 0x064e, 0x0644, 0x064e, 0x0654, 0x0627, 0x064e, 0x0020, 0x0686, + 0x0650, 0x0652, 0x0655, 0x06e0, 0x06a8, 0x0020, 0x0628, 0x0650, 0x06b9, 0x0652, + 0x0029, 0x0020, 0x0628, 0x0020, 0x200d, 0x062a, 0x06a8, 0x0633, 0x0670, 0x061b, + 0x0020, 0x06f1, 0x06f2, 0x06f3, 0x0020, 0x0633, 0x0670, 0x0639, 0x062f, 0x0645, + 0x067e, 0x0020, 0x0644, 0x0670, 0x060c, 0x0020, 0x202e, 0x06f1, 0x06f2, 0x06f3, + 0x06f4, 0x06f5, 0x202c, 0x0020, 0x0633, 0x0647, 0x0627, 0x0631, 0x0639, 0x0646, + 0x061b, 0x0000 + }; + strRet.assign(charData); + return strRet; +} + +/*---------------------------------------------------------------------------------------------- + A set of tests that uses Tai Viet script to test positioning. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupTaiViet1() +{ + m_testName = "Tai Viet Collisions"; + //m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test TaiViet"; + m_fontFile = "grtest_taiviet.ttf"; + m_fontSize = 36; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 2000; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_text = TaiVietText(); + + m_fset[0].id = 2001; m_fset[0].value = 2; // vowel position = final consonant + m_fset[1].id = 1051; m_fset[1].value = 0; // diacritic selection = off + m_fset[2].id = 2102; m_fset[2].value = 0; // collision avoidance = off + m_fset[3].id = 0; + + // Output: + m_segWidth = 946; // physical width of segment + + const int charCnt = 46; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, false, true, true, true, false, true, true, true, + false, false, true, true, false, true, true, false, false, true, + true, false, false, true, true, false, false, true, true, false, + false, true, true, false, true, true, false, false, true, true, + false, true, true, true, false, false + }; + + const int glyphCnt = 46; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + // 0 10 20 30 40 + gid16 glyphList[] = {59, 70, 71, 65, 59, 70, 71, 23, 32, 175, 70, 65, 55, 70, 73, 55, 175, 184,185, 55, 76, 184,185, 55, 77, 70, 185, 41, 77, 70, 23, 56,175, 65, 27, 93, 70,185, 53, 69, 81, 50, 27,175, 70, 23}; + int xPositions[] = { 0, 72, 47, 72,101, 174,149,174, 206, 281, 283, 251, 283,352, 316, 352, 418, 425,386,425,493, 495,458, 495,556,559, 528, 559, 623, 623,591,623,706, 676, 706, 776,777,738, 777, 836, 816,843,880,944,946,912}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 5, 13, 0, 0, 5, 22, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 19, 0, 0, 8, 0, 0, 0, 5, 21, 0}; + int advWidths[] = {47, 0, 24, 29, 47, 0, 24, 32, 44, 0, 0, 29, 33, 0, 36, 33, 0, 0, 26, 33, 0, 0, 26, 33, 0, 0, 26, 32, 0, 0, 32, 52, 0, 29, 32, 0, 0, 26, 39, 0, 26, 36, 32, 0, 0, 32}; + + int bbLefts[] = { 5, 45, 52, 73,106, 147,154,177, 209, 254, 257, 252, 286,326, 322, 355, 391, 414,390,428,463, 484, 462,498,540,532, 532, 562, 607, 597,594,627,679, 677, 709, 744,751,742, 784, 825, 820,849,883,917,919,915}; + int bbRights[] = {72, 72, 63, 97,174, 174,165,211, 277, 281, 283, 276, 349,352, 355, 419, 418, 422,409,491,494, 491, 481,561,553,559, 551, 621, 620, 623,628,681,706, 701, 756, 776,777,761, 835, 833, 840,882,930,944,946,949}; + int bbTops [] = {60, 50, 25, 25, 60, 50, 25, 41, 60, 49, 66, 25, 60, 50, 40, 60, 55, 65, 36, 60, 56, 74, 36, 60, -5, 55, 36, 60, -5, 50, 41, 40, 49, 25, 55, 56, 69, 36, 55, 61, 41, 40, 55, 55, 71, 41}; + int bbBottoms [] = { 0, 35, 0, 0, 0, 35, 0, 0, 0, 34, 50, 0, 0, 35, 0, 0, 39, 51, 0, 0, 40, 60, 0, 0,-27, 40, 0, 0, -27, 35, 0, 0, 34, 0, 0, 40, 54, 0, 0, 45, 0, 0, 0, 39, 56, 0}; + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,0, 1,2,0, 2,2,1,1, 3,3,0, 4,4,0, 5,6,0, 6,6,1,5, 7,7,0, + 8,8,0, 9,11,0, 10,11,0, 11,11,2,9,10, 12,12,0, 13,14,0, 14,14,1,13, + 15,15,0, 16,18,0, 17,18,0, 18,18,2,16,17, 19,19,0, 20,22,0, 21,22,0, + 22,22,2,20,21, 23,23,0, 24,26,0, 25,26,0, 26,26,2,24,25, 27,27,0, 28,30,0, + 29,30,0, 30,30,2,28,29, 31,31,0, 32,33,0, 33,33,1,32, 34,34,0, 35,37,0, + 36,37,0, 37,37,2,35,36, 38,38,0, 39,40,0, 40,40,1,39, 41,41,0, 42,42,0, + 43,45,0, 44,45,0, 45,45,2,43,44 + }; + int attCount = sizeof(attachments) / sizeof(int); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel Top, prim sel bottom, prim sel left, + // sec sel Top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 4; + int clickStuff[] = { + 55, 40, 1, true, 0,100, 46, kAbsent, kAbsent, kAbsent, + 65, 20, 1, false, 0,100, 46, kAbsent, kAbsent, kAbsent, // adjust to the left to get a valid IP? + 95, 84, 4, true, 0,100, 100, kAbsent, kAbsent, kAbsent, + 104, 40, 4, false, 0,100, 100, kAbsent, kAbsent, kAbsent + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetAttachedClusters(attachments, attCount); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + A set of tests that uses Tai Viet script to test positioning. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupTaiViet2() +{ + m_testName = "Tai Viet No Collisions"; + //m_traceLog = true; + //m_debug = true; + //m_skip = true; + + // Input: + m_fontName = L"Graphite Test TaiViet"; + m_fontFile = "grtest_taiviet.ttf"; + m_fontSize = 36; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 2000; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_text = TaiVietText(); + + m_fset[0].id = 2001; m_fset[0].value = 2; // vowel position = final consonant + m_fset[1].id = 1051; m_fset[1].value = 1; // diacritic selection = on + m_fset[2].id = 2102; m_fset[2].value = 1; // collision avoidance = off + m_fset[3].id = 0; + + // Output: + m_segWidth = 947; // physical width of segment + + const int charCnt = 46; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true + }; + + const int glyphCnt = 46; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + // 0 10 20 30 40 + gid16 glyphList[] = {59, 70, 71, 65, 59, 70, 71, 23, 32, 175, 70, 65, 55, 70, 73, 55, 175, 184,185, 55, 76, 184,185, 55, 77, 70, 185, 41, 77, 70, 23, 56,175, 65, 27, 93, 70,185, 53, 69, 81, 50, 27,175, 70, 23}; + int xPositions[] = { 0, 82, 47, 72,101, 184,149,174, 206, 281, 283, 251, 283,359, 316, 352, 418, 431,386,425,496, 508,458, 497,559,578, 530, 561, 626, 635,593,626,709, 678, 708, 778,780,740, 780, 853, 819,846,882,942,947,914}; + int yPositions[] = { 0, -3, 0, 0, 0, -3, 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, 0, 9, 0, 0, 2, 20, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -4, 0, 0, 5, 25, 0, 0, 8, 0, 0, 0, 0, 23, 0}; + int advWidths[] = {47, 0, 24, 29, 47, 0, 24, 32, 44, 0, 0, 29, 33, 0, 36, 33, 0, 0, 26, 33, 0, 0, 26, 33, 0, 0, 26, 32, 0, 0, 32, 52, 0, 29, 32, 0, 0, 26, 39, 0, 26, 36, 32, 0, 0, 32}; + + int bbLefts[] = { 5, 56, 52, 73,106, 158,154,177, 209, 254, 257, 252, 286,333, 322, 355, 391, 420,390,428,466, 497, 462,500,542,552, 534, 564, 609, 609,597,629,682, 679, 711, 747,753,744, 786, 842, 823,851,885,916,921,918}; + int bbRights[] = {72, 82, 63, 97,174, 184,165,211, 277, 281, 283, 276, 349,359, 355, 419, 418, 427,409,491,496, 504, 481,564,555,578, 553, 624, 622, 635,630,684,709, 703, 758, 778,780,763, 837, 850, 842,885,932,942,947,951}; + int bbTops [] = {60, 46, 25, 25, 60, 46, 25, 41, 60, 49, 73, 25, 60, 50, 40, 60, 50, 60, 36, 60, 54, 72, 36, 60, -5, 52, 36, 60, -5, 50, 41, 40, 45, 25, 55, 56, 75, 36, 55, 61, 41, 40, 55, 50, 73, 41}; + int bbBottoms [] = { 0, 31, 0, 0, 0, 31, 0, 0, 0, 34, 57, 0, 0, 35, 0, 0, 34, 46, 0, 0, 37, 57, 0, 0,-27, 36, 0, 0, -27, 35, 0, 0, 29, 0, 0, 40, 60, 0, 0, 45, 0, 0, 0, 34, 58, 0}; + + // Each group = glyph-index, base, number of attached, glyphs, attached-glyph-indices + int attachments[] = { + 0,0,0, 1,2,0, 2,2,1,1, 3,3,0, 4,4,0, 5,6,0, 6,6,1,5, 7,7,0, + 8,8,0, 9,11,0, 10,11,0, 11,11,2,9,10, 12,12,0, 13,14,0, 14,14,1,13, + 15,15,0, 16,18,0, 17,18,0, 18,18,2,16,17, 19,19,0, 20,22,0, 21,22,0, + 22,22,2,20,21, 23,23,0, 24,26,0, 25,26,0, 26,26,2,24,25, 27,27,0, 28,30,0, + 29,30,0, 30,30,2,28,29, 31,31,0, 32,33,0, 33,33,1,32, 34,34,0, 35,37,0, + 36,37,0, 37,37,2,35,36, 38,38,0, 39,40,0, 40,40,1,39, 41,41,0, 42,42,0, + 43,45,0, 44,45,0, 45,45,2,43,44 + }; + int attCount = sizeof(attachments) / sizeof(int); + + // Each line in clickStuff represents one click test with the following items: + // click x-coord, click y-coord, char index, assoc-prev, + // prim sel top, prim sel bottom, prim sel left, + // sec sel top, sec sel bottom, sec sel left + // Y-coordinates are offsets from segment top; ie, (0,0) is segment top-left. + const int clickTestCnt = 4; + int clickStuff[] = { + 55, 40, 2, false, 35, 65, 49, 14, 33, 82, + 65, 20, 1, false, 0,100, 50, kAbsent, kAbsent, kAbsent, + 95, 84, 4, true, 0,100, 100, kAbsent, kAbsent, kAbsent, + 104, 40, 4, false, 0,100, 100, kAbsent, kAbsent, kAbsent + }; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); + SetAttachedClusters(attachments, attCount); + SetClickTests(clickTestCnt, clickStuff); +} + +std::wstring TestCase::TaiVietText() +{ + std::wstring strRet; + wchar_t charData[] = { + 0xe00f,0xe042,0xe031,0xe02b,0xe00f,0xe042,0xe031,0xe025,0xe021,0xe033, + 0xe042,0xe02b,0xe01c,0xe042,0xe03e,0xe01c,0xe033,0xe040,0xe009,0xe01c, + 0xe039,0xe040,0xe009,0xe01c,0xe035,0xe042,0xe009,0xe024,0xe035,0xe042, + 0xe025,0xe01b,0xe033,0xe02b,0xe00a,0xe030,0xe042,0xe009,0xe01e,0xe040, + 0xe03b,0xe019,0xe00a,0xe033,0xe042,0xe025,0x0000 + }; + strRet.assign(charData); + return strRet; +} + +/*---------------------------------------------------------------------------------------------- + Set up a test where the font is bad and we revert to dumb rendering +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupDumbFallback1() +{ + m_testName = "Dumb Fallback 1"; + //m_debug = true; + m_traceLog = false; + //m_skip = true; + + // Input: + m_fontName = L"GrErr BadVersion"; + m_fontFile = "grtest_badVersion.ttf"; + m_text = RomanText(); // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_dumbFallback = true; + + // Output: + m_badFont = true; + m_segWidth = 196; // physical width of segment + + const int charCnt = 26; // number of characters in the segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true, + true, true, true, true, true, true + }; + + const int glyphCnt = 26; // number of glyphs in the segment + + // need glyphCnt elements in these arrays: + // 0 10 20 + gid16 glyphList[] = {71, 0, 0, 82, 0, 85, 73, 0, 0, 0, 0, 67, 0, 0, 75, 0, 43, 0, 79, 0, 0, 0, 0, 72, 72, 75}; + int xPositions[] = { 0, 7, 15, 23, 31, 39, 46, 54, 62, 70, 78, 86, 93,101,109,114,122,128,136,149,157,165,173,181,186,192}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 7, 8, 8, 8, 8, 6, 8, 8, 8, 8, 8, 7, 8, 8, 4, 8, 5, 8, 12, 8, 8, 8, 8, 5, 5, 4}; + + const int clickTestCnt = 0; + int * clickStuff = NULL; + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetBBs(NULL, NULL, NULL, NULL); + SetInsPtFlags(insPtFlags); + SetClickTests(clickTestCnt, clickStuff); +} + +/*---------------------------------------------------------------------------------------------- + Now make sure we will get a crash when we turn dumb rendering off for the same font. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupDumbFallback2() +{ + m_testName = "Dumb Fallback 2"; + //m_debug = true; + m_traceLog = false; + //m_skip = true; + + // Input: + m_fontName = L"GrErr BadVersion"; + m_fontFile = "grtest_badVersion.ttf"; + m_text = L"This is a test."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_dumbFallback = false; + + // Output: + m_badFont = true; + m_noSegment = true; + m_segWidth = 0; // physical width of segment + + const int charCnt = 0; // number of characters in the segment + + const int glyphCnt = 0; // number of glyphs in the segment + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); +} + +/*---------------------------------------------------------------------------------------------- + Now make sure we will get a crash when we turn dumb rendering off for the same font. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetupBadFont() +{ + m_testName = "Bad Font"; + //m_debug = true; + m_traceLog = false; + m_skip = true; + + // Input: + // The font has been corrupted so that the size of the cmap in the directory is invalid. + m_fontName = L"Graphite Test Roman"; + m_fontFile = "grtest_badCmap.ttf"; + m_text = L"This is a test."; // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_rtl = false; + m_backtrack = false; + m_dumbFallback = true; // wants to do dumb fall-back, but can't because the font is totally invalid + + // Output: + m_badFont = true; + m_noSegment = true; + m_segWidth = 0; // physical width of segment + + const int charCnt = 0; // number of characters in the segment + + const int glyphCnt = 0; // number of glyphs in the segment + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); +} +// *** Add more methods here. *** + + +//:>******************************************************************************************** +//:> Utility methods. +//:>******************************************************************************************** + +/*---------------------------------------------------------------------------------------------- + Delete the list of tests. +----------------------------------------------------------------------------------------------*/ +void TestCase::DeleteTests() +{ + delete[] g_ptcaseList; +} + +/*---------------------------------------------------------------------------------------------- + Constructor: initialize test case with default values. +----------------------------------------------------------------------------------------------*/ +TestCase::TestCase() +{ + m_testName = "Unknown"; + m_debug = false; + m_traceLog = false; + m_skip = false; + + m_fontName.erase(); + m_fontFile.erase(); + m_text.erase(); // text to render + m_fontSize = 12; // font size in points + m_prefBreak = klbWordBreak; // preferred break-weight + m_worstBreak = klbClipBreak; // worst-case break-weight + m_availWidth = 500; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + m_twsh = ktwshAll; + m_paraRtl = false; + m_firstChar = 0; + m_contextBlockInSize = 0; + m_contextBlockIn = NULL; + m_initWithPrev = false; + memset(m_fset, 0, MAXFEAT * sizeof(FeatureSetting)); + m_dumbFallback = true; + + m_badFont = false; + m_noSegment = false; // yes, a segment should be generated + m_charCount = 0; + m_glyphCount = 0; + m_glyphArray = NULL; + m_xPositions = NULL; + m_yPositions = NULL; + m_advWidths = NULL; + m_bbLefts = NULL; + m_bbRights = NULL; + m_bbTops = NULL; + m_bbBottoms = NULL; + m_insPointFlags = NULL; + m_charsToGlyphs = NULL; + m_c2gCount = 0; + m_attGlyphs = NULL; + m_attGCount = 0; + m_contextBlockOutSize = 0; + m_contextBlockOut = NULL; + + m_clickTestCount = 0; + m_clickTests = NULL; +} + +/*---------------------------------------------------------------------------------------------- + Destructor. +----------------------------------------------------------------------------------------------*/ +TestCase::~TestCase() +{ + delete[] m_glyphArray; + delete[] m_xPositions; + delete[] m_yPositions; + delete[] m_advWidths; + delete[] m_bbLefts; + delete[] m_bbRights; + delete[] m_bbTops; + delete[] m_bbBottoms; + delete[] m_insPointFlags; + delete[] m_charsToGlyphs; + delete[] m_attGlyphs; + delete[] m_clickTests; + delete[] m_contextBlockIn; + delete[] m_contextBlockOut; +} + +/*---------------------------------------------------------------------------------------------- + Setters. +----------------------------------------------------------------------------------------------*/ +void TestCase::SetCharCount(int charCount) +{ + m_charCount = charCount; + m_insPointFlags = new bool[charCount]; +} + +void TestCase::SetGlyphCount(int glyphCount) +{ + m_glyphCount = glyphCount; + m_glyphArray = new gid16[glyphCount]; + m_xPositions = new int[glyphCount]; + m_yPositions = new int[glyphCount]; + m_advWidths = new int[glyphCount]; + m_bbLefts = new int[glyphCount]; + m_bbRights = new int[glyphCount]; + m_bbTops = new int[glyphCount]; + m_bbBottoms = new int[glyphCount]; +} + +void TestCase::SetGlyphList(gid16 * glyphList) +{ + for (int i = 0; i < m_glyphCount; i++) + m_glyphArray[i] = glyphList[i]; +} + +void TestCase::SetXPositions(int * xPosList) +{ + for (int i = 0; i < m_glyphCount; i++) + m_xPositions[i] = xPosList[i]; +} + +void TestCase::SetYPositions(int * yPosList) +{ + for (int i = 0; i < m_glyphCount; i++) + m_yPositions[i] = yPosList[i]; +} + +void TestCase::SetAdvWidths(int * advWidths) +{ + for (int i = 0; i < m_glyphCount; i++) + m_advWidths[i] = advWidths[i]; +} + +void TestCase::SetBBs(int * bbLefts, int * bbRights, int * bbTops, int * bbBottoms) +{ + if (bbLefts == NULL) // no bb tests + { + delete[] m_bbLefts; + delete[] m_bbRights; + delete[] m_bbTops; + delete[] m_bbBottoms; + m_bbLefts = NULL; + m_bbRights = NULL; + m_bbTops = NULL; + m_bbBottoms = NULL; + return; + } + + for (int i = 0; i < m_glyphCount; i++) + { + m_bbLefts[i] = bbLefts[i]; + m_bbRights[i] = bbRights[i]; + m_bbTops[i] = bbTops[i]; + m_bbBottoms[i] = bbBottoms[i]; + } +} + +void TestCase::SetInsPtFlags(bool * flags) +{ + for (int i = 0; i < m_charCount; i++) + m_insPointFlags[i] = flags[i]; +} + +void TestCase::SetCharsToGlyphs(int * stuff, int count) +{ + m_c2gCount = count; + m_charsToGlyphs = new int[count]; + for (int i = 0; i < count; i++) + m_charsToGlyphs[i] = stuff[i]; +} + +void TestCase::SetAttachedClusters(int * stuff, int count) +{ + m_attGCount = count; + m_attGlyphs = new int[count]; + for (int i = 0; i < count; i++) + m_attGlyphs[i] = stuff[i]; +} + +void TestCase::SetClickTests(int clickTestCount, int * clickStuff) +{ + const int fc = ClickTest::fieldCnt; + + m_clickTestCount = clickTestCount; + m_clickTests = new ClickTest[clickTestCount]; + for (int i = 0; i < clickTestCount; i++) + { + m_clickTests[i].xClick = clickStuff[(i * fc) + 0]; + m_clickTests[i].yClick = clickStuff[(i * fc) + 1]; + m_clickTests[i].charIndex = clickStuff[(i * fc) + 2]; + m_clickTests[i].assocPrev = clickStuff[(i * fc) + 3]; + m_clickTests[i].sel1Top = clickStuff[(i * fc) + 4]; + m_clickTests[i].sel1Bottom = clickStuff[(i * fc) + 5]; + m_clickTests[i].sel1Left = clickStuff[(i * fc) + 6]; + m_clickTests[i].sel2Top = clickStuff[(i * fc) + 7]; + m_clickTests[i].sel2Bottom = clickStuff[(i * fc) + 8]; + m_clickTests[i].sel2Left = clickStuff[(i * fc) + 9]; + } +} + +void TestCase::SetInputContextBlock(int contextBlockInSize, gr::byte * pContextBlockIn) +{ + m_contextBlockInSize = contextBlockInSize; + if (contextBlockInSize == 0) + { + m_contextBlockIn = NULL; + } + else + { + m_contextBlockIn = new gr::byte[contextBlockInSize]; + std::copy(pContextBlockIn, pContextBlockIn + contextBlockInSize, m_contextBlockIn); + } +} + +void TestCase::SetOutputContextBlock(int contextBlockOutSize, gr::byte * pContextBlockOut) +{ + m_contextBlockOutSize = contextBlockOutSize; + m_contextBlockOut = new gr::byte[contextBlockOutSize]; + std::copy(pContextBlockOut, pContextBlockOut + contextBlockOutSize, m_contextBlockOut); +} + + + + +void TestCase::SetupBugTest() +{ + m_testName = "Bug Test"; + m_traceLog = true; + m_debug = true; + m_skip = true; + + // Input: + m_fontName = L"Padauk"; + m_fontFile = "grtest_infinity.ttf"; + + wchar_t charData[] = { 0x101e, 0x1032, 0x1015, 0x103c, 0x103d, 0x103e, 0x102d, 0x1038, 0x0000 }; + m_text.assign(charData); + int charCnt = 8; + + m_fontSize = 20; // font size in points + m_prefBreak = klbWsBreak; // preferred break-weight + m_worstBreak = klbHyphenBreak; // worst-case break-weight + m_availWidth = 1000; // width available for segment + m_bold = false; + m_italic = false; + m_backtrack = false; + m_rtl = false; + + // Output: + m_noSegment = false; + m_segWidth = 52; // physical width of segment + + // need charCnt elements in this array: + bool insPtFlags[] = { + true, false, true, true, false, false, false, true + }; + + int glyphCnt = 7; + // need glyphCnt elements in these arrays: + gid16 glyphList[] = {105,174,158,202,231,162,231}; + int xPositions[] = { 0, 17, 20, 22, 28, 29, 38}; + int yPositions[] = { 0, 0, 0, 0, 0, 0, 0}; + int advWidths[] = { 17, 2, 9, 4, 0, 10, 0}; + + int bbLefts[] = { 0, 10, 21, 23, 23, 30, 33}; + int bbRights[] = { 16, 19, 28, 25, 28, 39, 38}; + int bbTops[] = { 7, 7, 7, -1, 15, 7, 15}; + int bbBottoms[] = { 0, -7, -1, -7, 9, 0, 9}; + + // Each group = char-index, number of glyphs, glyph-indices. + int charsToGlyphs[] = { + 0, 1, 0, 1, 1, 1, 2, 1, 3, 3, 1, 2, 4, 1, 4, 5, 0, 6, 1, 5, 7, 1, 6 + }; + int c2gCount = sizeof(charsToGlyphs) / sizeof(int); + + // Finish setting up test case. + SetCharCount(charCnt); + SetGlyphCount(glyphCnt); + SetGlyphList(glyphList); + SetXPositions(xPositions); + SetYPositions(yPositions); + SetAdvWidths(advWidths); + SetCharsToGlyphs(charsToGlyphs, c2gCount); + SetBBs(bbLefts, bbRights, bbTops, bbBottoms); + SetInsPtFlags(insPtFlags); +} diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.h b/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.h index d18fd22b126..68258929a1f 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.h +++ b/Build/source/libs/graphite-engine/test/RegressionTest/TestCase.h @@ -1,243 +1,245 @@ -/*--------------------------------------------------------------------*//*:Ignore this sentence.
-Copyright (C) 2004 SIL International. All rights reserved.
-
-Distributable under the terms of either the Common Public License or the
-GNU Lesser General Public License, as specified in the LICENSING.txt file.
-
-File: TestCase.h
-Responsibility: Sharon Correll
-Last reviewed: Not yet.
-
-Description:
- Definition of TestCase class for Graphite regression test program.
--------------------------------------------------------------------------------*//*:End Ignore*/
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-#ifndef TESTCASE_H
-#define TESTCASE_H 1
-
-#define NO_EXCEPTIONS 1
-
-class TestCase
-{
-public:
- // Methods to set up test cases.
- void SetupSimpleTest();
- void SetupSimpleBacktrackTest();
- void SetupBurmese1();
- void SetupBurmese2();
- void SetupBurmese3();
- void SetupBurmese4();
- void SetupRoman();
- void SetupRomanFeatures();
- void SetupStackingAndBridging();
- void SetupNoWhiteSpace();
- void SetupNoWhiteSpaceNoSeg();
- void SetupOnlyWhiteSpace();
- void SetupCrossLine1();
- void SetupCrossLine2();
- void SetupCrossLine3();
- void SetupCrossLine4();
- void SetupArabic1();
- void SetupArabic2();
- void SetupTaiViet1();
- void SetupTaiViet2();
- void SetupDumbFallback1();
- void SetupDumbFallback2();
- void SetupBadFont();
- // *** Add more methods here. ***
-
-protected:
- // Auxiliary functions to set up test cases.
- void SetupBurmeseAux(int charCount, int glyphCount, int clickTestCount);
- void SetupArabicAux(int charCount, int glyphCount);
- std::wstring BurmeseText();
- std::wstring RomanText();
- std::wstring CrossLineText();
- std::wstring ArabicText();
- std::wstring TaiVietText();
-
-public:
- const static int kAbsent = -100; // not present in data
-
-public:
- // constructor:
- TestCase();
- // destructor:
- ~TestCase();
-
- static int SetupTests(TestCase **);
- static void DeleteTests();
-
- // Getters:
- std::string TestName() { return m_testName; }
- bool RunDebugger() { return m_debug; }
- bool TraceLog() { return m_traceLog; }
- bool Skip() { return m_skip; }
-
- std::wstring Text() { return m_text; }
- std::wstring FontName() { return m_fontName; }
- std::string FontFile() { return m_fontFile; }
- size_t FontSize() { return m_fontSize; }
- LineBrk PrefBreak() { return m_prefBreak; }
- LineBrk WorstBreak() { return m_worstBreak; }
- int FeatureID(int i) { return m_fset[i].id; }
- int FeatureValue(int i) { return m_fset[i].value; }
- FeatureSetting * Features() { return m_fset; }
- int AvailWidth() { return m_availWidth; }
- bool Backtrack() { return m_backtrack; }
- TrWsHandling Twsh() { return m_twsh; }
- bool Rtl() { return m_rtl; }
- bool ParaRtl() { return m_paraRtl; }
- size_t FirstChar() { return m_firstChar; }
- bool DumbFallback() { return m_dumbFallback; }
- size_t InputContextBlock(gr::byte ** ppContextBlock)
- {
- *ppContextBlock = m_contextBlockIn;
- return m_contextBlockInSize;
- }
-
- bool InitWithPrevSeg() { return m_initWithPrev; }
- bool BadFont() { return m_badFont; }
- bool NoSegment() { return m_noSegment; }
- int SegWidth() { return m_segWidth; }
- int CharCount() { return m_charCount; }
- int GlyphCount() { return m_glyphCount; }
-
- int GlyphID(int i) { return m_glyphArray[i]; }
- int XPos(int i) { return m_xPositions[i]; }
- int YPos(int i) { return m_yPositions[i]; }
- int AdvWidth(int i) { return m_advWidths[i]; }
- int BbLeft(int i) { return m_bbLefts[i]; }
- int BbRight(int i) { return m_bbRights[i]; }
- int BbTop(int i) { return m_bbTops[i]; }
- int BbBottom(int i) { return m_bbBottoms[i]; }
- bool BbTests() { return (m_bbLefts != NULL); }
-
- int InsPtFlag(int i) { return m_insPointFlags[i]; }
-
- int CharToGlyphCount() { return m_c2gCount; }
- int CharToGlyphItem(int i) { return m_charsToGlyphs[i]; }
- int AttachedGlyphCount() { return m_attGCount; } // that is, the lenght of the data
- int AttachedGlyphItem(int i) { return m_attGlyphs[i]; }
-
- int NumberOfClickTests() { return m_clickTestCount; }
- int XClick(int i) { return m_clickTests[i].xClick; }
- int YClick(int i) { return m_clickTests[i].yClick; }
- int ClickCharIndex(int i) { return m_clickTests[i].charIndex; }
- bool ClickAssocPrev(int i) { return (bool)m_clickTests[i].assocPrev; }
- int Sel1Top(int i) { return m_clickTests[i].sel1Top; }
- int Sel1Bottom(int i) { return m_clickTests[i].sel1Bottom; }
- int Sel1Left(int i) { return m_clickTests[i].sel1Left; }
- int Sel2Top(int i) { return m_clickTests[i].sel2Top; }
- int Sel2Bottom(int i) { return m_clickTests[i].sel2Bottom; }
- int Sel2Left(int i) { return m_clickTests[i].sel2Left; }
- size_t OutputContextBlockSize() { return m_contextBlockOutSize; }
- bool CompareContextBlock(gr::byte * pResult)
- {
- for (size_t i = 0; i < m_contextBlockOutSize; i++)
- {
- if (m_contextBlockOut[i] != pResult[i])
- return false;
- }
- return true;
- }
-
- struct ClickTest
- {
- int xClick;
- int yClick;
- int charIndex;
- int assocPrev; // boolean: 0 or 1
- int sel1Top;
- int sel1Bottom;
- int sel1Left; // we only need left or right, not both
- int sel2Top;
- int sel2Bottom;
- int sel2Left;
-
- const static int fieldCnt = 10;
- };
-
-protected:
- std::string m_testName;
- bool m_debug; // break into the debugger when running this test
- bool m_traceLog; // generate a logging file (tracelog.txt) for this test; if this is turned on for
- // more than one test, the tests will be appended
- bool m_skip;
-
-#define MAXFEAT 10
-
- // Input parameters:
- std::wstring m_text; // default: none
- std::wstring m_fontName; // default: empty
- std::string m_fontFile; // default: empty
- size_t m_fontSize; // default: 12
- LineBrk m_prefBreak; // default: word-break
- LineBrk m_worstBreak; // default: clip-break
- FeatureSetting m_fset[MAXFEAT]; // default: none
- int m_availWidth; // default: 100
- bool m_bold; // default: false
- bool m_italic; // default: false
- bool m_rtl; // default: false
- bool m_backtrack; // default: false
- TrWsHandling m_twsh; // default: ktwshAll
- bool m_paraRtl; // default: false
- size_t m_firstChar; // default: 0
- size_t m_contextBlockInSize; // default: 0
- gr::byte * m_contextBlockIn; // default: NULL -- DELETE
- bool m_initWithPrev; // default: false
- bool m_dumbFallback; // default: true
- // start of line flag
- // resolution
- // justification
-
- // Output:
- bool m_badFont; // default: false
- bool m_noSegment; // no segment should be generated
- int m_segWidth;
- int m_charCount;
- int m_glyphCount;
- gid16 * m_glyphArray;
- int * m_xPositions;
- int * m_yPositions;
- int * m_advWidths;
- int * m_bbLefts;
- int * m_bbRights;
- int * m_bbTops;
- int * m_bbBottoms;
- bool * m_insPointFlags;
- int * m_charsToGlyphs; // char-to-glyph mappings
- int m_c2gCount;
- int * m_attGlyphs; // attachment clusters
- int m_attGCount;
- int m_clickTestCount;
- ClickTest * m_clickTests;
- size_t m_contextBlockOutSize;
- gr::byte * m_contextBlockOut;
- // glyphs-to-chars
- // pdichwContext
- // arrow key behavior
- // etc.
-
- // Setters:
- void SetCharCount(int charCount);
- void SetGlyphCount(int glyphCount);
- void SetGlyphList(gid16 * glyphList);
- void SetXPositions(int * posList);
- void SetYPositions(int * posList);
- void SetAdvWidths(int * advWidths);
- void SetBBs(int * bbLefts, int * bbRights, int * bbTops, int * bbBottoms);
- void SetInsPtFlags(bool * flags);
- void SetCharsToGlyphs(int * stuff, int count);
- void SetAttachedClusters(int * stuff, int count);
- void SetClickTests(int clickTestCount, int * clickStuff);
- void SetInputContextBlock(int contextBlockInSize, gr::byte * contextBlockIn);
- void SetOutputContextBlock(int contextBlockOutSize, gr::byte * contextBlockIn);
-};
-
-
-#endif // !TESTCASE_H
-
+/*--------------------------------------------------------------------*//*:Ignore this sentence. +Copyright (C) 2004 SIL International. All rights reserved. + +Distributable under the terms of either the Common Public License or the +GNU Lesser General Public License, as specified in the LICENSING.txt file. + +File: TestCase.h +Responsibility: Sharon Correll +Last reviewed: Not yet. + +Description: + Definition of TestCase class for Graphite regression test program. +-------------------------------------------------------------------------------*//*:End Ignore*/ + +#ifdef _MSC_VER +#pragma once +#endif +#ifndef TESTCASE_H +#define TESTCASE_H 1 + +#define NO_EXCEPTIONS 1 + +class TestCase +{ +public: + // Methods to set up test cases. + void SetupSimpleTest(); + void SetupSimpleBacktrackTest(); + void SetupSurrogateTest(); // TODO: add a test for UTF-8 + void SetupBurmese1(); + void SetupBurmese2(); + void SetupBurmese3(); + void SetupBurmese4(); + void SetupRoman(); + void SetupRomanFeatures(); + void SetupStackingAndBridging(); + void SetupNoWhiteSpace(); + void SetupNoWhiteSpaceNoSeg(); + void SetupOnlyWhiteSpace(); + void SetupCrossLine1(); + void SetupCrossLine2(); + void SetupCrossLine3(); + void SetupCrossLine4(); + void SetupArabic1(); + void SetupArabic2(); + void SetupTaiViet1(); + void SetupTaiViet2(); + void SetupDumbFallback1(); + void SetupDumbFallback2(); + void SetupBadFont(); + void SetupBugTest(); + // *** Add more methods here. *** + +protected: + // Auxiliary functions to set up test cases. + void SetupBurmeseAux(int charCount, int glyphCount, int clickTestCount); + void SetupArabicAux(int charCount, int glyphCount); + std::wstring BurmeseText(); + std::wstring RomanText(); + std::wstring CrossLineText(); + std::wstring ArabicText(); + std::wstring TaiVietText(); + +public: + const static int kAbsent = -100; // not present in data + +public: + // constructor: + TestCase(); + // destructor: + ~TestCase(); + + static int SetupTests(TestCase **); + static void DeleteTests(); + + // Getters: + std::string TestName() { return m_testName; } + bool RunDebugger() { return m_debug; } + bool TraceLog() { return m_traceLog; } + bool Skip() { return m_skip; } + + std::wstring Text() { return m_text; } + std::wstring FontName() { return m_fontName; } + std::string FontFile() { return m_fontFile; } + size_t FontSize() { return m_fontSize; } + LineBrk PrefBreak() { return m_prefBreak; } + LineBrk WorstBreak() { return m_worstBreak; } + int FeatureID(int i) { return m_fset[i].id; } + int FeatureValue(int i) { return m_fset[i].value; } + FeatureSetting * Features() { return m_fset; } + int AvailWidth() { return m_availWidth; } + bool Backtrack() { return m_backtrack; } + TrWsHandling Twsh() { return m_twsh; } + bool Rtl() { return m_rtl; } + bool ParaRtl() { return m_paraRtl; } + size_t FirstChar() { return m_firstChar; } + bool DumbFallback() { return m_dumbFallback; } + size_t InputContextBlock(gr::byte ** ppContextBlock) + { + *ppContextBlock = m_contextBlockIn; + return m_contextBlockInSize; + } + + bool InitWithPrevSeg() { return m_initWithPrev; } + bool BadFont() { return m_badFont; } + bool NoSegment() { return m_noSegment; } + int SegWidth() { return m_segWidth; } + int CharCount() { return m_charCount; } + int GlyphCount() { return m_glyphCount; } + + int GlyphID(int i) { return m_glyphArray[i]; } + int XPos(int i) { return m_xPositions[i]; } + int YPos(int i) { return m_yPositions[i]; } + int AdvWidth(int i) { return m_advWidths[i]; } + int BbLeft(int i) { return m_bbLefts[i]; } + int BbRight(int i) { return m_bbRights[i]; } + int BbTop(int i) { return m_bbTops[i]; } + int BbBottom(int i) { return m_bbBottoms[i]; } + bool BbTests() { return (m_bbLefts != NULL); } + + int InsPtFlag(int i) { return m_insPointFlags[i]; } + + int CharToGlyphCount() { return m_c2gCount; } + int CharToGlyphItem(int i) { return m_charsToGlyphs[i]; } + int AttachedGlyphCount() { return m_attGCount; } // that is, the lenght of the data + int AttachedGlyphItem(int i) { return m_attGlyphs[i]; } + + int NumberOfClickTests() { return m_clickTestCount; } + int XClick(int i) { return m_clickTests[i].xClick; } + int YClick(int i) { return m_clickTests[i].yClick; } + int ClickCharIndex(int i) { return m_clickTests[i].charIndex; } + bool ClickAssocPrev(int i) { return (bool)m_clickTests[i].assocPrev; } + int Sel1Top(int i) { return m_clickTests[i].sel1Top; } + int Sel1Bottom(int i) { return m_clickTests[i].sel1Bottom; } + int Sel1Left(int i) { return m_clickTests[i].sel1Left; } + int Sel2Top(int i) { return m_clickTests[i].sel2Top; } + int Sel2Bottom(int i) { return m_clickTests[i].sel2Bottom; } + int Sel2Left(int i) { return m_clickTests[i].sel2Left; } + size_t OutputContextBlockSize() { return m_contextBlockOutSize; } + bool CompareContextBlock(gr::byte * pResult) + { + for (size_t i = 0; i < m_contextBlockOutSize; i++) + { + if (m_contextBlockOut[i] != pResult[i]) + return false; + } + return true; + } + + struct ClickTest + { + int xClick; + int yClick; + int charIndex; + int assocPrev; // boolean: 0 or 1 + int sel1Top; + int sel1Bottom; + int sel1Left; // we only need left or right, not both + int sel2Top; + int sel2Bottom; + int sel2Left; + + const static int fieldCnt = 10; + }; + +protected: + std::string m_testName; + bool m_debug; // break into the debugger when running this test + bool m_traceLog; // generate a logging file (tracelog.txt) for this test; if this is turned on for + // more than one test, the tests will be appended + bool m_skip; + +#define MAXFEAT 10 + + // Input parameters: + std::wstring m_text; // default: none + std::wstring m_fontName; // default: empty + std::string m_fontFile; // default: empty + size_t m_fontSize; // default: 12 + LineBrk m_prefBreak; // default: word-break + LineBrk m_worstBreak; // default: clip-break + FeatureSetting m_fset[MAXFEAT]; // default: none + int m_availWidth; // default: 100 + bool m_bold; // default: false + bool m_italic; // default: false + bool m_rtl; // default: false + bool m_backtrack; // default: false + TrWsHandling m_twsh; // default: ktwshAll + bool m_paraRtl; // default: false + size_t m_firstChar; // default: 0 + size_t m_contextBlockInSize; // default: 0 + gr::byte * m_contextBlockIn; // default: NULL -- DELETE + bool m_initWithPrev; // default: false + bool m_dumbFallback; // default: true + // start of line flag + // resolution + // justification + + // Output: + bool m_badFont; // default: false + bool m_noSegment; // no segment should be generated + int m_segWidth; + int m_charCount; + int m_glyphCount; + gid16 * m_glyphArray; + int * m_xPositions; + int * m_yPositions; + int * m_advWidths; + int * m_bbLefts; + int * m_bbRights; + int * m_bbTops; + int * m_bbBottoms; + bool * m_insPointFlags; + int * m_charsToGlyphs; // char-to-glyph mappings + int m_c2gCount; + int * m_attGlyphs; // attachment clusters + int m_attGCount; + int m_clickTestCount; + ClickTest * m_clickTests; + size_t m_contextBlockOutSize; + gr::byte * m_contextBlockOut; + // glyphs-to-chars + // pdichwContext + // arrow key behavior + // etc. + + // Setters: + void SetCharCount(int charCount); + void SetGlyphCount(int glyphCount); + void SetGlyphList(gid16 * glyphList); + void SetXPositions(int * posList); + void SetYPositions(int * posList); + void SetAdvWidths(int * advWidths); + void SetBBs(int * bbLefts, int * bbRights, int * bbTops, int * bbBottoms); + void SetInsPtFlags(bool * flags); + void SetCharsToGlyphs(int * stuff, int count); + void SetAttachedClusters(int * stuff, int count); + void SetClickTests(int clickTestCount, int * clickStuff); + void SetInputContextBlock(int contextBlockInSize, gr::byte * contextBlockIn); + void SetOutputContextBlock(int contextBlockOutSize, gr::byte * contextBlockIn); +}; + + +#endif // !TESTCASE_H + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/arabicText.wpx b/Build/source/libs/graphite-engine/test/RegressionTest/arabicText.wpx index 1300d4e3ae5..62fee81be5b 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/arabicText.wpx +++ b/Build/source/libs/graphite-engine/test/RegressionTest/arabicText.wpx @@ -1,137 +1,137 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd">
-<WpDoc wpxVersion="2.0">
-
-<Languages>
- <LgWritingSystem id="arb" language="arb" type="ISO-639-2">
- <Name24>
- <AUni ws="en">Arabic, Standard</AUni>
- </Name24>
- <Abbr24>
- <AUni ws="en">Ara</AUni>
- </Abbr24>
- <Locale24><Integer val="1033"/></Locale24>
- <RightToLeft24><Boolean val="true"/></RightToLeft24>
- <DefaultSerif24><Uni>Scheherazade Graphite Alpha</Uni></DefaultSerif24>
- <DefaultSansSerif24><Uni>Scheherazade Graphite Alpha</Uni></DefaultSansSerif24>
- <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24>
- <DefaultMonospace24><Uni>Courier</Uni></DefaultMonospace24>
- <ICULocale24><Uni>arb</Uni></ICULocale24>
- <KeyboardType24><Uni>standard</Uni></KeyboardType24>
- <KeymanKeyboard24><Uni>Arabic Demo</Uni></KeymanKeyboard24>
- <Collations24>
- <LgCollation>
- <Name30>
- <AUni ws="en">DefaultCollation</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30>
- </LgCollation>
- </Collations24>
- </LgWritingSystem>
-</Languages>
-
-<Styles>
- <StStyle>
- <Name17><Uni>Normal</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni></Uni></BasedOn17>
- <Next17><Uni>Normal</Uni></Next17>
- <Rules17>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Bulleted List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Bulleted List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 1</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 1</Uni></Next17>
- <Rules17>
- <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 2</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 2</Uni></Next17>
- <Rules17>
- <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 3</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 3</Uni></Next17>
- <Rules17>
- <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Numbered List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Numbered List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="10"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>External Link</Uni></Name17>
- <Type17><Integer val="1"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>External Link</Uni></Next17>
- <Rules17>
- <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/>
- </Rules17>
- </StStyle>
-</Styles>
-
-<Body docRightToLeft="false">
- <StTxtPara>
- <StyleRules15>
- <Prop spaceBefore="12000" spaceAfter="12000" rightToLeft="1" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="arb" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Arabic" fontVariations="1051=1,1030=0">ببَلَٔاَ چِْٕ۠ڨ بِڹْ) ب تڨسٰ؛ ۱۲۳ سٰعدمپ لٰ، ۱۲۳۴۵ سهارعن؛</Run>
- </Str>
- </Contents16>
- </StTxtPara>
-</Body>
-
-<PageSetup>
- <PageInfo>
- <TopMargin9999><Integer val="72000"/></TopMargin9999>
- <BottomMargin9999><Integer val="72000"/></BottomMargin9999>
- <LeftMargin9999><Integer val="90000"/></LeftMargin9999>
- <RightMargin9999><Integer val="90000"/></RightMargin9999>
- <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999>
- <FooterMargin9999><Integer val="36000"/></FooterMargin9999>
- <PageSize9999><Integer val="0"/></PageSize9999>
- <PageHeight9999><Integer val="792000"/></PageHeight9999>
- <PageWidth9999><Integer val="612000"/></PageWidth9999>
- <PageOrientation9999><Integer val="0"/></PageOrientation9999>
- <Header9999>
- <Str>
- <Run ws="en">arabicText.wpx</Run>
- </Str>
- </Header9999>
- <Footer9999>
- <Str>
- <Run ws="en">&[page],&[date]</Run>
- </Str>
- </Footer9999>
- </PageInfo>
-</PageSetup>
-
-</WpDoc>
+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd"> +<WpDoc wpxVersion="2.0"> + +<Languages> + <LgWritingSystem id="arb" language="arb" type="ISO-639-2"> + <Name24> + <AUni ws="en">Arabic, Standard</AUni> + </Name24> + <Abbr24> + <AUni ws="en">Ara</AUni> + </Abbr24> + <Locale24><Integer val="1033"/></Locale24> + <RightToLeft24><Boolean val="true"/></RightToLeft24> + <DefaultSerif24><Uni>Scheherazade Graphite Alpha</Uni></DefaultSerif24> + <DefaultSansSerif24><Uni>Scheherazade Graphite Alpha</Uni></DefaultSansSerif24> + <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24> + <DefaultMonospace24><Uni>Courier</Uni></DefaultMonospace24> + <ICULocale24><Uni>arb</Uni></ICULocale24> + <KeyboardType24><Uni>standard</Uni></KeyboardType24> + <KeymanKeyboard24><Uni>Arabic Demo</Uni></KeymanKeyboard24> + <Collations24> + <LgCollation> + <Name30> + <AUni ws="en">DefaultCollation</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30> + </LgCollation> + </Collations24> + </LgWritingSystem> +</Languages> + +<Styles> + <StStyle> + <Name17><Uni>Normal</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni></Uni></BasedOn17> + <Next17><Uni>Normal</Uni></Next17> + <Rules17> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Bulleted List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Bulleted List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 1</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 1</Uni></Next17> + <Rules17> + <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 2</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 2</Uni></Next17> + <Rules17> + <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 3</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 3</Uni></Next17> + <Rules17> + <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Numbered List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Numbered List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="10"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>External Link</Uni></Name17> + <Type17><Integer val="1"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>External Link</Uni></Next17> + <Rules17> + <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/> + </Rules17> + </StStyle> +</Styles> + +<Body docRightToLeft="false"> + <StTxtPara> + <StyleRules15> + <Prop spaceBefore="12000" spaceAfter="12000" rightToLeft="1" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="arb" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Arabic" fontVariations="1051=1,1030=0">ببَلَٔاَ چِْٕ۠ڨ بِڹْ) ب تڨسٰ؛ ۱۲۳ سٰعدمپ لٰ، ۱۲۳۴۵ سهارعن؛</Run> + </Str> + </Contents16> + </StTxtPara> +</Body> + +<PageSetup> + <PageInfo> + <TopMargin9999><Integer val="72000"/></TopMargin9999> + <BottomMargin9999><Integer val="72000"/></BottomMargin9999> + <LeftMargin9999><Integer val="90000"/></LeftMargin9999> + <RightMargin9999><Integer val="90000"/></RightMargin9999> + <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999> + <FooterMargin9999><Integer val="36000"/></FooterMargin9999> + <PageSize9999><Integer val="0"/></PageSize9999> + <PageHeight9999><Integer val="792000"/></PageHeight9999> + <PageWidth9999><Integer val="612000"/></PageWidth9999> + <PageOrientation9999><Integer val="0"/></PageOrientation9999> + <Header9999> + <Str> + <Run ws="en">arabicText.wpx</Run> + </Str> + </Header9999> + <Footer9999> + <Str> + <Run ws="en">&[page],&[date]</Run> + </Str> + </Footer9999> + </PageInfo> +</PageSetup> + +</WpDoc> diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/bridgingStackingText.wpx b/Build/source/libs/graphite-engine/test/RegressionTest/bridgingStackingText.wpx index 2682bad84f6..d91ecea8262 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/bridgingStackingText.wpx +++ b/Build/source/libs/graphite-engine/test/RegressionTest/bridgingStackingText.wpx @@ -1,158 +1,158 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd">
-<WpDoc wpxVersion="2.0">
-
-<Languages>
- <LgWritingSystem id="en" language="en" type="ISO-639-1">
- <Name24>
- <AUni ws="en">English</AUni>
- </Name24>
- <Abbr24>
- <AUni ws="en">Eng</AUni>
- </Abbr24>
- <Description24>
- <AStr ws="en">
- <Run ws="en">The standard alphabetic representation of English (United States style).</Run>
- </AStr>
- </Description24>
- <Locale24><Integer val="1033"/></Locale24>
- <RightToLeft24><Boolean val="false"/></RightToLeft24>
- <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24>
- <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24>
- <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24>
- <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24>
- <ICULocale24><Uni>en</Uni></ICULocale24>
- <KeyboardType24><Uni>standard</Uni></KeyboardType24>
- <Collations24>
- <LgCollation>
- <Name30>
- <AUni ws="en">Default Collation</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30>
- </LgCollation>
- <LgCollation>
- <Name30>
- <AUni ws="en">Case Sensitive</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CS_AI</Uni></WinCollation30>
- </LgCollation>
- </Collations24>
- </LgWritingSystem>
-</Languages>
-
-<Styles>
- <StStyle>
- <Name17><Uni>Normal</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni></Uni></BasedOn17>
- <Next17><Uni>Normal</Uni></Next17>
- <Rules17>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Bulleted List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Bulleted List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 1</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 1</Uni></Next17>
- <Rules17>
- <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 2</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 2</Uni></Next17>
- <Rules17>
- <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 3</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 3</Uni></Next17>
- <Rules17>
- <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Numbered List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Numbered List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="10"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>External Link</Uni></Name17>
- <Type17><Integer val="1"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>External Link</Uni></Next17>
- <Rules17>
- <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/>
- </Rules17>
- </StStyle>
-</Styles>
-
-<Body docRightToLeft="false">
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="48000" fontsizeUnit="mpt" fontFamily="Doulos SIL"></Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">a͝a t͝a à̀͝a ʃ̀̀͝a a̖̖a ʃ̀̀a a̖̖a ʃ͝a</Run>
- </Str>
- </Contents16>
- </StTxtPara>
-</Body>
-
-<PageSetup>
- <PageInfo>
- <TopMargin9999><Integer val="72000"/></TopMargin9999>
- <BottomMargin9999><Integer val="72000"/></BottomMargin9999>
- <LeftMargin9999><Integer val="90000"/></LeftMargin9999>
- <RightMargin9999><Integer val="90000"/></RightMargin9999>
- <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999>
- <FooterMargin9999><Integer val="36000"/></FooterMargin9999>
- <PageSize9999><Integer val="0"/></PageSize9999>
- <PageHeight9999><Integer val="792000"/></PageHeight9999>
- <PageWidth9999><Integer val="612000"/></PageWidth9999>
- <PageOrientation9999><Integer val="0"/></PageOrientation9999>
- <Header9999>
- <Str>
- <Run ws="en">bridgingDiacTest.wpx</Run>
- </Str>
- </Header9999>
- <Footer9999>
- <Str>
- <Run ws="en">&[page],&[date]</Run>
- </Str>
- </Footer9999>
- </PageInfo>
-</PageSetup>
-
-</WpDoc>
+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd"> +<WpDoc wpxVersion="2.0"> + +<Languages> + <LgWritingSystem id="en" language="en" type="ISO-639-1"> + <Name24> + <AUni ws="en">English</AUni> + </Name24> + <Abbr24> + <AUni ws="en">Eng</AUni> + </Abbr24> + <Description24> + <AStr ws="en"> + <Run ws="en">The standard alphabetic representation of English (United States style).</Run> + </AStr> + </Description24> + <Locale24><Integer val="1033"/></Locale24> + <RightToLeft24><Boolean val="false"/></RightToLeft24> + <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24> + <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24> + <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24> + <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24> + <ICULocale24><Uni>en</Uni></ICULocale24> + <KeyboardType24><Uni>standard</Uni></KeyboardType24> + <Collations24> + <LgCollation> + <Name30> + <AUni ws="en">Default Collation</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30> + </LgCollation> + <LgCollation> + <Name30> + <AUni ws="en">Case Sensitive</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CS_AI</Uni></WinCollation30> + </LgCollation> + </Collations24> + </LgWritingSystem> +</Languages> + +<Styles> + <StStyle> + <Name17><Uni>Normal</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni></Uni></BasedOn17> + <Next17><Uni>Normal</Uni></Next17> + <Rules17> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Bulleted List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Bulleted List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 1</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 1</Uni></Next17> + <Rules17> + <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 2</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 2</Uni></Next17> + <Rules17> + <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 3</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 3</Uni></Next17> + <Rules17> + <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Numbered List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Numbered List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="10"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>External Link</Uni></Name17> + <Type17><Integer val="1"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>External Link</Uni></Next17> + <Rules17> + <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/> + </Rules17> + </StStyle> +</Styles> + +<Body docRightToLeft="false"> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="48000" fontsizeUnit="mpt" fontFamily="Doulos SIL"></Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">a͝a t͝a à̀͝a ʃ̀̀͝a a̖̖a ʃ̀̀a a̖̖a ʃ͝a</Run> + </Str> + </Contents16> + </StTxtPara> +</Body> + +<PageSetup> + <PageInfo> + <TopMargin9999><Integer val="72000"/></TopMargin9999> + <BottomMargin9999><Integer val="72000"/></BottomMargin9999> + <LeftMargin9999><Integer val="90000"/></LeftMargin9999> + <RightMargin9999><Integer val="90000"/></RightMargin9999> + <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999> + <FooterMargin9999><Integer val="36000"/></FooterMargin9999> + <PageSize9999><Integer val="0"/></PageSize9999> + <PageHeight9999><Integer val="792000"/></PageHeight9999> + <PageWidth9999><Integer val="612000"/></PageWidth9999> + <PageOrientation9999><Integer val="0"/></PageOrientation9999> + <Header9999> + <Str> + <Run ws="en">bridgingDiacTest.wpx</Run> + </Str> + </Header9999> + <Footer9999> + <Str> + <Run ws="en">&[page],&[date]</Run> + </Str> + </Footer9999> + </PageInfo> +</PageSetup> + +</WpDoc> diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/main.h b/Build/source/libs/graphite-engine/test/RegressionTest/main.h index 5985429e8a3..1fcdacf6293 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/main.h +++ b/Build/source/libs/graphite-engine/test/RegressionTest/main.h @@ -1,89 +1,89 @@ -/*--------------------------------------------------------------------*//*:Ignore this sentence.
-Copyright (C) 2004 SIL International. All rights reserved.
-
-Distributable under the terms of either the Common Public License or the
-GNU Lesser General Public License, as specified in the LICENSING.txt file.
-
-File: Main.h
-Responsibility: Sharon Correll
-Last reviewed: Not yet.
-
-Description:
- Header files to include in the Graphite regression test program.
--------------------------------------------------------------------------------*//*:End Ignore*/
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-#ifndef GRCOMPILER_H
-#define GRCOMPILER_H 1
-
-#define NO_EXCEPTIONS 1
-
-// To allow call to IsDebuggerPresent:
-#define _WIN32_WINNT WINVER
-
-//:>********************************************************************************************
-//:> Include files
-//:>********************************************************************************************
-// #include "windows.h"
-#include "stdafx.h"
-////#include "resource.h"
-// #include <hash_map>
-#include <fstream>
-#include <iostream>
-#include <vector>
-////#include <algorithm>
-#include <string>
-#ifdef _WIN32
-#include <crtdbg.h>
-#endif // _WIN32
-#include <assert.h>
-
-////using std::max;
-////using std::min;
-
-#include "GrCommon.h"
-#include "GrPlatform.h"
-
-////////#include "LgCharPropsStub.h"
-
-#include "GrConstants.h"
-///#include "TtfUtil.h"
-///#include "Tt.h"
-
-#include "GrClient.h"
-#include "ITextSource.h"
-#include "SimpleTextSrc.h"
-#include "IGrEngine.h"
-#include "IGrJustifier.h"
-#include "GrJustifier.h"
-#include "SegmentAux.h"
-#include "Font.h"
-// #include "WinFont.h"
-#include "FileFont.h"
-#include "Segment.h"
-#include "SegmentPainter.h"
-// #include "WinSegmentPainter.h"
-
-#include "TestCase.h"
-#include "RtTextSrc.h"
-
-
-//:>********************************************************************************************
-//:> Functions
-//:>********************************************************************************************
-void RunTests(int numberOfTests, TestCase * ptcaseList);
-int RunOneTestCase(TestCase * ptcase, Segment * psegPrev, Segment ** ppsegRet, RtTextSrc ** pptsrcRet);
-void OutputError(TestCase * ptcase, std::string strErr, int i = -1);
-void OutputErrorWithValues(TestCase * ptcase, std::string strErr, int i,
- int valueFound, int valueExpected);
-void OutputErrorAux(TestCase * ptcase, std::string strErr, int i,
- bool showValues, int valueFound, int valueExpected);
-bool WriteToLog(std::string str, int i = -1);
-bool WriteToLog(std::string str, int i,
- bool showValues, int valueFound, int valueExpected);
-bool WriteToLog(int n);
-
-#endif //!WRCOMPILER_H
-
+/*--------------------------------------------------------------------*//*:Ignore this sentence. +Copyright (C) 2004 SIL International. All rights reserved. + +Distributable under the terms of either the Common Public License or the +GNU Lesser General Public License, as specified in the LICENSING.txt file. + +File: Main.h +Responsibility: Sharon Correll +Last reviewed: Not yet. + +Description: + Header files to include in the Graphite regression test program. +-------------------------------------------------------------------------------*//*:End Ignore*/ + +#ifdef _MSC_VER +#pragma once +#endif +#ifndef GRCOMPILER_H +#define GRCOMPILER_H 1 + +#define NO_EXCEPTIONS 1 + +// To allow call to IsDebuggerPresent: +#define _WIN32_WINNT WINVER + +//:>******************************************************************************************** +//:> Include files +//:>******************************************************************************************** +// #include "windows.h" +#include "stdafx.h" +////#include "resource.h" +// #include <hash_map> +#include <fstream> +#include <iostream> +#include <vector> +////#include <algorithm> +#include <string> +#ifdef _WIN32 +#include <crtdbg.h> +#endif // _WIN32 +#include <assert.h> + +////using std::max; +////using std::min; + +#include "GrCommon.h" +#include "GrPlatform.h" + +////////#include "LgCharPropsStub.h" + +#include "GrConstants.h" +///#include "TtfUtil.h" +///#include "Tt.h" + +#include "GrClient.h" +#include "ITextSource.h" +#include "SimpleTextSrc.h" +#include "IGrEngine.h" +#include "IGrJustifier.h" +#include "GrJustifier.h" +#include "SegmentAux.h" +#include "Font.h" +// #include "WinFont.h" +#include "FileFont.h" +#include "Segment.h" +#include "SegmentPainter.h" +// #include "WinSegmentPainter.h" + +#include "TestCase.h" +#include "RtTextSrc.h" + + +//:>******************************************************************************************** +//:> Functions +//:>******************************************************************************************** +void RunTests(int numberOfTests, TestCase * ptcaseList); +int RunOneTestCase(TestCase * ptcase, Segment * psegPrev, Segment ** ppsegRet, RtTextSrc ** pptsrcRet); +void OutputError(TestCase * ptcase, std::string strErr, int i = -1); +void OutputErrorWithValues(TestCase * ptcase, std::string strErr, int i, + int valueFound, int valueExpected); +void OutputErrorAux(TestCase * ptcase, std::string strErr, int i, + bool showValues, int valueFound, int valueExpected); +bool WriteToLog(std::string str, int i = -1); +bool WriteToLog(std::string str, int i, + bool showValues, int valueFound, int valueExpected); +bool WriteToLog(int n); + +#endif //!WRCOMPILER_H + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/makedebug.bat b/Build/source/libs/graphite-engine/test/RegressionTest/makedebug.bat index 2faf70b6e49..94d09eb720a 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/makedebug.bat +++ b/Build/source/libs/graphite-engine/test/RegressionTest/makedebug.bat @@ -1,2 +1,2 @@ -cls
+cls nmake CFG=DEBUG -f makefile.vc
\ No newline at end of file diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/readme.txt b/Build/source/libs/graphite-engine/test/RegressionTest/readme.txt index 5b3c1414645..e9f7facad20 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/readme.txt +++ b/Build/source/libs/graphite-engine/test/RegressionTest/readme.txt @@ -1,19 +1,19 @@ -Graphite Regression Test
-
-COMPILING
-Use makedebug.bat to build a debug version. Creating a release version is not supported.
-
-RUNNING
-Extract the fonts from the fonts.zip file and install them.
-
-Options:
-/d - breaks into the debugger (if any) when an error occurs
-/s - silent mode; does not write to the standard output but only to the log file
-
-The program generates a file called grregtest.log with a list of errors.
-
-A file called tracelog.txt will be output for the tests for which tracing is turned on.
-
-ADDING TESTS
-See TestCase.cpp.
-
+Graphite Regression Test + +COMPILING +Use makedebug.bat to build a debug version. Creating a release version is not supported. + +RUNNING +Extract the fonts from the fonts.zip file and install them. + +Options: +/d - breaks into the debugger (if any) when an error occurs +/s - silent mode; does not write to the standard output but only to the log file + +The program generates a file called grregtest.log with a list of errors. + +A file called tracelog.txt will be output for the tests for which tracing is turned on. + +ADDING TESTS +See TestCase.cpp. + diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/romanText.wpx b/Build/source/libs/graphite-engine/test/RegressionTest/romanText.wpx index 3f8342364c7..594cc886a0f 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/romanText.wpx +++ b/Build/source/libs/graphite-engine/test/RegressionTest/romanText.wpx @@ -1,201 +1,206 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd">
-<WpDoc wpxVersion="2.0">
-
-<Languages>
- <LgWritingSystem id="en" language="en" type="ISO-639-1">
- <Name24>
- <AUni ws="en">English</AUni>
- </Name24>
- <Abbr24>
- <AUni ws="en">Eng</AUni>
- </Abbr24>
- <Description24>
- <AStr ws="en">
- <Run ws="en">The standard alphabetic representation of English (United States style).</Run>
- </AStr>
- </Description24>
- <Locale24><Integer val="1033"/></Locale24>
- <RightToLeft24><Boolean val="false"/></RightToLeft24>
- <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24>
- <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24>
- <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24>
- <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24>
- <ICULocale24><Uni>en</Uni></ICULocale24>
- <KeyboardType24><Uni>standard</Uni></KeyboardType24>
- <Collations24>
- <LgCollation>
- <Name30>
- <AUni ws="en">Default Collation</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30>
- </LgCollation>
- <LgCollation>
- <Name30>
- <AUni ws="en">Case Sensitive</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CS_AI</Uni></WinCollation30>
- </LgCollation>
- </Collations24>
- </LgWritingSystem>
-</Languages>
-
-<Styles>
- <StStyle>
- <Name17><Uni>Normal</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni></Uni></BasedOn17>
- <Next17><Uni>Normal</Uni></Next17>
- <Rules17>
- <Prop italic="off" bold="off" superscript="off" underline="none" fontsize="10000" fontsizeUnit="mpt" offset="0" offsetUnit="mpt" forecolor="black" backcolor="white" undercolor="black" align="leading" firstIndent="0" leadingIndent="0" trailingIndent="0" spaceBefore="0" spaceAfter="0" lineHeight="10000" lineHeightUnit="mpt" lineHeightType="atLeast" rightToLeft="0" borderTop="0" borderBottom="0" borderLeading="0" borderTrailing="0" borderColor="black" bulNumScheme="0" bulNumStartAt="1" fontFamily="<default serif>">
- <BulNumFontInfo backcolor="white" bold="off" fontsize="10000mpt" forecolor="black" italic="off" offset="0mpt" superscript="off" undercolor="black" underline="none" fontFamily="Times New Roman"/>
- </Prop>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Bulleted List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Bulleted List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 1</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 1</Uni></Next17>
- <Rules17>
- <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 2</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 2</Uni></Next17>
- <Rules17>
- <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 3</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 3</Uni></Next17>
- <Rules17>
- <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Numbered List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Numbered List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="10"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>External Link</Uni></Name17>
- <Type17><Integer val="1"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>External Link</Uni></Next17>
- <Rules17>
- <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/>
- </Rules17>
- </StStyle>
-</Styles>
-
-<Body docRightToLeft="false">
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">ẽ̀p͡sg˨˥˧ŊấĩĨm̼̀̈̄ffi</Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="20000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">with features:</Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman" fontVariations="1026=1,1029=1,1032=1,1024=2,1051=0">ẽ̀p͡sg˨˥˧ŊấĩĨm̼̀̈̄ffi</Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman"></Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="20000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">stacking and bridging:</Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop rightToLeft="0" namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">a͝a t͝a à̀͝a ʃ̀̀͝a a̖̖a ʃ̀̀a a̖̖a</Run>
- </Str>
- </Contents16>
- </StTxtPara>
-</Body>
-
-<PageSetup>
- <PageInfo>
- <TopMargin9999><Integer val="72000"/></TopMargin9999>
- <BottomMargin9999><Integer val="72000"/></BottomMargin9999>
- <LeftMargin9999><Integer val="90000"/></LeftMargin9999>
- <RightMargin9999><Integer val="90000"/></RightMargin9999>
- <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999>
- <FooterMargin9999><Integer val="36000"/></FooterMargin9999>
- <PageSize9999><Integer val="0"/></PageSize9999>
- <PageHeight9999><Integer val="792000"/></PageHeight9999>
- <PageWidth9999><Integer val="612000"/></PageWidth9999>
- <PageOrientation9999><Integer val="0"/></PageOrientation9999>
- <Header9999>
- <Str>
- <Run ws="en">romanText.wpx</Run>
- </Str>
- </Header9999>
- <Footer9999>
- <Str>
- <Run ws="en">&[page],&[date]</Run>
- </Str>
- </Footer9999>
- </PageInfo>
-</PageSetup>
-
-</WpDoc>
+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd"> +<WpDoc wpxVersion="2.0"> + +<Languages> + <LgWritingSystem id="en" language="en" type="ISO-639-1"> + <Name24> + <AUni ws="en">English</AUni> + </Name24> + <Abbr24> + <AUni ws="en">Eng</AUni> + </Abbr24> + <Description24> + <AStr ws="en"> + <Run ws="en">The standard alphabetic representation of English (United States style).</Run> + </AStr> + </Description24> + <Locale24><Integer val="1033"/></Locale24> + <RightToLeft24><Boolean val="false"/></RightToLeft24> + <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24> + <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24> + <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24> + <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24> + <ICULocale24><Uni>en</Uni></ICULocale24> + <KeyboardType24><Uni>standard</Uni></KeyboardType24> + <Collations24> + <LgCollation> + <Name30> + <AUni ws="en">Default Collation</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30> + </LgCollation> + <LgCollation> + <Name30> + <AUni ws="en">Case Sensitive</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CS_AI</Uni></WinCollation30> + </LgCollation> + </Collations24> + </LgWritingSystem> +</Languages> + +<Styles> + <StStyle> + <Name17><Uni>Normal</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni></Uni></BasedOn17> + <Next17><Uni>Normal</Uni></Next17> + <Rules17> + <Prop italic="off" bold="off" superscript="off" underline="none" fontsize="10000" fontsizeUnit="mpt" offset="0" offsetUnit="mpt" forecolor="black" backcolor="white" undercolor="black" align="leading" firstIndent="0" leadingIndent="0" trailingIndent="0" spaceBefore="0" spaceAfter="0" lineHeight="10000" lineHeightUnit="mpt" lineHeightType="atLeast" rightToLeft="0" borderTop="0" borderBottom="0" borderLeading="0" borderTrailing="0" borderColor="black" bulNumScheme="0" bulNumStartAt="1" fontFamily="<default serif>"> + <BulNumFontInfo backcolor="white" bold="off" fontsize="10000mpt" forecolor="black" italic="off" offset="0mpt" superscript="off" undercolor="black" underline="none" fontFamily="Times New Roman"/> + </Prop> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Bulleted List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Bulleted List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 1</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 1</Uni></Next17> + <Rules17> + <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 2</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 2</Uni></Next17> + <Rules17> + <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 3</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 3</Uni></Next17> + <Rules17> + <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Numbered List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Numbered List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="10"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>External Link</Uni></Name17> + <Type17><Integer val="1"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>External Link</Uni></Next17> + <Rules17> + <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/> + </Rules17> + </StStyle> +</Styles> + +<Body docRightToLeft="false"> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">ẽ̀p͡sg˨˥˧ŊấĩĨm̼̀̈̄ffi</Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="20000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">with features:</Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman" fontVariations="1026=1,1029=1,1032=1,1024=2,1051=0">ẽ̀p͡sg˨˥˧ŊấĩĨm̼̀̈̄ffi</Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman"></Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="20000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">stacking and bridging:</Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop rightToLeft="0" namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman">a͝a t͝a à̀͝a </Run> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" forecolor="ff6000" fontFamily="Graphite Test Roman">ʃ̀̀͝a</Run> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman"> a̖̖a </Run> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" forecolor="blue" fontFamily="Graphite Test Roman">ʃ̀̀a</Run> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" fontFamily="Graphite Test Roman"> </Run> + <Run ws="en" fontsize="36000" fontsizeUnit="mpt" forecolor="yellow" fontFamily="Graphite Test Roman">a̖̖a</Run> + </Str> + </Contents16> + </StTxtPara> +</Body> + +<PageSetup> + <PageInfo> + <TopMargin9999><Integer val="72000"/></TopMargin9999> + <BottomMargin9999><Integer val="72000"/></BottomMargin9999> + <LeftMargin9999><Integer val="90000"/></LeftMargin9999> + <RightMargin9999><Integer val="90000"/></RightMargin9999> + <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999> + <FooterMargin9999><Integer val="36000"/></FooterMargin9999> + <PageSize9999><Integer val="0"/></PageSize9999> + <PageHeight9999><Integer val="792000"/></PageHeight9999> + <PageWidth9999><Integer val="612000"/></PageWidth9999> + <PageOrientation9999><Integer val="0"/></PageOrientation9999> + <Header9999> + <Str> + <Run ws="en">romanText.wpx</Run> + </Str> + </Header9999> + <Footer9999> + <Str> + <Run ws="en">&[page],&[date]</Run> + </Str> + </Footer9999> + </PageInfo> +</PageSetup> + +</WpDoc> diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.cpp b/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.cpp index 215140dfbe7..7f699d258e2 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.cpp +++ b/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.cpp @@ -1,8 +1,8 @@ -// stdafx.cpp : source file that includes just the standard includes
-// RegressionTest.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+// stdafx.cpp : source file that includes just the standard includes +// RegressionTest.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.h b/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.h index 845d66d236e..c5e242de5cb 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.h +++ b/Build/source/libs/graphite-engine/test/RegressionTest/stdafx.h @@ -1,12 +1,12 @@ -// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#pragma once
-
-
-#include <iostream>
-// #include <tchar.h>
-
-// TODO: reference additional headers your program requires here
+// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + + +#include <iostream> +// #include <tchar.h> + +// TODO: reference additional headers your program requires here diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/taivietText.wpx b/Build/source/libs/graphite-engine/test/RegressionTest/taivietText.wpx index 05532a9385a..964c4968611 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/taivietText.wpx +++ b/Build/source/libs/graphite-engine/test/RegressionTest/taivietText.wpx @@ -1,162 +1,162 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd">
-<WpDoc wpxVersion="2.0">
-
-<Languages>
- <LgWritingSystem id="blt_TV" language="blt" type="ISO-639-2">
- <Name24>
- <AUni ws="en">Tai Dam</AUni>
- </Name24>
- <Locale24><Integer val="1033"/></Locale24>
- <RightToLeft24><Boolean val="false"/></RightToLeft24>
- <FontVariation24><Uni>2001=0,2005=0,2101=1,1051=1,2102=1</Uni></FontVariation24>
- <DefaultSerif24><Uni>Tai Heritage Graphite</Uni></DefaultSerif24>
- <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24>
- <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24>
- <DefaultMonospace24><Uni>Courier</Uni></DefaultMonospace24>
- <ICULocale24><Uni>blt_TV</Uni></ICULocale24>
- <KeyboardType24><Uni>standard</Uni></KeyboardType24>
- <Collations24>
- <LgCollation>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30>
- </LgCollation>
- </Collations24>
- </LgWritingSystem>
-</Languages>
-
-<Styles>
- <StStyle>
- <Name17><Uni>Normal</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni></Uni></BasedOn17>
- <Next17><Uni>Normal</Uni></Next17>
- <Rules17>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Bulleted List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Bulleted List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 1</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 1</Uni></Next17>
- <Rules17>
- <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 2</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 2</Uni></Next17>
- <Rules17>
- <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 3</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 3</Uni></Next17>
- <Rules17>
- <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Numbered List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Numbered List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="10"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>External Link</Uni></Name17>
- <Type17><Integer val="1"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>External Link</Uni></Next17>
- <Rules17>
- <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/>
- </Rules17>
- </StStyle>
-</Styles>
-
-<Body docRightToLeft="false">
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run></Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,1051=0,2102=0"></Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,2102=0"></Run>
- </Str>
- </Contents16>
- </StTxtPara>
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,2102=1"></Run>
- <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2"></Run>
- </Str>
- </Contents16>
- </StTxtPara>
-</Body>
-
-<PageSetup>
- <PageInfo>
- <TopMargin9999><Integer val="72000"/></TopMargin9999>
- <BottomMargin9999><Integer val="72000"/></BottomMargin9999>
- <LeftMargin9999><Integer val="90000"/></LeftMargin9999>
- <RightMargin9999><Integer val="90000"/></RightMargin9999>
- <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999>
- <FooterMargin9999><Integer val="36000"/></FooterMargin9999>
- <PageSize9999><Integer val="0"/></PageSize9999>
- <PageHeight9999><Integer val="792000"/></PageHeight9999>
- <PageWidth9999><Integer val="612000"/></PageWidth9999>
- <PageOrientation9999><Integer val="0"/></PageOrientation9999>
- <Header9999>
- <Str>
- <Run ws="en">collision_examples.wpx</Run>
- </Str>
- </Header9999>
- <Footer9999>
- <Str>
- <Run ws="en">&[page],&[date]</Run>
- </Str>
- </Footer9999>
- </PageInfo>
-</PageSetup>
-
-</WpDoc>
+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd"> +<WpDoc wpxVersion="2.0"> + +<Languages> + <LgWritingSystem id="blt_TV" language="blt" type="ISO-639-2"> + <Name24> + <AUni ws="en">Tai Dam</AUni> + </Name24> + <Locale24><Integer val="1033"/></Locale24> + <RightToLeft24><Boolean val="false"/></RightToLeft24> + <FontVariation24><Uni>2001=0,2005=0,2101=1,1051=1,2102=1</Uni></FontVariation24> + <DefaultSerif24><Uni>Tai Heritage Graphite</Uni></DefaultSerif24> + <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24> + <DefaultBodyFont24><Uni>Charis SIL</Uni></DefaultBodyFont24> + <DefaultMonospace24><Uni>Courier</Uni></DefaultMonospace24> + <ICULocale24><Uni>blt_TV</Uni></ICULocale24> + <KeyboardType24><Uni>standard</Uni></KeyboardType24> + <Collations24> + <LgCollation> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30> + </LgCollation> + </Collations24> + </LgWritingSystem> +</Languages> + +<Styles> + <StStyle> + <Name17><Uni>Normal</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni></Uni></BasedOn17> + <Next17><Uni>Normal</Uni></Next17> + <Rules17> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Bulleted List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Bulleted List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 1</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 1</Uni></Next17> + <Rules17> + <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 2</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 2</Uni></Next17> + <Rules17> + <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 3</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 3</Uni></Next17> + <Rules17> + <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Numbered List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Numbered List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="10"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>External Link</Uni></Name17> + <Type17><Integer val="1"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>External Link</Uni></Next17> + <Rules17> + <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/> + </Rules17> + </StStyle> +</Styles> + +<Body docRightToLeft="false"> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run></Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,1051=0,2102=0"></Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,2102=0"></Run> + </Str> + </Contents16> + </StTxtPara> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2,2102=1"></Run> + <Run ws="blt_TV" fontsize="36000" fontsizeUnit="mpt" forecolor="transparent" fontFamily="Graphite Test TaiViet" fontVariations="2001=2"></Run> + </Str> + </Contents16> + </StTxtPara> +</Body> + +<PageSetup> + <PageInfo> + <TopMargin9999><Integer val="72000"/></TopMargin9999> + <BottomMargin9999><Integer val="72000"/></BottomMargin9999> + <LeftMargin9999><Integer val="90000"/></LeftMargin9999> + <RightMargin9999><Integer val="90000"/></RightMargin9999> + <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999> + <FooterMargin9999><Integer val="36000"/></FooterMargin9999> + <PageSize9999><Integer val="0"/></PageSize9999> + <PageHeight9999><Integer val="792000"/></PageHeight9999> + <PageWidth9999><Integer val="612000"/></PageWidth9999> + <PageOrientation9999><Integer val="0"/></PageOrientation9999> + <Header9999> + <Str> + <Run ws="en">collision_examples.wpx</Run> + </Str> + </Header9999> + <Footer9999> + <Str> + <Run ws="en">&[page],&[date]</Run> + </Str> + </Footer9999> + </PageInfo> +</PageSetup> + +</WpDoc> diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/xline.gdl b/Build/source/libs/graphite-engine/test/RegressionTest/xline.gdl index b0e97bcde58..70bfa15902a 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/xline.gdl +++ b/Build/source/libs/graphite-engine/test/RegressionTest/xline.gdl @@ -1,146 +1,146 @@ -
-/*********************************************************************************
- File: xline.gdl
-
- For testing cross-line contextualization.
-
- Compile with stddr.ttf
-
- To test, type something like these examples:
- abc$x
- abcx@
- abc$x@
- and force a line break after the x.
-*********************************************************************************/
-
-#include "stddef.gdh"
-
-Bidi = false;
-
-#define duplicated user1
-
-
-table(glyph) {MUnits = 1000 }
-
- g_A = codepoint("A");
- g_B = codepoint("B");
- g_C = codepoint("C");
- g_D = codepoint("D");
- g_E = codepoint("E");
- g_F = codepoint("F");
- g_G = codepoint("G");
-
- g_a = codepoint("a");
- g_b = codepoint("b");
- g_c = codepoint("c");
- g_d = codepoint("d");
- g_e = codepoint("e");
- g_f = codepoint("f");
- g_g = codepoint("g");
-
- g_x = codepoint("x");
- g_y = codepoint("y");
- g_z = codepoint("z");
-
- g_asterisk = codepoint("*") { ptCenter = point(bb.width/2, bb.height/2) };
- g_dollar = codepoint("$") { xWid = aw };
- g_hash = codepoint("#");
- g_at = codepoint("@") { xWid = aw };
- g_amp = codepoint("&") {xWid = aw };
- g_percent = codepoint("%");
-
- g_leftArrow = codepoint("<") { xWid = aw };
- g_rightArrow = codepoint(">") { xWid = aw };
-
- clsUpper = codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
- { ptCenter = point(bb.width/2, ascent/2) };
- clsLower = codepoint("abcdefghijklmnopqrstuvwxyz");
-
- clsMyAny = glyphid(2..216) { justify.stretch = 700m };
-
- g_m = codepoint("m");
- g_Mlig = codepoint("M") {
- component.one = box(0,0, bb.width/2, ascent);
- component.two = box(bb.width/2,0, bb.width,ascent) };
-
- gSpace = U+0020 { justify.stretch = 3000m };
-
- clsXYZ = (g_x g_y g_z);
-
-endtable; // glyph
-
-
-table(lb)
-
- // Allow non-optimal linebreaks after x, y, or z.
- clsXYZ {break = BREAK_INTRA};
-
-endtable; // lb
-
-
-table(sub)
-
-pass(1)
-
- // Switch the $ and @ if they are both there, and insert & after the one on the first
- // line and before the one on the second line. Note that these rules supercede the rule
- // to insert the left- and right-arrows.
- g_dollar _ _ g_at > @7 g_amp:7 g_amp:1 @1
- / _ _ ANY? # {break == BREAK_INTRA} ANY? _ _ ;
-
- g_dollar
- clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw}
- ANY {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw}
- g_at;
- g_dollar
- clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw}
- g_at {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw};
-
-
- // Just copy the $ to the following segment.
- g_dollar _ > @1 {duplicated = true} g_dollar:1
- / _ {duplicated == false} ANY? ^ # {break == BREAK_INTRA} ANY? _ ;
-
- g_dollar
- clsXYZ {measure.endofline = g_rightArrow.aw}
- ANY {measure.startofline = g_dollar.aw + g_leftArrow.aw};
-
-
- // Just copy the @ to the previous segment.
- _ g_at > g_at:5 @5 {duplicated = true}
- / _ ANY? ^ # {break == BREAK_INTRA} ANY? _ {duplicated == false};
-
- clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw}
- ANY {measure.startofline = g_leftArrow.aw}
- g_at;
-
- clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw}
- g_at {measure.startofline = g_leftArrow.aw};
-
-
- // Insert a '<' at the beginning of the line and a '>' at the end.
- _ > g_leftArrow / # _;
- _ > g_rightArrow / clsMyAny _ # ^ ;
-
- clsMyAny {measure {startofline = g_leftArrow.aw; endofline = g_rightArrow.aw}};
-
-endpass;
-
-pass(2)
-
- // Don't stretch trailing white space.
- gSpace {justify.stretch = 0} / _ [gSpace [gSpace [gSpace gSpace?]? ]? ]? # ;
- // In fact, don't stretch any line-boundary glyph.
- clsMyAny {justify.stretch = 0} / _ #;
-
-
-endpass;
-
-endtable; // sub
-
-
-table(pos)
-
- clsMyAny {adv.x += justify.width};
-
-endtable; // pos
+ +/********************************************************************************* + File: xline.gdl + + For testing cross-line contextualization. + + Compile with stddr.ttf + + To test, type something like these examples: + abc$x + abcx@ + abc$x@ + and force a line break after the x. +*********************************************************************************/ + +#include "stddef.gdh" + +Bidi = false; + +#define duplicated user1 + + +table(glyph) {MUnits = 1000 } + + g_A = codepoint("A"); + g_B = codepoint("B"); + g_C = codepoint("C"); + g_D = codepoint("D"); + g_E = codepoint("E"); + g_F = codepoint("F"); + g_G = codepoint("G"); + + g_a = codepoint("a"); + g_b = codepoint("b"); + g_c = codepoint("c"); + g_d = codepoint("d"); + g_e = codepoint("e"); + g_f = codepoint("f"); + g_g = codepoint("g"); + + g_x = codepoint("x"); + g_y = codepoint("y"); + g_z = codepoint("z"); + + g_asterisk = codepoint("*") { ptCenter = point(bb.width/2, bb.height/2) }; + g_dollar = codepoint("$") { xWid = aw }; + g_hash = codepoint("#"); + g_at = codepoint("@") { xWid = aw }; + g_amp = codepoint("&") {xWid = aw }; + g_percent = codepoint("%"); + + g_leftArrow = codepoint("<") { xWid = aw }; + g_rightArrow = codepoint(">") { xWid = aw }; + + clsUpper = codepoint("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + { ptCenter = point(bb.width/2, ascent/2) }; + clsLower = codepoint("abcdefghijklmnopqrstuvwxyz"); + + clsMyAny = glyphid(2..216) { justify.stretch = 700m }; + + g_m = codepoint("m"); + g_Mlig = codepoint("M") { + component.one = box(0,0, bb.width/2, ascent); + component.two = box(bb.width/2,0, bb.width,ascent) }; + + gSpace = U+0020 { justify.stretch = 3000m }; + + clsXYZ = (g_x g_y g_z); + +endtable; // glyph + + +table(lb) + + // Allow non-optimal linebreaks after x, y, or z. + clsXYZ {break = BREAK_INTRA}; + +endtable; // lb + + +table(sub) + +pass(1) + + // Switch the $ and @ if they are both there, and insert & after the one on the first + // line and before the one on the second line. Note that these rules supercede the rule + // to insert the left- and right-arrows. + g_dollar _ _ g_at > @7 g_amp:7 g_amp:1 @1 + / _ _ ANY? # {break == BREAK_INTRA} ANY? _ _ ; + + g_dollar + clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw} + ANY {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw} + g_at; + g_dollar + clsXYZ {measure.endofline = g_at.aw - g_dollar.aw + g_amp.aw} + g_at {measure.startofline = g_dollar.aw - g_at.aw + g_amp.aw}; + + + // Just copy the $ to the following segment. + g_dollar _ > @1 {duplicated = true} g_dollar:1 + / _ {duplicated == false} ANY? ^ # {break == BREAK_INTRA} ANY? _ ; + + g_dollar + clsXYZ {measure.endofline = g_rightArrow.aw} + ANY {measure.startofline = g_dollar.aw + g_leftArrow.aw}; + + + // Just copy the @ to the previous segment. + _ g_at > g_at:5 @5 {duplicated = true} + / _ ANY? ^ # {break == BREAK_INTRA} ANY? _ {duplicated == false}; + + clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw} + ANY {measure.startofline = g_leftArrow.aw} + g_at; + + clsXYZ {measure.endofline = g_at.aw + g_rightArrow.aw} + g_at {measure.startofline = g_leftArrow.aw}; + + + // Insert a '<' at the beginning of the line and a '>' at the end. + _ > g_leftArrow / # _; + _ > g_rightArrow / clsMyAny _ # ^ ; + + clsMyAny {measure {startofline = g_leftArrow.aw; endofline = g_rightArrow.aw}}; + +endpass; + +pass(2) + + // Don't stretch trailing white space. + gSpace {justify.stretch = 0} / _ [gSpace [gSpace [gSpace gSpace?]? ]? ]? # ; + // In fact, don't stretch any line-boundary glyph. + clsMyAny {justify.stretch = 0} / _ #; + + +endpass; + +endtable; // sub + + +table(pos) + + clsMyAny {adv.x += justify.width}; + +endtable; // pos diff --git a/Build/source/libs/graphite-engine/test/RegressionTest/xlineText.wpx b/Build/source/libs/graphite-engine/test/RegressionTest/xlineText.wpx index 5b49f9a22e9..a8d51fefda7 100644 --- a/Build/source/libs/graphite-engine/test/RegressionTest/xlineText.wpx +++ b/Build/source/libs/graphite-engine/test/RegressionTest/xlineText.wpx @@ -1,132 +1,132 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd">
-<WpDoc wpxVersion="2.0">
-
-<Languages>
- <LgWritingSystem id="en" language="en" type="ISO-639-1">
- <Name24>
- <AUni ws="en">English</AUni>
- </Name24>
- <Locale24><Integer val="1033"/></Locale24>
- <RightToLeft24><Boolean val="false"/></RightToLeft24>
- <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24>
- <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24>
- <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24>
- <ICULocale24><Uni>en</Uni></ICULocale24>
- <KeyboardType24><Uni>standard</Uni></KeyboardType24>
- <Collations24>
- <LgCollation>
- <Name30>
- <AUni ws="en">DefaultCollation</AUni>
- </Name30>
- <WinLCID30><Integer val="1033"/></WinLCID30>
- <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30>
- </LgCollation>
- </Collations24>
- </LgWritingSystem>
-</Languages>
-
-<Styles>
- <StStyle>
- <Name17><Uni>Normal</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni></Uni></BasedOn17>
- <Next17><Uni>Normal</Uni></Next17>
- <Rules17>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Bulleted List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Bulleted List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 1</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 1</Uni></Next17>
- <Rules17>
- <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 2</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 2</Uni></Next17>
- <Rules17>
- <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Heading 3</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Heading 3</Uni></Next17>
- <Rules17>
- <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>Numbered List</Uni></Name17>
- <Type17><Integer val="0"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>Numbered List</Uni></Next17>
- <Rules17>
- <Prop firstIndent="-18000" bulNumScheme="10"/>
- </Rules17>
- </StStyle>
- <StStyle>
- <Name17><Uni>External Link</Uni></Name17>
- <Type17><Integer val="1"/></Type17>
- <BasedOn17><Uni>Normal</Uni></BasedOn17>
- <Next17><Uni>External Link</Uni></Next17>
- <Rules17>
- <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/>
- </Rules17>
- </StStyle>
-</Styles>
-
-<Body docRightToLeft="false">
- <StTxtPara>
- <StyleRules15>
- <Prop namedStyle="Normal"/>
- </StyleRules15>
- <Contents16>
- <Str>
- <Run ws="en" fontsize="28000" fontsizeUnit="mpt" fontFamily="Graphite Test CrossLine">abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww</Run>
- </Str>
- </Contents16>
- </StTxtPara>
-</Body>
-
-<PageSetup>
- <PageInfo>
- <TopMargin9999><Integer val="72000"/></TopMargin9999>
- <BottomMargin9999><Integer val="72000"/></BottomMargin9999>
- <LeftMargin9999><Integer val="90000"/></LeftMargin9999>
- <RightMargin9999><Integer val="90000"/></RightMargin9999>
- <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999>
- <FooterMargin9999><Integer val="36000"/></FooterMargin9999>
- <PageSize9999><Integer val="0"/></PageSize9999>
- <PageHeight9999><Integer val="792000"/></PageHeight9999>
- <PageWidth9999><Integer val="612000"/></PageWidth9999>
- <PageOrientation9999><Integer val="0"/></PageOrientation9999>
- <Header9999>
- <Str>
- <Run ws="en">xline_test.wpx</Run>
- </Str>
- </Header9999>
- <Footer9999>
- <Str>
- <Run ws="en">&[page],&[date]</Run>
- </Str>
- </Footer9999>
- </PageInfo>
-</PageSetup>
-
-</WpDoc>
+<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE WpDoc SYSTEM "WorldPad.dtd"> +<WpDoc wpxVersion="2.0"> + +<Languages> + <LgWritingSystem id="en" language="en" type="ISO-639-1"> + <Name24> + <AUni ws="en">English</AUni> + </Name24> + <Locale24><Integer val="1033"/></Locale24> + <RightToLeft24><Boolean val="false"/></RightToLeft24> + <DefaultSerif24><Uni>Times New Roman</Uni></DefaultSerif24> + <DefaultSansSerif24><Uni>Arial</Uni></DefaultSansSerif24> + <DefaultMonospace24><Uni>Courier New</Uni></DefaultMonospace24> + <ICULocale24><Uni>en</Uni></ICULocale24> + <KeyboardType24><Uni>standard</Uni></KeyboardType24> + <Collations24> + <LgCollation> + <Name30> + <AUni ws="en">DefaultCollation</AUni> + </Name30> + <WinLCID30><Integer val="1033"/></WinLCID30> + <WinCollation30><Uni>Latin1_General_CI_AI</Uni></WinCollation30> + </LgCollation> + </Collations24> + </LgWritingSystem> +</Languages> + +<Styles> + <StStyle> + <Name17><Uni>Normal</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni></Uni></BasedOn17> + <Next17><Uni>Normal</Uni></Next17> + <Rules17> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Bulleted List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Bulleted List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="101" bulNumStartAt="1"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 1</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 1</Uni></Next17> + <Rules17> + <Prop bold="invert" fontsize="14000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 2</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 2</Uni></Next17> + <Rules17> + <Prop italic="invert" fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Heading 3</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Heading 3</Uni></Next17> + <Rules17> + <Prop fontsize="12000" fontsizeUnit="mpt" spaceBefore="12000" spaceAfter="3000"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>Numbered List</Uni></Name17> + <Type17><Integer val="0"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>Numbered List</Uni></Next17> + <Rules17> + <Prop firstIndent="-18000" bulNumScheme="10"/> + </Rules17> + </StStyle> + <StStyle> + <Name17><Uni>External Link</Uni></Name17> + <Type17><Integer val="1"/></Type17> + <BasedOn17><Uni>Normal</Uni></BasedOn17> + <Next17><Uni>External Link</Uni></Next17> + <Rules17> + <Prop underline="single" forecolor="7f007f" undercolor="7f007f"/> + </Rules17> + </StStyle> +</Styles> + +<Body docRightToLeft="false"> + <StTxtPara> + <StyleRules15> + <Prop namedStyle="Normal"/> + </StyleRules15> + <Contents16> + <Str> + <Run ws="en" fontsize="28000" fontsizeUnit="mpt" fontFamily="Graphite Test CrossLine">abcddddefx@ghijkmmmmn$yopppppqrsss$z@tttwwww</Run> + </Str> + </Contents16> + </StTxtPara> +</Body> + +<PageSetup> + <PageInfo> + <TopMargin9999><Integer val="72000"/></TopMargin9999> + <BottomMargin9999><Integer val="72000"/></BottomMargin9999> + <LeftMargin9999><Integer val="90000"/></LeftMargin9999> + <RightMargin9999><Integer val="90000"/></RightMargin9999> + <HeaderMargin9999><Integer val="36000"/></HeaderMargin9999> + <FooterMargin9999><Integer val="36000"/></FooterMargin9999> + <PageSize9999><Integer val="0"/></PageSize9999> + <PageHeight9999><Integer val="792000"/></PageHeight9999> + <PageWidth9999><Integer val="612000"/></PageWidth9999> + <PageOrientation9999><Integer val="0"/></PageOrientation9999> + <Header9999> + <Str> + <Run ws="en">xline_test.wpx</Run> + </Str> + </Header9999> + <Footer9999> + <Str> + <Run ws="en">&[page],&[date]</Run> + </Str> + </Footer9999> + </PageInfo> +</PageSetup> + +</WpDoc> diff --git a/Build/source/libs/graphite-engine/test/examples/khmer/cloudsku2.txt b/Build/source/libs/graphite-engine/test/examples/khmer/cloudsku2.txt index e9c75837a9a..6026347f841 100755 --- a/Build/source/libs/graphite-engine/test/examples/khmer/cloudsku2.txt +++ b/Build/source/libs/graphite-engine/test/examples/khmer/cloudsku2.txt @@ -1,29 +1,29 @@ -ពពក
-១-ពពកនៅលើមេឃគឺជាតំណក់ទឹកតូចៗជាច្រើន ។
-២-ពពកមើលទៅឃើញស្អាត ហើយមានប្រយោជន៍ចំញេះមនុស្សដែរ ។
-៣-ពពកគឺជាប្រភពនៃទឹកភ្លៀង ដែលរុក្ខជាតិ នឹងសត្វទាំងឡាយត្រូវការ ។
-៤-ទឹកភ្លៀងបង្អុរពីលើ "ពពក" ទៅក្នុងទន្លេដែលជាទីកន្លែងសំរាប់យើងរកត្រី ។
-៥-ទឹកអណ្ដូងរបស់យើងក៏មកពីទឹកភ្លៀងដែរ ។
-៦-យើងប្រើទឹកសំរាប់ហូប សំរាប់ដាំស្ល និងសំរាប់ងូតទឹកសំរាប់បោកគក់ ។
-៧-នៅពេលថ្ងៃ ពពកផ្ដល់ម្លប់អោយយើងពីកំដៅព្រះអាទិត្យ ។
-៨-ប្រសិនបើមានពពកនៅពេលយប់ នោះនឹង អាចការពារកំដៅពីចំហាយផែនដី ។ ហេតុដូច្នេះហើយទើបធ្វើអោយយើងមានអារម្មណ៍កក់ក្ដៅនៅពេលយប់ដែលមានពពកច្រើន ។
-៩-ពេលខ្លះពពកធ្វើអោយមានភ្លៀងធ្លាក់យ៉ាងខ្លាំង និងធ្វើអោយមានទឹកជំនន់ទឹកទន្លេជន់ឡើងយ៉ាងខ្លាំងហើយផ្ទះសំបែងជាច្រើនបានត្រូវលិចលង់ ។
-១០-ទឹកជំនន់បំផ្លិចបំផ្លាញផលដំណាំជាច្រើន ។
-១១-សត្វជាច្រើនបានលង់ទឹកស្លាប់ ។
-១២-មានផ្ទាំងដីធ្លាក់បាក់ចុះមកជាច្រើន ។
-១៣-ប៉ុន្ដែនៅទីណាដែលគ្មានពពកច្រើន ទីកន្លែងនោះខ្វះខាតទឹក និងក្លាយទៅជាវាលរហោស្ថាន ។ អត់មានដើមឈើរុក្ខជាតិរស់ ស្វតនិងមនុស្សក៏មិនអាចរស់នៅទីនោះបានដែរ ។
-
-CLOUDS
-1 The clouds in the sky are made up of little drops of water.
-2 Clouds are pretty to look at as well as useful to man.
-3 Clouds are the source of rain, which is needed by both plants and animals.
-4 Rain from the clouds fills the rivers where we get fish.
-5 Our wells are also filled by the rain that falls from the clouds.
-6 We use water for drinking, for cooking and for washing.
-7 During the day, the clouds provide shade from the heat of the sun.
-8 If there are clouds at night, they prevent the heat from the surface of the earth from rising. So that is why we feel warm on a cloudy night.
-9 Sometimes clouds bring heavy rains and floods. Rivers overflow and houses get flooded.
-10 The floods destroy crops.
-11 Animals are drowned.
-12 There are landslides.
-13 But in places where there are not many clouds, there is less water and the place becomes a desert in which no plants grow and no animals and people live.
+ពពក +១-ពពកនៅលើមេឃគឺជាតំណក់ទឹកតូចៗជាច្រើន ។ +២-ពពកមើលទៅឃើញស្អាត ហើយមានប្រយោជន៍ចំញេះមនុស្សដែរ ។ +៣-ពពកគឺជាប្រភពនៃទឹកភ្លៀង ដែលរុក្ខជាតិ នឹងសត្វទាំងឡាយត្រូវការ ។ +៤-ទឹកភ្លៀងបង្អុរពីលើ "ពពក" ទៅក្នុងទន្លេដែលជាទីកន្លែងសំរាប់យើងរកត្រី ។ +៥-ទឹកអណ្ដូងរបស់យើងក៏មកពីទឹកភ្លៀងដែរ ។ +៦-យើងប្រើទឹកសំរាប់ហូប សំរាប់ដាំស្ល និងសំរាប់ងូតទឹកសំរាប់បោកគក់ ។ +៧-នៅពេលថ្ងៃ ពពកផ្ដល់ម្លប់អោយយើងពីកំដៅព្រះអាទិត្យ ។ +៨-ប្រសិនបើមានពពកនៅពេលយប់ នោះនឹង អាចការពារកំដៅពីចំហាយផែនដី ។ ហេតុដូច្នេះហើយទើបធ្វើអោយយើងមានអារម្មណ៍កក់ក្ដៅនៅពេលយប់ដែលមានពពកច្រើន ។ +៩-ពេលខ្លះពពកធ្វើអោយមានភ្លៀងធ្លាក់យ៉ាងខ្លាំង និងធ្វើអោយមានទឹកជំនន់ទឹកទន្លេជន់ឡើងយ៉ាងខ្លាំងហើយផ្ទះសំបែងជាច្រើនបានត្រូវលិចលង់ ។ +១០-ទឹកជំនន់បំផ្លិចបំផ្លាញផលដំណាំជាច្រើន ។ +១១-សត្វជាច្រើនបានលង់ទឹកស្លាប់ ។ +១២-មានផ្ទាំងដីធ្លាក់បាក់ចុះមកជាច្រើន ។ +១៣-ប៉ុន្ដែនៅទីណាដែលគ្មានពពកច្រើន ទីកន្លែងនោះខ្វះខាតទឹក និងក្លាយទៅជាវាលរហោស្ថាន ។ អត់មានដើមឈើរុក្ខជាតិរស់ ស្វតនិងមនុស្សក៏មិនអាចរស់នៅទីនោះបានដែរ ។ + +CLOUDS +1 The clouds in the sky are made up of little drops of water. +2 Clouds are pretty to look at as well as useful to man. +3 Clouds are the source of rain, which is needed by both plants and animals. +4 Rain from the clouds fills the rivers where we get fish. +5 Our wells are also filled by the rain that falls from the clouds. +6 We use water for drinking, for cooking and for washing. +7 During the day, the clouds provide shade from the heat of the sun. +8 If there are clouds at night, they prevent the heat from the surface of the earth from rising. So that is why we feel warm on a cloudy night. +9 Sometimes clouds bring heavy rains and floods. Rivers overflow and houses get flooded. +10 The floods destroy crops. +11 Animals are drowned. +12 There are landslides. +13 But in places where there are not many clouds, there is less water and the place becomes a desert in which no plants grow and no animals and people live. |