Skip to content

Commit

Permalink
lab/text: custom fonts (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 17, 2023
1 parent 06da994 commit ec35370
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions extensions/lab/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
}

_getFontStyle () {
return `${this.calculatedFontSize}px "${this.fontFamily}", sans-serif`;
return `${this.calculatedFontSize}px ${this.fontFamily}, sans-serif`;
}

_reflowText () {
Expand Down Expand Up @@ -883,6 +883,22 @@
};
}

getFonts () {
const customFonts = Scratch.vm.runtime.fontManager ? Scratch.vm.runtime.fontManager.getFonts().map(i => ({
text: i.name,
value: i.family
})) : [];

return [
...FONTS,
...customFonts,
{
text: 'random font',
value: 'Random'
}
];
}

/**
* @param {VM.Target} target
* @returns {TextState}
Expand Down Expand Up @@ -934,16 +950,6 @@
target.setCostume(target.currentCostume);
}

getFonts () {
return [
...FONTS,
{
text: 'random font',
value: 'Random'
}
];
}

setText ({ TEXT }, util) {
const state = this._getState(util.target);
this._renderText(util.target, state);
Expand Down

0 comments on commit ec35370

Please sign in to comment.