void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
// sets fonts to be used when displaying HTML page.
- virtual wxList* GetTempData();
-
static void AddModule(wxHtmlTagsModule *module);
// Adds tags module. see wxHtmlTagsModule for details.
void SetFontUnderlined(int x) {m_FontUnderlined = x;}
int GetFontFixed() const {return m_FontFixed;}
void SetFontFixed(int x) {m_FontFixed = x;}
+ wxString GetFontFace() const {return GetFontFixed() ? m_FontFaceFixed : m_FontFaceNormal;}
+ void SetFontFace(const wxString& face) {if (GetFontFixed()) m_FontFaceFixed = face; else m_FontFaceNormal = face;}
int GetAlign() const {return m_Align;}
void SetAlign(int a) {m_Align = a;}
// average height of normal-sized text
int m_Align;
// actual alignment
-
- wxFont *m_FontsTable[2][2][2][2][7];
+
+ wxFont* m_FontsTable[2][2][2][2][7];
+ wxString m_FontsFacesTable[2][2][2][2][7];
// table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off
// state of these flags (from left to right):
// [bold][italic][underlined][fixed_size]
#include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h"
+#include "wx/fontenum.h"
+#include "wx/tokenzr.h"
FORCE_LINK_ME(m_fonts)
TAG_HANDLER_BEGIN(FONT, "FONT")
+ TAG_HANDLER_VARS
+ wxSortedArrayString m_Faces;
+
TAG_HANDLER_PROC(tag)
{
wxColour oldclr = m_WParser -> GetActualColor();
int oldsize = m_WParser -> GetFontSize();
+ wxString oldface = m_WParser -> GetFontFace();
if (tag.HasParam(wxT("COLOR"))) {
unsigned long tmp = 0;
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
}
}
+
+ if (tag.HasParam(wxT("FACE"))) {
+ if (m_Faces.GetCount() == 0) {
+ wxFontEnumerator enu;
+ enu.EnumerateFacenames();
+ m_Faces = *enu.GetFacenames();
+ }
+ wxStringTokenizer tk(tag.GetParam(wxT("FACE")), ",");
+ int index;
+
+ while (tk.HasMoreTokens())
+ if ((index = m_Faces.Index(tk.GetNextToken())) != wxNOT_FOUND) {
+ m_WParser -> SetFontFace(m_Faces[index]);
+ m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
+ break;
+ }
+ }
ParseInner(tag);
- if (oldclr != m_WParser -> GetActualColor()) {
- m_WParser -> SetActualColor(oldclr);
- m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
- }
+ if (oldface != m_WParser -> GetFontFace()) {
+ m_WParser -> SetFontFace(oldface);
+ m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
+ }
if (oldsize != m_WParser -> GetFontSize()) {
m_WParser -> SetFontSize(oldsize);
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
+ }
+ if (oldclr != m_WParser -> GetActualColor()) {
+ m_WParser -> SetActualColor(oldclr);
+ m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
}
return TRUE;
}
for (j = 0; j < 2; j++)
for (k = 0; k < 2; k++)
for (l = 0; l < 2; l++)
- for (m = 0; m < 7; m++)
+ for (m = 0; m < 7; m++) {
m_FontsTable[i][j][k][l][m] = NULL;
+ m_FontsFacesTable[i][j][k][l][m] = wxEmptyString;
+ }
#ifdef __WXMSW__
static int default_sizes[7] = {7, 8, 10, 12, 16, 22, 30};
#else
-wxList* wxHtmlWinParser::GetTempData()
-{
- int i, j, k, l, m;
- wxFont *f;
- wxList *lst = wxHtmlParser::GetTempData();
-
- if (lst == NULL) lst = new wxList;
- lst -> DeleteContents(TRUE);
-
- for (i = 0; i < 2; i++)
- for (j = 0; j < 2; j++)
- for (k = 0; k < 2; k++)
- for (l = 0; l < 2; l++)
- for (m = 0; m < 7; m++) {
- f = m_FontsTable[i][j][k][l][m];
- if (f) lst -> Append(f);
- }
- return lst;
-}
-
-
-
void wxHtmlWinParser::AddText(const char* txt)
{
wxHtmlCell *c;
ff = GetFontFixed(),
fs = GetFontSize() - 1 /*remap from <1;7> to <0;6>*/ ;
- 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);
+ 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 (*fontptr != NULL && *faceptr != face) {
+ delete *fontptr;
+ *fontptr = NULL;
+ }
+
+ if (*fontptr == NULL) {
+ *faceptr = face;
+ *fontptr = new wxFont(
+ m_FontsSizes[fs] * m_PixelScale,
+ ff ? wxMODERN : wxSWISS,
+ fi ? wxITALIC : wxNORMAL,
+ fb ? wxBOLD : wxNORMAL,
+ fu ? TRUE : FALSE, face);
}
- m_DC -> SetFont(*(m_FontsTable[fb][fi][fu][ff][fs]));
- return (m_FontsTable[fb][fi][fu][ff][fs]);
+ m_DC -> SetFont(**fontptr);
+ return (*fontptr);
}