#if wxUSE_HTML && wxUSE_STREAMS
-#ifndef WXPRECOMP
+#ifndef WX_PRECOMP
#include "wx/intl.h"
#include "wx/dc.h"
#include "wx/log.h"
// using a fixed factor (1.2, from CSS2) is a bad idea as explained at
// http://www.w3.org/TR/CSS21/fonts.html#font-size-props but this is by far
// simplest thing to do so still do it like this for now
- sizes[0] = int(size * 0.69);
+ sizes[0] = int(size * 0.75); // exception to 1.2 rule, otherwise too small
sizes[1] = int(size * 0.83);
sizes[2] = size;
sizes[3] = int(size * 1.2);
sizes[6] = int(size * 2);
}
+static int wxGetDefaultHTMLFontSize()
+{
+ // base the default font size on the size of the default system font but
+ // also ensure that we have a font of reasonable size, otherwise small HTML
+ // fonts are unreadable
+ int size = wxNORMAL_FONT->GetPointSize();
+ if ( size < 10 )
+ size = 10;
+ return size;
+}
+
void wxHtmlWinParser::SetFonts(const wxString& normal_face,
const wxString& fixed_face,
const int *sizes)
if ( !sizes )
{
if ( !default_sizes[0] )
- wxBuildFontSizes(default_sizes, wxNORMAL_FONT->GetPointSize());
+ wxBuildFontSizes(default_sizes, wxGetDefaultHTMLFontSize());
sizes = default_sizes;
}
const wxString& fixed_face)
{
if (size == -1)
- size = wxNORMAL_FONT->GetPointSize();
+ size = wxGetDefaultHTMLFontSize();
int f_sizes[7];
wxBuildFontSizes(f_sizes, size);
m_FontBold = m_FontItalic = m_FontUnderlined = m_FontFixed = FALSE;
m_FontSize = 3; //default one
CreateCurrentFont(); // we're selecting default font into
- m_DC->GetTextExtent( wxT("H"), &m_CharWidth, &m_CharHeight);
- /* NOTE : we're not using GetCharWidth/Height() because
- of differences under X and win
- */
+
+ // we're not using GetCharWidth/Height() because of
+ // differences under X and win
+ wxCoord w,h;
+ m_DC->GetTextExtent( wxT("H"), &w, &h);
+ m_CharWidth = w;
+ m_CharHeight = h;
m_UseLink = false;
m_Link = wxHtmlLinkInfo( wxEmptyString );
if ( status == wxHTML_BLOCK )
return NULL;
- return GetFS()->OpenFile(myurl);
+ int flags = wxFS_READ;
+ if (type == wxHTML_URL_IMAGE)
+ flags |= wxFS_SEEKABLE;
+
+ return GetFS()->OpenFile(myurl, flags);
}
-void wxHtmlWinParser::AddText(const wxChar* txt)
+void wxHtmlWinParser::AddText(const wxString& txt)
{
- size_t i = 0,
- x,
- lng = wxStrlen(txt);
register wxChar d;
int templen = 0;
wxChar nbsp = GetEntitiesParser()->GetCharForCode(160 /* nbsp */);
+ size_t lng = txt.length();
if (lng+1 > m_tmpStrBufSize)
{
delete[] m_tmpStrBuf;
}
wxChar *temp = m_tmpStrBuf;
+ wxString::const_iterator i = txt.begin();
+ wxString::const_iterator end = txt.end();
+
if (m_tmpLastWasSpace)
{
- while ((i < lng) &&
- ((txt[i] == wxT('\n')) || (txt[i] == wxT('\r')) || (txt[i] == wxT(' ')) ||
- (txt[i] == wxT('\t')))) i++;
+ while ( (i < end) &&
+ (*i == wxT('\n') || *i == wxT('\r') || *i == wxT(' ') ||
+ *i == wxT('\t')) )
+ {
+ ++i;
+ }
}
- while (i < lng)
+ while (i < end)
{
- x = 0;
- d = temp[templen++] = txt[i];
+ size_t x = 0;
+ d = temp[templen++] = *i;
if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t')))
{
- i++, x++;
- while ((i < lng) && ((txt[i] == wxT('\n')) || (txt[i] == wxT('\r')) ||
- (txt[i] == wxT(' ')) || (txt[i] == wxT('\t')))) i++, x++;
+ ++i, ++x;
+ while ( (i < end) &&
+ (*i == wxT('\n') || *i == wxT('\r') ||
+ *i == wxT(' ') || *i == wxT('\t')) )
+ {
+ ++i;
+ ++x;
+ }
}
- else i++;
+ else
+ ++i;
if (x)
{