[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 5ea5c86 101/156: Simplify and correct current
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 5ea5c86 101/156: Simplify and correct current PDF DC font handling |
Date: |
Tue, 30 Jan 2018 17:22:21 -0500 (EST) |
branch: master
commit 5ea5c86f17e73c6cdc5b63fb04d16a5eff88c8f5
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Simplify and correct current PDF DC font handling
Only set the smaller font (and although the pen) used for tables once,
when creating the table generator object and avoid changing in it
pdf_writer_wx::output_html() to make it unnecessary to ever set it
again.
This ensures that the same font size is used for the table column widths
determination and actually outputting the text of these columns, which
required explicit use of wxDCFontChanger before.
Also explicitly use 9pt font instead of using wxFont::Smaller() which
resulted in too small font (8pt).
---
ledger_pdf_generator_wx.cpp | 25 +++++++++++--------------
pdf_writer_wx.cpp | 4 ++++
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 0bd03e1..a80b111 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -335,8 +335,19 @@ class using_illustration_table
,pdf_writer_wx& writer
) const
{
+ // Set the smaller font used for all tables before creating the table
+ // generator which uses the DC font for its measurements.
+ auto& dc = writer.dc();
+ auto font = dc.GetFont();
+ font.SetPointSize(9);
+ dc.SetFont(font);
+
illustration_table_generator table(writer);
+ // But set the highlight colour for drawing separator lines after
+ // creating it to override its default pen.
+ dc.SetPen(HIGHLIGHT_COL);
+
int column = 0;
for(auto const& i : get_table_columns())
{
@@ -1224,8 +1235,6 @@ class numeric_summary_table_cell
{
auto const& ledger = pdf_context_for_html_output.ledger();
auto& writer = pdf_context_for_html_output.writer();
- auto& dc = writer.dc();
- wxDCFontChanger set_smaller_font(dc, dc.GetFont().Smaller());
illustration_table_generator
table{create_table_generator(ledger, writer)};
@@ -1600,13 +1609,6 @@ class tabular_detail_page : public
page_with_tabular_report
,output_mode
);
- auto& dc = writer.dc();
-
- // Decrease the font size for the table to match the main page
- // body text size.
- dc.SetFont(dc.GetFont().Smaller());
- dc.SetPen(HIGHLIGHT_COL);
-
// Make a copy because we want the real pos_y to be modified only once,
// not twice, by both output_super_header() calls.
auto pos_y_copy = pos_y;
@@ -1723,11 +1725,6 @@ class tabular_detail2_page : public
page_with_tabular_report
,output_mode
);
- // Decrease the font size for the table to match the main page
- // body text size.
- auto& dc = writer.dc();
- dc.SetFont(dc.GetFont().Smaller());
-
table.output_header(&pos_y, output_mode);
pos_y += table.get_separator_line_height();
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index 9b9b193..5ae36c2 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -174,6 +174,10 @@ int pdf_writer_wx::output_html
,enum_output_mode output_mode
)
{
+ // We don't really want to change the font, but to preserve the current DC
+ // font which is changed by rendering the HTML contents.
+ wxDCFontChanger preserve_font(pdf_dc_, wxFont());
+
auto const html_str = wxString::FromUTF8(html.as_html());
std::unique_ptr<wxHtmlContainerCell> const cell
(static_cast<wxHtmlContainerCell*>(html_parser_.Parse(html_str))
- [lmi-commits] [lmi] master ea2564b 099/156: Split the NASD header template in the upper and lower parts, (continued)
- [lmi-commits] [lmi] master ea2564b 099/156: Split the NASD header template in the upper and lower parts, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c1bf4a8 032/156: Adjust position of the right hand side of the header manually, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 89b4674 120/156: Add automatic support for multiline super-headers, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0f885a2 116/156: Define CorpNameAbbrev60 and Insured1Abbrev30 in common code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 08559c3 121/156: Factor out base_suffix() and ir_suffix() functions, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 36c84ce 123/156: Add another individual private placement illustration page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0ecc8ec 036/156: Add support for partials to our ad hoc Mustache parser, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6f09722 107/156: Add missing words to the narrative summary continuation page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6510601 150/156: Rename a mute variable to avoid gcc -Wshadow warning, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 048ae05 093/156: Start NASD PDF illustration class implementation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5ea5c86 101/156: Simplify and correct current PDF DC font handling,
Greg Chicares <=
- [lmi-commits] [lmi] master ec490eb 153/156: Revise and extend some comments in PDF generation code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 38cab5e 096/156: Make footer template depend on illustration kind, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d1204c2 111/156: Factor out common parts of render_or_measure_fixed_page_part(), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e388f6e 037/156: Add beginning of numeric summary page using an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_basic_tabular_report class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a85943b 124/156: Add the rest of individual private placement illustration pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f0b9cea 113/156: Add "Assumption Detail" page to NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 031070b 132/156: Implement supplemental report page for the regular illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9fe1d07 125/156: Implement page-specific footer for "Tabular Details" pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f3a02e 078/156: Add company logo to the cover page, Greg Chicares, 2018/01/30