+ fs = GetFontSize() - 1 /*remap from <1;7> to <0;6>*/ ;
+
+ wxString face = ff ? m_FontFaceFixed : m_FontFaceNormal;
+ wxString *faceptr = &(m_FontsFacesTable[fb][fi][fu][ff][fs]);
+ wxFont **fontptr = &(m_FontsTable[fb][fi][fu][ff][fs]);
+#if !wxUSE_UNICODE
+ wxFontEncoding *encptr = &(m_FontsEncTable[fb][fi][fu][ff][fs]);
+#endif
+
+ if (*fontptr != NULL && (*faceptr != face
+#if !wxUSE_UNICODE
+ || *encptr != m_OutputEnc
+#endif
+ ))
+ {
+ delete *fontptr;
+ *fontptr = NULL;
+ }
+
+ if (*fontptr == NULL)
+ {
+ *faceptr = face;
+ *fontptr = new wxFont(
+ (int) (m_FontsSizes[fs] * m_PixelScale),
+ ff ? wxMODERN : wxSWISS,
+ fi ? wxITALIC : wxNORMAL,
+ fb ? wxBOLD : wxNORMAL,
+ fu ? true : false, face
+#if wxUSE_UNICODE
+ );
+#else
+ , m_OutputEnc);
+ *encptr = m_OutputEnc;
+#endif
+ }
+ m_DC->SetFont(**fontptr);
+ return (*fontptr);
+}
+
+
+
+void wxHtmlWinParser::SetLink(const wxHtmlLinkInfo& link)
+{
+ m_Link = link;
+ m_UseLink = (link.GetHref() != wxEmptyString);
+}
+
+void wxHtmlWinParser::SetFontFace(const wxString& face)
+{
+ if (GetFontFixed())
+ m_FontFaceFixed = face;
+ else
+ m_FontFaceNormal = face;
+
+#if !wxUSE_UNICODE
+ if (m_InputEnc != wxFONTENCODING_DEFAULT)
+ SetInputEncoding(m_InputEnc);
+#endif
+}
+
+void wxHtmlWinParser::ApplyStateToCell(wxHtmlCell *cell)
+{
+ // set the link:
+ if (m_UseLink)
+ cell->SetLink(GetLink());
+
+ // apply current script mode settings:
+ cell->SetScriptMode(GetScriptMode(), GetScriptBaseline());
+}
+
+
+#if !wxUSE_UNICODE
+void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
+{
+ // the character used for non-breakable space may change:
+ m_nbsp = 0;
+
+ m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
+ if (m_EncConv)
+ {
+ delete m_EncConv;
+ m_EncConv = NULL;
+ }
+
+ if (enc == wxFONTENCODING_DEFAULT)
+ return;
+
+ wxFontEncoding altfix, altnorm;
+ bool availfix, availnorm;
+
+ availnorm = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceNormal);
+ availfix = wxFontMapper::Get()->IsEncodingAvailable(enc, m_FontFaceFixed);
+
+ if (availnorm && availfix)
+ {
+ // exact match?
+ m_OutputEnc = enc;
+ }
+
+ else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false) &&
+ wxFontMapper::Get()->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, false) &&
+ altnorm == altfix)
+ {
+ // alternatives?
+ m_OutputEnc = altnorm;
+ }
+ else if (availnorm)
+ {
+ // at least normal face?
+ m_OutputEnc = enc;
+ }
+ else if (wxFontMapper::Get()->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, false))
+ {
+ m_OutputEnc = altnorm;
+ }
+ else
+ {
+#ifndef __WXMAC__
+ // okay, let's convert to ISO_8859-1, available always
+ m_OutputEnc = wxFONTENCODING_DEFAULT;
+#else
+ m_OutputEnc = wxLocale::GetSystemEncoding() ;
+#endif
+ }
+
+ m_InputEnc = enc;
+ if (m_OutputEnc == wxFONTENCODING_DEFAULT)
+ {
+ GetEntitiesParser()->SetEncoding(wxFONTENCODING_SYSTEM);
+ }
+ else
+ {
+ GetEntitiesParser()->SetEncoding(m_OutputEnc);
+ }
+
+ if (m_InputEnc == m_OutputEnc)
+ return;
+
+ m_EncConv = new wxEncodingConverter();
+ if (!m_EncConv->Init(m_InputEnc,
+ (m_OutputEnc == wxFONTENCODING_DEFAULT) ?
+ wxFONTENCODING_ISO8859_1 : m_OutputEnc,
+ wxCONVERT_SUBSTITUTE))
+ { // total failure :-(
+ wxLogError(_("Failed to display HTML document in %s encoding"),
+ wxFontMapper::GetEncodingName(enc).c_str());
+ m_InputEnc = m_OutputEnc = wxFONTENCODING_DEFAULT;
+ delete m_EncConv;
+ m_EncConv = NULL;