2 // File Aspect_FontMap.cxx
3 // Created Septembre 1993
6 //-Copyright MatraDatavision 1991,1992
10 //-Design Declaration des variables specifiques aux Ensembles
11 // de Fontures de texts
13 //-Warning Une FontMap est definie par un ensemble de FontMapEntries
22 #include <Aspect_FontMap.ixx>
26 //-Global data definitions
28 // mydata : SequenceOfFontMapEntry from Aspect is protected
36 Aspect_FontMap::Aspect_FontMap( ) {
37 Aspect_FontMapEntry theDefaultEntry;
39 AddEntry(theDefaultEntry);
42 void Aspect_FontMap::AddEntry (const Aspect_FontMapEntry& AnEntry) {
43 Standard_Integer i,index = AnEntry.Index();
44 Aspect_FontMapEntry theEntry;
46 for( i=1 ; i<=mydata.Length() ; i++ ) {
47 theEntry = mydata.Value(i);
48 if( index == theEntry.Index() ) break;
51 if( i > mydata.Length() ) {
52 mydata.Append( AnEntry );
54 mydata.SetValue(i,AnEntry);
58 Standard_Integer Aspect_FontMap::AddEntry (const Aspect_FontStyle &aStyle) {
59 Aspect_FontMapEntry theEntry ;
60 Standard_Integer i,maxindex = 0 ;
62 for( i=1 ; i<=mydata.Length() ; i++ ) {
63 theEntry = mydata.Value(i) ;
64 maxindex = Max(maxindex,theEntry.Index()) ;
65 if( theEntry.Type() == aStyle ) return theEntry.Index() ;
69 theEntry.SetValue(maxindex,aStyle) ;
70 mydata.Append( theEntry ) ;
74 Standard_Integer Aspect_FontMap::Size() const {
76 return mydata.Length() ;
79 Standard_Integer Aspect_FontMap::Index(const Standard_Integer anIndex) const {
81 if( anIndex < 1 || anIndex > Size() ) {
82 Aspect_BadAccess::Raise ("Undefined fontmap Index");
85 Aspect_FontMapEntry theEntry = mydata.Value(anIndex) ;
87 return theEntry.Index() ;
90 Aspect_FontMapEntry Aspect_FontMap::Entry (const Standard_Integer AnIndex) const {
92 if( AnIndex < 1 || AnIndex > mydata.Length() )
93 Aspect_BadAccess::Raise ("Aspect_FontMap::Entry Bad Index");
95 return mydata.Value(AnIndex);
98 void Aspect_FontMap::Dump () const {
102 cout << "Fontmap Dump-->\n" ;
104 for ( i = 1 ; i <= Size() ; i++ ) (Entry(i)).Dump() ;
106 cout << "<--End Fontmap Dump\n" ;