X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d84eb0838423075d768a425ab8a0d49d28735c05..3bc755fc89fbb7ef10442c6b5216f4c77abf4bd8:/src/gtk1/font.cpp diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp index dfb4fd8be2..6a2d12c7af 100644 --- a/src/gtk1/font.cpp +++ b/src/gtk1/font.cpp @@ -2,8 +2,7 @@ // Name: font.cpp // Purpose: // Author: Robert Roebling -// Created: 01/02/97 -// Id: +// Id: $Id$ // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -103,6 +102,9 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, { m_refData = new wxFontRefData(); + if (FontIdOrFamily == wxDEFAULT) FontIdOrFamily = wxSWISS; + M_FONTDATA->m_family = FontIdOrFamily; + if ((M_FONTDATA->m_faceName = (Face) ? copystring(Face) : (char*)NULL) ) { M_FONTDATA->m_fontId = wxTheFontNameDirectory->FindOrCreateFontId( Face, FontIdOrFamily ); @@ -113,11 +115,12 @@ wxFont::wxFont(int PointSize, int FontIdOrFamily, int Style, int Weight, M_FONTDATA->m_fontId = FontIdOrFamily; M_FONTDATA->m_family = wxTheFontNameDirectory->GetFamily( FontIdOrFamily ); } - if (Style == wxDEFAULT) Style = wxSWISS; + + if (Style == wxDEFAULT) Style = wxNORMAL; M_FONTDATA->m_style = Style; if (Weight == wxDEFAULT) Weight = wxNORMAL; M_FONTDATA->m_weight = Weight; - if (PointSize == wxDEFAULT) PointSize = 10; + if (PointSize == wxDEFAULT) PointSize = 12; M_FONTDATA->m_pointSize = PointSize; M_FONTDATA->m_underlined = Underlined; @@ -179,25 +182,27 @@ bool wxFont::operator != ( const wxFont& font ) bool wxFont::Ok() const { - if (!m_refData) - { - wxFAIL_MSG( "invalid font" ); - return FALSE; - } - else - return TRUE; + return (m_refData != NULL); } int wxFont::GetPointSize(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } return M_FONTDATA->m_pointSize; } wxString wxFont::GetFaceString(void) const { - if (!Ok()) return ""; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); return s; @@ -205,7 +210,11 @@ wxString wxFont::GetFaceString(void) const wxString wxFont::GetFaceName(void) const { - if (!Ok()) return ""; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return ""; + } wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId ); return s; @@ -213,14 +222,22 @@ wxString wxFont::GetFaceName(void) const int wxFont::GetFamily(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } return M_FONTDATA->m_family; } wxString wxFont::GetFamilyString(void) const { - if (!Ok()) return "wxDEFAULT"; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } switch (M_FONTDATA->m_family) { @@ -238,21 +255,33 @@ wxString wxFont::GetFamilyString(void) const int wxFont::GetFontId(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } return M_FONTDATA->m_fontId; // stub } int wxFont::GetStyle(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } return M_FONTDATA->m_style; } wxString wxFont::GetStyleString(void) const { - if (!Ok()) return "wxDEFAULT"; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } switch (M_FONTDATA->m_style) { @@ -267,14 +296,22 @@ wxString wxFont::GetStyleString(void) const int wxFont::GetWeight(void) const { - if (!Ok()) return 0; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return 0; + } return M_FONTDATA->m_weight; } wxString wxFont::GetWeightString(void) const { - if (!Ok()) return "wxDEFAULT"; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return "wxDEFAULT"; + } switch (M_FONTDATA->m_weight) { @@ -289,7 +326,11 @@ wxString wxFont::GetWeightString(void) const bool wxFont::GetUnderlined(void) const { - if (!Ok()) return FALSE; + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return FALSE; + } return M_FONTDATA->m_underlined; } @@ -305,6 +346,12 @@ static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid, GdkFont *wxFont::GetInternalFont(float scale) const { + if (!Ok()) + { + wxFAIL_MSG( "invalid font" ); + return (GdkFont*) NULL; + } + if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font; long int_scale = long(scale * 100.0 + 0.5); // key for fontlist @@ -318,8 +365,27 @@ GdkFont *wxFont::GetInternalFont(float scale) const } else { - font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, - M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); +/* + if (int_scale == 100) printf( "int_scale.\n" ); + if (M_FONTDATA->m_style == wxSWISS) printf( "swiss.\n" ); + if (M_FONTDATA->m_pointSize == 12) printf( "12.\n" ); + if (M_FONTDATA->m_weight == wxNORMAL) printf( "normal.\n" ); + if (M_FONTDATA->m_underlined == FALSE) printf( "false.\n" ); +*/ + if ((int_scale == 100) && + (M_FONTDATA->m_family == wxSWISS) && + (M_FONTDATA->m_style == wxNORMAL) && + (M_FONTDATA->m_pointSize == 12) && + (M_FONTDATA->m_weight == wxNORMAL) && + (M_FONTDATA->m_underlined == FALSE)) + { + font = gdk_font_load( "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" ); + } + else + { + font = wxLoadQueryNearestFont( point_scale, M_FONTDATA->m_fontId, M_FONTDATA->m_style, + M_FONTDATA->m_weight, M_FONTDATA->m_underlined ); + } M_FONTDATA->m_scaled_xfonts.Append( int_scale, (wxObject*)font ); } if (!font) @@ -698,7 +764,7 @@ public: inline int GetFamily(void) {return family;} inline int GetId(void) {return id;} inline bool IsRoman(void) {return isroman;} -#if WXDEBUG +#if defined(__WXDEBUG__) void Dump(ostream& str); #endif @@ -729,7 +795,7 @@ wxFontNameItem::~wxFontNameItem(void) name = (char *) NULL; } -#if WXDEBUG +#if defined(__WXDEBUG__) void wxFontNameItem::Dump(ostream& str) { str << "wxFontNameItem(" << name << ")";