]>
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
184 wxFAIL_MSG( "invalid font" );
188 return M_FONTDATA
->m_pointSize
;
191 wxString
wxFont::GetFaceString() const
195 wxFAIL_MSG( "invalid font" );
199 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
203 wxString
wxFont::GetFaceName() const
207 wxFAIL_MSG( "invalid font" );
211 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
215 int wxFont::GetFamily() const
219 wxFAIL_MSG( "invalid font" );
223 return M_FONTDATA
->m_family
;
226 wxString
wxFont::GetFamilyString() const
230 wxFAIL_MSG( "invalid font" );
234 switch (M_FONTDATA
->m_family
)
236 case wxDECORATIVE
: return wxString("wxDECORATIVE");
237 case wxROMAN
: return wxString("wxROMAN");
238 case wxSCRIPT
: return wxString("wxSCRIPT");
239 case wxSWISS
: return wxString("wxSWISS");
240 case wxMODERN
: return wxString("wxMODERN");
241 case wxTELETYPE
: return wxString("wxTELETYPE");
242 default: return "wxDEFAULT";
248 int wxFont::GetFontId() const
252 wxFAIL_MSG( "invalid font" );
256 return M_FONTDATA
->m_fontId
; // stub
259 int wxFont::GetStyle() const
263 wxFAIL_MSG( "invalid font" );
267 return M_FONTDATA
->m_style
;
270 wxString
wxFont::GetStyleString() const
274 wxFAIL_MSG( "invalid font" );
278 switch (M_FONTDATA
->m_style
)
280 case wxNORMAL
: return wxString("wxNORMAL");
281 case wxSLANT
: return wxString("wxSLANT");
282 case wxITALIC
: return wxString("wxITALIC");
283 default: return wxString("wxDEFAULT");
286 return wxString("wxDEFAULT");
289 int wxFont::GetWeight() const
293 wxFAIL_MSG( "invalid font" );
297 return M_FONTDATA
->m_weight
;
300 wxString
wxFont::GetWeightString() const
304 wxFAIL_MSG( "invalid font" );
308 switch (M_FONTDATA
->m_weight
)
310 case wxNORMAL
: return wxString("wxNORMAL");
311 case wxBOLD
: return wxString("wxBOLD");
312 case wxLIGHT
: return wxString("wxLIGHT");
313 default: return wxString("wxDEFAULT");
316 return wxString("wxDEFAULT");
319 bool wxFont::GetUnderlined() const
323 wxFAIL_MSG( "invalid font" );
327 return M_FONTDATA
->m_underlined
;
330 //-----------------------------------------------------------------------------
331 // get internal representation of font
332 //-----------------------------------------------------------------------------
334 // local help function
335 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
336 int style
, int weight
,
339 GdkFont
*wxFont::GetInternalFont(float scale
) const
343 wxFAIL_MSG( "invalid font" );
344 return (GdkFont
*) NULL
;
347 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
349 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
350 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
351 GdkFont
*font
= (GdkFont
*) NULL
;
353 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
356 font
= (GdkFont
*)node
->Data();
361 if (int_scale == 100) printf( "int_scale.\n" );
362 if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
363 if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
364 if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
365 if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
367 if ((int_scale
== 100) &&
368 (M_FONTDATA
->m_family
== wxSWISS
) &&
369 (M_FONTDATA
->m_style
== wxNORMAL
) &&
370 (M_FONTDATA
->m_pointSize
== 12) &&
371 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
372 (M_FONTDATA
->m_underlined
== FALSE
))
374 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
378 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
379 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
381 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
384 printf("could not load any font");
385 // wxError("could not load any font", "wxFont");
389 //-----------------------------------------------------------------------------
390 // local utilities to find a X font
391 //-----------------------------------------------------------------------------
393 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
394 int weight
, bool WXUNUSED(underlined
))
397 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
400 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
401 sprintf(buffer
, name
, point_size
);
403 return gdk_font_load( buffer
);
406 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
407 int style
, int weight
,
412 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
415 // search up and down by stepsize 10
416 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
417 int min_size
= point_size
- 20 * (1 + (point_size
/180));
420 // Search for smaller size (approx.)
421 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
422 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
423 // Search for larger size (approx.)
424 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
425 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
426 // Try default family
427 if (!font
&& fontid
!= wxDEFAULT
)
428 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
432 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
438 //-----------------------------------------------------------------------------
439 // face names and index functions
440 //-----------------------------------------------------------------------------
442 static char *font_defaults
[] = {
443 "FamilyDefault", "Default",
444 "FamilyRoman", "Roman",
445 "FamilyDecorative", "Decorative",
446 "FamilyModern", "Modern",
447 "FamilyTeletype", "Teletype",
448 "FamilySwiss", "Swiss",
449 "FamilyScript", "Script",
455 "AfmItalic", "${AfmSlant}",
459 "AfmHelvetica", "Helv",
460 "AfmCourier", "Cour",
462 "Afm___", "${AfmTimes,$[weight],$[style]}",
464 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
465 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
466 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
467 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
468 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
470 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
471 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
473 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
475 "PostScriptMediumStraight", "",
476 "PostScriptMediumItalic", "-Oblique",
477 "PostScriptMediumSlant", "-Oblique",
478 "PostScriptLightStraight", "",
479 "PostScriptLightItalic", "-Oblique",
480 "PostScriptLightSlant", "-Oblique",
481 "PostScriptBoldStraight", "-Bold",
482 "PostScriptBoldItalic", "-BoldOblique",
483 "PostScriptBoldSlant", "-BoldOblique",
485 #if WX_NORMALIZED_PS_FONTS
486 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
488 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
489 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
492 "PostScriptTimesMedium", "",
493 "PostScriptTimesLight", "",
494 "PostScriptTimesBold", "Bold",
496 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
497 "PostScriptTimesMediumStraight", "Times-Roman",
498 "PostScriptTimesLightStraight", "Times-Roman",
499 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
500 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
502 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
503 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
505 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
507 #if !WX_NORMALIZED_PS_FONTS
508 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
511 "ScreenMedium", "medium",
512 "ScreenBold", "bold",
513 "ScreenLight", "light",
514 "ScreenStraight", "r",
518 "ScreenDefaultBase", "misc-fixed",
519 "ScreenRomanBase", "*-times",
520 "ScreenDecorativeBase", "*-helvetica",
521 "ScreenModernBase", "*-courier",
522 "ScreenTeletypeBase", "*-lucidatypewriter",
523 "ScreenSwissBase", "*-lucida",
524 "ScreenScriptBase", "*-zapfchancery",
526 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
527 "-normal-*-*-%d-*-*-*-*-*-*",
530 "-${ScreenDefaultBase}${ScreenStdSuffix}",
532 "-${ScreenRomanBase}${ScreenStdSuffix}",
533 "ScreenDecorative__",
534 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
536 "-${ScreenModernBase}${ScreenStdSuffix}",
538 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
540 "-${ScreenSwissBase}${ScreenStdSuffix}",
542 "-${ScreenScriptBase}${ScreenStdSuffix}",
546 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
547 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
549 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
)
562 case wxITALIC
: return wxSTYLE_ITALIC
;
563 case wxSLANT
: return wxSTYLE_SLANT
;
565 default: return wxSTYLE_NORMAL
;
569 //-----------------------------------------------------------------------------
571 //-----------------------------------------------------------------------------
577 inline char *GetName(int weight
, int style
)
579 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
582 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
583 void Initialize(const char *, const char *);
587 #define wxGetResource(a, b, c) 0
590 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
593 char resource
[1024], **defaults
, *internal
;
598 internal
= (char *) NULL
;
600 for (i
= 0; i
< k
; i
++) {
601 strcpy(resource
, prefix
);
602 for (j
= 0; j
< count
; j
++) {
604 strcat(resource
, names
[j
]);
606 strcat(resource
, "_");
608 if (wxGetResource(wxAPP_CLASS
, (char *)resource
, v
))
611 defaults
= font_defaults
;
613 if (!strcmp(*defaults
, resource
)) {
614 internal
= defaults
[1];
622 *v
= copystring(internal
);
625 wxSuffixMap::~wxSuffixMap()
629 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
630 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
633 map
[k
][j
] = (char *) NULL
;
637 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
639 const char *weight
, *style
;
642 const char *names
[3];
644 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++) {
646 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
647 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
649 default: weight
= "Bold";
651 for (j
= 0; j
< wxNUM_STYLES
; j
++) {
653 case wxSTYLE_NORMAL
: style
= "Straight"; break;
654 case wxSTYLE_ITALIC
: style
= "Italic"; break;
656 default: style
= "Slant";
662 SearchResource(devresname
, names
, 3, &v
);
664 /* Expand macros in the found string: */
666 int len
, closer
= 0, startpos
= 0;
668 len
= (v
? strlen(v
) : 0);
669 for (i
= 0; i
< len
; i
++) {
670 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{'))) {
672 closer
= (v
[i
+1] == '[') ? ']' : '}';
674 } else if (v
[i
] == closer
) {
676 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
679 name
= v
+ startpos
+ 2;
686 for (i
= 0, count
= 1; name
[i
]; i
++)
692 names
= new char*[count
];
694 for (i
= 0, count
= 1; i
< len
; i
++)
695 if (name
[i
] == ',') {
696 names
[count
++] = name
+ i
+ 1;
700 SearchResource("", (const char **)names
, count
, (char **)&r
);
705 for (i
= 0; i
< len
; i
++)
709 printf("Bad resource name \"%s\" in font lookup\n", name
);
711 } else if (!strcmp(name
, "weight")) {
713 } else if (!strcmp(name
, "style")) {
715 } else if (!strcmp(name
, "family")) {
719 printf("Bad font macro name \"%s\"\n", name
);
723 newstrlen
= strlen(r
);
724 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
725 memcpy(naya
, v
, startpos
);
726 memcpy(naya
+ startpos
, r
, newstrlen
);
727 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
736 /* We have a final value: */
742 //-----------------------------------------------------------------------------
744 //-----------------------------------------------------------------------------
746 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();
815 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
817 node
= table
->Next();
822 int wxFontNameDirectory::GetNewFontId()
824 return (nextFontId
--);
827 void wxFontNameDirectory::Initialize()
829 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
830 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
831 Initialize(wxROMAN
, wxROMAN
, "Roman");
832 Initialize(wxMODERN
, wxMODERN
, "Modern");
833 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
834 Initialize(wxSWISS
, wxSWISS
, "Swiss");
835 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
838 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
840 char *fam
, resource
[256];
842 sprintf(resource
, "Family%s", resname
);
843 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
845 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
846 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
847 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
848 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
849 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
850 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
851 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
852 delete[] fam
; // free resource
854 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
857 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
861 // font exists -> return id
862 if ( (id
= GetFontId(name
)) ) return id
;
864 Initialize(id
=GetNewFontId(), family
, name
);
868 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
870 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
872 return item
->GetScreenName(weight
, style
);
873 // font does not exist
874 return (char *) NULL
;
877 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
879 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
881 return item
->GetPostScriptName(weight
, style
);
882 // font does not exist
883 return (char *) NULL
;
886 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
888 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
890 return item
->GetAFMName(weight
, style
);
891 // font does not exist
892 return (char *) NULL
;
895 char *wxFontNameDirectory::GetFontName(int fontid
)
897 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
899 return item
->GetName();
900 // font does not exist
901 return (char *) NULL
;
904 int wxFontNameDirectory::GetFontId(const char *name
)
910 while ( (node
= table
->Next()) ) {
911 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
912 if (!strcmp(name
, item
->name
))
915 // font does not exist
919 int wxFontNameDirectory::GetFamily(int fontid
)
921 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
925 // font does not exist