Skip to content

Commit 7cd5b30

Browse files
committed
make svg 'ascent' and 'descent' props part of every plotly icons
1 parent ef3c734 commit 7cd5b30

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/components/modebar/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,17 @@ proto.createButton = function (config) {
159159
* @Return {HTMLelement}
160160
*/
161161
proto.createIcon = function (thisIcon) {
162-
var iconHeight = Icons.ascent - Icons.descent,
162+
var iconHeight = thisIcon.ascent - thisIcon.descent,
163163
svgNS = 'http://www.w3.org/2000/svg',
164164
icon = document.createElementNS(svgNS, 'svg'),
165165
path = document.createElementNS(svgNS, 'path');
166166

167167
icon.setAttribute('height', '1em');
168-
icon.setAttribute('width', (thisIcon.width / iconHeight)+'em');
168+
icon.setAttribute('width', (thisIcon.width / iconHeight) + 'em');
169169
icon.setAttribute('viewBox', [0, 0, thisIcon.width, iconHeight].join(' '));
170170

171171
path.setAttribute('d', thisIcon.path);
172-
path.setAttribute('transform', 'matrix(1 0 0 -1 0 ' + Icons.ascent + ')');
172+
path.setAttribute('transform', 'matrix(1 0 0 -1 0 ' + thisIcon.ascent + ')');
173173
icon.appendChild(path);
174174

175175
return icon;

tasks/util/pull_font_svg.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ module.exports = function pullFontSVG(data, pathOut) {
1010

1111
var font_obj = result.svg.defs[0].font[0],
1212
default_width = Number(font_obj.$['horiz-adv-x']),
13-
chars = {
14-
ascent: Number(font_obj['font-face'][0].$.ascent),
15-
descent: Number(font_obj['font-face'][0].$.descent)
16-
};
13+
ascent = Number(font_obj['font-face'][0].$.ascent),
14+
descent = Number(font_obj['font-face'][0].$.descent),
15+
chars = {};
1716

1817
font_obj.glyph.forEach(function(glyph) {
1918
chars[glyph.$['glyph-name']] = {
2019
width: Number(glyph.$['horiz-adv-x']) || default_width,
21-
path: glyph.$.d
20+
path: glyph.$.d,
21+
ascent: ascent,
22+
descent: descent
2223
};
2324
});
2425

0 commit comments

Comments
 (0)