From 725935ae6da3d50d8bdb0e5526cc23c925b242d2 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Mon, 15 Apr 2024 11:58:19 -0400 Subject: [PATCH 1/4] pass font styles to text-cache --- lib/text.js | 27 ++++++++++++++++++++++++--- plot.js | 11 ++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/text.js b/lib/text.js index 605bbd5..bbd90c7 100644 --- a/lib/text.js +++ b/lib/text.js @@ -211,6 +211,10 @@ proto.update = function(options) { var x = tick.x var text = tick.text var font = tick.font || 'sans-serif' + var fontStyle = tick.fontStyle || 'normal' + var fontWeight = tick.fontWeight || 'normal' + var fontStretch = tick.fontStretch || 'normal' + var fontVariant = tick.fontVariant || 'normal' scale = (tick.fontSize || 12) var coordScale = 1.0 / (bounds[dimension+2] - bounds[dimension]) @@ -218,7 +222,12 @@ proto.update = function(options) { var rows = text.split('\n') for(var r = 0; r < rows.length; r++) { - data = getText(font, rows[r]).data + data = getText(font, rows[r], { + fontStyle: fontStyle, + fontWeight: fontWeight, + fontStretch: fontStretch, + fontVariant: fontVariant + }).data for (j = 0; j < data.length; j += 2) { vertices.push( data[j] * scale, @@ -239,7 +248,14 @@ proto.update = function(options) { for(dimension=0; dimension<2; ++dimension) { this.labelOffset[dimension] = Math.floor(vertices.length/3) - data = getText(options.labelFont[dimension], options.labels[dimension], { textAlign: 'center' }).data + data = getText(options.labelFont[dimension], options.labels[dimension], { + fontStyle: options.labelFontStyle[dimension], + fontWeight: options.labelFontWeight[dimension], + fontStretch: options.labelFontStretch[dimension], + fontVariant: options.labelFontVariant[dimension], + textAlign: 'center' + }).data + scale = options.labelSize[dimension] for(i=0; i Date: Mon, 15 Apr 2024 12:14:18 -0400 Subject: [PATCH 2/4] link to gl-vis/text-cache --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de8fb4c..61a0959 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "gl-shader": "^4.2.1", "glsl-inverse": "^1.0.0", "glslify": "^7.0.0", - "text-cache": "^4.2.2" + "text-cache": "github:gl-vis/text-cache#9dcc9c398288a7c6b41d6f355460ff7beb14a7af" }, "devDependencies": { "camera-2d": "^1.0.1", From f8a284945a08a1d6b53b8ab9c5706572f46651de Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Wed, 17 Apr 2024 16:12:58 -0400 Subject: [PATCH 3/4] link to text-cache --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 61a0959..89f8168 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "gl-shader": "^4.2.1", "glsl-inverse": "^1.0.0", "glslify": "^7.0.0", - "text-cache": "github:gl-vis/text-cache#9dcc9c398288a7c6b41d6f355460ff7beb14a7af" + "text-cache": "github:gl-vis/text-cache#5369cdcfa5b94077f6be76b1dfa74d6ac87e76f3" }, "devDependencies": { "camera-2d": "^1.0.1", From ac02a12ec9fa5283a79c042b900dfd0707c43891 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Wed, 17 Apr 2024 16:13:56 -0400 Subject: [PATCH 4/4] no stretch option for now --- lib/text.js | 4 ---- plot.js | 2 -- 2 files changed, 6 deletions(-) diff --git a/lib/text.js b/lib/text.js index bbd90c7..f64366b 100644 --- a/lib/text.js +++ b/lib/text.js @@ -213,7 +213,6 @@ proto.update = function(options) { var font = tick.font || 'sans-serif' var fontStyle = tick.fontStyle || 'normal' var fontWeight = tick.fontWeight || 'normal' - var fontStretch = tick.fontStretch || 'normal' var fontVariant = tick.fontVariant || 'normal' scale = (tick.fontSize || 12) @@ -225,7 +224,6 @@ proto.update = function(options) { data = getText(font, rows[r], { fontStyle: fontStyle, fontWeight: fontWeight, - fontStretch: fontStretch, fontVariant: fontVariant }).data for (j = 0; j < data.length; j += 2) { @@ -251,7 +249,6 @@ proto.update = function(options) { data = getText(options.labelFont[dimension], options.labels[dimension], { fontStyle: options.labelFontStyle[dimension], fontWeight: options.labelFontWeight[dimension], - fontStretch: options.labelFontStretch[dimension], fontVariant: options.labelFontVariant[dimension], textAlign: 'center' }).data @@ -270,7 +267,6 @@ proto.update = function(options) { data = getText(options.titleFont, options.title, { fontStyle: options.titleFontStyle, fontWeight: options.titleFontWeight, - fontStretch: options.titleFontStretch, fontVariant: options.titleFontVariant, }).data scale = options.titleSize diff --git a/plot.js b/plot.js index 3ad7099..e907a56 100644 --- a/plot.js +++ b/plot.js @@ -506,7 +506,6 @@ proto.update = function(options) { labelFont: options.labelFont || ['sans-serif', 'sans-serif'], labelFontStyle: options.labelFontStyle || ['normal', 'normal'], labelFontWeight: options.labelFontWeight || ['normal', 'normal'], - labelFontStretch: options.labelFontStretch || ['normal', 'normal'], labelFontVariant: options.labelFontVariant || ['normal', 'normal'], title: options.title || '', @@ -514,7 +513,6 @@ proto.update = function(options) { titleFont: options.titleFont || 'sans-serif', titleFontStyle: options.titleFontStyle || 'normal', titleFontWeight: options.titleFontWeight || 'normal', - titleFontStretch: options.titleFontStretch || 'normal', titleFontVariant: options.titleFontVariant || 'normal' })