Apply Mart R.'s patch for improved font width

handling and minor doc corrections.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2005-04-13 13:53:19 +00:00
parent 308a5aeb9d
commit 0f6858b69e
4 changed files with 109 additions and 97 deletions

View File

@@ -36,6 +36,19 @@ enum wxFontFamily
}; };
\end{verbatim} \end{verbatim}
The possible values for the \arg{weight} parameter are (the old names
are for compatibility only):
\begin{verbatim}
enum wxFontWeight
{
wxFONTWEIGHT_NORMAL = wxNORMAL,
wxFONTWEIGHT_LIGHT = wxLIGHT,
wxFONTWEIGHT_BOLD = wxBOLD,
wxFONTWEIGHT_MAX
};
\end{verbatim}
The font flags which can be used during the font creation are: The font flags which can be used during the font creation are:
\begin{verbatim} \begin{verbatim}
@@ -152,11 +165,11 @@ wxSWISS\_FONT}
Default constructor. Default constructor.
\func{}{wxFont}{\param{int}{ pointSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{int}{ weight}, \func{}{wxFont}{\param{int}{ pointSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{wxFontWeight}{ weight},
\param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""}, \param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""},
\param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
\func{}{wxFont}{\param{int}{ pixelSize}, \param{int}{ family}, \param{int}{ style}, \param{int}{ weight}, \func{}{wxFont}{\param{int}{ pixelSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{wxFontWeight}{ weight},
\param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""}, \param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""},
\param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
@@ -175,17 +188,25 @@ the static \helpref{New}{wxfontnew} method must be used.}
\twocolwidtha{5cm} \twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt \begin{twocollist}\itemsep=0pt
\twocolitem{{\bf wxDEFAULT}}{Chooses a default font.} \twocolitem{{\bf wxFONTFAMILY\_DEFAULT}}{Chooses a default font.}
\twocolitem{{\bf wxDECORATIVE}}{A decorative font.} \twocolitem{{\bf wxFONTFAMILY\_DECORATIVE}}{A decorative font.}
\twocolitem{{\bf wxROMAN}}{A formal, serif font.} \twocolitem{{\bf wxFONTFAMILY\_ROMAN}}{A formal, serif font.}
\twocolitem{{\bf wxSCRIPT}}{A handwriting font.} \twocolitem{{\bf wxFONTFAMILY\_SCRIPT}}{A handwriting font.}
\twocolitem{{\bf wxSWISS}}{A sans-serif font.} \twocolitem{{\bf wxFONTFAMILY\_SWISS}}{A sans-serif font.}
\twocolitem{{\bf wxMODERN}}{A fixed pitch font.} \twocolitem{{\bf wxFONTFAMILY\_MODERN}}{A fixed pitch font.}
\twocolitem{{\bf wxFONTFAMILY\_TELETYPE}}{A teletype font.}
\end{twocollist}} \end{twocollist}}
\docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.} \docparam{style}{One of {\bf wxFONTSTYLE\_NORMAL}, {\bf wxFONTSTYLE\_SLANT} and {\bf wxFONTSTYLE\_ITALIC}.}
\docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.} \docparam{weight}{Font weight, sometimes also referred to as font boldness. One of:
\twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt
\twocolitem{{\bf wxFONTWEIGHT\_NORMAL}}{Normal font.}
\twocolitem{{\bf wxFONTWEIGHT\_LIGHT}}{Light font.}
\twocolitem{{\bf wxFONTWEIGHT\_BOLD}}{Bold font.}
\end{twocollist}}
\docparam{underline}{The value can be true or false. At present this has an effect on Windows and Motif 2.x only.} \docparam{underline}{The value can be true or false. At present this has an effect on Windows and Motif 2.x only.}
@@ -269,9 +290,9 @@ typeface information.
\membersection{wxFont::GetFamily}\label{wxfontgetfamily} \membersection{wxFont::GetFamily}\label{wxfontgetfamily}
\constfunc{int}{GetFamily}{\void} \constfunc{wxFontFamily}{GetFamily}{\void}
Gets the font family. See \helpref{wxFont::wxFont}{wxfontctor} for a list of valid Gets the font family. See \helpref{wxFont::SetFamily}{wxfontsetfamily} for a list of valid
family identifiers. family identifiers.
\wxheading{See also} \wxheading{See also}
@@ -327,7 +348,7 @@ Returns true if the font is underlined, false otherwise.
\membersection{wxFont::GetWeight}\label{wxfontgetweight} \membersection{wxFont::GetWeight}\label{wxfontgetweight}
\constfunc{int}{GetWeight}{\void} \constfunc{wxFontWeight}{GetWeight}{\void}
Gets the font weight. See \helpref{wxFont::wxFont}{wxfontctor} for a list of valid Gets the font weight. See \helpref{wxFont::wxFont}{wxfontctor} for a list of valid
weight identifiers. weight identifiers.
@@ -339,7 +360,7 @@ weight identifiers.
\membersection{wxFont::New}\label{wxfontnew} \membersection{wxFont::New}\label{wxfontnew}
\func{static wxFont *}{New}{\param{int}{ pointSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{int}{ weight}, \func{static wxFont *}{New}{\param{int}{ pointSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{wxFontWeight}{ weight},
\param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""}, \param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""},
\param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
@@ -347,7 +368,7 @@ weight identifiers.
\param{int}{ flags = \texttt{wxFONTFLAG\_DEFAULT}}, \param{const wxString\& }{faceName = ""}, \param{int}{ flags = \texttt{wxFONTFLAG\_DEFAULT}}, \param{const wxString\& }{faceName = ""},
\param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
\func{static wxFont *}{New}{\param{const wxSize\&}{ pixelSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{int}{ weight}, \func{static wxFont *}{New}{\param{const wxSize\&}{ pixelSize}, \param{wxFontFamily}{ family}, \param{int}{ style}, \param{wxFontWeight}{ weight},
\param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""}, \param{const bool}{ underline = false}, \param{const wxString\& }{faceName = ""},
\param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}} \param{wxFontEncoding }{encoding = wxFONTENCODING\_DEFAULT}}
@@ -405,7 +426,7 @@ and then for a font belonging to the same family.
\membersection{wxFont::SetFamily}\label{wxfontsetfamily} \membersection{wxFont::SetFamily}\label{wxfontsetfamily}
\func{void}{SetFamily}{\param{int}{ family}} \func{void}{SetFamily}{\param{wxFontFamily}{ family}}
Sets the font family. Sets the font family.
@@ -415,12 +436,13 @@ Sets the font family.
\twocolwidtha{5cm} \twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt \begin{twocollist}\itemsep=0pt
\twocolitem{{\bf wxDEFAULT}}{Chooses a default font.} \twocolitem{{\bf wxFONTFAMILY\_DEFAULT}}{Chooses a default font.}
\twocolitem{{\bf wxDECORATIVE}}{A decorative font.} \twocolitem{{\bf wxFONTFAMILY\_DECORATIVE}}{A decorative font.}
\twocolitem{{\bf wxROMAN}}{A formal, serif font.} \twocolitem{{\bf wxFONTFAMILY\_ROMAN}}{A formal, serif font.}
\twocolitem{{\bf wxSCRIPT}}{A handwriting font.} \twocolitem{{\bf wxFONTFAMILY\_SCRIPT}}{A handwriting font.}
\twocolitem{{\bf wxSWISS}}{A sans-serif font.} \twocolitem{{\bf wxFONTFAMILY\_SWISS}}{A sans-serif font.}
\twocolitem{{\bf wxMODERN}}{A fixed pitch font.} \twocolitem{{\bf wxFONTFAMILY\_MODERN}}{A fixed pitch font.}
\twocolitem{{\bf wxFONTFAMILY\_TELETYPE}}{A teletype font.}
\end{twocollist}} \end{twocollist}}
\wxheading{See also} \wxheading{See also}
@@ -461,7 +483,7 @@ Sets the font style.
\wxheading{Parameters} \wxheading{Parameters}
\docparam{style}{One of {\bf wxNORMAL}, {\bf wxSLANT} and {\bf wxITALIC}.} \docparam{style}{One of {\bf wxFONTSTYLE\_NORMAL}, {\bf wxFONTSTYLE\_SLANT} and {\bf wxFONTSTYLE\_ITALIC}.}
\wxheading{See also} \wxheading{See also}
@@ -485,13 +507,20 @@ Sets underlining.
\membersection{wxFont::SetWeight}\label{wxfontsetweight} \membersection{wxFont::SetWeight}\label{wxfontsetweight}
\func{void}{SetWeight}{\param{int}{ weight}} \func{void}{SetWeight}{\param{wxFontWeight}{ weight}}
Sets the font weight. Sets the font weight.
\wxheading{Parameters} \wxheading{Parameters}
\docparam{weight}{One of {\bf wxNORMAL}, {\bf wxLIGHT} and {\bf wxBOLD}.} \docparam{weight}{One of:
\twocolwidtha{5cm}
\begin{twocollist}\itemsep=0pt
\twocolitem{{\bf wxFONTWEIGHT\_NORMAL}}{Normal font.}
\twocolitem{{\bf wxFONTWEIGHT\_LIGHT}}{Light font.}
\twocolitem{{\bf wxFONTWEIGHT\_BOLD}}{Bold font.}
\end{twocollist}}
\wxheading{See also} \wxheading{See also}

View File

@@ -256,26 +256,19 @@ void wxFontRefData::InitFromNative()
break; break;
} }
switch (pango_font_description_get_weight( desc )) PangoWeight pango_weight = pango_font_description_get_weight( desc );
if (pango_weight >= 600)
{
m_weight = wxFONTWEIGHT_BOLD;
}
else if (pango_weight < 350)
{ {
case PANGO_WEIGHT_ULTRALIGHT:
m_weight = wxFONTWEIGHT_LIGHT; m_weight = wxFONTWEIGHT_LIGHT;
break; }
case PANGO_WEIGHT_LIGHT: else
m_weight = wxFONTWEIGHT_LIGHT; {
break;
case PANGO_WEIGHT_NORMAL:
m_weight = wxFONTWEIGHT_NORMAL; m_weight = wxFONTWEIGHT_NORMAL;
break;
case PANGO_WEIGHT_BOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_ULTRABOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_HEAVY:
m_weight = wxFONTWEIGHT_BOLD;
break;
} }
if (m_faceName == wxT("monospace")) if (m_faceName == wxT("monospace"))

View File

@@ -256,26 +256,19 @@ void wxFontRefData::InitFromNative()
break; break;
} }
switch (pango_font_description_get_weight( desc )) PangoWeight pango_weight = pango_font_description_get_weight( desc );
if (pango_weight >= 600)
{
m_weight = wxFONTWEIGHT_BOLD;
}
else if (pango_weight < 350)
{ {
case PANGO_WEIGHT_ULTRALIGHT:
m_weight = wxFONTWEIGHT_LIGHT; m_weight = wxFONTWEIGHT_LIGHT;
break; }
case PANGO_WEIGHT_LIGHT: else
m_weight = wxFONTWEIGHT_LIGHT; {
break;
case PANGO_WEIGHT_NORMAL:
m_weight = wxFONTWEIGHT_NORMAL; m_weight = wxFONTWEIGHT_NORMAL;
break;
case PANGO_WEIGHT_BOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_ULTRABOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_HEAVY:
m_weight = wxFONTWEIGHT_BOLD;
break;
} }
if (m_faceName == wxT("monospace")) if (m_faceName == wxT("monospace"))

View File

@@ -29,6 +29,7 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/font.h" // wxFont enums
#include "wx/encinfo.h" #include "wx/encinfo.h"
#endif // PCH #endif // PCH
@@ -99,31 +100,27 @@ wxFontStyle wxNativeFontInfo::GetStyle() const
wxFontWeight wxNativeFontInfo::GetWeight() const wxFontWeight wxNativeFontInfo::GetWeight() const
{ {
wxFontWeight m_weight = wxFONTWEIGHT_NORMAL; #if 0
// We seem to currently initialize only by string.
// In that case PANGO_FONT_MASK_WEIGHT is always set.
if (!(pango_font_description_get_set_fields(description) & PANGO_FONT_MASK_WEIGHT))
return wxFONTWEIGHT_NORMAL;
#endif
switch (pango_font_description_get_weight( description )) PangoWeight pango_weight = pango_font_description_get_weight( description );
{
case PANGO_WEIGHT_ULTRALIGHT:
m_weight = wxFONTWEIGHT_LIGHT;
break;
case PANGO_WEIGHT_LIGHT:
m_weight = wxFONTWEIGHT_LIGHT;
break;
case PANGO_WEIGHT_NORMAL:
m_weight = wxFONTWEIGHT_NORMAL;
break;
case PANGO_WEIGHT_BOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_ULTRABOLD:
m_weight = wxFONTWEIGHT_BOLD;
break;
case PANGO_WEIGHT_HEAVY:
m_weight = wxFONTWEIGHT_BOLD;
break;
}
return m_weight; // Until the API can be changed the following ranges of weight values are used:
// wxFONTWEIGHT_LIGHT: 100 .. 349 - range of 250
// wxFONTWEIGHT_NORMAL: 350 .. 599 - range of 250
// wxFONTWEIGHT_BOLD: 600 .. 900 - range of 301 (600 is "semibold" already)
if (pango_weight >= 600)
return wxFONTWEIGHT_BOLD;
if (pango_weight < 350)
return wxFONTWEIGHT_LIGHT;
return wxFONTWEIGHT_NORMAL;
} }
bool wxNativeFontInfo::GetUnderlined() const bool wxNativeFontInfo::GetUnderlined() const