1 // Created on: 2008-01-20
2 // Created by: Alexander A. BORODIN
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and / or modify it
8 // under the terms of the GNU Lesser General Public version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
18 #include <Font_SystemFont.ixx>
19 #include <OSD_Path.hxx>
20 #include <TCollection_HAsciiString.hxx>
23 Font_SystemFont::Font_SystemFont():
25 MyFontAspect(Font_FA_Undefined),
27 MyVerification(Standard_False)
31 Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& FontName,
32 const Font_FontAspect FontAspect,
33 const Handle(TCollection_HAsciiString)& FilePath ):
35 MyFontAspect(FontAspect),
38 MyVerification(Standard_True)
43 Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
44 const Handle(TCollection_HAsciiString)& theFilePath) :
45 MyFontAspect(Font_FA_Regular),
47 MyFilePath(theFilePath)
49 MyVerification = Standard_True;
52 MyVerification = Standard_False; // empty font description handler
54 if (theXLFD->IsEmpty())
56 MyVerification = Standard_False; // empty font description
61 MyFontName = theXLFD->Token ("-", 2);
62 TCollection_AsciiString aXLFD (theXLFD->ToCString());
64 // Getting font size for fixed size fonts
65 if (aXLFD.Search ("-0-0-0-0-") >= 0)
66 MyFaceSize = -1; // Scalable font
69 MyFaceSize = aXLFD.Token ("-", 7).IntegerValue();
72 if (aXLFD.Token ("-", 3).IsEqual ("bold") &&
73 (aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o")))
75 MyFontAspect = Font_FA_BoldItalic;
77 else if (aXLFD.Token ("-", 3).IsEqual ("bold"))
79 MyFontAspect = Font_FA_Bold;
81 else if (aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o"))
83 MyFontAspect = Font_FA_Italic;
88 Standard_Boolean Font_SystemFont::IsValid() const{
90 return Standard_False;
92 if ( MyFontAspect == Font_FA_Undefined )
93 return Standard_False;
95 if ( MyFontName->IsEmpty() || !MyFontName->IsAscii() )
96 return Standard_False;
99 return path.IsValid( MyFilePath->String() );
102 Handle(TCollection_HAsciiString) Font_SystemFont::FontPath() const{
106 Handle(TCollection_HAsciiString) Font_SystemFont::FontName() const{
110 Font_FontAspect Font_SystemFont::FontAspect() const{
114 Standard_Integer Font_SystemFont::FontHeight() const {
118 Standard_Boolean Font_SystemFont::IsEqual(const Handle(Font_SystemFont)& theOtherFont) const
120 if (!MyFontName->IsSameString (theOtherFont->FontName(), Standard_False))
122 return Standard_False;
125 if (MyFontAspect != theOtherFont->FontAspect())
127 return Standard_False;
130 if (MyFaceSize != theOtherFont->FontHeight())
132 return Standard_False;
135 return Standard_True;