From 340ef5c5ab51504c005962b9fcccc6ba0959e201 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 4 Jun 2012 09:13:13 +0000 Subject: [PATCH] Corrected collection of common attributes, for clashing font size units. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71643 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextbuffer.cpp | 46 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 6ccb090e8a..6b54b33dc3 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -12411,34 +12411,44 @@ void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAtt if (attr.HasFont()) { - if (attr.HasFontPointSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_POINT_SIZE)) + // If different font size units are being used, this is a clash. + if (((attr.GetFlags() & wxTEXT_ATTR_FONT_SIZE) | (currentStyle.GetFlags() & wxTEXT_ATTR_FONT_SIZE)) == wxTEXT_ATTR_FONT_SIZE) { - if (currentStyle.HasFontPointSize()) + currentStyle.SetFontSize(0); + currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_SIZE); + clashingAttr.AddFlag(wxTEXT_ATTR_FONT_SIZE); + } + else + { + if (attr.HasFontPointSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_POINT_SIZE)) { - if (currentStyle.GetFontSize() != attr.GetFontSize()) + if (currentStyle.HasFontPointSize()) { - // Clash of attr - mark as such - clashingAttr.AddFlag(wxTEXT_ATTR_FONT_POINT_SIZE); - currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_POINT_SIZE); + if (currentStyle.GetFontSize() != attr.GetFontSize()) + { + // Clash of attr - mark as such + clashingAttr.AddFlag(wxTEXT_ATTR_FONT_POINT_SIZE); + currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_POINT_SIZE); + } } + else + currentStyle.SetFontSize(attr.GetFontSize()); } - else - currentStyle.SetFontSize(attr.GetFontSize()); - } - if (attr.HasFontPixelSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_PIXEL_SIZE)) - { - if (currentStyle.HasFontPixelSize()) + if (attr.HasFontPixelSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_PIXEL_SIZE)) { - if (currentStyle.GetFontSize() != attr.GetFontSize()) + if (currentStyle.HasFontPixelSize()) { - // Clash of attr - mark as such - clashingAttr.AddFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); - currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); + if (currentStyle.GetFontSize() != attr.GetFontSize()) + { + // Clash of attr - mark as such + clashingAttr.AddFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); + currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_PIXEL_SIZE); + } } + else + currentStyle.SetFontPixelSize(attr.GetFontSize()); } - else - currentStyle.SetFontPixelSize(attr.GetFontSize()); } if (attr.HasFontItalic() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_ITALIC)) -- 2.45.2