Add font family reversed switching

This commit is contained in:
abakkk 2020-08-06 00:26:10 +02:00
parent 39ec1ba888
commit a1ce4aaf79
6 changed files with 18 additions and 5 deletions

View File

@ -930,9 +930,12 @@ var DrawingArea = new Lang.Class({
`${_(FontStyleNames[this.currentFontStyle])}</span>`, "", -1, false);
},
switchFontFamily: function() {
switchFontFamily: function(reverse) {
let index = Math.max(0, this.fontFamilies.indexOf(this.currentFontFamily));
this.currentFontFamily = (index == this.fontFamilies.length - 1) ? 0 : this.fontFamilies[index + 1];
if (reverse)
this.currentFontFamily = (index == 0) ? this.fontFamilies[this.fontFamilies.length - 1] : this.fontFamilies[index - 1];
else
this.currentFontFamily = (index == this.fontFamilies.length - 1) ? this.fontFamilies[0] : this.fontFamilies[index + 1];
if (this.currentElement && this.currentElement.font) {
this.currentElement.font.family = this.currentFontFamily;
this._redisplay();

View File

@ -215,7 +215,8 @@ var AreaManager = new Lang.Class({
'toggle-background': this.activeArea.toggleBackground.bind(this.activeArea),
'toggle-grid': this.activeArea.toggleGrid.bind(this.activeArea),
'toggle-square-area': this.activeArea.toggleSquareArea.bind(this.activeArea),
'switch-font-family': this.activeArea.switchFontFamily.bind(this.activeArea),
'reverse-switch-font-family': this.activeArea.switchFontFamily.bind(this.activeArea, true),
'switch-font-family': this.activeArea.switchFontFamily.bind(this.activeArea, false),
'switch-font-weight': this.activeArea.switchFontWeight.bind(this.activeArea),
'switch-font-style': this.activeArea.switchFontStyle.bind(this.activeArea),
'switch-text-alignment': this.activeArea.switchTextAlignment.bind(this.activeArea),

View File

@ -218,7 +218,10 @@ msgstr ""
msgid "Toggle fill rule"
msgstr ""
msgid "Change font family (generic name)"
msgid "Change font family"
msgstr ""
msgid "Change font family (reverse)"
msgstr ""
msgid "Change font weight"

View File

@ -70,7 +70,8 @@ var INTERNAL_KEYBINDINGS = {
'switch-linecap': "Change linecap",
'switch-dash': "Dashed line",
'-separator-4': '',
'switch-font-family': "Change font family (generic name)",
'switch-font-family': "Change font family",
'reverse-switch-font-family': "Change font family (reverse)",
'switch-font-weight': "Change font weight",
'switch-font-style': "Change font style",
'switch-text-alignment': "Toggle text alignment",

Binary file not shown.

View File

@ -226,6 +226,11 @@
<summary>switch font family</summary>
<description>switch font family</description>
</key>
<key type="as" name="reverse-switch-font-family">
<default>["&lt;Primary&gt;&lt;Shift&gt;f"]</default>
<summary>switch font family (reverse)</summary>
<description>switch font family (reverse)</description>
</key>
<key type="as" name="switch-font-weight">
<default>["&lt;Primary&gt;w"]</default>
<summary>switch font weight</summary>