[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 145965d 1/7: Fix initial font after detaching
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 145965d 1/7: Fix initial font after detaching the header HTML cell |
Date: |
Thu, 11 Oct 2018 15:41:10 -0400 (EDT) |
branch: master
commit 145965d6385f4833e9bfd50b26332527ae65f7fc
Author: Vadim Zeitlin <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Fix initial font after detaching the header HTML cell
Don't detach the initial wxHtmlColourCells and wxHtmlFontCell when
removing the header from the HTML document as this resulted in using the
default back- and foreground colours and font when rendering the part of
the document without the header later, which was wrong as it didn't use
the font explicitly set for all the HTML contents by pdf_writer_wx.
In practice, this resulted in the cells following <header> tag using a
visible wrong font until the next font change, e.g. a <b>, <i> or <u>
tag occurrence.
The fix itself is trivially simple and consists in only including the
header contents itself in the header cell container, excluding the
contents of the currently opened container which was erroneously
included before.
---
ledger_pdf_generator_wx.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 9d35269..6caf75e 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -454,7 +454,17 @@ static char const* const header_cell_id =
"_lmi_page_header_id";
TAG_HANDLER_BEGIN(page_header, "HEADER")
TAG_HANDLER_PROC(tag)
{
- auto container = m_WParser->GetContainer();
+ // Although the header typically occurs at the very beginning of the
+ // HTML template, it doesn't mean that the current container is empty,
+ // quite on the contrary, it typically isn't because it contains the
+ // cells setting the initial colours and font for the HTML body and we
+ // must not make these cells part of the header cell as otherwise they
+ // would be removed from the containing HTML document later and it
+ // would use default font instead of the one set by pdf_writer_wx.
+ // So first, close the existing container and open a new one which we
+ // will mark as being the actual header cell.
+ m_WParser->CloseContainer();
+ const auto container = m_WParser->OpenContainer();
// Set a unique ID for this container to allow finding it later.
container->SetId(header_cell_id);
- [lmi-commits] [lmi] master updated (9ec9f44 -> b9f72cb), Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 42525e9 5/7: Behave reasonably in unexpected circumstances, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master ebfdc8a 3/7: Replace wxDCFontChanger with dc_font_preserver, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 145965d 1/7: Fix initial font after detaching the header HTML cell,
Greg Chicares <=
- [lmi-commits] [lmi] master 2f1464a 4/7: Improve concinnity, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 683f549 2/7: Move code manipulating wxHtmlCells into pdf_writer_wx, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master 1cfcae9 6/7: Improve concinnity, Greg Chicares, 2018/10/11
- [lmi-commits] [lmi] master b9f72cb 7/7: Improve const correctness, Greg Chicares, 2018/10/11