]>
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
35 wxList m_scaled_xfonts
;
37 int m_family
, m_style
, m_weight
;
48 wxFontRefData::wxFontRefData() : m_scaled_xfonts(wxKEY_INTEGER
)
50 m_byXFontName
= FALSE
;
57 m_faceName
= (char *) NULL
;
58 m_font
= (GdkFont
*) NULL
;
61 wxFontRefData::~wxFontRefData()
63 wxNode
*node
= m_scaled_xfonts
.First();
66 GdkFont
*font
= (GdkFont
*)node
->Data();
67 wxNode
*next
= node
->Next();
68 gdk_font_unref( font
);
74 m_faceName
= (char *) NULL
;
76 if (m_font
) gdk_font_unref( m_font
);
79 //-----------------------------------------------------------------------------
81 #define M_FONTDATA ((wxFontRefData *)m_refData)
83 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
87 if (wxTheFontList
) wxTheFontList
->Append( this );
90 wxFont::wxFont( char *xFontName
)
92 if (!xFontName
) return;
94 m_refData
= new wxFontRefData();
96 M_FONTDATA
->m_byXFontName
= TRUE
;
97 M_FONTDATA
->m_font
= gdk_font_load( xFontName
);
100 wxFont::wxFont(int PointSize
, int FontIdOrFamily
, int Style
, int Weight
,
101 bool Underlined
, const char* Face
)
103 m_refData
= new wxFontRefData();
105 if (FontIdOrFamily
== wxDEFAULT
) FontIdOrFamily
= wxSWISS
;
106 M_FONTDATA
->m_family
= FontIdOrFamily
;
108 if ((M_FONTDATA
->m_faceName
= (Face
) ? copystring(Face
) : (char*)NULL
) )
110 M_FONTDATA
->m_fontId
= wxTheFontNameDirectory
->FindOrCreateFontId( Face
, FontIdOrFamily
);
111 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( FontIdOrFamily
);
115 M_FONTDATA
->m_fontId
= FontIdOrFamily
;
116 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( FontIdOrFamily
);
119 if (Style
== wxDEFAULT
) Style
= wxNORMAL
;
120 M_FONTDATA
->m_style
= Style
;
121 if (Weight
== wxDEFAULT
) Weight
= wxNORMAL
;
122 M_FONTDATA
->m_weight
= Weight
;
123 if (PointSize
== wxDEFAULT
) PointSize
= 12;
124 M_FONTDATA
->m_pointSize
= PointSize
;
125 M_FONTDATA
->m_underlined
= Underlined
;
127 if (wxTheFontList
) wxTheFontList
->Append( this );
130 wxFont::wxFont(int PointSize
, const char *Face
, int Family
, int Style
,
131 int Weight
, bool Underlined
)
133 m_refData
= new wxFontRefData();
135 M_FONTDATA
->m_fontId
= wxTheFontNameDirectory
->FindOrCreateFontId( Face
, Family
);
136 M_FONTDATA
->m_faceName
= (Face
) ? copystring(Face
) : (char*)NULL
;
137 M_FONTDATA
->m_family
= wxTheFontNameDirectory
->GetFamily( M_FONTDATA
->m_fontId
);
138 M_FONTDATA
->m_style
= Style
;
139 M_FONTDATA
->m_weight
= Weight
;
140 M_FONTDATA
->m_pointSize
= PointSize
;
141 M_FONTDATA
->m_underlined
= Underlined
;
143 if (wxTheFontList
) wxTheFontList
->Append( this );
146 wxFont::wxFont( const wxFont
& font
)
150 if (wxTheFontList
) wxTheFontList
->Append( this );
155 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
158 wxFont
& wxFont::operator = ( const wxFont
& font
)
160 if (*this == font
) return (*this);
165 bool wxFont::operator == ( const wxFont
& font
)
167 return m_refData
== font
.m_refData
;
170 bool wxFont::operator != ( const wxFont
& font
)
172 return m_refData
!= font
.m_refData
;
175 bool wxFont::Ok() const
177 return (m_refData
!= NULL
);
180 int wxFont::GetPointSize() const
182 wxCHECK_MSG( Ok(), 0, "invalid font" );
184 return M_FONTDATA
->m_pointSize
;
187 wxString
wxFont::GetFaceString() const
189 wxCHECK_MSG( Ok(), "", "invalid font" );
191 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
195 wxString
wxFont::GetFaceName() const
197 wxCHECK_MSG( Ok(), "", "invalid font" );
199 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
203 int wxFont::GetFamily() const
205 wxCHECK_MSG( Ok(), 0, "invalid font" );
207 return M_FONTDATA
->m_family
;
210 wxString
wxFont::GetFamilyString() const
212 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
214 switch (M_FONTDATA
->m_family
)
216 case wxDECORATIVE
: return wxString("wxDECORATIVE");
217 case wxROMAN
: return wxString("wxROMAN");
218 case wxSCRIPT
: return wxString("wxSCRIPT");
219 case wxSWISS
: return wxString("wxSWISS");
220 case wxMODERN
: return wxString("wxMODERN");
221 case wxTELETYPE
: return wxString("wxTELETYPE");
222 default: return "wxDEFAULT";
228 int wxFont::GetFontId() const
230 wxCHECK_MSG( Ok(), 0, "invalid font" );
232 return M_FONTDATA
->m_fontId
; // stub
235 int wxFont::GetStyle() const
237 wxCHECK_MSG( Ok(), 0, "invalid font" );
239 return M_FONTDATA
->m_style
;
242 wxString
wxFont::GetStyleString() const
244 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
246 switch (M_FONTDATA
->m_style
)
248 case wxNORMAL
: return wxString("wxNORMAL");
249 case wxSLANT
: return wxString("wxSLANT");
250 case wxITALIC
: return wxString("wxITALIC");
251 default: return wxString("wxDEFAULT");
254 return wxString("wxDEFAULT");
257 int wxFont::GetWeight() const
259 wxCHECK_MSG( Ok(), 0, "invalid font" );
261 return M_FONTDATA
->m_weight
;
264 wxString
wxFont::GetWeightString() const
266 wxCHECK_MSG( Ok(), "wxDEFAULT", "invalid font" );
268 switch (M_FONTDATA
->m_weight
)
270 case wxNORMAL
: return wxString("wxNORMAL");
271 case wxBOLD
: return wxString("wxBOLD");
272 case wxLIGHT
: return wxString("wxLIGHT");
273 default: return wxString("wxDEFAULT");
276 return wxString("wxDEFAULT");
279 bool wxFont::GetUnderlined() const
281 wxCHECK_MSG( Ok(), FALSE
, "invalid font" );
283 return M_FONTDATA
->m_underlined
;
286 //-----------------------------------------------------------------------------
287 // get internal representation of font
288 //-----------------------------------------------------------------------------
290 // local help function
291 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
292 int style
, int weight
,
295 GdkFont
*wxFont::GetInternalFont(float scale
) const
299 wxFAIL_MSG( "invalid font" );
300 return (GdkFont
*) NULL
;
303 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
305 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
306 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
307 GdkFont
*font
= (GdkFont
*) NULL
;
309 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
312 font
= (GdkFont
*)node
->Data();
317 if (int_scale == 100) printf( "int_scale.\n" );
318 if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
319 if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
320 if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
321 if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
323 if ((int_scale
== 100) &&
324 (M_FONTDATA
->m_family
== wxSWISS
) &&
325 (M_FONTDATA
->m_style
== wxNORMAL
) &&
326 (M_FONTDATA
->m_pointSize
== 12) &&
327 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
328 (M_FONTDATA
->m_underlined
== FALSE
))
330 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
334 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
335 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
337 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
340 printf("could not load any font");
341 // wxError("could not load any font", "wxFont");
345 //-----------------------------------------------------------------------------
346 // local utilities to find a X font
347 //-----------------------------------------------------------------------------
349 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
350 int weight
, bool WXUNUSED(underlined
))
353 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
356 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
357 sprintf(buffer
, name
, point_size
);
359 return gdk_font_load( buffer
);
362 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
363 int style
, int weight
,
368 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
371 // search up and down by stepsize 10
372 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
373 int min_size
= point_size
- 20 * (1 + (point_size
/180));
376 // Search for smaller size (approx.)
377 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
378 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
379 // Search for larger size (approx.)
380 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
381 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
382 // Try default family
383 if (!font
&& fontid
!= wxDEFAULT
)
384 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
388 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
394 //-----------------------------------------------------------------------------
395 // face names and index functions
396 //-----------------------------------------------------------------------------
398 static char *font_defaults
[] = {
399 "FamilyDefault", "Default",
400 "FamilyRoman", "Roman",
401 "FamilyDecorative", "Decorative",
402 "FamilyModern", "Modern",
403 "FamilyTeletype", "Teletype",
404 "FamilySwiss", "Swiss",
405 "FamilyScript", "Script",
411 "AfmItalic", "${AfmSlant}",
415 "AfmHelvetica", "Helv",
416 "AfmCourier", "Cour",
418 "Afm___", "${AfmTimes,$[weight],$[style]}",
420 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
421 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
422 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
423 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
424 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
426 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
427 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
429 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
431 "PostScriptMediumStraight", "",
432 "PostScriptMediumItalic", "-Oblique",
433 "PostScriptMediumSlant", "-Oblique",
434 "PostScriptLightStraight", "",
435 "PostScriptLightItalic", "-Oblique",
436 "PostScriptLightSlant", "-Oblique",
437 "PostScriptBoldStraight", "-Bold",
438 "PostScriptBoldItalic", "-BoldOblique",
439 "PostScriptBoldSlant", "-BoldOblique",
441 #if WX_NORMALIZED_PS_FONTS
442 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
444 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
445 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
448 "PostScriptTimesMedium", "",
449 "PostScriptTimesLight", "",
450 "PostScriptTimesBold", "Bold",
452 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
453 "PostScriptTimesMediumStraight", "Times-Roman",
454 "PostScriptTimesLightStraight", "Times-Roman",
455 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
456 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
458 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
459 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
461 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
463 #if !WX_NORMALIZED_PS_FONTS
464 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
467 "ScreenMedium", "medium",
468 "ScreenBold", "bold",
469 "ScreenLight", "light",
470 "ScreenStraight", "r",
474 "ScreenDefaultBase", "misc-fixed",
475 "ScreenRomanBase", "*-times",
476 "ScreenDecorativeBase", "*-helvetica",
477 "ScreenModernBase", "*-courier",
478 "ScreenTeletypeBase", "*-lucidatypewriter",
479 "ScreenSwissBase", "*-lucida",
480 "ScreenScriptBase", "*-zapfchancery",
482 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
483 "-normal-*-*-%d-*-*-*-*-*-*",
486 "-${ScreenDefaultBase}${ScreenStdSuffix}",
488 "-${ScreenRomanBase}${ScreenStdSuffix}",
489 "ScreenDecorative__",
490 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
492 "-${ScreenModernBase}${ScreenStdSuffix}",
494 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
496 "-${ScreenSwissBase}${ScreenStdSuffix}",
498 "-${ScreenScriptBase}${ScreenStdSuffix}",
502 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
503 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
505 static int WCoordinate(int w
)
508 case wxBOLD
: return wxWEIGHT_BOLD
;
509 case wxLIGHT
: return wxWEIGHT_LIGHT
;
511 default: return wxWEIGHT_NORMAL
;
515 static int SCoordinate(int s
)
518 case wxITALIC
: return wxSTYLE_ITALIC
;
519 case wxSLANT
: return wxSTYLE_SLANT
;
521 default: return wxSTYLE_NORMAL
;
525 //-----------------------------------------------------------------------------
527 //-----------------------------------------------------------------------------
533 inline char *GetName(int weight
, int style
)
535 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
538 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
539 void Initialize(const char *, const char *);
543 #define wxGetResource(a, b, c) 0
546 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
549 char resource
[1024], **defaults
, *internal
;
554 internal
= (char *) NULL
;
556 for (i
= 0; i
< k
; i
++) {
557 strcpy(resource
, prefix
);
558 for (j
= 0; j
< count
; j
++) {
560 strcat(resource
, names
[j
]);
562 strcat(resource
, "_");
564 if (wxGetResource(wxAPP_CLASS
, (char *)resource
, v
))
567 defaults
= font_defaults
;
569 if (!strcmp(*defaults
, resource
)) {
570 internal
= defaults
[1];
578 *v
= copystring(internal
);
581 wxSuffixMap::~wxSuffixMap()
585 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
586 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
589 map
[k
][j
] = (char *) NULL
;
593 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
595 const char *weight
, *style
;
598 const char *names
[3];
600 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++) {
602 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
603 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
605 default: weight
= "Bold";
607 for (j
= 0; j
< wxNUM_STYLES
; j
++) {
609 case wxSTYLE_NORMAL
: style
= "Straight"; break;
610 case wxSTYLE_ITALIC
: style
= "Italic"; break;
612 default: style
= "Slant";
618 SearchResource(devresname
, names
, 3, &v
);
620 /* Expand macros in the found string: */
622 int len
, closer
= 0, startpos
= 0;
624 len
= (v
? strlen(v
) : 0);
625 for (i
= 0; i
< len
; i
++) {
626 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{'))) {
628 closer
= (v
[i
+1] == '[') ? ']' : '}';
630 } else if (v
[i
] == closer
) {
632 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
635 name
= v
+ startpos
+ 2;
642 for (i
= 0, count
= 1; name
[i
]; i
++)
648 names
= new char*[count
];
650 for (i
= 0, count
= 1; i
< len
; i
++)
651 if (name
[i
] == ',') {
652 names
[count
++] = name
+ i
+ 1;
656 SearchResource("", (const char **)names
, count
, (char **)&r
);
661 for (i
= 0; i
< len
; i
++)
665 printf("Bad resource name \"%s\" in font lookup\n", name
);
667 } else if (!strcmp(name
, "weight")) {
669 } else if (!strcmp(name
, "style")) {
671 } else if (!strcmp(name
, "family")) {
675 printf("Bad font macro name \"%s\"\n", name
);
679 newstrlen
= strlen(r
);
680 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
681 memcpy(naya
, v
, startpos
);
682 memcpy(naya
+ startpos
, r
, newstrlen
);
683 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
692 /* We have a final value: */
698 //-----------------------------------------------------------------------------
700 //-----------------------------------------------------------------------------
702 class wxFontNameItem
: public wxObject
{
703 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
705 wxFontNameItem(const char *name
, int id
, int family
);
708 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
709 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
710 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
711 inline char* GetName() {return name
;}
712 inline int GetFamily() {return family
;}
713 inline int GetId() {return id
;}
714 inline bool IsRoman() {return isroman
;}
715 #if defined(__WXDEBUG__)
716 void Dump(ostream
& str
);
722 wxSuffixMap screen
, printing
, afm
;
726 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
728 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
730 name
= copystring(Name
);
734 screen
. Initialize(name
, "Screen");
735 printing
.Initialize(name
, "PostScript");
736 afm
. Initialize(name
, "Afm");
739 wxFontNameItem::~wxFontNameItem()
743 name
= (char *) NULL
;
746 #if defined(__WXDEBUG__)
747 void wxFontNameItem::Dump(ostream
& str
)
749 str
<< "wxFontNameItem(" << name
<< ")";
753 //-----------------------------------------------------------------------------
755 //-----------------------------------------------------------------------------
757 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
759 wxFontNameDirectory::wxFontNameDirectory()
761 table
= new wxHashTable(wxKEY_INTEGER
, 20);
765 wxFontNameDirectory::~wxFontNameDirectory()
767 // Cleanup wxFontNameItems allocated
769 wxNode
*node
= table
->Next();
771 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
773 node
= table
->Next();
778 int wxFontNameDirectory::GetNewFontId()
780 return (nextFontId
--);
783 void wxFontNameDirectory::Initialize()
785 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
786 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
787 Initialize(wxROMAN
, wxROMAN
, "Roman");
788 Initialize(wxMODERN
, wxMODERN
, "Modern");
789 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
790 Initialize(wxSWISS
, wxSWISS
, "Swiss");
791 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
794 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
796 char *fam
, resource
[256];
798 sprintf(resource
, "Family%s", resname
);
799 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
801 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
802 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
803 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
804 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
805 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
806 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
807 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
808 delete[] fam
; // free resource
810 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
813 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
817 // font exists -> return id
818 if ( (id
= GetFontId(name
)) ) return id
;
820 Initialize(id
=GetNewFontId(), family
, name
);
824 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
826 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
828 return item
->GetScreenName(weight
, style
);
829 // font does not exist
830 return (char *) NULL
;
833 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
835 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
837 return item
->GetPostScriptName(weight
, style
);
838 // font does not exist
839 return (char *) NULL
;
842 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
844 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
846 return item
->GetAFMName(weight
, style
);
847 // font does not exist
848 return (char *) NULL
;
851 char *wxFontNameDirectory::GetFontName(int fontid
)
853 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
855 return item
->GetName();
856 // font does not exist
857 return (char *) NULL
;
860 int wxFontNameDirectory::GetFontId(const char *name
)
866 while ( (node
= table
->Next()) ) {
867 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
868 if (!strcmp(name
, item
->name
))
871 // font does not exist
875 int wxFontNameDirectory::GetFamily(int fontid
)
877 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
881 // font does not exist