@@ -11925,6 +11925,10 @@ function Axes(gl) {
11925
11925
11926
11926
this.tickEnable = [ true, true, true ]
11927
11927
this.tickFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ]
11928
+ this.tickFontStyle = [ 'normal', 'normal', 'normal' ]
11929
+ this.tickFontWeight = [ 'normal', 'normal', 'normal' ]
11930
+ this.tickFontStretch = [ 'normal', 'normal', 'normal' ]
11931
+ this.tickFontVariant = [ 'normal', 'normal', 'normal' ]
11928
11932
this.tickSize = [ 12, 12, 12 ]
11929
11933
this.tickAngle = [ 0, 0, 0 ]
11930
11934
this.tickAlign = [ 'auto', 'auto', 'auto' ]
@@ -11938,7 +11942,11 @@ function Axes(gl) {
11938
11942
11939
11943
this.labels = [ 'x', 'y', 'z' ]
11940
11944
this.labelEnable = [ true, true, true ]
11941
- this.labelFont = 'sans-serif'
11945
+ this.labelFont = [ 'sans-serif', 'sans-serif', 'sans-serif' ]
11946
+ this.labelFontStyle = [ 'normal', 'normal', 'normal' ]
11947
+ this.labelFontWeight = [ 'normal', 'normal', 'normal' ]
11948
+ this.labelFontStretch = [ 'normal', 'normal', 'normal' ]
11949
+ this.labelFontVariant = [ 'normal', 'normal', 'normal' ]
11942
11950
this.labelSize = [ 20, 20, 20 ]
11943
11951
this.labelAngle = [ 0, 0, 0 ]
11944
11952
this.labelAlign = [ 'auto', 'auto', 'auto' ]
@@ -12075,19 +12083,28 @@ i_loop:
12075
12083
12076
12084
//Parse tick properties
12077
12085
BOOLEAN('tickEnable')
12078
- if(STRING('tickFont')) {
12079
- ticksUpdate = true //If font changes, must rebuild vbo
12080
- }
12086
+
12087
+ //If font changes, must rebuild vbo
12088
+ if(STRING('tickFont')) ticksUpdate = true
12089
+ if(STRING('tickFontStyle')) ticksUpdate = true
12090
+ if(STRING('tickFontWeight')) ticksUpdate = true
12091
+ if(STRING('tickFontStretch')) ticksUpdate = true
12092
+ if(STRING('tickFontVariant')) ticksUpdate = true
12093
+
12081
12094
NUMBER('tickSize')
12082
12095
NUMBER('tickAngle')
12083
12096
NUMBER('tickPad')
12084
12097
COLOR('tickColor')
12085
12098
12086
12099
//Axis labels
12087
12100
var labelUpdate = STRING('labels')
12088
- if(STRING('labelFont')) {
12089
- labelUpdate = true
12090
- }
12101
+
12102
+ if(STRING('labelFont')) labelUpdate = true
12103
+ if(STRING('labelFontStyle')) labelUpdate = true
12104
+ if(STRING('labelFontWeight')) labelUpdate = true
12105
+ if(STRING('labelFontStretch')) labelUpdate = true
12106
+ if(STRING('labelFontVariant')) labelUpdate = true
12107
+
12091
12108
BOOLEAN('labelEnable')
12092
12109
NUMBER('labelSize')
12093
12110
NUMBER('labelPad')
@@ -12120,22 +12137,70 @@ i_loop:
12120
12137
BOOLEAN('backgroundEnable')
12121
12138
COLOR('backgroundColor')
12122
12139
12140
+ var labelFontOpts = [
12141
+ {
12142
+ family: this.labelFont[0],
12143
+ style: this.labelFontStyle[0],
12144
+ weight: this.labelFontWeight[0],
12145
+ stretch: this.labelFontStretch[0],
12146
+ variant: this.labelFontVariant[0],
12147
+ },
12148
+ {
12149
+ family: this.labelFont[1],
12150
+ style: this.labelFontStyle[1],
12151
+ weight: this.labelFontWeight[1],
12152
+ stretch: this.labelFontStretch[1],
12153
+ variant: this.labelFontVariant[1],
12154
+ },
12155
+ {
12156
+ family: this.labelFont[2],
12157
+ style: this.labelFontStyle[2],
12158
+ weight: this.labelFontWeight[2],
12159
+ stretch: this.labelFontStretch[2],
12160
+ variant: this.labelFontVariant[2],
12161
+ }
12162
+ ]
12163
+
12164
+ var tickFontOpts = [
12165
+ {
12166
+ family: this.tickFont[0],
12167
+ style: this.tickFontStyle[0],
12168
+ weight: this.tickFontWeight[0],
12169
+ stretch: this.tickFontStretch[0],
12170
+ variant: this.tickFontVariant[0],
12171
+ },
12172
+ {
12173
+ family: this.tickFont[1],
12174
+ style: this.tickFontStyle[1],
12175
+ weight: this.tickFontWeight[1],
12176
+ stretch: this.tickFontStretch[1],
12177
+ variant: this.tickFontVariant[1],
12178
+ },
12179
+ {
12180
+ family: this.tickFont[2],
12181
+ style: this.tickFontStyle[2],
12182
+ weight: this.tickFontWeight[2],
12183
+ stretch: this.tickFontStretch[2],
12184
+ variant: this.tickFontVariant[2],
12185
+ }
12186
+ ]
12187
+
12123
12188
//Update text if necessary
12124
12189
if(!this._text) {
12125
12190
this._text = createText(
12126
12191
this.gl,
12127
12192
this.bounds,
12128
12193
this.labels,
12129
- this.labelFont ,
12194
+ labelFontOpts ,
12130
12195
this.ticks,
12131
- this.tickFont )
12196
+ tickFontOpts )
12132
12197
} else if(this._text && (labelUpdate || ticksUpdate)) {
12133
12198
this._text.update(
12134
12199
this.bounds,
12135
12200
this.labels,
12136
- this.labelFont ,
12201
+ labelFontOpts ,
12137
12202
this.ticks,
12138
- this.tickFont )
12203
+ tickFontOpts )
12139
12204
}
12140
12205
12141
12206
//Update lines if necessary
@@ -13183,15 +13248,27 @@ proto.update = function(bounds, labels, labelFont, ticks, tickFont) {
13183
13248
var data = []
13184
13249
13185
13250
function addItem(t, text, font, size, lineSpacing, styletags) {
13186
- var fontcache = __TEXT_CACHE[font]
13251
+ var fontKey = [
13252
+ font.style,
13253
+ font.weight,
13254
+ font.stretch,
13255
+ font.variant,
13256
+ font.family
13257
+ ].join('_')
13258
+
13259
+ var fontcache = __TEXT_CACHE[fontKey]
13187
13260
if(!fontcache) {
13188
- fontcache = __TEXT_CACHE[font ] = {}
13261
+ fontcache = __TEXT_CACHE[fontKey ] = {}
13189
13262
}
13190
13263
var mesh = fontcache[text]
13191
13264
if(!mesh) {
13192
13265
mesh = fontcache[text] = tryVectorizeText(text, {
13193
13266
triangles: true,
13194
- font: font,
13267
+ font: font.family,
13268
+ fontStyle: font.style,
13269
+ fontWeight: font.weight,
13270
+ fontStretch: font.stretch,
13271
+ fontVariant: font.variant,
13195
13272
textAlign: 'center',
13196
13273
textBaseline: 'middle',
13197
13274
lineSpacing: lineSpacing,
@@ -13243,10 +13320,19 @@ proto.update = function(bounds, labels, labelFont, ticks, tickFont) {
13243
13320
if(!ticks[d][i].text) {
13244
13321
continue
13245
13322
}
13323
+
13324
+ var font = {
13325
+ family: ticks[d][i].font || tickFont[d].family,
13326
+ style: tickFont[d].fontStyle || tickFont[d].style,
13327
+ weight: tickFont[d].fontWeight || tickFont[d].weight,
13328
+ stretch: tickFont[d].fontStretch || tickFont[d].stretch,
13329
+ variant: tickFont[d].fontVariant || tickFont[d].variant,
13330
+ }
13331
+
13246
13332
addItem(
13247
13333
ticks[d][i].x,
13248
13334
ticks[d][i].text,
13249
- ticks[d][i]. font || tickFont ,
13335
+ font,
13250
13336
ticks[d][i].fontSize || 12,
13251
13337
lineSpacing,
13252
13338
styletags
0 commit comments