From 4cc963061075b8627f4885cff66eb35d7119bc69 Mon Sep 17 00:00:00 2001 From: Sotiri Bakagiannis Date: Mon, 17 May 2021 14:22:22 +0100 Subject: [PATCH 1/2] visual/Form: support font property --- src/visual/Form.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/visual/Form.js b/src/visual/Form.js index 4b27f3e..f7bc38a 100644 --- a/src/visual/Form.js +++ b/src/visual/Form.js @@ -42,6 +42,7 @@ import {Slider} from './Slider'; * @param {number[]} [options.items= []] - the array of labels * @param {number} [options.itemPadding= 0.05] - the granularity * + * @param {string} [options.font= 'Arial'] - the text font * @param {string} [options.fontFamily= 'Helvetica'] - the text font * @param {boolean} [options.bold= true] - whether or not the font of the labels is bold * @param {boolean} [options.italic= false] - whether or not the font of the labels is italic @@ -55,7 +56,7 @@ import {Slider} from './Slider'; */ export class Form extends util.mix(VisualStim).with(ColorMixin) { - constructor({name, win, pos, size, units, color, contrast, opacity, depth, items, randomize, itemPadding, fontFamily, bold, italic, fontSize, clipMask, autoDraw, autoLog} = {}) + constructor({name, win, pos, size, units, color, contrast, opacity, depth, items, randomize, itemPadding, font, fontFamily, bold, italic, fontSize, clipMask, autoDraw, autoLog} = {}) { super({name, win, units, opacity, depth, pos, size, clipMask, autoDraw, autoLog}); @@ -81,6 +82,13 @@ export class Form extends util.mix(VisualStim).with(ColorMixin) ); // fonts: + this._addAttribute( + 'font', + font, + 'Arial', + this._onChange(true, true) + ); + // Not in use at present this._addAttribute( 'fontFamily', fontFamily, @@ -688,7 +696,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin) const textStimOption = { win: this._win, name: 'item text', - font: 'Arial', + font: this.font, units: this._units, alignHoriz: 'left', alignVert: 'top', @@ -704,7 +712,10 @@ export class Form extends util.mix(VisualStim).with(ColorMixin) name: 'choice response', units: this._units, flip: false, - fontFamily: 'Arial', + // Not part of Slider options as things stand + fontFamily: this.fontFamily, + // As found in Slider options + font: this.font, bold: false, italic: false, fontSize: this._fontSize * this._responseTextHeightRatio, @@ -722,7 +733,7 @@ export class Form extends util.mix(VisualStim).with(ColorMixin) flip: false, opacity: 1, depth: this._depth + 1, - font: 'Arial', + font: this.font, letterHeight: this._fontSize * this._responseTextHeightRatio, bold: false, italic: false, From 864eab588ad196400dd09354a6b7224db1db080c Mon Sep 17 00:00:00 2001 From: Sotiri Bakagiannis Date: Mon, 17 May 2021 14:26:06 +0100 Subject: [PATCH 2/2] visual/Slider: clean up JSDoc for font, use Arial by default --- src/visual/Slider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/visual/Slider.js b/src/visual/Slider.js index 53c596e..aceea0d 100644 --- a/src/visual/Slider.js +++ b/src/visual/Slider.js @@ -44,7 +44,7 @@ import {PsychoJS} from "../core/PsychoJS"; * and labels with respect to the central bar * @param {boolean} [options.readOnly= false] - whether or not the slider is read only * - * @param {string} [options.fontFamily= 'Helvetica'] - the text font + * @param {string} [options.font= 'Arial'] - the text font * @param {boolean} [options.bold= true] - whether or not the font of the labels is bold * @param {boolean} [options.italic= false] - whether or not the font of the labels is italic * @param {number} [options.fontSize] - the font size of the labels (in pixels), the default fontSize depends on the @@ -130,7 +130,7 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin) this._addAttribute( 'font', font, - 'Helvetica', + 'Arial', this._onChange(true, true) ); this._addAttribute(