1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +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:
dbv
2012-12-07 13:42:37 +04:00
parent cb9292ed80
commit aff395a36d
29 changed files with 809 additions and 840 deletions

View File

@@ -45,48 +45,46 @@ MyVerification(Standard_True)
}
Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& XLFD,
const Handle(TCollection_HAsciiString)& FilePath) :
MyFilePath(FilePath),
MyFontAspect(Font_FA_Undefined)
Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
const Handle(TCollection_HAsciiString)& theFilePath) :
MyFilePath(theFilePath),
MyFontAspect(Font_FA_Regular)
{
MyVerification = Standard_True;
if ( XLFD.IsNull() )
if (theXLFD.IsNull())
{
MyVerification=Standard_False;
printf("NULL XLFD handler \n");
MyVerification = Standard_False; // empty font description handler
}
if ( XLFD->IsEmpty() )
if (theXLFD->IsEmpty())
{
MyVerification=Standard_False;
printf("EMPTY XLFD handler \n");
MyVerification = Standard_False; // empty font description
}
if(MyVerification)
if (MyVerification)
{
MyFontName = XLFD->Token( "-", 2 );
TCollection_AsciiString str( XLFD->ToCString() );
MyFontName = theXLFD->Token ("-", 2);
TCollection_AsciiString aXLFD (theXLFD->ToCString());
if ( str.Search( "-0-0-0-0-" ) >=0 )
MyFaceSize = -1;
// Getting font size for fixed size fonts
if (aXLFD.Search ("-0-0-0-0-") >= 0)
MyFaceSize = -1; // Scalable font
else
//TODO catch exeption
MyFaceSize = str.Token( "-", 7 ).IntegerValue();
MyFaceSize = aXLFD.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" ) ) )
// Detect font aspect
if (aXLFD.Token ("-", 3).IsEqual ("bold") &&
(aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o")))
{
if ( MyFontAspect == Font_FA_Bold )
MyFontAspect = Font_FA_BoldItalic;
else
MyFontAspect = Font_FA_Italic;
MyFontAspect = Font_FA_BoldItalic;
}
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;
}
}
}
@@ -120,3 +118,23 @@ Font_FontAspect Font_SystemFont::FontAspect() const{
Standard_Integer Font_SystemFont::FontHeight() const {
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;
}