diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/util/Makefile /windows/AbiCVS/abi_mine/src/af/util/Makefile
--- /windows/AbiCVS/abi/src/af/util/Makefile	Thu Dec 14 08:31:34 2000
+++ /windows/AbiCVS/abi_mine/src/af/util/Makefile	Fri Feb  2 19:31:08 2001
@@ -92,7 +92,9 @@
 		$(OBJDIR)/ut_units.$(OBJ_SUFFIX)			\
 		$(OBJDIR)/ut_vector.$(OBJ_SUFFIX)			\
 		$(OBJDIR)/ut_pair.$(OBJ_SUFFIX)			\
-		$(OBJDIR)/ut_wctomb.$(OBJ_SUFFIX)
+		$(OBJDIR)/ut_wctomb.$(OBJ_SUFFIX)       \
+		$(OBJDIR)/ut_AdobeEncoding.$(OBJ_SUFFIX)       \
+		
 
 include $(ABI_ROOT)/src/config/abi_rules.mk
 
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/util/xp/Makefile /windows/AbiCVS/abi_mine/src/af/util/xp/Makefile
--- /windows/AbiCVS/abi/src/af/util/xp/Makefile	Sat Feb  3 07:39:28 2001
+++ /windows/AbiCVS/abi_mine/src/af/util/xp/Makefile	Sat Feb  3 07:42:12 2001
@@ -41,7 +41,8 @@
 		ut_units.cpp		\
 		ut_vector.cpp		\
 		ut_wctomb.cpp		\
-		ut_pair.cpp
+		ut_pair.cpp			\
+		ut_AdobeEncoding.cpp
 
 ### regex is only used by calc.
 ###CSRCS=		ut_regex.c
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/util/xp/ut_AdobeEncoding.cpp /windows/AbiCVS/abi_mine/src/af/util/xp/ut_AdobeEncoding.cpp
--- /windows/AbiCVS/abi/src/af/util/xp/ut_AdobeEncoding.cpp	Thu Jan  1 01:00:00 1970
+++ /windows/AbiCVS/abi_mine/src/af/util/xp/ut_AdobeEncoding.cpp	Tue Feb  6 18:35:06 2001
@@ -0,0 +1,87 @@
+/* AbiSource Program Utilities
+ * Copyright (C) 2001 AbiSource, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "ut_AdobeEncoding.h"
+#include "ut_string.h"
+#include "ut_debugmsg.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+
+static int s_compare (const void * a, const void * b)
+{
+  const encoding_pair * ep;
+  const char * name;
+
+  name = (const char *) a;
+  ep   = (const encoding_pair *) b;
+
+  return UT_strcmp (name, ep->adb);
+}
+
+
+UT_AdobeEncoding::UT_AdobeEncoding(const encoding_pair * ep, UT_uint32 esize)
+{
+	m_pLUT = ep;
+	m_iLutSize = esize;
+}
+
+
+UT_UCSChar UT_AdobeEncoding::adobeToUcs(const char * str) const
+{
+	//first of all, see if the name is not of the uniXXXX type
+	if(!strncmp(str,"uni",3) && isxdigit(*(str+3)) && isxdigit(*(str+4)) && isxdigit(*(str+5)) && isxdigit(*(str+6)))
+	{
+		char buff[7] = "0x";
+		strcpy(buff + 2, str + 3);
+		UT_uint32 i;
+		sscanf(buff,"%x",&i);
+		//printf("%x ", i);
+		return ((UT_UCSChar) i);
+	};
+	
+	encoding_pair * ep;
+	ep = (encoding_pair *)bsearch (str, m_pLUT, m_iLutSize, sizeof (encoding_pair), s_compare);
+   	if(ep)
+   		return (ep->ucs);
+   	else
+   	{
+   		UT_DEBUGMSG(("Unrecognised character: %s\n", str));
+   		return 0;
+   	}
+}
+
+const char * UT_AdobeEncoding::ucsToAdobe(const UT_UCSChar c)
+{
+	UT_uint32 i;
+	
+	for(i = 0; i < m_iLutSize; i++)
+	{
+		if(m_pLUT[i].ucs == c)
+			return m_pLUT[i].adb;
+	}
+	
+	/*	if we got this far, this char is not in our table, so we will
+		produce a name in the uniXXXX format
+	*/
+	sprintf(m_buff, "uni%04x",(UT_uint32)c);
+	return((const char *) m_buff);
+}
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/util/xp/ut_AdobeEncoding.h /windows/AbiCVS/abi_mine/src/af/util/xp/ut_AdobeEncoding.h
--- /windows/AbiCVS/abi/src/af/util/xp/ut_AdobeEncoding.h	Thu Jan  1 01:00:00 1970
+++ /windows/AbiCVS/abi_mine/src/af/util/xp/ut_AdobeEncoding.h	Tue Feb  6 18:35:17 2001
@@ -0,0 +1,40 @@
+/* AbiSource Program Utilities
+ * Copyright (C) 2001 AbiSource, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "ut_types.h"
+
+struct encoding_pair
+{
+	const char *	adb;
+	UT_UCSChar		ucs;
+};
+
+
+class UT_AdobeEncoding
+{
+	public:
+		UT_AdobeEncoding(const encoding_pair *ep, UT_uint32 esize);
+		
+		UT_UCSChar		adobeToUcs(const char * str)   const;
+		const char *	ucsToAdobe(const UT_UCSChar c);
+	private:
+		char 			m_buff[8];
+		encoding_pair *	m_pLUT;
+		UT_uint32 		m_iLutSize;
+};
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixFont.cpp /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixFont.cpp
--- /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixFont.cpp	Sat Feb  3 07:39:30 2001
+++ /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixFont.cpp	Tue Feb  6 18:40:48 2001
@@ -32,6 +32,7 @@
 #include "xap_UnixFont.h"
 #include "xap_UnixFontXLFD.h"
 #include "xap_EncodingManager.h"
+//#include "ut_AdobeEncoding.h"
 
 
 #define ASSERT_MEMBERS	do { UT_ASSERT(m_name); UT_ASSERT(m_fontfile); UT_ASSERT(m_metricfile); } while (0)
@@ -93,6 +94,9 @@
 	m_PFFile = NULL;
 	
 	m_fontKey = NULL;
+	
+	m_pEncodingTable = NULL;
+	m_iEncodingTableSize = 0;
 }
 
 XAP_UnixFont::XAP_UnixFont(XAP_UnixFont & copy)
@@ -117,6 +121,11 @@
 			   copy.getMetricfile(),
 			   copy.getXLFD(),
 			   copy.getStyle());
+			
+	m_pEncodingTable = NULL;
+	m_iEncodingTableSize = 0;
+	if(copy.getEncodingTable())
+		loadEncodingFile();
 }
 
 XAP_UnixFont::~XAP_UnixFont(void)
@@ -132,6 +141,9 @@
 
 	UT_VECTOR_PURGEALL(allocFont *, m_allocFonts);
 	
+	FREEP(m_uniWidths);
+	
+	_deleteEncodingTable();
 	// leave GdkFont * alone
 }
 
@@ -241,459 +253,169 @@
 	return m_xlfd;
 }
 
-UT_uint16 * XAP_UnixFont::getUniWidths(void)
+UT_uint16 XAP_UnixFont::getCharWidth(UT_UCSChar c)
 {
-	if (!m_uniWidths)
+	UT_sint32 i;
+	if(!m_uniWidths)
 		getMetricsData();
-	return m_uniWidths;
+	for (i=0; i<m_metricsData->numOfChars; i++)
+	{
+		if(m_uniWidths[i].ucs == c)
+			return(m_uniWidths[i].width);
+	}
+	return 0;
 }
 
-/* These are just the glyphs in the standard encoding. I need to add
-   the rest of the glyphs, accessible through nonstandard
-   encodings. */
-
-/* This table is adapted very straightforwardly from
-   ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/stdenc.txt.
-
-   I have reviewed them and compared them against an independently
-   constructed encoding, and believe they are correct.
-  */
+UT_Bool	XAP_UnixFont::_getMetricsDataFromX(void)
+{
+	UT_DEBUGMSG(("Attempting to generate font metrix from X server info\n"));
+	UT_DEBUGMSG(("This feature is not implemented (yet)\n"));
+	return (UT_FALSE);
+}
 
-struct FontMappingTable {
-	UT_sint32 unicode;
-	char *type1_name;
-};
+void XAP_UnixFont::_deleteEncodingTable()
+{
+	if(m_pEncodingTable)
+	{
+		for(UT_uint32 i = 0; i < m_iEncodingTableSize; i++)
+			delete[] m_pEncodingTable[i].adb;
+		delete[] m_pEncodingTable;
+		m_pEncodingTable = 0;
+		m_iEncodingTableSize = 0;
+	}
+}
 
-const FontMappingTable std_enc[] = {
-  { 0x0020, "space" },
-  { 0x0021, "exclam" },
-  { 0x0022, "quotedbl" },
-  { 0x0023, "numbersign" },
-  { 0x0024, "dollar" },
-  { 0x0025, "percent" },
-  { 0x0026, "ampersand" },
-  { 0x0027, "quotesingle" },
-  { 0x0028, "parenleft" },
-  { 0x0029, "parenright" },
-  { 0x002A, "asterisk" },
-  { 0x002B, "plus" },
-  { 0x002C, "comma" },
-  { 0x002D, "hyphen" },
-  { 0x002E, "period" },
-  { 0x002F, "slash" },
-  { 0x0030, "zero" },
-  { 0x0031, "one" },
-  { 0x0032, "two" },
-  { 0x0033, "three" },
-  { 0x0034, "four" },
-  { 0x0035, "five" },
-  { 0x0036, "six" },
-  { 0x0037, "seven" },
-  { 0x0038, "eight" },
-  { 0x0039, "nine" },
-  { 0x003A, "colon" },
-  { 0x003B, "semicolon" },
-  { 0x003C, "less" },
-  { 0x003D, "equal" },
-  { 0x003E, "greater" },
-  { 0x003F, "question" },
-  { 0x0040, "at" },
-  { 0x0041, "A" },
-  { 0x0042, "B" },
-  { 0x0043, "C" },
-  { 0x0044, "D" },
-  { 0x0045, "E" },
-  { 0x0046, "F" },
-  { 0x0047, "G" },
-  { 0x0048, "H" },
-  { 0x0049, "I" },
-  { 0x004A, "J" },
-  { 0x004B, "K" },
-  { 0x004C, "L" },
-  { 0x004D, "M" },
-  { 0x004E, "N" },
-  { 0x004F, "O" },
-  { 0x0050, "P" },
-  { 0x0051, "Q" },
-  { 0x0052, "R" },
-  { 0x0053, "S" },
-  { 0x0054, "T" },
-  { 0x0055, "U" },
-  { 0x0056, "V" },
-  { 0x0057, "W" },
-  { 0x0058, "X" },
-  { 0x0059, "Y" },
-  { 0x005A, "Z" },
-  { 0x005B, "bracketleft" },
-  { 0x005C, "backslash" },
-  { 0x005D, "bracketright" },
-  { 0x005E, "asciicircum" },
-  { 0x005F, "underscore" },
-  { 0x0060, "grave" },
-  { 0x0061, "a" },
-  { 0x0062, "b" },
-  { 0x0063, "c" },
-  { 0x0064, "d" },
-  { 0x0065, "e" },
-  { 0x0066, "f" },
-  { 0x0067, "g" },
-  { 0x0068, "h" },
-  { 0x0069, "i" },
-  { 0x006A, "j" },
-  { 0x006B, "k" },
-  { 0x006C, "l" },
-  { 0x006D, "m" },
-  { 0x006E, "n" },
-  { 0x006F, "o" },
-  { 0x0070, "p" },
-  { 0x0071, "q" },
-  { 0x0072, "r" },
-  { 0x0073, "s" },
-  { 0x0074, "t" },
-  { 0x0075, "u" },
-  { 0x0076, "v" },
-  { 0x0077, "w" },
-  { 0x0078, "x" },
-  { 0x0079, "y" },
-  { 0x007A, "z" },
-  { 0x007B, "braceleft" },
-  { 0x007C, "bar" },
-  { 0x007D, "braceright" },
-  { 0x007E, "asciitilde" },
-  { 0x00A1, "exclamdown" },
-  { 0x00A2, "cent" },
-  { 0x00A3, "sterling" },
-  { 0x00A4, "currency" },
-  { 0x00A5, "yen" },
-  { 0x00A7, "section" },
-  { 0x00A8, "dieresis" },
-  { 0x00AA, "ordfeminine" },
-  { 0x00AB, "guillemotleft" },
-  { 0x00AF, "macron" },
-  { 0x00B4, "acute" },
-  { 0x00B6, "paragraph" },
-  { 0x00B7, "periodcentered" },
-  { 0x00B8, "cedilla" },
-  { 0x00BA, "ordmasculine" },
-  { 0x00BB, "guillemotright" },
-  { 0x00BF, "questiondown" },
-  { 0x00C6, "AE" },
-  { 0x00D8, "Oslash" },
-  { 0x00DF, "germandbls" },
-  { 0x00E6, "ae" },
-  { 0x00F8, "oslash" },
-  /*{ 0x0131, "dotlessi" },
-  { 0x0141, "Lslash" },
-  { 0x0142, "lslash" },
-  { 0x0152, "OE" },
-  { 0x0153, "oe" },
-  { 0x0192, "florin" },
-  { 0x02C6, "circumflex" },
-  { 0x02C7, "caron" },
-  { 0x02D8, "breve" },
-  { 0x02D9, "dotaccent" },
-  { 0x02DA, "ring" },
-  { 0x02DB, "ogonek" },
-  { 0x02DC, "tilde" },
-  { 0x02DD, "hungarumlaut" },
-  { 0x2013, "endash" },
-  { 0x2014, "emdash" },
-  { 0x2018, "quoteleft" },
-  { 0x2019, "quoteright" },
-  { 0x201A, "quotesinglbase" },
-  { 0x201C, "quotedblleft" },
-  { 0x201D, "quotedblright" },
-  { 0x201E, "quotedblbase" },
-  { 0x2020, "dagger" },
-  { 0x2021, "daggerdbl" },
-  { 0x2022, "bullet" },
-  { 0x2026, "ellipsis" },
-  { 0x2030, "perthousand" },
-  { 0x2039, "guilsinglleft" },
-  { 0x203A, "guilsinglright" },
-  { 0x2044, "fraction" },*/
-//  { 0xFB01, "fi" },
-//  { 0xFB02, "fl" },
-
-  // All of the ones you see above were found in gnome-print. The following were added by Aaron Lehmann.
-  // These will be contributed to gnome-print if they end up working.
-  // My references are ftp://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT and a random AFM file.
-
-  { 0x00DD, "Yacute" },
-  { 0x00DB, "Ucircumflex" },
-  { 0x00D9, "Ugrave" },
-  // HELP: What is "Zcaron"? ANS: Z + caron; caron = inverted circumflex
-  { 0x00FF, "Ydieresis" },
-  { 0x00B3, "threesuperior" },
-  { 0x00DA, "Uacute" },
-  { 0x00B2, "twosuperior" },
-  { 0x00DC, "Udieresis" },
-  { 0x00B7, "middot" },
-  { 0x00B9, "onesuperior" },
-  { 0x00E1, "aacute" },
-  { 0x00E0, "agrave" },
-  { 0x00E2, "acircumflex" },
-  { 0x00DF, "Scaron" },
-  { 0x00D5, "Otilde" },
-  { 0x00AD, "sfthyphen" },
-  { 0x00E3, "atilde" },
-  { 0x00E5, "aring" },
-  { 0x00E4, "adieresis" },
-  { 0x00D2, "Ograve" },
-  { 0x00D4, "Ocircumflex" },
-  { 0x00D6, "Odieresis" },
-  { 0x00D1, "Ntilde" },
-  { 0x00EB, "edieresis" },
-  { 0x00E9, "eacute" },
-  { 0x00E8, "egrave" },
-  { 0x00CE, "Icircumflex" },
-  { 0x00EA, "ecircumflex" },
-  { 0x00CC, "Igrave" },
-  { 0x00CD, "Iacute" },
-  { 0x00CF, "Idieresis" },
-  { 0x00B0, "degree" },
-  { 0x00CA, "Ecircumflex" },
-  { 0x002D, "minus" },
-  { 0x00D7, "multiply" },
-  { 0x00F7, "divide" },
-  { 0x00C8, "Egrave" },
-  // HELP: What is "trademark"?
-  { 0x00D3, "Oacute" },
-  { 0x00FE, "thorn" },
-  { 0x00F0, "eth" },
-  { 0x00C9, "Eacute" },
-  { 0x00E7, "ccedilla" },
-  { 0x00EF, "idieresis" },
-  { 0x00ED, "iacute" },
-  { 0x00EC, "igrave" },
-  { 0x00B1, "plusminus" },
-  { 0x00BD, "onehalf" },
-  { 0x00BC, "onequarter" },
-  { 0x00BE, "threequarters" },
-  { 0x00EE, "icircumflex" },
-  { 0x00CB, "Edieresis" },
-  { 0x00F1, "ntilde" },
-  { 0x00C5, "Aring" },
-  { 0x00F6, "odieresis" },
-  { 0x00F3, "oacute" },
-  { 0x00F2, "ograve" },
-  { 0x00F4, "ocircumflex" },
-  { 0x00F5, "otilde" },
-  // HELP: What is "scaron"?
-  { 0x00FC, "udieresis" },
-  { 0x00FA, "uacute" },
-  { 0x00F9, "ugrave" },
-  { 0x00FB, "ucircumflex" },
-  { 0x00FD, "yacute" },
-  // HELP: What is "zcaron"?
-  { 0x00FF, "ydieresis" },
-  { 0x00A9, "copyright" },
-  { 0x00AE, "registered" },
-  { 0x00C3, "Atilde" },
-  { 0x00A0, "nbspace" },
-  { 0x00C7, "Ccedilla" },
-  { 0x00C2, "Acircumflex" },
-  { 0x00C0, "Agrave" },
-  { 0x00AC, "logicalnot" },
-  { 0x00C1, "Aacute" },
-  { 0x00D0, "Eth" },
-  { 0x00A6, "brokenbar" },
-  { 0x00DE, "Thorn" },
-  { 0x00C4, "Adieresis" },
-  { 0x00B5, "mu" },
-  { 0x0000, NULL }
-};
+const encoding_pair * XAP_UnixFont::loadEncodingFile()
+{
+	char * encfile = new char[strlen(m_fontfile)+3]; //3 to be on the safe side, in case extension is < 3
+	strcpy(encfile, m_fontfile);
+	char * dot = strrchr(encfile, '.');
+	if(!dot) return NULL;
+	*(dot+1) = 'u';
+	*(dot+2) = '2';
+	*(dot+3) = 'g';
+	*(dot+4) = 0;
+	
+	const encoding_pair * ep = loadEncodingFile(encfile);
+	delete [] encfile;
+	return ep;
+}
+const encoding_pair * XAP_UnixFont::loadEncodingFile(char * encfile)
+{
+	if(m_pEncodingTable)
+	{
+		UT_DEBUGMSG(("UnixFont: font table already exists\n"));
+		return m_pEncodingTable;
+	}
+	
+	if(!encfile)
+	{
+		UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+		return 0;
+	}
+	
+	
+	FILE * ef = fopen(encfile, "r");
+	if(!ef)
+	{
+		//if the file does not exist, we will load a generic one
+		//get the path from m_fontfile
+		// NB the file is separated from the file name by two slashes.
+		char * slash = strstr(m_fontfile, "//");
+		char * full_name;
+		if(slash)
+		{
+		    full_name = new char[(slash - m_fontfile) + 20];
+		    strncpy(full_name, m_fontfile, (slash - m_fontfile)+1);
+			full_name[(slash - m_fontfile)+1] = 0;
+		}
+		else
+		{
+		    full_name = new char[20];
+		    *full_name = 0;
+		}
+			
+		if(XAP_EncodingManager::instance->isUnicodeLocale())
+			//unicode locale, use the complete table
+			strcat(full_name, "adobe-full.u2g");
+		else
+			strcat(full_name, "adobe-short.u2g");
+			
+		UT_DEBUGMSG(("UnixFont: loading generic encoding file [%s]\n", full_name));
+		
+		ef = fopen(full_name, "r");
+		
+		if(!ef)
+		{
+			UT_DEBUGMSG(("UnixFont: could not load default encoding file [%s].\n", full_name));
+			char msg[300];
+			sprintf(msg, "AbiWord could not find required encoding file %s.", full_name);
+			messageBoxOK(msg);
+			return 0;
+		}
+	}
 
-const FontMappingTable sym_enc[] = {
-	{ 32, "space" },
-	{ 33, "exclam" },
-	{ 34, "universal" },
-	{ 35, "numbersign" },
-	{ 36, "existential" },
-	{ 37, "percent" },
-	{ 38, "ampersand" },
-	{ 39, "suchthat" },
-	{ 40, "parenleft" },
-	{ 41, "parenright" },
-	{ 42, "asteriskmath" },
-	{ 43, "plus" },
-	{ 44, "comma" },
-	{ 45, "minus" },
-	{ 46, "period" },
-	{ 47, "slash" },
-	{ 48, "zero" },
-	{ 49, "one" },
-	{ 50, "two" },
-	{ 51, "three" },
-	{ 52, "four" },
-	{ 53, "five" },
-	{ 54, "six" },
-	{ 55, "seven" },
-	{ 56, "eight" },
-	{ 57, "nine" },
-	{ 58, "colon" },
-	{ 59, "semicolon" },
-	{ 60, "less" },
-	{ 61, "equal" },
-	{ 62, "greater" },
-	{ 63, "question" },
-	{ 64, "congruent" },
-	{ 65, "Alpha" },
-	{ 66, "Beta" },
-	{ 67, "Chi" },
-	{ 68, "Delta" },
-	{ 69, "Epsilon" },
-	{ 70, "Phi" },
-	{ 71, "Gamma" },
-	{ 72, "Eta" },
-	{ 73, "Iota" },
-	{ 74, "theta1" },
-	{ 75, "Kappa" },
-	{ 76, "Lambda" },
-	{ 77, "Mu" },
-	{ 78, "Nu" },
-	{ 79, "Omicron" },
-	{ 80, "Pi" },
-	{ 81, "Theta" },
-	{ 82, "Rho" },
-	{ 83, "Sigma" },
-	{ 84, "Tau" },
-	{ 85, "Upsilon" },
-	{ 86, "sigma1" },
-	{ 87, "Omega" },
-	{ 88, "Xi" },
-	{ 89, "Psi" },
-	{ 90, "Zeta" },
-	{ 91, "bracketleft" },
-	{ 92, "therefore" },
-	{ 93, "bracketright" },
-	{ 94, "perpendicular" },
-	{ 95, "underscore" },
-	{ 96, "radicalex" },
-	{ 97, "alpha" },
-	{ 98, "beta" },
-	{ 99, "chi" },
-	{ 100, "delta" },
-	{ 101, "epsilon" },
-	{ 102, "phi" },
-	{ 103, "gamma" },
-	{ 104, "eta" },
-	{ 105, "iota" },
-	{ 106, "phi1" },
-	{ 107, "kappa" },
-	{ 108, "lambda" },
-	{ 109, "mu" },
-	{ 110, "nu" },
-	{ 111, "omicron" },
-	{ 112, "pi" },
-	{ 113, "theta" },
-	{ 114, "rho" },
-	{ 115, "sigma" },
-	{ 116, "tau" },
-	{ 117, "upsilon" },
-	{ 118, "omega1" },
-	{ 119, "omega" },
-	{ 120, "xi" },
-	{ 121, "psi" },
-	{ 122, "zeta" },
-	{ 123, "braceleft" },
-	{ 124, "bar" },
-	{ 125, "braceright" },
-	{ 126, "similar" },
-	{ 161, "Upsilon1" },
-	{ 162, "minute" },
-	{ 163, "lessequal" },
-	{ 164, "fraction" },
-	{ 165, "infinity" },
-	{ 166, "florin" },
-	{ 167, "club" },
-	{ 168, "diamond" },
-	{ 169, "heart" },
-	{ 170, "spade" },
-	{ 171, "arrowboth" },
-	{ 172, "arrowleft" },
-	{ 173, "arrowup" },
-	{ 174, "arrowright" },
-	{ 175, "arrowdown" },
-	{ 176, "degree" },
-	{ 177, "plusminus" },
-	{ 178, "second" },
-	{ 179, "greaterequal" },
-	{ 180, "multiply" },
-	{ 181, "proportional" },
-	{ 182, "partialdiff" },
-	{ 183, "bullet" },
-	{ 184, "divide" },
-	{ 185, "notequal" },
-	{ 186, "equivalence" },
-	{ 187, "approxequal" },
-	{ 188, "ellipsis" },
-	{ 189, "arrowvertex" },
-	{ 190, "arrowhorizex" },
-	{ 191, "carriagereturn" },
-	{ 192, "aleph" },
-	{ 193, "Ifraktur" },
-	{ 194, "Rfraktur" },
-	{ 195, "weierstrass" },
-	{ 196, "circlemultiply" },
-	{ 197, "circleplus" },
-	{ 198, "emptyset" },
-	{ 199, "intersection" },
-	{ 200, "union" },
-	{ 201, "propersuperset" },
-	{ 202, "reflexsuperset" },
-	{ 203, "notsubset" },
-	{ 204, "propersubset" },
-	{ 205, "reflexsubset" },
-	{ 206, "element" },
-	{ 207, "notelement" },
-	{ 208, "angle" },
-	{ 209, "gradient" },
-	{ 210, "registeredserif" },
-	{ 211, "copyrightserif" },
-	{ 212, "trademarkserif" },
-	{ 213, "product" },
-	{ 214, "radical" },
-	{ 215, "dotmath" },
-	{ 216, "logicalnot" },
-	{ 217, "logicaland" },
-	{ 218, "logicalor" },
-	{ 219, "arrowdblboth" },
-	{ 220, "arrowdblleft" },
-	{ 221, "arrowdblup" },
-	{ 222, "arrowdblright" },
-	{ 223, "arrowdbldown" },
-	{ 224, "lozenge" },
-	{ 225, "angleleft" },
-	{ 226, "registeredsans" },
-	{ 227, "copyrightsans" },
-	{ 228, "trademarksans" },
-	{ 229, "summation" },
-	{ 230, "parenlefttp" },
-	{ 231, "parenleftex" },
-	{ 232, "parenleftbt" },
-	{ 233, "bracketlefttp" },
-	{ 234, "bracketleftex" },
-	{ 235, "bracketleftbt" },
-	{ 236, "bracelefttp" },
-	{ 237, "braceleftmid" },
-	{ 238, "bracelefttbt" },
-	{ 239, "braceex" },
-	{ 241, "angleright" },
-	{ 242, "integral" },
-	{ 243, "integraltp" },
-	{ 244, "integralex" },
-	{ 245, "integralbt" },
-	{ 246, "parenrighttp" },
-	{ 247, "parenrightex" },
-	{ 248, "parenrightbt" },
-	{ 249, "bracketrighttp" },
-	{ 250, "bracketrightex" },
-	{ 251, "bracketrightbt" },
-	{ 252, "bracerighttp" },
-	{ 253, "bracerightmid" },
-	{ 254, "bracerightbt" },
-  { 0x0000, NULL }
+	char buff[128];
+	//skip comments
+	while(fgets(buff,128,ef))
+		if(*buff != '#')
+			break;
+			
+	m_iEncodingTableSize = atoi(buff);
+	if(!m_iEncodingTableSize)
+	{
+		UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+		return 0;
+	}
+	UT_DEBUGMSG(("encoding file contains %d entries\n", m_iEncodingTableSize));
+	
+	UT_uint32 ucs;
+	
+	m_pEncodingTable = new encoding_pair[m_iEncodingTableSize];
+	
+	for(UT_uint32 i = 0; i < m_iEncodingTableSize; i++)
+	{
+		if(!fgets(buff,128,ef))
+		{
+			for(UT_uint32 j = 0; j < i; j++)
+				delete [] m_pEncodingTable[j].adb;
+			delete[] m_pEncodingTable;
+			m_pEncodingTable = 0;
+			m_iEncodingTableSize = 0;
+			UT_DEBUGMSG(("Invalid encoding file\n"));
+			fclose(ef);
+			return NULL;
+		}
+		
+		if(*buff != '#')
+		{
+			buff[strlen(buff)-1]= 0; //remove '\n'
+			char * comma = strchr(buff, ',');
+			if(!comma)
+			{
+				for(UT_uint32 j = 0; j < i; j++)
+					delete [] m_pEncodingTable[j].adb;
+				delete[] m_pEncodingTable;
+				m_pEncodingTable = 0;
+				m_iEncodingTableSize = 0;
+				UT_DEBUGMSG(("Invalid encoding file\n"));
+				fclose(ef);
+				return NULL;
+			}
+			
+			*comma = 0;
+			
+			sscanf(comma + 1, "0x%x", &ucs);
+			m_pEncodingTable[i].ucs = (UT_UCSChar) ucs;
+			m_pEncodingTable[i].adb = strdup(buff);
+			//UT_DEBUGMSG(("encoding pair: %s, 0x%x\n",m_pEncodingTable[i].adb, m_pEncodingTable[i].ucs));
+		}
+		else
+			i--;
+	}
+	
+	fclose(ef);
+	return m_pEncodingTable;
 };
 
 ABIFontInfo * XAP_UnixFont::getMetricsData(void)
@@ -711,121 +433,120 @@
 
 	if (fp == NULL)
 	{
-		g_snprintf(message, 1024,
+		if(!_getMetricsDataFromX())	
+		{
+			g_snprintf(message, 1024,
 				   "The font metrics file [%s] could\n"
-				   "not be opened for parsing.  Please ensure that this file\n"
-				   "is present before printing.  Right now, this is a pretty\n"
-				   "darn fatal error.",
+				   "not be opened for parsing, nor was\n"
+				   "it possible to retrieve the needed\n"
+				   "information from the X server; this\n"
+				   "is a fatal error and AbiWord will\n"
+				   "terminated.",
 				   m_metricfile);
-		messageBoxOK(message);
-		return NULL;
+			messageBoxOK(message);
+			return NULL;
+		}
+		else
+			return(m_metricsData);
 	}
-
-	// call down to the Adobe code
-	int result = abi_parseFile(fp, &m_metricsData, P_GM);
-	switch (result)
+    else
 	{
-	case parseError:
-		g_snprintf(message, 1024,
+		//UT_DEBUGMSG(("Found afm file for the font\n"));
+		// call down to the Adobe code
+		int result = abi_parseFile(fp, &m_metricsData, P_GM);
+		switch (result)
+		{
+			case parseError:
+				g_snprintf(message, 1024,
 				   "AbiWord encountered errors parsing the font metrics file\n"
 				   "[%s].\n"
 				   "These errors were not fatal, but print metrics may be incorrect.",
 				   m_metricfile);
-		messageBoxOK(message);
-		break;
-	case earlyEOF:
-		g_snprintf(message, 1024,
+				messageBoxOK(message);
+				break;
+			case earlyEOF:
+				g_snprintf(message, 1024,
 				   "AbiWord encountered a premature End of File (EOF) while parsing\n"
 				   "the font metrics file [%s].\n"
 				   "Printing cannot continue.",
 				   m_metricfile);
-		messageBoxOK(message);
-		m_metricsData = NULL;
-		break;
-	case storageProblem:
-		// if we got here, either the metrics file is broken (like it's
-		// saying it has 209384098278942398743982 kerning lines coming, and
-		// we know we can't allocate that), or we really did run out of memory.
-		UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
-		m_metricsData = NULL;
-		break;
-	default:
-		// everything is peachy
-		break;
-	}
+				messageBoxOK(message);
+				m_metricsData = NULL;
+				break;
+			case storageProblem:
+				// if we got here, either the metrics file is broken (like it's
+				// saying it has 209384098278942398743982 kerning lines coming, and
+				// we know we can't allocate that), or we really did run out of memory.
+				UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+				m_metricsData = NULL;
+				break;
+			default:
+				// everything is peachy
+				break;
+		}
 
-	// Need to mangle the cmi[i].wx variables to work right with Unicode
-	const FontMappingTable *the_enc = std_enc;
-	xxx_UT_DEBUGMSG(("PS font file:          %s %d\n", m_fontfile, this));
-	xxx_UT_DEBUGMSG(("PS font metrics file:  %s\n", m_metricfile));
-	xxx_UT_DEBUGMSG(("PS font encoding type: %s\n", m_metricsData->gfi->encodingScheme));
-	if (strcmp("FontSpecific", m_metricsData->gfi->encodingScheme) == 0)
-	{
-		// TODO: This is slightly a crock since we imagine the only font
-		// TODO: we'll see with FontSpecific encoding is the standard symbols
-		// TODO: font.  Sez who?  What we probably ought to do is dynamically
-		// TODO: allocate the encoding table for the font based on the
-		// TODO: FontSpecific encoding.  Or something.
-		the_enc = sym_enc;
-	}
-	m_uniWidths = (UT_uint16 *) malloc (sizeof (UT_uint16) * 256);
-	memset (m_uniWidths, 0, 256 * sizeof(UT_uint16)); // Clear array - i would hope that sizeof(UT_uint16) == 16
-	if (XAP_EncodingManager::instance->try_nativeToU(0xa1)==0xa1)
-	{
-           /* it's iso8859-1 or cp1252 encoding - glyphs in font are in wrong
-               order - we have to map them by name.
-           */
-	    int numfound = 0;
-           for (UT_sint32 i=0; i != m_metricsData->numOfChars && i<256; ++i)
-           {
+		// Need to mangle the cmi[i].wx variables to work right with Unicode
+		UT_DEBUGMSG(("PS font file:          %s %d\n", m_fontfile, this));
+		UT_DEBUGMSG(("PS font metrics file:  %s\n", m_metricfile));
+		UT_DEBUGMSG(("PS font encoding type: %s\n", m_metricsData->gfi->encodingScheme));
+		UT_DEBUGMSG(("PS font char count: %d\n", m_metricsData->numOfChars));
+		m_uniWidths = (uniWidth *) malloc (sizeof (uniWidth) * m_metricsData->numOfChars);
+		memset (m_uniWidths, 0, m_metricsData->numOfChars * sizeof(uniWidth)); // Clear array - i would hope that sizeof(UT_uint16) == 16
+		UT_AdobeEncoding *ae = 0;
 
-		UT_sint32 unicode = -1;
-		for (UT_uint32 j = 0; the_enc[j].type1_name != NULL; j++)
+		if (loadEncodingFile() && (XAP_EncodingManager::instance->isUnicodeLocale() || XAP_EncodingManager::instance->try_nativeToU(0xa1)==0xa1))
 		{
-			if (!strcmp (m_metricsData->cmi[i].name, the_enc[j].type1_name))
-			{
-				unicode = the_enc[j].unicode;
-				break;
+			/*
+				iso8859-1 or cp1252 encoding or utf-8 locale -
+				map glyphs by name.
+			*/
+			UT_DEBUGMSG(("Creating AdobeEncoding with %d entries\n", m_iEncodingTableSize));
+			ae = new UT_AdobeEncoding(m_pEncodingTable, m_iEncodingTableSize);
+    		int numfound = 0;
+			
+			for (UT_sint32 i=0; i < m_metricsData->numOfChars; ++i)
+       		{
+				UT_UCSChar unicode = ae->adobeToUcs(m_metricsData->cmi[i].name);
+				if (unicode > 0)
+				{
+					m_uniWidths[numfound].ucs = unicode;
+					m_uniWidths[numfound].width = m_metricsData->cmi[i].wx;
+					++numfound;
+				}
 			}
+			UT_DEBUGMSG(("created width table with %d entries\n", numfound));
+			
+			//OK, now we have the widths, we can get rid off the encoding table
+			delete ae;
+			_deleteEncodingTable();
 		}
-		if (unicode >= 0)
+		else
 		{
-			UT_ASSERT (unicode < 256); // TODO: support multibyte chars
-			m_uniWidths[unicode] = m_metricsData->cmi[i].wx;
-			++numfound;
-		}
-           }
-	   if (numfound < 127) 
-	   {
-	       /*
-	         it looks like font has a broken glyph names. Dingbats is one 
-		 of them.
-	       */
-               for (UT_sint32 i=0; i != m_metricsData->numOfChars && i<256; ++i)
-               {     
-		    if (m_metricsData->cmi[i].code<256 && m_metricsData->cmi[i].code>=0)
-			    m_uniWidths[m_metricsData->cmi[i].code] = m_metricsData->cmi[i].wx;
-               }	   
-	   }
-       } 
-       else
-       {
-           /* it's non-latin1 encoding - we have to assume that order of 
-              glyphs in font is correct.
-           */
-           for (UT_sint32 i=0; i != m_metricsData->numOfChars && i<256; ++i)
+			/*	
+				it's neither iso 8859-1, nor cp1250, nor utf-8 or we did not
+				succeed in loading an encoding file
+				we have to assume that order of glyphs in font is correct.
+			*/
+			
+           int numfound = 0;
+           for (UT_sint32 i=0; i < m_metricsData->numOfChars; ++i)
            {     
-		if (m_metricsData->cmi[i].code<256 && m_metricsData->cmi[i].code>=0)
-			m_uniWidths[m_metricsData->cmi[i].code] = m_metricsData->cmi[i].wx;
-               
+				UT_UCSChar ucs = XAP_EncodingManager::instance->try_nativeToU(m_metricsData->cmi[i].code);
+				if(ucs)
+				{
+					m_uniWidths[numfound].ucs   = ucs;
+					m_uniWidths[numfound].width = m_metricsData->cmi[i].wx;
+					++numfound;
+				}
            }
-       }
-
-	fclose(fp);
-	
-	UT_ASSERT(m_metricsData);
-	UT_ASSERT(m_metricsData->gfi);
-	return m_metricsData;
+       	}
+		
+		fclose(fp);
+		
+		UT_ASSERT(m_metricsData);
+		UT_ASSERT(m_metricsData->gfi);
+		return m_metricsData;
+	}
 }
 
 UT_Bool XAP_UnixFont::openPFA(void)
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixFont.h /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixFont.h
--- /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixFont.h	Sat Dec 23 07:26:08 2000
+++ /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixFont.h	Tue Feb  6 16:25:44 2001
@@ -32,7 +32,14 @@
 
 #include "xap_UnixPSParseAFM.h"
 #include "xap_UnixFontXLFD.h"
-  
+
+#include "ut_AdobeEncoding.h"
+
+struct uniWidth
+{
+	UT_UCSChar ucs;
+	UT_uint16  width;
+};
 
 class XAP_UnixFont
 {
@@ -65,12 +72,16 @@
 
 	const char * 			getFontfile(void);
 	const char * 			getMetricfile(void);
+	const encoding_pair*	loadEncodingFile(void);
+	const encoding_pair*	loadEncodingFile(char * file);
+	const encoding_pair*	getEncodingTable(){return m_pEncodingTable;};
+	UT_uint32				getEncodingTableSize(){return m_iEncodingTableSize;};
 
 	void					setXLFD(const char * xlfd);
 	const char * 			getXLFD(void);
 
 	ABIFontInfo *			getMetricsData(void);
-	UT_uint16 *				getUniWidths(void);
+	UT_uint16				getCharWidth(UT_UCSChar c);
 	
 	UT_Bool					openPFA(void);
 	char					getPFAChar(void);
@@ -99,7 +110,7 @@
 	
 	// The next line is the info that is given back to us by parseAFM. The line after that is our own mangled one to follow Unicode.
 	ABIFontInfo *			m_metricsData;
-	UT_uint16 *				m_uniWidths;
+	uniWidth *				m_uniWidths;
 
 	char * 					m_fontfile;
 	char *					m_metricfile;
@@ -109,7 +120,12 @@
 	UT_Bool					m_PFB;
 	UT_ByteBuf				m_buffer;
 	UT_uint32				m_bufpos;
+	
+	encoding_pair * 		m_pEncodingTable;
+	UT_uint32				m_iEncodingTableSize;
 	char					_getPFBChar(void);
+	UT_Bool					_getMetricsDataFromX(void);
+	void					_deleteEncodingTable();
 
 	struct CJK_PSFontMetric
 	{
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSFont.cpp /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSFont.cpp
--- /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSFont.cpp	Thu Dec 14 08:31:56 2000
+++ /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSFont.cpp	Fri Feb  2 21:27:16 2001
@@ -61,8 +61,8 @@
 	return m_hFont->getMetricsData();
 }
 
-UT_uint16 * PSFont::getUniWidths(void)
+UT_uint16 PSFont::getCharWidth(UT_UCSChar c)
 {
 	UT_ASSERT(m_hFont);
-	return m_hFont->getUniWidths();
+	return m_hFont->getCharWidth(c);
 }
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSFont.h /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSFont.h
--- /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSFont.h	Thu Dec 14 08:31:56 2000
+++ /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSFont.h	Fri Feb  2 21:25:20 2001
@@ -41,7 +41,7 @@
 	UT_uint32			getIndex(void) { return m_index; };	
 	
 	ABIFontInfo *		getMetricsData(void);
-	UT_uint16 *			getUniWidths(void);
+	UT_uint16			getCharWidth(UT_UCSChar c);
 	// perhaps request raw data from PSFont?
  
 protected:
diff -Naur -X /windows/AbiCVS/exclude /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSGraphics.cpp /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSGraphics.cpp
--- /windows/AbiCVS/abi/src/af/xap/unix/xap_UnixPSGraphics.cpp	Sat Dec 23 07:26:08 2000
+++ /windows/AbiCVS/abi_mine/src/af/xap/unix/xap_UnixPSGraphics.cpp	Tue Feb  6 18:30:16 2001
@@ -164,12 +164,12 @@
 	PSFont *pEnglishFont;
 	PSFont *pChineseFont;
 	explodePSFonts(pEnglishFont,pChineseFont);  
-	const UT_uint16 * cwi = pEnglishFont->getUniWidths();
+	
 	if (XAP_EncodingManager::instance->is_cjk_letter(c))
 	    return _scale(pChineseFont->getUnixFont()->get_CJK_Width());
-	else {	
-	    UT_Byte recoded = c <= 0xff ? c : XAP_EncodingManager::instance->try_UToNative(c);
-	    return recoded <= 0xff && recoded!=0  ? _scale(cwi[recoded]) : 0;
+	else
+	{	
+	    return _scale(pEnglishFont->getCharWidth(c));
 	};
 }
 #if 0
@@ -329,7 +329,6 @@
   explodePSFonts(pEnglishFont,pChineseFont);  
   UT_ASSERT(pEnglishFont && pChineseFont);
 
-  const UT_uint16 *cwi = pEnglishFont->getUniWidths();
   const UT_UCSChar *pS;
   const UT_UCSChar *pE=pChars+iCharOffset;
   const UT_UCSChar *pEnd=pChars+iCharOffset+iLength;
@@ -344,7 +343,7 @@
 		  drawCharsCJK(pS,0,pE-pS,xS,yoff);
 		}
 	  for(pS=pE,xS=xoff; pE<pEnd && !XAP_EncodingManager::instance->is_cjk_letter(*pE); ++pE)
-	          xoff+=_scale(cwi[XAP_EncodingManager::instance->UToNative(remapGlyph(*pE,*pS > 0xff))]);
+	          xoff += _scale(pEnglishFont->getCharWidth(remapGlyph(*pE,/**pS > 0xff*/0)));
 	  if(pE>pS)
 		{
 		  _emit_SetFont(pEnglishFont);
@@ -363,9 +362,27 @@
 	    pWctomb = new UT_Wctomb;
 	else
 	    pWctomb->initialize();
-	    
+	
+	const encoding_pair*  enc = 0;
+	UT_AdobeEncoding* ae = 0;
+	
 	UT_ASSERT(m_pCurrentFont);
 
+	if (XAP_EncodingManager::instance->isUnicodeLocale())
+	{
+		enc = m_pCurrentFont->getUnixFont()->loadEncodingFile();
+		if(enc)
+		{
+			ae = new UT_AdobeEncoding(enc, m_pCurrentFont->getUnixFont()->getEncodingTableSize());
+		}
+		else
+		{
+			UT_DEBUGMSG(("UnixPS_Graphics: no encoding available!\n"));
+			UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
+		}
+	}
+
+	
 	// The GR classes are expected to take yoff as the upper-left of
 	// each glyph.  PostScript interprets the yoff as the baseline,
 	// which doesn't match this expectation.  Adding the ascent of the
@@ -382,7 +399,11 @@
 	char _bytes[30];
 	int _bytes_len;
 
-	*pD++ = '(';
+	//when printing 8-bit chars we enclose them in brackets, but 16-bit
+	//chars must be printed by name without brackets
+	
+	UT_Bool open_bracket = UT_FALSE;
+	UT_Bool using_names = UT_FALSE;
 	while (pS<pEnd)
 	{
 		if (pD-buf > OUR_LINE_LIMIT)
@@ -395,8 +416,76 @@
 		}
 
 		// TODO deal with Unicode issues.
-		if (XAP_EncodingManager::instance->is_cjk_letter(*pS)) 
+		if (XAP_EncodingManager::instance->isUnicodeLocale())
+		{
+			currentChar = remapGlyph(*pS, UT_FALSE);
+			if(currentChar > 255)
+			{
+				if(open_bracket)
+				{
+					open_bracket = UT_FALSE;
+					sprintf((char *) pD,") %d %d MS\n",xoff,yoff);
+					m_ps->writeBytes(buf);
+					pD = buf;
+				}
+				else if(!using_names)
+				{
+					sprintf((char *) pD," %d %d MV ",xoff,yoff);
+					pD = buf + strlen(buf);
+					using_names = UT_TRUE;
+				}
+
+				
+				const char * glyph = ae->ucsToAdobe(currentChar);
+				// ' /glyph GS '
+				if(pD - buf + strlen(glyph) + 6 > OUR_LINE_LIMIT)
+				{
+					*pD++ = '\\';
+					*pD++ = '\n';
+					*pD++ = 0;
+					m_ps->writeBytes(buf);
+					pD = buf;
+				}
+				
+				
+				*pD++ = ' ';
+				*pD++ = '/';
+				strcpy(pD, (const unsigned char*)glyph);
+				pD += strlen(glyph);
+				strcpy(pD, " GS ");
+				pD += 4;
+			}
+			else
+			{
+				if(!open_bracket)
+				{
+					*pD++ = '(';
+					open_bracket = UT_TRUE;
+					using_names = UT_FALSE;
+				}
+				
+			    switch (currentChar)
+			    {
+					case 0x08:		*pD++ = '\\';	*pD++ = 'b';	break;
+					case UCS_TAB:	*pD++ = '\\';	*pD++ = 't';	break;
+					case UCS_LF:	*pD++ = '\\';	*pD++ = 'n';	break;
+					case UCS_FF:	*pD++ = '\\';	*pD++ = 'f';	break;
+					case UCS_CR:	*pD++ = '\\';	*pD++ = 'r';	break;
+					case '\\':		*pD++ = '\\';	*pD++ = '\\';	break;
+					case '(':		*pD++ = '\\';	*pD++ = '(';	break;
+					case ')':		*pD++ = '\\';	*pD++ = ')';	break;
+					default:		*pD++ = (unsigned char)currentChar; 	break;
+		    	}
+			}
+		}
+		else if (XAP_EncodingManager::instance->is_cjk_letter(*pS))
 		{		
+			if(!open_bracket)
+			{
+				*pD++ = '(';
+				open_bracket = UT_TRUE;
+				using_names = UT_FALSE;
+			}
 			pWctomb->wctomb_or_fallback(_bytes,_bytes_len,*pS);
 			if (pD+_bytes_len-buf > OUR_LINE_LIMIT)
 			{
@@ -418,6 +507,14 @@
                        }
 
 		} else 	{
+			
+			if(!open_bracket)
+			{
+				*pD++ = '(';
+				open_bracket = UT_TRUE;
+				using_names = UT_FALSE;
+			}
+		
 		    currentChar = remapGlyph(*pS, *pS >= 256 ? UT_TRUE : UT_FALSE);
 		    currentChar = currentChar <= 0xff ? currentChar : XAP_EncodingManager::instance->UToNative(currentChar);
 		    switch (currentChar)
@@ -435,9 +532,20 @@
 		}
 		pS++;
 	}
-	*pD++ = ')';
-	sprintf((char *) pD," %d %d MS\n",xoff,yoff);
+	if(open_bracket)
+	{
+		*pD++ = ')';
+		sprintf((char *) pD," %d %d MS\n",xoff,yoff);
+	}
+	else
+	{
+		*pD++ = '\n';
+		*pD++ = 0;
+	}
+			
 	m_ps->writeBytes(buf);
+	if(ae)
+		delete ae;
 }
 
 void PS_Graphics::drawLine(UT_sint32 x1, UT_sint32 y1, UT_sint32 x2, UT_sint32 y2)
@@ -713,7 +821,10 @@
 		// into the document.  This looks really slow... perhaps buffer line
 		// by line or in larger chunks the font data.
 		XAP_UnixFont * unixfont = psf->getUnixFont();
-		if(unixfont->is_CJK_font())
+		
+		//under unicode locale we do not want to ouptut the fonts, because they
+		//are huge ...
+		if(unixfont->is_CJK_font() || XAP_EncodingManager::instance->isUnicodeLocale())
 		  continue;
 		int match=0;
 		for(int i=0;i<fontKeyCount;++i)
@@ -785,6 +896,8 @@
 	static const char * t[] = {
 		"/FSF {findfont exch scalefont} bind def",			// Find & scale a font. <size> /<fontname> FSD
 		"/MS  {neg moveto show} bind def",					// Move and draw. (<string>) <x> <y> MS
+		"/GS  {glyphshow} bind def",						// show glyph by name
+		"/MV  {neg moveto} bind def",						// Move only
 		"/BP  {gsave 72 exch div dup scale} bind def",		// Begin Page. <res> BP
 		"/SZ  {/HH exch def /WW exch def} bind def",		// Page Size.  <w> <h> SZ
 		"/BPP {BP SZ 0 HH translate} bind def",				// Begin Portrait Page.  <w> <h> <res> BPP
