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 under
8 // the terms of the GNU Lesser General Public License 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.
16 #include <Font_SystemFont.hxx>
18 #include <Font_FontMgr.hxx>
19 #include <OSD_Path.hxx>
21 IMPLEMENT_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
23 // =======================================================================
24 // function : Font_SystemFont
26 // =======================================================================
27 Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName)
28 : myFontKey (theFontName),
29 myFontName (theFontName),
30 myIsSingleLine (Standard_False)
32 if (theFontName.IsEmpty()) { throw Standard_ProgramError ("Font_SystemFont constructor called with empty font name"); }
33 myFontKey.LowerCase();
36 // =======================================================================
37 // function : SetFontPath
39 // =======================================================================
40 void Font_SystemFont::SetFontPath (Font_FontAspect theAspect,
41 const TCollection_AsciiString& thePath)
43 if (theAspect == Font_FontAspect_UNDEFINED) { throw Standard_ProgramError ("Font_SystemFont::SetFontPath() called with UNDEFINED aspect"); }
44 myFilePaths[theAspect] = thePath;
47 // =======================================================================
50 // =======================================================================
51 Standard_Boolean Font_SystemFont::IsEqual (const Handle(Font_SystemFont)& theOtherFont) const
53 return theOtherFont.get() == this
54 || myFontKey.IsEqual (theOtherFont->myFontKey);
57 // =======================================================================
58 // function : ToString
60 // =======================================================================
61 TCollection_AsciiString Font_SystemFont::ToString() const
63 TCollection_AsciiString aDesc;
64 aDesc += TCollection_AsciiString() + "'" + myFontName + "'";
66 bool isFirstAspect = true;
67 aDesc += " [aspects: ";
68 for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
70 if (!HasFontAspect ((Font_FontAspect )anAspectIter))
81 isFirstAspect = false;
83 aDesc += Font_FontMgr::FontAspectToString ((Font_FontAspect )anAspectIter);
89 for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
91 if (!HasFontAspect ((Font_FontAspect )anAspectIter))
102 isFirstAspect = false;
104 aDesc += FontPath ((Font_FontAspect )anAspectIter);