1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright: OpenCASCADE
// File: OSD_SystemFont.cxx
// Created: 20.01.2008
// Author: Alexander A. BORODIN
// Updated:
#include <OSD_SystemFont.ixx>
#include <OSD_Path.hxx>
#include <TCollection_HAsciiString.hxx>
#include <stdio.h>
OSD_SystemFont::OSD_SystemFont():
MyFontName(),
MyFontAspect(OSD_FA_Undefined),
MyFaceSize(-1),
MyVerification(Standard_False)
{
}
OSD_SystemFont::OSD_SystemFont( const Handle(TCollection_HAsciiString)& FontName,
const OSD_FontAspect FontAspect,
const Handle(TCollection_HAsciiString)& FilePath ):
MyFontName(FontName),
MyFontAspect(FontAspect),
MyFaceSize(-1),
MyFilePath(FilePath),
MyVerification(Standard_True)
{
}
OSD_SystemFont::OSD_SystemFont( const Handle(TCollection_HAsciiString)& XLFD,
const Handle(TCollection_HAsciiString)& FilePath) :
MyFontAspect(OSD_FA_Undefined),
MyFilePath(FilePath)
{
MyVerification = Standard_True;
if ( XLFD.IsNull() )
{
MyVerification=Standard_False;
printf("NULL XLFD handler \n");
}
if ( XLFD->IsEmpty() )
{
MyVerification=Standard_False;
printf("EMPTY XLFD handler \n");
}
if(MyVerification)
{
MyFontName = XLFD->Token( "-", 2 );
TCollection_AsciiString str( XLFD->ToCString() );
if ( str.Search( "-0-0-0-0-" ) >=0 )
MyFaceSize = -1;
else
//TODO catch exeption
MyFaceSize = Standard_Integer (str.Token( "-", 7 ).RealValue());
//detect aspect
if ( str.Token("-", 3).IsEqual( "bold" ) )
MyFontAspect = OSD_FA_Bold;
else if ( str.Token("-", 3).IsEqual( "medium" ) ||
str.Token("-", 3).IsEqual( "normal" ) )
MyFontAspect = OSD_FA_Regular;
if ( MyFontAspect != OSD_FA_Undefined &&
( str.Token("-",4 ).IsEqual( "i" ) || str.Token("-",4 ).IsEqual( "o" ) ) )
{
if ( MyFontAspect == OSD_FA_Bold )
MyFontAspect = OSD_FA_BoldItalic;
else
MyFontAspect = OSD_FA_Italic;
}
}
}
Standard_Boolean OSD_SystemFont::IsValid() const{
if ( !MyVerification)
return Standard_False;
if ( MyFontAspect == OSD_FA_Undefined )
return Standard_False;
if ( MyFontName->IsEmpty() || !MyFontName->IsAscii() )
return Standard_False;
OSD_Path path;
return path.IsValid( MyFilePath->String() );
}
Handle(TCollection_HAsciiString) OSD_SystemFont::FontPath() const{
return MyFilePath;
}
Handle(TCollection_HAsciiString) OSD_SystemFont::FontName() const{
return MyFontName;
}
OSD_FontAspect OSD_SystemFont::FontAspect() const{
return MyFontAspect;
}
Standard_Integer OSD_SystemFont::FontHeight() const {
return MyFaceSize;
}
|