]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/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(void) : m_scaled_xfonts(wxKEY_INTEGER
)
50 m_byXFontName
= FALSE
;
57 m_faceName
= (char *) NULL
;
58 m_font
= (GdkFont
*) NULL
;
61 wxFontRefData::~wxFontRefData(void)
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 );
153 wxFont::wxFont( const wxFont
* font
)
156 if (font
) Ref( *font
);
158 if (wxTheFontList
) wxTheFontList
->Append( this );
161 wxFont::~wxFont(void)
163 if (wxTheFontList
) wxTheFontList
->DeleteObject( this );
166 wxFont
& wxFont::operator = ( const wxFont
& font
)
168 if (*this == font
) return (*this);
173 bool wxFont::operator == ( const wxFont
& font
)
175 return m_refData
== font
.m_refData
;
178 bool wxFont::operator != ( const wxFont
& font
)
180 return m_refData
!= font
.m_refData
;
183 bool wxFont::Ok() const
185 return (m_refData
!= NULL
);
188 int wxFont::GetPointSize(void) const
192 wxFAIL_MSG( "invalid font" );
196 return M_FONTDATA
->m_pointSize
;
199 wxString
wxFont::GetFaceString(void) const
203 wxFAIL_MSG( "invalid font" );
207 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
211 wxString
wxFont::GetFaceName(void) const
215 wxFAIL_MSG( "invalid font" );
219 wxString s
= wxTheFontNameDirectory
->GetFontName( M_FONTDATA
->m_fontId
);
223 int wxFont::GetFamily(void) const
227 wxFAIL_MSG( "invalid font" );
231 return M_FONTDATA
->m_family
;
234 wxString
wxFont::GetFamilyString(void) const
238 wxFAIL_MSG( "invalid font" );
242 switch (M_FONTDATA
->m_family
)
244 case wxDECORATIVE
: return wxString("wxDECORATIVE");
245 case wxROMAN
: return wxString("wxROMAN");
246 case wxSCRIPT
: return wxString("wxSCRIPT");
247 case wxSWISS
: return wxString("wxSWISS");
248 case wxMODERN
: return wxString("wxMODERN");
249 case wxTELETYPE
: return wxString("wxTELETYPE");
250 default: return "wxDEFAULT";
256 int wxFont::GetFontId(void) const
260 wxFAIL_MSG( "invalid font" );
264 return M_FONTDATA
->m_fontId
; // stub
267 int wxFont::GetStyle(void) const
271 wxFAIL_MSG( "invalid font" );
275 return M_FONTDATA
->m_style
;
278 wxString
wxFont::GetStyleString(void) const
282 wxFAIL_MSG( "invalid font" );
286 switch (M_FONTDATA
->m_style
)
288 case wxNORMAL
: return wxString("wxNORMAL");
289 case wxSLANT
: return wxString("wxSLANT");
290 case wxITALIC
: return wxString("wxITALIC");
291 default: return wxString("wxDEFAULT");
294 return wxString("wxDEFAULT");
297 int wxFont::GetWeight(void) const
301 wxFAIL_MSG( "invalid font" );
305 return M_FONTDATA
->m_weight
;
308 wxString
wxFont::GetWeightString(void) const
312 wxFAIL_MSG( "invalid font" );
316 switch (M_FONTDATA
->m_weight
)
318 case wxNORMAL
: return wxString("wxNORMAL");
319 case wxBOLD
: return wxString("wxBOLD");
320 case wxLIGHT
: return wxString("wxLIGHT");
321 default: return wxString("wxDEFAULT");
324 return wxString("wxDEFAULT");
327 bool wxFont::GetUnderlined(void) const
331 wxFAIL_MSG( "invalid font" );
335 return M_FONTDATA
->m_underlined
;
338 //-----------------------------------------------------------------------------
339 // get internal representation of font
340 //-----------------------------------------------------------------------------
342 // local help function
343 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
344 int style
, int weight
,
347 GdkFont
*wxFont::GetInternalFont(float scale
) const
351 wxFAIL_MSG( "invalid font" );
352 return (GdkFont
*) NULL
;
355 if (M_FONTDATA
->m_byXFontName
) return M_FONTDATA
->m_font
;
357 long int_scale
= long(scale
* 100.0 + 0.5); // key for fontlist
358 int point_scale
= (M_FONTDATA
->m_pointSize
* 10 * int_scale
) / 100;
359 GdkFont
*font
= (GdkFont
*) NULL
;
361 wxNode
*node
= M_FONTDATA
->m_scaled_xfonts
.Find(int_scale
);
364 font
= (GdkFont
*)node
->Data();
369 if (int_scale == 100) printf( "int_scale.\n" );
370 if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" );
371 if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" );
372 if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" );
373 if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" );
375 if ((int_scale
== 100) &&
376 (M_FONTDATA
->m_family
== wxSWISS
) &&
377 (M_FONTDATA
->m_style
== wxNORMAL
) &&
378 (M_FONTDATA
->m_pointSize
== 12) &&
379 (M_FONTDATA
->m_weight
== wxNORMAL
) &&
380 (M_FONTDATA
->m_underlined
== FALSE
))
382 font
= gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" );
386 font
= wxLoadQueryNearestFont( point_scale
, M_FONTDATA
->m_fontId
, M_FONTDATA
->m_style
,
387 M_FONTDATA
->m_weight
, M_FONTDATA
->m_underlined
);
389 M_FONTDATA
->m_scaled_xfonts
.Append( int_scale
, (wxObject
*)font
);
392 printf("could not load any font");
393 // wxError("could not load any font", "wxFont");
397 //-----------------------------------------------------------------------------
398 // local utilities to find a X font
399 //-----------------------------------------------------------------------------
401 static GdkFont
*wxLoadQueryFont(int point_size
, int fontid
, int style
,
402 int weight
, bool WXUNUSED(underlined
))
405 char *name
= wxTheFontNameDirectory
->GetScreenName( fontid
, weight
, style
);
408 name
= "-*-*-*-*-*-*-*-%d-*-*-*-*-*-*";
409 sprintf(buffer
, name
, point_size
);
411 return gdk_font_load( buffer
);
414 static GdkFont
*wxLoadQueryNearestFont(int point_size
, int fontid
,
415 int style
, int weight
,
420 font
= wxLoadQueryFont( point_size
, fontid
, style
, weight
, underlined
);
423 // search up and down by stepsize 10
424 int max_size
= point_size
+ 20 * (1 + (point_size
/180));
425 int min_size
= point_size
- 20 * (1 + (point_size
/180));
428 // Search for smaller size (approx.)
429 for (i
=point_size
-10; !font
&& i
>= 10 && i
>= min_size
; i
-= 10)
430 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
431 // Search for larger size (approx.)
432 for (i
=point_size
+10; !font
&& i
<= max_size
; i
+= 10)
433 font
= wxLoadQueryFont(i
, fontid
, style
, weight
, underlined
);
434 // Try default family
435 if (!font
&& fontid
!= wxDEFAULT
)
436 font
= wxLoadQueryFont(point_size
, wxDEFAULT
, style
,
440 font
= wxLoadQueryFont(120, wxDEFAULT
, wxNORMAL
, wxNORMAL
,
446 //-----------------------------------------------------------------------------
447 // face names and index functions
448 //-----------------------------------------------------------------------------
450 static char *font_defaults
[] = {
451 "FamilyDefault", "Default",
452 "FamilyRoman", "Roman",
453 "FamilyDecorative", "Decorative",
454 "FamilyModern", "Modern",
455 "FamilyTeletype", "Teletype",
456 "FamilySwiss", "Swiss",
457 "FamilyScript", "Script",
463 "AfmItalic", "${AfmSlant}",
467 "AfmHelvetica", "Helv",
468 "AfmCourier", "Cour",
470 "Afm___", "${AfmTimes,$[weight],$[style]}",
472 "AfmTimes__", "${AfmTimes}${Afm$[weight]}${Afm$[style]}",
473 "AfmTimesMediumStraight", "${AfmTimes}${AfmRoman}",
474 "AfmTimesLightStraight", "${AfmTimes}${AfmRoman}",
475 "AfmTimes_Italic", "${AfmTimes}$[weight]${AfmItalic}",
476 "AfmTimes_Slant", "${AfmTimes}$[weight]${AfmItalic}",
478 "AfmSwiss__", "${AfmHelvetica}${Afm$[weight]}${Afm$[style]}",
479 "AfmModern__", "${AfmCourier}${Afm$[weight]}${Afm$[style]}",
481 "AfmTeletype__", "${AfmModern,$[weight],$[style]}",
483 "PostScriptMediumStraight", "",
484 "PostScriptMediumItalic", "-Oblique",
485 "PostScriptMediumSlant", "-Oblique",
486 "PostScriptLightStraight", "",
487 "PostScriptLightItalic", "-Oblique",
488 "PostScriptLightSlant", "-Oblique",
489 "PostScriptBoldStraight", "-Bold",
490 "PostScriptBoldItalic", "-BoldOblique",
491 "PostScriptBoldSlant", "-BoldOblique",
493 #if WX_NORMALIZED_PS_FONTS
494 "PostScript___", "${PostScriptTimes,$[weight],$[style]}",
496 "PostScriptRoman__", "${PostScriptTimes,$[weight],$[style]}",
497 "PostScript___", "LucidaSans${PostScript$[weight]$[style]}",
500 "PostScriptTimesMedium", "",
501 "PostScriptTimesLight", "",
502 "PostScriptTimesBold", "Bold",
504 "PostScriptTimes__", "Times${PostScript$[weight]$[style]}",
505 "PostScriptTimesMediumStraight", "Times-Roman",
506 "PostScriptTimesLightStraight", "Times-Roman",
507 "PostScriptTimes_Slant", "Times-${PostScriptTimes$[weight]}Italic",
508 "PostScriptTimes_Italic", "Times-${PostScriptTimes$[weight]}Italic",
510 "PostScriptSwiss__", "Helvetica${PostScript$[weight]$[style]}",
511 "PostScriptModern__", "Courier${PostScript$[weight]$[style]}",
513 "PostScriptTeletype__", "${PostScriptModern,$[weight],$[style]}",
515 #if !WX_NORMALIZED_PS_FONTS
516 "PostScriptScript__", "Zapf-Chancery-MediumItalic",
519 "ScreenMedium", "medium",
520 "ScreenBold", "bold",
521 "ScreenLight", "light",
522 "ScreenStraight", "r",
526 "ScreenDefaultBase", "misc-fixed",
527 "ScreenRomanBase", "*-times",
528 "ScreenDecorativeBase", "*-helvetica",
529 "ScreenModernBase", "*-courier",
530 "ScreenTeletypeBase", "*-lucidatypewriter",
531 "ScreenSwissBase", "*-lucida",
532 "ScreenScriptBase", "*-zapfchancery",
534 "ScreenStdSuffix", "-${Screen$[weight]}-${Screen$[style]}"
535 "-normal-*-*-%d-*-*-*-*-*-*",
538 "-${ScreenDefaultBase}${ScreenStdSuffix}",
540 "-${ScreenRomanBase}${ScreenStdSuffix}",
541 "ScreenDecorative__",
542 "-${ScreenDecorativeBase}${ScreenStdSuffix}",
544 "-${ScreenModernBase}${ScreenStdSuffix}",
546 "-${ScreenTeletypeBase}${ScreenStdSuffix}",
548 "-${ScreenSwissBase}${ScreenStdSuffix}",
550 "-${ScreenScriptBase}${ScreenStdSuffix}",
554 enum {wxWEIGHT_NORMAL
, wxWEIGHT_BOLD
, wxWEIGHT_LIGHT
, wxNUM_WEIGHTS
};
555 enum {wxSTYLE_NORMAL
, wxSTYLE_ITALIC
, wxSTYLE_SLANT
, wxNUM_STYLES
};
557 static int WCoordinate(int w
)
560 case wxBOLD
: return wxWEIGHT_BOLD
;
561 case wxLIGHT
: return wxWEIGHT_LIGHT
;
563 default: return wxWEIGHT_NORMAL
;
567 static int SCoordinate(int s
)
570 case wxITALIC
: return wxSTYLE_ITALIC
;
571 case wxSLANT
: return wxSTYLE_SLANT
;
573 default: return wxSTYLE_NORMAL
;
577 //-----------------------------------------------------------------------------
579 //-----------------------------------------------------------------------------
585 inline char *GetName(int weight
, int style
)
587 return ( map
[WCoordinate(weight
)] [SCoordinate(style
)] );
590 char *map
[wxNUM_WEIGHTS
][wxNUM_STYLES
];
591 void Initialize(const char *, const char *);
595 #define wxGetResource(a, b, c) 0
598 static void SearchResource(const char *prefix
, const char **names
, int count
, char **v
)
601 char resource
[1024], **defaults
, *internal
;
606 internal
= (char *) NULL
;
608 for (i
= 0; i
< k
; i
++) {
609 strcpy(resource
, prefix
);
610 for (j
= 0; j
< count
; j
++) {
612 strcat(resource
, names
[j
]);
614 strcat(resource
, "_");
616 if (wxGetResource(wxAPP_CLASS
, (char *)resource
, v
))
619 defaults
= font_defaults
;
621 if (!strcmp(*defaults
, resource
)) {
622 internal
= defaults
[1];
630 *v
= copystring(internal
);
633 wxSuffixMap::~wxSuffixMap(void)
637 for (k
= 0; k
< wxNUM_WEIGHTS
; ++k
)
638 for (j
= 0; j
< wxNUM_STYLES
; ++j
)
641 map
[k
][j
] = (char *) NULL
;
645 void wxSuffixMap::Initialize(const char *resname
, const char *devresname
)
647 const char *weight
, *style
;
650 const char *names
[3];
652 for (k
= 0; k
< wxNUM_WEIGHTS
; k
++) {
654 case wxWEIGHT_NORMAL
: weight
= "Medium"; break;
655 case wxWEIGHT_LIGHT
: weight
= "Light"; break;
657 default: weight
= "Bold";
659 for (j
= 0; j
< wxNUM_STYLES
; j
++) {
661 case wxSTYLE_NORMAL
: style
= "Straight"; break;
662 case wxSTYLE_ITALIC
: style
= "Italic"; break;
664 default: style
= "Slant";
670 SearchResource(devresname
, names
, 3, &v
);
672 /* Expand macros in the found string: */
674 int len
, closer
= 0, startpos
= 0;
676 len
= (v
? strlen(v
) : 0);
677 for (i
= 0; i
< len
; i
++) {
678 if (v
[i
] == '$' && ((v
[i
+1] == '[') || (v
[i
+1] == '{'))) {
680 closer
= (v
[i
+1] == '[') ? ']' : '}';
682 } else if (v
[i
] == closer
) {
684 const char *r
= (char *) NULL
; bool delete_r
= FALSE
;
687 name
= v
+ startpos
+ 2;
694 for (i
= 0, count
= 1; name
[i
]; i
++)
700 names
= new char*[count
];
702 for (i
= 0, count
= 1; i
< len
; i
++)
703 if (name
[i
] == ',') {
704 names
[count
++] = name
+ i
+ 1;
708 SearchResource("", (const char **)names
, count
, (char **)&r
);
713 for (i
= 0; i
< len
; i
++)
717 printf("Bad resource name \"%s\" in font lookup\n", name
);
719 } else if (!strcmp(name
, "weight")) {
721 } else if (!strcmp(name
, "style")) {
723 } else if (!strcmp(name
, "family")) {
727 printf("Bad font macro name \"%s\"\n", name
);
731 newstrlen
= strlen(r
);
732 char *naya
= new char[startpos
+ newstrlen
+ len
- i
];
733 memcpy(naya
, v
, startpos
);
734 memcpy(naya
+ startpos
, r
, newstrlen
);
735 memcpy(naya
+ startpos
+ newstrlen
, v
+ i
+ 1, len
- i
);
744 /* We have a final value: */
750 //-----------------------------------------------------------------------------
752 //-----------------------------------------------------------------------------
754 class wxFontNameItem
: public wxObject
{
755 DECLARE_DYNAMIC_CLASS(wxFontNameItem
)
757 wxFontNameItem(const char *name
, int id
, int family
);
760 inline char* GetScreenName(int w
, int s
) {return screen
.GetName(w
, s
);}
761 inline char* GetPostScriptName(int w
, int s
) {return printing
.GetName(w
, s
);}
762 inline char* GetAFMName(int w
, int s
) {return afm
.GetName(w
, s
);}
763 inline char* GetName(void) {return name
;}
764 inline int GetFamily(void) {return family
;}
765 inline int GetId(void) {return id
;}
766 inline bool IsRoman(void) {return isroman
;}
767 #if defined(__WXDEBUG__)
768 void Dump(ostream
& str
);
774 wxSuffixMap screen
, printing
, afm
;
778 IMPLEMENT_ABSTRACT_CLASS(wxFontNameItem
, wxObject
)
780 wxFontNameItem::wxFontNameItem(const char *Name
, int Id
, int Family
)
782 name
= copystring(Name
);
786 screen
. Initialize(name
, "Screen");
787 printing
.Initialize(name
, "PostScript");
788 afm
. Initialize(name
, "Afm");
791 wxFontNameItem::~wxFontNameItem(void)
795 name
= (char *) NULL
;
798 #if defined(__WXDEBUG__)
799 void wxFontNameItem::Dump(ostream
& str
)
801 str
<< "wxFontNameItem(" << name
<< ")";
805 //-----------------------------------------------------------------------------
807 //-----------------------------------------------------------------------------
809 IMPLEMENT_DYNAMIC_CLASS(wxFontNameDirectory
, wxObject
)
811 wxFontNameDirectory::wxFontNameDirectory(void)
813 table
= new wxHashTable(wxKEY_INTEGER
, 20);
817 wxFontNameDirectory::~wxFontNameDirectory()
819 // Cleanup wxFontNameItems allocated
821 wxNode
*node
= table
->Next();
823 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
825 node
= table
->Next();
830 int wxFontNameDirectory::GetNewFontId(void)
832 return (nextFontId
--);
835 void wxFontNameDirectory::Initialize()
837 Initialize(wxDEFAULT
, wxDEFAULT
, "Default");
838 Initialize(wxDECORATIVE
, wxDECORATIVE
, "Decorative");
839 Initialize(wxROMAN
, wxROMAN
, "Roman");
840 Initialize(wxMODERN
, wxMODERN
, "Modern");
841 Initialize(wxTELETYPE
, wxTELETYPE
, "Teletype");
842 Initialize(wxSWISS
, wxSWISS
, "Swiss");
843 Initialize(wxSCRIPT
, wxSCRIPT
, "Script");
846 void wxFontNameDirectory::Initialize(int fontid
, int family
, const char *resname
)
848 char *fam
, resource
[256];
850 sprintf(resource
, "Family%s", resname
);
851 SearchResource((const char *)resource
, (const char **) NULL
, 0, (char **)&fam
);
853 if (!strcmp(fam
, "Default")) family
= wxDEFAULT
;
854 else if (!strcmp(fam
, "Roman")) family
= wxROMAN
;
855 else if (!strcmp(fam
, "Decorative")) family
= wxDECORATIVE
;
856 else if (!strcmp(fam
, "Modern")) family
= wxMODERN
;
857 else if (!strcmp(fam
, "Teletype")) family
= wxTELETYPE
;
858 else if (!strcmp(fam
, "Swiss")) family
= wxSWISS
;
859 else if (!strcmp(fam
, "Script")) family
= wxSCRIPT
;
860 delete[] fam
; // free resource
862 table
->Put(fontid
, new wxFontNameItem(resname
, fontid
, family
));
865 int wxFontNameDirectory::FindOrCreateFontId(const char *name
, int family
)
869 // font exists -> return id
870 if ( (id
= GetFontId(name
)) ) return id
;
872 Initialize(id
=GetNewFontId(), family
, name
);
876 char *wxFontNameDirectory::GetScreenName(int fontid
, int weight
, int style
)
878 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
880 return item
->GetScreenName(weight
, style
);
881 // font does not exist
882 return (char *) NULL
;
885 char *wxFontNameDirectory::GetPostScriptName(int fontid
, int weight
, int style
)
887 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
889 return item
->GetPostScriptName(weight
, style
);
890 // font does not exist
891 return (char *) NULL
;
894 char *wxFontNameDirectory::GetAFMName(int fontid
, int weight
, int style
)
896 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
898 return item
->GetAFMName(weight
, style
);
899 // font does not exist
900 return (char *) NULL
;
903 char *wxFontNameDirectory::GetFontName(int fontid
)
905 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
); // find font
907 return item
->GetName();
908 // font does not exist
909 return (char *) NULL
;
912 int wxFontNameDirectory::GetFontId(const char *name
)
918 while ( (node
= table
->Next()) ) {
919 wxFontNameItem
*item
= (wxFontNameItem
*)node
->Data();
920 if (!strcmp(name
, item
->name
))
923 // font does not exist
927 int wxFontNameDirectory::GetFamily(int fontid
)
929 wxFontNameItem
*item
= (wxFontNameItem
*)table
->Get(fontid
);
933 // font does not exist