reset fontvariationaxes on font change
This commit is contained in:
parent
ab3786ef23
commit
2d55ef11b0
1 changed files with 19 additions and 2 deletions
|
@ -101,6 +101,7 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
|
|||
let axes = fontsAndAxes[selectedFontIndex].axes;
|
||||
if (axes.length > 0) {
|
||||
let variationAxes = {};
|
||||
let doThese = [];
|
||||
for (let a = 0; a < axes.length; a++) {
|
||||
const sanity_minMax = axes[a].minValue < axes[a].maxValue;
|
||||
const sanity_minDefault = axes[a].minValue <= axes[a].defaultValue;
|
||||
|
@ -109,11 +110,27 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
|
|||
variationAxes[axes[a].name] = tp.core.types.number(axes[a].defaultValue, {
|
||||
range: [axes[a].minValue, axes[a].maxValue],
|
||||
});
|
||||
if (typeof audio === 'object' &&
|
||||
typeof audio.getSavedMapping()[this.id()][`fontVariationAxes.${axes[a].name}`] === 'object' &&
|
||||
typeof audio.getMapping()[this.id()][`fontVariationAxes.${axes[a].name}`] === 'object' &&
|
||||
tp.getPanel() !== null) {
|
||||
doThese.push(() => {
|
||||
audio.removeAudioOptions(this, `fontVariationAxes.${axes[a].name}`);
|
||||
audio.removeAudioMapping(this, `fontVariationAxes.${axes[a].name}`);
|
||||
audio.getSavedMapping()[this.id()][`fontVariationAxes.${axes[a].name}`].min_out = axes[a].minValue;
|
||||
audio.getSavedMapping()[this.id()][`fontVariationAxes.${axes[a].name}`].max_out = axes[a].maxValue;
|
||||
audio.addAudioMapping(this, `fontVariationAxes.${axes[a].name}`);
|
||||
audio.addAudioOptions(this, `fontVariationAxes.${axes[a].name}`);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('js::layer::selectFont', 'this axis is insane, abort', axes[a]);
|
||||
}
|
||||
}
|
||||
props.fontVariationAxes = tp.core.types.compound(variationAxes);
|
||||
doThese.forEach((d) => {
|
||||
d();
|
||||
});
|
||||
} else {
|
||||
delete props.fontVariationAxes;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue