summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness')
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.cpp310
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.h146
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.am14
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.in462
-rw-r--r--Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/ProfileHarness.cpp476
5 files changed, 1408 insertions, 0 deletions
diff --git a/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.cpp b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.cpp
new file mode 100644
index 00000000000..30bfac34a9f
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.cpp
@@ -0,0 +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;
+}
+
diff --git a/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.h b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.h
new file mode 100644
index 00000000000..cae0a4850b5
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/GrUtfTextSrc.h
@@ -0,0 +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
+
diff --git a/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.am b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.am
new file mode 100644
index 00000000000..07d07348eff
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.am
@@ -0,0 +1,14 @@
+AUTOMAKE_OPTIONS = 1.6
+
+noinst_PROGRAMS = profile-graphite
+
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+profile_graphite_LDFLAGS = -L$(top_builddir)/src -lgraphite
+
+profile_graphite_SOURCES = \
+ GrUtfTextSrc.cpp GrUtfTextSrc.h \
+ ProfileHarness.cpp
+
+#dist-hook:
+# rm -f grregtest.log tracelog.txt
diff --git a/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.in b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.in
new file mode 100644
index 00000000000..778e839eecb
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/Makefile.in
@@ -0,0 +1,462 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+noinst_PROGRAMS = profile-graphite$(EXEEXT)
+subdir = test/ProfileHarness
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+am_profile_graphite_OBJECTS = GrUtfTextSrc.$(OBJEXT) \
+ ProfileHarness.$(OBJEXT)
+profile_graphite_OBJECTS = $(am_profile_graphite_OBJECTS)
+profile_graphite_LDADD = $(LDADD)
+profile_graphite_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(profile_graphite_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(profile_graphite_SOURCES)
+DIST_SOURCES = $(profile_graphite_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LSB_RELEASE = @LSB_RELEASE@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+REL_CODENAME = @REL_CODENAME@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SIZEOF_WCHAR_T = @SIZEOF_WCHAR_T@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = 1.6
+AM_CPPFLAGS = -I$(top_srcdir)/include
+profile_graphite_LDFLAGS = -L$(top_builddir)/src -lgraphite
+profile_graphite_SOURCES = \
+ GrUtfTextSrc.cpp GrUtfTextSrc.h \
+ ProfileHarness.cpp
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test/ProfileHarness/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign test/ProfileHarness/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+profile-graphite$(EXEEXT): $(profile_graphite_OBJECTS) $(profile_graphite_DEPENDENCIES)
+ @rm -f profile-graphite$(EXEEXT)
+ $(profile_graphite_LINK) $(profile_graphite_OBJECTS) $(profile_graphite_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrUtfTextSrc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProfileHarness.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstPROGRAMS ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+#dist-hook:
+# rm -f grregtest.log tracelog.txt
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/ProfileHarness.cpp b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/ProfileHarness.cpp
new file mode 100644
index 00000000000..361d6a6b734
--- /dev/null
+++ b/Build/source/libs/graphite/engine-2.3.1/test/ProfileHarness/ProfileHarness.cpp
@@ -0,0 +1,476 @@
+/*-----------------------------------------------------------------------------
+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 <cstring>
+
+#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