harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r545915 [4/5] - in /harmony/enhanced/classlib/trunk/modules/awt: ./ src/main/java/common/java/awt/ src/main/java/common/org/apache/harmony/awt/gl/ src/main/java/common/org/apache/harmony/awt/gl/font/ src/main/java/common/org/apache/harmony/...
Date Sun, 10 Jun 2007 17:31:25 GMT
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/AGL.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Viskov Nikolay 
+ * @version $Revision$
+ */
+#include "EncodedValue.h"
+#include <stdio.h>
+
+EncodedValue::EncodedValue(void) {	
+	text = NULL;
+}
+
+EncodedValue::~EncodedValue(void) {
+	delete[] text;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __TYPE_1_ENCODED_VALUE_CLASS_H
+#define __TYPE_1_ENCODED_VALUE_CLASS_H
+
+class EncodedValue {
+public:
+	EncodedValue(void);
+	~EncodedValue(void);  
+
+	unsigned short number;
+	unsigned short length;
+	char* text;
+};
+
+#endif //__TYPE_1_ENCODED_VALUE_CLASS_H

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,372 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+/*#ifdef WIN32
+#include <io.h>
+#else
+#include <glob.h>
+#endif*/
+
+#include "Tables.h"
+#include "Environment.h"
+
+static FontHeader* fhArray = NULL;
+
+//#ifdef WIN32
+//static bool getFonts = false;//true;
+//#endif
+
+int Environment::_length = 0;
+
+FontHeader::FontHeader()
+{
+	_familyName = NULL;
+	_filePath = NULL;
+    _font = NULL;
+    _nextHeader = NULL;
+	_head = NULL;
+}
+
+FontHeader::FontHeader(char** filePath, FontType fType)
+{
+	_filePath = *filePath;
+	_familyName = NULL;
+    _fType = fType;
+	_font = NULL;
+	_nextHeader = NULL;
+	_head = NULL;
+}
+
+FontHeader::~FontHeader()
+{
+    //printf("now = %s , %u \n", (char *)_filePath, _fType);
+	delete _familyName;
+	delete _filePath;
+    //delete _font;
+	delete _nextHeader;
+}
+
+bool fntType(char* font, char* type)
+{
+	bool ret=0;
+	unsigned char j=0;
+
+	int len = (int)strlen(font);
+	for (int i = 0; i<=len; i++)
+	{
+		if (tolower(font[i]) == tolower(type[j])) 
+		{
+			ret = 1;
+			j++;
+		}
+		else 
+		{
+			ret = 0;
+			j=0;
+		}
+	}
+	return ret;
+}
+
+void static inline getNewLexeme(char* str, FILE* font) {
+	unsigned char ch;
+	unsigned short count = 0;
+
+	while (!feof(font) && ((ch = getc(font)) == ' ' || ch == '\n' || ch == '\r')) {
+	}
+
+	str[count ++] = ch;	
+	while (!feof(font) && (ch = getc(font)) != ' ' && ch != '\n' && ch != '\r') {
+		str[count ++] = ch;
+	}
+
+	str[count] = '\0';	
+}
+
+int static inline getT1Name(char *pathToFile,wchar_t** fontFamilyName, StyleName* style) {
+
+	FILE *font;
+	char curStr[1024];
+	char *ptr;
+	unsigned char ch;
+
+	if( font = fopen(pathToFile, "rb")) {	
+
+		ch = getc(font);
+
+		if (ch == 0x80 && getc(font) == 0x01) {
+			//isASCII = false;	
+		} else if (ch == '%' && getc(font) == '!') {
+			//isASCII = true;	
+		} else {
+			fclose(font);
+			return -1;
+		}	
+
+		//printf("\nstart parsing %s\n", pathToFile);
+
+		while (!feof(font)) {
+			getNewLexeme(curStr, font);
+			if (!strcmp(curStr, "/FontInfo")) {
+				break;
+			}
+		}
+
+		while (!feof(font)) {
+			getNewLexeme(curStr, font);
+			if (!strcmp(curStr, "/FamilyName")) {
+
+				unsigned short count = 0;
+
+				while (!feof(font) && ((ch = getc(font)) == '(')) {
+				}
+
+				curStr[count ++] = ch;	
+				while (!feof(font) && (ch = getc(font)) != ')') {
+					curStr[count ++] = ch;
+				}
+
+				curStr[count] = '\0';	
+
+				ptr = curStr;
+
+				//printf("fontFamilyName = ");
+				ch = 0;
+				*fontFamilyName = new wchar_t[count + 1];
+				while (*ptr != '\0') {
+					(*fontFamilyName)[ch ++] = *ptr;
+					//printf("%c", *ptr);
+					ptr ++;
+				}
+
+				(*fontFamilyName)[ch] = L'\0';
+
+				//strncpy(*fontFamilyName, ptr, strlen(ptr) - 1);
+				//printf("fontFamilyName = %s\n", curStr);
+				//printf("\n");
+
+			} else if (!strcmp(curStr, "/Weight")) {
+
+				getNewLexeme(curStr, font);
+				ptr = curStr + 1;
+				if (!strncmp(ptr, "Regular",7)) {
+					*style = Regular;
+				} else if (!strncmp(ptr, "Bold",4)) {
+					if (*style == Italic) {
+						*style = BoldItalic;
+					} else {
+						*style = Bold;
+					}
+				} else if (!strncmp(ptr, "Normal",6)) {
+					*style = Regular;
+				} else {
+					*style = Regular;
+				}
+				//printf("style = %u\n", *style);
+
+			} else if (!strcmp(curStr, "/ItalicAngle")) {
+				getNewLexeme(curStr, font);				
+				double italicAngle = atof(curStr);
+				if (italicAngle) {
+					//printf("\n%f\n",italicAngle);
+					if (*style == Bold) {
+						*style = BoldItalic;
+					} else {
+						*style = Italic;
+					}
+				}
+			} else if (!strcmp(curStr, "end")) {
+				//getNewLexeme(curStr, font);
+				fclose(font);
+				return 0;
+			}
+		}
+	} 
+
+	fclose(font);
+
+    return -1;
+}
+
+FontHeader* addFontFile(char** file, FontType ft)
+{
+	FILE* ttfile;
+	StyleName* fStyle;
+	int result;
+
+	FontHeader *fh = new FontHeader(file, ft);
+
+	switch(ft)
+	{
+	case TrueType:
+		ttfile = fopen(fh->_filePath,"rb");
+		if (ttfile == NULL)
+		{
+			delete fh;
+			return NULL;
+		}
+		fStyle = new StyleName;
+		result = parseNameTable(ttfile, &(fh->_familyName), NULL, fStyle);
+		fclose(ttfile);
+
+		if (fStyle == NULL || result == -1)
+		{
+			delete[] fStyle;
+			delete fh;
+			return NULL;
+		}else {
+			fh->_style=*fStyle;
+		}
+
+		break;
+	case Type1:
+		result = getT1Name(fh->_filePath,&(fh->_familyName), &(fh->_style));
+		if (result == -1)
+		{
+            delete fh;
+			return NULL;
+		}
+		break;
+	default:
+		return NULL;
+	}
+
+	Environment::_length++;
+
+	if (fhArray != NULL)
+	{
+		fh->_head = fhArray->_head;
+		fhArray->_nextHeader = fh;
+		fhArray = fh;
+	} else
+	{
+		fh->_head = fh;
+        fhArray = fh;
+	}
+
+	return fh;
+}
+
+/*static inline FontHeader* add( char* name, char* dir, FontType ft)
+{
+	int len = (int)strlen(dir);
+	char* fontFile = new char[len+strlen(name)+1];
+	strncpy(fontFile, dir, len+1);
+	strcat(fontFile, name);
+	return addFontFile(&fontFile, ft);		
+}*/
+
+FontHeader* Environment::addFile(char* file, FontType ft)
+{
+	int len = (int)strlen(file);
+    char* filepath = new char[len+1];
+	strcpy(filepath,file);
+
+	return addFontFile(&filepath, ft);
+}
+
+/*int Environment::addPath(char* argPath)
+{
+	char* tok;
+	char fDir[1024];
+
+	char deLimits[] = " ;";
+	char currentDir[1024];
+	long hFile;
+
+	char path[1024];
+    strcpy(path,argPath);
+
+    tok = strtok(path, deLimits);
+	while (tok != NULL)
+	{
+		strcpy(fDir,tok);
+		strcpy(currentDir,tok);
+		strcat(currentDir, "*.*");
+//printf("%s\n",currentDir);
+
+#ifdef WIN32
+		struct _finddata_t font_file;
+		if( (hFile = (long)_findfirst( currentDir, &font_file )) != -1L )
+//			printf("No available fonts in %s\n", currentDir);
+//		else
+		{
+			do {
+				if (fntType(font_file.name,".ttf"))
+					add(font_file.name, fDir, TrueType);
+				else if (fntType(font_file.name,".pfa"))
+					add(font_file.name, fDir, Type1);
+				else if (fntType(font_file.name,".pfb"))
+					add(font_file.name, fDir, Type1);
+
+			}while( _findnext( hFile, &font_file ) == 0 );
+		}
+
+        _findclose( hFile );
+#else
+	    glob_t globbuf;
+
+		globbuf.gl_offs = 5; 
+		glob(currentDir, GLOB_NOSORT, NULL, &globbuf); 
+
+		for(char** filesList = globbuf.gl_pathv; *filesList != NULL; filesList++)
+		{
+			if (fntType(*filesList,".ttf"))
+				addFontFile(filesList, TrueType);		
+			else if (fntType(*filesList,".pfa"))
+				addFontFile(filesList, Type1);		
+			else if (fntType(*filesList,".pfb"))
+				addFontFile(filesList, Type1);
+		}
+#endif
+
+		tok = strtok(NULL,deLimits);
+	}
+
+	return 0;
+}*/
+
+/* Getting all installed fonts from windows and user's defined directories */
+FontHeader* Environment::getAllFonts()
+{
+
+	/*if (getFonts)
+	{
+#ifdef WIN32
+		char* WINFONTS = "\\Fonts\\";
+		char winDir[256];
+		strcpy(winDir,getenv("windir"));
+		strcat(winDir,WINFONTS);
+		addPath(winDir);
+
+#else
+	//printf("adding paths...\n");
+	addPath("/usr/X11R6/lib/X11/fonts/truetype/;/usr/X11R6/lib/X11/fonts/Type1/");
+	//printf("paths added\n");
+#endif
+		getFonts = 	false;
+        }    */
+
+    return fhArray == NULL ? NULL : fhArray->_head;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __GRAPHICS_ENVIRONMENT_H__
+#define __GRAPHICS_ENVIRONMENT_H__
+
+#include "Font.h"
+
+typedef enum FontTypeTag {
+    TrueType = 0, 
+    Type1 = 1} FontType;
+
+class FontHeader
+{
+public:
+	wchar_t *_familyName;
+	char* _filePath;
+	StyleName _style;
+    Font* _font;
+	FontType _fType;
+	FontHeader* _nextHeader;
+	FontHeader* _head;
+
+	FontHeader();
+	FontHeader(char** filePath, FontType fType);
+
+	~FontHeader();
+}; 
+
+class Environment
+{
+public:
+	static int _length; //length of list 
+	static int addPath(char* argPath);
+	static FontHeader* addFile(char* argPath, FontType ft);
+	static FontHeader* getAllFonts();
+};
+
+#endif // __GRAPHICS_ENVIRONMENT_H__

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,170 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#include "Font.h"
+#include "Environment.h"
+#include "TTFont.h"
+#include "T1Font.h"
+
+Font::Font() {
+    _famName = NULL;
+}
+
+Font::~Font() {
+	for( std::map<const unsigned long, Glyph*>::iterator iter = _glyphMap.begin(); iter != _glyphMap.end(); iter++ ) {		
+		delete iter->second;		
+	}
+
+	delete[] _famName;
+
+	/*unsigned short famLength = wcslen((wchar_t *)_famName);
+	char *family = new char[famLength+1];
+
+	unsigned short i;
+	for (i = 0;i < famLength;i++) {
+		(family)[i] = _famName[i];
+	}
+	(family)[i] = '\0';
+
+	FontHeader* fh = GraphicsEnvironment::getAllFonts()->_head;
+	//printf("\nfaund = -%s-\n", family);
+	for(int i=0; i<GraphicsEnvironment::_length; i++){
+		//printf("font = -%s-\n", fh->_familyName);
+		if (strcmp(fh->_familyName,family)==0 && fh->_style == _style) {
+			fh->_font = NULL;
+			break;
+		}
+
+		fh=fh->_nextHeader;
+	}
+
+	delete[] family;*/
+}
+
+Glyph* Font::createGlyph(unsigned short unicode, unsigned short size){
+	return NULL; 
+}
+
+wchar_t* Font::getPSName()
+{
+	return NULL;
+}
+
+float* Font::getLineMetrics()
+{
+	return NULL;
+}
+
+int	Font::getMissingGlyphCode()
+{
+	return 0;
+}
+
+bool Font::canDisplay(unsigned short c)
+{
+	return NULL;
+}
+
+unsigned short Font::getUnicodeByIndex(unsigned short ind)
+{
+	return NULL;
+}
+
+//unicode = 0 - default glyph
+Glyph* Font::getGlyph(unsigned short unicode, unsigned short size) {
+	unsigned long id;
+    
+	//printf("unicode = %lu, size = %lu\n", unicode,size);
+
+    if (!canDisplay(unicode)) {
+		id = (unsigned long)(size << 16);
+        unicode = 0;
+    } else {
+		id = (unsigned long)(size << 16) + unicode;
+    }	
+
+    //printf("unicode = %lu, size = %lu, id = %lu\n", unicode,size,id);
+
+	std::map<const unsigned long, Glyph*>::iterator iter = _glyphMap.find(id);	
+	if (iter != _glyphMap.end()) {
+//printf("return the glyph");
+		return (Glyph *)(*iter).second;	
+	}
+//printf("creation of the glyph");
+	Glyph *glyph = createGlyph(unicode, size);
+	
+	_glyphMap[id] = glyph;
+
+	return glyph;	
+}
+
+// Creation of font depending on font type
+Font* createFont(char* family, StyleName sn) {
+	int nLen = (int) strlen(family);
+	wchar_t* name = new wchar_t[nLen+1];
+	for (int i = 0; i <= nLen; i++)
+		name[i] = family[i];
+
+	Font* retFont = createFont(name, sn);
+
+	delete[] name;
+
+	return retFont;
+}
+
+// Creation of font depending on font type
+Font* createFont(wchar_t* family, StyleName sn) 
+{
+	Font* retFont;
+	bool isFound = false;
+
+	if (Environment::getAllFonts() == NULL)	return NULL;
+
+	for(FontHeader* fh = Environment::getAllFonts();
+		fh != NULL; fh=fh->_nextHeader)
+	{
+
+		if (wcscmp(fh->_familyName,family)==0 && fh->_style == sn)
+		{
+
+			switch(fh->_fType)
+			{
+				case TrueType:
+						retFont = new TTFont(fh->_filePath);
+						fh->_font=retFont;
+
+					break;
+				case Type1:					
+						retFont = new T1Font(family,sn,fh->_filePath);
+						fh->_font=retFont;
+
+					break;
+			}
+			isFound = true;
+			break;
+		}
+	}
+	if (!isFound)
+	{
+//		printf("Font not found");
+		return 0; // çäåñü ïîñòàâèòü çíà÷åíèÿ ïî óìîë÷àíèþ
+	}    
+	return retFont;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,100 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __FONT_H__
+#define __FONT_H__
+
+#include <map>
+#include "Glyph.h"
+
+typedef enum StyleNameTag {
+    Regular = 0, 
+    Bold = 1, 
+    Italic = 2, 
+    BoldItalic = 3
+} StyleName;
+
+typedef enum FlagsTag {ANGLE, IS_FIXED_PITCH, BOLD} Flags;
+
+static const unsigned char FONT_METRICS_QUANTITY = 8;
+static const unsigned char GLYPH_METRICS_QUANTITY = 6;
+
+/*
+typedef struct
+{
+	int numChars;
+	int baselineIndex;
+	float underlineThickness;
+	float underlineOffset;
+	float strikethroughThickness;
+    float strikethroughOffset;
+	float leading;
+	float height;
+	float descent;
+	float ascent;
+	float baseLineOffsets[1];
+}LineMetrics;
+*/
+
+class Font {
+public:
+	Font();
+	virtual ~Font();
+
+	Glyph* getGlyph(unsigned short unicode, unsigned short size);
+	Glyph* getDefaultGlyph();
+	int	getMissingGlyphCode();
+
+	virtual Glyph* createGlyph(unsigned short unicode, unsigned short size);
+	virtual	float* getLineMetrics(); 
+	virtual wchar_t* getPSName();
+	virtual bool canDisplay(unsigned short c);
+	virtual unsigned short getUnicodeByIndex(unsigned short ind);
+
+
+//protected:
+	unsigned short _numGlyphs; // Number of available glyphs
+	wchar_t *_famName; // (unsigned short*) Family name
+    StyleName _style; // Font style 
+	//short *_bitmaps; // - (?)
+	float _boundingBox[4]; // Glyphs bounding box - array of 4 shorts
+	float _ascent; 
+	float _descent;
+	float _externalLeading; //lineGap in TrueType
+	float _height;
+	float _strikeOutSize;
+	float _strikeOutOffset;
+    float _underlineOffset;
+    float _underlineThickness;
+	unsigned short _size;
+	std::map<const unsigned long, Glyph*> _glyphMap;//(size << 16 + unicode) -- Glyph	
+	Flags _flags;	
+
+//	virtual unsigned short* getBitmap();
+//	virtual unsigned short* getOutline();
+//	virtual unsigned short* getGlyph();
+private:
+	inline Glyph* findGlyph(unsigned short unicode, unsigned short size, unsigned long id);
+};
+
+Font* createFont(wchar_t* family, StyleName sn);
+Font* createFont(char* family, StyleName sn);
+
+#endif //__FONT_H__

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#include "Glyph.h"
+
+Glyph::Glyph() {
+}
+
+Glyph::~Glyph(void) {
+}
+
+Outline* Glyph::getOutline(void){
+	return NULL;
+}
+
+float* Glyph::getGlyphMetrics(void){
+	return NULL;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __SHARED_GLYPH_CLASS_H
+#define __SHARED_GLYPH_CLASS_H
+
+#include "Outline.h"
+
+class Glyph {
+public:
+	Glyph();
+	virtual ~Glyph(void);
+	virtual Outline* getOutline(void);
+	virtual float* getGlyphMetrics(void);
+
+//protected:
+	unsigned short _size;
+	unsigned short _unicode;	
+	float _advanceX;
+	float _advanceY;
+};
+
+#endif //__SHARED_GLYPH_CLASS_H

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#include "Outline.h"
+
+Outline::Outline(unsigned short pointsNumber, unsigned short commandNumber) {
+	pointsCount = 0;
+	commandsCount = 0;
+
+	_points = new float[_pointsLength = pointsNumber];
+	_commands = new unsigned char[_commandLenght = commandNumber];    
+
+	/*for (commandsCount = 0 ; commandsCount < commandNumber; commandsCount ++) {
+		this->_commands[commandsCount] = SEG_CLOSE;
+	}
+
+	commandsCount = 0;*/
+}
+
+Outline::~Outline() {
+	delete[] _points;
+	delete[] _commands;
+}
+
+void Outline::trim() {
+    if (_commandLenght == commandsCount) {
+		return;
+	}
+
+	//printf("_length = %u, commandsCount = %u\n", _commandLenght, commandsCount);
+
+	unsigned char *commandMas = new unsigned char[commandsCount];
+	float *pointsMas = new float[pointsCount];
+	
+    memcpy(commandMas, _commands, commandsCount);
+    memcpy(pointsMas, _points, pointsCount * sizeof(float));
+
+	delete[] _points;
+	delete[] _commands;
+
+	_points = pointsMas;
+	_commands = commandMas;
+
+    _commandLenght = commandsCount;
+    _pointsLength = pointsCount;
+}
+
+void Outline::lineTo(float x, float y) {
+	_points[pointsCount ++] = x;
+	_points[pointsCount ++] = -y;
+	_commands[commandsCount ++] = SEG_LINETO;
+	//printf("SEG_LINETO ");
+}
+
+void Outline::moveTo(float x, float y) {
+	_commands[commandsCount ++] = SEG_MOVETO;
+	_points[pointsCount ++] = x;
+	_points[pointsCount ++] = -y;
+//	printf("SEG_MOVETO ");
+}
+
+void Outline::quadTo(float x1, float y1, float x2, float y2) {
+	_points[pointsCount ++] = x1;
+	_points[pointsCount ++] = -y1;
+	_points[pointsCount ++] = x2;
+	_points[pointsCount ++] = -y2;
+	_commands[commandsCount ++] = SEG_QUADTO;
+	//printf("SEG_QUADTO ");
+}
+
+void Outline::curveTo(float x1, float y1, float x2, float y2, float x3, float y3) {
+	_points[pointsCount ++] = x1;
+	_points[pointsCount ++] = -y1;
+	_points[pointsCount ++] = x2;
+	_points[pointsCount ++] = -y2;
+	_points[pointsCount ++] = x3;
+	_points[pointsCount ++] = -y3;
+	_commands[commandsCount ++] = SEG_CUBICTO;
+	//printf("SEG_CUBICTO ");
+}
+
+void Outline::closePath(void) {
+	//if (_commands[commandsCount - 1] != SEG_CLOSE) {
+		_commands[commandsCount ++] = SEG_CLOSE;
+	//} 
+        /*else {
+		printf("two close path\n");
+	}*/
+	//printf("SEG_CLOSE\n");
+}
+
+unsigned short Outline::getPointsLength(void) {
+	return _pointsLength;
+}
+
+unsigned short Outline::getCommandLength(void) {
+    return _commandLenght;
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,81 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev, Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __SHARED_OUTLINE_CLASS_H
+#define __SHARED_OUTLINE_CLASS_H
+
+#include <string>
+
+/*typedef enum {
+	SEG_CLOSE = 0,
+	SEG_LINETO = 1, 
+	SEG_MOVETO = 2, 
+	SEG_CUBICTO = 3, 
+	SEG_QUADTO = 4	
+} SegmentType;*/
+
+/*typedef enum SegmentTypeTag {
+    SEG_MOVETO = 0, 	
+	SEG_LINETO = 1, 
+	SEG_QUADTO = 2,
+	SEG_CUBICTO = 3, 		
+    SEG_CLOSE = 4
+} SegmentType;*/
+
+static const unsigned char SEG_MOVETO = 0;
+static const unsigned char SEG_LINETO = 1;
+static const unsigned char SEG_QUADTO = 2;
+static const unsigned char SEG_CUBICTO = 3;
+static const unsigned char SEG_CLOSE = 4;
+
+class Outline {
+public:
+
+	Outline(unsigned short pointsNumber, unsigned short commandNumber);
+
+	~Outline();
+
+	void lineTo(float x, float y);
+
+	void moveTo(float x, float y);
+
+	void quadTo(float x1, float y1, float x2, float y2);
+
+	void curveTo(float x1, float y1, float x2, float y2, float x3, float y3);
+
+	void closePath(void);
+
+	unsigned short getPointsLength(void);
+    unsigned short getCommandLength(void);
+
+	void trim(void);
+
+    float *_points;
+	unsigned char *_commands;
+	
+private:
+	unsigned short _pointsLength;	
+    unsigned short _commandLenght;	
+
+	unsigned short pointsCount;
+	unsigned short commandsCount;
+};
+
+#endif //__SHARED_OUTLINE_CLASS_H

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,1160 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Dmitriy S. Matveev
+ * @version $Revision$
+ */
+#include <stdio.h>
+#include <memory.h>
+
+#include "Tables.h"
+
+static inline unsigned long dwReverse(unsigned long data)
+{
+    unsigned char *dataElems = (unsigned char *) &data;
+    return (unsigned long)((dataElems[0]<<24) | (dataElems[1]<<16) | (dataElems[2]<<8) | dataElems[3]);
+}
+
+/* Reverses WORD bytes order */
+static inline unsigned short wReverse(unsigned short data)
+{
+    return (unsigned short)(((data<<8) & 0xFF00) | ((data>>8) & 0x00FF));
+}
+
+/* Reverses WORD bytes order */
+static inline short wReverse(short data)
+{
+    return (short)(((data<<8) & 0xFF00) | ((data>>8) & 0x00FF));
+}
+
+/* Searching of table, 
+	return TRUE if table founded */
+bool searchTable(unsigned long table, unsigned long* offset, FILE* tt_file)
+{
+    Table_Offset tableOffset;
+    Table_Directory tableDirectory;
+
+    bool isFound = false;
+    int size;
+    int i;
+
+    /* Open font file stream */
+//	if( (tt_file = fopen( fPath,"rb")) == NULL ){
+//		printf("Error opening font file");
+//		return 0;
+//  }
+
+	size = (int)fseek(tt_file,0,SEEK_SET);
+	if (size != 0)
+	{
+#ifdef DEBUG
+		printf("Error seeking table\n");
+#endif 
+		return 0;
+	}
+
+    size = (int)fread(&tableOffset, sizeof(Table_Offset), 1, tt_file);
+    if (size != 1){
+#ifdef DEBUG
+		printf("Error reading font file\n");
+#endif
+        return 0;
+    }
+
+    /* Reverse byte order */
+    tableOffset.version = dwReverse(tableOffset.version);
+    tableOffset.num_tables = wReverse(tableOffset.num_tables);
+//    tableOffset.search_range = wReverse(tableOffset.search_range);
+//    tableOffset.entry_selector = wReverse(tableOffset.entry_selector);
+
+    /* check whether the version is 1.0 */
+    if(tableOffset.version != 0x10000)
+        return 0;
+
+    /* look for 'head' table */
+    for(i=0; i< tableOffset.num_tables; i++)
+	{
+		size = (int)fread(&tableDirectory, sizeof(Table_Directory), 1, tt_file);
+        if ( size != 1){
+#ifdef DEBUG
+            printf("Error reading Table Directory from file.");
+#endif
+            return 0;
+        }
+        if (* (unsigned long*)tableDirectory.tag == table){
+            isFound = true;
+//            tableDirectory.length = dwReverse(tableDirectory.length);
+//            tableDirectory.offset = dwReverse(tableDirectory.offset);
+            *offset = dwReverse(tableDirectory.offset);
+            break;
+        }
+    }
+	return isFound;
+}
+
+int getTableEncode_4(FILE* tt_file, TableEncode* te, unsigned short table_len)
+{
+	unsigned short* tableEncode;
+	unsigned short length;
+	int size, i; 
+
+	length = (table_len - sizeof(Table_encode_header))/sizeof(unsigned short); // in USHORTs
+	tableEncode = new unsigned short[length];
+	
+	/* reading tail of the table */
+	size = (int)fread(tableEncode,sizeof(unsigned short),length,tt_file);
+	if(size != length)
+	{
+#ifdef DEBUG
+		printf("Error reading table encode format 4 from 'cmap' table");
+#endif
+		delete[] tableEncode;
+		tableEncode = NULL;
+		return -1;
+	}
+
+	for(i=0;i<length;i++)
+	{
+		tableEncode[i]=wReverse(tableEncode[i]);
+	}
+    
+	te->TableEncode = tableEncode; // pointer to tail of 'Table_encode' subtable (of 'cmap')
+	return 0;
+}
+
+#ifndef WIN32
+static inline bool compare(wchar_t* wstr, char* str)
+{
+    char cstr[256];
+	wcstombs(cstr,wstr,256);
+	return !strcasecmp(cstr,str);
+}
+#endif
+
+int parseNameTable(FILE* tt_file, wchar_t** familyName, wchar_t** psName, StyleName* fontStyle)
+{
+    unsigned long dwTable = *(unsigned long*)NAME_TABLE;
+    unsigned long offset;
+    Table_name tableName;
+    Name_Entry nameRecord;
+    long curPos;
+	unsigned short *subFamilyName;
+
+    int i, j;
+    int size;
+	bool inFamilyNameCase = false, inSubfamilyNameCase = false, inPSNameCase = false;
+
+    if (searchTable(dwTable, &offset, tt_file))
+	{
+        /* move position to the 'name' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+#ifdef DEBUG
+            printf("Error executing fseek() for 'name' table.");
+#endif
+            return -1;
+        }
+
+		/* read 'name' table header */
+        size = (int)fread(&tableName, sizeof(Table_name) - sizeof(Name_Entry), 1, tt_file);
+        if (size != 1){
+#ifdef DEBUG
+            printf("Error reading Table 'Name' from file.");
+#endif
+            return -1;
+        }
+
+        tableName.num_name_records = wReverse(tableName.num_name_records);
+        tableName.storage_offset = wReverse(tableName.storage_offset);
+
+        /* enumerating NameRecords and finding Family Name value */
+        for(i=0; i < tableName.num_name_records; i++)
+		{
+            size = (int)fread(&nameRecord, sizeof(Name_Entry), 1, tt_file);
+            if (size != 1)
+			{
+#ifdef DEBUG
+                printf("Error reading Name Record from file.");
+#endif
+                return -1;
+            }
+
+            nameRecord.nameID = wReverse(nameRecord.nameID);
+			nameRecord.platformID = wReverse(nameRecord.platformID);
+            if(nameRecord.platformID == WINDOWS_PLATFORM_ID)
+				switch (nameRecord.nameID)
+				{
+				case FAMILY_NAME_ID:
+					if (familyName != NULL && !inFamilyNameCase)
+					{
+						nameRecord.string_length = wReverse(nameRecord.string_length);
+		                nameRecord.string_offset = wReverse(nameRecord.string_offset);
+
+						/* Save current position if someting wrong with family name */
+						curPos = ftell(tt_file);
+						size = fseek(   tt_file,
+							    offset + tableName.storage_offset + nameRecord.string_offset,
+								SEEK_SET);
+				        if (size != 0){
+#ifdef DEBUG
+				            printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+
+
+//		                ZeroMemory(&fontFamilyName, nameRecord.string_length/2 + sizeof(unsigned short));
+
+						unsigned short *fontFamilyName = new unsigned short[nameRecord.string_length/2+1];
+
+//						ZeroMemory(&(fontName[nameRecord.string_length]),1);
+
+						size = (int)fread(fontFamilyName, sizeof(unsigned short), nameRecord.string_length/2, tt_file);
+						if (size != nameRecord.string_length/2)
+						{
+#ifdef DEBUG
+						    printf("Error reading Family Name from file.");
+#endif
+							delete[] fontFamilyName;
+							fontFamilyName = NULL;
+							return -1;
+						}
+
+						for(j=0; j < nameRecord.string_length/2; j++)
+						{
+							(fontFamilyName)[j] = wReverse((fontFamilyName)[j]);
+//printf("%c",(char)(fontFamilyName)[j]);
+						}
+//printf("\n");
+						(fontFamilyName)[j] = 0;
+						inFamilyNameCase = true;
+
+#ifdef WIN32
+						*familyName = (wchar_t*)fontFamilyName;
+#else
+//TODO: To unify this cycle and previous
+						*familyName = new wchar_t[nameRecord.string_length/2+1];
+
+						for(j=0; j < nameRecord.string_length/2+1; j++)
+						{
+                            (*familyName)[j] = (wchar_t)fontFamilyName[j];
+						}
+						delete fontFamilyName;
+#endif
+
+						size = fseek( tt_file, curPos, SEEK_SET);
+				        if (size != 0){
+#ifdef DEBUG
+							printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+					}
+					break;
+				case POSTSCRIPT_NAME_ID:
+					if (psName != NULL && !inPSNameCase)
+					{
+						nameRecord.string_length = wReverse(nameRecord.string_length);
+		                nameRecord.string_offset = wReverse(nameRecord.string_offset);
+
+						/* Save current position if someting wrong with postscript name */
+						curPos = ftell(tt_file);
+						size = fseek(   tt_file,
+							    offset + tableName.storage_offset + nameRecord.string_offset,
+								SEEK_SET);
+				        if (size != 0){
+#ifdef DEBUG
+				            printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+
+						unsigned short *fontPSName = new unsigned short[nameRecord.string_length/2+1];
+
+						size = (int)fread(fontPSName, sizeof(unsigned short), nameRecord.string_length/2, tt_file);
+						if (size != nameRecord.string_length/2)
+						{
+#ifdef DEBUG
+						    printf("Error reading PostScript Name from file.");
+#endif
+							delete[] fontPSName;
+							fontPSName = NULL;
+							return -1;
+						}
+
+						for(j=0; j < nameRecord.string_length/2; j++)
+						{
+							(fontPSName)[j] = wReverse((fontPSName)[j]);
+						}
+						(fontPSName)[j] = 0;
+						inPSNameCase = true;
+
+#ifdef WIN32
+						*psName = (wchar_t*)fontPSName;
+#else
+
+						*psName = new wchar_t[nameRecord.string_length/2+1];
+//TODO: To unify this cycle and previous
+						for(j=0; j < nameRecord.string_length/2+1; j++)
+						{
+                            (*psName)[j] = (wchar_t)fontPSName[j];
+						}
+						delete fontPSName;
+#endif
+
+						size = fseek( tt_file, curPos, SEEK_SET);
+				        if (size != 0){
+#ifdef DEBUG 
+							printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+					}
+					break;
+				case SUBFAMILY_NAME_ID:
+					if(fontStyle != NULL && !inSubfamilyNameCase)
+					{
+						nameRecord.string_length = wReverse(nameRecord.string_length);
+						nameRecord.string_offset = wReverse(nameRecord.string_offset);
+
+					/* Save current position if someting wrong with subfamily name */
+						curPos = ftell(tt_file);
+						size = fseek(   tt_file,
+							    offset + tableName.storage_offset + nameRecord.string_offset,
+								SEEK_SET);
+					    if (size != 0){
+#ifdef DEBUG
+						    printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+
+//					    ZeroMemory(&fontName, nameRecord.string_length + sizeof(unsigned short));
+
+						subFamilyName = new unsigned short[nameRecord.string_length/2+1];
+
+//						ZeroMemory(&(fontName[nameRecord.string_length]),1);
+
+						size = (int)fread(subFamilyName, sizeof(unsigned short), nameRecord.string_length/2, tt_file);
+					    if (size != nameRecord.string_length/2)
+						{
+#ifdef DEBUG
+						    printf("Error reading SubFamily Name from file.");
+#endif
+							delete[] subFamilyName;
+							subFamilyName = NULL;
+							return -1;
+						}
+
+						for(j=0; j < nameRecord.string_length/2; j++)
+						{
+							subFamilyName[j] = wReverse(subFamilyName[j]);
+						}
+						subFamilyName[j] = 0;
+
+#ifdef WIN32
+
+#define COMPARE_IT		(!_wcsicmp((wchar_t *)subFamilyName,L"Italic"))
+#define COMPARE_BD		(!_wcsicmp((wchar_t *)subFamilyName,L"Bold"))
+#define COMPARE_BDIT	(!_wcsicmp((wchar_t *)subFamilyName,L"Bold Italic"))
+#define COMPARE_REG		(!_wcsicmp((wchar_t *)subFamilyName,L"Regular") || !_wcsicmp((wchar_t *)subFamilyName,L"Normal"))
+
+#else
+
+#define COMPARE_IT		(compare((wchar_t *)subFamilyName, "Italic"))
+#define COMPARE_BD		(compare((wchar_t *)subFamilyName, "Bold"))
+#define COMPARE_BDIT	(compare((wchar_t *)subFamilyName, "Bold Italic"))
+#define COMPARE_REG		(compare((wchar_t *)subFamilyName, "Regular") || compare((wchar_t *)subFamilyName, "Normal"))
+
+#endif
+
+						if COMPARE_IT
+						{
+							*fontStyle = Italic;
+							inSubfamilyNameCase = true;
+						}
+						else if COMPARE_BD
+						{
+							*fontStyle = Bold;
+							inSubfamilyNameCase = true;
+						}
+						else if COMPARE_BDIT
+						{
+							*fontStyle = BoldItalic;
+							inSubfamilyNameCase = true;
+						}
+						else if COMPARE_REG
+						{
+							*fontStyle = Regular;
+							inSubfamilyNameCase = true;
+						}
+
+						delete[] subFamilyName;
+						subFamilyName = NULL;
+
+						size = fseek( tt_file, curPos, SEEK_SET);
+				        if (size != 0){
+#ifdef DEBUG
+				            printf("Error executing fseek() for 'name' table.");
+#endif
+							return -1;
+						}
+
+					}
+
+				}
+			}
+		}
+
+
+     /* Close font file stream */
+/*     if( fclose( tt_file ) ){
+        printf("Error closing TrueType font file.");
+        return 0;
+     }
+*/
+//	fclose(tt_file);
+	
+	if  (!inSubfamilyNameCase)
+		fontStyle = NULL;
+	return 0;
+}
+
+int parseHeadTable(FILE* tt_file, float* bbox, short* format, unsigned short* unitsPerEm)
+{
+    unsigned long hTable = *(unsigned long*)HEAD_TABLE;
+	unsigned long offset;
+    Table_head tableHead;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'head' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+#ifdef DEBUG
+            printf("Error executing fseek() for 'head' table.");
+#endif
+            return -1;
+        }
+
+		/* read 'head' table header */
+        size = (int)fread(&tableHead, sizeof(Table_head), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'Head' from file.");
+            return -1;
+        }
+
+		bbox[0] = wReverse(tableHead.xMin);
+		bbox[1] = wReverse(tableHead.yMin);
+		bbox[2] = wReverse(tableHead.xMax);//for wingding must be -432(?)
+		bbox[3] = wReverse(tableHead.yMax);
+
+		tableHead.index_to_loc_format=wReverse(tableHead.index_to_loc_format);
+		if (wReverse(tableHead.glyph_data_format))
+		{
+//		if (tableHead.index_to_loc_format == 1 || tableHead.index_to_loc_format == 0)
+            *format = !tableHead.index_to_loc_format;
+		}
+		else 
+		{
+			*format = tableHead.index_to_loc_format;
+//			printf("debug information: see 'loca' table format!!!\n");
+		}
+
+		*unitsPerEm = wReverse(tableHead.units_per_EM);
+	}
+
+// ******* Validating data *********
+
+//	HDC hDC = GetDC(NULL);
+//	HDC hDC = GetDC(NULL);
+//	Table_head tableHead1;
+//	unsigned long tbl = (unsigned long)"head";
+//	int m = GetFontData(hDC,tbl,(unsigned long)offset,&tableHead1,sizeof(Table_head));
+
+// ******* Validating data *********
+//	return *bbox;
+//	fclose(tt_file);
+	return 0;
+}
+
+int parseMaxpTable(FILE* tt_file, unsigned short* numGlyphs)
+{
+    unsigned long hTable = *(unsigned long*)MAXP_TABLE;
+	unsigned long offset;
+    Table_maxp tableMaxp;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'maxp' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'maxp' table.");
+            return -1;
+        }
+
+		/* read 'maxp' table header */
+        size = (int)fread(&tableMaxp, sizeof(Table_maxp), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'maxp' from file.");
+            return -1;
+        }
+	}else 
+	{
+		return -1;
+	}
+
+	*numGlyphs = wReverse(tableMaxp.numGlyphs);
+	tableMaxp.maxPoints = wReverse(tableMaxp.maxPoints);
+	tableMaxp.maxContours = wReverse(tableMaxp.maxContours);
+	tableMaxp.maxCompositePoints = wReverse(tableMaxp.maxCompositeContours); //must be 141 for wingding(?)
+	tableMaxp.maxCompositeContours = wReverse(tableMaxp.maxCompositeContours);
+	tableMaxp.maxStackElements = wReverse(tableMaxp.maxStackElements);
+	tableMaxp.maxSizeOfInstructions = wReverse(tableMaxp.maxSizeOfInstructions);
+
+//	fclose(tt_file);
+	return 0;
+}
+
+int parseHheaTable(FILE* tt_file, unsigned short* numOfHMetrics, float* ascent, float* descent, float* lineGap)
+{
+    unsigned long hTable = *(unsigned long*)HHEA_TABLE;
+	unsigned long offset;
+    Table_hhea tableHhea;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'hhea' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'hhea' table.");
+            return -1;
+        }
+
+	/* read 'hhea' table header */
+        size = (int)fread(&tableHhea, sizeof(Table_hhea), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'hhea' from file.");
+            return -1;
+        }
+	}else
+	{
+		return -1;
+	}
+
+	*numOfHMetrics = wReverse(tableHhea.number_of_hMetrics);
+	*ascent = wReverse(tableHhea.ascender);
+	*descent = wReverse(tableHhea.descender);
+	*lineGap = wReverse(tableHhea.line_gap);
+
+	return 0;
+}
+
+int parseOs2Table(FILE* tt_file, float* strikeOutSize, float* strikeOutOffset)
+{
+    unsigned long hTable = *(unsigned long*)OS2_TABLE;
+	unsigned long offset;
+    Table_os2 tableOs2;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'OS/2' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'OS/2' table.");
+            return -1;
+        }
+
+	/* read 'OS/2' table header */
+        size = (int)fread(&tableOs2, sizeof(Table_os2), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'OS/2' from file.");
+            return -1;
+        }
+	} else
+	{
+		return -1;
+	}
+
+//	tableOs2.usFirstCharIndex = wReverse(tableOs2.usFirstCharIndex);
+//	*ascent = wReverse(tableOs2.sTypoAscender);
+//	*descent = wReverse(tableOs2.sTypoDescender);
+	*strikeOutSize = wReverse(tableOs2.yStrikeoutSize);
+	*strikeOutOffset = wReverse(tableOs2.yStrikeoutPosition);
+//	fclose(tt_file);
+
+	return 0;
+}
+
+int parsePostTable(FILE* tt_file, short* uOffset, short* uThickness)
+{
+    unsigned long hTable = *(unsigned long*)POST_TABLE;
+	unsigned long offset;
+    Table_post tablePost;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'post' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'post' table.");
+            return -1;
+        }
+
+	/* read 'post' table header */
+        size = (int)fread(&tablePost, sizeof(Table_post), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'post' from file.");
+            return -1;
+        }
+	} else
+	{
+		return -1;
+	}
+
+	*uOffset = wReverse(tablePost.underlineOffset);
+	*uThickness = wReverse(tablePost.underlineThickness);
+
+	return 0;
+}
+
+int parseHmtxTable(FILE* tt_file, unsigned short numOfHMetrics, HMetrics** hm)
+{
+    unsigned long hTable = *(unsigned long*)HMTX_TABLE;
+	unsigned long offset;
+
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'hmtx' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'OS/2' table.");
+            return -1;
+        }
+		/* read 'hmtx' table */
+		*hm = new HMetrics[numOfHMetrics];
+
+        size = (int)fread(*hm, sizeof(HMetrics), numOfHMetrics, tt_file);
+        if (size != numOfHMetrics){
+			delete[] hm;
+//            printf("Error reading Table 'hmtx' from file.");
+            return -1;
+        }
+
+		for (int i=0; i<numOfHMetrics;i++)
+		{
+			(*hm)[i].adwance_width = wReverse((*hm)[i].adwance_width);
+		}
+
+	} else
+	{
+		return -1;
+	}
+
+	return 0;
+}
+
+int parseLocaTable(FILE* tt_file, GlyphOffsets* gOffsets, unsigned short numGlyphs)
+{
+	unsigned long hTable = *(unsigned long*)LOCA_TABLE;
+	unsigned long gTable = *(unsigned long*)GLYF_TABLE;
+	unsigned long offset,localGlyfOffset;
+
+	unsigned long *gLongOffsets = NULL;
+	unsigned short *gShortOffsets = NULL;
+    int size, i;
+
+	gLongOffsets = new unsigned long[numGlyphs+1];
+	if (!(*gOffsets).format)
+		gShortOffsets = new unsigned short[numGlyphs+1];
+
+    if (searchTable(hTable, &offset, tt_file) && searchTable(gTable,&localGlyfOffset,tt_file))
+	{
+        /* move position to the 'loca' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0)
+		{
+//            printf("Error executing fseek() for 'loca' table.");
+
+			delete[] gLongOffsets;
+			gLongOffsets = NULL;
+
+			if (gOffsets->format)
+			{
+				delete[] gShortOffsets;
+			}
+            return -1;
+        }
+
+		/* read 'loca' table */
+		if (gOffsets->format)
+		{
+			size = (int)fread(gLongOffsets, sizeof(long),numGlyphs+1, tt_file);
+			if (size != numGlyphs+1)
+			{
+//				printf("Error reading Table 'loca' from file.");
+				delete[] gLongOffsets;
+				gLongOffsets = NULL;
+				return -1;
+			}
+			for (i=0; i<=numGlyphs; i++)
+				gLongOffsets[i] = dwReverse(gLongOffsets[i])+localGlyfOffset;
+		}else
+		{
+			size = (int)fread(gShortOffsets, sizeof(short), numGlyphs+1, tt_file);
+			if (size != numGlyphs+1)
+			{
+//				printf("Error reading Table 'loca' from file.");
+				delete[] gShortOffsets;
+				gShortOffsets = NULL;
+				delete[] gLongOffsets;
+				gLongOffsets = NULL;
+				return -1;
+			}
+			for (i=0;i<=numGlyphs;i++)
+				gLongOffsets[i] = wReverse(gShortOffsets[i])*2+localGlyfOffset;
+		}
+		(*gOffsets).offsets = gLongOffsets;
+		delete[] gShortOffsets;
+	}
+
+//	fclose(tt_file);
+
+	return 0;
+};
+
+int parseCmapTable(FILE* tt_file, TableEncode* te)
+{
+	unsigned long hTable = *(unsigned long*)CMAP_TABLE;
+	unsigned long offset;
+    Table_cmap tableCmap;
+	Cmap_Entry cmapRecord;
+	Table_encode_header tableEncodeHeader;
+	long curPos;
+
+    int i;
+    int size;
+
+    if (searchTable(hTable, &offset, tt_file))
+	{
+        /* move position to the 'cmap' table */
+        size = fseek(tt_file, offset, SEEK_SET);
+        if (size != 0){
+//            printf("Error executing fseek() for 'cmap' table.");
+            return -1;
+        }
+
+		/* read 'cmap' table header */
+        size = (int)fread(&tableCmap, sizeof(Table_cmap) - sizeof(Cmap_Entry), 1, tt_file);
+        if (size != 1){
+//            printf("Error reading Table 'cmap' from file.");
+            return -1;
+        }
+        
+		tableCmap.numSubTables = wReverse(tableCmap.numSubTables);
+
+		for(i=0; i < tableCmap.numSubTables; i++)
+		{
+            size = (int)fread(&cmapRecord, sizeof(Cmap_Entry), 1, tt_file);
+            if (size != 1)
+			{
+//                printf("Error reading cmap Record from file.");
+                return -1;
+            }
+
+			cmapRecord.encodingID = wReverse(cmapRecord.encodingID);
+			cmapRecord.platform = wReverse(cmapRecord.platform);
+
+            if(cmapRecord.platform == WINDOWS_PLATFORM_ID)
+			{
+				switch (cmapRecord.encodingID)
+				{
+				case UNICODE_ENCODING:
+					cmapRecord.table_offset = dwReverse(cmapRecord.table_offset);
+
+					/* Save current position if someting wrong with family name */
+					curPos = ftell(tt_file);
+					size = fseek(   tt_file, offset + cmapRecord.table_offset, SEEK_SET);
+			        if (size != 0){
+//			            printf("Error executing fseek() for 'cmap' table.");
+			            return -1;
+					}
+
+
+					size = (int)fread(&tableEncodeHeader, sizeof(Table_encode_header), 1, tt_file);
+					if (size != 1)
+					{
+//						printf("Error reading Table Encode from file.");
+						return -1;
+					}
+
+					tableEncodeHeader.format	= wReverse(tableEncodeHeader.format);
+					tableEncodeHeader.length	= wReverse(tableEncodeHeader.length);
+					tableEncodeHeader.version	= wReverse(tableEncodeHeader.version);
+
+					if (tableEncodeHeader.format == 0 && te->TableEncode == NULL) 
+					{
+						unsigned char *map = new unsigned char[256];
+						te->format = 0;
+                        size = (int)fread(map, sizeof(unsigned char), 256, tt_file);
+						if (size != 256)
+						{
+//							printf("Error reading map format 0");
+							delete[] map;
+							map = NULL;
+						} else
+						{
+							te->TableEncode = map;
+						}
+
+					}else if (tableEncodeHeader.format == 4 && te->TableEncode == NULL)
+					{
+						te->format = 4;
+						getTableEncode_4(tt_file, te, tableEncodeHeader.length);
+					}
+					size = fseek( tt_file, curPos, SEEK_SET);
+			        if (size != 0){
+//			            printf("Error executing fseek() for 'name' table.");
+						return -1;
+					}
+
+					break;
+				}
+			}
+		}
+	}
+
+//	fclose(tt_file);
+	return 0;
+}
+
+int parseGlyphData(FILE* tt_file, const GlyphOffsets gO, unsigned short numGlyphs, unsigned short glyphIndex, TTCurve *curve, short* bRect, float transform)
+{
+	unsigned long offset;
+	Glyph_header glyphHeader;
+	short numOfContours;
+	unsigned short *endPtsOfContours = NULL; 
+	unsigned short instructionLength;//instruction length in bytes
+	unsigned char* instructions = NULL;
+	unsigned char* flags = NULL;
+	unsigned char* xCoord = NULL; //pointer to array of X coordinates
+	unsigned char* yCoord = NULL; //pointer to array of Y coordinates
+	unsigned char* tmp = NULL;
+
+	int numPoints; // number of Points
+	int size, i, j, curLen;
+	int flagIndex = 0; 
+	int xCoordIndex = 0;
+	int yCoordIndex = 0;
+	int rep = 0;
+
+	short xLength = 0; //length of array of X coordinates
+	short yLength = 0; //length of array of Y coordinates
+	unsigned char curFlag = 0;
+
+	if (glyphIndex >= numGlyphs)
+	{
+//		printf("debug info: glyphIndex out of range");
+		glyphIndex = 0;
+	}
+
+	offset = gO.offsets[glyphIndex];
+	if (offset == gO.offsets[glyphIndex+1])
+	{
+		curve->add(0,0, 1);
+		return 0;
+	}
+
+	size = fseek(tt_file, offset, SEEK_SET);
+	if (size != 0){
+//		printf("Error executing fseek() for someone glyph.");
+		return -1;
+	}
+
+	/* read 'Glyph_header' table */
+	size = (int)fread(&glyphHeader, sizeof(Glyph_header), 1, tt_file);
+	if (size != 1){
+//		printf("Error reading 'Glyph_header' table from file.");
+		return -1;
+	}
+
+	glyphHeader.number_of_contours = wReverse(glyphHeader.number_of_contours);
+	numOfContours = glyphHeader.number_of_contours;
+	bRect[0] = (short)(wReverse(glyphHeader.xMin)*transform);
+	bRect[1] = (short)(wReverse(glyphHeader.yMin)*transform);
+	bRect[2] = (short)(wReverse(glyphHeader.xMax)*transform);
+	bRect[3] = (short)(wReverse(glyphHeader.yMax)*transform);
+	
+	if (numOfContours > 0)
+	{
+		endPtsOfContours = new unsigned short[numOfContours];
+		size = (int)fread(endPtsOfContours, sizeof(short),numOfContours,tt_file);
+		if (size != numOfContours)
+		{
+//			printf("Error reading endPtsOfContours for someone glyph.");
+			delete endPtsOfContours;
+			return -1;
+		}
+
+		for (i=0; i<numOfContours; i++)
+		{
+			endPtsOfContours[i] = wReverse(endPtsOfContours[i]);
+		}
+		numPoints = endPtsOfContours[i-1] + 1;
+
+		size = (int)fread(&instructionLength,sizeof(short),1,tt_file);
+		if (size != 1)
+		{
+//			printf("Error reading length of instructions./n");
+			delete[] endPtsOfContours;
+			return -1;
+		}
+		instructionLength = wReverse(instructionLength);
+
+		instructions = new unsigned char[instructionLength];
+		size = (int)fread(instructions,sizeof(unsigned char),instructionLength,tt_file);
+		if (size != instructionLength)
+		{
+//			printf("Error reading instructions./n");
+			delete[] instructions;
+			delete[] endPtsOfContours;
+			return -1;
+		}
+
+		curLen=0;
+		flags = NULL;
+
+		for (i=0; i<numPoints; i++)
+		{
+            int x_repeat = 0;
+			int y_repeat = 0;
+
+			tmp = flags;
+			curLen++;
+			flags = new unsigned char[curLen];
+			memcpy(flags,tmp,curLen-1);
+			delete[] tmp;
+			size = (int)fread(&(flags[curLen-1]),sizeof(unsigned char),1,tt_file);
+			if (size != 1)
+			{
+//                printf("Error reading array of flags from font file.\n");
+				delete[] flags; 
+				delete[] instructions;
+				delete[] endPtsOfContours;
+				return -1;
+			}
+            
+			if ((flags[curLen-1] & X_POSITIVE) == X_POSITIVE ||
+				(flags[curLen-1] & X_POSITIVE) == X_NEGATIVE)	
+				x_repeat = 1;
+			else if ((flags[curLen-1] & X_POSITIVE) == X_DWORD)
+				x_repeat = 2;
+
+			if ((flags[curLen-1] & Y_POSITIVE) == Y_POSITIVE ||
+				(flags[curLen-1] & Y_POSITIVE) == Y_NEGATIVE)	
+				y_repeat = 1;
+			else if ((flags[curLen-1] & Y_POSITIVE) == Y_DWORD)
+				y_repeat = 2;
+
+			if(flags[curLen-1] & REPEAT)
+			{
+                tmp = flags;
+				curLen++;
+				flags = new unsigned char[curLen];
+				memcpy(flags,tmp,curLen-1);
+				delete[] tmp;
+				size=(int)fread(&(flags[curLen-1]),sizeof(unsigned char),1,tt_file);
+				if (size != 1)
+				{
+//					printf("Error reading array of flags from font file.\n");
+					delete[] flags;
+					delete[] instructions;
+					delete[] endPtsOfContours;
+					return -1;
+				}
+
+                xLength += x_repeat*(flags[curLen-1] + 1);
+				yLength += y_repeat*(flags[curLen-1] + 1);
+
+				i += flags[curLen-1];
+
+			} else
+				xLength += x_repeat;
+				yLength += y_repeat;
+		}
+
+        xCoord = new unsigned char[xLength];
+		yCoord = new unsigned char[yLength];
+
+		size = (int)fread(xCoord,sizeof(unsigned char),xLength,tt_file);
+		if (size != xLength)
+		{
+//			printf("Error reading x-coordinate of glyph's point.\n");
+			delete[] flags;
+			delete[] instructions;
+			delete[] endPtsOfContours;
+			return -1;
+		}
+
+		size = (int)fread(yCoord,sizeof(unsigned char),yLength,tt_file);
+		if (size != yLength)
+		{
+//			printf("Error reading coordinates of glyph points.\n");
+			delete[] flags;
+			delete[] instructions;
+			delete[] endPtsOfContours;
+			return -1;
+		}
+		
+		i=0;
+		rep=0;
+		int x=0, y=0;
+		float xFirstInContour,yFirstInContour;
+		bool contBegin; //íà÷àëî êîíòóðà
+
+		for (j=0; j<numOfContours;j++)
+		{
+			int repLim = endPtsOfContours[j];
+			contBegin = 1;
+			
+			while(i<=repLim)
+			{
+                if (rep==0)
+				{
+					curFlag = flags[flagIndex];
+					flagIndex++;
+					rep = 1;
+
+					if (curFlag & REPEAT)
+					{
+						rep += flags[flagIndex];
+						flagIndex++;
+					}
+				}
+
+				int xChange = 0, yChange = 0;
+
+				if ((curFlag & X_POSITIVE) == X_POSITIVE)
+				{
+					xChange = xCoord[xCoordIndex]; 
+					xCoordIndex++;
+				}else if ((curFlag & X_POSITIVE) == X_NEGATIVE)
+				{
+					xChange = -xCoord[xCoordIndex]; 
+					xCoordIndex++;
+				}else if ((curFlag & X_POSITIVE) == X_DWORD)
+				{
+					xChange = (short)((xCoord[xCoordIndex]<<8)+xCoord[xCoordIndex+1]);
+					xCoordIndex+=2;
+				}
+
+				if ((curFlag & Y_POSITIVE) == Y_POSITIVE)
+				{
+					yChange = yCoord[yCoordIndex]; 
+					yCoordIndex++;
+				}else if ((curFlag & Y_POSITIVE) == Y_NEGATIVE)
+				{
+					yChange = -yCoord[yCoordIndex]; 
+					yCoordIndex++;
+				}else if ((curFlag & Y_POSITIVE) == Y_DWORD)
+				{
+					yChange = (short)((yCoord[yCoordIndex]<<8)+yCoord[yCoordIndex+1]);
+					yCoordIndex+=2;
+				}
+
+				if((flagIndex >1) && !(curFlag & ON_CURVE ) && 
+					((rep == 1) ? (!(flags[flagIndex-2] & ON_CURVE)) : (!(flags[flagIndex-3] & ON_CURVE))))
+					curve->add((x+xChange/2)*transform,(y+yChange/2)*transform,FLAG_ONCURVE);
+
+
+				x+=xChange;
+				y+=yChange;
+
+				if (contBegin)
+				{
+					curve->add(x*transform,y*transform, 1);
+					xFirstInContour = x*transform;
+					yFirstInContour = y*transform;
+
+					contBegin = 0;
+				} else 
+                    curve->add(x*transform,y*transform, curFlag & ON_CURVE ? FLAG_ONCURVE : 0);
+
+				rep--;
+				i++;
+			}
+			curve->add(xFirstInContour,yFirstInContour,FLAG_ONCURVE);
+		}
+	}
+
+
+	delete[] xCoord;
+	delete[] yCoord;
+	delete[] flags;
+	delete[] endPtsOfContours;
+	delete[] instructions;
+
+	return 0;
+}
+
+/* Should be removed when the composite glyph parsing will be realized */
+bool isCompositeGlyph(FILE* tt_file, const GlyphOffsets gO, unsigned short numGlyphs, unsigned short glyphIndex)
+{
+	unsigned long offset;
+	Glyph_header glyphHeader;
+
+	int size;
+
+	if (glyphIndex >= numGlyphs) 
+		glyphIndex = 0;
+
+	offset = gO.offsets[glyphIndex];
+	if (offset == gO.offsets[glyphIndex+1])
+		return false;
+
+/*printf("glyphIndex = %d\n",glyphIndex);
+if (tt_file == NULL)
+printf("file is NULL\n");
+else
+printf("file isn't NULL\n");*/
+	size = fseek(tt_file, offset, SEEK_SET);
+	if (size != 0)
+{
+//printf("return false\n");
+		return false;
+}
+//printf("second return\n");
+	/* read 'Glyph_header' table */
+	size = (int)fread(&glyphHeader, sizeof(Glyph_header), 1, tt_file);
+	if (size != 1)
+		return false;
+//printf("third return\n");
+	return wReverse(glyphHeader.number_of_contours) < 0;
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp Sun Jun 10 10:31:22 2007
@@ -0,0 +1,684 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Viskov Nikolay 
+ * @version $Revision$
+ */
+
+#include <string>
+
+#include "T1Font.h"
+#include "T1Glyph.h"
+
+T1Font::T1Font(wchar_t *family, StyleName sn, char* pathToFile):Font() {
+	//this->_famName = family;
+	_style = sn;   
+
+    fullName = NULL;
+
+	FILE *inputFile;
+
+	if( inputFile = fopen(pathToFile, "rb")) {	
+
+		try {
+			initFont(inputFile);
+		} catch (char*) {
+			//printf("%s", str);
+		} 
+		
+		fclose(inputFile);	
+
+        //set default ascent and descent
+        _ascent = 649;
+        _descent = 195;
+
+
+        char path[MAX_STR_LENGHT];
+        size_t length = strlen(pathToFile) - 3;
+
+        strncpy(path, pathToFile, length);
+        strcpy(path + length, "afm");        
+
+        if( inputFile = fopen(path, "rb")) {
+
+		    try {
+			    parseAFM(inputFile);
+		    } catch (...) {
+			    //printf("%s", str);
+		    } 
+    		
+		    fclose(inputFile);
+	    }
+
+	}
+
+}
+
+T1Font::~T1Font(void) {
+
+	for( Type1Map::iterator iter = subrsMap.begin(); iter != subrsMap.end(); iter++ ) {		
+		delete iter->second;		
+	}
+
+	for( Type1Map::iterator iter = charStringMap.begin(); iter != charStringMap.end(); iter++ ) {		
+		delete iter->second;		
+	}
+
+    /*for( Type1AFMMap::iterator iter = afmMap.begin(); iter != afmMap.end(); iter++ ) {		
+		delete[] iter->second;		
+	}*/
+
+    delete fullName;
+}
+
+Glyph* T1Font::createGlyph(unsigned short unicode, unsigned short size) {    
+
+    /*float floatMas[4];
+    
+    Type1AFMMap::iterator iter = afmMap.find(unicode); 
+
+    //return iter == glyphCodeMap.end()? NULL : (unsigned short)iter->second;
+
+    memcpy(floatMas, _boundingBox, 4 * sizeof(float));    
+
+    if (iter != afmMap.end()) {
+        //printf("%s\n", iter->second);
+        char* curValue = strstr( iter->second, " B ");
+        if (curValue != NULL) {
+
+            curValue += 3; 
+
+            floatMas[0] = (float) atof(curValue);
+            //printf("0 = %f\n", floatMas[0]);
+
+            while (*(++curValue) != ' ') {
+			}
+
+            floatMas[1] = (float) atof(curValue);
+            //printf("1 = %f\n", floatMas[1]);
+
+            while (*(++curValue) != ' ') {
+			}
+
+            floatMas[2] = (float) atof(curValue);           
+            //printf("2 = %f\n", floatMas[2]);
+
+            while (*(++curValue) != ' ') {
+			}
+
+            floatMas[3] = (float) atof(curValue);
+            //printf("3 = %f\n", floatMas[3]);
+        }
+    }*/
+
+    Glyph *glyph = new T1Glyph(&(this->charStringMap), &(this->subrsMap), unicode, size, size / matrixScale, _boundingBox);
+	
+	return glyph;
+}
+
+//TODO: owerwrite this:
+wchar_t* T1Font::getPSName() {
+	return fullName;
+}
+
+float* T1Font::getLineMetrics() {
+    /*
+     * metrics[0] - ascent<p>
+     * metrics[1] - descent<p>
+     * metrics[2] - external leading<p>
+     * metrics[3] - underline thickness<p>
+     * metrics[4] - underline offset<p>
+     * metrics[5] - strikethrough thickness<p>
+     * metrics[6] - strikethrough offset<p>
+     * metrics[7] - maximum char width<p>*/
+
+    float* floatMas = new float[FONT_METRICS_QUANTITY];
+
+    floatMas[0] = _ascent / matrixScale; //ascent
+    floatMas[1] = _descent / matrixScale; //descent
+    floatMas[2] = (_height - _ascent - _descent) / matrixScale;//_externalLeading;
+
+	floatMas[3] = _underlineThickness / matrixScale;
+	floatMas[4] = _underlineOffset / matrixScale;
+	
+    floatMas[5] = _underlineThickness / matrixScale;//_strikeOutSize;
+	floatMas[6] = -_ascent/(2 * matrixScale);//_strikeOutOffset;
+
+	floatMas[7] = ((float)(_boundingBox[3] - _boundingBox[1])) / matrixScale;
+	
+	return floatMas;
+}
+
+bool T1Font::canDisplay(unsigned short ch) {    
+	return this->charStringMap.find(ch) != this->charStringMap.end();
+}
+
+unsigned short T1Font::getUnicodeByIndex(unsigned short index) {
+    Type1GlyphCodeMap::iterator iter = glyphCodeMap.find(index); 
+
+    return iter == glyphCodeMap.end()? 0 : (unsigned short)iter->second;
+}
+
+void error(){
+	//printf("invalidfont");
+	throw "invalidfont";
+}
+
+unsigned inline short hexCharToUShort(char ch){
+	return  ch >= '0' && ch <= '9' ? ch - '0' :
+			ch >= 'A' && ch <= 'F' ? ch - 'A' + 10 :
+			ch >= 'a' && ch <= 'f' ? ch - 'a' + 10 :			
+			0;   
+}
+
+void static getNextLine(char* str, FILE* font) {
+	unsigned short count = 0;
+	unsigned char ch = ' ';
+
+    while (!feof(font) && (ch == ' ' || ch == '\n' || ch == '\r')) {
+        ch = getc(font);
+	}
+
+    str[count] = ch;
+	while (!feof(font) && ch != '\r' && ch != '\n') {
+		str[++count] = (ch = getc(font));
+	}
+	
+	str[count] = '\0';
+}
+
+unsigned static char getNextChar(FILE* font) {
+	unsigned char ch;	
+	do {
+		ch = getc(font);
+	} while (ch == '\r' || ch == '\n');
+
+	return ch;
+}
+
+unsigned static char decryptNextSimbol(FILE* font, unsigned short* r, bool isASCII) {
+	unsigned char clipher = (unsigned char)(
+		isASCII ? 
+		(unsigned char) ((hexCharToUShort(getNextChar(font)) << 4 ) + (hexCharToUShort(getNextChar(font)))) : 
+		getc(font)
+	);
+
+	unsigned char plain = (unsigned char)(clipher ^ (*r >> 8));
+	*r = ( (unsigned char)clipher + *r ) * C1 + C2;	
+	return plain;
+}
+
+void static decodeASCIILine(char* str, unsigned short* r, unsigned short n, unsigned short length) {
+	char* p = str;
+	unsigned char plain;
+	unsigned char clipher;
+	unsigned short count = 0;	
+	length /= 2;	
+	
+	while(count < length) {
+		clipher = (unsigned char)((hexCharToUShort(*p) << 4 ) + (hexCharToUShort(*(p + 1))));
+
+		plain = (unsigned char)(clipher ^ (*r >> 8));
+		*r = ( (unsigned char)clipher + *r ) * C1 + C2;
+
+		if (count >= n) {
+			str[count - n] = plain;
+		}
+
+		count ++;
+
+		p+= 2;
+	}		
+	str[count - n] = '\0';
+}
+
+void static decodeBinaryLine(char* str, unsigned short* r, unsigned short n, unsigned short length) {
+	char* p = str;
+	unsigned char plain;
+	unsigned char clipher;
+	unsigned short count = 0;		
+	while(count < length) {
+		clipher = (unsigned char)*p;
+		
+		plain = (unsigned char)(clipher ^ (*r >> 8));
+		*r = ( (unsigned char)clipher + *r ) * C1 + C2;
+
+		if (count >= n) {
+			str[count - n] = plain;
+		}
+
+		count ++;
+
+		p ++;
+	}		
+	str[count - n] = '\0';
+}
+
+void static decodeLine(char* str, unsigned short* r, unsigned short n, bool isASCII, unsigned short length) {
+
+	if (isASCII) {
+		decodeASCIILine(str,r,n,length);
+	} else {
+		decodeBinaryLine(str,r,n,length);
+	}
+	return;
+	/*char* p = str;
+	unsigned char plain;
+	unsigned char clipher;
+	unsigned short count = 0;	
+	if (isASCII) {
+		length /= 2;	
+	}
+	while(count < length) {
+		clipher = (unsigned char)(isASCII ? ((hexCharToUShort(*p) << 4 ) + (hexCharToUShort(*(p + 1)))) : *p);
+
+		plain = (unsigned char)(clipher ^ (*r >> 8));
+		*r = ( (unsigned char)clipher + *r ) * C1 + C2;
+
+		//printf("%u ---- %u,%u\n", clipher, plain, *r);
+		if (count >= n) {
+			str[count - n] = plain;
+		}
+
+		count ++;
+
+		p+= isASCII ? 2 : 1;
+	}		
+	str[count - n] = '\0';//*/
+}
+
+void static getNextDecodeLine(char* str, FILE* font, unsigned short* r, bool isASCII) {
+	unsigned short count = 0;
+	unsigned char plain;
+	while(!feof(font)) {		
+		plain = decryptNextSimbol(font, r, isASCII);
+
+		str[count ++] = plain;		
+
+		if (plain == '\r' || plain == '\n') {
+			break;		
+		}
+	}		
+	
+	str[count] = '\0';
+}
+
+void static getNextDecodeLexeme(char* str, FILE* font, unsigned short* r, bool isASCII) {
+	unsigned char ch;
+	unsigned short count = 0;
+
+	while (!feof(font) && ((ch = decryptNextSimbol(font, r, isASCII)) == ' ' || ch == '\n' || ch == '\r')) {
+	}
+
+	str[count ++] = ch;	
+	while (!feof(font) && (ch = decryptNextSimbol(font, r, isASCII)) != ' ' && ch != '\n' && ch != '\r') {
+		str[count ++] = ch;
+	}
+
+	str[count] = '\0';	
+}
+
+void static getNextLexeme(char* str, FILE* font) {
+	unsigned char ch;
+	unsigned short count = 0;
+
+	while (!feof(font) && ((ch = getc(font)) == ' ' || ch == '\n' || ch == '\r' && ch != '{')) {
+	}
+
+	str[count ++] = ch;	
+    while (!feof(font) && (ch = getc(font)) != ' ' && ch != '\n' && ch != '\r' && ch != '{') {
+		str[count ++] = ch;
+	}
+
+	str[count] = '\0';	
+}
+
+unsigned short static findUnicode(const char *str) {
+	
+	unsigned short count = 0;
+	unsigned short strCount = 0;
+	unsigned short lastStrCount = 0;
+
+	while(true) {
+		if (GLYPH_LIST[count] == str[strCount]) {
+			count ++;
+			strCount ++;
+			//next iteration				
+		} else if ((GLYPH_LIST[count] ^ (1 << 7)) == str[strCount]) {
+			strCount ++;
+			if (str[strCount] == '\0') {
+				return (unsigned short)((GLYPH_LIST[count + 1] << 8) + GLYPH_LIST[count + 2]);
+			}
+
+			count = ((GLYPH_LIST[count + 5] << 8) + GLYPH_LIST[count + 6]);
+
+			lastStrCount = strCount;
+
+			if (!count) {
+				return FONT_NOT_FOUND_UNICODE_VALUE;
+			}
+
+			//on next level
+		} else {
+			strCount = lastStrCount;
+
+			for (;!(GLYPH_LIST[count] & (1 << 7)) ; ) {
+				count ++;
+			}
+
+			count = ((GLYPH_LIST[count + 3] << 8) + GLYPH_LIST[count + 4]);
+
+			if (!count) {
+				return FONT_NOT_FOUND_UNICODE_VALUE;
+			}
+
+			//next on this level
+		}
+	}
+}
+
+unsigned short static getUnicode(char *name) {
+	if (!strncmp(name, ".notdef", 7)) {
+		return 0;	
+	}
+
+	return findUnicode(name);
+}
+
+void T1Font::parseAFM(FILE *font) {
+    char curStr[MAX_STR_LENGHT];
+
+    while (!feof(font)) {
+        getNextLexeme(curStr, font);
+        //printf("%s\n",curStr);
+
+        if (!strcmp(curStr, "EndFontMetrics") || !strcmp(curStr, "StartCharMetrics")) {
+
+            return;
+        } else if (!strcmp(curStr, "Ascender")) {
+            getNextLexeme(curStr, font);
+            _ascent = (float) fabs(atof(curStr));
+            //printf("ascend = %f\n", _ascent);
+            
+        } else if (!strcmp(curStr, "Descender")) {
+            getNextLexeme(curStr, font);
+            _descent = (float) fabs(atof(curStr));
+            //printf("descent = %f\n", _descent);
+            
+        } /*else if (!strcmp(curStr, "StartCharMetrics")) {
+            getNextLexeme(curStr, font);            
+            char* curValue;
+            char psName[MAX_STR_LENGHT];
+            unsigned short count = (unsigned short) atoi(curStr);
+            for (unsigned short i = 0; i < count; i ++) {
+                getNextLine(curStr, font);
+
+                //printf("%s\n",curStr);
+                curValue = strstr( curStr, " N ");
+                if (curValue != NULL) {
+
+                    curValue += 3;
+
+                    //printf("%s\n", curValue);
+                    
+                    unsigned short i;
+                    for (i = 0; curValue[i] != ' ' && curValue[i] != '\0'; i ++) {
+                        psName[i] = curValue[i];
+                    }
+                    psName[i] = '\0';                    
+
+                    curValue = new char[strlen(curStr) + 1]; 
+
+                    strcpy(curValue, curStr);
+
+                    //printf("%u = %s = %s\n",findUnicode(psName),curValue,psName);
+
+				    afmMap[getUnicode(psName)] = curValue;
+                }
+            }
+            
+        }*/ else {
+            getNextLine(curStr, font);
+        }
+    }
+}
+
+
+void T1Font::initFont(FILE *font) {
+	char curStr[MAX_STR_LENGHT];
+
+	DecodeState state = HEADER;
+
+	unsigned short r = DEF_R_EXEC;
+	unsigned short n = 4;
+
+	unsigned short lenIV = DEF_LENIV;	
+	unsigned short charStringR;	
+
+	unsigned short count = 0;
+	unsigned short tempShort = 0;
+	unsigned short length = 0;
+	unsigned short valueLength = 0;
+
+    matrixScale = 1000;
+
+	bool isASCII = true;
+
+	unsigned char ch;	
+	EncodedValue *curValue;
+
+	ch = getc(font);
+
+	if (ch == 0x80 && getc(font) == 0x01) {
+		isASCII = false;	
+	} else if (ch == '%' && getc(font) == '!') {
+		isASCII = true;	
+	} else {
+		error();	
+	}	
+
+	while (!feof(font)) {
+		switch (state) {
+		case HEADER: {
+			getNextLexeme(curStr, font);
+
+            if (!strcmp(curStr, "/UnderlinePosition")) {
+                getNextLexeme(curStr, font);
+                _underlineOffset = (float) - atof(curStr);
+		    } else if (!strcmp(curStr, "/UnderlineThickness")) {
+                getNextLexeme(curStr, font);
+                _underlineThickness = (float) atof(curStr);			
+		    } else if (strstr(curStr, "/FontBBox") != NULL) {
+                //getNextLexeme(curStr, font);
+
+                while (!feof(font) && ((ch = getc(font)) == '{')) {
+				}
+
+                ungetc(ch, font);
+
+                getNextLexeme(curStr, font);
+                _boundingBox[0] = (float) atof(curStr);
+
+                getNextLexeme(curStr, font);
+                _boundingBox[1] = (float) atof(curStr);
+
+                getNextLexeme(curStr, font);
+                _boundingBox[2] = (float) atof(curStr);
+
+                getNextLexeme(curStr, font);                
+                _boundingBox[3] = (float) atof(curStr);
+
+                _height = ((float)(_boundingBox[2] -_boundingBox[0]));
+
+		    } else if (!strcmp(curStr, "/FullName")) {
+                //getNextLexeme(curStr, font);                
+
+				while (!feof(font) && ((ch = getc(font)) == '(')) {
+				}
+
+				curStr[count ++] = ch;	
+				while (!feof(font) && (ch = getc(font)) != ')') {
+					curStr[count ++] = ch;
+				}
+
+				curStr[count] = '\0';	
+
+				char *ptr = curStr;
+
+				ch = 0;
+				fullName = new wchar_t[count + 1];
+				while (*ptr != '\0') {
+					fullName[ch ++] = *ptr;
+					ptr ++;
+				}
+
+				fullName[ch] = L'\0';
+		    } else if (!strcmp(curStr, "eexec")) {
+				state = PRIVATE_DIR;			
+			
+				if (isASCII) {
+					for (count = 0; count < lenIV * 2; count ++) {
+						if (!isascii(ch = getc(font))) {
+							error();					
+						}					
+						curStr[count] = ch;
+					}
+					decodeASCIILine(curStr, &r, n, count);
+				} else {
+					for (count = 0; count < 6; count ++) {					
+						curStr[count] = getc(font);
+					}
+					
+					if (curStr[0] != (char)0x80 || curStr[1] != 0x02) {
+						error();
+					}
+					for (count = 0; count < lenIV; count ++) {
+						curStr[count] = getc(font);
+					}
+					decodeBinaryLine(curStr, &r, n, count);
+				}
+			}
+			break;			
+		}
+		case PRIVATE_DIR: {
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+			
+			if (!strcmp(curStr, "/Subrs")) {
+
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				valueLength = atoi(curStr);
+				
+				count = 0;
+				state = SUBRS_MASSIVE;	 
+				getNextDecodeLine(curStr, font, &r, isASCII);
+			} else if (!strcmp(curStr, "/CharStrings")) {
+
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				valueLength = atoi(curStr);		
+				
+				count = 0;
+				state = CHAR_STRING;
+				getNextDecodeLine(curStr, font, &r, isASCII);
+			}
+			break;
+		}
+		case SUBRS_MASSIVE: {			
+			curValue = new EncodedValue();
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+			curValue->number = (unsigned short) atoi(curStr);	
+
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+			length = (unsigned short) atoi(curStr);
+			curValue->length = length - lenIV;
+
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+			
+			for (tempShort = 0; tempShort - length < 0; tempShort ++) {
+				curStr[tempShort] = decryptNextSimbol(font, &r, isASCII);
+			}
+
+			charStringR = DEF_R_CHARSTRING;
+			decodeBinaryLine(curStr, &charStringR, lenIV, length);
+
+			curValue->text = new char[curValue->length];
+			for (tempShort = 0; tempShort - curValue->length < 0; tempShort ++) {
+				curValue->text[tempShort] = curStr[tempShort];
+			}
+
+			subrsMap[curValue->number] = curValue;
+
+			getNextDecodeLine(curStr, font, &r, isASCII);
+
+			if (++count >= valueLength) {
+				state = PRIVATE_DIR;
+				count = 0;
+			}
+			
+			break;
+		}
+		case CHAR_STRING: {
+			getNextDecodeLexeme(curStr, font, &r, isASCII);
+			tempShort = getUnicode(curStr + 1);
+
+			if (tempShort != FONT_NOT_FOUND_UNICODE_VALUE) {
+
+                glyphCodeMap[count] = tempShort;
+
+				curValue = new EncodedValue(); 
+
+				curValue->number = tempShort;
+
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				length = (unsigned short) atoi(curStr);
+				curValue->length = length - lenIV;	
+
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				for (tempShort = 0; tempShort - length < 0; tempShort ++) {
+					curStr[tempShort] = decryptNextSimbol(font, &r, isASCII);
+				}
+
+				charStringR = DEF_R_CHARSTRING;
+				decodeBinaryLine(curStr, &charStringR, lenIV, length);
+
+				curValue->text = new char[curValue->length];
+				for (tempShort = 0; tempShort - curValue->length < 0; tempShort ++) {
+					curValue->text[tempShort] = curStr[tempShort];
+				}
+				charStringMap[curValue->number] = curValue;
+			} else {
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				length = (unsigned short) atoi(curStr);							
+
+				getNextDecodeLexeme(curStr, font, &r, isASCII);
+				for (tempShort = 0; tempShort - length < 0; tempShort ++) {
+					decryptNextSimbol(font, &r, isASCII);
+				}
+			}			
+
+			getNextDecodeLine(curStr, font, &r, isASCII);
+
+			if (++count >= valueLength) {
+				return;		
+			}
+			
+			break;
+		}
+	}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h Sun Jun 10 10:31:22 2007
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (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.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Viskov Nikolay 
+ * @version $Revision$
+ */
+#ifndef __TYPE_1_FONT_CLASS_H
+#define __TYPE_1_FONT_CLASS_H
+
+#include <map>
+#include <math.h>
+
+#include "Font.h"
+#include "Type1Structs.h"
+
+class T1Font : public Font {
+public:
+	T1Font(wchar_t *family, StyleName sn, char* pathToFile);
+	~T1Font(void);
+	Glyph* createGlyph(unsigned short unicode, unsigned short size);
+	wchar_t* getPSName();
+	float* getLineMetrics(); 
+	bool canDisplay(unsigned short c);
+
+	unsigned short getUnicodeByIndex(unsigned short ind);
+
+//	float* GetExtraMetrics();
+
+
+private:
+	void initFont(FILE *font);
+    void parseAFM(FILE *font);
+	Type1Map subrsMap;//number -- subrutine
+	Type1Map charStringMap;//unicode -- info
+
+    //Type1AFMMap afmMap;//unicode -- afm string
+
+    Type1GlyphCodeMap glyphCodeMap;//glyphCode -- unicode
+
+    wchar_t *fullName;
+
+    float matrixScale;
+};
+
+#endif //__TYPE_1_FONT_CLASS_H

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message