0030439: Visualization - extend fonts search within Font_FontMgr::FindFont() on Linux
[occt.git] / src / Font / Font_SystemFont.cxx
CommitLineData
b311480e 1// Created on: 2008-01-20
2// Created by: Alexander A. BORODIN
973c2be1 3// Copyright (c) 2008-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
42cf5bc1 16#include <Font_SystemFont.hxx>
e4f0cc46 17
5b377041 18#include <Font_FontMgr.hxx>
7fd59977 19#include <OSD_Path.hxx>
7fd59977 20
e4f0cc46 21IMPLEMENT_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient)
22
23// =======================================================================
24// function : Font_SystemFont
25// purpose :
26// =======================================================================
5b377041 27Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName)
28: myFontKey (theFontName),
29 myFontName (theFontName),
30 myIsSingleLine (Standard_False)
7fd59977 31{
5b377041 32 if (theFontName.IsEmpty()) { throw Standard_ProgramError ("Font_SystemFont constructor called with empty font name"); }
33 myFontKey.LowerCase();
7fd59977 34}
35
e4f0cc46 36// =======================================================================
5b377041 37// function : SetFontPath
e4f0cc46 38// purpose :
39// =======================================================================
5b377041 40void Font_SystemFont::SetFontPath (Font_FontAspect theAspect,
41 const TCollection_AsciiString& thePath)
7fd59977 42{
5b377041 43 if (theAspect == Font_FontAspect_UNDEFINED) { throw Standard_ProgramError ("Font_SystemFont::SetFontPath() called with UNDEFINED aspect"); }
44 myFilePaths[theAspect] = thePath;
7fd59977 45}
46
e4f0cc46 47// =======================================================================
5b377041 48// function : IsEqual
e4f0cc46 49// purpose :
50// =======================================================================
5b377041 51Standard_Boolean Font_SystemFont::IsEqual (const Handle(Font_SystemFont)& theOtherFont) const
7fd59977 52{
5b377041 53 return theOtherFont.get() == this
54 || myFontKey.IsEqual (theOtherFont->myFontKey);
e4f0cc46 55}
aff395a3 56
e4f0cc46 57// =======================================================================
5b377041 58// function : ToString
e4f0cc46 59// purpose :
60// =======================================================================
5b377041 61TCollection_AsciiString Font_SystemFont::ToString() const
e4f0cc46 62{
5b377041 63 TCollection_AsciiString aDesc;
64 aDesc += TCollection_AsciiString() + "'" + myFontName + "'";
e4f0cc46 65
5b377041 66 bool isFirstAspect = true;
67 aDesc += " [aspects: ";
68 for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
69 {
70 if (!HasFontAspect ((Font_FontAspect )anAspectIter))
71 {
72 continue;
73 }
74
75 if (!isFirstAspect)
76 {
77 aDesc += ",";
78 }
79 else
80 {
81 isFirstAspect = false;
82 }
83 aDesc += Font_FontMgr::FontAspectToString ((Font_FontAspect )anAspectIter);
84 }
85 aDesc += "]";
86
87 isFirstAspect = true;
88 aDesc += " [paths: ";
89 for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter)
90 {
91 if (!HasFontAspect ((Font_FontAspect )anAspectIter))
92 {
93 continue;
94 }
95
96 if (!isFirstAspect)
97 {
98 aDesc += ";";
99 }
100 else
101 {
102 isFirstAspect = false;
103 }
104 aDesc += FontPath ((Font_FontAspect )anAspectIter);
105 }
106 aDesc += "]";
107 return aDesc;
aff395a3 108}