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 |
21 | IMPLEMENT_STANDARD_RTTIEXT(Font_SystemFont, Standard_Transient) |
22 | |
23 | // ======================================================================= |
24 | // function : Font_SystemFont |
25 | // purpose : |
26 | // ======================================================================= |
5b377041 |
27 | Font_SystemFont::Font_SystemFont (const TCollection_AsciiString& theFontName) |
28 | : myFontKey (theFontName), |
29 | myFontName (theFontName), |
30 | myIsSingleLine (Standard_False) |
7fd59977 |
31 | { |
9a90a452 |
32 | memset (myFaceIds, 0, sizeof(myFaceIds)); |
5b377041 |
33 | if (theFontName.IsEmpty()) { throw Standard_ProgramError ("Font_SystemFont constructor called with empty font name"); } |
34 | myFontKey.LowerCase(); |
7fd59977 |
35 | } |
36 | |
e4f0cc46 |
37 | // ======================================================================= |
5b377041 |
38 | // function : SetFontPath |
e4f0cc46 |
39 | // purpose : |
40 | // ======================================================================= |
5b377041 |
41 | void Font_SystemFont::SetFontPath (Font_FontAspect theAspect, |
9a90a452 |
42 | const TCollection_AsciiString& thePath, |
43 | const Standard_Integer theFaceId) |
7fd59977 |
44 | { |
5b377041 |
45 | if (theAspect == Font_FontAspect_UNDEFINED) { throw Standard_ProgramError ("Font_SystemFont::SetFontPath() called with UNDEFINED aspect"); } |
46 | myFilePaths[theAspect] = thePath; |
9a90a452 |
47 | myFaceIds [theAspect] = theFaceId; |
7fd59977 |
48 | } |
49 | |
e4f0cc46 |
50 | // ======================================================================= |
5b377041 |
51 | // function : IsEqual |
e4f0cc46 |
52 | // purpose : |
53 | // ======================================================================= |
5b377041 |
54 | Standard_Boolean Font_SystemFont::IsEqual (const Handle(Font_SystemFont)& theOtherFont) const |
7fd59977 |
55 | { |
5b377041 |
56 | return theOtherFont.get() == this |
57 | || myFontKey.IsEqual (theOtherFont->myFontKey); |
e4f0cc46 |
58 | } |
aff395a3 |
59 | |
e4f0cc46 |
60 | // ======================================================================= |
5b377041 |
61 | // function : ToString |
e4f0cc46 |
62 | // purpose : |
63 | // ======================================================================= |
5b377041 |
64 | TCollection_AsciiString Font_SystemFont::ToString() const |
e4f0cc46 |
65 | { |
5b377041 |
66 | TCollection_AsciiString aDesc; |
67 | aDesc += TCollection_AsciiString() + "'" + myFontName + "'"; |
e4f0cc46 |
68 | |
5b377041 |
69 | bool isFirstAspect = true; |
70 | aDesc += " [aspects: "; |
71 | for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter) |
72 | { |
73 | if (!HasFontAspect ((Font_FontAspect )anAspectIter)) |
74 | { |
75 | continue; |
76 | } |
77 | |
78 | if (!isFirstAspect) |
79 | { |
80 | aDesc += ","; |
81 | } |
82 | else |
83 | { |
84 | isFirstAspect = false; |
85 | } |
86 | aDesc += Font_FontMgr::FontAspectToString ((Font_FontAspect )anAspectIter); |
87 | } |
88 | aDesc += "]"; |
89 | |
90 | isFirstAspect = true; |
91 | aDesc += " [paths: "; |
92 | for (int anAspectIter = 0; anAspectIter < Font_FontAspect_NB; ++anAspectIter) |
93 | { |
94 | if (!HasFontAspect ((Font_FontAspect )anAspectIter)) |
95 | { |
96 | continue; |
97 | } |
98 | |
99 | if (!isFirstAspect) |
100 | { |
101 | aDesc += ";"; |
102 | } |
103 | else |
104 | { |
105 | isFirstAspect = false; |
106 | } |
107 | aDesc += FontPath ((Font_FontAspect )anAspectIter); |
9a90a452 |
108 | if (FontFaceId ((Font_FontAspect )anAspectIter) != 0) |
109 | { |
110 | aDesc = aDesc + "," + FontFaceId ((Font_FontAspect )anAspectIter); |
111 | } |
5b377041 |
112 | } |
113 | aDesc += "]"; |
114 | return aDesc; |
aff395a3 |
115 | } |