]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/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",
514 "ScreenDefaultBase", "misc-fixed",
516 "ScreenDefaultBase", "*-times",
518 "ScreenRomanBase", "*-times",
519 "ScreenDecorativeBase", "*-helvetica",
520 "ScreenModernBase", "*-courier",
521 "ScreenTeletypeBase", "*-lucidatypewriter",
522 "ScreenSwissBase", "*-lucida",
523 "ScreenScriptBase", "*-zapfchancery",
525 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
526 "-normal-*-*-%d-*-*-*-*-*-*",
529 "-${ScreenDefaultBase}${ScreenStdSuffix}",
531 "-${ScreenRomanBase}${ScreenStdSuffix}",
532 "ScreenDecorative__",
533 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
535 "-${ScreenModernBase}${ScreenStdSuffix}",
537 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
539 "-${ScreenSwissBase}${ScreenStdSuffix}",
541 "-${ScreenScriptBase}${ScreenStdSuffix}",
545 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
546 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
548 static int WCoordinate(int w
)
552 case wxBOLD
: return wxWEIGHT_BOLD
;
553 case wxLIGHT
: return wxWEIGHT_LIGHT
;
555 default: return wxWEIGHT_NORMAL
;
559 static int SCoordinate(int s
)
563 case wxITALIC
: return wxSTYLE_ITALIC
;
564 case wxSLANT
: return wxSTYLE_SLANT
;
566 default: return wxSTYLE_NORMAL
;
570 //-----------------------------------------------------------------------------
572 //-----------------------------------------------------------------------------
579 inline char *GetName(int weight
, int style
)
581 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
584 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
585 void Initialize(const char *, const char *);
588 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
591 char resource
[1024], **defaults
, *internal
;
596 internal
= (char *) NULL
;
598 for (i
= 0; i
< k
; i
++)
600 strcpy(resource
, prefix
);
601 for (j
= 0; j
< count
; j
++)
603 /* upon failure to find a matching fontname
604 in the default fonts above, we substitute more
605 and more values by _ so that at last ScreenMyFontBoldNormal
606 would turn into Screen___ and this will then get
607 converted to -${ScreenDefaultBase}${ScreenStdSuffix}
611 strcat(resource
, names
[j
]);
613 strcat(resource
, "_");
616 /* we previously search the Xt-resources here */
620 defaults
= font_defaults
;
623 if (!strcmp(*defaults
, resource
))
625 internal
= defaults
[1];
635 if ((strcmp(internal
,"-${ScreenDefaultBase}${ScreenStdSuffix}") == 0) &&
636 (strcmp(names
[0], "Default") != 0))
638 /* we did not find any font name in the standard list.
639 this can (hopefully does) mean that someone supplied
640 the facename in the wxFont constructor so we insert
643 strcpy( resource
,"-*-" ); /* any producer */
644 strcat( resource
, names
[0] ); /* facename */
645 strcat( resource
, "${ScreenStdSuffix}" ); /* add size params later on */
646 *v
= copystring(resource
);
650 *v
= copystring(internal
);
655 wxSuffixMap::~wxSuffixMap()
659 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
660 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
664 map
[k
][j
] = (char *) NULL
;
668 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
670 const char *weight
, *style
;
673 const char *names
[3];
675 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++)
679 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
680 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
682 default: weight
= "Bold";
684 for (j
= 0; j
< wxNUM_STYLES
; j
++)
688 case wxSTYLE_NORMAL
: style
= "Straight"; break;
689 case wxSTYLE_ITALIC
: style
= "Italic"; break;
691 default: style
= "Slant";
697 SearchResource(devresname
, names
, 3, &v
);
699 /* Expand macros in the found string: */
701 int len
, closer
= 0, startpos
= 0;
703 len
= (v
? strlen(v
) : 0);
704 for (i
= 0; i
< len
; i
++)
706 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{')))
709 closer
= (v
[i
+1] == '[') ? ']' : '}';
712 else if (v
[i
] == closer
)
715 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
718 name
= v
+ startpos
+ 2;
726 for (i
= 0, count
= 1; name
[i
]; i
++)
732 names
= new char*[count
];
734 for (i
= 0, count
= 1; i
< len
; i
++)
737 names
[count
++] = name
+ i
+ 1;
741 SearchResource("", (const char **)names
, count
, (char **)&r
);
747 for (i
= 0; i
< len
; i
++)
751 wxLogError( "Bad resource name in font lookup." );
753 } else if (!strcmp(name
, "weight")) {
755 } else if (!strcmp(name
, "style")) {
757 } else if (!strcmp(name
, "family")) {
761 wxLogError( "Bad font macro name." );
765 newstrlen
= strlen(r
);
766 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
767 memcpy(naya
, v
, startpos
);
768 memcpy(naya
+ startpos
, r
, newstrlen
);
769 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
778 /* We have a final value: */
784 //-----------------------------------------------------------------------------
786 //-----------------------------------------------------------------------------
788 class wxFontNameItem
: public wxObject
790 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
792 wxFontNameItem(const char *name
, int id
, int family
);
795 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
796 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
797 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
798 inline char* GetName() {return name
;}
799 inline int GetFamily() {return family
;}
800 inline int GetId() {return id
;}
801 inline bool IsRoman() {return isroman
;}
802 #if defined(__WXDEBUG__)
803 void Dump(ostream
& str
);
809 wxSuffixMap screen
, printing
, afm
;
813 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
815 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
817 name
= copystring(Name
);
821 screen
. Initialize(name
, "Screen");
822 printing
.Initialize(name
, "PostScript");
823 afm
. Initialize(name
, "Afm");
826 wxFontNameItem::~wxFontNameItem()
830 name
= (char *) NULL
;
833 #if defined(__WXDEBUG__)
834 void wxFontNameItem::Dump(ostream
& str
)
836 str
<< "wxFontNameItem(" << name
<< ")";
840 //-----------------------------------------------------------------------------
842 //-----------------------------------------------------------------------------
844 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
846 wxFontNameDirectory::wxFontNameDirectory()
848 table
= new wxHashTable(wxKEY_INTEGER
, 20);
852 wxFontNameDirectory::~wxFontNameDirectory()
854 // Cleanup wxFontNameItems allocated
856 wxNode
*node
= table
->Next();
859 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
861 node
= table
->Next();
866 int wxFontNameDirectory::GetNewFontId()
868 return (nextFontId
--);
871 void wxFontNameDirectory::Initialize()
873 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
874 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
875 Initialize(wxROMAN
, wxROMAN
, "Roman");
876 Initialize(wxMODERN
, wxMODERN
, "Modern");
877 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
878 Initialize(wxSWISS
, wxSWISS
, "Swiss");
879 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
882 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
884 char *fam
, resource
[256];
886 sprintf(resource
, "Family%s", resname
);
887 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
891 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
892 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
893 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
894 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
895 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
896 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
897 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
898 delete[] fam
; // free resource
900 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
903 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
907 // font exists -> return id
908 if ( (id
= GetFontId(name
)) ) return id
;
911 Initialize(id
=GetNewFontId(), family
, name
);
915 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
917 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
919 return item
->GetScreenName(weight
, style
);
921 // font does not exist
922 return (char *) NULL
;
925 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
927 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
929 return item
->GetPostScriptName(weight
, style
);
931 // font does not exist
932 return (char *) NULL
;
935 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
937 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
939 return item
->GetAFMName(weight
, style
);
940 // font does not exist
941 return (char *) NULL
;
944 char *wxFontNameDirectory::GetFontName(int fontid
)
946 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
948 return item
->GetName();
950 // font does not exist
951 return (char *) NULL
;
954 int wxFontNameDirectory::GetFontId(const char *name
)
960 while ( (node
= table
->Next()) )
962 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
963 if (!strcmp(name
, item
->name
))
967 // font does not exist
971 int wxFontNameDirectory::GetFamily(int fontid
)
973 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
978 // font does not exist