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
 
65
 
66
       var totalHeight = lines.length * theme[type + 'LineHeight'] + (lines.length - 1) * theme[type + 'LineSpacing'];
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
       // horizontal alignment
73
       // horizontal alignment
69
       var x = theme[type + 'Align'] === "left" ? left : theme[type + 'Align'] === "right" ? right : (left + right) / 2;
74
       var x = theme[type + 'Align'] === "left" ? left : theme[type + 'Align'] === "right" ? right : (left + right) / 2;
70
 
75
 
79
         y = bottom - totalHeight;
84
         y = bottom - totalHeight;
80
       } else {
85
       } else {
81
         // Vertical align top
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
       // draw text
95
       // draw text

+ 1 - 1
settings/themes.json View File

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