From: dbv Date: Thu, 11 Oct 2012 13:45:15 +0000 (+0400) Subject: 0023466: Move OSD_FontMgr class outside TKernel X-Git-Tag: V6_5_4_beta1~5 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=eeaaaefb6f5580107f7170c08fa036c071b2cf6e;p=occt-copy.git 0023466: Move OSD_FontMgr class outside TKernel Created new package Font in TKService. Classes FontMgr and SystemFont have been moved from OSD package to Font package. --- diff --git a/adm/UDLIST b/adm/UDLIST index c2f073ced8..e8ec8abe6d 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -501,3 +501,4 @@ r QAResources t TKQADraw p QADNaming p QABugs +p Font diff --git a/src/Font/FILES b/src/Font/FILES new file mode 100644 index 0000000000..5c9f2acb58 --- /dev/null +++ b/src/Font/FILES @@ -0,0 +1 @@ +Font_NListOfSystemFont.hxx diff --git a/src/Font/Font.cdl b/src/Font/Font.cdl new file mode 100644 index 0000000000..71f2826ea5 --- /dev/null +++ b/src/Font/Font.cdl @@ -0,0 +1,36 @@ +-- Copyright (c) 1992-1999 Matra Datavision +-- Copyright (c) 1999-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +package Font + +uses Standard , + Quantity , + TCollection, + OSD + +is + enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic; + ---Purpose: Specifies aspect of system font. + + class SystemFont; + + imported NListOfSystemFont; + + class FontMgr; + +end Font; diff --git a/src/Font/Font_FontMgr.cdl b/src/Font/Font_FontMgr.cdl new file mode 100644 index 0000000000..160385f2cf --- /dev/null +++ b/src/Font/Font_FontMgr.cdl @@ -0,0 +1,44 @@ +-- Created on: 2008-01-20 +-- Created by: Alexander A. BORODIN +-- Copyright (c) 2008-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class FontMgr from Font inherits TShared from MMgt +---Purpose: Structure for store of Font System Information + +uses SystemFont, + NListOfSystemFont, + Path from OSD, + AsciiString from TCollection +is + GetInstance(myclass) returns FontMgr; + ---Level: Public + + GetAvalableFonts(me) returns NListOfSystemFont; + +--- Private methods + + Create returns FontMgr is private; + ---Purpose: Creates empty font object + ---Level: Private + + InitFontDataBase(me:mutable) is private; + +fields + MyListOfFonts: NListOfSystemFont; + +end FontMgr; diff --git a/src/Font/Font_FontMgr.cxx b/src/Font/Font_FontMgr.cxx new file mode 100644 index 0000000000..5c5af20270 --- /dev/null +++ b/src/Font/Font_FontMgr.cxx @@ -0,0 +1,434 @@ +// Created on: 2008-01-20 +// Created by: Alexander A. BORODIN +// Copyright (c) 2008-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + +#include +#ifdef WNT +# include +# include +#else //WNT +# include +# include +#endif //WNT + +#include +#include +#include +#include + + +#ifndef WNT +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +const Standard_Integer font_service_conf_size = 3; +static Standard_Character font_service_conf[font_service_conf_size][64] = { {"/etc/X11/fs/config"}, + {"/usr/X11R6/lib/X11/fs/config"}, + {"/usr/X11/lib/X11/fs/config"} + }; + +DEFINE_LIST( StringList, NCollection_List, TCollection_HAsciiString ); + +void find_path_with_font_dir( const TCollection_AsciiString& dir,StringList& dirs ) +{ + if( !dir.IsEmpty() ) + { + TCollection_AsciiString PathName( dir ); + + Standard_Integer rem = PathName.Length(); + + if ( PathName.SearchFromEnd("/") == rem ) + PathName.Remove( rem, 1 ); + + Standard_Boolean need_to_append = Standard_True; + + StringList::Iterator it( dirs ); + for( ; it.More(); it.Next() ) + { + if ( PathName.IsEqual(it.Value().ToCString()) ) { + need_to_append = Standard_False; + break; + } + } + if ( need_to_append ) + dirs.Append( PathName ); + + OSD_DirectoryIterator osd_dir(PathName,"*"); + while(osd_dir.More()) + { + OSD_Path path_file; + osd_dir.Values().Path( path_file ); + if( path_file.Name().Length() < 1 ) + { + osd_dir.Next(); + continue; + } + + TCollection_AsciiString full_path_name = PathName + "/" + path_file.Name(); + rem = full_path_name.Length(); + if ( full_path_name.SearchFromEnd("/") == rem ) + full_path_name.Remove( rem, 1 ); + find_path_with_font_dir( full_path_name, dirs ); + osd_dir.Next(); + } + } +} + +#endif //WNT + + +Handle(Font_FontMgr) Font_FontMgr::GetInstance() { + + static Handle(Font_FontMgr) _mgr; + if ( _mgr.IsNull() ) + _mgr = new Font_FontMgr(); + + return _mgr; + +} + +Font_FontMgr::Font_FontMgr() { + + InitFontDataBase(); + +} + +void Font_FontMgr::InitFontDataBase() { + + MyListOfFonts.Clear(); + +#ifdef WNT + //detect font directory + + OSD_Environment env("windir"); + TCollection_AsciiString windir_str = env.Value(); + if ( windir_str.IsEmpty() ) + { + return; + } + Handle(TCollection_HAsciiString) HFontDir = new TCollection_HAsciiString( windir_str ); + HFontDir->AssignCat( "\\Fonts\\" ); + #ifdef TRACE + cout << "System font directory: " << HFontDir->ToCString() << "\n"; + #endif TRACE + + //read registry + HKEY fonts_hkey; + if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, + TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), + 0, + KEY_READ, + &fonts_hkey ) + != ERROR_SUCCESS ) + { + return; + } + Standard_Integer id = 0; + Standard_Character buf_name[100]; + Standard_Byte buf_data[100]; + DWORD size_name = 100, + size_data = 100; + + while ( true ) + { + //detect file name + DWORD type; + size_name = 100, + size_data = 100; + Font_FontAspect aspect; + if( RegEnumValue( fonts_hkey, + id, + buf_name, + &size_name, + NULL, + &type, + buf_data, + &size_data) == ERROR_NO_MORE_ITEMS ) { + break; + } + Handle(TCollection_HAsciiString) fname = + new TCollection_HAsciiString(buf_name); + fname->RightAdjust(); + fname->LeftAdjust(); + //remove construction like (TrueType.... + Standard_Integer anIndexTT = fname->SearchFromEnd( new TCollection_HAsciiString( " (" ) ); + Standard_Boolean aTruncate = Standard_False; + if ( anIndexTT > 1 ) + fname->Trunc( anIndexTT ); + Standard_Integer anIndex = 0; + fname->RightAdjust(); + if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Bold Italic") ) ) > 0 ) { + aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); + aspect = Font_FA_BoldItalic; + } else if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Bold") ) ) > 0 ) { + aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); + aspect = Font_FA_Bold; + } else if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Italic") ) ) > 0 ) { + aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); + aspect = Font_FA_Italic; + } else { + aspect = Font_FA_Regular; + } + if( aTruncate ) + fname->Trunc( anIndex - 1 ); + fname->RightAdjust(); + Handle(TCollection_HAsciiString) file_path = + new TCollection_HAsciiString( (Standard_Character*)buf_data ); + if ( strchr( (Standard_Character*)buf_data, '\\' ) == NULL ) { + file_path->Insert( 1, HFontDir ); + } + + if( ( ( file_path->Search(".ttf") > 0 ) || ( file_path->Search(".TTF") > 0 ) || + ( file_path->Search(".otf") > 0 ) || ( file_path->Search(".OTF") > 0 ) || + ( file_path->Search(".ttc") > 0 ) || ( file_path->Search(".TTC") > 0 ) ) ){ + MyListOfFonts.Append( new Font_SystemFont( fname, aspect, file_path ) ); +#ifdef TRACE + cout << "Adding font...\n" + << " font name: " << fname->ToCString() << "\n" + << " font file: " << file_path->ToCString() << "\n" + << " font aspect: "; + switch( aspect ) { + case Font_FA_Bold: + cout << "Font_FA_Bold\n"; + break; + case Font_FA_BoldItalic: + cout << "Font_FA_BoldItalic\n"; + break; + case Font_FA_Italic: + cout << "Font_FA_Italic\n"; + break; + default: + cout << "Font_FA_Regular\n"; + break; + } +#endif + } + id++; + } + //close registry + RegCloseKey( fonts_hkey ); +#endif //WNT + +#ifndef WNT + StringList dirs; + Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString; + Display * disp = XOpenDisplay("localhost:0.0"); + + if (!disp) + { + // let the X server find the available connection + disp = XOpenDisplay(":0.0"); + if (!disp) + { + cout << "Display is NULL!" << endl; + return ; + } + } + + Standard_Integer npaths = 0; + + Standard_Character** fontpath = XGetFontPath(disp, &npaths); +#ifdef TRACE + cout << "NPATHS = " << npaths << endl ; +#endif + for (Standard_Integer i = 0; i < npaths; i++ ) + { +#ifdef TRACE + cout << "Font Path: " << fontpath[i] << endl; +#endif + if ( fontpath[i][0] == '/' ) { + TCollection_AsciiString aFontPath( fontpath[i] ); + find_path_with_font_dir( aFontPath, dirs ); + } + else + { + TCollection_AsciiString aFontPath( fontpath[i] ); + TCollection_AsciiString aCutFontPath; + Standard_Integer location = -1 ; + location = aFontPath.Location( "/",1,aFontPath.Length() ); + if( location > 0 ) + aCutFontPath.AssignCat( aFontPath.SubString(location, aFontPath.Length() ) ); + find_path_with_font_dir( aCutFontPath, dirs ); + } + } + XFreeFontPath(fontpath); + + + OSD_OpenMode aMode = OSD_ReadOnly; + OSD_Protection aProtect( OSD_R, OSD_R, OSD_R, OSD_R ); + + for( Standard_Integer j = 0 ; j < font_service_conf_size; j++ ) + { + TCollection_AsciiString fileOfFontServiceName( font_service_conf[j] ); + OSD_File aFile( fileOfFontServiceName ); + + if( aFile.Exists() ) + aFile.Open( aMode, aProtect ); + + if( aFile.IsOpen() )//font service + { + Standard_Integer aNByte = 256; + Standard_Integer aNbyteRead; + TCollection_AsciiString aStr( aNByte );//read string with information + TCollection_AsciiString aStrCut( aNByte );//cut of string + TCollection_AsciiString endStr;//cutting string + + Standard_Boolean read_dirs = Standard_False; + Standard_Integer location =- 1; //disposition of necessary literals + Standard_Integer begin =- 1; //first left entry in string + Standard_Integer end =- 1; //first right entry in string + while( !aFile.IsAtEnd() ) + { + aFile.ReadLine( aStr, aNByte, aNbyteRead );//reading 1 lines(256 bytes) + location = aStr.Location( "catalogue = ", 1, aStr.Length() ); + if(location == 0) + location = aStr.Location( "catalogue=", 1, aStr.Length() ); + if(location == 0) + location = aStr.Location( "catalogue= ", 1, aStr.Length() ); + if(location == 0) + location = aStr.Location( "catalogue = ", 1, aStr.Length() ); + if( location > 0 ) + { +#ifdef TRACE + cout << " Font config find!!" << endl; +#endif + read_dirs = Standard_True; + } + + if( read_dirs ) + { + begin = aStr.Location( "/", 1, aStr.Length() );//begin of path name + end = aStr.Location( ":", 1, aStr.Length() );//end of path name + if( end < 1 ) + end = aStr.Location( ",", 1, aStr.Length() );//also end of path name + end -= 1; + if( begin > 0 && end > 0 ) + { + if( ( end - begin ) > 0 ) + endStr.AssignCat( aStr.SubString ( begin, end ) );//cutting necessary literals for string + dirs.Append( TCollection_HAsciiString ( endStr ) ); + endStr.Clear(); + } + else + if( begin > 0 && end == -1 ) + { + //if end of string don't have "," or ":" + //it is possible last sentence in block of word + endStr.AssignCat( aStr.SubString( begin, aStr.Length() - 1 ) ); + dirs.Append( TCollection_HAsciiString( endStr ) ); + endStr.Clear(); + } + } + + } + aFile.Close(); + } + } + + if( dirs.Size() > 0 ) + { + //if dirs list contains elements + OSD_OpenMode aModeRead = OSD_ReadOnly; + OSD_Protection aProtectRead( OSD_R, OSD_R , OSD_R , OSD_R ); + + TCollection_AsciiString fileFontsDir; + StringList::Iterator it( dirs ); + for( ; it.More(); it.Next() ) + { + fileFontsDir.AssignCat( it.Value().ToCString() ); + fileFontsDir.AssignCat( "/fonts.dir" );//append file name in path way + + OSD_File readFile( fileFontsDir ); + readFile.Open( aModeRead, aProtectRead ); + + Standard_Integer aNbyteRead, aNByte = 256; + if( readFile.IsOpen ( ) ) + { + TCollection_AsciiString aLine( aNByte ); + Standard_Integer countOfString = 0 ; + while( ! readFile.IsAtEnd() )//return true if EOF + { + if( countOfString > 1 ) + { + readFile.ReadLine( aLine , aNByte , aNbyteRead ); + if( ( ( aLine.Search(".pfa") > 0 ) || ( aLine.Search(".PFA") > 0 ) || + ( aLine.Search(".pfb") > 0 ) || ( aLine.Search(".PFB") > 0 ) || + ( aLine.Search(".ttf") > 0 ) || ( aLine.Search(".TTF") > 0 ) || + ( aLine.Search(".otf") > 0 ) || ( aLine.Search(".OTF") > 0 ) || + ( aLine.Search(".ttc") > 0 ) || ( aLine.Search(".TTC") > 0 ) ) + && ( aLine.Search( "iso8859-1\n" ) > 0 ) ) + { + + // In current implementation use fonts with ISO-8859-1 coding page. + // OCCT not give to manage coding page by means of programm interface. + // TODO: make high level interface for + // choosing necessary coding page. + TCollection_AsciiString aXLFD; + Standard_Integer leftXLFD = aLine.SearchFromEnd(" "); + Standard_Integer rightXLFD = aLine.Length(); + if( leftXLFD && rightXLFD ) + aXLFD.AssignCat(aLine.SubString( leftXLFD + 1, rightXLFD ) ); + + TCollection_AsciiString aPath; + TCollection_AsciiString aTemp( it.Value().ToCString() ); + if ( aTemp.SearchFromEnd("/") == aTemp.Length() ) + { + //this branch intend to SUN + aPath.AssignCat( aTemp.ToCString() ); + aPath.AssignCat( aLine.Token( " ", 1 ) ); + } + else { + //this branch intend to Linux + aPath.AssignCat( aTemp.ToCString( ) ); + aPath.AssignCat( "/" ); + aPath.AssignCat( aLine.Token( " ", 1 ) ); + } + MyListOfFonts.Append( new Font_SystemFont( new TCollection_HAsciiString( aXLFD ), + new TCollection_HAsciiString( aPath ) ) ); + } + + } + else + readFile.ReadLine( aLine, aNByte, aNbyteRead ); + countOfString++; + } + readFile.Close(); + } + fileFontsDir.Clear(); + } + } +#endif +} + +Font_NListOfSystemFont Font_FontMgr::GetAvalableFonts() const +{ + return MyListOfFonts; +} + + diff --git a/src/Font/Font_NListOfSystemFont.hxx b/src/Font/Font_NListOfSystemFont.hxx new file mode 100644 index 0000000000..3fa542231f --- /dev/null +++ b/src/Font/Font_NListOfSystemFont.hxx @@ -0,0 +1,26 @@ +// Created on: 2009-01-20 +// Created by: Alexander A. BORODIN +// Copyright (c) 2009-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. +#ifndef _Font_NListOfSystemFont_HeaderFile +#define _Font_NListOfSystemFont_HeaderFile +#include +#include +DEFINE_LIST (Font_NListOfSystemFont, + NCollection_List, + Handle(Font_SystemFont)) +#endif diff --git a/src/Font/Font_SystemFont.cdl b/src/Font/Font_SystemFont.cdl new file mode 100644 index 0000000000..6fe62dbef5 --- /dev/null +++ b/src/Font/Font_SystemFont.cdl @@ -0,0 +1,69 @@ +-- Created on: 2008-01-20 +-- Created by: Alexander A. BORODIN +-- Copyright (c) 2008-2012 OPEN CASCADE SAS +-- +-- The content of this file is subject to the Open CASCADE Technology Public +-- License Version 6.5 (the "License"). You may not use the content of this file +-- except in compliance with the License. Please obtain a copy of the License +-- at http://www.opencascade.org and read it completely before using this file. +-- +-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +-- +-- The Original Code and all software distributed under the License is +-- distributed on an "AS IS" basis, without warranty of any kind, and the +-- Initial Developer hereby disclaims all such warranties, including without +-- limitation, any warranties of merchantability, fitness for a particular +-- purpose or non-infringement. Please see the License for the specific terms +-- and conditions governing the rights and limitations under the License. + +class SystemFont from Font inherits TShared from MMgt +---Purpose: Structure for store of Font System Information + +uses FontAspect, + HAsciiString from TCollection + +is + Create returns SystemFont; + ---Purpose: Creates empty font object + ---Level: Public + + Create (FontName : HAsciiString; + Aspect : FontAspect; + FilePath : HAsciiString ) returns SystemFont; + ---Purpose: Creates Font object initialized with as name + --- .... TODO + ---Level: Public + + Create (XLFD : HAsciiString; + FilePath : HAsciiString ) returns SystemFont; + ---Purpose: TODO + ---Level: Public + + FontName (me) returns HAsciiString; + --- Purpose: Returns font family name + ---Level: Public + + FontPath (me) returns HAsciiString; + --- Purpose: Returns font file path + --- Level: Public + + FontAspect (me) returns FontAspect; + --- Purpose: Returns font aspect + --- Level: Public + + FontHeight (me) returns Integer from Standard; + --- Purpose: Returns font height + --- If returned value is equal -1 it means that font is resizable + --- Level: Public + + IsValid (me) returns Boolean; + +fields + MyFontName: HAsciiString; --Font family name + MyFontAspect: FontAspect; + MyFaceSize: Integer; --height of font + MyFilePath: HAsciiString; --absolute path to font file + MyVerification: Boolean; --indicator of font initialization errors. False if initialization is failed. + +end SystemFont; diff --git a/src/Font/Font_SystemFont.cxx b/src/Font/Font_SystemFont.cxx new file mode 100644 index 0000000000..8285e81e83 --- /dev/null +++ b/src/Font/Font_SystemFont.cxx @@ -0,0 +1,122 @@ +// Created on: 2008-01-20 +// Created by: Alexander A. BORODIN +// Copyright (c) 2008-2012 OPEN CASCADE SAS +// +// The content of this file is subject to the Open CASCADE Technology Public +// License Version 6.5 (the "License"). You may not use the content of this file +// except in compliance with the License. Please obtain a copy of the License +// at http://www.opencascade.org and read it completely before using this file. +// +// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its +// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. +// +// The Original Code and all software distributed under the License is +// distributed on an "AS IS" basis, without warranty of any kind, and the +// Initial Developer hereby disclaims all such warranties, including without +// limitation, any warranties of merchantability, fitness for a particular +// purpose or non-infringement. Please see the License for the specific terms +// and conditions governing the rights and limitations under the License. + + +// Updated: + +#include +#include +#include + + +Font_SystemFont::Font_SystemFont(): +MyFontName(), +MyFontAspect(Font_FA_Undefined), +MyFaceSize(-1), +MyVerification(Standard_False) +{ +} + +Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& FontName, + const Font_FontAspect FontAspect, + const Handle(TCollection_HAsciiString)& FilePath ): +MyFontName(FontName), +MyFontAspect(FontAspect), +MyFilePath(FilePath), +MyFaceSize(-1), +MyVerification(Standard_True) +{ + +} + +Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& XLFD, + const Handle(TCollection_HAsciiString)& FilePath) : +MyFilePath(FilePath), +MyFontAspect(Font_FA_Undefined) +{ + MyVerification = Standard_True; + if ( XLFD.IsNull() ) + { + MyVerification=Standard_False; + printf("NULL XLFD handler \n"); + } + if ( XLFD->IsEmpty() ) + { + MyVerification=Standard_False; + printf("EMPTY XLFD handler \n"); + } + + if(MyVerification) + { + MyFontName = XLFD->Token( "-", 2 ); + TCollection_AsciiString str( XLFD->ToCString() ); + + if ( str.Search( "-0-0-0-0-" ) >=0 ) + MyFaceSize = -1; + else + //TODO catch exeption + MyFaceSize = str.Token( "-", 7 ).IntegerValue(); + + //detect aspect + if ( str.Token("-", 3).IsEqual( "bold" ) ) + MyFontAspect = Font_FA_Bold; + else if ( str.Token("-", 3).IsEqual( "medium" ) || + str.Token("-", 3).IsEqual( "normal" ) ) + MyFontAspect = Font_FA_Regular; + + if ( MyFontAspect != Font_FA_Undefined && + ( str.Token("-",4 ).IsEqual( "i" ) || str.Token("-",4 ).IsEqual( "o" ) ) ) + { + if ( MyFontAspect == Font_FA_Bold ) + MyFontAspect = Font_FA_BoldItalic; + else + MyFontAspect = Font_FA_Italic; + } + } +} + +Standard_Boolean Font_SystemFont::IsValid() const{ + if ( !MyVerification) + return Standard_False; + + if ( MyFontAspect == Font_FA_Undefined ) + return Standard_False; + + if ( MyFontName->IsEmpty() || !MyFontName->IsAscii() ) + return Standard_False; + + OSD_Path path; + return path.IsValid( MyFilePath->String() ); +} + +Handle(TCollection_HAsciiString) Font_SystemFont::FontPath() const{ + return MyFilePath; +} + +Handle(TCollection_HAsciiString) Font_SystemFont::FontName() const{ + return MyFontName; +} + +Font_FontAspect Font_SystemFont::FontAspect() const{ + return MyFontAspect; +} + +Standard_Integer Font_SystemFont::FontHeight() const { + return MyFaceSize; +} diff --git a/src/Graphic3d/Graphic3d.cdl b/src/Graphic3d/Graphic3d.cdl index 03e54b6d83..fa0ca14894 100755 --- a/src/Graphic3d/Graphic3d.cdl +++ b/src/Graphic3d/Graphic3d.cdl @@ -77,7 +77,8 @@ uses WNT, Image, AlienImage, - gp + gp, + Font is ----------------------- diff --git a/src/Graphic3d/Graphic3d_AspectText3d.cdl b/src/Graphic3d/Graphic3d_AspectText3d.cdl index 3e21ca1001..cce89813e9 100755 --- a/src/Graphic3d/Graphic3d_AspectText3d.cdl +++ b/src/Graphic3d/Graphic3d_AspectText3d.cdl @@ -40,7 +40,7 @@ uses TypeOfStyleText from Aspect, TypeOfDisplayText from Aspect, AsciiString from TCollection, - FontAspect from OSD + FontAspect from Font raises @@ -169,12 +169,12 @@ is ---Purpose: Returns Angle of degree SetTextFontAspect ( me : mutable; - AFontAspect : FontAspect from OSD ); + AFontAspect : FontAspect from Font ); ---Level: Public ---Purpose: Turns usage of Aspect text ---Category: Methods to modify the class definition - GetTextFontAspect( me ) returns FontAspect from OSD; + GetTextFontAspect( me ) returns FontAspect from Font; ---Level: Public ---Purpose: Returns text FontAspect @@ -239,7 +239,7 @@ is AColorSubTitle : out Color from Quantity; ATextZoomable : out Boolean from Standard; ATextAngle : out Real from Standard; - ATextFontAspect : out FontAspect from OSD) + ATextFontAspect : out FontAspect from Font) is static; ---Level: Public ---Purpose: Returns the current values of the group . @@ -290,6 +290,6 @@ fields MyTextAngle : Real from Standard; -- the variable turning FontAspect of the text - MyTextFontAspect : FontAspect from OSD; + MyTextFontAspect : FontAspect from Font; end AspectText3d; diff --git a/src/Graphic3d/Graphic3d_AspectText3d.cxx b/src/Graphic3d/Graphic3d_AspectText3d.cxx index 5fe609e32b..e7b19cfc6c 100755 --- a/src/Graphic3d/Graphic3d_AspectText3d.cxx +++ b/src/Graphic3d/Graphic3d_AspectText3d.cxx @@ -83,7 +83,7 @@ Graphic3d_AspectText3d::Graphic3d_AspectText3d (): MyFont (Graphic3d_NOF_ASCII_MONO), MyColor (Quantity_NOC_YELLOW), MyFactor (1.0), MySpace (0.0), MyStyle (Aspect_TOST_NORMAL), MyDisplayType (Aspect_TODT_NORMAL), MyColorSubTitle (Quantity_NOC_WHITE) { MyTextZoomable = Standard_False; MyTextAngle = 0.0; - MyTextFontAspect = OSD_FA_Regular; + MyTextFontAspect = Font_FA_Regular; } Graphic3d_AspectText3d::Graphic3d_AspectText3d ( @@ -96,7 +96,7 @@ Graphic3d_AspectText3d::Graphic3d_AspectText3d ( MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (AStyle), MyDisplayType(ADisplayType), MyColorSubTitle (Quantity_NOC_WHITE) { MyTextZoomable = Standard_False; MyTextAngle = 0.0; - MyTextFontAspect = OSD_FA_Regular; + MyTextFontAspect = Font_FA_Regular; if(MyFont.Length() == 0) MyFont.AssignCat(Graphic3d_NOF_ASCII_MONO); @@ -181,12 +181,12 @@ Standard_Real Graphic3d_AspectText3d::GetTextAngle() const return MyTextAngle; } -void Graphic3d_AspectText3d::SetTextFontAspect(const OSD_FontAspect AFontAspect) +void Graphic3d_AspectText3d::SetTextFontAspect(const Font_FontAspect AFontAspect) { MyTextFontAspect = AFontAspect; } -OSD_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const +Font_FontAspect Graphic3d_AspectText3d::GetTextFontAspect() const { return MyTextFontAspect; } @@ -236,7 +236,7 @@ void Graphic3d_AspectText3d::Values ( Quantity_Color& AColor, Quantity_Color& AColorSubTitle, Standard_Boolean& ATextZoomable, Standard_Real& ATextAngle, - OSD_FontAspect& ATextFontAspect ) const + Font_FontAspect& ATextFontAspect ) const { AColor = MyColor; diff --git a/src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx b/src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx index 1426988508..e34df4a5fc 100644 --- a/src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx +++ b/src/Graphic3d/Graphic3d_CGraduatedTrihedron.hxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include typedef void (*minMaxValuesCallback)(void*); class Graphic3d_CGraduatedTrihedron @@ -65,13 +65,13 @@ class Graphic3d_CGraduatedTrihedron /* Font name of names of axes: Courier, Arial, ... */ TCollection_AsciiString fontOfNames; /* Style of names of axes: OSD_FA_Regular, OSD_FA_Bold, ... */ - OSD_FontAspect styleOfNames; + Font_FontAspect styleOfNames; /* Size of names of axes: 8, 10, 12, 14, ... */ Standard_Integer sizeOfNames; /* Font name of values: Courier, Arial, ... */ TCollection_AsciiString fontOfValues; /* Style of values: OSD_FA_Regular, OSD_FA_Bold, ... */ - OSD_FontAspect styleOfValues; + Font_FontAspect styleOfValues; /* Size of values: 8, 10, 12, 14, ... */ Standard_Integer sizeOfValues; diff --git a/src/Graphic3d/Graphic3d_GraphicDriver.cdl b/src/Graphic3d/Graphic3d_GraphicDriver.cdl index 446ab365de..3a298f902f 100755 --- a/src/Graphic3d/Graphic3d_GraphicDriver.cdl +++ b/src/Graphic3d/Graphic3d_GraphicDriver.cdl @@ -129,7 +129,7 @@ uses HArray1OfReal from TColStd, CUserDraw from Graphic3d, NListOfHAsciiString from Graphic3d, - FontAspect from OSD, + FontAspect from Font, CGraduatedTrihedron from Graphic3d raises diff --git a/src/Graphic3d/Graphic3d_Group_8.cxx b/src/Graphic3d/Graphic3d_Group_8.cxx index 423e5c3b75..d028c18e79 100755 --- a/src/Graphic3d/Graphic3d_Group_8.cxx +++ b/src/Graphic3d/Graphic3d_Group_8.cxx @@ -344,7 +344,7 @@ void Graphic3d_Group::SetGroupPrimitivesAspect (const Handle(Graphic3d_AspectTex Quantity_Color AColorSubTitle; Standard_Boolean ATextZoomable; Standard_Real ATextAngle; - OSD_FontAspect ATextFontAspect; + Font_FontAspect ATextFontAspect; CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect); AColor.Values (R, G, B, Quantity_TOC_RGB); @@ -664,7 +664,7 @@ void Graphic3d_Group::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& Quantity_Color AColorSubTitle; Standard_Boolean ATextZoomable; Standard_Real ATextAngle; - OSD_FontAspect ATextFontAspect; + Font_FontAspect ATextFontAspect; CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect); AColor.Values (R, G, B, Quantity_TOC_RGB); diff --git a/src/Graphic3d/Graphic3d_Structure.cxx b/src/Graphic3d/Graphic3d_Structure.cxx index 3eb05d8673..781c557c03 100755 --- a/src/Graphic3d/Graphic3d_Structure.cxx +++ b/src/Graphic3d/Graphic3d_Structure.cxx @@ -1294,7 +1294,7 @@ void Graphic3d_Structure::SetPrimitivesAspect (const Handle(Graphic3d_AspectText Quantity_Color AColorSubTitle; Standard_Boolean ATextZoomable; Standard_Real ATextAngle; - OSD_FontAspect ATextFontAspect; + Font_FontAspect ATextFontAspect; CTX->Values (AColor, AFont, AnExpansion, ASpace, AStyle, ADisplayType,AColorSubTitle,ATextZoomable,ATextAngle,ATextFontAspect); AColor.Values (R, G, B, Quantity_TOC_RGB); @@ -2113,7 +2113,7 @@ void Graphic3d_Structure::UpdateStructure (const Handle(Graphic3d_AspectLine3d)& Quantity_Color AColorSubTitle; Standard_Boolean ATextZoomable; Standard_Real ATextAngle; - OSD_FontAspect ATextFontAspect; + Font_FontAspect ATextFontAspect; CTXL->Values (AColor, ALType, AWidth); diff --git a/src/MeshVS/MeshVS_TextPrsBuilder.cxx b/src/MeshVS/MeshVS_TextPrsBuilder.cxx index b9cb71a3c3..d614ab4849 100755 --- a/src/MeshVS/MeshVS_TextPrsBuilder.cxx +++ b/src/MeshVS/MeshVS_TextPrsBuilder.cxx @@ -178,7 +178,7 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, TCollection_AsciiString AFontString; Standard_Integer ADispInt; // Bold font is used by default for better text readability - OSD_FontAspect AFontAspectType = OSD_FA_Bold; + Font_FontAspect AFontAspectType = Font_FA_Bold; Standard_Integer AAspect; @@ -193,7 +193,7 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs, if ( aDrawer->GetInteger ( MeshVS_DA_TextDisplayType, ADispInt ) ) ADisplayType = (Aspect_TypeOfDisplayText) ADispInt; if ( aDrawer->GetInteger ( MeshVS_DA_TextFontAspect, AAspect ) ) - AFontAspectType = (OSD_FontAspect)AAspect; + AFontAspectType = (Font_FontAspect)AAspect; Handle (Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d ( AColor, AFont, AExpansionFactor, ASpace, ATextStyle, ADisplayType ); diff --git a/src/MeshVS/MeshVS_Tool.cxx b/src/MeshVS/MeshVS_Tool.cxx index ff1ca68760..3b4b569e0e 100755 --- a/src/MeshVS/MeshVS_Tool.cxx +++ b/src/MeshVS/MeshVS_Tool.cxx @@ -200,11 +200,11 @@ Handle( Graphic3d_AspectText3d ) MeshVS_Tool::CreateAspectText3d Aspect_TypeOfStyleText aStyle = Aspect_TOST_NORMAL; Aspect_TypeOfDisplayText aDispText = Aspect_TODT_NORMAL; TCollection_AsciiString aFontString = Graphic3d_NOF_ASCII_MONO; - OSD_FontAspect aFontAspect = OSD_FA_Regular; + Font_FontAspect aFontAspect = Font_FA_Regular; Standard_Integer aStyleI = (Standard_Integer)Aspect_TOST_NORMAL; Standard_Integer aDispTextI = (Standard_Integer)Aspect_TODT_NORMAL; // Bold font is used by default for better text readability - Standard_Integer aFontAspectI = (Standard_Integer)OSD_FA_Bold; + Standard_Integer aFontAspectI = (Standard_Integer)Font_FA_Bold; if ( !theDr->GetColor ( MeshVS_DA_TextColor, aTColor ) && !UseDefaults ) return anAsp; @@ -233,7 +233,7 @@ Handle( Graphic3d_AspectText3d ) MeshVS_Tool::CreateAspectText3d if ( !theDr->GetInteger ( MeshVS_DA_TextFontAspect, aFontAspectI ) && !UseDefaults ) return anAsp; else - aFontAspect = (OSD_FontAspect) aFontAspectI; + aFontAspect = (Font_FontAspect) aFontAspectI; anAsp = new Graphic3d_AspectText3d ( aTColor, aFont, anExpFactor, aSpace, aStyle, aDispText ); anAsp->SetTextFontAspect( aFontAspect ); diff --git a/src/OSD/FILES b/src/OSD/FILES index 510ba5174e..3c20c771ba 100755 --- a/src/OSD/FILES +++ b/src/OSD/FILES @@ -16,7 +16,6 @@ OSD_signal.cxx OSD_signal_WNT.cxx OSD_ThreadFunction.hxx OSD_PThread.hxx -OSD_NListOfSystemFont.hxx OSD_Localizer.cxx OSD_PerfMeter.c OSD_PerfMeter.h diff --git a/src/OSD/OSD.cdl b/src/OSD/OSD.cdl index 930d527019..85f08da49f 100755 --- a/src/OSD/OSD.cdl +++ b/src/OSD/OSD.cdl @@ -93,10 +93,6 @@ is enumeration KindFile is FILE, DIRECTORY, LINK, SOCKET, UNKNOWN; ---Purpose: Specifies the type of files. - - --ABD Integration support of system fonts (using FTGL and FreeType) - enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic; - ---Purpose: Specifies aspect of system font. private enumeration WhoAmI is WDirectory, WDirectoryIterator, WEnvironment, WFile, WFileNode, WFileIterator, WMailBox, @@ -179,13 +175,7 @@ is imported ThreadFunction; class Thread; ---Purpose: A tool to manage threads - - --ABD Integration support of system fonts (using FTGL and FreeType) - imported NListOfSystemFont; - class SystemFont; - class FontMgr; - class Real2String; ---Purpose: Convertion of CString to Real and reciprocally diff --git a/src/OSD/OSD_FontMgr.cdl b/src/OSD/OSD_FontMgr.cdl deleted file mode 100755 index 80af87093b..0000000000 --- a/src/OSD/OSD_FontMgr.cdl +++ /dev/null @@ -1,52 +0,0 @@ --- Created on: 2008-01-20 --- Created by: Alexander A. BORODIN --- Copyright (c) 2008-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Updated: - - -class FontMgr from OSD inherits TShared from MMgt - - ---Purpose: Structure for store of Font System Information - -uses Path, - SystemFont, - NListOfSystemFont, - AsciiString from TCollection -is - GetInstance(myclass) - returns FontMgr; - ---Level: Public - - GetAvalableFonts(me) - returns NListOfSystemFont; - ---- Private methods - - Create returns FontMgr is private; - ---Purpose: Creates empty font object - ---Level: Private - - InitFontDataBase(me:mutable) is private; - -fields - - MyListOfFonts: NListOfSystemFont; - -end FontMgr; \ No newline at end of file diff --git a/src/OSD/OSD_FontMgr.cxx b/src/OSD/OSD_FontMgr.cxx deleted file mode 100755 index ae41f5b657..0000000000 --- a/src/OSD/OSD_FontMgr.cxx +++ /dev/null @@ -1,437 +0,0 @@ -// Created on: 2008-01-20 -// Created by: Alexander A. BORODIN -// Copyright (c) 2008-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Updated: - -#include -#ifdef WNT -# include -# include -#else //WNT -# include -# include -#endif //WNT - -#include -#include -#include -#include - - -#ifndef WNT -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -const Standard_Integer font_service_conf_size = 3; -static Standard_Character font_service_conf[font_service_conf_size][64] = { {"/etc/X11/fs/config"}, - {"/usr/X11R6/lib/X11/fs/config"}, - {"/usr/X11/lib/X11/fs/config"} - }; - -DEFINE_LIST( StringList, NCollection_List, TCollection_HAsciiString ); - -void find_path_with_font_dir( const TCollection_AsciiString& dir,StringList& dirs ) -{ - if( !dir.IsEmpty() ) - { - TCollection_AsciiString PathName( dir ); - - Standard_Integer rem = PathName.Length(); - - if ( PathName.SearchFromEnd("/") == rem ) - PathName.Remove( rem, 1 ); - - Standard_Boolean need_to_append = Standard_True; - - StringList::Iterator it( dirs ); - for( ; it.More(); it.Next() ) - { - if ( PathName.IsEqual(it.Value().ToCString()) ) { - need_to_append = Standard_False; - break; - } - } - if ( need_to_append ) - dirs.Append( PathName ); - - OSD_DirectoryIterator osd_dir(PathName,"*"); - while(osd_dir.More()) - { - OSD_Path path_file; - osd_dir.Values().Path( path_file ); - if( path_file.Name().Length() < 1 ) - { - osd_dir.Next(); - continue; - } - - TCollection_AsciiString full_path_name = PathName + "/" + path_file.Name(); - rem = full_path_name.Length(); - if ( full_path_name.SearchFromEnd("/") == rem ) - full_path_name.Remove( rem, 1 ); - find_path_with_font_dir( full_path_name, dirs ); - osd_dir.Next(); - } - } -} - -#endif //WNT - - -Handle(OSD_FontMgr) OSD_FontMgr::GetInstance() { - - static Handle(OSD_FontMgr) _mgr; - if ( _mgr.IsNull() ) - _mgr = new OSD_FontMgr(); - - return _mgr; - -} - -OSD_FontMgr::OSD_FontMgr() { - - InitFontDataBase(); - -} - -void OSD_FontMgr::InitFontDataBase() { - - MyListOfFonts.Clear(); - -#ifdef WNT - //detect font directory - - OSD_Environment env("windir"); - TCollection_AsciiString windir_str = env.Value(); - if ( windir_str.IsEmpty() ) - { - return; - } - Handle(TCollection_HAsciiString) HFontDir = new TCollection_HAsciiString( windir_str ); - HFontDir->AssignCat( "\\Fonts\\" ); - #ifdef TRACE - cout << "System font directory: " << HFontDir->ToCString() << "\n"; - #endif TRACE - - //read registry - HKEY fonts_hkey; - if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, - TEXT("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"), - 0, - KEY_READ, - &fonts_hkey ) - != ERROR_SUCCESS ) - { - return; - } - Standard_Integer id = 0; - Standard_Character buf_name[100]; - Standard_Byte buf_data[100]; - DWORD size_name = 100, - size_data = 100; - - while ( true ) - { - //detect file name - DWORD type; - size_name = 100, - size_data = 100; - OSD_FontAspect aspect; - if( RegEnumValue( fonts_hkey, - id, - buf_name, - &size_name, - NULL, - &type, - buf_data, - &size_data) == ERROR_NO_MORE_ITEMS ) { - break; - } - Handle(TCollection_HAsciiString) fname = - new TCollection_HAsciiString(buf_name); - fname->RightAdjust(); - fname->LeftAdjust(); - //remove construction like (TrueType.... - Standard_Integer anIndexTT = fname->SearchFromEnd( new TCollection_HAsciiString( " (" ) ); - Standard_Boolean aTruncate = Standard_False; - if ( anIndexTT > 1 ) - fname->Trunc( anIndexTT ); - Standard_Integer anIndex = 0; - fname->RightAdjust(); - if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Bold Italic") ) ) > 0 ) { - aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); - aspect = OSD_FA_BoldItalic; - } else if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Bold") ) ) > 0 ) { - aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); - aspect = OSD_FA_Bold; - } else if ( ( anIndex = fname->SearchFromEnd( new TCollection_HAsciiString("Italic") ) ) > 0 ) { - aTruncate = ( anIndex > 1 ) && ( fname->Value(anIndex - 1 ) == ' ' ); - aspect = OSD_FA_Italic; - } else { - aspect = OSD_FA_Regular; - } - if( aTruncate ) - fname->Trunc( anIndex - 1 ); - fname->RightAdjust(); - Handle(TCollection_HAsciiString) file_path = - new TCollection_HAsciiString( (Standard_Character*)buf_data ); - if ( strchr( (Standard_Character*)buf_data, '\\' ) == NULL ) { - file_path->Insert( 1, HFontDir ); - } - - if( ( ( file_path->Search(".ttf") > 0 ) || ( file_path->Search(".TTF") > 0 ) || - ( file_path->Search(".otf") > 0 ) || ( file_path->Search(".OTF") > 0 ) || - ( file_path->Search(".ttc") > 0 ) || ( file_path->Search(".TTC") > 0 ) ) ){ - MyListOfFonts.Append( new OSD_SystemFont( fname, aspect, file_path ) ); -#ifdef TRACE - cout << "Adding font...\n" - << " font name: " << fname->ToCString() << "\n" - << " font file: " << file_path->ToCString() << "\n" - << " font aspect: "; - switch( aspect ) { - case OSD_FA_Bold: - cout << "OSD_FA_Bold\n"; - break; - case OSD_FA_BoldItalic: - cout << "OSD_FA_BoldItalic\n"; - break; - case OSD_FA_Italic: - cout << "OSD_FA_Italic\n"; - break; - default: - cout << "OSD_FA_Regular\n"; - break; - } -#endif - } - id++; - } - //close registry - RegCloseKey( fonts_hkey ); -#endif //WNT - -#ifndef WNT - StringList dirs; - Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString; - Display * disp = XOpenDisplay("localhost:0.0"); - - if (!disp) - { - // let the X server find the available connection - disp = XOpenDisplay(":0.0"); - if (!disp) - { - cout << "Display is NULL!" << endl; - return ; - } - } - - Standard_Integer npaths = 0; - - Standard_Character** fontpath = XGetFontPath(disp, &npaths); -#ifdef TRACE - cout << "NPATHS = " << npaths << endl ; -#endif - for (Standard_Integer i = 0; i < npaths; i++ ) - { -#ifdef TRACE - cout << "Font Path: " << fontpath[i] << endl; -#endif - if ( fontpath[i][0] == '/' ) { - TCollection_AsciiString aFontPath( fontpath[i] ); - find_path_with_font_dir( aFontPath, dirs ); - } - else - { - TCollection_AsciiString aFontPath( fontpath[i] ); - TCollection_AsciiString aCutFontPath; - Standard_Integer location = -1 ; - location = aFontPath.Location( "/",1,aFontPath.Length() ); - if( location > 0 ) - aCutFontPath.AssignCat( aFontPath.SubString(location, aFontPath.Length() ) ); - find_path_with_font_dir( aCutFontPath, dirs ); - } - } - XFreeFontPath(fontpath); - - - OSD_OpenMode aMode = OSD_ReadOnly; - OSD_Protection aProtect( OSD_R, OSD_R, OSD_R, OSD_R ); - - for( Standard_Integer j = 0 ; j < font_service_conf_size; j++ ) - { - TCollection_AsciiString fileOfFontServiceName( font_service_conf[j] ); - OSD_File aFile( fileOfFontServiceName ); - - if( aFile.Exists() ) - aFile.Open( aMode, aProtect ); - - if( aFile.IsOpen() )//font service - { - Standard_Integer aNByte = 256; - Standard_Integer aNbyteRead; - TCollection_AsciiString aStr( aNByte );//read string with information - TCollection_AsciiString aStrCut( aNByte );//cut of string - TCollection_AsciiString endStr;//cutting string - - Standard_Boolean read_dirs = Standard_False; - Standard_Integer location =- 1; //disposition of necessary literals - Standard_Integer begin =- 1; //first left entry in string - Standard_Integer end =- 1; //first right entry in string - while( !aFile.IsAtEnd() ) - { - aFile.ReadLine( aStr, aNByte, aNbyteRead );//reading 1 lines(256 bytes) - location = aStr.Location( "catalogue = ", 1, aStr.Length() ); - if(location == 0) - location = aStr.Location( "catalogue=", 1, aStr.Length() ); - if(location == 0) - location = aStr.Location( "catalogue= ", 1, aStr.Length() ); - if(location == 0) - location = aStr.Location( "catalogue = ", 1, aStr.Length() ); - if( location > 0 ) - { -#ifdef TRACE - cout << " Font config find!!" << endl; -#endif - read_dirs = Standard_True; - } - - if( read_dirs ) - { - begin = aStr.Location( "/", 1, aStr.Length() );//begin of path name - end = aStr.Location( ":", 1, aStr.Length() );//end of path name - if( end < 1 ) - end = aStr.Location( ",", 1, aStr.Length() );//also end of path name - end -= 1; - if( begin > 0 && end > 0 ) - { - if( ( end - begin ) > 0 ) - endStr.AssignCat( aStr.SubString ( begin, end ) );//cutting necessary literals for string - dirs.Append( TCollection_HAsciiString ( endStr ) ); - endStr.Clear(); - } - else - if( begin > 0 && end == -1 ) - { - //if end of string don't have "," or ":" - //it is possible last sentence in block of word - endStr.AssignCat( aStr.SubString( begin, aStr.Length() - 1 ) ); - dirs.Append( TCollection_HAsciiString( endStr ) ); - endStr.Clear(); - } - } - - } - aFile.Close(); - } - } - - if( dirs.Size() > 0 ) - { - //if dirs list contains elements - OSD_OpenMode aModeRead = OSD_ReadOnly; - OSD_Protection aProtectRead( OSD_R, OSD_R , OSD_R , OSD_R ); - - TCollection_AsciiString fileFontsDir; - StringList::Iterator it( dirs ); - for( ; it.More(); it.Next() ) - { - fileFontsDir.AssignCat( it.Value().ToCString() ); - fileFontsDir.AssignCat( "/fonts.dir" );//append file name in path way - - OSD_File readFile( fileFontsDir ); - readFile.Open( aModeRead, aProtectRead ); - - Standard_Integer aNbyteRead, aNByte = 256; - if( readFile.IsOpen ( ) ) - { - TCollection_AsciiString aLine( aNByte ); - Standard_Integer countOfString = 0 ; - while( ! readFile.IsAtEnd() )//return true if EOF - { - if( countOfString > 1 ) - { - readFile.ReadLine( aLine , aNByte , aNbyteRead ); - if( ( ( aLine.Search(".pfa") > 0 ) || ( aLine.Search(".PFA") > 0 ) || - ( aLine.Search(".pfb") > 0 ) || ( aLine.Search(".PFB") > 0 ) || - ( aLine.Search(".ttf") > 0 ) || ( aLine.Search(".TTF") > 0 ) || - ( aLine.Search(".otf") > 0 ) || ( aLine.Search(".OTF") > 0 ) || - ( aLine.Search(".ttc") > 0 ) || ( aLine.Search(".TTC") > 0 ) ) - && ( aLine.Search( "iso8859-1\n" ) > 0 ) ) - { - - // In current implementation use fonts with ISO-8859-1 coding page. - // OCCT not give to manage coding page by means of programm interface. - // TODO: make high level interface for - // choosing necessary coding page. - TCollection_AsciiString aXLFD; - Standard_Integer leftXLFD = aLine.SearchFromEnd(" "); - Standard_Integer rightXLFD = aLine.Length(); - if( leftXLFD && rightXLFD ) - aXLFD.AssignCat(aLine.SubString( leftXLFD + 1, rightXLFD ) ); - - TCollection_AsciiString aPath; - TCollection_AsciiString aTemp( it.Value().ToCString() ); - if ( aTemp.SearchFromEnd("/") == aTemp.Length() ) - { - //this branch intend to SUN - aPath.AssignCat( aTemp.ToCString() ); - aPath.AssignCat( aLine.Token( " ", 1 ) ); - } - else { - //this branch intend to Linux - aPath.AssignCat( aTemp.ToCString( ) ); - aPath.AssignCat( "/" ); - aPath.AssignCat( aLine.Token( " ", 1 ) ); - } - MyListOfFonts.Append( new OSD_SystemFont( new TCollection_HAsciiString( aXLFD ), - new TCollection_HAsciiString( aPath ) ) ); - } - - } - else - readFile.ReadLine( aLine, aNByte, aNbyteRead ); - countOfString++; - } - readFile.Close(); - } - fileFontsDir.Clear(); - } - } -#endif -} - -OSD_NListOfSystemFont OSD_FontMgr::GetAvalableFonts() const -{ - return MyListOfFonts; -} - - diff --git a/src/OSD/OSD_NListOfSystemFont.hxx b/src/OSD/OSD_NListOfSystemFont.hxx deleted file mode 100755 index c30575c113..0000000000 --- a/src/OSD/OSD_NListOfSystemFont.hxx +++ /dev/null @@ -1,31 +0,0 @@ -// Created on: 2009-01-20 -// Created by: Alexander A. BORODIN -// Copyright (c) 2009-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifndef _OSD_NListOfSystemFont_HeaderFile -#define _OSD_NListOfSystemFont_HeaderFile - -#include -#include - -DEFINE_LIST (OSD_NListOfSystemFont, - NCollection_List, - Handle(OSD_SystemFont)) - -#endif diff --git a/src/OSD/OSD_SystemFont.cdl b/src/OSD/OSD_SystemFont.cdl deleted file mode 100755 index 704488f332..0000000000 --- a/src/OSD/OSD_SystemFont.cdl +++ /dev/null @@ -1,82 +0,0 @@ --- Created on: 2008-01-20 --- Created by: Alexander A. BORODIN --- Copyright (c) 2008-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Updated: - - -class SystemFont from OSD inherits TShared from MMgt - - ---Purpose: Structure for store of Font System Information - -uses FontAspect, - HAsciiString from TCollection - - -is - Create returns SystemFont; - ---Purpose: Creates empty font object - ---Level: Public - - Create ( - FontName : HAsciiString; - Aspect : FontAspect; - FilePath : HAsciiString ) returns SystemFont; - ---Purpose: Creates Font object initialized with as name - --- .... TODO - ---Level: Public - - Create ( - XLFD : HAsciiString; - FilePath : HAsciiString ) returns SystemFont; - ---Purpose: TODO - ---Level: Public - - FontName (me) - returns HAsciiString; - --- Purpose: Returns font family name - ---Level: Public - - FontPath (me) - returns HAsciiString; - --- Purpose: Returns font file path - --- Level: Public - - FontAspect (me) - returns FontAspect from OSD; - --- Purpose: Returns font aspect - --- Level: Public - - FontHeight (me) - returns Integer from Standard; - --- Purpose: Returns font height - --- If returned value is equal -1 it means that font is resizable - --- Level: Public - - IsValid( me ) - returns Boolean; - - fields - MyFontName: HAsciiString; --Font family name - MyFontAspect: FontAspect; - MyFaceSize: Integer; --height of font - MyFilePath: HAsciiString; --absolute path to font file - MyVerification: Boolean; --indicator of font initialization errors. False if initialization is failed. - -end SystemFont; diff --git a/src/OSD/OSD_SystemFont.cxx b/src/OSD/OSD_SystemFont.cxx deleted file mode 100755 index 5accc0c143..0000000000 --- a/src/OSD/OSD_SystemFont.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// Created on: 2008-01-20 -// Created by: Alexander A. BORODIN -// Copyright (c) 2008-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// Updated: - -#include -#include -#include - - -OSD_SystemFont::OSD_SystemFont(): -MyFontName(), -MyFontAspect(OSD_FA_Undefined), -MyFaceSize(-1), -MyVerification(Standard_False) -{ -} - -OSD_SystemFont::OSD_SystemFont( const Handle(TCollection_HAsciiString)& FontName, - const OSD_FontAspect FontAspect, - const Handle(TCollection_HAsciiString)& FilePath ): -MyFontName(FontName), -MyFontAspect(FontAspect), -MyFilePath(FilePath), -MyFaceSize(-1), -MyVerification(Standard_True) -{ - -} - -OSD_SystemFont::OSD_SystemFont( const Handle(TCollection_HAsciiString)& XLFD, - const Handle(TCollection_HAsciiString)& FilePath) : -MyFilePath(FilePath), -MyFontAspect(OSD_FA_Undefined) -{ - MyVerification = Standard_True; - if ( XLFD.IsNull() ) - { - MyVerification=Standard_False; - printf("NULL XLFD handler \n"); - } - if ( XLFD->IsEmpty() ) - { - MyVerification=Standard_False; - printf("EMPTY XLFD handler \n"); - } - - if(MyVerification) - { - MyFontName = XLFD->Token( "-", 2 ); - TCollection_AsciiString str( XLFD->ToCString() ); - - if ( str.Search( "-0-0-0-0-" ) >=0 ) - MyFaceSize = -1; - else - //TODO catch exeption - MyFaceSize = str.Token( "-", 7 ).IntegerValue(); - - //detect aspect - if ( str.Token("-", 3).IsEqual( "bold" ) ) - MyFontAspect = OSD_FA_Bold; - else if ( str.Token("-", 3).IsEqual( "medium" ) || - str.Token("-", 3).IsEqual( "normal" ) ) - MyFontAspect = OSD_FA_Regular; - - if ( MyFontAspect != OSD_FA_Undefined && - ( str.Token("-",4 ).IsEqual( "i" ) || str.Token("-",4 ).IsEqual( "o" ) ) ) - { - if ( MyFontAspect == OSD_FA_Bold ) - MyFontAspect = OSD_FA_BoldItalic; - else - MyFontAspect = OSD_FA_Italic; - } - } -} - -Standard_Boolean OSD_SystemFont::IsValid() const{ - if ( !MyVerification) - return Standard_False; - - if ( MyFontAspect == OSD_FA_Undefined ) - return Standard_False; - - if ( MyFontName->IsEmpty() || !MyFontName->IsAscii() ) - return Standard_False; - - OSD_Path path; - return path.IsValid( MyFilePath->String() ); -} - -Handle(TCollection_HAsciiString) OSD_SystemFont::FontPath() const{ - return MyFilePath; -} - -Handle(TCollection_HAsciiString) OSD_SystemFont::FontName() const{ - return MyFontName; -} - -OSD_FontAspect OSD_SystemFont::FontAspect() const{ - return MyFontAspect; -} - -Standard_Integer OSD_SystemFont::FontHeight() const { - return MyFaceSize; -} diff --git a/src/OpenGl/OpenGl_AspectText.cxx b/src/OpenGl/OpenGl_AspectText.cxx index 18eb71a05c..7a5a02197c 100644 --- a/src/OpenGl/OpenGl_AspectText.cxx +++ b/src/OpenGl/OpenGl_AspectText.cxx @@ -27,7 +27,7 @@ static const TEL_COLOUR myDefaultColor = {{ 1.0F, 1.0F, 1.0F, 1.0F }}; OpenGl_AspectText::OpenGl_AspectText () : myZoomable(0), myAngle(0.0F), - myFontAspect(OSD_FA_Regular), + myFontAspect(Font_FA_Regular), myFont(NULL), //mySpace(0.3F), //myExpan(1.0F), @@ -53,7 +53,7 @@ void OpenGl_AspectText::SetContext (const CALL_DEF_CONTEXTTEXT &AContext) { myZoomable = (int) AContext.TextZoomable; myAngle = (float) AContext.TextAngle; - myFontAspect = (OSD_FontAspect) AContext.TextFontAspect; + myFontAspect = (Font_FontAspect) AContext.TextFontAspect; //mySpace = (float) AContext.Space; //myExpan = (float) AContext.Expan; myColor.rgb[0] = (float) AContext.Color.r; diff --git a/src/OpenGl/OpenGl_AspectText.hxx b/src/OpenGl/OpenGl_AspectText.hxx index 8f52814a0f..4904825e18 100644 --- a/src/OpenGl/OpenGl_AspectText.hxx +++ b/src/OpenGl/OpenGl_AspectText.hxx @@ -22,7 +22,7 @@ #define OpenGl_AspectText_Header #include -#include +#include #include #include @@ -40,7 +40,7 @@ public: int IsZoomable() const { return myZoomable; } float Angle() const { return myAngle; } - OSD_FontAspect FontAspect() const { return myFontAspect; } + Font_FontAspect FontAspect() const { return myFontAspect; } const char * Font() const { return myFont; } const TEL_COLOUR & Color() const { return myColor; } Aspect_TypeOfStyleText StyleType() const { return myStyleType; } @@ -58,7 +58,7 @@ protected: int myZoomable; float myAngle; - OSD_FontAspect myFontAspect; + Font_FontAspect myFontAspect; const char *myFont; //float mySpace; //float myExpan; diff --git a/src/OpenGl/OpenGl_Display.hxx b/src/OpenGl/OpenGl_Display.hxx index 5feee80149..01daf2b7fd 100644 --- a/src/OpenGl/OpenGl_Display.hxx +++ b/src/OpenGl/OpenGl_Display.hxx @@ -33,7 +33,7 @@ #include #include -#include +#include #include @@ -115,7 +115,7 @@ class OpenGl_Display : public MMgt_TShared // Fonts - int FindFont (const char* AFontName, const OSD_FontAspect AFontAspect, const int ABestSize = -1, const float AXScale = 1.F, const float AYScale = 1.F); + int FindFont (const char* AFontName, const Font_FontAspect AFontAspect, const int ABestSize = -1, const float AXScale = 1.F, const float AYScale = 1.F); void StringSize (const wchar_t *text, int &width, int &ascent, int &descent); diff --git a/src/OpenGl/OpenGl_Display_1.cxx b/src/OpenGl/OpenGl_Display_1.cxx index e81239642d..482c780ccf 100644 --- a/src/OpenGl/OpenGl_Display_1.cxx +++ b/src/OpenGl/OpenGl_Display_1.cxx @@ -45,7 +45,7 @@ struct FontMapNode { const char * EnumName; const char * FontName; - OSD_FontAspect FontAspect; + Font_FontAspect FontAspect; }; static const FontMapNode myFontMap[] = @@ -53,30 +53,30 @@ static const FontMapNode myFontMap[] = #ifdef WNT - { "Courier" , "Courier New" , OSD_FA_Regular }, - { "Times-Roman" , "Times New Roman", OSD_FA_Regular }, - { "Times-Bold" , "Times New Roman", OSD_FA_Bold }, - { "Times-Italic" , "Times New Roman", OSD_FA_Italic }, - { "Times-BoldItalic" , "Times New Roman", OSD_FA_BoldItalic }, - { "ZapfChancery-MediumItalic", "Script" , OSD_FA_Regular }, - { "Symbol" , "Symbol" , OSD_FA_Regular }, - { "ZapfDingbats" , "WingDings" , OSD_FA_Regular }, - { "Rock" , "Arial" , OSD_FA_Regular }, - { "Iris" , "Lucida Console" , OSD_FA_Regular } + { "Courier" , "Courier New" , Font_FA_Regular }, + { "Times-Roman" , "Times New Roman", Font_FA_Regular }, + { "Times-Bold" , "Times New Roman", Font_FA_Bold }, + { "Times-Italic" , "Times New Roman", Font_FA_Italic }, + { "Times-BoldItalic" , "Times New Roman", Font_FA_BoldItalic }, + { "ZapfChancery-MediumItalic", "Script" , Font_FA_Regular }, + { "Symbol" , "Symbol" , Font_FA_Regular }, + { "ZapfDingbats" , "WingDings" , Font_FA_Regular }, + { "Rock" , "Arial" , Font_FA_Regular }, + { "Iris" , "Lucida Console" , Font_FA_Regular } #else //X11 - { "Courier" , "Courier" , OSD_FA_Regular }, - { "Times-Roman" , "Times" , OSD_FA_Regular }, - { "Times-Bold" , "Times" , OSD_FA_Bold }, - { "Times-Italic" , "Times" , OSD_FA_Italic }, - { "Times-BoldItalic" , "Times" , OSD_FA_BoldItalic }, - { "Arial" , "Helvetica" , OSD_FA_Regular }, - { "ZapfChancery-MediumItalic", "-adobe-itc zapf chancery-medium-i-normal--*-*-*-*-*-*-iso8859-1" , OSD_FA_Regular }, - { "Symbol" , "-adobe-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , OSD_FA_Regular }, - { "ZapfDingbats" , "-adobe-itc zapf dingbats-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , OSD_FA_Regular }, - { "Rock" , "-sgi-rock-medium-r-normal--*-*-*-*-p-*-iso8859-1" , OSD_FA_Regular }, - { "Iris" , "--iris-medium-r-normal--*-*-*-*-m-*-iso8859-1" , OSD_FA_Regular } + { "Courier" , "Courier" , Font_FA_Regular }, + { "Times-Roman" , "Times" , Font_FA_Regular }, + { "Times-Bold" , "Times" , Font_FA_Bold }, + { "Times-Italic" , "Times" , Font_FA_Italic }, + { "Times-BoldItalic" , "Times" , Font_FA_BoldItalic }, + { "Arial" , "Helvetica" , Font_FA_Regular }, + { "ZapfChancery-MediumItalic", "-adobe-itc zapf chancery-medium-i-normal--*-*-*-*-*-*-iso8859-1" , Font_FA_Regular }, + { "Symbol" , "-adobe-symbol-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular }, + { "ZapfDingbats" , "-adobe-itc zapf dingbats-medium-r-normal--*-*-*-*-*-*-adobe-fontspecific" , Font_FA_Regular }, + { "Rock" , "-sgi-rock-medium-r-normal--*-*-*-*-p-*-iso8859-1" , Font_FA_Regular }, + { "Iris" , "--iris-medium-r-normal--*-*-*-*-m-*-iso8859-1" , Font_FA_Regular } #endif }; @@ -154,7 +154,7 @@ void OpenGl_Display::getGL2PSFontName (const char *src_font, char *ps_font) /*-----------------------------------------------------------------------------*/ -int OpenGl_Display::FindFont (const char* AFontName, const OSD_FontAspect AFontAspect, +int OpenGl_Display::FindFont (const char* AFontName, const Font_FontAspect AFontAspect, const int ABestSize, const float AXScale, const float AYScale) { if (!AFontName) @@ -194,7 +194,7 @@ int OpenGl_Display::FindFont (const char* AFontName, const OSD_FontAspect AFontA // The last resort: trying to use ANY font available in the system if ( myFont == -1 ) { - myFont = mgr->request_font( family_name, OSD_FA_Undefined, -1 ); + myFont = mgr->request_font( family_name, Font_FA_Undefined, -1 ); } if ( myFont != -1 ) diff --git a/src/OpenGl/OpenGl_FontMgr.cxx b/src/OpenGl/OpenGl_FontMgr.cxx index 7665039c9d..c4413219d9 100755 --- a/src/OpenGl/OpenGl_FontMgr.cxx +++ b/src/OpenGl/OpenGl_FontMgr.cxx @@ -81,22 +81,22 @@ OpenGl_FontMgr* OpenGl_FontMgr::instance() void OpenGl_FontMgr::_initializeFontDB() { - Handle(OSD_FontMgr) fntMgr = OSD_FontMgr::GetInstance(); + Handle(Font_FontMgr) fntMgr = Font_FontMgr::GetInstance(); if ( !fntMgr.IsNull() ) { - OSD_NListOfSystemFont fontList = fntMgr->GetAvalableFonts(); + Font_NListOfSystemFont fontList = fntMgr->GetAvalableFonts(); if ( fontList.Size() != 0 ) { - // The library used as a tool for checking font aspect since OSD_FontMgr + // The library used as a tool for checking font aspect since Font_FontMgr // fails to get aspect for the fonts that have name dependant // on system locale. FT_Library aFtLibrary; FT_Error aLibError = FT_Init_FreeType(&aFtLibrary); - OSD_NListOfSystemFont::Iterator it(fontList); + Font_NListOfSystemFont::Iterator it(fontList); for ( ; it.More(); it.Next() ) { OGLFont_SysInfo* info = new OGLFont_SysInfo(); - if ( it.Value()->FontAspect() == OSD_FA_Regular ) { + if ( it.Value()->FontAspect() == Font_FA_Regular ) { Handle(TCollection_HAsciiString) aFontPath = it.Value()->FontPath(); @@ -119,20 +119,20 @@ void OpenGl_FontMgr::_initializeFontDB() << "\tFont New Name: " << aFontFace->family_name << endl << "\tFont Aspect: " << aFontFace->style_flags << endl; #endif - OSD_FontAspect aspect = OSD_FA_Regular; + Font_FontAspect aspect = Font_FA_Regular; if ( aFontFace->style_flags == (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD) ) - aspect = OSD_FA_BoldItalic; + aspect = Font_FA_BoldItalic; else if ( aFontFace->style_flags == FT_STYLE_FLAG_ITALIC ) - aspect = OSD_FA_Italic; + aspect = Font_FA_Italic; else if ( aFontFace->style_flags == FT_STYLE_FLAG_BOLD ) - aspect = OSD_FA_Bold; + aspect = Font_FA_Bold; #ifdef TRACE - cout << "\tOSD_FontAspect: " << aspect << endl; + cout << "\tFont_FontAspect: " << aspect << endl; #endif Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString( aFontFace->family_name ); - info->SysFont = new OSD_SystemFont( aFontName, aspect, aFontPath ); + info->SysFont = new Font_SystemFont( aFontName, aspect, aFontPath ); } FT_Done_Face(aFontFace); @@ -174,10 +174,10 @@ bool OpenGl_FontMgr::requestFontList( Graphic3d_NListOfHAsciiString& lst) } // Empty fontName means that ANY family name can be used. -// fontAspect == OSD_FA_Undefined means ANY font aspect is acceptable. +// fontAspect == Font_FA_Undefined means ANY font aspect is acceptable. // fontheight == -1 means ANY font height is acceptable. int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontName, - const OSD_FontAspect fontAspect, + const Font_FontAspect fontAspect, const Standard_Integer fontHeight ) { Standard_Integer aFontHeight = fontHeight; @@ -216,7 +216,7 @@ int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontNa #endif //check for font aspect - if (fontAspect != OSD_FA_Undefined && DBit.Value()->SysFont->FontAspect() != fontAspect) { + if (fontAspect != Font_FA_Undefined && DBit.Value()->SysFont->FontAspect() != fontAspect) { #ifdef TRACE cout << "\tAspect of candidate font: " << DBit.Value()->SysFont->FontAspect() << endl; cout << "\tAspects are not equal! Continue seaching...\n"; @@ -322,20 +322,20 @@ int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontNa switch( fontAspect ) { - case OSD_FA_Bold: - cout << "OSD_FA_Bold\n"; + case Font_FA_Bold: + cout << "Font_FA_Bold\n"; break; - case OSD_FA_BoldItalic: - cout << "OSD_FA_BoldItalic\n"; + case Font_FA_BoldItalic: + cout << "Font_FA_BoldItalic\n"; break; - case OSD_FA_Italic: - cout << "OSD_FA_Italic\n"; + case Font_FA_Italic: + cout << "Font_FA_Italic\n"; break; - case OSD_FA_Regular: - cout << "OSD_FA_Regular\n"; + case Font_FA_Regular: + cout << "Font_FA_Regular\n"; break; default: - cout << "OSD_FA_Undefined\n"; + cout << "Font_FA_Undefined\n"; break; } cout << " font height: "< #include #include -#include +#include void dump_texture(); @@ -44,7 +44,7 @@ class OpenGl_FontMgr static OpenGl_FontMgr* instance(); int request_font( const Handle(TCollection_HAsciiString)& fontName, - const OSD_FontAspect fontAspect, + const Font_FontAspect fontAspect, const Standard_Integer fontHeight ); void render_text( const Standard_Integer id, @@ -78,7 +78,7 @@ private: typedef NCollection_List IDList; struct OGLFont_SysInfo { - Handle(OSD_SystemFont) SysFont; + Handle(Font_SystemFont) SysFont; IDList GeneratedFonts; }; diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx index b920edf70c..183edb5b45 100644 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.cxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.cxx @@ -135,7 +135,7 @@ static char getFarestCorner(float d000, float d100, float d010, float d001, return 8; /* d111 */ } -static void drawText(const Handle(OpenGl_Workspace) &AWorkspace, const wchar_t* text, const char* font, OSD_FontAspect style, int size, float x, float y, float z) +static void drawText(const Handle(OpenGl_Workspace) &AWorkspace, const wchar_t* text, const char* font, Font_FontAspect style, int size, float x, float y, float z) { AWorkspace->FindFont(font, style, size); AWorkspace->RenderText(text, 0, x, y, z); diff --git a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx index 9a30e6e04e..529620b390 100644 --- a/src/OpenGl/OpenGl_GraduatedTrihedron.hxx +++ b/src/OpenGl/OpenGl_GraduatedTrihedron.hxx @@ -64,10 +64,10 @@ class OpenGl_GraduatedTrihedron : public MMgt_TShared float myYColor[3]; float myZColor[3]; const char *myFontOfNames; - OSD_FontAspect myStyleOfNames; + Font_FontAspect myStyleOfNames; int mySizeOfNames; const char* myFontOfValues; - OSD_FontAspect myStyleOfValues; + Font_FontAspect myStyleOfValues; int mySizeOfValues; minMaxValuesCallback myCbCubicAxes; void* myPtrVisual3dView; diff --git a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx index fa51a9e582..9c884b1b7d 100755 --- a/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx +++ b/src/OpenGl/OpenGl_GraphicDriver_Layer.cxx @@ -22,7 +22,7 @@ #include -#include +#include #include #include @@ -64,7 +64,7 @@ static const CALL_DEF_CONTEXTTEXT myDefaultContextText = { 1.F, 1.F, 1.F }, //ColorSubTitle 0, //TextZoomable 0.F, //TextAngle - (int)OSD_FA_Regular //TextFontAspect + (int)Font_FA_Regular //TextFontAspect }; static Standard_Boolean TheLayerIsOpen = Standard_False; diff --git a/src/OpenGl/OpenGl_Trihedron.cxx b/src/OpenGl/OpenGl_Trihedron.cxx index 2bc7e0ee65..49c03bc8d6 100644 --- a/src/OpenGl/OpenGl_Trihedron.cxx +++ b/src/OpenGl/OpenGl_Trihedron.cxx @@ -63,7 +63,7 @@ static const CALL_DEF_CONTEXTTEXT myDefaultContextText = { 1.F, 1.F, 1.F }, //ColorSubTitle 0, //TextZoomable 0.F, //TextAngle - OSD_FA_Regular //TextFontAspect + Font_FA_Regular //TextFontAspect }; /*----------------------------------------------------------------------*/ diff --git a/src/OpenGl/OpenGl_Workspace.hxx b/src/OpenGl/OpenGl_Workspace.hxx index 6e9d569a9c..e43eea7abe 100644 --- a/src/OpenGl/OpenGl_Workspace.hxx +++ b/src/OpenGl/OpenGl_Workspace.hxx @@ -167,11 +167,11 @@ public: //// RELATED TO FONTS //// - int FindFont (const char* theFontName, - const OSD_FontAspect theFontAspect, - const int theBestSize = -1, - const float theXScale = 1.0f, - const float theYScale = 1.0f) + int FindFont (const char* theFontName, + const Font_FontAspect theFontAspect, + const int theBestSize = -1, + const float theXScale = 1.0f, + const float theYScale = 1.0f) { return myDisplay->FindFont (theFontName, theFontAspect, theBestSize, theXScale, theYScale); } diff --git a/src/TKService/PACKAGES b/src/TKService/PACKAGES index 1e0072a1a4..228e8aee78 100755 --- a/src/TKService/PACKAGES +++ b/src/TKService/PACKAGES @@ -12,3 +12,4 @@ PlotMgt ImageUtility WNT TColQuantity +Font diff --git a/src/V3d/V3d.cdl b/src/V3d/V3d.cdl index 71de97b632..f805b9bd02 100755 --- a/src/V3d/V3d.cdl +++ b/src/V3d/V3d.cdl @@ -58,7 +58,8 @@ uses PlotMgt, Image, gp, - OSD + OSD, + Font is diff --git a/src/V3d/V3d_View.cdl b/src/V3d/V3d_View.cdl index 540697859c..0d67fc479e 100755 --- a/src/V3d/V3d_View.cdl +++ b/src/V3d/V3d_View.cdl @@ -149,7 +149,7 @@ uses GraphicCallbackProc from Aspect, FillMethod from Aspect, GradientFillMethod from Aspect, - FontAspect from OSD, + FontAspect from Font, AsciiString from TCollection, ExtendedString from TCollection, PrintAlgo from Aspect @@ -524,13 +524,13 @@ is -- Name of font for names of axes -- fontOfNames : out AsciiString from TCollection; -- Style of names of axes -- - styleOfNames : out FontAspect from OSD; + styleOfNames : out FontAspect from Font; -- Size of names of axes -- sizeOfNames : out Integer from Standard; -- Name of font for values -- fontOfValues : out AsciiString from TCollection; -- Style of values -- - styleOfValues : out FontAspect from OSD; + styleOfValues : out FontAspect from Font; -- Size of values -- sizeOfValues : out Integer from Standard) ---Purpose: Returns data of a graduated trihedron. @@ -590,13 +590,13 @@ is -- Name of font for names of axes -- fontOfNames : AsciiString from TCollection = "Arial"; -- Style of names of axes -- - styleOfNames : FontAspect from OSD = OSD_FA_Bold; + styleOfNames : FontAspect from Font = Font_FA_Bold; -- Size of names of axes -- sizeOfNames : Integer from Standard = 12; -- Name of font for values -- fontOfValues : AsciiString from TCollection = "Arial"; -- Style of values -- - styleOfValues : FontAspect from OSD = OSD_FA_Regular; + styleOfValues : FontAspect from Font = Font_FA_Regular; -- Size of values -- sizeOfValues : Integer from Standard = 12) ---Purpose: Displays a graduated trihedron. diff --git a/src/V3d/V3d_View_4.cxx b/src/V3d/V3d_View_4.cxx index 562b3e2bbc..b0b049ce1e 100755 --- a/src/V3d/V3d_View_4.cxx +++ b/src/V3d/V3d_View_4.cxx @@ -562,13 +562,13 @@ void V3d_View::GetGraduatedTrihedron(/* Names of axes */ /* Name of font for names of axes */ TCollection_AsciiString &fontOfNames, /* Style of names of axes */ - OSD_FontAspect& styleOfNames, + Font_FontAspect& styleOfNames, /* Size of names of axes */ Standard_Integer& sizeOfNames, /* Name of font for values */ TCollection_AsciiString &fontOfValues, /* Style of values */ - OSD_FontAspect& styleOfValues, + Font_FontAspect& styleOfValues, /* Size of values */ Standard_Integer& sizeOfValues) const { @@ -689,13 +689,13 @@ void V3d_View::GraduatedTrihedronDisplay(/* Names of axes */ /* Name of font for names of axes */ const TCollection_AsciiString &fontOfNames, /* Style of names of axes */ - const OSD_FontAspect styleOfNames, + const Font_FontAspect styleOfNames, /* Size of names of axes */ const Standard_Integer sizeOfNames, /* Name of font for values */ const TCollection_AsciiString &fontOfValues, /* Style of values */ - const OSD_FontAspect styleOfValues, + const Font_FontAspect styleOfValues, /* Size of values */ const Standard_Integer sizeOfValues) { diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 846bb7bc63..a6fc1dc654 100755 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2301,7 +2301,7 @@ public: Standard_Real Angle , Standard_Boolean Zoom , Standard_Real Height, - OSD_FontAspect FontAspect, + Font_FontAspect FontAspect, Standard_CString Font ); @@ -2325,7 +2325,7 @@ protected: Standard_Boolean aZoomable; Quantity_Color aColor; Standard_CString aFont; - OSD_FontAspect aFontAspect; + Font_FontAspect aFontAspect; Graphic3d_HorizontalTextAlignment aHJustification; Graphic3d_VerticalTextAlignment aVJustification; }; @@ -2343,7 +2343,7 @@ MyTextClass::MyTextClass( const TCollection_ExtendedString& text, const gp_Pnt& Standard_Real angle = 0.0 , Standard_Boolean zoomable = Standard_True, Standard_Real height = 12., - OSD_FontAspect fontAspect = OSD_FA_Regular, + Font_FontAspect fontAspect = Font_FA_Regular, Standard_CString font = "Courier") { aText = text; @@ -2443,7 +2443,7 @@ static int VDrawText (Draw_Interpretor& di, Standard_Integer argc, const char** const Standard_Real height = atof(argv[12]); // Text aspect - const OSD_FontAspect aspect = OSD_FontAspect(atoi(argv[13])); + const Font_FontAspect aspect = Font_FontAspect(atoi(argv[13])); // Text font TCollection_AsciiString font; diff --git a/src/Visual3d/Visual3d.cdl b/src/Visual3d/Visual3d.cdl index 2080f56dc4..21755f2b0e 100755 --- a/src/Visual3d/Visual3d.cdl +++ b/src/Visual3d/Visual3d.cdl @@ -59,7 +59,8 @@ uses MMgt, Xw, WNT, - OSD + OSD, + Font is diff --git a/src/Visual3d/Visual3d_Layer.cdl b/src/Visual3d/Visual3d_Layer.cdl index 2ecb2c6265..a6d6c0908c 100755 --- a/src/Visual3d/Visual3d_Layer.cdl +++ b/src/Visual3d/Visual3d_Layer.cdl @@ -47,7 +47,7 @@ uses LayerItem from Visual3d, NListOfLayerItem from Visual3d, - FontAspect from OSD + FontAspect from Font raises LayerDefinitionError from Visual3d diff --git a/src/Visual3d/Visual3d_View.cdl b/src/Visual3d/Visual3d_View.cdl index 48e58647c5..9c2a4685ae 100755 --- a/src/Visual3d/Visual3d_View.cdl +++ b/src/Visual3d/Visual3d_View.cdl @@ -117,7 +117,7 @@ uses ExportFormat from Graphic3d, SortType from Graphic3d, Color from Quantity, - FontAspect from OSD, + FontAspect from Font, AsciiString from TCollection, ExtendedString from TCollection, CGraduatedTrihedron from Graphic3d, @@ -635,13 +635,13 @@ is -- Name of font for names of axes -- fontOfNames : out AsciiString from TCollection; -- Style of names of axes -- - styleOfNames : out FontAspect from OSD; + styleOfNames : out FontAspect from Font; -- Size of names of axes -- sizeOfNames : out Integer from Standard; -- Name of font for values -- fontOfValues : out AsciiString from TCollection; -- Style of values -- - styleOfValues : out FontAspect from OSD; + styleOfValues : out FontAspect from Font; -- Size of values -- sizeOfValues : out Integer from Standard) returns Boolean from Standard @@ -678,13 +678,13 @@ is -- Name of font for names of axes -- fontOfNames : AsciiString from TCollection; -- Style of names of axes -- - styleOfNames : FontAspect from OSD; + styleOfNames : FontAspect from Font; -- Size of names of axes -- sizeOfNames : Integer from Standard; -- Name of font for values -- fontOfValues : AsciiString from TCollection; -- Style of values -- - styleOfValues : FontAspect from OSD; + styleOfValues : FontAspect from Font; -- Size of values -- sizeOfValues : Integer from Standard) ---Purpose: Displays a graduated trihedron. diff --git a/src/Visual3d/Visual3d_View.cxx b/src/Visual3d/Visual3d_View.cxx index a53786b886..c93e96d6dc 100755 --- a/src/Visual3d/Visual3d_View.cxx +++ b/src/Visual3d/Visual3d_View.cxx @@ -3734,13 +3734,13 @@ Standard_Boolean Visual3d_View::GetGraduatedTrihedron /* Name of font for names of axes */ TCollection_AsciiString& fontOfNames, /* Style of names of axes */ - OSD_FontAspect& styleOfNames, + Font_FontAspect& styleOfNames, /* Size of names of axes */ Standard_Integer& sizeOfNames, /* Name of font for values */ TCollection_AsciiString& fontOfValues, /* Style of values */ - OSD_FontAspect& styleOfValues, + Font_FontAspect& styleOfValues, /* Size of values */ Standard_Integer& sizeOfValues) const { @@ -3859,13 +3859,13 @@ void Visual3d_View::GraduatedTrihedronDisplay /* Name of font for names of axes */ const TCollection_AsciiString &fontOfNames, /* Style of names of axes */ - const OSD_FontAspect styleOfNames, + const Font_FontAspect styleOfNames, /* Size of names of axes */ const Standard_Integer sizeOfNames, /* Name of font for values */ const TCollection_AsciiString &fontOfValues, /* Style of values */ - const OSD_FontAspect styleOfValues, + const Font_FontAspect styleOfValues, /* Size of values */ const Standard_Integer sizeOfValues) {