Browse Source

Flexible citation raises or lowers with the height of the caption.

parisminton 7 years ago
parent
commit
8429a12f94
2 changed files with 12 additions and 2 deletions
  1. 11 1
      renderer/text-wrapper.js
  2. 1 1
      settings/themes.json

+ 11 - 1
renderer/text-wrapper.js View File

@@ -65,6 +65,11 @@ module.exports = function(theme) {
65 65
 
66 66
       var totalHeight = lines.length * theme[type + 'LineHeight'] + (lines.length - 1) * theme[type + 'LineSpacing'];
67 67
 
68
+      // save caption height for measuring citation top
69
+      if (type === 'caption') {
70
+        theme.captionTotalHeight = totalHeight;
71
+      }
72
+
68 73
       // horizontal alignment
69 74
       var x = theme[type + 'Align'] === "left" ? left : theme[type + 'Align'] === "right" ? right : (left + right) / 2;
70 75
 
@@ -79,7 +84,12 @@ module.exports = function(theme) {
79 84
         y = bottom - totalHeight;
80 85
       } else {
81 86
         // Vertical align top
82
-        y = top;
87
+        if (type === 'citation' && theme.captionTotalHeight) {
88
+          y = theme.captionTop + theme.captionTotalHeight + theme[type + 'TopMargin'];
89
+        }
90
+        else {
91
+          y = top
92
+        }
83 93
       }
84 94
 
85 95
       // draw text

+ 1 - 1
settings/themes.json View File

@@ -17,7 +17,7 @@
17 17
     "captionLineSpacing": 7,
18 18
     "citationAlign": "left",
19 19
     "citationFont": "300 38px 'NYT Franklin Light'",
20
-    "citationTopMargin": 40,
20
+    "citationTopMargin": 32,
21 21
     "citationTop": 342,
22 22
     "citationLeft": 50,
23 23
     "citationRight": 890,