gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Mon Oct 26 17:08:53 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/946cbef9 (commit)
via https://github.com/Gnucash/gnucash/commit/4ddd28a5 (commit)
via https://github.com/Gnucash/gnucash/commit/676cc337 (commit)
via https://github.com/Gnucash/gnucash/commit/974342bb (commit)
from https://github.com/Gnucash/gnucash/commit/92f27278 (commit)
commit 946cbef95f3e68131f49bcf1801f310a476e6e0f
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Oct 26 14:05:31 2020 -0700
HTML fonts: Parse additional values of font-weight from the pango font name.
diff --git a/gnucash/report/html-fonts.scm b/gnucash/report/html-fonts.scm
index ea5a3126f..ee1598948 100644
--- a/gnucash/report/html-fonts.scm
+++ b/gnucash/report/html-fonts.scm
@@ -26,6 +26,7 @@
(use-modules (gnucash core-utils))
+(use-modules (ice-9 regex))
(define (string-strip s1 s2)
(let ((idx (string-contains-ci s1 s2)))
@@ -40,11 +41,24 @@
(font-stretch "")
(idx (string-index-right font-name #\space))
(font-size (substring font-name (1+ idx) (string-length font-name)))
- (font-name (string-take font-name idx)))
+ (font-name (string-take font-name idx))
+ (pat (make-regexp " weight=([0-9]+)" regexp/icase regexp/extended))
+ (match (regexp-exec pat font-name)))
- (when (string-contains-ci font-name " bold")
+
+ (cond
+ ((string-contains-ci font-name " bold")
(set! font-weight "font-weight: bold; ")
(set! font-name (string-strip font-name " bold")))
+ ((string-contains-ci font-name " regular")
+ (set! font-weight "font-weight: normal; ")
+ (set! font-name (string-strip font-name " regular")))
+ ((string-contains-ci font-name " light")
+ (set! font-weight "font-weight: lighter; ")
+ (set! font-name (string-strip font-name " light")))
+ ((regexp-match? match)
+ (set! font-weight (regexp-substitute #f match "font-weight: " 1 "; "))
+ (set! font-name (regexp-substitute #f match 'pre 'post))))
(cond
((string-contains-ci font-name " italic")
diff --git a/gnucash/report/test/test-html-fonts.scm b/gnucash/report/test/test-html-fonts.scm
index 0a6df2ca7..d5abc1827 100644
--- a/gnucash/report/test/test-html-fonts.scm
+++ b/gnucash/report/test/test-html-fonts.scm
@@ -14,11 +14,11 @@
(test-begin "font-name-to-style-info")
(test-equal "basic"
- "font-family: \"Courier Regular\", sans-serif; font-size: 20pt; "
+ "font-family: \"Courier\", sans-serif; font-size: 20pt; font-weight: normal; "
(font-name-to-style-info "Courier Regular 20"))
(test-equal "basic size 50"
- "font-family: \"Courier Regular\", sans-serif; font-size: 50pt; "
+ "font-family: \"Courier\", sans-serif; font-size: 50pt; font-weight: normal; "
(font-name-to-style-info "Courier Regular 50"))
(test-equal "basic size 50 bold"
@@ -33,4 +33,8 @@
"font-family: \"Courier\", sans-serif; font-size: 15pt; font-style: oblique; "
(font-name-to-style-info "Courier oblique 15"))
+ (test-equal "basic size 15 numeric weight"
+ "font-family: \"Courier\", sans-serif; font-size: 15pt; font-weight: 550; "
+ (font-name-to-style-info "Courier weight=550 15"))
+
(test-end "font-name-to-style-info"))
commit 4ddd28a5d9f65e7c5f05bfee9d86a56fa5a67645
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Oct 26 11:48:22 2020 -0700
Extract font-stretch when converting pango font names to CSS.
Also wrap font-family value in quotes and lower-case the fallback
generic sans-serif font-family for CSS conformance (though browsers
don't seem to care).
diff --git a/gnucash/report/html-fonts.scm b/gnucash/report/html-fonts.scm
index 0cd86c176..ea5a3126f 100644
--- a/gnucash/report/html-fonts.scm
+++ b/gnucash/report/html-fonts.scm
@@ -37,6 +37,7 @@
(define (font-name-to-style-info font-name)
(let* ((font-style "")
(font-weight "")
+ (font-stretch "")
(idx (string-index-right font-name #\space))
(font-size (substring font-name (1+ idx) (string-length font-name)))
(font-name (string-take font-name idx)))
@@ -54,9 +55,18 @@
(set! font-style "font-style: oblique; ")
(set! font-name (string-strip font-name " oblique"))))
- (string-append "font-family: " font-name ", Sans-Serif; "
+ (cond
+ ((string-contains-ci font-name " expanded")
+ (set! font-stretch "font-stretch: expanded; ")
+ (set! font-name (string-strip font-name " expanded")))
+
+ ((string-contains-ci font-name " condensed")
+ (set! font-stretch "font-stretch: condensed; ")
+ (set! font-name (string-strip font-name " condensed"))))
+
+ (string-append "font-family: \"" font-name "\", sans-serif; "
"font-size: " font-size "pt; "
- font-style font-weight)))
+ font-style font-weight font-stretch)))
;; Registers font options
(define (register-font-options options)
diff --git a/gnucash/report/test/test-html-fonts.scm b/gnucash/report/test/test-html-fonts.scm
index 65352f9a6..0a6df2ca7 100644
--- a/gnucash/report/test/test-html-fonts.scm
+++ b/gnucash/report/test/test-html-fonts.scm
@@ -14,23 +14,23 @@
(test-begin "font-name-to-style-info")
(test-equal "basic"
- "font-family: Courier Regular, Sans-Serif; font-size: 20pt; "
+ "font-family: \"Courier Regular\", sans-serif; font-size: 20pt; "
(font-name-to-style-info "Courier Regular 20"))
(test-equal "basic size 50"
- "font-family: Courier Regular, Sans-Serif; font-size: 50pt; "
+ "font-family: \"Courier Regular\", sans-serif; font-size: 50pt; "
(font-name-to-style-info "Courier Regular 50"))
(test-equal "basic size 50 bold"
- "font-family: Courier, Sans-Serif; font-size: 50pt; font-weight: bold; "
+ "font-family: \"Courier\", sans-serif; font-size: 50pt; font-weight: bold; "
(font-name-to-style-info "Courier bold 50"))
(test-equal "basic size 50 italic"
- "font-family: Courier, Sans-Serif; font-size: 50pt; font-style: italic; "
+ "font-family: \"Courier\", sans-serif; font-size: 50pt; font-style: italic; "
(font-name-to-style-info "Courier italic 50"))
(test-equal "basic size 15 oblique"
- "font-family: Courier, Sans-Serif; font-size: 15pt; font-style: oblique; "
+ "font-family: \"Courier\", sans-serif; font-size: 15pt; font-style: oblique; "
(font-name-to-style-info "Courier oblique 15"))
(test-end "font-name-to-style-info"))
commit 676cc337dcff1cb68661169ee916b90fdbc1ace9
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Oct 26 11:45:23 2020 -0700
[macOS] Replace bogus font name from pango.
Pango on macOS reports ".AppleSystemUIFont" as the name for the
system-ui alias. This bogus name doesn't work so replace it with
the fallback Arial.
diff --git a/gnucash/report/gnc-report.c b/gnucash/report/gnc-report.c
index 45065f422..3981740df 100644
--- a/gnucash/report/gnc-report.c
+++ b/gnucash/report/gnc-report.c
@@ -284,7 +284,8 @@ gnc_get_default_report_font_family(void)
pango_font_description_free (font_desc);
- if (default_font_family == NULL)
+ if (default_font_family == NULL ||
+ g_str_has_prefix (default_font_family, ".AppleSystemUIFont"))
return g_strdup("Arial");
else
return default_font_family;
commit 974342bbaeebccaadced41a038bbb7d8f8ae275a
Author: John Ralls <jralls at ceridwen.us>
Date: Sun Oct 25 16:30:44 2020 -0700
[macOS] Fix Fontconfig unable to find conf.d.
diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 7fabd3545..bc2ab97cd 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -226,7 +226,7 @@ if (MAC_INTEGRATION)
file(APPEND ${ENV_FILE_OUT} "GIO_MODULE_DIR={SYS_LIB}/gio/modules\n")
file(APPEND ${ENV_FILE_OUT} "XDG_CONFIG_HOME={HOME}/Library/Application Support/${PACKAGE_NAME}/config\n")
file(APPEND ${ENV_FILE_OUT} "GDK_PIXBUF_MODULE_FILE={SYS_LIB}/gdk-pixbuf-2.0/2.10.0/loaders.cache\n")
- file(APPEND ${ENV_FILE_OUT} "FONTCONFIG_FILE={GNC_HOME}/etc/fonts/fonts.conf\n")
+ file(APPEND ${ENV_FILE_OUT} "FONTCONFIG_PATH={GNC_HOME}/etc/fonts\n")
file(APPEND ${ENV_FILE_OUT} "OFX_DTD_PATH={GNC_HOME}/share/libofx/dtd\n")
file(APPEND ${ENV_FILE_OUT} "GNC_DBD_DIR={SYS_LIB}/dbd\n")
file(APPEND ${ENV_FILE_OUT} "GTK_IM_MODULE_FILE={GNC_HOME}/lib/gtk-3.0/3.0.0/immodules.cache\n")
Summary of changes:
gnucash/CMakeLists.txt | 2 +-
gnucash/report/gnc-report.c | 3 ++-
gnucash/report/html-fonts.scm | 32 ++++++++++++++++++++++++++++----
gnucash/report/test/test-html-fonts.scm | 14 +++++++++-----
4 files changed, 40 insertions(+), 11 deletions(-)
More information about the gnucash-changes
mailing list