Beispiel #1
0
wxString wxFontPickerCtrl::Font2String(const wxFont &f)
{
    wxString ret = f.GetNativeFontInfoUserDesc();
#ifdef __WXMSW__
    // on wxMSW the encoding of the font is appended at the end of the string;
    // since encoding is not very user-friendly we remove it.
    wxFontEncoding enc = f.GetEncoding();
    if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM )
        ret = ret.BeforeLast(wxT(' '));
#endif
    return ret;
}
Beispiel #2
0
wxString xsFontPropIO::ToString(wxFont value)
{
    return value.GetNativeFontInfoUserDesc();
}
Beispiel #3
0
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
    wxPaintDC dc(this);
    PrepareDC(dc);

    // set background
    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();
    dc.SetFont(m_font);

    // one text line height
    wxCoord hLine = dc.GetCharHeight();

    // the current text origin
    wxCoord x = 5,
            y = 5;

    // output the font name/info
    wxString fontInfo;

    fontInfo.Printf(wxT("Face name: %s, family: %s"),
                    m_font.GetFaceName().c_str(),
                    m_font.GetFamilyString().c_str());

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    fontInfo.Printf(wxT("Size: %d points or %d pixels; %d*%d average char size"),
                    m_font.GetPointSize(),
                    m_font.GetPixelSize().y,
                    dc.GetCharWidth(), dc.GetCharHeight());

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    fontInfo.Printf(wxT("Style: %s, weight: %s, fixed width: %s, encoding: %s"),
                    m_font.GetStyleString().c_str(),
                    m_font.GetWeightString().c_str(),
                    m_font.IsFixedWidth() ? wxT("yes") : wxT("no"),
                    wxFontMapper::GetEncodingDescription(m_font.GetEncoding()));

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    if ( m_font.IsOk() )
    {
        const wxNativeFontInfo *info = m_font.GetNativeFontInfo();
        if ( info )
        {
            wxString fontDesc = m_font.GetNativeFontInfoUserDesc();
            fontInfo.Printf(wxT("Native font info: %s"), fontDesc.c_str());

            dc.DrawText(fontInfo, x, y);
            y += hLine;
        }
    }

    y += hLine;

    // prepare to draw the font
    dc.SetTextForeground(m_colour);

    // the size of one cell (Normally biggest char + small margin)
    wxCoord maxCharWidth, maxCharHeight;
    dc.GetTextExtent(wxT("W"), &maxCharWidth, &maxCharHeight);
    int w = maxCharWidth + 5,
        h = maxCharHeight + 4;


    // print all font symbols from 32 to 256 in 7 rows of 32 chars each
    for ( int i = 0; i < 7; i++ )
    {
        for ( int j = 0; j < 32; j++ )
        {
            wxChar c = (wxChar)(32 * (i + 1) + j);

            wxCoord charWidth, charHeight;
            dc.GetTextExtent(c, &charWidth, &charHeight);
            dc.DrawText
            (
                c,
                x + w*j + (maxCharWidth - charWidth) / 2 + 1,
                y + h*i + (maxCharHeight - charHeight) / 2
            );
        }
    }

    // draw the lines between them
    dc.SetPen(*wxBLUE_PEN);
    int l;

    // horizontal
    for ( l = 0; l < 8; l++ )
    {
        int yl = y + h*l - 2;
        dc.DrawLine(x - 2, yl, x + 32*w - 1, yl);
    }

    // and vertical
    for ( l = 0; l < 33; l++ )
    {
        int xl = x + w*l - 2;
        dc.DrawLine(xl, y - 2, xl, y + 7*h - 1);
    }
}
Beispiel #4
0
 // wxFont
 static wxString FontToString(const wxFont & font)
     { return font.GetNativeFontInfoUserDesc(); }