1 // Created on: 2008-01-20
2 // Created by: Alexander A. BORODIN
3 // Copyright (c) 2008-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
23 #include <Font_SystemFont.ixx>
24 #include <OSD_Path.hxx>
25 #include <TCollection_HAsciiString.hxx>
28 Font_SystemFont::Font_SystemFont():
30 MyFontAspect(Font_FA_Undefined),
32 MyVerification(Standard_False)
36 Font_SystemFont::Font_SystemFont( const Handle(TCollection_HAsciiString)& FontName,
37 const Font_FontAspect FontAspect,
38 const Handle(TCollection_HAsciiString)& FilePath ):
40 MyFontAspect(FontAspect),
43 MyVerification(Standard_True)
48 Font_SystemFont::Font_SystemFont (const Handle(TCollection_HAsciiString)& theXLFD,
49 const Handle(TCollection_HAsciiString)& theFilePath) :
50 MyFilePath(theFilePath),
51 MyFontAspect(Font_FA_Regular)
53 MyVerification = Standard_True;
56 MyVerification = Standard_False; // empty font description handler
58 if (theXLFD->IsEmpty())
60 MyVerification = Standard_False; // empty font description
65 MyFontName = theXLFD->Token ("-", 2);
66 TCollection_AsciiString aXLFD (theXLFD->ToCString());
68 // Getting font size for fixed size fonts
69 if (aXLFD.Search ("-0-0-0-0-") >= 0)
70 MyFaceSize = -1; // Scalable font
73 MyFaceSize = aXLFD.Token ("-", 7).IntegerValue();
76 if (aXLFD.Token ("-", 3).IsEqual ("bold") &&
77 (aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o")))
79 MyFontAspect = Font_FA_BoldItalic;
81 else if (aXLFD.Token ("-", 3).IsEqual ("bold"))
83 MyFontAspect = Font_FA_Bold;
85 else if (aXLFD.Token ("-", 4).IsEqual ("i") || aXLFD.Token ("-", 4).IsEqual ("o"))
87 MyFontAspect = Font_FA_Italic;
92 Standard_Boolean Font_SystemFont::IsValid() const{
94 return Standard_False;
96 if ( MyFontAspect == Font_FA_Undefined )
97 return Standard_False;
99 if ( MyFontName->IsEmpty() || !MyFontName->IsAscii() )
100 return Standard_False;
103 return path.IsValid( MyFilePath->String() );
106 Handle(TCollection_HAsciiString) Font_SystemFont::FontPath() const{
110 Handle(TCollection_HAsciiString) Font_SystemFont::FontName() const{
114 Font_FontAspect Font_SystemFont::FontAspect() const{
118 Standard_Integer Font_SystemFont::FontHeight() const {
122 Standard_Boolean Font_SystemFont::IsEqual(const Handle(Font_SystemFont)& theOtherFont) const
124 if (!MyFontName->IsSameString (theOtherFont->FontName(), Standard_False))
126 return Standard_False;
129 if (MyFontAspect != theOtherFont->FontAspect())
131 return Standard_False;
134 if (MyFaceSize != theOtherFont->FontHeight())
136 return Standard_False;
139 return Standard_True;