mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0023415: OSD_FontMgr can't idenify aspect for fonts with names dependant on system locale.
Added function DetectFontsAspects to Font_FontMgr class. This function uses workaround from OpenGl_FontMgr with FreeType for detecting font aspect. Removed font name parsing from Font_FontMgr::InitFontDataBase(). Now the font name and font style we get through the FreeType. Fixed Unix part of Font_FontMgr::InitFontDataBase() method. Font name and font style now detected through the FreeType. Remarks fix. Added recursive default font directories scanning . Fixed adding fonts folders recursively from configuration files. Moved fonts aliases map from OpenGl_Display_1 to Font_FontMgr. Moved fonts name definition from Graphic3d_NameOfFont.hxx to Font_NameOfFont.hxx. Added new methods to Font_FontMgr: GetAvailableFontsNames, GetFont and FindFont. Modified Font_SystemFont creation from XLFD. Added method IsEqual to Font_SystemFont. Modified methods OpenGl_Display::FindFont, OpenGl_FontMgr::request_font in accordance to the new functionality of the Font_FontMgr. OpenGl_FontMgr now stores only generated fonts instead of duplication of available fonts list. Removed method OpenGl_FontMgr::requestFontList. Its function now performs Font_FontMgr::GetAvailableFontsNames. Documentation was fixed Adjusting testing cases for current state of OCCT
This commit is contained in:
parent
cb9292ed80
commit
aff395a36d
1
src/Font/EXTERNLIB
Normal file
1
src/Font/EXTERNLIB
Normal file
@ -0,0 +1 @@
|
|||||||
|
CSF_FREETYPE
|
@ -1 +1,3 @@
|
|||||||
|
EXTERNLIB
|
||||||
Font_NListOfSystemFont.hxx
|
Font_NListOfSystemFont.hxx
|
||||||
|
Font_NameOfFont.hxx
|
||||||
|
@ -21,7 +21,8 @@ package Font
|
|||||||
uses Standard ,
|
uses Standard ,
|
||||||
Quantity ,
|
Quantity ,
|
||||||
TCollection,
|
TCollection,
|
||||||
OSD
|
OSD,
|
||||||
|
TColStd
|
||||||
|
|
||||||
is
|
is
|
||||||
enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic;
|
enumeration FontAspect is FA_Undefined, FA_Regular, FA_Bold, FA_Italic, FA_BoldItalic;
|
||||||
|
@ -18,27 +18,78 @@
|
|||||||
-- and conditions governing the rights and limitations under the License.
|
-- and conditions governing the rights and limitations under the License.
|
||||||
|
|
||||||
class FontMgr from Font inherits TShared from MMgt
|
class FontMgr from Font inherits TShared from MMgt
|
||||||
---Purpose: Structure for store of Font System Information
|
---Purpose: Collects and provides information about available fonts in system.
|
||||||
|
---On Windows it gets information about available fonts from registry value
|
||||||
|
---"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts". If the description
|
||||||
|
---of the font does not contain the full path to it, FontMgr looks for it in the
|
||||||
|
---default fonts directory. (WinAPI function GetSystemWindowsDirectory is used
|
||||||
|
---to get the path of the shared Windows directory on a multi-user system.)
|
||||||
|
---On Linux and Mac OS X platforms for getting the directories with fonts, at first
|
||||||
|
---it checks X11 configuration files, which can be located at "/etc/X11/fs/config",
|
||||||
|
---"/usr/X11R6/lib/X11/fs/config" or "/usr/X11/lib/X11/fs/config". Then it adds
|
||||||
|
---default directories(for Linux: "/usr/share/fonts" and "/usr/local/share/fonts",
|
||||||
|
---for Mac OS X: "/System/Library/Fonts" and "/Library/Fonts"). After that FontMgr
|
||||||
|
---looks for the "fonts.dir" file in each stored directory. This file contain
|
||||||
|
---fonts description in XLFD (X Logical Font Description) format.
|
||||||
|
---On all platforms (Windows, Linux, Mac OS X) we use FreeType library for getting
|
||||||
|
---font name and aspect.
|
||||||
|
---On Linux and Mac OS X in cases when the font description obtained from FreeType
|
||||||
|
---does not match the description in XLFD, FontMgr stores such fonts as two different
|
||||||
|
---fonts (font management feature on Unix systems).
|
||||||
|
|
||||||
uses SystemFont,
|
uses FontAspect,
|
||||||
|
SystemFont,
|
||||||
NListOfSystemFont,
|
NListOfSystemFont,
|
||||||
Path from OSD,
|
Path from OSD,
|
||||||
AsciiString from TCollection
|
AsciiString from TCollection,
|
||||||
|
HAsciiString from TCollection,
|
||||||
|
SequenceOfHAsciiString from TColStd
|
||||||
is
|
is
|
||||||
GetInstance(myclass) returns FontMgr;
|
GetInstance(myclass) returns FontMgr;
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
GetAvalableFonts(me) returns NListOfSystemFont;
|
GetAvailableFonts(me) returns NListOfSystemFont;
|
||||||
|
---C++: return const &
|
||||||
|
|
||||||
--- Private methods
|
GetAvailableFontsNames(me;
|
||||||
|
theFontsNames: out SequenceOfHAsciiString);
|
||||||
|
---Purpose: Returns sequence of available fonts names
|
||||||
|
---Level: Public
|
||||||
|
|
||||||
|
GetFont (me;
|
||||||
|
theFontName : HAsciiString;
|
||||||
|
theFontAspect : FontAspect;
|
||||||
|
theFontSize : Integer) returns SystemFont;
|
||||||
|
---Purpose: Returns font that match given parameters.
|
||||||
|
--- If theFontName is empty string returned font can have any FontName.
|
||||||
|
--- If theFontAspect is Font_FA_Undefined returned font can have any FontAspect.
|
||||||
|
--- If theFontSize is "-1" returned font can have any FontSize.
|
||||||
|
---Level: Public
|
||||||
|
|
||||||
|
FindFont (me;
|
||||||
|
theFontName : HAsciiString;
|
||||||
|
theFontAspect : FontAspect;
|
||||||
|
theFontSize : Integer) returns SystemFont;
|
||||||
|
---Purpose: Tries to find font by given parameters.
|
||||||
|
--- If the specified font is not found tries to use font names mapping.
|
||||||
|
--- If the requested family name not found -> search for any font family
|
||||||
|
--- with given aspect and height. If the font is still not found, returns
|
||||||
|
--- any font available in the system. Returns NULL in case when the fonts
|
||||||
|
--- are not found in the system.
|
||||||
|
---Level: Public
|
||||||
|
|
||||||
|
--- Private methods
|
||||||
|
|
||||||
Create returns FontMgr is private;
|
Create returns FontMgr is private;
|
||||||
---Purpose: Creates empty font object
|
---Purpose: Creates empty font object
|
||||||
---Level: Private
|
---Level: Private
|
||||||
|
|
||||||
InitFontDataBase(me:mutable) is private;
|
InitFontDataBase(me:mutable) is private;
|
||||||
|
---Purpose: Collects available fonts paths.
|
||||||
|
---Level: Private
|
||||||
|
|
||||||
fields
|
fields
|
||||||
MyListOfFonts: NListOfSystemFont;
|
|
||||||
|
myListOfFonts : NListOfSystemFont;
|
||||||
|
|
||||||
end FontMgr;
|
end FontMgr;
|
||||||
|
@ -18,417 +18,564 @@
|
|||||||
// and conditions governing the rights and limitations under the License.
|
// and conditions governing the rights and limitations under the License.
|
||||||
|
|
||||||
#include <Font_FontMgr.ixx>
|
#include <Font_FontMgr.ixx>
|
||||||
#ifdef WNT
|
|
||||||
# include <windows.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
#else //WNT
|
|
||||||
# include <dirent.h>
|
|
||||||
# include <X11/Xlib.h>
|
|
||||||
#endif //WNT
|
|
||||||
|
|
||||||
#include <OSD_Environment.hxx>
|
#include <OSD_Environment.hxx>
|
||||||
#include <NCollection_List.hxx>
|
#include <NCollection_List.hxx>
|
||||||
#include <TCollection_HAsciiString.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
#include <Standard_Stream.hxx>
|
#include <Standard_Stream.hxx>
|
||||||
|
#include <TCollection_HAsciiString.hxx>
|
||||||
|
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
#ifndef WNT
|
struct Font_FontMgr_FontAliasMapNode
|
||||||
#include <TCollection_AsciiString.hxx>
|
{
|
||||||
|
const char * EnumName;
|
||||||
|
const char * FontName;
|
||||||
|
Font_FontAspect FontAspect;
|
||||||
|
};
|
||||||
|
|
||||||
#include <NCollection_DefineList.hxx>
|
static const Font_FontMgr_FontAliasMapNode Font_FontMgr_MapOfFontsAliases[] =
|
||||||
#include <NCollection_List.hxx>
|
{
|
||||||
|
|
||||||
#include <OSD_Path.hxx>
|
#ifdef WNT
|
||||||
#include <OSD_FileIterator.hxx>
|
|
||||||
#include <OSD_DirectoryIterator.hxx>
|
|
||||||
#include <OSD_File.hxx>
|
|
||||||
#include <OSD_FileNode.hxx>
|
|
||||||
#include <OSD_OpenMode.hxx>
|
|
||||||
#include <OSD_Protection.hxx>
|
|
||||||
#include <Font_NListOfSystemFont.hxx>
|
|
||||||
|
|
||||||
const Standard_Integer font_service_conf_size = 3;
|
{ "Courier" , "Courier New" , Font_FA_Regular },
|
||||||
static Standard_Character font_service_conf[font_service_conf_size][64] = { {"/etc/X11/fs/config"},
|
{ "Times-Roman" , "Times New Roman", Font_FA_Regular },
|
||||||
{"/usr/X11R6/lib/X11/fs/config"},
|
{ "Times-Bold" , "Times New Roman", Font_FA_Bold },
|
||||||
{"/usr/X11/lib/X11/fs/config"}
|
{ "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" , 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
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NUM_FONT_ENTRIES (sizeof(Font_FontMgr_MapOfFontsAliases)/sizeof(Font_FontMgr_FontAliasMapNode))
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__))
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma comment (lib, "freetype.lib")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
// list of supported extensions
|
||||||
|
static Standard_CString Font_FontMgr_Extensions[] =
|
||||||
|
{
|
||||||
|
"ttf",
|
||||||
|
"otf",
|
||||||
|
"ttc",
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_LIST( StringList, NCollection_List, TCollection_HAsciiString );
|
};
|
||||||
|
|
||||||
void find_path_with_font_dir( const TCollection_AsciiString& dir,StringList& dirs )
|
#else
|
||||||
|
|
||||||
|
#include <OSD_DirectoryIterator.hxx>
|
||||||
|
#include <OSD_Path.hxx>
|
||||||
|
#include <OSD_File.hxx>
|
||||||
|
#include <OSD_OpenMode.hxx>
|
||||||
|
#include <OSD_Protection.hxx>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
// list of supported extensions
|
||||||
|
static Standard_CString Font_FontMgr_Extensions[] =
|
||||||
|
{
|
||||||
|
"ttf",
|
||||||
|
"otf",
|
||||||
|
"ttc",
|
||||||
|
"pfa",
|
||||||
|
"pfb",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
// X11 configuration file in plain text format (obsolete - doesn't exists in modern distributives)
|
||||||
|
static Standard_CString myFontServiceConf[] = {"/etc/X11/fs/config",
|
||||||
|
"/usr/X11R6/lib/X11/fs/config",
|
||||||
|
"/usr/X11/lib/X11/fs/config",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
// default fonts paths in Mac OS X
|
||||||
|
static Standard_CString myDefaultFontsDirs[] = {"/System/Library/Fonts",
|
||||||
|
"/Library/Fonts",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
// default fonts paths in most Unix systems (Linux and others)
|
||||||
|
static Standard_CString myDefaultFontsDirs[] = {"/usr/share/fonts",
|
||||||
|
"/usr/local/share/fonts",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void addDirsRecursively (const OSD_Path& thePath,
|
||||||
|
NCollection_Map<TCollection_AsciiString>& theDirsMap)
|
||||||
|
{
|
||||||
|
TCollection_AsciiString aDirName;
|
||||||
|
thePath.SystemName (aDirName);
|
||||||
|
if (!theDirsMap.Add (aDirName))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (OSD_DirectoryIterator aDirIterator (thePath, "*"); aDirIterator.More(); aDirIterator.Next())
|
||||||
|
{
|
||||||
|
OSD_Path aChildDirPath;
|
||||||
|
aDirIterator.Values().Path (aChildDirPath);
|
||||||
|
|
||||||
|
TCollection_AsciiString aChildDirName;
|
||||||
|
aChildDirPath.SystemName (aChildDirName);
|
||||||
|
if (!aChildDirName.IsEqual (".") && !aChildDirName.IsEqual (".."))
|
||||||
|
{
|
||||||
|
aChildDirName = aDirName + "/" + aChildDirName;
|
||||||
|
OSD_Path aPath (aChildDirName);
|
||||||
|
addDirsRecursively (aPath, theDirsMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : checkFont
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
static Handle(Font_SystemFont) checkFont (FT_Library theFTLib,
|
||||||
|
const Standard_CString theFontPath)
|
||||||
{
|
{
|
||||||
if( !dir.IsEmpty() )
|
FT_Face aFontFace;
|
||||||
|
FT_Error aFaceError = FT_New_Face (theFTLib, theFontPath, 0, &aFontFace);
|
||||||
|
if (aFaceError != FT_Err_Ok)
|
||||||
{
|
{
|
||||||
TCollection_AsciiString PathName( dir );
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Integer rem = PathName.Length();
|
Font_FontAspect anAspect = Font_FA_Regular;
|
||||||
|
if (aFontFace->style_flags == (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD))
|
||||||
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()) ) {
|
anAspect = Font_FA_BoldItalic;
|
||||||
need_to_append = Standard_False;
|
}
|
||||||
break;
|
else if (aFontFace->style_flags == FT_STYLE_FLAG_ITALIC)
|
||||||
|
{
|
||||||
|
anAspect = Font_FA_Italic;
|
||||||
|
}
|
||||||
|
else if (aFontFace->style_flags == FT_STYLE_FLAG_BOLD)
|
||||||
|
{
|
||||||
|
anAspect = Font_FA_Bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name);
|
||||||
|
Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath);
|
||||||
|
Handle(Font_SystemFont) aResult = new Font_SystemFont (aFontName, anAspect, aFontPath);
|
||||||
|
|
||||||
|
FT_Done_Face (aFontFace);
|
||||||
|
|
||||||
|
return aResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : GetInstance
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Handle(Font_FontMgr) Font_FontMgr::GetInstance()
|
||||||
|
{
|
||||||
|
static Handle(Font_FontMgr) _mgr;
|
||||||
|
if (_mgr.IsNull())
|
||||||
|
{
|
||||||
|
_mgr = new Font_FontMgr();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _mgr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : Font_FontMgr
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
Font_FontMgr::Font_FontMgr()
|
||||||
|
{
|
||||||
|
InitFontDataBase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
// function : InitFontDataBase
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
void Font_FontMgr::InitFontDataBase()
|
||||||
|
{
|
||||||
|
myListOfFonts.Clear();
|
||||||
|
FT_Library aFtLibrary = NULL;
|
||||||
|
|
||||||
|
#if (defined(_WIN32) || defined(__WIN32__))
|
||||||
|
|
||||||
|
// font directory is placed in "C:\Windows\Fonts\"
|
||||||
|
UINT aStrLength = GetSystemWindowsDirectoryA (NULL, 0);
|
||||||
|
if (aStrLength == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* aWinDir = new char[aStrLength];
|
||||||
|
GetSystemWindowsDirectoryA (aWinDir, aStrLength);
|
||||||
|
Handle(TCollection_HAsciiString) aFontsDir = new TCollection_HAsciiString (aWinDir);
|
||||||
|
aFontsDir->AssignCat ("\\Fonts\\");
|
||||||
|
delete[] aWinDir;
|
||||||
|
|
||||||
|
// read fonts list from registry
|
||||||
|
HKEY aFontsKey;
|
||||||
|
if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
|
||||||
|
0, KEY_READ, &aFontsKey) != ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NCollection_Map<TCollection_AsciiString> aSupportedExtensions;
|
||||||
|
for (Standard_Integer anIter = 0; Font_FontMgr_Extensions[anIter] != NULL; ++anIter)
|
||||||
|
{
|
||||||
|
Standard_CString anExt = Font_FontMgr_Extensions[anIter];
|
||||||
|
aSupportedExtensions.Add (TCollection_AsciiString (anExt));
|
||||||
|
}
|
||||||
|
|
||||||
|
FT_Init_FreeType (&aFtLibrary);
|
||||||
|
static const DWORD aBufferSize = 256;
|
||||||
|
char aNameBuff[aBufferSize];
|
||||||
|
char aPathBuff[aBufferSize];
|
||||||
|
DWORD aNameSize = aBufferSize;
|
||||||
|
DWORD aPathSize = aBufferSize;
|
||||||
|
for (DWORD anIter = 0;
|
||||||
|
RegEnumValueA (aFontsKey, anIter,
|
||||||
|
aNameBuff, &aNameSize, NULL, NULL,
|
||||||
|
(LPBYTE )aPathBuff, &aPathSize) != ERROR_NO_MORE_ITEMS;
|
||||||
|
++anIter, aNameSize = aBufferSize, aPathSize = aBufferSize)
|
||||||
|
{
|
||||||
|
aPathBuff[(aPathSize < aBufferSize) ? aPathSize : (aBufferSize - 1)] = '\0'; // ensure string is NULL-terminated
|
||||||
|
|
||||||
|
Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aNameBuff);
|
||||||
|
Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (aPathBuff);
|
||||||
|
if (aFontPath->Search ("\\") == -1)
|
||||||
|
{
|
||||||
|
aFontPath->Insert (1, aFontsDir); // make absolute path
|
||||||
|
}
|
||||||
|
|
||||||
|
// check file extension is in list of supported
|
||||||
|
const Standard_Integer anExtensionPosition = aFontPath->SearchFromEnd (".") + 1;
|
||||||
|
if (anExtensionPosition > 0 && anExtensionPosition < aFontPath->Length())
|
||||||
|
{
|
||||||
|
Handle(TCollection_HAsciiString) aFontExtension = aFontPath->SubString (anExtensionPosition, aFontPath->Length());
|
||||||
|
aFontExtension->LowerCase();
|
||||||
|
if (aSupportedExtensions.Contains (aFontExtension->String()))
|
||||||
|
{
|
||||||
|
Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath->ToCString());
|
||||||
|
if (!aNewFont.IsNull())
|
||||||
|
{
|
||||||
|
myListOfFonts.Append (aNewFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( need_to_append )
|
|
||||||
dirs.Append( PathName );
|
|
||||||
|
|
||||||
OSD_DirectoryIterator osd_dir(PathName,"*");
|
// close registry key
|
||||||
while(osd_dir.More())
|
RegCloseKey (aFontsKey);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NCollection_Map<TCollection_AsciiString> aMapOfFontsDirs;
|
||||||
|
const OSD_Protection aProtectRead (OSD_R, OSD_R, OSD_R, OSD_R);
|
||||||
|
|
||||||
|
// read fonts directories from font service config file (obsolete)
|
||||||
|
for (Standard_Integer anIter = 0; myFontServiceConf[anIter] != NULL; ++anIter)
|
||||||
{
|
{
|
||||||
OSD_Path path_file;
|
const TCollection_AsciiString aFileOfFontsPath (myFontServiceConf[anIter]);
|
||||||
osd_dir.Values().Path( path_file );
|
OSD_File aFile (aFileOfFontsPath);
|
||||||
if( path_file.Name().Length() < 1 )
|
if (!aFile.Exists())
|
||||||
{
|
{
|
||||||
osd_dir.Next();
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TCollection_AsciiString full_path_name = PathName + "/" + path_file.Name();
|
aFile.Open (OSD_ReadOnly, aProtectRead);
|
||||||
rem = full_path_name.Length();
|
if (!aFile.IsOpen())
|
||||||
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;
|
continue;
|
||||||
}
|
|
||||||
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 aNByte = 256;
|
||||||
Standard_Integer aNbyteRead;
|
Standard_Integer aNbyteRead;
|
||||||
TCollection_AsciiString aStr( aNByte );//read string with information
|
TCollection_AsciiString aStr; // read string with information
|
||||||
TCollection_AsciiString aStrCut( aNByte );//cut of string
|
while (!aFile.IsAtEnd())
|
||||||
TCollection_AsciiString endStr;//cutting string
|
{
|
||||||
|
Standard_Integer aLocation = -1;
|
||||||
|
Standard_Integer aPathLocation = -1;
|
||||||
|
|
||||||
Standard_Boolean read_dirs = Standard_False;
|
aFile.ReadLine (aStr, aNByte, aNbyteRead); // reading 1 line (256 bytes)
|
||||||
Standard_Integer location =- 1; //disposition of necessary literals
|
aLocation = aStr.Search ("catalogue=");
|
||||||
Standard_Integer begin =- 1; //first left entry in string
|
if (aLocation < 0)
|
||||||
Standard_Integer end =- 1; //first right entry in string
|
|
||||||
while( !aFile.IsAtEnd() )
|
|
||||||
{
|
{
|
||||||
aFile.ReadLine( aStr, aNByte, aNbyteRead );//reading 1 lines(256 bytes)
|
aLocation = aStr.Search ("catalogue =");
|
||||||
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 )
|
aPathLocation = aStr.Search ("/");
|
||||||
|
if (aLocation > 0 && aPathLocation > 0)
|
||||||
{
|
{
|
||||||
begin = aStr.Location( "/", 1, aStr.Length() );//begin of path name
|
aStr = aStr.Split (aPathLocation - 1);
|
||||||
end = aStr.Location( ":", 1, aStr.Length() );//end of path name
|
TCollection_AsciiString aFontPath;
|
||||||
if( end < 1 )
|
Standard_Integer aPathNumber = 1;
|
||||||
end = aStr.Location( ",", 1, aStr.Length() );//also end of path name
|
do
|
||||||
end -= 1;
|
|
||||||
if( begin > 0 && end > 0 )
|
|
||||||
{
|
{
|
||||||
if( ( end - begin ) > 0 )
|
// Getting directory paths, which can be splitted by "," or ":"
|
||||||
endStr.AssignCat( aStr.SubString ( begin, end ) );//cutting necessary literals for string
|
aFontPath = aStr.Token (":,", aPathNumber);
|
||||||
dirs.Append( TCollection_HAsciiString ( endStr ) );
|
aFontPath.RightAdjust();
|
||||||
endStr.Clear();
|
if (!aFontPath.IsEmpty())
|
||||||
}
|
|
||||||
else
|
|
||||||
if( begin > 0 && end == -1 )
|
|
||||||
{
|
{
|
||||||
//if end of string don't have "," or ":"
|
OSD_Path aPath(aFontPath);
|
||||||
//it is possible last sentence in block of word
|
addDirsRecursively (aPath, aMapOfFontsDirs);
|
||||||
endStr.AssignCat( aStr.SubString( begin, aStr.Length() - 1 ) );
|
|
||||||
dirs.Append( TCollection_HAsciiString( endStr ) );
|
|
||||||
endStr.Clear();
|
|
||||||
}
|
}
|
||||||
|
aPathNumber++;
|
||||||
|
}
|
||||||
|
while (!aFontPath.IsEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
aFile.Close();
|
aFile.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// append default directories
|
||||||
|
for (Standard_Integer anIter = 0; myDefaultFontsDirs[anIter] != NULL; ++anIter)
|
||||||
|
{
|
||||||
|
Standard_CString anItem = myDefaultFontsDirs[anIter];
|
||||||
|
TCollection_AsciiString aPathStr (anItem);
|
||||||
|
OSD_Path aPath (aPathStr);
|
||||||
|
addDirsRecursively (aPath, aMapOfFontsDirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( dirs.Size() > 0 )
|
NCollection_Map<TCollection_AsciiString> aSupportedExtensions;
|
||||||
|
for (Standard_Integer anIter = 0; Font_FontMgr_Extensions[anIter] != NULL; ++anIter)
|
||||||
{
|
{
|
||||||
//if dirs list contains elements
|
Standard_CString anExt = Font_FontMgr_Extensions[anIter];
|
||||||
OSD_OpenMode aModeRead = OSD_ReadOnly;
|
aSupportedExtensions.Add (TCollection_AsciiString (anExt));
|
||||||
OSD_Protection aProtectRead( OSD_R, OSD_R , OSD_R , OSD_R );
|
}
|
||||||
|
|
||||||
TCollection_AsciiString fileFontsDir;
|
FT_Init_FreeType (&aFtLibrary);
|
||||||
StringList::Iterator it( dirs );
|
for (NCollection_Map<TCollection_AsciiString>::Iterator anIter (aMapOfFontsDirs);
|
||||||
for( ; it.More(); it.Next() )
|
anIter.More(); anIter.Next())
|
||||||
{
|
{
|
||||||
fileFontsDir.AssignCat( it.Value().ToCString() );
|
OSD_File aReadFile (anIter.Value() + "/fonts.dir");
|
||||||
fileFontsDir.AssignCat( "/fonts.dir" );//append file name in path way
|
if (!aReadFile.Exists())
|
||||||
|
{
|
||||||
|
continue; // invalid fonts directory
|
||||||
|
}
|
||||||
|
|
||||||
OSD_File readFile( fileFontsDir );
|
aReadFile.Open (OSD_ReadOnly, aProtectRead);
|
||||||
readFile.Open( aModeRead, aProtectRead );
|
if (!aReadFile.IsOpen())
|
||||||
|
{
|
||||||
|
continue; // invalid fonts directory
|
||||||
|
}
|
||||||
|
|
||||||
Standard_Integer aNbyteRead, aNByte = 256;
|
Standard_Integer aNbyteRead, aNByte = 256;
|
||||||
if( readFile.IsOpen ( ) )
|
TCollection_AsciiString aLine (aNByte);
|
||||||
|
Standard_Boolean isFirstLine = Standard_True;
|
||||||
|
const TCollection_AsciiString anEncoding ("iso8859-1\n");
|
||||||
|
while (!aReadFile.IsAtEnd())
|
||||||
{
|
{
|
||||||
TCollection_AsciiString aLine( aNByte );
|
aReadFile.ReadLine (aLine, aNByte, aNbyteRead);
|
||||||
Standard_Integer countOfString = 0 ;
|
if (isFirstLine)
|
||||||
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 ) )
|
|
||||||
{
|
{
|
||||||
|
// first line contains the number of fonts in this file
|
||||||
|
// just ignoring it...
|
||||||
|
isFirstLine = Standard_False;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer anExtensionPosition = aLine.Search (".") + 1;
|
||||||
|
if (anExtensionPosition == 0)
|
||||||
|
{
|
||||||
|
continue; // can't find extension position in the font description
|
||||||
|
}
|
||||||
|
|
||||||
|
Standard_Integer anEndOfFileName = aLine.Location (" ", anExtensionPosition, aLine.Length()) - 1;
|
||||||
|
if (anEndOfFileName < 0 || anEndOfFileName < anExtensionPosition)
|
||||||
|
{
|
||||||
|
continue; // font description have empty extension
|
||||||
|
}
|
||||||
|
|
||||||
|
TCollection_AsciiString aFontExtension = aLine.SubString (anExtensionPosition, anEndOfFileName);
|
||||||
|
aFontExtension.LowerCase();
|
||||||
|
if (aSupportedExtensions.Contains (aFontExtension) && (aLine.Search (anEncoding) > 0))
|
||||||
|
{
|
||||||
// In current implementation use fonts with ISO-8859-1 coding page.
|
// In current implementation use fonts with ISO-8859-1 coding page.
|
||||||
// OCCT not give to manage coding page by means of programm interface.
|
// OCCT not give to manage coding page by means of programm interface.
|
||||||
// TODO: make high level interface for
|
// TODO: make high level interface for choosing necessary coding page.
|
||||||
// choosing necessary coding page.
|
Handle(TCollection_HAsciiString) aXLFD =
|
||||||
TCollection_AsciiString aXLFD;
|
new TCollection_HAsciiString (aLine.SubString (anEndOfFileName + 2, aLine.Length()));
|
||||||
Standard_Integer leftXLFD = aLine.SearchFromEnd(" ");
|
Handle(TCollection_HAsciiString) aFontPath =
|
||||||
Standard_Integer rightXLFD = aLine.Length();
|
new TCollection_HAsciiString (anIter.Value().ToCString());
|
||||||
if( leftXLFD && rightXLFD )
|
if (aFontPath->SearchFromEnd ("/") != aFontPath->Length())
|
||||||
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
|
aFontPath->AssignCat ("/");
|
||||||
aPath.AssignCat( aTemp.ToCString() );
|
|
||||||
aPath.AssignCat( aLine.Token( " ", 1 ) );
|
|
||||||
}
|
}
|
||||||
else {
|
Handle(TCollection_HAsciiString) aFontFileName =
|
||||||
//this branch intend to Linux
|
new TCollection_HAsciiString (aLine.SubString (1, anEndOfFileName));
|
||||||
aPath.AssignCat( aTemp.ToCString( ) );
|
aFontPath->AssignCat (aFontFileName);
|
||||||
aPath.AssignCat( "/" );
|
|
||||||
aPath.AssignCat( aLine.Token( " ", 1 ) );
|
Handle(Font_SystemFont) aNewFontFromXLFD = new Font_SystemFont (aXLFD, aFontPath);
|
||||||
|
Handle(Font_SystemFont) aNewFont = checkFont (aFtLibrary, aFontPath->ToCString());
|
||||||
|
|
||||||
|
if (aNewFontFromXLFD->IsValid() && !aNewFont.IsNull() &&
|
||||||
|
!aNewFont->IsEqual (aNewFontFromXLFD))
|
||||||
|
{
|
||||||
|
myListOfFonts.Append (aNewFont);
|
||||||
|
myListOfFonts.Append (aNewFontFromXLFD);
|
||||||
}
|
}
|
||||||
MyListOfFonts.Append( new Font_SystemFont( new TCollection_HAsciiString( aXLFD ),
|
else if (!aNewFont.IsNull())
|
||||||
new TCollection_HAsciiString( aPath ) ) );
|
{
|
||||||
|
myListOfFonts.Append (aNewFont);
|
||||||
|
}
|
||||||
|
else if (aNewFontFromXLFD->IsValid())
|
||||||
|
{
|
||||||
|
myListOfFonts.Append (aNewFontFromXLFD);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
readFile.ReadLine( aLine, aNByte, aNbyteRead );
|
|
||||||
countOfString++;
|
|
||||||
}
|
|
||||||
readFile.Close();
|
|
||||||
}
|
|
||||||
fileFontsDir.Clear();
|
|
||||||
}
|
}
|
||||||
|
aReadFile.Close();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
FT_Done_FreeType (aFtLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
Font_NListOfSystemFont Font_FontMgr::GetAvalableFonts() const
|
// =======================================================================
|
||||||
|
// function : GetAvailableFonts
|
||||||
|
// purpose :
|
||||||
|
// =======================================================================
|
||||||
|
const Font_NListOfSystemFont& Font_FontMgr::GetAvailableFonts() const
|
||||||
{
|
{
|
||||||
return MyListOfFonts;
|
return myListOfFonts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Font_FontMgr::GetAvailableFontsNames (TColStd_SequenceOfHAsciiString& theFontsNames) const
|
||||||
|
{
|
||||||
|
theFontsNames.Clear();
|
||||||
|
for (Font_NListOfSystemFont::Iterator anIter(myListOfFonts); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
theFontsNames.Append (anIter.Value()->FontName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(Font_SystemFont) Font_FontMgr::GetFont (const Handle(TCollection_HAsciiString)& theFontName,
|
||||||
|
const Font_FontAspect theFontAspect,
|
||||||
|
const Standard_Integer theFontSize) const
|
||||||
|
{
|
||||||
|
if ( (theFontSize < 2 && theFontSize != -1) || theFontName.IsNull())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Font_NListOfSystemFont::Iterator aFontsIterator (myListOfFonts);
|
||||||
|
|
||||||
|
for (; aFontsIterator.More(); aFontsIterator.Next())
|
||||||
|
{
|
||||||
|
if (!theFontName->IsEmpty() && !aFontsIterator.Value()->FontName()->IsSameString (theFontName, Standard_False))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theFontAspect != Font_FA_Undefined && aFontsIterator.Value()->FontAspect() != theFontAspect)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (theFontSize == -1 || aFontsIterator.Value()->FontHeight() == -1 ||
|
||||||
|
theFontSize == aFontsIterator.Value()->FontHeight())
|
||||||
|
{
|
||||||
|
return aFontsIterator.Value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(Font_SystemFont) Font_FontMgr::FindFont (const Handle(TCollection_HAsciiString)& theFontName,
|
||||||
|
const Font_FontAspect theFontAspect,
|
||||||
|
const Standard_Integer theFontSize) const
|
||||||
|
{
|
||||||
|
Handle(TCollection_HAsciiString) aFontName = theFontName;
|
||||||
|
Font_FontAspect aFontAspect = theFontAspect;
|
||||||
|
Standard_Integer aFontSize = theFontSize;
|
||||||
|
|
||||||
|
Handle(Font_SystemFont) aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||||
|
|
||||||
|
if (!aFont.IsNull())
|
||||||
|
{
|
||||||
|
return aFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Trying to use font names mapping
|
||||||
|
for (Standard_Integer anIter = 0; anIter < NUM_FONT_ENTRIES; ++anIter)
|
||||||
|
{
|
||||||
|
Handle(TCollection_HAsciiString) aFontAlias =
|
||||||
|
new TCollection_HAsciiString (Font_FontMgr_MapOfFontsAliases[anIter].EnumName);
|
||||||
|
|
||||||
|
if (aFontAlias->IsSameString (aFontName, Standard_False))
|
||||||
|
{
|
||||||
|
aFontName = new TCollection_HAsciiString (Font_FontMgr_MapOfFontsAliases[anIter].FontName);
|
||||||
|
aFontAspect = Font_FontMgr_MapOfFontsAliases[anIter].FontAspect;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||||
|
|
||||||
|
if (!aFont.IsNull())
|
||||||
|
{
|
||||||
|
return aFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Requested family name not found -> search for any font family with given aspect and height
|
||||||
|
aFontName = new TCollection_HAsciiString ("");
|
||||||
|
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||||
|
|
||||||
|
if (!aFont.IsNull())
|
||||||
|
{
|
||||||
|
return aFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The last resort: trying to use ANY font available in the system
|
||||||
|
aFontAspect = Font_FA_Undefined;
|
||||||
|
aFontSize = -1;
|
||||||
|
aFont = GetFont (aFontName, aFontAspect, aFontSize);
|
||||||
|
|
||||||
|
if (!aFont.IsNull())
|
||||||
|
{
|
||||||
|
return aFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL; // Fonts are not found in the system.
|
||||||
|
}
|
||||||
|
@ -23,4 +23,10 @@
|
|||||||
DEFINE_LIST (Font_NListOfSystemFont,
|
DEFINE_LIST (Font_NListOfSystemFont,
|
||||||
NCollection_List,
|
NCollection_List,
|
||||||
Handle(Font_SystemFont))
|
Handle(Font_SystemFont))
|
||||||
|
|
||||||
|
inline Standard_Boolean IsEqual (const Handle(Font_SystemFont)& theFirstFont,
|
||||||
|
const Handle(Font_SystemFont)& theSecondFont)
|
||||||
|
{
|
||||||
|
return theFirstFont->IsEqual (theSecondFont);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
34
src/Graphic3d/Graphic3d_NameOfFont.hxx → src/Font/Font_NameOfFont.hxx
Executable file → Normal file
34
src/Graphic3d/Graphic3d_NameOfFont.hxx → src/Font/Font_NameOfFont.hxx
Executable file → Normal file
@ -19,20 +19,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define Graphic3d_NOF_ASCII_MONO "Courier"
|
#define Font_NOF_ASCII_MONO "Courier"
|
||||||
#define Graphic3d_NOF_ASCII_SIMPLEX "Times-Roman"
|
#define Font_NOF_ASCII_SIMPLEX "Times-Roman"
|
||||||
#define Graphic3d_NOF_ASCII_COMPLEX "Times-Roman"
|
#define Font_NOF_ASCII_COMPLEX "Times-Roman"
|
||||||
#define Graphic3d_NOF_ASCII_DUPLEX "Times-Bold"
|
#define Font_NOF_ASCII_DUPLEX "Times-Bold"
|
||||||
#define Graphic3d_NOF_ASCII_TRIPLEX "Times-Bold"
|
#define Font_NOF_ASCII_TRIPLEX "Times-Bold"
|
||||||
#define Graphic3d_NOF_ASCII_ITALIC_COMPLEX "Times-Italic"
|
#define Font_NOF_ASCII_ITALIC_COMPLEX "Times-Italic"
|
||||||
#define Graphic3d_NOF_ASCII_ITALIC_TRIPLEX "Times-BoldItalic"
|
#define Font_NOF_ASCII_ITALIC_TRIPLEX "Times-BoldItalic"
|
||||||
#define Graphic3d_NOF_ASCII_SCRIPT_SIMPLEX "ZapfChancery-MediumItalic"
|
#define Font_NOF_ASCII_SCRIPT_SIMPLEX "ZapfChancery-MediumItalic"
|
||||||
#define Graphic3d_NOF_ASCII_SCRIPT_COMPLEX "ZapfChancery-MediumItalic"
|
#define Font_NOF_ASCII_SCRIPT_COMPLEX "ZapfChancery-MediumItalic"
|
||||||
#define Graphic3d_NOF_GREEK_MONO "Symbol"
|
#define Font_NOF_GREEK_MONO "Symbol"
|
||||||
#define Graphic3d_NOF_GREEK_SIMPLEX "Symbol"
|
#define Font_NOF_GREEK_SIMPLEX "Symbol"
|
||||||
#define Graphic3d_NOF_GREEK_COMPLEX "Symbol"
|
#define Font_NOF_GREEK_COMPLEX "Symbol"
|
||||||
#define Graphic3d_NOF_SYMBOL_MONO "ZapfDingbats"
|
#define Font_NOF_SYMBOL_MONO "ZapfDingbats"
|
||||||
#define Graphic3d_NOF_SYMBOL_SIMPLEX "ZapfDingbats"
|
#define Font_NOF_SYMBOL_SIMPLEX "ZapfDingbats"
|
||||||
#define Graphic3d_NOF_CARTOGRAPHIC_SIMPLEX "Rock"
|
#define Font_NOF_CARTOGRAPHIC_SIMPLEX "Rock"
|
||||||
#define Graphic3d_NOF_KANJI_MONO "Iris"
|
#define Font_NOF_KANJI_MONO "Iris"
|
||||||
#define Graphic3d_NOF_KATAKANA_MONO "Iris"
|
#define Font_NOF_KATAKANA_MONO "Iris"
|
@ -28,16 +28,17 @@ is
|
|||||||
---Purpose: Creates empty font object
|
---Purpose: Creates empty font object
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Create (FontName : HAsciiString;
|
Create (theFontName : HAsciiString;
|
||||||
Aspect : FontAspect;
|
theFontAspect : FontAspect;
|
||||||
FilePath : HAsciiString ) returns SystemFont;
|
theFilePath : HAsciiString ) returns SystemFont;
|
||||||
---Purpose: Creates Font object initialized with <FontName> as name
|
---Purpose: Creates Font object initialized with <FontName> as name
|
||||||
--- <FontAspect>.... TODO
|
--- <FontAspect>.... TODO
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
Create (XLFD : HAsciiString;
|
Create (theXLFD : HAsciiString;
|
||||||
FilePath : HAsciiString ) returns SystemFont;
|
theFilePath : HAsciiString ) returns SystemFont;
|
||||||
---Purpose: TODO
|
---Purpose: Creates Font object and initialize class fields with
|
||||||
|
--- values taken from XLFD (X Logical Font Description)
|
||||||
---Level: Public
|
---Level: Public
|
||||||
|
|
||||||
FontName (me) returns HAsciiString;
|
FontName (me) returns HAsciiString;
|
||||||
@ -59,6 +60,11 @@ is
|
|||||||
|
|
||||||
IsValid (me) returns Boolean;
|
IsValid (me) returns Boolean;
|
||||||
|
|
||||||
|
IsEqual (me;
|
||||||
|
theOtherFont: SystemFont) returns Boolean;
|
||||||
|
--- Purpose: Return true if the FontName, FontAspect and FontSize are the same.
|
||||||
|
--- Level: Public
|
||||||
|
|
||||||
fields
|
fields
|
||||||
MyFontName: HAsciiString; --Font family name
|
MyFontName: HAsciiString; --Font family name
|
||||||
MyFontAspect: FontAspect;
|
MyFontAspect: FontAspect;
|
||||||
|
@ -45,47 +45,45 @@ MyVerification(Standard_True)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& XLFD,
|
Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
|
||||||
const Handle(TCollection_HAsciiString)& FilePath) :
|
const Handle(TCollection_HAsciiString)& theFilePath) :
|
||||||
MyFilePath(FilePath),
|
MyFilePath(theFilePath),
|
||||||
MyFontAspect(Font_FA_Undefined)
|
MyFontAspect(Font_FA_Regular)
|
||||||
{
|
{
|
||||||
MyVerification = Standard_True;
|
MyVerification = Standard_True;
|
||||||
if ( XLFD.IsNull() )
|
if (theXLFD.IsNull())
|
||||||
{
|
{
|
||||||
MyVerification=Standard_False;
|
MyVerification = Standard_False; // empty font description handler
|
||||||
printf("NULL XLFD handler \n");
|
|
||||||
}
|
}
|
||||||
if ( XLFD->IsEmpty() )
|
if (theXLFD->IsEmpty())
|
||||||
{
|
{
|
||||||
MyVerification=Standard_False;
|
MyVerification = Standard_False; // empty font description
|
||||||
printf("EMPTY XLFD handler \n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(MyVerification)
|
if (MyVerification)
|
||||||
{
|
{
|
||||||
MyFontName = XLFD->Token( "-", 2 );
|
MyFontName = theXLFD->Token ("-", 2);
|
||||||
TCollection_AsciiString str( XLFD->ToCString() );
|
TCollection_AsciiString aXLFD (theXLFD->ToCString());
|
||||||
|
|
||||||
if ( str.Search( "-0-0-0-0-" ) >=0 )
|
// Getting font size for fixed size fonts
|
||||||
MyFaceSize = -1;
|
if (aXLFD.Search ("-0-0-0-0-") >= 0)
|
||||||
|
MyFaceSize = -1; // Scalable font
|
||||||
else
|
else
|
||||||
//TODO catch exeption
|
//TODO catch exeption
|
||||||
MyFaceSize = str.Token( "-", 7 ).IntegerValue();
|
MyFaceSize = aXLFD.Token ("-", 7).IntegerValue();
|
||||||
|
|
||||||
//detect aspect
|
// Detect font aspect
|
||||||
if ( str.Token("-", 3).IsEqual( "bold" ) )
|
if (aXLFD.Token ("-", 3).IsEqual ("bold") &&
|
||||||
MyFontAspect = Font_FA_Bold;
|
(aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o")))
|
||||||
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;
|
MyFontAspect = Font_FA_BoldItalic;
|
||||||
else
|
}
|
||||||
|
else if (aXLFD.Token ("-", 3).IsEqual ("bold"))
|
||||||
|
{
|
||||||
|
MyFontAspect = Font_FA_Bold;
|
||||||
|
}
|
||||||
|
else if (aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o"))
|
||||||
|
{
|
||||||
MyFontAspect = Font_FA_Italic;
|
MyFontAspect = Font_FA_Italic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,3 +118,23 @@ Font_FontAspect Font_SystemFont::FontAspect() const{
|
|||||||
Standard_Integer Font_SystemFont::FontHeight() const {
|
Standard_Integer Font_SystemFont::FontHeight() const {
|
||||||
return MyFaceSize;
|
return MyFaceSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Standard_Boolean Font_SystemFont::IsEqual(const Handle(Font_SystemFont)& theOtherFont) const
|
||||||
|
{
|
||||||
|
if (!MyFontName->IsSameString (theOtherFont->FontName(), Standard_False))
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MyFontAspect != theOtherFont->FontAspect())
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MyFaceSize != theOtherFont->FontHeight())
|
||||||
|
{
|
||||||
|
return Standard_False;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
@ -51,6 +51,5 @@ Graphic3d_CTransPersStruct.cxx
|
|||||||
Graphic3d_NListOfHAsciiString.hxx
|
Graphic3d_NListOfHAsciiString.hxx
|
||||||
Graphic3d_AspectText3d.cxx
|
Graphic3d_AspectText3d.cxx
|
||||||
Graphic3d_WNTGraphicDevice.cxx
|
Graphic3d_WNTGraphicDevice.cxx
|
||||||
Graphic3d_NameOfFont.hxx
|
|
||||||
Graphic3d_PtrFrameBuffer.hxx
|
Graphic3d_PtrFrameBuffer.hxx
|
||||||
Graphic3d_BufferType.hxx
|
Graphic3d_BufferType.hxx
|
||||||
|
@ -72,7 +72,7 @@ is
|
|||||||
---Purpose: Creates a context table for text primitives
|
---Purpose: Creates a context table for text primitives
|
||||||
-- defined with the specified values.
|
-- defined with the specified values.
|
||||||
-- AFont may be to take means from User(example "Courier New")
|
-- AFont may be to take means from User(example "Courier New")
|
||||||
-- or Font described in OpenGl_FontName(example Graphic3d_NOF_ASCII_MONO)
|
-- or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
|
||||||
-- or use default font("Courier")
|
-- or use default font("Courier")
|
||||||
--
|
--
|
||||||
raises AspectTextDefinitionError from Graphic3d;
|
raises AspectTextDefinitionError from Graphic3d;
|
||||||
@ -104,7 +104,7 @@ is
|
|||||||
---Purpose: Modifies the font of <me>.
|
---Purpose: Modifies the font of <me>.
|
||||||
---Category: Methods to modify the class definition
|
---Category: Methods to modify the class definition
|
||||||
---AFont may be to take means from User(example "Courier New")
|
---AFont may be to take means from User(example "Courier New")
|
||||||
---or Font described in OpenGl_FontName(example Graphic3d_NOF_ASCII_MONO)
|
---or Font name defined in Font_NameOfFont(example Font_NOF_ASCII_MONO)
|
||||||
---or use default font("Courier")
|
---or use default font("Courier")
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <OSD_Environment.hxx>
|
#include <OSD_Environment.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
//-Aliases
|
//-Aliases
|
||||||
|
|
||||||
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Graphic3d_AspectText3d::Graphic3d_AspectText3d ():
|
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) {
|
MyFont (Font_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;
|
MyTextZoomable = Standard_False;
|
||||||
MyTextAngle = 0.0;
|
MyTextAngle = 0.0;
|
||||||
MyTextFontAspect = Font_FA_Regular;
|
MyTextFontAspect = Font_FA_Regular;
|
||||||
@ -98,7 +98,7 @@ MyFont(AFont), MyColor (AColor), MyFactor (AFactor), MySpace (ASpace), MyStyle (
|
|||||||
MyTextAngle = 0.0;
|
MyTextAngle = 0.0;
|
||||||
MyTextFontAspect = Font_FA_Regular;
|
MyTextFontAspect = Font_FA_Regular;
|
||||||
if(MyFont.Length() == 0)
|
if(MyFont.Length() == 0)
|
||||||
MyFont.AssignCat(Graphic3d_NOF_ASCII_MONO);
|
MyFont.AssignCat(Font_NOF_ASCII_MONO);
|
||||||
|
|
||||||
if (AFactor <= 0.0)
|
if (AFactor <= 0.0)
|
||||||
Graphic3d_AspectTextDefinitionError::Raise
|
Graphic3d_AspectTextDefinitionError::Raise
|
||||||
@ -127,7 +127,7 @@ void Graphic3d_AspectText3d::SetFont (const Standard_CString AFont) {
|
|||||||
|
|
||||||
TCollection_AsciiString aTemp("");
|
TCollection_AsciiString aTemp("");
|
||||||
if( !strlen(AFont))
|
if( !strlen(AFont))
|
||||||
aTemp.AssignCat(Graphic3d_NOF_ASCII_MONO);
|
aTemp.AssignCat(Font_NOF_ASCII_MONO);
|
||||||
else
|
else
|
||||||
aTemp.AssignCat(AFont);
|
aTemp.AssignCat(AFont);
|
||||||
MyFont = aTemp;
|
MyFont = aTemp;
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include <MeshVS_DrawerAttribute.hxx>
|
#include <MeshVS_DrawerAttribute.hxx>
|
||||||
#include <MeshVS_Buffer.hxx>
|
#include <MeshVS_Buffer.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
// Function : Constructor MeshVS_TextPrsBuilder
|
// Function : Constructor MeshVS_TextPrsBuilder
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <MeshVS_DrawerAttribute.hxx>
|
#include <MeshVS_DrawerAttribute.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
//================================================================
|
//================================================================
|
||||||
// Function : CreateAspectFillArea3d
|
// Function : CreateAspectFillArea3d
|
||||||
@ -196,10 +196,10 @@ Handle( Graphic3d_AspectText3d ) MeshVS_Tool::CreateAspectText3d
|
|||||||
Quantity_Color aTColor = Quantity_NOC_YELLOW;
|
Quantity_Color aTColor = Quantity_NOC_YELLOW;
|
||||||
Standard_Real anExpFactor = 1.0,
|
Standard_Real anExpFactor = 1.0,
|
||||||
aSpace = 0.0;
|
aSpace = 0.0;
|
||||||
Standard_CString aFont = Graphic3d_NOF_ASCII_MONO;
|
Standard_CString aFont = Font_NOF_ASCII_MONO;
|
||||||
Aspect_TypeOfStyleText aStyle = Aspect_TOST_NORMAL;
|
Aspect_TypeOfStyleText aStyle = Aspect_TOST_NORMAL;
|
||||||
Aspect_TypeOfDisplayText aDispText = Aspect_TODT_NORMAL;
|
Aspect_TypeOfDisplayText aDispText = Aspect_TODT_NORMAL;
|
||||||
TCollection_AsciiString aFontString = Graphic3d_NOF_ASCII_MONO;
|
TCollection_AsciiString aFontString = Font_NOF_ASCII_MONO;
|
||||||
Font_FontAspect aFontAspect = Font_FA_Regular;
|
Font_FontAspect aFontAspect = Font_FA_Regular;
|
||||||
Standard_Integer aStyleI = (Standard_Integer)Aspect_TOST_NORMAL;
|
Standard_Integer aStyleI = (Standard_Integer)Aspect_TOST_NORMAL;
|
||||||
Standard_Integer aDispTextI = (Standard_Integer)Aspect_TODT_NORMAL;
|
Standard_Integer aDispTextI = (Standard_Integer)Aspect_TODT_NORMAL;
|
||||||
|
@ -1 +0,0 @@
|
|||||||
CSF_MotifLibs
|
|
@ -115,7 +115,7 @@ class OpenGl_Display : public MMgt_TShared
|
|||||||
|
|
||||||
// Fonts
|
// Fonts
|
||||||
|
|
||||||
int FindFont (const char* AFontName, const Font_FontAspect AFontAspect, const int ABestSize = -1, const float AXScale = 1.F, const float AYScale = 1.F);
|
Standard_Integer FindFont (Standard_CString theFontName, const Font_FontAspect theFontAspect, const Standard_Integer theBestSize = -1, const Standard_ShortReal theXScale = 1.F, const Standard_ShortReal theYScale = 1.F);
|
||||||
|
|
||||||
void StringSize (const wchar_t *text, int &width, int &ascent, int &descent);
|
void StringSize (const wchar_t *text, int &width, int &ascent, int &descent);
|
||||||
|
|
||||||
|
@ -41,48 +41,6 @@
|
|||||||
* Prototypes variables statiques
|
* Prototypes variables statiques
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct FontMapNode
|
|
||||||
{
|
|
||||||
const char * EnumName;
|
|
||||||
const char * FontName;
|
|
||||||
Font_FontAspect FontAspect;
|
|
||||||
};
|
|
||||||
|
|
||||||
static const FontMapNode myFontMap[] =
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef WNT
|
|
||||||
|
|
||||||
{ "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" , 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
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NUM_FONT_ENTRIES (sizeof(myFontMap)/sizeof(FontMapNode))
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -154,51 +112,25 @@ void OpenGl_Display::getGL2PSFontName (const char *src_font, char *ps_font)
|
|||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int OpenGl_Display::FindFont (const char* AFontName, const Font_FontAspect AFontAspect,
|
Standard_Integer OpenGl_Display::FindFont (Standard_CString theFontName,
|
||||||
const int ABestSize, const float AXScale, const float AYScale)
|
const Font_FontAspect theFontAspect,
|
||||||
|
const Standard_Integer theBestSize,
|
||||||
|
const Standard_ShortReal theXScale,
|
||||||
|
const Standard_ShortReal theYScale)
|
||||||
{
|
{
|
||||||
if (!AFontName)
|
if (!theFontName)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ABestSize != -1)
|
if (theBestSize != -1)
|
||||||
myFontSize = ABestSize;
|
myFontSize = theBestSize;
|
||||||
|
|
||||||
OpenGl_FontMgr* mgr = OpenGl_FontMgr::instance();
|
OpenGl_FontMgr* anOpenGlFontMgr = OpenGl_FontMgr::instance();
|
||||||
|
|
||||||
Handle(TCollection_HAsciiString) family_name = new TCollection_HAsciiString(AFontName);
|
Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (theFontName);
|
||||||
myFont = mgr->request_font( family_name, AFontAspect, myFontSize );
|
myFont = anOpenGlFontMgr->request_font (aFontName, theFontAspect, myFontSize);
|
||||||
|
|
||||||
if( myFont == -1 )
|
if (myFont != -1)
|
||||||
{
|
anOpenGlFontMgr->setCurrentScale (theXScale, theYScale);
|
||||||
//try to use font names mapping
|
|
||||||
FontMapNode newTempFont = myFontMap[0];
|
|
||||||
for ( int i = 0; i < NUM_FONT_ENTRIES; ++i )
|
|
||||||
{
|
|
||||||
if ( TCollection_AsciiString(myFontMap[i].EnumName).IsEqual( family_name->ToCString() ) )
|
|
||||||
{
|
|
||||||
newTempFont = myFontMap[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
family_name = new TCollection_HAsciiString(newTempFont.FontName);
|
|
||||||
myFont = mgr->request_font( family_name, newTempFont.FontAspect, myFontSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Requested family name not found -> serach for any font family with given aspect and height
|
|
||||||
if ( myFont == -1 )
|
|
||||||
{
|
|
||||||
family_name = new TCollection_HAsciiString( "" );
|
|
||||||
myFont = mgr->request_font( family_name, AFontAspect, myFontSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
// The last resort: trying to use ANY font available in the system
|
|
||||||
if ( myFont == -1 )
|
|
||||||
{
|
|
||||||
myFont = mgr->request_font( family_name, Font_FA_Undefined, -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( myFont != -1 )
|
|
||||||
mgr->setCurrentScale( AXScale, AYScale );
|
|
||||||
|
|
||||||
return myFont;
|
return myFont;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,10 @@
|
|||||||
#include <OpenGl_GlCore11.hxx>
|
#include <OpenGl_GlCore11.hxx>
|
||||||
|
|
||||||
#include <Standard_Stream.hxx>
|
#include <Standard_Stream.hxx>
|
||||||
|
#include <TColStd_SequenceOfHAsciiString.hxx>
|
||||||
#include <ft2build.h>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma comment( lib, "ftgl.lib" )
|
#pragma comment( lib, "ftgl.lib" )
|
||||||
#pragma comment( lib, "freetype.lib" )
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef TRACE
|
#undef TRACE
|
||||||
@ -62,9 +60,9 @@ IsEqual( const Handle(TCollection_HAsciiString)& h1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
OpenGl_FontMgr::OpenGl_FontMgr()
|
OpenGl_FontMgr::OpenGl_FontMgr()
|
||||||
: _CurrentFontId(-1),
|
: myCurrentFontId(-1),
|
||||||
_XCurrentScale(1.f),
|
myXCurrentScale(1.f),
|
||||||
_YCurrentScale(1.f)
|
myYCurrentScale(1.f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,282 +72,92 @@ OpenGl_FontMgr* OpenGl_FontMgr::instance()
|
|||||||
if ( _mgr == NULL )
|
if ( _mgr == NULL )
|
||||||
{
|
{
|
||||||
_mgr = new OpenGl_FontMgr();
|
_mgr = new OpenGl_FontMgr();
|
||||||
_mgr->_initializeFontDB();
|
|
||||||
}
|
}
|
||||||
return _mgr;
|
return _mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGl_FontMgr::_initializeFontDB()
|
|
||||||
{
|
|
||||||
Handle(Font_FontMgr) fntMgr = Font_FontMgr::GetInstance();
|
|
||||||
if ( !fntMgr.IsNull() ) {
|
|
||||||
|
|
||||||
Font_NListOfSystemFont fontList = fntMgr->GetAvalableFonts();
|
|
||||||
if ( fontList.Size() != 0 ) {
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
Font_NListOfSystemFont::Iterator it(fontList);
|
|
||||||
for ( ; it.More(); it.Next() ) {
|
|
||||||
OGLFont_SysInfo* info = new OGLFont_SysInfo();
|
|
||||||
if ( it.Value()->FontAspect() == Font_FA_Regular ) {
|
|
||||||
|
|
||||||
Handle(TCollection_HAsciiString) aFontPath = it.Value()->FontPath();
|
|
||||||
|
|
||||||
//this workaround for fonts with names dependent on system locale.
|
|
||||||
//for example: "Times New Roman Fett Kursive" or "Times New Roman Gras Italiqui"
|
|
||||||
FT_Face aFontFace;
|
|
||||||
FT_Error aFaceError = FT_New_Face(aFtLibrary,
|
|
||||||
aFontPath->ToCString(), 0,
|
|
||||||
&aFontFace);
|
|
||||||
|
|
||||||
if ( aFaceError == FT_Err_Ok ) {
|
|
||||||
if ( aFontFace->style_flags == 0 ) {
|
|
||||||
info->SysFont = it.Value();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//new aspect detected for current font item
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "TKOpenGl::initializeFontDB() detected new font!\n"
|
|
||||||
<< "\tFont Previous Name: " << it.Value()->FontName()->ToCString() << endl
|
|
||||||
<< "\tFont New Name: " << aFontFace->family_name << endl
|
|
||||||
<< "\tFont Aspect: " << aFontFace->style_flags << endl;
|
|
||||||
#endif
|
|
||||||
Font_FontAspect aspect = Font_FA_Regular;
|
|
||||||
if ( aFontFace->style_flags == (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD) )
|
|
||||||
aspect = Font_FA_BoldItalic;
|
|
||||||
else if ( aFontFace->style_flags == FT_STYLE_FLAG_ITALIC )
|
|
||||||
aspect = Font_FA_Italic;
|
|
||||||
else if ( aFontFace->style_flags == FT_STYLE_FLAG_BOLD )
|
|
||||||
aspect = Font_FA_Bold;
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tFont_FontAspect: " << aspect << endl;
|
|
||||||
#endif
|
|
||||||
Handle(TCollection_HAsciiString) aFontName =
|
|
||||||
new TCollection_HAsciiString( aFontFace->family_name );
|
|
||||||
info->SysFont = new Font_SystemFont( aFontName, aspect, aFontPath );
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Done_Face(aFontFace);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
info->SysFont = it.Value();
|
|
||||||
}
|
|
||||||
_FontDB.Append(info);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// finalize library instance
|
|
||||||
if ( aLibError == FT_Err_Ok )
|
|
||||||
{
|
|
||||||
FT_Done_FreeType(aFtLibrary);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
if ( !_FontDB.Size() ) {
|
|
||||||
cout << "\nTKOpenGl::initializeFontDB() FAILED!!!\n"
|
|
||||||
<< "No fonts detected in the system!\n"
|
|
||||||
<< "Text rendering in 3D viewer will not be available." << endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenGl_FontMgr::requestFontList( Graphic3d_NListOfHAsciiString& lst)
|
|
||||||
{
|
|
||||||
FontDBIt DBit(_FontDB);
|
|
||||||
lst.Clear();
|
|
||||||
for ( ; DBit.More(); DBit.Next() ) {
|
|
||||||
lst.Append( DBit.Value()->SysFont->FontName() );
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty fontName means that ANY family name can be used.
|
// Empty fontName means that ANY family name can be used.
|
||||||
// fontAspect == Font_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.
|
// fontheight == -1 means ANY font height is acceptable.
|
||||||
int OpenGl_FontMgr::request_font( const Handle(TCollection_HAsciiString)& fontName,
|
int OpenGl_FontMgr::request_font (const Handle(TCollection_HAsciiString)& theFontName,
|
||||||
const Font_FontAspect fontAspect,
|
const Font_FontAspect theFontAspect,
|
||||||
const Standard_Integer fontHeight )
|
const Standard_Integer& theFontHeight)
|
||||||
{
|
{
|
||||||
Standard_Integer aFontHeight = fontHeight;
|
Handle(Font_FontMgr) aFontMgr = Font_FontMgr::GetInstance();
|
||||||
if ( aFontHeight < 2 && aFontHeight != -1 )
|
Handle(Font_SystemFont) aRequestedFont = aFontMgr->FindFont (theFontName, theFontAspect, theFontHeight);
|
||||||
|
|
||||||
|
if (aRequestedFont.IsNull())
|
||||||
{
|
{
|
||||||
#ifdef TRACE
|
|
||||||
cout << "TKOpenGl::request_font\n"
|
|
||||||
<< " Error: font height is invalid!!!\n"
|
|
||||||
<< " font height:" << aFontHeight << "\n";
|
|
||||||
#endif //TRACE
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TRACE
|
// Setting font height
|
||||||
cout << "TKOpenGl::request_font\n"
|
Standard_Integer aFontHeight = theFontHeight;
|
||||||
<< " font name: " << fontName->ToCString() << endl
|
if (theFontHeight < 2 && aRequestedFont->FontHeight() == -1)
|
||||||
<< " font aspect: " << fontAspect << endl
|
|
||||||
<< " font height: " << aFontHeight << endl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GLCONTEXT ctx = GET_GL_CONTEXT();
|
|
||||||
|
|
||||||
//check for font
|
|
||||||
FontDBIt DBit(_FontDB);
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "Searching font in font database...\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for ( ; DBit.More(); DBit.Next() ) {
|
|
||||||
// san (23.07.2010): comparing font names in case-insensitive mode,
|
|
||||||
// as on SUN and SGI system font names are in lower-case
|
|
||||||
if ( fontName->IsEmpty() || DBit.Value()->SysFont->FontName()->IsSameString(fontName, Standard_False) ) {
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tName is found...\n\tCheking aspect...\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//check for font aspect
|
|
||||||
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";
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tAspect is found...\n\tCheking height...\n";
|
|
||||||
#endif
|
|
||||||
//check for fixed height
|
|
||||||
if (DBit.Value()->SysFont->FontHeight() != -1) {
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tChecking fixed height: " << DBit.Value()->SysFont->FontHeight() << endl;
|
|
||||||
#endif
|
|
||||||
//fixed height font
|
|
||||||
if ( aFontHeight != -1 && DBit.Value()->SysFont->FontHeight() != aFontHeight ){
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tHeights are not equal! Continue seaching...\n";
|
|
||||||
#endif
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// We need to remember the font height to be used
|
// Font height is not specified -> use DEFAULT_FONT_HEIGHT for variable-height fonts
|
||||||
if ( aFontHeight == -1 )
|
|
||||||
aFontHeight = DBit.Value()->SysFont->FontHeight();
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tHeight is found\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If font height is not specified -> use DEFAULT_FONT_HEIGHT for variable-height fonts
|
|
||||||
if ( aFontHeight == -1 )
|
|
||||||
aFontHeight = DEFAULT_FONT_HEIGHT;
|
aFontHeight = DEFAULT_FONT_HEIGHT;
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tFont has variable height == -1. height is found\n";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef TRACE
|
else if (theFontHeight < 2)
|
||||||
cout << "\tChecking font manager cache...\n";
|
|
||||||
#endif
|
|
||||||
//check in loaded fonts
|
|
||||||
IDList::Iterator fIt(DBit.Value()->GeneratedFonts);
|
|
||||||
for ( ; fIt.More(); fIt.Next() ) {
|
|
||||||
OGLFont_Cache cache = _FontCache.Find( fIt.Value() );
|
|
||||||
if ( cache.FontHeight == aFontHeight && cache.GlContext == ctx ) {
|
|
||||||
//requested font is generated already
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tRequested font is generated already\n\tId = " ;
|
|
||||||
cout << fIt.Value() << endl;
|
|
||||||
#endif
|
|
||||||
_CurrentFontId = fIt.Value();
|
|
||||||
return _CurrentFontId;
|
|
||||||
} else {
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\t\tHeights or contexts are not equal:\n"
|
|
||||||
<< "\t\t\tfont height: " << aFontHeight << "\tchache height: " << cache.FontHeight << endl
|
|
||||||
<< "\t\t\tfont context: " << ctx << "\tchache context: " << cache.GlContext << endl;
|
|
||||||
cout << "\t\tContinue searching in cache...\n";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\tRequested font is not found among genarated fonts.\n\tCreating new...\n";
|
|
||||||
#endif
|
|
||||||
//if not found in generated fonts
|
|
||||||
//create new
|
|
||||||
FTGLTextureFont* font = new FTGLTextureFont(DBit.Value()->SysFont->FontPath()->ToCString());
|
|
||||||
//by default creates regular font
|
|
||||||
if ( ! font || font->Error() != FT_Err_Ok) {
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\t\tError during creation FTGL font object!\n";
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! font->FaceSize( aFontHeight) || font->Error() != FT_Err_Ok ){
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\t\tError during setup FTGL font height!\n";
|
|
||||||
#endif
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
font->UseDisplayList( false );
|
|
||||||
|
|
||||||
//put font to cache
|
|
||||||
OGLFont_Cache cache;
|
|
||||||
cache.Font = font;
|
|
||||||
cache.FontHeight = aFontHeight;
|
|
||||||
cache.GlContext = ctx;
|
|
||||||
|
|
||||||
_CurrentFontId =_FontCache.Size() + 1;
|
|
||||||
_FontCache.Bind( _CurrentFontId, cache );
|
|
||||||
DBit.Value()->GeneratedFonts.Append(_CurrentFontId);
|
|
||||||
|
|
||||||
#ifdef TRACE
|
|
||||||
cout << "TKOpenGl::Loaded New FTGL font:\n"
|
|
||||||
<< " font name: " << fontName->ToCString() << "\n"
|
|
||||||
<< " font aspect: ";
|
|
||||||
|
|
||||||
switch( fontAspect )
|
|
||||||
{
|
{
|
||||||
case Font_FA_Bold:
|
// Font height is not specified -> use font height for fixed size fonts
|
||||||
cout << "Font_FA_Bold\n";
|
aFontHeight = aRequestedFont->FontHeight();
|
||||||
break;
|
|
||||||
case Font_FA_BoldItalic:
|
|
||||||
cout << "Font_FA_BoldItalic\n";
|
|
||||||
break;
|
|
||||||
case Font_FA_Italic:
|
|
||||||
cout << "Font_FA_Italic\n";
|
|
||||||
break;
|
|
||||||
case Font_FA_Regular:
|
|
||||||
cout << "Font_FA_Regular\n";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cout << "Font_FA_Undefined\n";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
cout << " font height: "<<aFontHeight<<"\n";
|
|
||||||
cout << " font id: " << _CurrentFontId << "\n";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return _CurrentFontId;
|
GLCONTEXT aContext = GET_GL_CONTEXT();
|
||||||
|
|
||||||
|
// Check in already generated fonts.
|
||||||
|
if (myGeneratedFontDB.IsBound (aRequestedFont))
|
||||||
|
{
|
||||||
|
const IDList& anIDList = myGeneratedFontDB.Find (aRequestedFont);
|
||||||
|
for (IDList::Iterator anIDListIterator (anIDList); anIDListIterator.More();
|
||||||
|
anIDListIterator.Next())
|
||||||
|
{
|
||||||
|
OGLFont_Cache aFontCache = myGeneratedFontCache (anIDListIterator.Value());
|
||||||
|
if (aFontCache.FontHeight == aFontHeight && aFontCache.GlContext == aContext)
|
||||||
|
{
|
||||||
|
// Requested font is already generated, returning it cache ID.
|
||||||
|
myCurrentFontId = anIDListIterator.Value();
|
||||||
|
return myCurrentFontId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//invalid family name
|
}
|
||||||
#ifdef TRACE
|
|
||||||
cout << "\n---Invalid Family Name!!!---\n";
|
// Cache for requested font is not found. Generating new FTGL font.
|
||||||
#endif
|
FTGLTextureFont* aFTGLFont = new FTGLTextureFont(aRequestedFont->FontPath()->ToCString());
|
||||||
return -1;
|
if ( !aFTGLFont || aFTGLFont->Error() != FT_Err_Ok)
|
||||||
|
{
|
||||||
|
return -1; // Error during creation FTGL font object!
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !aFTGLFont->FaceSize (aFontHeight) || aFTGLFont->Error() != FT_Err_Ok )
|
||||||
|
{
|
||||||
|
return -1; // Error during setup FTGL font height!
|
||||||
|
}
|
||||||
|
|
||||||
|
aFTGLFont->UseDisplayList (false);
|
||||||
|
|
||||||
|
// Adding font to cache.
|
||||||
|
OGLFont_Cache aCache;
|
||||||
|
aCache.Font = aFTGLFont;
|
||||||
|
aCache.FontHeight = aFontHeight;
|
||||||
|
aCache.GlContext = aContext;
|
||||||
|
|
||||||
|
myCurrentFontId = myGeneratedFontCache.Size() + 1;
|
||||||
|
myGeneratedFontCache.Bind ( myCurrentFontId, aCache);
|
||||||
|
|
||||||
|
if (myGeneratedFontDB.IsBound (aRequestedFont))
|
||||||
|
{
|
||||||
|
myGeneratedFontDB.ChangeFind (aRequestedFont).Append (myCurrentFontId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IDList anIDList;
|
||||||
|
anIDList.Append (myCurrentFontId);
|
||||||
|
myGeneratedFontDB.Bind (aRequestedFont, anIDList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return myCurrentFontId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text,
|
void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text,
|
||||||
@ -360,11 +168,11 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text
|
|||||||
<< "\tfont id = " << id << endl
|
<< "\tfont id = " << id << endl
|
||||||
<< "\ttext = " << text << endl;
|
<< "\ttext = " << text << endl;
|
||||||
#endif
|
#endif
|
||||||
if ( text && _FontCache.IsBound( id ) ) {
|
if ( text && myGeneratedFontCache.IsBound( id ) ) {
|
||||||
glMatrixMode( GL_MODELVIEW );
|
glMatrixMode( GL_MODELVIEW );
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glScalef( _XCurrentScale, _YCurrentScale, 1 );
|
glScalef( myXCurrentScale, myYCurrentScale, 1 );
|
||||||
glPushAttrib( GL_ENABLE_BIT );
|
glPushAttrib( GL_ENABLE_BIT );
|
||||||
|
|
||||||
GLboolean enableTexture = glIsEnabled(GL_TEXTURE_2D);
|
GLboolean enableTexture = glIsEnabled(GL_TEXTURE_2D);
|
||||||
@ -386,7 +194,7 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text
|
|||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glAlphaFunc(GL_GEQUAL, 0.285f);
|
glAlphaFunc(GL_GEQUAL, 0.285f);
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
OGLFont_Cache cache = _FontCache.Find( id );
|
OGLFont_Cache cache = myGeneratedFontCache.Find( id );
|
||||||
cache.Font->Render( text );
|
cache.Font->Render( text );
|
||||||
|
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, param);
|
||||||
@ -405,20 +213,20 @@ void OpenGl_FontMgr::render_text( const Standard_Integer id, const wchar_t* text
|
|||||||
|
|
||||||
void OpenGl_FontMgr::render_text ( const wchar_t* text, const Standard_Boolean is2d )
|
void OpenGl_FontMgr::render_text ( const wchar_t* text, const Standard_Boolean is2d )
|
||||||
{
|
{
|
||||||
render_text( _CurrentFontId, text, is2d );
|
render_text( myCurrentFontId, text, is2d );
|
||||||
}
|
}
|
||||||
|
|
||||||
const FTFont* OpenGl_FontMgr::fontById (const Standard_Integer id)
|
const FTFont* OpenGl_FontMgr::fontById (const Standard_Integer id)
|
||||||
{
|
{
|
||||||
return _FontCache.IsBound( id ) ? _FontCache.Find( id ).Font: NULL;
|
return myGeneratedFontCache.IsBound( id ) ? myGeneratedFontCache.Find( id ).Font: NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, const wchar_t* text )
|
Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, const wchar_t* text )
|
||||||
{
|
{
|
||||||
if( !_FontCache.IsBound( id ) )
|
if( !myGeneratedFontCache.IsBound( id ) )
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
OGLFont_Cache cache = _FontCache.Find( id );
|
OGLFont_Cache cache = myGeneratedFontCache.Find( id );
|
||||||
|
|
||||||
Standard_ShortReal w = cache.Font->Advance( text );
|
Standard_ShortReal w = cache.Font->Advance( text );
|
||||||
|
|
||||||
@ -428,8 +236,8 @@ Standard_ShortReal OpenGl_FontMgr::computeWidth( const Standard_Integer id, cons
|
|||||||
void OpenGl_FontMgr::setCurrentScale (const Standard_ShortReal xScale,
|
void OpenGl_FontMgr::setCurrentScale (const Standard_ShortReal xScale,
|
||||||
const Standard_ShortReal yScale)
|
const Standard_ShortReal yScale)
|
||||||
{
|
{
|
||||||
_XCurrentScale = xScale;
|
myXCurrentScale = xScale;
|
||||||
_YCurrentScale = yScale;
|
myYCurrentScale = yScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <AlienImage_BMPAlienData.hxx>
|
#include <AlienImage_BMPAlienData.hxx>
|
||||||
|
@ -43,9 +43,9 @@ class OpenGl_FontMgr
|
|||||||
public:
|
public:
|
||||||
static OpenGl_FontMgr* instance();
|
static OpenGl_FontMgr* instance();
|
||||||
|
|
||||||
int request_font( const Handle(TCollection_HAsciiString)& fontName,
|
int request_font (const Handle(TCollection_HAsciiString)& theFontName,
|
||||||
const Font_FontAspect fontAspect,
|
const Font_FontAspect theFontAspect,
|
||||||
const Standard_Integer fontHeight );
|
const Standard_Integer& theFontHeight);
|
||||||
|
|
||||||
void render_text( const Standard_Integer id,
|
void render_text( const Standard_Integer id,
|
||||||
const wchar_t* text,
|
const wchar_t* text,
|
||||||
@ -62,8 +62,6 @@ class OpenGl_FontMgr
|
|||||||
//returns width of string
|
//returns width of string
|
||||||
Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
|
Standard_ShortReal computeWidth( const Standard_Integer id, const wchar_t *str );
|
||||||
|
|
||||||
bool requestFontList( Graphic3d_NListOfHAsciiString& );
|
|
||||||
|
|
||||||
void setCurrentScale( const Standard_ShortReal xScale = 1.f,
|
void setCurrentScale( const Standard_ShortReal xScale = 1.f,
|
||||||
const Standard_ShortReal yScale = 1.f);
|
const Standard_ShortReal yScale = 1.f);
|
||||||
|
|
||||||
@ -77,29 +75,24 @@ private:
|
|||||||
|
|
||||||
typedef NCollection_List<Standard_Integer> IDList;
|
typedef NCollection_List<Standard_Integer> IDList;
|
||||||
|
|
||||||
struct OGLFont_SysInfo {
|
|
||||||
Handle(Font_SystemFont) SysFont;
|
|
||||||
IDList GeneratedFonts;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct OGLFont_Cache {
|
struct OGLFont_Cache {
|
||||||
FTFont* Font;
|
FTFont* Font;
|
||||||
Standard_Integer FontHeight;
|
Standard_Integer FontHeight;
|
||||||
GLCONTEXT GlContext;
|
GLCONTEXT GlContext;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef NCollection_List<OGLFont_SysInfo*> FontDataBase;
|
typedef NCollection_DataMap<Handle(Font_SystemFont), IDList> FontDataBase;
|
||||||
typedef FontDataBase::Iterator FontDBIt;
|
typedef FontDataBase::Iterator FontDBIterator;
|
||||||
typedef NCollection_DataMap<Standard_Integer,OGLFont_Cache> FontCache;
|
typedef NCollection_DataMap<Standard_Integer, OGLFont_Cache> FontCache;
|
||||||
typedef FontCache::Iterator FCacheIt;
|
typedef FontCache::Iterator FontCacheIterator;
|
||||||
|
|
||||||
FontDataBase _FontDB;
|
FontDataBase myGeneratedFontDB;
|
||||||
FontCache _FontCache;
|
FontCache myGeneratedFontCache;
|
||||||
|
|
||||||
Standard_Integer _CurrentFontId;
|
Standard_Integer myCurrentFontId;
|
||||||
|
|
||||||
Standard_ShortReal _XCurrentScale,
|
Standard_ShortReal myXCurrentScale,
|
||||||
_YCurrentScale;
|
myYCurrentScale;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OPENGL_FONT_MGR_H
|
#endif //OPENGL_FONT_MGR_H
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <Prs3d_TextAspect.ixx>
|
#include <Prs3d_TextAspect.ixx>
|
||||||
#include <Quantity_Color.hxx>
|
#include <Quantity_Color.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
Prs3d_TextAspect::Prs3d_TextAspect ()
|
Prs3d_TextAspect::Prs3d_TextAspect ()
|
||||||
: myAngle(0.),
|
: myAngle(0.),
|
||||||
@ -36,7 +36,7 @@ Prs3d_TextAspect::Prs3d_TextAspect ()
|
|||||||
|
|
||||||
myTextAspect = new Graphic3d_AspectText3d (
|
myTextAspect = new Graphic3d_AspectText3d (
|
||||||
Quantity_Color(Quantity_NOC_YELLOW),
|
Quantity_Color(Quantity_NOC_YELLOW),
|
||||||
Graphic3d_NOF_ASCII_TRIPLEX,
|
Font_NOF_ASCII_TRIPLEX,
|
||||||
1.,
|
1.,
|
||||||
0.);
|
0.);
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
|
|||||||
#include <GGraphic2d_SetOfCurves.hxx>
|
#include <GGraphic2d_SetOfCurves.hxx>
|
||||||
#include <Graphic2d_SetOfSegments.hxx>
|
#include <Graphic2d_SetOfSegments.hxx>
|
||||||
|
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
|
static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/)
|
||||||
{
|
{
|
||||||
@ -462,13 +462,13 @@ static Standard_Integer BUC60821(Draw_Interpretor& di, Standard_Integer argc,con
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(QABugs_MyText) txt1 = new QABugs_MyText("Gosha1",gp_Pnt(0,0,0),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
|
Handle(QABugs_MyText) txt1 = new QABugs_MyText("Gosha1",gp_Pnt(0,0,0),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_RED,atoi(argv[1]));
|
||||||
aContext->Display(txt1);
|
aContext->Display(txt1);
|
||||||
|
|
||||||
Handle(QABugs_MyText) txt2 = new QABugs_MyText("Gosha2",gp_Pnt(0,0,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
|
Handle(QABugs_MyText) txt2 = new QABugs_MyText("Gosha2",gp_Pnt(0,0,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_YELLOW,atoi(argv[2]));
|
||||||
aContext->Display(txt2);
|
aContext->Display(txt2);
|
||||||
|
|
||||||
Handle(QABugs_MyText) txt3 = new QABugs_MyText("Gosha3",gp_Pnt(0,100,100),Graphic3d_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
|
Handle(QABugs_MyText) txt3 = new QABugs_MyText("Gosha3",gp_Pnt(0,100,100),Font_NOF_ASCII_SIMPLEX,Quantity_NOC_SKYBLUE,atoi(argv[3]));
|
||||||
aContext->Display(txt3);
|
aContext->Display(txt3);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <Prs3d_Text.hxx>
|
#include <Prs3d_Text.hxx>
|
||||||
#include <Select3D_SensitiveBox.hxx>
|
#include <Select3D_SensitiveBox.hxx>
|
||||||
#include <SelectMgr_Selection.hxx>
|
#include <SelectMgr_Selection.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -4,3 +4,4 @@ CSF_XwLibs
|
|||||||
CSF_dpsLibs
|
CSF_dpsLibs
|
||||||
CSF_XmuLibs
|
CSF_XmuLibs
|
||||||
CSF_FreeImagePlus
|
CSF_FreeImagePlus
|
||||||
|
CSF_FREETYPE
|
||||||
|
@ -7,5 +7,3 @@ CSF_user32
|
|||||||
CSF_kernel32
|
CSF_kernel32
|
||||||
STLPortLib
|
STLPortLib
|
||||||
CSF_TBB
|
CSF_TBB
|
||||||
CSF_MotifLibs
|
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <TCollection_AsciiString.hxx>
|
#include <TCollection_AsciiString.hxx>
|
||||||
#include <TColStd_SequenceOfExtendedString.hxx>
|
#include <TColStd_SequenceOfExtendedString.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
V3d_ColorScale::V3d_ColorScale( const Handle(V3d_LayerMgr)& aMgr )
|
V3d_ColorScale::V3d_ColorScale( const Handle(V3d_LayerMgr)& aMgr )
|
||||||
: Aspect_ColorScale(),
|
: Aspect_ColorScale(),
|
||||||
@ -99,7 +99,7 @@ void V3d_ColorScale::PaintText( const TCollection_ExtendedString& aText,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
theLayer->SetColor( aColor );
|
theLayer->SetColor( aColor );
|
||||||
theLayer->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, aColor );
|
theLayer->SetTextAttributes( Font_NOF_ASCII_MONO, Aspect_TODT_NORMAL, aColor );
|
||||||
TCollection_AsciiString theText( aText.ToExtString(), '?' );
|
TCollection_AsciiString theText( aText.ToExtString(), '?' );
|
||||||
Standard_Integer aTextH = GetTextHeight();
|
Standard_Integer aTextH = GetTextHeight();
|
||||||
Standard_Integer aWidth, anAscent, aDescent;
|
Standard_Integer aWidth, anAscent, aDescent;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
#include <Visual3d_View.hxx>
|
#include <Visual3d_View.hxx>
|
||||||
#include <V3d_ColorScale.hxx>
|
#include <V3d_ColorScale.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
|
|
||||||
V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView )
|
V3d_LayerMgr::V3d_LayerMgr( const Handle(V3d_View)& AView )
|
||||||
@ -98,7 +98,7 @@ Standard_Boolean V3d_LayerMgr::Begin()
|
|||||||
myOverlay->Clear();
|
myOverlay->Clear();
|
||||||
myOverlay->SetViewport( aW, aH ); //szv:!!!
|
myOverlay->SetViewport( aW, aH ); //szv:!!!
|
||||||
myOverlay->Begin();
|
myOverlay->Begin();
|
||||||
myOverlay->SetTextAttributes( Graphic3d_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_Color() );
|
myOverlay->SetTextAttributes( Font_NOF_ASCII_MONO, Aspect_TODT_NORMAL, Quantity_Color() );
|
||||||
myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT );
|
myOverlay->SetOrtho( 0, Max( aW, aH ), Max( aW, aH ), 0, Aspect_TOC_TOP_LEFT );
|
||||||
|
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
@ -2255,7 +2255,6 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha
|
|||||||
//===============================================================================================
|
//===============================================================================================
|
||||||
#include <Graphic3d_Group.hxx>
|
#include <Graphic3d_Group.hxx>
|
||||||
#include <Graphic3d_Structure.hxx>
|
#include <Graphic3d_Structure.hxx>
|
||||||
#include <Graphic3d_NameOfFont.hxx>
|
|
||||||
#include <Graphic3d_AspectText3d.hxx>
|
#include <Graphic3d_AspectText3d.hxx>
|
||||||
#include <Graphic2d_GraphicObject.hxx>
|
#include <Graphic2d_GraphicObject.hxx>
|
||||||
#include <Graphic3d_Array1OfVertex.hxx>
|
#include <Graphic3d_Array1OfVertex.hxx>
|
||||||
@ -2264,6 +2263,8 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha
|
|||||||
#include <Graphic3d_VerticalTextAlignment.hxx>
|
#include <Graphic3d_VerticalTextAlignment.hxx>
|
||||||
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
#include <Graphic3d_HorizontalTextAlignment.hxx>
|
||||||
|
|
||||||
|
#include <Font_NameOfFont.hxx>
|
||||||
|
|
||||||
#include <Visual3d_ViewManager.hxx>
|
#include <Visual3d_ViewManager.hxx>
|
||||||
#include <ViewerTest_Tool.ixx>
|
#include <ViewerTest_Tool.ixx>
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ if { [info exist only_screen] } {
|
|||||||
vdump $imagedir/${test_image}.png
|
vdump $imagedir/${test_image}.png
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if { [info exist only_screen2d] } {
|
||||||
|
v2ddump $imagedir/${test_image}.png
|
||||||
|
}
|
||||||
|
|
||||||
# to end a test script
|
# to end a test script
|
||||||
puts "TEST COMPLETED"
|
puts "TEST COMPLETED"
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
pload QAcommands
|
|
||||||
puts "================"
|
puts "================"
|
||||||
puts "OCC322"
|
puts "OCC322"
|
||||||
puts "================"
|
puts "================"
|
||||||
puts ""
|
puts ""
|
||||||
|
|
||||||
|
pload QAcommands
|
||||||
|
|
||||||
restore [locate_data_file OCC322.brep] a
|
restore [locate_data_file OCC322.brep] a
|
||||||
puts [checkshape a]
|
puts [checkshape a]
|
||||||
|
|
||||||
@ -21,10 +22,11 @@ set x1 204
|
|||||||
set y1 297
|
set y1 297
|
||||||
|
|
||||||
set x2 251
|
set x2 251
|
||||||
set y2 230
|
set y2 232
|
||||||
|
|
||||||
QAGetPixelColor $x1 $y1 $Yellow_R $Yellow_G $Yellow_B
|
QAGetPixelColor $x1 $y1 $Yellow_R $Yellow_G $Yellow_B
|
||||||
QAGetPixelColor $x2 $y2 $Yellow_R $Yellow_G $Yellow_B
|
QAGetPixelColor $x2 $y2 $Yellow_R $Yellow_G $Yellow_B
|
||||||
|
|
||||||
set square 20000
|
set square 20000
|
||||||
set only_screen 1
|
set only_screen 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user