[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations |
Date: |
Tue, 30 Jan 2018 17:21:51 -0500 (EST) |
branch: master
commit 234cd39c8d4f3622b44b795d25ed9a6cfc97f9ce
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Use custom font sizes to be closer to the existing illustrations
Allow specifying custom font sizes in pdf_writer_wx and use this to get
closer to the existing output which uses specific font sizes.
---
ledger_pdf_generator_wx.cpp | 37 +++++++++++++++++++++++++++----------
pdf_writer_wx.cpp | 30 ++++++++++++++++++++++++------
pdf_writer_wx.hpp | 8 ++++++--
3 files changed, 57 insertions(+), 18 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 6863d11..432f9c9 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -50,7 +50,7 @@ class pdf_illustration
pdf_illustration(Ledger const& ledger
,fs::path const& output
)
- :writer_(output.string(), wxPORTRAIT)
+ :writer_(output.string(), wxPORTRAIT, &html_font_sizes)
,dc_(writer_.dc())
,ledger_(ledger)
,properties_(properties::init(ledger))
@@ -118,6 +118,11 @@ class pdf_illustration
};
private:
+ // Use non-default font sizes to make it simpler to replicate the existing
+ // illustrations.
+ static std::array<int, 7> const html_font_sizes;
+
+
// Writer object used for the page metrics and higher level functions.
pdf_writer_wx writer_;
@@ -135,6 +140,16 @@ class pdf_illustration
int page_number_{0};
};
+std::array<int, 7> const pdf_illustration::html_font_sizes =
+ { 8
+ , 9
+ ,10
+ ,12
+ ,14
+ ,18
+ ,20
+ };
+
class page
{
public:
@@ -292,15 +307,17 @@ class cover_page : public page
);
auto const footer_html = tag::p[attr::align("center")]
- (text::from
- (invar.InsCoShortName
- +"Financial Group is a marketing name for "
- +invar.InsCoName
- +"("
- +invar.InsCoShortName
- +") and its affiliated company and sales representatives, "
- +invar.InsCoAddr
- +"."
+ (tag::font[attr::size("-1")]
+ (text::from
+ (invar.InsCoShortName
+ +"Financial Group is a marketing name for "
+ +invar.InsCoName
+ +"("
+ +invar.InsCoShortName
+ +") and its affiliated company and sales representatives, "
+ +invar.InsCoAddr
+ +"."
+ )
)
);
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index c3b20ee..6b4ab4d 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -53,6 +53,7 @@ wxPrintData make_print_data
pdf_writer_wx::pdf_writer_wx
(wxString const& output_filename
,wxPrintOrientation orientation
+ ,std::array<int, 7> const* html_font_sizes
)
:print_data_ {make_print_data(output_filename, orientation)}
,pdf_dc_ {print_data_}
@@ -74,16 +75,33 @@ pdf_writer_wx::pdf_writer_wx
// Use a standard PDF Helvetica font (without embedding any custom fonts in
// the generated file, the only other realistic choice is Times New Roman).
pdf_dc_.SetFont
- (wxFontInfo(8).Family(wxFONTFAMILY_SWISS).FaceName("Helvetica")
+ (wxFontInfo
+ (html_font_sizes
+ ? html_font_sizes->at(2)
+ : 8
+ )
+ .Family(wxFONTFAMILY_SWISS)
+ .FaceName("Helvetica")
);
// Create an HTML parser to allow easily adding HTML contents to the
output.
html_parser_.SetDC(&pdf_dc_);
- html_parser_.SetStandardFonts
- (pdf_dc_.GetFont().GetPointSize()
- ,"Helvetica"
- ,"Courier"
- );
+ if(html_font_sizes)
+ {
+ html_parser_.SetFonts
+ ("Helvetica"
+ ,"Courier"
+ ,html_font_sizes->data()
+ );
+ }
+ else
+ {
+ html_parser_.SetStandardFonts
+ (pdf_dc_.GetFont().GetPointSize()
+ ,"Helvetica"
+ ,"Courier"
+ );
+ }
}
/// Output an image at the given scale into the PDF.
diff --git a/pdf_writer_wx.hpp b/pdf_writer_wx.hpp
index 20e1726..b375fcd 100644
--- a/pdf_writer_wx.hpp
+++ b/pdf_writer_wx.hpp
@@ -30,6 +30,7 @@
#include <wx/pdfdc.h>
+#include <array>
#include <memory> // std::unique_ptr
namespace html { class text; }
@@ -42,9 +43,12 @@ enum enum_output_mode
class pdf_writer_wx
{
public:
+ // Optional html_font_sizes array allows to override default font sizes for
+ // the standard HTML3 fonts (1..7).
pdf_writer_wx
- (wxString const& output_filename
- ,wxPrintOrientation orientation
+ (wxString const& output_filename
+ ,wxPrintOrientation orientation
+ ,std::array<int, 7> const* html_font_sizes = nullptr
);
pdf_writer_wx(pdf_writer_wx const&) = delete;
- [lmi-commits] [lmi] master dbaf3c4 048/156: Render PDF illustrations in two passes, (continued)
- [lmi-commits] [lmi] master dbaf3c4 048/156: Render PDF illustrations in two passes, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master de9567e 152/156: Fix misplaced commas in ledger PDF generator code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 783befa 006/156: Add separate class for representing HTML contents, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8c5be11 128/156: Use proper types for get_two_column_header() parameters, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 257ff4b 065/156: Add numeric summary table to PDF illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ef38c9d 141/156: Revert the title map related changes, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b1ab0fa 126/156: Leave a gap between upper footer part and main page contents, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 940198c 059/156: Add numeric summary attachment page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b341a2a 061/156: Factor out using_illustration_table helper class, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1b46585 076/156: Use MarketingNameFootnote & StateMarketingImprimatur on cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 234cd39 012/156: Use custom font sizes to be closer to the existing illustrations,
Greg Chicares <=
- [lmi-commits] [lmi] master 956fcca 071/156: Change the second narrative summary page to use a template too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master dbe5955 015/156: Factor out html_interpolator from pdf_illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9665573 070/156: Change narrative summary page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a629602 083/156: Use custom <scaled_image> HTML tag for the embedded images, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b425030 082/156: Factor out html_cell_for_pdf_output from numeric_summary_table_cell, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d99576a 069/156: Change cover page to use an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 416ab02 030/156: Add support for vector variables to PDF generating code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d4dfaa9 075/156: Also use data directory for image files referenced from HTML, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f98db5 081/156: Don't show "Age 70" row in numeric summary for composites, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f8853b9 090/156: Add "contract numbers" fragment to the header, Greg Chicares, 2018/01/30