]>
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"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 extern wxFontNameDirectory
*wxTheFontNameDirectory
;
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class wxFontRefData
: public wxObjectRefData
33 wxFontRefData( const wxFontRefData
& data
);
36 wxList m_scaled_xfonts
;
38 int m_family
, m_style
, m_weight
;
49 wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER
)
51 m_byXFontName
= FALSE
;
58 m_font
= (GdkFont
*) NULL
;
61 wxFontRefData::wxFontRefData( const wxFontRefData
& data
) : m_scaled_xfonts(wxKEY_INTEGER
)
63 m_byXFontName
= FALSE
;
64 m_pointSize
= data
.m_pointSize
;
65 m_family
= data
.m_family
;
66 m_style
= data
.m_style
;
67 m_weight
= data
.m_weight
;
68 m_underlined
= data
.m_underlined
;
69 m_fontId
= data
.m_fontId
;
70 m_faceName
= data
.m_faceName
;
71 m_font
= (GdkFont
*) NULL
;
72 if (data
.m_font
) m_font
= gdk_font_ref( data
.m_font
);
75 wxFontRefData::~wxFontRefData()
77 wxNode
*node
= m_scaled_xfonts
.First();
80 GdkFont
*font
= (GdkFont
*)node
->Data();
81 wxNode
*next
= node
->Next();
82 gdk_font_unref( font
);
85 if (m_font
) gdk_font_unref( m_font
);
88 //-----------------------------------------------------------------------------
90 #define M_FONTDATA ((wxFontRefData *)m_refData)
92 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
96 if (wxTheFontList
) wxTheFontList
->Append( this );
99 wxFont::wxFont( char *xFontName
)
101 if (!xFontName
) return;
103 m_refData
= new wxFontRefData();
105 M_FONTDATA
->m_byXFontName
= TRUE
;
106 M_FONTDATA
->m_font
= gdk_font_load( xFontName
);
109 wxFont::wxFont( int pointSize
, int family
, int style
, int weight
, bool underlined
= FALSE
,
110 const wxString
& face
= wxEmptyString
)
112 m_refData
= new wxFontRefData();
114 if (family
== wxDEFAULT
) family
= wxSWISS
;
115 M_FONTDATA
->m_family
= family
;
119 M_FONTDATA
->m_faceName
= face
;
120 M_FONTDATA
->m_fontId
= wxTheFontNameDirectory
->FindOrCreateFontId( face
, family
);
121 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
125 M_FONTDATA
->m_fontId
= family
;
126 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( family
);
129 if (style
== wxDEFAULT
) style
= wxNORMAL
;
130 M_FONTDATA
->m_style
= style
;
131 if (weight
== wxDEFAULT
) weight
= wxNORMAL
;
132 M_FONTDATA
->m_weight
= weight
;
133 if (pointSize
== wxDEFAULT
) pointSize
= 12;
134 M_FONTDATA
->m_pointSize
= pointSize
;
135 M_FONTDATA
->m_underlined
= underlined
;
137 if (wxTheFontList
) wxTheFontList
->Append( this );
141 wxFont::wxFont( const wxFont
& font
)
145 if (wxTheFontList
) wxTheFontList
->Append( this );
150 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
153 wxFont
& wxFont::operator = ( const wxFont
& font
)
155 if (*this == font
) return (*this);
160 bool wxFont::operator == ( const wxFont
& font
)
162 return m_refData
== font
.m_refData
;
165 bool wxFont::operator != ( const wxFont
& font
)
167 return m_refData
!= font
.m_refData
;
170 bool wxFont::Ok() const
172 return (m_refData
!= NULL
);
175 int wxFont::GetPointSize() const
177 wxCHECK_MSG( Ok(), 0, "invalid font" );
179 return M_FONTDATA
->m_pointSize
;
182 wxString
wxFont::GetFaceName() const
184 wxCHECK_MSG( Ok(), "", "invalid font" );
186 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
190 int wxFont::GetFamily() const
192 wxCHECK_MSG( Ok(), 0, "invalid font" );
194 return M_FONTDATA
->m_family
;
197 wxString
wxFont::GetFamilyString() const
199 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
201 switch (M_FONTDATA
->m_family
)
203 case wxDECORATIVE
: return wxString("wxDECORATIVE");
204 case wxROMAN
: return wxString("wxROMAN");
205 case wxSCRIPT
: return wxString("wxSCRIPT");
206 case wxSWISS
: return wxString("wxSWISS");
207 case wxMODERN
: return wxString("wxMODERN");
208 case wxTELETYPE
: return wxString("wxTELETYPE");
209 default: return "wxDEFAULT";
215 int wxFont::GetFontId() const
217 wxCHECK_MSG( Ok(), 0, "invalid font" );
219 return M_FONTDATA
->m_fontId
; // stub
222 int wxFont::GetStyle() const
224 wxCHECK_MSG( Ok(), 0, "invalid font" );
226 return M_FONTDATA
->m_style
;
229 wxString
wxFont::GetStyleString() const
231 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
233 switch (M_FONTDATA
->m_style
)
235 case wxNORMAL
: return wxString("wxNORMAL");
236 case wxSLANT
: return wxString("wxSLANT");
237 case wxITALIC
: return wxString("wxITALIC");
238 default: return wxString("wxDEFAULT");
241 return wxString("wxDEFAULT");
244 int wxFont::GetWeight() const
246 wxCHECK_MSG( Ok(), 0, "invalid font" );
248 return M_FONTDATA
->m_weight
;
251 wxString
wxFont::GetWeightString() const
253 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
255 switch (M_FONTDATA
->m_weight
)
257 case wxNORMAL
: return wxString("wxNORMAL");
258 case wxBOLD
: return wxString("wxBOLD");
259 case wxLIGHT
: return wxString("wxLIGHT");
260 default: return wxString("wxDEFAULT");
263 return wxString("wxDEFAULT");
266 bool wxFont::GetUnderlined() const
268 wxCHECK_MSG( Ok(), FALSE
, "invalid font" );
270 return M_FONTDATA
->m_underlined
;
273 void wxFont::Unshare()
277 m_refData
= new wxFontRefData();
281 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
287 void wxFont::SetPointSize(int pointSize
)
291 M_FONTDATA
->m_pointSize
= pointSize
;
294 void wxFont::SetFamily(int family
)
298 M_FONTDATA
->m_family
= family
;
301 void wxFont::SetStyle(int style
)
305 M_FONTDATA
->m_style
= style
;
308 void wxFont::SetWeight(int weight
)
312 M_FONTDATA
->m_weight
= weight
;
315 void wxFont::SetFaceName(const wxString
& faceName
)
319 M_FONTDATA
->m_faceName
= faceName
;
322 void wxFont::SetUnderlined(bool underlined
)
326 M_FONTDATA
->m_underlined
= underlined
;
329 //-----------------------------------------------------------------------------
330 // get internal representation of font
331 //-----------------------------------------------------------------------------
333 // local help function
334 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
335 int style
, int weight
,
338 GdkFont
*wxFont::GetInternalFont(float scale
) const
342 wxFAIL_MSG( "invalid font" );
343 return (GdkFont
*) NULL
;
346 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
348 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
349 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
350 GdkFont
*font
= (GdkFont
*) NULL
;
352 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
355 font
= (GdkFont
*)node
->Data();
360 if (int_scale == 100) printf( "int_scale.\n" );
361 if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
362 if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
363 if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
364 if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
366 if ((int_scale
== 100) &&
367 (M_FONTDATA
->m_family
== wxSWISS
) &&
368 (M_FONTDATA
->m_style
== wxNORMAL
) &&
369 (M_FONTDATA
->m_pointSize
== 12) &&
370 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
371 (M_FONTDATA
->m_underlined
== FALSE
))
373 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
377 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
378 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
380 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
383 printf("could not load any font");
384 // wxError("could not load any font", "wxFont");
388 //-----------------------------------------------------------------------------
389 // local utilities to find a X font
390 //-----------------------------------------------------------------------------
392 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
393 int weight
, bool WXUNUSED(underlined
))
396 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
399 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
400 sprintf(buffer
, name
, point_size
);
402 return gdk_font_load( buffer
);
405 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
406 int style
, int weight
,
411 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
414 // search up and down by stepsize 10
415 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
416 int min_size
= point_size
- 20 * (1 + (point_size
/180));
419 // Search for smaller size (approx.)
420 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
421 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
422 // Search for larger size (approx.)
423 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
424 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
425 // Try default family
426 if (!font
&& fontid
!= wxDEFAULT
)
427 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
431 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
437 //-----------------------------------------------------------------------------
438 // face names and index functions
439 //-----------------------------------------------------------------------------
441 static char *font_defaults
[] = {
442 "FamilyDefault", "Default",
443 "FamilyRoman", "Roman",
444 "FamilyDecorative", "Decorative",
445 "FamilyModern", "Modern",
446 "FamilyTeletype", "Teletype",
447 "FamilySwiss", "Swiss",
448 "FamilyScript", "Script",
454 "AfmItalic", "${AfmSlant}",
458 "AfmHelvetica", "Helv",
459 "AfmCourier", "Cour",
461 "Afm___", "${AfmTimes,$[weight],$[style]}",
463 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
464 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
465 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
466 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
467 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
469 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
470 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
472 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
474 "PostScriptMediumStraight", "",
475 "PostScriptMediumItalic", "-Oblique",
476 "PostScriptMediumSlant", "-Oblique",
477 "PostScriptLightStraight", "",
478 "PostScriptLightItalic", "-Oblique",
479 "PostScriptLightSlant", "-Oblique",
480 "PostScriptBoldStraight", "-Bold",
481 "PostScriptBoldItalic", "-BoldOblique",
482 "PostScriptBoldSlant", "-BoldOblique",
484 #if WX_NORMALIZED_PS_FONTS
485 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
487 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
488 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
491 "PostScriptTimesMedium", "",
492 "PostScriptTimesLight", "",
493 "PostScriptTimesBold", "Bold",
495 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
496 "PostScriptTimesMediumStraight", "Times-Roman",
497 "PostScriptTimesLightStraight", "Times-Roman",
498 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
499 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
501 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
502 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
504 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
506 #if !WX_NORMALIZED_PS_FONTS
507 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
510 "ScreenMedium", "medium",
511 "ScreenBold", "bold",
512 "ScreenLight", "light",
513 "ScreenStraight", "r",
517 "ScreenDefaultBase", "misc-fixed",
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
)
551 case wxBOLD
: return wxWEIGHT_BOLD
;
552 case wxLIGHT
: return wxWEIGHT_LIGHT
;
554 default: return wxWEIGHT_NORMAL
;
558 static int SCoordinate(int s
)
561 case wxITALIC
: return wxSTYLE_ITALIC
;
562 case wxSLANT
: return wxSTYLE_SLANT
;
564 default: return wxSTYLE_NORMAL
;
568 //-----------------------------------------------------------------------------
570 //-----------------------------------------------------------------------------
576 inline char *GetName(int weight
, int style
)
578 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
581 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
582 void Initialize(const char *, const char *);
586 #define wxGetResource(a, b, c) 0
589 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
592 char resource
[1024], **defaults
, *internal
;
597 internal
= (char *) NULL
;
599 for (i
= 0; i
< k
; i
++) {
600 strcpy(resource
, prefix
);
601 for (j
= 0; j
< count
; j
++) {
603 strcat(resource
, names
[j
]);
605 strcat(resource
, "_");
607 if (wxGetResource(wxAPP_CLASS
, (char *)resource
, v
))
610 defaults
= font_defaults
;
612 if (!strcmp(*defaults
, resource
)) {
613 internal
= defaults
[1];
621 *v
= copystring(internal
);
624 wxSuffixMap::~wxSuffixMap()
628 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
629 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
632 map
[k
][j
] = (char *) NULL
;
636 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
638 const char *weight
, *style
;
641 const char *names
[3];
643 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++) {
645 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
646 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
648 default: weight
= "Bold";
650 for (j
= 0; j
< wxNUM_STYLES
; j
++) {
652 case wxSTYLE_NORMAL
: style
= "Straight"; break;
653 case wxSTYLE_ITALIC
: style
= "Italic"; break;
655 default: style
= "Slant";
661 SearchResource(devresname
, names
, 3, &v
);
663 /* Expand macros in the found string: */
665 int len
, closer
= 0, startpos
= 0;
667 len
= (v
? strlen(v
) : 0);
668 for (i
= 0; i
< len
; i
++) {
669 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{'))) {
671 closer
= (v
[i
+1] == '[') ? ']' : '}';
673 } else if (v
[i
] == closer
) {
675 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
678 name
= v
+ startpos
+ 2;
685 for (i
= 0, count
= 1; name
[i
]; i
++)
691 names
= new char*[count
];
693 for (i
= 0, count
= 1; i
< len
; i
++)
694 if (name
[i
] == ',') {
695 names
[count
++] = name
+ i
+ 1;
699 SearchResource("", (const char **)names
, count
, (char **)&r
);
704 for (i
= 0; i
< len
; i
++)
708 printf("Bad resource name \"%s\" in font lookup\n", name
);
710 } else if (!strcmp(name
, "weight")) {
712 } else if (!strcmp(name
, "style")) {
714 } else if (!strcmp(name
, "family")) {
718 printf("Bad font macro name \"%s\"\n", name
);
722 newstrlen
= strlen(r
);
723 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
724 memcpy(naya
, v
, startpos
);
725 memcpy(naya
+ startpos
, r
, newstrlen
);
726 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
735 /* We have a final value: */
741 //-----------------------------------------------------------------------------
743 //-----------------------------------------------------------------------------
745 class wxFontNameItem
: public wxObject
747 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
749 wxFontNameItem(const char *name
, int id
, int family
);
752 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
753 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
754 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
755 inline char* GetName() {return name
;}
756 inline int GetFamily() {return family
;}
757 inline int GetId() {return id
;}
758 inline bool IsRoman() {return isroman
;}
759 #if defined(__WXDEBUG__)
760 void Dump(ostream
& str
);
766 wxSuffixMap screen
, printing
, afm
;
770 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
772 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
774 name
= copystring(Name
);
778 screen
. Initialize(name
, "Screen");
779 printing
.Initialize(name
, "PostScript");
780 afm
. Initialize(name
, "Afm");
783 wxFontNameItem::~wxFontNameItem()
787 name
= (char *) NULL
;
790 #if defined(__WXDEBUG__)
791 void wxFontNameItem::Dump(ostream
& str
)
793 str
<< "wxFontNameItem(" << name
<< ")";
797 //-----------------------------------------------------------------------------
799 //-----------------------------------------------------------------------------
801 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
803 wxFontNameDirectory::wxFontNameDirectory()
805 table
= new wxHashTable(wxKEY_INTEGER
, 20);
809 wxFontNameDirectory::~wxFontNameDirectory()
811 // Cleanup wxFontNameItems allocated
813 wxNode
*node
= table
->Next();
816 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
818 node
= table
->Next();
823 int wxFontNameDirectory::GetNewFontId()
825 return (nextFontId
--);
828 void wxFontNameDirectory::Initialize()
830 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
831 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
832 Initialize(wxROMAN
, wxROMAN
, "Roman");
833 Initialize(wxMODERN
, wxMODERN
, "Modern");
834 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
835 Initialize(wxSWISS
, wxSWISS
, "Swiss");
836 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
839 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
841 char *fam
, resource
[256];
843 sprintf(resource
, "Family%s", resname
);
844 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
847 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
848 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
849 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
850 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
851 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
852 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
853 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
854 delete[] fam
; // free resource
856 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
859 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
863 // font exists -> return id
864 if ( (id
= GetFontId(name
)) ) return id
;
867 Initialize(id
=GetNewFontId(), family
, name
);
871 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
873 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
875 return item
->GetScreenName(weight
, style
);
877 // font does not exist
878 return (char *) NULL
;
881 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
883 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
885 return item
->GetPostScriptName(weight
, style
);
887 // font does not exist
888 return (char *) NULL
;
891 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
893 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
895 return item
->GetAFMName(weight
, style
);
896 // font does not exist
897 return (char *) NULL
;
900 char *wxFontNameDirectory::GetFontName(int fontid
)
902 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
904 return item
->GetName();
906 // font does not exist
907 return (char *) NULL
;
910 int wxFontNameDirectory::GetFontId(const char *name
)
916 while ( (node
= table
->Next()) )
918 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
919 if (!strcmp(name
, item
->name
))
923 // font does not exist
927 int wxFontNameDirectory::GetFamily(int fontid
)
929 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
934 // font does not exist