]>
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"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 extern wxFontNameDirectory
*wxTheFontNameDirectory
;
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 class wxFontRefData
: public wxObjectRefData
36 wxFontRefData( const wxFontRefData
& data
);
39 wxList m_scaled_xfonts
;
41 int m_family
, m_style
, m_weight
;
52 wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER
)
54 m_byXFontName
= FALSE
;
61 m_font
= (GdkFont
*) NULL
;
64 wxFontRefData::wxFontRefData( const wxFontRefData
& data
) : m_scaled_xfonts(wxKEY_INTEGER
)
66 m_byXFontName
= FALSE
;
67 m_pointSize
= data
.m_pointSize
;
68 m_family
= data
.m_family
;
69 m_style
= data
.m_style
;
70 m_weight
= data
.m_weight
;
71 m_underlined
= data
.m_underlined
;
72 m_fontId
= data
.m_fontId
;
73 m_faceName
= data
.m_faceName
;
74 m_font
= (GdkFont
*) NULL
;
75 if (data
.m_font
) m_font
= gdk_font_ref( data
.m_font
);
78 wxFontRefData::~wxFontRefData()
80 wxNode
*node
= m_scaled_xfonts
.First();
83 GdkFont
*font
= (GdkFont
*)node
->Data();
84 wxNode
*next
= node
->Next();
85 gdk_font_unref( font
);
88 if (m_font
) gdk_font_unref( m_font
);
91 //-----------------------------------------------------------------------------
93 #define M_FONTDATA ((wxFontRefData *)m_refData)
95 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
99 if (wxTheFontList
) wxTheFontList
->Append( this );
102 wxFont::wxFont( char *xFontName
)
104 if (!xFontName
) return;
106 m_refData
= new wxFontRefData();
108 M_FONTDATA
->m_byXFontName
= TRUE
;
109 M_FONTDATA
->m_font
= gdk_font_load( xFontName
);
112 wxFont::wxFont( int pointSize
, int family
, int style
, int weight
, bool underlined
= FALSE
,
113 const wxString
& face
= wxEmptyString
)
115 m_refData
= new wxFontRefData();
117 if (family
== wxDEFAULT
) family
= wxSWISS
;
118 M_FONTDATA
->m_family
= family
;
122 M_FONTDATA
->m_faceName
= face
;
123 M_FONTDATA
->m_fontId
= wxTheFontNameDirectory
->FindOrCreateFontId( face
, family
);
124 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
128 M_FONTDATA
->m_fontId
= family
;
129 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
132 if (style
== wxDEFAULT
) style
= wxNORMAL
;
133 M_FONTDATA
->m_style
= style
;
134 if (weight
== wxDEFAULT
) weight
= wxNORMAL
;
135 M_FONTDATA
->m_weight
= weight
;
136 if (pointSize
== wxDEFAULT
) pointSize
= 12;
137 M_FONTDATA
->m_pointSize
= pointSize
;
138 M_FONTDATA
->m_underlined
= underlined
;
140 if (wxTheFontList
) wxTheFontList
->Append( this );
144 wxFont::wxFont( const wxFont
& font
)
148 if (wxTheFontList
) wxTheFontList
->Append( this );
153 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
156 wxFont
& wxFont::operator = ( const wxFont
& font
)
158 if (*this == font
) return (*this);
163 bool wxFont::operator == ( const wxFont
& font
)
165 return m_refData
== font
.m_refData
;
168 bool wxFont::operator != ( const wxFont
& font
)
170 return m_refData
!= font
.m_refData
;
173 bool wxFont::Ok() const
175 return (m_refData
!= NULL
);
178 int wxFont::GetPointSize() const
180 wxCHECK_MSG( Ok(), 0, "invalid font" );
182 return M_FONTDATA
->m_pointSize
;
185 wxString
wxFont::GetFaceName() const
187 wxCHECK_MSG( Ok(), "", "invalid font" );
189 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
193 int wxFont::GetFamily() const
195 wxCHECK_MSG( Ok(), 0, "invalid font" );
197 return M_FONTDATA
->m_family
;
200 wxString
wxFont::GetFamilyString() const
202 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
204 switch (M_FONTDATA
->m_family
)
206 case wxDECORATIVE
: return wxString("wxDECORATIVE");
207 case wxROMAN
: return wxString("wxROMAN");
208 case wxSCRIPT
: return wxString("wxSCRIPT");
209 case wxSWISS
: return wxString("wxSWISS");
210 case wxMODERN
: return wxString("wxMODERN");
211 case wxTELETYPE
: return wxString("wxTELETYPE");
212 default: return "wxDEFAULT";
218 int wxFont::GetFontId() const
220 wxCHECK_MSG( Ok(), 0, "invalid font" );
222 return M_FONTDATA
->m_fontId
; // stub
225 int wxFont::GetStyle() const
227 wxCHECK_MSG( Ok(), 0, "invalid font" );
229 return M_FONTDATA
->m_style
;
232 wxString
wxFont::GetStyleString() const
234 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
236 switch (M_FONTDATA
->m_style
)
238 case wxNORMAL
: return wxString("wxNORMAL");
239 case wxSLANT
: return wxString("wxSLANT");
240 case wxITALIC
: return wxString("wxITALIC");
241 default: return wxString("wxDEFAULT");
244 return wxString("wxDEFAULT");
247 int wxFont::GetWeight() const
249 wxCHECK_MSG( Ok(), 0, "invalid font" );
251 return M_FONTDATA
->m_weight
;
254 wxString
wxFont::GetWeightString() const
256 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
258 switch (M_FONTDATA
->m_weight
)
260 case wxNORMAL
: return wxString("wxNORMAL");
261 case wxBOLD
: return wxString("wxBOLD");
262 case wxLIGHT
: return wxString("wxLIGHT");
263 default: return wxString("wxDEFAULT");
266 return wxString("wxDEFAULT");
269 bool wxFont::GetUnderlined() const
271 wxCHECK_MSG( Ok(), FALSE
, "invalid font" );
273 return M_FONTDATA
->m_underlined
;
276 void wxFont::Unshare()
280 m_refData
= new wxFontRefData();
284 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
290 void wxFont::SetPointSize(int pointSize
)
294 M_FONTDATA
->m_pointSize
= pointSize
;
297 void wxFont::SetFamily(int family
)
301 M_FONTDATA
->m_family
= family
;
304 void wxFont::SetStyle(int style
)
308 M_FONTDATA
->m_style
= style
;
311 void wxFont::SetWeight(int weight
)
315 M_FONTDATA
->m_weight
= weight
;
318 void wxFont::SetFaceName(const wxString
& faceName
)
322 M_FONTDATA
->m_faceName
= faceName
;
325 void wxFont::SetUnderlined(bool underlined
)
329 M_FONTDATA
->m_underlined
= underlined
;
332 //-----------------------------------------------------------------------------
333 // get internal representation of font
334 //-----------------------------------------------------------------------------
336 // local help function
337 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
338 int style
, int weight
,
341 GdkFont
*wxFont::GetInternalFont(float scale
) const
345 wxFAIL_MSG( "invalid font" );
346 return (GdkFont
*) NULL
;
349 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
351 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
352 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
353 GdkFont
*font
= (GdkFont
*) NULL
;
355 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
358 font
= (GdkFont
*)node
->Data();
362 if ((int_scale
== 100) &&
363 (M_FONTDATA
->m_family
== wxSWISS
) &&
364 (M_FONTDATA
->m_style
== wxNORMAL
) &&
365 (M_FONTDATA
->m_pointSize
== 12) &&
366 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
367 (M_FONTDATA
->m_underlined
== FALSE
))
369 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
373 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
374 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
376 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
379 wxLogError("could not load any font");
384 //-----------------------------------------------------------------------------
385 // local utilities to find a X font
386 //-----------------------------------------------------------------------------
388 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
389 int weight
, bool WXUNUSED(underlined
))
392 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
395 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
396 sprintf(buffer
, name
, point_size
);
398 return gdk_font_load( buffer
);
401 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
402 int style
, int weight
,
407 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
410 // search up and down by stepsize 10
411 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
412 int min_size
= point_size
- 20 * (1 + (point_size
/180));
415 // Search for smaller size (approx.)
416 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
417 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
418 // Search for larger size (approx.)
419 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
420 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
421 // Try default family
422 if (!font
&& fontid
!= wxDEFAULT
)
423 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
427 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
433 //-----------------------------------------------------------------------------
434 // face names and index functions
435 //-----------------------------------------------------------------------------
437 static char *font_defaults
[] = {
438 "FamilyDefault", "Default",
439 "FamilyRoman", "Roman",
440 "FamilyDecorative", "Decorative",
441 "FamilyModern", "Modern",
442 "FamilyTeletype", "Teletype",
443 "FamilySwiss", "Swiss",
444 "FamilyScript", "Script",
450 "AfmItalic", "${AfmSlant}",
454 "AfmHelvetica", "Helv",
455 "AfmCourier", "Cour",
457 "Afm___", "${AfmTimes,$[weight],$[style]}",
459 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
460 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
461 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
462 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
463 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
465 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
466 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
468 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
470 "PostScriptMediumStraight", "",
471 "PostScriptMediumItalic", "-Oblique",
472 "PostScriptMediumSlant", "-Oblique",
473 "PostScriptLightStraight", "",
474 "PostScriptLightItalic", "-Oblique",
475 "PostScriptLightSlant", "-Oblique",
476 "PostScriptBoldStraight", "-Bold",
477 "PostScriptBoldItalic", "-BoldOblique",
478 "PostScriptBoldSlant", "-BoldOblique",
480 #if WX_NORMALIZED_PS_FONTS
481 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
483 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
484 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
487 "PostScriptTimesMedium", "",
488 "PostScriptTimesLight", "",
489 "PostScriptTimesBold", "Bold",
491 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
492 "PostScriptTimesMediumStraight", "Times-Roman",
493 "PostScriptTimesLightStraight", "Times-Roman",
494 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
495 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
497 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
498 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
500 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
502 #if !WX_NORMALIZED_PS_FONTS
503 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
506 "ScreenMedium", "medium",
507 "ScreenBold", "bold",
508 "ScreenLight", "light",
509 "ScreenStraight", "r",
513 "ScreenDefaultBase", "misc-fixed",
514 "ScreenRomanBase", "*-times",
515 "ScreenDecorativeBase", "*-helvetica",
516 "ScreenModernBase", "*-courier",
517 "ScreenTeletypeBase", "*-lucidatypewriter",
518 "ScreenSwissBase", "*-lucida",
519 "ScreenScriptBase", "*-zapfchancery",
521 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
522 "-normal-*-*-%d-*-*-*-*-*-*",
525 "-${ScreenDefaultBase}${ScreenStdSuffix}",
527 "-${ScreenRomanBase}${ScreenStdSuffix}",
528 "ScreenDecorative__",
529 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
531 "-${ScreenModernBase}${ScreenStdSuffix}",
533 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
535 "-${ScreenSwissBase}${ScreenStdSuffix}",
537 "-${ScreenScriptBase}${ScreenStdSuffix}",
541 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
542 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
544 static int WCoordinate(int w
)
548 case wxBOLD
: return wxWEIGHT_BOLD
;
549 case wxLIGHT
: return wxWEIGHT_LIGHT
;
551 default: return wxWEIGHT_NORMAL
;
555 static int SCoordinate(int s
)
559 case wxITALIC
: return wxSTYLE_ITALIC
;
560 case wxSLANT
: return wxSTYLE_SLANT
;
562 default: return wxSTYLE_NORMAL
;
566 //-----------------------------------------------------------------------------
568 //-----------------------------------------------------------------------------
575 inline char *GetName(int weight
, int style
)
577 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
580 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
581 void Initialize(const char *, const char *);
584 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
587 char resource
[1024], **defaults
, *internal
;
592 internal
= (char *) NULL
;
594 for (i
= 0; i
< k
; i
++)
596 strcpy(resource
, prefix
);
597 for (j
= 0; j
< count
; j
++)
599 /* upon failure to find a matching fontname
600 in the default fonts above, we substitute more
601 and more values by _ so that at last ScreenMyFontBoldNormal
602 would turn into Screen___ and this will then get
603 converted to -${ScreenDefaultBase}${ScreenStdSuffix}
607 strcat(resource
, names
[j
]);
609 strcat(resource
, "_");
612 /* we previously search the Xt-resources here */
616 defaults
= font_defaults
;
619 if (!strcmp(*defaults
, resource
))
621 internal
= defaults
[1];
631 if (strcmp(internal
,"-${ScreenDefaultBase}${ScreenStdSuffix}") == 0)
633 /* we did not find any font name in the standard list.
634 this can (hopefully does) mean that someone supplied
635 the facename in the wxFont constructor so we insert
638 strcpy( resource
,"-*-" ); /* any producer */
639 strcat( resource
, names
[0] ); /* facename */
640 strcat( resource
, "${ScreenStdSuffix}" ); /* add size params later on */
641 *v
= copystring(resource
);
645 *v
= copystring(internal
);
650 wxSuffixMap::~wxSuffixMap()
654 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
655 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
659 map
[k
][j
] = (char *) NULL
;
663 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
665 const char *weight
, *style
;
668 const char *names
[3];
670 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++)
674 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
675 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
677 default: weight
= "Bold";
679 for (j
= 0; j
< wxNUM_STYLES
; j
++)
683 case wxSTYLE_NORMAL
: style
= "Straight"; break;
684 case wxSTYLE_ITALIC
: style
= "Italic"; break;
686 default: style
= "Slant";
692 SearchResource(devresname
, names
, 3, &v
);
694 /* Expand macros in the found string: */
696 int len
, closer
= 0, startpos
= 0;
698 len
= (v
? strlen(v
) : 0);
699 for (i
= 0; i
< len
; i
++)
701 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{')))
704 closer
= (v
[i
+1] == '[') ? ']' : '}';
707 else if (v
[i
] == closer
)
710 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
713 name
= v
+ startpos
+ 2;
721 for (i
= 0, count
= 1; name
[i
]; i
++)
727 names
= new char*[count
];
729 for (i
= 0, count
= 1; i
< len
; i
++)
732 names
[count
++] = name
+ i
+ 1;
736 SearchResource("", (const char **)names
, count
, (char **)&r
);
742 for (i
= 0; i
< len
; i
++)
746 wxLogError( "Bad resource name in font lookup." );
748 } else if (!strcmp(name
, "weight")) {
750 } else if (!strcmp(name
, "style")) {
752 } else if (!strcmp(name
, "family")) {
756 wxLogError( "Bad font macro name." );
760 newstrlen
= strlen(r
);
761 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
762 memcpy(naya
, v
, startpos
);
763 memcpy(naya
+ startpos
, r
, newstrlen
);
764 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
773 /* We have a final value: */
779 //-----------------------------------------------------------------------------
781 //-----------------------------------------------------------------------------
783 class wxFontNameItem
: public wxObject
785 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
787 wxFontNameItem(const char *name
, int id
, int family
);
790 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
791 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
792 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
793 inline char* GetName() {return name
;}
794 inline int GetFamily() {return family
;}
795 inline int GetId() {return id
;}
796 inline bool IsRoman() {return isroman
;}
797 #if defined(__WXDEBUG__)
798 void Dump(ostream
& str
);
804 wxSuffixMap screen
, printing
, afm
;
808 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
810 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
812 name
= copystring(Name
);
816 screen
. Initialize(name
, "Screen");
817 printing
.Initialize(name
, "PostScript");
818 afm
. Initialize(name
, "Afm");
821 wxFontNameItem::~wxFontNameItem()
825 name
= (char *) NULL
;
828 #if defined(__WXDEBUG__)
829 void wxFontNameItem::Dump(ostream
& str
)
831 str
<< "wxFontNameItem(" << name
<< ")";
835 //-----------------------------------------------------------------------------
837 //-----------------------------------------------------------------------------
839 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
841 wxFontNameDirectory::wxFontNameDirectory()
843 table
= new wxHashTable(wxKEY_INTEGER
, 20);
847 wxFontNameDirectory::~wxFontNameDirectory()
849 // Cleanup wxFontNameItems allocated
851 wxNode
*node
= table
->Next();
854 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
856 node
= table
->Next();
861 int wxFontNameDirectory::GetNewFontId()
863 return (nextFontId
--);
866 void wxFontNameDirectory::Initialize()
868 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
869 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
870 Initialize(wxROMAN
, wxROMAN
, "Roman");
871 Initialize(wxMODERN
, wxMODERN
, "Modern");
872 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
873 Initialize(wxSWISS
, wxSWISS
, "Swiss");
874 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
877 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
879 char *fam
, resource
[256];
881 sprintf(resource
, "Family%s", resname
);
882 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
886 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
887 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
888 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
889 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
890 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
891 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
892 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
893 delete[] fam
; // free resource
895 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
898 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
902 // font exists -> return id
903 if ( (id
= GetFontId(name
)) ) return id
;
906 Initialize(id
=GetNewFontId(), family
, name
);
910 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
912 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
914 return item
->GetScreenName(weight
, style
);
916 // font does not exist
917 return (char *) NULL
;
920 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
922 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
924 return item
->GetPostScriptName(weight
, style
);
926 // font does not exist
927 return (char *) NULL
;
930 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
932 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
934 return item
->GetAFMName(weight
, style
);
935 // font does not exist
936 return (char *) NULL
;
939 char *wxFontNameDirectory::GetFontName(int fontid
)
941 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
943 return item
->GetName();
945 // font does not exist
946 return (char *) NULL
;
949 int wxFontNameDirectory::GetFontId(const char *name
)
955 while ( (node
= table
->Next()) )
957 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
958 if (!strcmp(name
, item
->name
))
962 // font does not exist
966 int wxFontNameDirectory::GetFamily(int fontid
)
968 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
973 // font does not exist