Better representation of styles
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@59957 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -619,7 +619,65 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
|
|||||||
int size = 3;
|
int size = 3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int stdFontSize = 12;
|
// Guess a standard font size
|
||||||
|
int stdFontSize = 0;
|
||||||
|
|
||||||
|
// First see if we have a default/normal style to base the size on
|
||||||
|
wxString normalTranslated(_("normal"));
|
||||||
|
wxString defaultTranslated(_("default"));
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < m_styleNames.GetCount(); i++)
|
||||||
|
{
|
||||||
|
wxString name = m_styleNames[i].Lower();
|
||||||
|
if (name.Find(wxT("normal")) != wxNOT_FOUND || name.Find(normalTranslated) != wxNOT_FOUND ||
|
||||||
|
name.Find(wxT("default")) != wxNOT_FOUND || name.Find(defaultTranslated) != wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
wxRichTextStyleDefinition* d = GetStyleSheet()->FindStyle(m_styleNames[i]);
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
|
wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet()));
|
||||||
|
if (attr2.HasFontSize())
|
||||||
|
{
|
||||||
|
stdFontSize = attr2.GetFontSize();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdFontSize == 0)
|
||||||
|
{
|
||||||
|
// Look at sizes up to 20 points, and see which is the most common
|
||||||
|
wxArrayInt sizes;
|
||||||
|
size_t maxSize = 20;
|
||||||
|
for (i = 0; i <= maxSize; i++)
|
||||||
|
sizes.Add(0);
|
||||||
|
for (i = 0; i < m_styleNames.GetCount(); i++)
|
||||||
|
{
|
||||||
|
wxRichTextStyleDefinition* d = GetStyleSheet()->FindStyle(m_styleNames[i]);
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
|
wxRichTextAttr attr2(d->GetStyleMergedWithBase(GetStyleSheet()));
|
||||||
|
if (attr2.HasFontSize())
|
||||||
|
{
|
||||||
|
if (attr2.GetFontSize() <= (int) maxSize)
|
||||||
|
sizes[attr2.GetFontSize()] ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int mostCommonSize = 0;
|
||||||
|
for (i = 0; i <= maxSize; i++)
|
||||||
|
{
|
||||||
|
if (sizes[i] > mostCommonSize)
|
||||||
|
mostCommonSize = i;
|
||||||
|
}
|
||||||
|
if (mostCommonSize > 0)
|
||||||
|
stdFontSize = mostCommonSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stdFontSize == 0)
|
||||||
|
stdFontSize = 12;
|
||||||
|
|
||||||
int thisFontSize = ((attr.GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? attr.GetFontSize() : stdFontSize;
|
int thisFontSize = ((attr.GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? attr.GetFontSize() : stdFontSize;
|
||||||
|
|
||||||
if (thisFontSize < stdFontSize)
|
if (thisFontSize < stdFontSize)
|
||||||
|
Reference in New Issue
Block a user