]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/font.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "font.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 extern wxFontNameDirectory
*wxTheFontNameDirectory
;
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class wxFontRefData
: public wxObjectRefData
34 wxFontRefData( const wxFontRefData
& data
);
37 wxList m_scaled_xfonts
;
39 int m_family
, m_style
, m_weight
;
50 wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER
)
52 m_byXFontName
= FALSE
;
59 m_font
= (GdkFont
*) NULL
;
62 wxFontRefData::wxFontRefData( const wxFontRefData
& data
) : m_scaled_xfonts(wxKEY_INTEGER
)
64 m_byXFontName
= FALSE
;
65 m_pointSize
= data
.m_pointSize
;
66 m_family
= data
.m_family
;
67 m_style
= data
.m_style
;
68 m_weight
= data
.m_weight
;
69 m_underlined
= data
.m_underlined
;
70 m_fontId
= data
.m_fontId
;
71 m_faceName
= data
.m_faceName
;
72 m_font
= (GdkFont
*) NULL
;
73 if (data
.m_font
) m_font
= gdk_font_ref( data
.m_font
);
76 wxFontRefData::~wxFontRefData()
78 wxNode
*node
= m_scaled_xfonts
.First();
81 GdkFont
*font
= (GdkFont
*)node
->Data();
82 wxNode
*next
= node
->Next();
83 gdk_font_unref( font
);
86 if (m_font
) gdk_font_unref( m_font
);
89 //-----------------------------------------------------------------------------
91 #define M_FONTDATA ((wxFontRefData *)m_refData)
93 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
97 if (wxTheFontList
) wxTheFontList
->Append( this );
100 wxFont::wxFont( char *xFontName
)
102 if (!xFontName
) return;
104 m_refData
= new wxFontRefData();
106 M_FONTDATA
->m_byXFontName
= TRUE
;
107 M_FONTDATA
->m_font
= gdk_font_load( xFontName
);
110 wxFont::wxFont( int pointSize
, int family
, int style
, int weight
, bool underlined
= FALSE
,
111 const wxString
& face
= wxEmptyString
)
113 m_refData
= new wxFontRefData();
115 if (family
== wxDEFAULT
) family
= wxSWISS
;
116 M_FONTDATA
->m_family
= family
;
120 M_FONTDATA
->m_faceName
= face
;
121 M_FONTDATA
->m_fontId
= wxTheFontNameDirectory
->FindOrCreateFontId( face
, family
);
122 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
126 M_FONTDATA
->m_fontId
= family
;
127 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
130 if (style
== wxDEFAULT
) style
= wxNORMAL
;
131 M_FONTDATA
->m_style
= style
;
132 if (weight
== wxDEFAULT
) weight
= wxNORMAL
;
133 M_FONTDATA
->m_weight
= weight
;
134 if (pointSize
== wxDEFAULT
) pointSize
= 12;
135 M_FONTDATA
->m_pointSize
= pointSize
;
136 M_FONTDATA
->m_underlined
= underlined
;
138 if (wxTheFontList
) wxTheFontList
->Append( this );
142 wxFont::wxFont( const wxFont
& font
)
146 if (wxTheFontList
) wxTheFontList
->Append( this );
151 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
154 wxFont
& wxFont::operator = ( const wxFont
& font
)
156 if (*this == font
) return (*this);
161 bool wxFont::operator == ( const wxFont
& font
)
163 return m_refData
== font
.m_refData
;
166 bool wxFont::operator != ( const wxFont
& font
)
168 return m_refData
!= font
.m_refData
;
171 bool wxFont::Ok() const
173 return (m_refData
!= NULL
);
176 int wxFont::GetPointSize() const
178 wxCHECK_MSG( Ok(), 0, "invalid font" );
180 return M_FONTDATA
->m_pointSize
;
183 wxString
wxFont::GetFaceName() const
185 wxCHECK_MSG( Ok(), "", "invalid font" );
187 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
191 int wxFont::GetFamily() const
193 wxCHECK_MSG( Ok(), 0, "invalid font" );
195 return M_FONTDATA
->m_family
;
198 wxString
wxFont::GetFamilyString() const
200 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
202 switch (M_FONTDATA
->m_family
)
204 case wxDECORATIVE
: return wxString("wxDECORATIVE");
205 case wxROMAN
: return wxString("wxROMAN");
206 case wxSCRIPT
: return wxString("wxSCRIPT");
207 case wxSWISS
: return wxString("wxSWISS");
208 case wxMODERN
: return wxString("wxMODERN");
209 case wxTELETYPE
: return wxString("wxTELETYPE");
210 default: return "wxDEFAULT";
216 int wxFont::GetFontId() const
218 wxCHECK_MSG( Ok(), 0, "invalid font" );
220 return M_FONTDATA
->m_fontId
; // stub
223 int wxFont::GetStyle() const
225 wxCHECK_MSG( Ok(), 0, "invalid font" );
227 return M_FONTDATA
->m_style
;
230 wxString
wxFont::GetStyleString() const
232 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
234 switch (M_FONTDATA
->m_style
)
236 case wxNORMAL
: return wxString("wxNORMAL");
237 case wxSLANT
: return wxString("wxSLANT");
238 case wxITALIC
: return wxString("wxITALIC");
239 default: return wxString("wxDEFAULT");
242 return wxString("wxDEFAULT");
245 int wxFont::GetWeight() const
247 wxCHECK_MSG( Ok(), 0, "invalid font" );
249 return M_FONTDATA
->m_weight
;
252 wxString
wxFont::GetWeightString() const
254 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
256 switch (M_FONTDATA
->m_weight
)
258 case wxNORMAL
: return wxString("wxNORMAL");
259 case wxBOLD
: return wxString("wxBOLD");
260 case wxLIGHT
: return wxString("wxLIGHT");
261 default: return wxString("wxDEFAULT");
264 return wxString("wxDEFAULT");
267 bool wxFont::GetUnderlined() const
269 wxCHECK_MSG( Ok(), FALSE
, "invalid font" );
271 return M_FONTDATA
->m_underlined
;
274 void wxFont::Unshare()
278 m_refData
= new wxFontRefData();
282 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
288 void wxFont::SetPointSize(int pointSize
)
292 M_FONTDATA
->m_pointSize
= pointSize
;
295 void wxFont::SetFamily(int family
)
299 M_FONTDATA
->m_family
= family
;
302 void wxFont::SetStyle(int style
)
306 M_FONTDATA
->m_style
= style
;
309 void wxFont::SetWeight(int weight
)
313 M_FONTDATA
->m_weight
= weight
;
316 void wxFont::SetFaceName(const wxString
& faceName
)
320 M_FONTDATA
->m_faceName
= faceName
;
323 void wxFont::SetUnderlined(bool underlined
)
327 M_FONTDATA
->m_underlined
= underlined
;
330 //-----------------------------------------------------------------------------
331 // get internal representation of font
332 //-----------------------------------------------------------------------------
334 // local help function
335 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
336 int style
, int weight
,
339 GdkFont
*wxFont::GetInternalFont(float scale
) const
343 wxFAIL_MSG( "invalid font" );
344 return (GdkFont
*) NULL
;
347 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
349 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
350 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
351 GdkFont
*font
= (GdkFont
*) NULL
;
353 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
356 font
= (GdkFont
*)node
->Data();
360 if ((int_scale
== 100) &&
361 (M_FONTDATA
->m_family
== wxSWISS
) &&
362 (M_FONTDATA
->m_style
== wxNORMAL
) &&
363 (M_FONTDATA
->m_pointSize
== 12) &&
364 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
365 (M_FONTDATA
->m_underlined
== FALSE
))
367 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
371 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
372 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
374 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
377 wxLogError("could not load any font");
382 //-----------------------------------------------------------------------------
383 // local utilities to find a X font
384 //-----------------------------------------------------------------------------
386 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
387 int weight
, bool WXUNUSED(underlined
))
390 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
393 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
394 sprintf(buffer
, name
, point_size
);
396 return gdk_font_load( buffer
);
399 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
400 int style
, int weight
,
405 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
408 // search up and down by stepsize 10
409 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
410 int min_size
= point_size
- 20 * (1 + (point_size
/180));
413 // Search for smaller size (approx.)
414 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
415 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
416 // Search for larger size (approx.)
417 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
418 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
419 // Try default family
420 if (!font
&& fontid
!= wxDEFAULT
)
421 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
425 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
431 //-----------------------------------------------------------------------------
432 // face names and index functions
433 //-----------------------------------------------------------------------------
435 static char *font_defaults
[] = {
436 "FamilyDefault", "Default",
437 "FamilyRoman", "Roman",
438 "FamilyDecorative", "Decorative",
439 "FamilyModern", "Modern",
440 "FamilyTeletype", "Teletype",
441 "FamilySwiss", "Swiss",
442 "FamilyScript", "Script",
448 "AfmItalic", "${AfmSlant}",
452 "AfmHelvetica", "Helv",
453 "AfmCourier", "Cour",
455 "Afm___", "${AfmTimes,$[weight],$[style]}",
457 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
458 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
459 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
460 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
461 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
463 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
464 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
466 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
468 "PostScriptMediumStraight", "",
469 "PostScriptMediumItalic", "-Oblique",
470 "PostScriptMediumSlant", "-Oblique",
471 "PostScriptLightStraight", "",
472 "PostScriptLightItalic", "-Oblique",
473 "PostScriptLightSlant", "-Oblique",
474 "PostScriptBoldStraight", "-Bold",
475 "PostScriptBoldItalic", "-BoldOblique",
476 "PostScriptBoldSlant", "-BoldOblique",
478 #if WX_NORMALIZED_PS_FONTS
479 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
481 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
482 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
485 "PostScriptTimesMedium", "",
486 "PostScriptTimesLight", "",
487 "PostScriptTimesBold", "Bold",
489 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
490 "PostScriptTimesMediumStraight", "Times-Roman",
491 "PostScriptTimesLightStraight", "Times-Roman",
492 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
493 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
495 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
496 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
498 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
500 #if !WX_NORMALIZED_PS_FONTS
501 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
504 "ScreenMedium", "medium",
505 "ScreenBold", "bold",
506 "ScreenLight", "light",
507 "ScreenStraight", "r",
511 "ScreenDefaultBase", "misc-fixed",
512 "ScreenRomanBase", "*-times",
513 "ScreenDecorativeBase", "*-helvetica",
514 "ScreenModernBase", "*-courier",
515 "ScreenTeletypeBase", "*-lucidatypewriter",
516 "ScreenSwissBase", "*-lucida",
517 "ScreenScriptBase", "*-zapfchancery",
519 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
520 "-normal-*-*-%d-*-*-*-*-*-*",
523 "-${ScreenDefaultBase}${ScreenStdSuffix}",
525 "-${ScreenRomanBase}${ScreenStdSuffix}",
526 "ScreenDecorative__",
527 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
529 "-${ScreenModernBase}${ScreenStdSuffix}",
531 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
533 "-${ScreenSwissBase}${ScreenStdSuffix}",
535 "-${ScreenScriptBase}${ScreenStdSuffix}",
539 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
540 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
542 static int WCoordinate(int w
)
546 case wxBOLD
: return wxWEIGHT_BOLD
;
547 case wxLIGHT
: return wxWEIGHT_LIGHT
;
549 default: return wxWEIGHT_NORMAL
;
553 static int SCoordinate(int s
)
557 case wxITALIC
: return wxSTYLE_ITALIC
;
558 case wxSLANT
: return wxSTYLE_SLANT
;
560 default: return wxSTYLE_NORMAL
;
564 //-----------------------------------------------------------------------------
566 //-----------------------------------------------------------------------------
573 inline char *GetName(int weight
, int style
)
575 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
578 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
579 void Initialize(const char *, const char *);
582 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
585 char resource
[1024], **defaults
, *internal
;
590 internal
= (char *) NULL
;
592 for (i
= 0; i
< k
; i
++)
594 strcpy(resource
, prefix
);
595 for (j
= 0; j
< count
; j
++)
597 /* upon failure to find a matching fontname
598 in the default fonts above, we substitute more
599 and more values by _ so that at last ScreenMyFontBoldNormal
600 would turn into Screen___ and this will then get
601 converted to -${ScreenDefaultBase}${ScreenStdSuffix}
605 strcat(resource
, names
[j
]);
607 strcat(resource
, "_");
610 /* we previously search the Xt-resources here */
614 defaults
= font_defaults
;
617 if (!strcmp(*defaults
, resource
))
619 internal
= defaults
[1];
629 if (strcmp(internal
,"-${ScreenDefaultBase}${ScreenStdSuffix}") == 0)
631 /* we did not find any font name in the standard list.
632 this can (hopefully does) mean that someone supplied
633 the facename in the wxFont constructor so we insert
636 strcpy( resource
,"-*-" ); /* any producer */
637 strcat( resource
, names
[0] ); /* facename */
638 strcat( resource
, "${ScreenStdSuffix}" ); /* add size params later on */
639 *v
= copystring(resource
);
643 *v
= copystring(internal
);
648 wxSuffixMap::~wxSuffixMap()
652 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
653 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
657 map
[k
][j
] = (char *) NULL
;
661 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
663 const char *weight
, *style
;
666 const char *names
[3];
668 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++)
672 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
673 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
675 default: weight
= "Bold";
677 for (j
= 0; j
< wxNUM_STYLES
; j
++)
681 case wxSTYLE_NORMAL
: style
= "Straight"; break;
682 case wxSTYLE_ITALIC
: style
= "Italic"; break;
684 default: style
= "Slant";
690 SearchResource(devresname
, names
, 3, &v
);
692 /* Expand macros in the found string: */
694 int len
, closer
= 0, startpos
= 0;
696 len
= (v
? strlen(v
) : 0);
697 for (i
= 0; i
< len
; i
++)
699 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{')))
702 closer
= (v
[i
+1] == '[') ? ']' : '}';
705 else if (v
[i
] == closer
)
708 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
711 name
= v
+ startpos
+ 2;
719 for (i
= 0, count
= 1; name
[i
]; i
++)
725 names
= new char*[count
];
727 for (i
= 0, count
= 1; i
< len
; i
++)
730 names
[count
++] = name
+ i
+ 1;
734 SearchResource("", (const char **)names
, count
, (char **)&r
);
740 for (i
= 0; i
< len
; i
++)
744 wxLogError( "Bad resource name in font lookup." );
746 } else if (!strcmp(name
, "weight")) {
748 } else if (!strcmp(name
, "style")) {
750 } else if (!strcmp(name
, "family")) {
754 wxLogError( "Bad font macro name." );
758 newstrlen
= strlen(r
);
759 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
760 memcpy(naya
, v
, startpos
);
761 memcpy(naya
+ startpos
, r
, newstrlen
);
762 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
771 /* We have a final value: */
777 //-----------------------------------------------------------------------------
779 //-----------------------------------------------------------------------------
781 class wxFontNameItem
: public wxObject
783 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
785 wxFontNameItem(const char *name
, int id
, int family
);
788 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
789 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
790 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
791 inline char* GetName() {return name
;}
792 inline int GetFamily() {return family
;}
793 inline int GetId() {return id
;}
794 inline bool IsRoman() {return isroman
;}
795 #if defined(__WXDEBUG__)
796 void Dump(ostream
& str
);
802 wxSuffixMap screen
, printing
, afm
;
806 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
808 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
810 name
= copystring(Name
);
814 screen
. Initialize(name
, "Screen");
815 printing
.Initialize(name
, "PostScript");
816 afm
. Initialize(name
, "Afm");
819 wxFontNameItem::~wxFontNameItem()
823 name
= (char *) NULL
;
826 #if defined(__WXDEBUG__)
827 void wxFontNameItem::Dump(ostream
& str
)
829 str
<< "wxFontNameItem(" << name
<< ")";
833 //-----------------------------------------------------------------------------
835 //-----------------------------------------------------------------------------
837 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
839 wxFontNameDirectory::wxFontNameDirectory()
841 table
= new wxHashTable(wxKEY_INTEGER
, 20);
845 wxFontNameDirectory::~wxFontNameDirectory()
847 // Cleanup wxFontNameItems allocated
849 wxNode
*node
= table
->Next();
852 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
854 node
= table
->Next();
859 int wxFontNameDirectory::GetNewFontId()
861 return (nextFontId
--);
864 void wxFontNameDirectory::Initialize()
866 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
867 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
868 Initialize(wxROMAN
, wxROMAN
, "Roman");
869 Initialize(wxMODERN
, wxMODERN
, "Modern");
870 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
871 Initialize(wxSWISS
, wxSWISS
, "Swiss");
872 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
875 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
877 char *fam
, resource
[256];
879 sprintf(resource
, "Family%s", resname
);
880 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
884 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
885 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
886 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
887 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
888 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
889 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
890 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
891 delete[] fam
; // free resource
893 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
896 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
900 // font exists -> return id
901 if ( (id
= GetFontId(name
)) ) return id
;
904 Initialize(id
=GetNewFontId(), family
, name
);
908 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
910 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
912 return item
->GetScreenName(weight
, style
);
914 // font does not exist
915 return (char *) NULL
;
918 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
920 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
922 return item
->GetPostScriptName(weight
, style
);
924 // font does not exist
925 return (char *) NULL
;
928 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
930 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
932 return item
->GetAFMName(weight
, style
);
933 // font does not exist
934 return (char *) NULL
;
937 char *wxFontNameDirectory::GetFontName(int fontid
)
939 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
941 return item
->GetName();
943 // font does not exist
944 return (char *) NULL
;
947 int wxFontNameDirectory::GetFontId(const char *name
)
953 while ( (node
= table
->Next()) )
955 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
956 if (!strcmp(name
, item
->name
))
960 // font does not exist
964 int wxFontNameDirectory::GetFamily(int fontid
)
966 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
971 // font does not exist