1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
19 #pragma implementation "font.h"
25 #include "wx/gdicmn.h"
26 #include "wx/tokenzr.h"
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 #if wxUSE_FONTNAMEDIRECTORY
37 extern wxFontNameDirectory
*wxTheFontNameDirectory
;
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 static GdkFont
*wxLoadQueryFont( int pointSize
,
49 const wxString
&facename
,
50 wxFontEncoding encoding
);
52 static GdkFont
*wxLoadQueryNearestFont( int pointSize
,
57 const wxString
&facename
,
58 wxFontEncoding encoding
);
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 class wxFontRefData
: public wxObjectRefData
67 wxFontRefData(int size
= wxDEFAULT
,
68 int family
= wxDEFAULT
,
69 int style
= wxDEFAULT
,
70 int weight
= wxDEFAULT
,
71 bool underlined
= FALSE
,
72 const wxString
& faceName
= wxEmptyString
,
73 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
74 : m_scaled_xfonts(wxKEY_INTEGER
)
76 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
79 wxFontRefData( const wxFontRefData
& data
);
81 virtual ~wxFontRefData();
84 // common part of all ctors
85 void Init(int pointSize
,
90 const wxString
& faceName
,
91 wxFontEncoding encoding
);
94 wxList m_scaled_xfonts
;
102 wxFontEncoding m_encoding
;
110 // ============================================================================
112 // ============================================================================
114 // ----------------------------------------------------------------------------
116 // ----------------------------------------------------------------------------
118 void wxFontRefData::Init(int pointSize
,
123 const wxString
& faceName
,
124 wxFontEncoding encoding
)
126 if (family
== wxDEFAULT
)
131 m_faceName
= faceName
;
133 if (style
== wxDEFAULT
)
138 if (weight
== wxDEFAULT
)
143 if (pointSize
== wxDEFAULT
)
146 m_pointSize
= pointSize
;
148 m_underlined
= underlined
;
149 m_encoding
= encoding
;
151 m_byXFontName
= FALSE
;
152 m_font
= (GdkFont
*) NULL
;
155 wxFontRefData::wxFontRefData( const wxFontRefData
& data
)
156 : m_scaled_xfonts(wxKEY_INTEGER
)
158 Init(data
.m_pointSize
, data
.m_family
, data
.m_style
, data
.m_weight
,
159 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
162 m_font
= gdk_font_ref( data
.m_font
);
165 wxFontRefData::~wxFontRefData()
167 wxNode
*node
= m_scaled_xfonts
.First();
170 GdkFont
*font
= (GdkFont
*)node
->Data();
171 wxNode
*next
= node
->Next();
172 gdk_font_unref( font
);
177 gdk_font_unref( m_font
);
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
189 wxTheFontList
->Append( this );
192 wxFont::wxFont( GdkFont
*font
, char *xFontName
)
197 // VZ: this ctor ddidn't append the font to wxTheFontList before, but
198 // there is no reason to not do it, is there?
201 m_refData
= new wxFontRefData();
203 // M_FONTDATA->m_byXFontName = TRUE;
204 M_FONTDATA
->m_font
= font
;
208 wxString
fontname( xFontName
);
209 wxStringTokenizer
tn( fontname
, _T("-") );
211 tn
.GetNextToken(); // foundry
213 M_FONTDATA
->m_faceName
= tn
.GetNextToken(); // courier
215 tmp
= tn
.GetNextToken().MakeUpper();
216 if (tmp
== _T("BOLD")) M_FONTDATA
->m_weight
= wxBOLD
;
218 tmp
= tn
.GetNextToken().MakeUpper();
219 if (tmp
== _T("I")) M_FONTDATA
->m_style
= wxITALIC
;
220 if (tmp
== _T("O")) M_FONTDATA
->m_style
= wxITALIC
;
222 tn
.GetNextToken(); // set width
223 tn
.GetNextToken(); // ?
224 tn
.GetNextToken(); // pixel size
226 tmp
= tn
.GetNextToken(); // pointsize
227 int num
= wxStrtol (tmp
.c_str(), (wxChar
**) NULL
, 10);
228 M_FONTDATA
->m_pointSize
= num
/ 10;
230 tn
.GetNextToken(); // x-res
231 tn
.GetNextToken(); // y-res
233 tmp
= tn
.GetNextToken().MakeUpper();
234 if (tmp
== _T("M")) M_FONTDATA
->m_family
= wxMODERN
;
235 else if (M_FONTDATA
->m_faceName
== _T("TIMES")) M_FONTDATA
->m_family
= wxROMAN
;
236 else if (M_FONTDATA
->m_faceName
== _T("HELVETICA")) M_FONTDATA
->m_family
= wxSWISS
;
237 else if (M_FONTDATA
->m_faceName
== _T("LUCIDATYPEWRITER")) M_FONTDATA
->m_family
= wxTELETYPE
;
238 else if (M_FONTDATA
->m_faceName
== _T("LUCIDA")) M_FONTDATA
->m_family
= wxDECORATIVE
;
239 else if (M_FONTDATA
->m_faceName
== _T("UTOPIA")) M_FONTDATA
->m_family
= wxSCRIPT
;
242 bool wxFont::Create( int pointSize
,
247 const wxString
& face
,
248 wxFontEncoding encoding
)
250 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
251 underlined
, face
, encoding
);
258 void wxFont::Unshare()
262 m_refData
= new wxFontRefData();
266 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
275 wxTheFontList
->DeleteObject( this );
278 // ----------------------------------------------------------------------------
280 // ----------------------------------------------------------------------------
282 int wxFont::GetPointSize() const
284 wxCHECK_MSG( Ok(), 0, _T("invalid font") );
286 return M_FONTDATA
->m_pointSize
;
289 wxString
wxFont::GetFaceName() const
291 wxCHECK_MSG( Ok(), _T(""), _T("invalid font") );
293 return M_FONTDATA
->m_faceName
;
296 int wxFont::GetFamily() const
298 wxCHECK_MSG( Ok(), 0, _T("invalid font") );
300 return M_FONTDATA
->m_family
;
303 int wxFont::GetStyle() const
305 wxCHECK_MSG( Ok(), 0, _T("invalid font") );
307 return M_FONTDATA
->m_style
;
310 int wxFont::GetWeight() const
312 wxCHECK_MSG( Ok(), 0, _T("invalid font") );
314 return M_FONTDATA
->m_weight
;
317 bool wxFont::GetUnderlined() const
319 wxCHECK_MSG( Ok(), FALSE
, _T("invalid font") );
321 return M_FONTDATA
->m_underlined
;
325 wxFontEncoding
wxFont::GetEncoding() const
327 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, _T("invalid font") );
329 return M_FONTDATA
->m_encoding
;
332 // ----------------------------------------------------------------------------
333 // change font attributes
334 // ----------------------------------------------------------------------------
336 void wxFont::SetPointSize(int pointSize
)
340 M_FONTDATA
->m_pointSize
= pointSize
;
343 void wxFont::SetFamily(int family
)
347 M_FONTDATA
->m_family
= family
;
350 void wxFont::SetStyle(int style
)
354 M_FONTDATA
->m_style
= style
;
357 void wxFont::SetWeight(int weight
)
361 M_FONTDATA
->m_weight
= weight
;
364 void wxFont::SetFaceName(const wxString
& faceName
)
368 M_FONTDATA
->m_faceName
= faceName
;
371 void wxFont::SetUnderlined(bool underlined
)
375 M_FONTDATA
->m_underlined
= underlined
;
378 void wxFont::SetEncoding(wxFontEncoding encoding
)
382 M_FONTDATA
->m_encoding
= encoding
;
385 // ----------------------------------------------------------------------------
386 // get internal representation of font
387 // ----------------------------------------------------------------------------
389 GdkFont
*wxFont::GetInternalFont( float scale
) const
393 wxFAIL_MSG( _T("invalid font") );
395 return (GdkFont
*) NULL
;
398 /* short cut if the special X font constructor has been used */
399 if (M_FONTDATA
->m_byXFontName
)
400 return M_FONTDATA
->m_font
;
402 long int_scale
= long(scale
* 100.0 + 0.5); /* key for fontlist */
403 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
404 GdkFont
*font
= (GdkFont
*) NULL
;
406 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
409 font
= (GdkFont
*)node
->Data();
414 if ((int_scale
== 100) &&
415 (M_FONTDATA
->m_family
== wxSWISS
) &&
416 (M_FONTDATA
->m_style
== wxNORMAL
) &&
417 (M_FONTDATA
->m_pointSize
== 12) &&
418 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
419 (M_FONTDATA
->m_underlined
== FALSE
))
421 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
426 font
= wxLoadQueryNearestFont( point_scale
,
427 M_FONTDATA
->m_family
,
429 M_FONTDATA
->m_weight
,
430 M_FONTDATA
->m_underlined
,
431 M_FONTDATA
->m_faceName
,
432 M_FONTDATA
->m_encoding
);
435 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
440 wxLogError(_T("could not load any font"));
446 //-----------------------------------------------------------------------------
447 // local utilities to find a X font
448 //-----------------------------------------------------------------------------
450 // wow, what's this stuff? Is it used/useful? (VZ)
453 //-----------------------------------------------------------------------------
454 // face names and index functions
455 //-----------------------------------------------------------------------------
457 static char *font_defaults
[] = {
458 "FamilyDefault", "Default",
459 "FamilyRoman", "Roman",
460 "FamilyDecorative", "Decorative",
461 "FamilyModern", "Modern",
462 "FamilyTeletype", "Teletype",
463 "FamilySwiss", "Swiss",
464 "FamilyScript", "Script",
470 "AfmItalic", "${AfmSlant}",
474 "AfmHelvetica", "Helv",
475 "AfmCourier", "Cour",
477 "Afm___", "${AfmTimes,$[weight],$[style]}",
479 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
480 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
481 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
482 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
483 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
485 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
486 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
488 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
490 "PostScriptMediumStraight", "",
491 "PostScriptMediumItalic", "-Oblique",
492 "PostScriptMediumSlant", "-Oblique",
493 "PostScriptLightStraight", "",
494 "PostScriptLightItalic", "-Oblique",
495 "PostScriptLightSlant", "-Oblique",
496 "PostScriptBoldStraight", "-Bold",
497 "PostScriptBoldItalic", "-BoldOblique",
498 "PostScriptBoldSlant", "-BoldOblique",
500 #if WX_NORMALIZED_PS_FONTS
501 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
503 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
504 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
507 "PostScriptTimesMedium", "",
508 "PostScriptTimesLight", "",
509 "PostScriptTimesBold", "Bold",
511 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
512 "PostScriptTimesMediumStraight", "Times-Roman",
513 "PostScriptTimesLightStraight", "Times-Roman",
514 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
515 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
517 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
518 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
520 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
522 #if !WX_NORMALIZED_PS_FONTS
523 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
526 "ScreenMedium", "medium",
527 "ScreenBold", "bold",
528 "ScreenLight", "light",
529 "ScreenStraight", "r",
533 "ScreenDefaultBase", "*-times",
535 "ScreenRomanBase", "*-times",
536 "ScreenDecorativeBase", "*-helvetica",
537 "ScreenModernBase", "*-courier",
538 "ScreenTeletypeBase", "*-lucidatypewriter",
539 "ScreenSwissBase", "*-lucida",
540 "ScreenScriptBase", "*-zapfchancery",
542 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
543 "-normal-*-*-%d-*-*-*-*-*-*",
546 "-${ScreenDefaultBase}${ScreenStdSuffix}",
548 "-${ScreenRomanBase}${ScreenStdSuffix}",
549 "ScreenDecorative__",
550 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
552 "-${ScreenModernBase}${ScreenStdSuffix}",
554 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
556 "-${ScreenSwissBase}${ScreenStdSuffix}",
558 "-${ScreenScriptBase}${ScreenStdSuffix}",
562 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
563 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
565 static int WCoordinate(int w
)
569 case wxBOLD
: return wxWEIGHT_BOLD
;
570 case wxLIGHT
: return wxWEIGHT_LIGHT
;
572 default: return wxWEIGHT_NORMAL
;
576 static int SCoordinate(int s
)
580 case wxITALIC
: return wxSTYLE_ITALIC
;
581 case wxSLANT
: return wxSTYLE_SLANT
;
583 default: return wxSTYLE_NORMAL
;
587 //-----------------------------------------------------------------------------
589 //-----------------------------------------------------------------------------
596 inline char *GetName(int weight
, int style
)
598 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
601 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
602 void Initialize(const char *, const char *);
605 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
608 char resource
[1024], **defaults
, *internal
;
613 internal
= (char *) NULL
;
615 for (i
= 0; i
< k
; i
++)
617 strcpy(resource
, prefix
);
618 for (j
= 0; j
< count
; j
++)
620 // upon failure to find a matching fontname
621 // in the default fonts above, we substitute more
622 // and more values by _ so that at last ScreenMyFontBoldNormal
623 // would turn into Screen___ and this will then get
624 // converted to -${ScreenDefaultBase}${ScreenStdSuffix}
627 strcat(resource
, names
[j
]);
629 strcat(resource
, "_");
632 // we previously search the Xt-resources here
636 defaults
= font_defaults
;
639 if (!strcmp(*defaults
, resource
))
641 internal
= defaults
[1];
651 if ((strcmp(internal
,"-${ScreenDefaultBase}${ScreenStdSuffix}") == 0) &&
652 (strcmp(names
[0], "Default") != 0))
654 // we did not find any font name in the standard list.
655 // this can (hopefully does) mean that someone supplied
656 // the facename in the wxFont constructor so we insert
659 strcpy( resource
,"-*-" ); // any producer
660 strcat( resource
, names
[0] ); // facename
661 strcat( resource
, "${ScreenStdSuffix}" ); // add size params later on
662 *v
= copystring(resource
);
666 *v
= copystring(internal
);
671 wxSuffixMap::~wxSuffixMap()
675 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
676 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
680 map
[k
][j
] = (char *) NULL
;
684 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
686 const char *weight
, *style
;
689 const char *names
[3];
691 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++)
695 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
696 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
698 default: weight
= "Bold";
700 for (j
= 0; j
< wxNUM_STYLES
; j
++)
704 case wxSTYLE_NORMAL
: style
= "Straight"; break;
705 case wxSTYLE_ITALIC
: style
= "Italic"; break;
707 default: style
= "Slant";
713 SearchResource(devresname
, names
, 3, &v
);
715 // Expand macros in the found string:
717 int len
, closer
= 0, startpos
= 0;
719 len
= (v
? strlen(v
) : 0);
720 for (i
= 0; i
< len
; i
++)
722 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{')))
725 closer
= (v
[i
+1] == '[') ? ']' : '}';
728 else if (v
[i
] == closer
)
731 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
734 name
= v
+ startpos
+ 2;
742 for (i
= 0, count
= 1; name
[i
]; i
++)
748 names
= new char*[count
];
750 for (i
= 0, count
= 1; i
< len
; i
++)
753 names
[count
++] = name
+ i
+ 1;
757 SearchResource("", (const char **)names
, count
, (char **)&r
);
763 for (i
= 0; i
< len
; i
++)
767 wxLogError( "Bad resource name in font lookup." );
769 } else if (!strcmp(name
, "weight")) {
771 } else if (!strcmp(name
, "style")) {
773 } else if (!strcmp(name
, "family")) {
777 wxLogError( "Bad font macro name." );
781 newstrlen
= strlen(r
);
782 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
783 memcpy(naya
, v
, startpos
);
784 memcpy(naya
+ startpos
, r
, newstrlen
);
785 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
794 // We have a final value:
800 //-----------------------------------------------------------------------------
802 //-----------------------------------------------------------------------------
804 class wxFontNameItem
: public wxObject
806 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
808 wxFontNameItem(const char *name
, int id
, int family
);
811 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
812 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
813 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
814 inline char* GetName() {return name
;}
815 inline int GetFamily() {return family
;}
816 inline int GetId() {return id
;}
817 inline bool IsRoman() {return isroman
;}
818 #if defined(__WXDEBUG__)
819 void Dump(ostream
& str
);
825 wxSuffixMap screen
, printing
, afm
;
829 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
831 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
833 name
= copystring(Name
);
837 screen
. Initialize(name
, "Screen");
838 printing
.Initialize(name
, "PostScript");
839 afm
. Initialize(name
, "Afm");
842 wxFontNameItem::~wxFontNameItem()
846 name
= (char *) NULL
;
849 #if defined(__WXDEBUG__)
850 void wxFontNameItem::Dump(ostream
& str
)
852 str
<< "wxFontNameItem(" << name
<< ")";
856 //-----------------------------------------------------------------------------
858 //-----------------------------------------------------------------------------
860 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
862 wxFontNameDirectory::wxFontNameDirectory()
864 table
= new wxHashTable(wxKEY_INTEGER
, 20);
868 wxFontNameDirectory::~wxFontNameDirectory()
870 // Cleanup wxFontNameItems allocated
872 wxNode
*node
= table
->Next();
875 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
877 node
= table
->Next();
882 int wxFontNameDirectory::GetNewFontId()
884 return (nextFontId
--);
887 void wxFontNameDirectory::Initialize()
889 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
890 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
891 Initialize(wxROMAN
, wxROMAN
, "Roman");
892 Initialize(wxMODERN
, wxMODERN
, "Modern");
893 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
894 Initialize(wxSWISS
, wxSWISS
, "Swiss");
895 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
898 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
900 char *fam
, resource
[256];
902 sprintf(resource
, "Family%s", resname
);
903 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
907 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
908 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
909 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
910 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
911 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
912 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
913 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
914 delete[] fam
; // free resource
916 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
919 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
923 // font exists -> return id
924 if ( (id
= GetFontId(name
)) ) return id
;
927 Initialize(id
=GetNewFontId(), family
, name
);
931 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
933 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
935 return item
->GetScreenName(weight
, style
);
937 // font does not exist
938 return (char *) NULL
;
941 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
943 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
945 return item
->GetPostScriptName(weight
, style
);
947 // font does not exist
948 return (char *) NULL
;
951 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
953 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
955 return item
->GetAFMName(weight
, style
);
956 // font does not exist
957 return (char *) NULL
;
960 char *wxFontNameDirectory::GetFontName(int fontid
)
962 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
964 return item
->GetName();
966 // font does not exist
967 return (char *) NULL
;
970 int wxFontNameDirectory::GetFontId(const char *name
)
976 while ( (node
= table
->Next()) )
978 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
979 if (!strcmp(name
, item
->name
))
983 // font does not exist
987 int wxFontNameDirectory::GetFamily(int fontid
)
989 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
994 // font does not exist