- fs = GetFontSize() + 2 /*remap from <-2;4> to <0;7>*/ ;
-
- if (m_FontsTable[fb][fi][fu][ff][fs] == NULL) {
- m_FontsTable[fb][fi][fu][ff][fs] =
- new wxFont(
- m_FontsSizes[fs] * m_PixelScale,
- ff ? wxMODERN : wxSWISS,
- fi ? wxITALIC : wxNORMAL,
- fb ? wxBOLD : wxNORMAL,
- fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal);
+ 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]);
+ wxFontEncoding *encptr = &(m_FontsEncTable[fb][fi][fu][ff][fs]);
+
+ if (*fontptr != NULL && (*faceptr != face || *encptr != m_OutputEnc))
+ {
+ delete *fontptr;
+ *fontptr = NULL;
+ }
+
+ if (*fontptr == NULL)
+ {
+ *faceptr = face;
+ *encptr = m_OutputEnc;
+ *fontptr = new wxFont(
+ (int) (m_FontsSizes[fs] * m_PixelScale),
+ ff ? wxMODERN : wxSWISS,
+ fi ? wxITALIC : wxNORMAL,
+ fb ? wxBOLD : wxNORMAL,
+ fu ? TRUE : FALSE, face,
+ m_OutputEnc);
+ }
+ 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 (m_InputEnc != wxFONTENCODING_DEFAULT)
+ SetInputEncoding(m_InputEnc);
+}
+
+
+
+void wxHtmlWinParser::SetInputEncoding(wxFontEncoding enc)
+{
+ 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;
+
+ // exact match?
+ availnorm = wxTheFontMapper->IsEncodingAvailable(enc, m_FontFaceNormal);
+ availfix = wxTheFontMapper->IsEncodingAvailable(enc, m_FontFaceFixed);
+ if (availnorm && availfix)
+ m_OutputEnc = enc;
+
+ // alternatives?
+ else if (wxTheFontMapper->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE) &&
+ wxTheFontMapper->GetAltForEncoding(enc, &altfix, m_FontFaceFixed, FALSE) &&
+ altnorm == altfix)
+ m_OutputEnc = altnorm;
+
+ // at least normal face?
+ else if (availnorm)
+ m_OutputEnc = enc;
+ else if (wxTheFontMapper->GetAltForEncoding(enc, &altnorm, m_FontFaceNormal, FALSE))
+ m_OutputEnc = altnorm;
+
+ // okay, let convert to ISO_8859-1, available always
+ else
+ m_OutputEnc = wxFONTENCODING_DEFAULT;
+
+ m_InputEnc = enc;
+
+ 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 failture :-(
+ 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;