Skip to content

Commit f00147c

Browse files
authored
todo@NotSirius-A: V1.1.1 Improved font parsing and slightly altered visuals (#1640)
1 parent 8c7e82c commit f00147c

File tree

7 files changed

+94
-49
lines changed

7 files changed

+94
-49
lines changed

todo@NotSirius-A/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ I have spent many hours trying to make ibus/fcitx work while directly editing ta
4646

4747
### What can be improved?
4848

49-
* Improve font parsing.
50-
5149
* Fix the `clutter_focus` error.
5250

5351
* Somehow add alternate input methods support to St.Entry??

todo@NotSirius-A/files/todo@NotSirius-A/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11

2+
## [1.1.1] - 8.11.2025
3+
4+
### Changed
5+
6+
- Improved font parsing
7+
- Slightly increased task paddings and margins in `stylesheet.css`
8+
- Adjusted some default theme options to improve default visuals (IMO)
9+
- Updated `README.md`
10+
11+
### Deleted
12+
13+
- Font bold/italic options, because they are no longer needed
14+
215
## [1.1] - 13.10.2025
316

417
### Added

todo@NotSirius-A/files/todo@NotSirius-A/TODOList.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ class TODOList {
242242
parent_button.style = "font-family: '" + th["font_family"] + "';"
243243
+ "font-size: " + th["font_size"] + "px;"
244244
+ "color:" + th["font_color"] + ";"
245-
+ "font-weight:" + (th["font_bold"] ? "bold" : "normal") + ";"
246-
+ "font-style:" + (th["font_italic"] ? "italic" : "normal") + ";"
245+
+ "font-weight:" + th["font_weight"] + ";"
246+
+ "font-style:" + th["font_style"] + ";"
247+
+ "font-stretch:" + th["font_stretch"] + ";"
247248
+ "text-shadow:" + (th["text_shadow_enabled"] ? "1px 1px 6px " + th["text_shadow_color"] : "none") + ";";
248249

249250
if (Item.is_marked_important) {

todo@NotSirius-A/files/todo@NotSirius-A/desklet.js

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Gio = imports.gi.Gio;
1111
const Gettext = imports.gettext;
1212
const Tooltips = imports.ui.tooltips;
1313
const PopupMenu = imports.ui.popupMenu;
14+
const Pango = imports.gi.Pango;
1415

1516

1617
const UUID = "todo@NotSirius-A";
@@ -70,8 +71,6 @@ MyDesklet.prototype = {
7071
this.settings.bindProperty(Settings.BindingDirection.IN, "task-not-marked-icon", "taskNotMarkedDoneIcon", this.on_setting_changed);
7172
this.settings.bindProperty(Settings.BindingDirection.IN, "task-marked-icon", "taskMarkedDoneIcon", this.on_setting_changed);
7273
this.settings.bindProperty(Settings.BindingDirection.IN, "font", "fontRaw", this.on_setting_changed);
73-
this.settings.bindProperty(Settings.BindingDirection.IN, "font-bold", "fontBold", this.on_setting_changed);
74-
this.settings.bindProperty(Settings.BindingDirection.IN, "font-italic", "fontItalic", this.on_setting_changed);
7574
this.settings.bindProperty(Settings.BindingDirection.IN, "text-color", "customTextColor", this.on_setting_changed);
7675
this.settings.bindProperty(Settings.BindingDirection.IN, "text-shadow", "textShadow", this.on_setting_changed);
7776
this.settings.bindProperty(Settings.BindingDirection.IN, "text-shadow-color", "textShadowColor", this.on_setting_changed);
@@ -123,7 +122,7 @@ MyDesklet.prototype = {
123122
* Load visual theme from settings
124123
*/
125124
loadTheme: function() {
126-
this.font = this.parseFont(this.fontRaw);
125+
this.font = this.parseFontStringToCSS(this.fontRaw);
127126

128127
const default_item_width = 150;
129128
this.scale = this.scaleSize * global.ui_scale;
@@ -144,11 +143,12 @@ MyDesklet.prototype = {
144143
"TODOlist": {
145144
"num_of_columns": this.numOfColumns,
146145
"item_width": default_item_width * this.scale * this.text_scale,
147-
"font_family": this.font["family"],
148-
"font_size": this.font["size"] * this.text_scale,
146+
"font_family": this.font["font-family"],
147+
"font_size": this.font["font-size"] * this.text_scale,
149148
"font_color": this.customTextColor,
150-
"font_bold": this.fontBold,
151-
"font_italic": this.fontItalic,
149+
"font_weight": this.font["font-weight"],
150+
"font_style": this.font["font-style"],
151+
"font_stretch": this.font["font-stretch"],
152152
"text_align": this.textAlign,
153153
"text_shadow_enabled": this.textShadow,
154154
"text_shadow_color": this.textShadowColor,
@@ -220,29 +220,74 @@ MyDesklet.prototype = {
220220
},
221221

222222

223+
224+
223225
/**
224-
* Parse raw font string, TODO improve parsing, detect bold/italic etc.
225-
* @param {string} font_string - Font descriptor
226-
* @returns {{"family": string, "size": Number}} Font descriptor object
226+
* Parse raw font string.
227+
* @param {string} font_string - Font descriptor string
228+
* @returns {{"font-family": string, "font-size": Number, "font-weight": Number, "font-style": string, "font-stretch": string}} Font descriptor object
227229
*/
228-
parseFont: function(font_string) {
229-
// String are passed by reference here so
230+
parseFontStringToCSS: function(font_string) {
231+
// Some fonts don't work, so a fallback font is a good idea
232+
const fallback_font_str = "Ubuntu Regular 16";
233+
234+
// String are passed by reference here
230235
// make sure to copy the string to avoid triggering settings callback on change
231236
const font_string_copy = font_string.slice().trim();
237+
238+
let css_font;
239+
try {
240+
const my_font_description = Pango.font_description_from_string(font_string_copy);
241+
css_font = this._PangoFontDescriptionToCSS(my_font_description);
242+
} catch (e) {
243+
Main.notifyError(
244+
_("Sorry, this font is not supported, please select a different one.")
245+
+ _(" Font: `") + font_string_copy + _("` Error: ")
246+
+ e.toString()
247+
);
248+
249+
const fallback_font_description = Pango.font_description_from_string(fallback_font_str);
250+
css_font = this._PangoFontDescriptionToCSS(fallback_font_description);
251+
} finally {
252+
return css_font;
253+
}
254+
255+
},
232256

233-
const font_split = font_string_copy.split(" ");
234257

235-
const font_size = parseInt(font_split.pop());
236-
let font_family = font_split.join(" ");
258+
/**
259+
* Process Pango.FontDescription and return valid CSS values
260+
* @param {Pango.FontDescription} font_description - Font descriptor
261+
* @returns {{"font-family": string, "font-size": Number, "font-weight": Number, "font-style": string, "font-stretch": string}} Font descriptor object
262+
*/
263+
_PangoFontDescriptionToCSS: function(font_description) {
264+
const PangoStyle_to_CSS_map = {
265+
[Pango.Style.NORMAL]: "normal",
266+
[Pango.Style.OBLIQUE]: "oblique",
267+
[Pango.Style.ITALIC]: "italic",
268+
};
237269

270+
// font-stretch CSS property seems to be ignored by the CSS renderer
271+
const PangoStretch_to_CSS_map = {
272+
[Pango.Stretch.ULTRA_CONDENSED]: "ultra-condensed",
273+
[Pango.Stretch.EXTRA_CONDENSED]: "extra-condensed",
274+
[Pango.Stretch.CONDENSED]: "condensed",
275+
[Pango.Stretch.NORMAL]: "normal",
276+
[Pango.Stretch.SEMI_EXPANDED]: "semi-expanded",
277+
[Pango.Stretch.EXPANDED]: "expanded",
278+
[Pango.Stretch.EXTRA_EXPANDED]: "extra-expanded",
279+
[Pango.Stretch.ULTRA_EXPANDED]: "ultra-expanded",
280+
};
281+
238282
return {
239-
"family": font_family,
240-
"size": font_size
283+
"font-family": font_description.get_family(),
284+
"font-size": Math.floor(font_description.get_size() / Pango.SCALE),
285+
"font-weight": font_description.get_weight(),
286+
"font-style": PangoStyle_to_CSS_map[font_description.get_style()],
287+
"font-stretch": PangoStretch_to_CSS_map[font_description.get_stretch()]
241288
};
242289
},
243290

244-
245-
246291
/**
247292
* Render desklet decorations
248293
*/

todo@NotSirius-A/files/todo@NotSirius-A/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"max-instances": "5",
33
"description": "Themeable, customizable, and easy-to-use TODO desklet.",
44
"name": "TODO Desklet",
5-
"version": "1.1",
5+
"version": "1.1.1",
66
"uuid": "todo@NotSirius-A",
77
"author": "NotSirius-A"
88
}

todo@NotSirius-A/files/todo@NotSirius-A/settings-schema.json

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@
7979
"task-not-marked-icon",
8080
"task-marked-icon",
8181
"font",
82-
"font-bold",
83-
"font-italic",
8482
"text-color",
8583
"text-shadow",
8684
"text-shadow-color",
@@ -222,19 +220,9 @@
222220
},
223221
"font": {
224222
"type": "fontchooser",
225-
"description": "Font name (choose regular versions)",
226-
"default": "Ubuntu Regular 12",
227-
"tooltip": "Change font family"
228-
},
229-
"font-bold": {
230-
"type": "switch",
231-
"description": "Bold",
232-
"default": false
233-
},
234-
"font-italic": {
235-
"type": "switch",
236-
"description": "Italic",
237-
"default": false
223+
"description": "Font",
224+
"default": "Ubuntu Regular 13",
225+
"tooltip": "Change the font (some fonts may not work)"
238226
},
239227
"text-color": {
240228
"type": "colorchooser",
@@ -275,7 +263,7 @@
275263
},
276264
"task-border-color": {
277265
"type": "colorchooser",
278-
"default": "rgba(0,0,0,0.3)",
266+
"default": "rgba(0,0,0,0.45)",
279267
"description": "Border color",
280268
"tooltip": "Set the task border color (Transparent border will add more padding to tasks).",
281269
"dependency": "task-border-width>0"
@@ -289,14 +277,14 @@
289277
},
290278
"task-border-color-important": {
291279
"type": "colorchooser",
292-
"default": "rgb(70,0,0)",
280+
"default": "rgba(255,255,255,0.2)",
293281
"description": "Border color when marked as important",
294282
"tooltip": "Set the task border color when marked as important (Transparent border will add more padding to tasks).",
295283
"dependency": "task-border-width>0"
296284
},
297285
"task-icon-size": {
298286
"type": "spinbutton",
299-
"default": 11,
287+
"default": 10,
300288
"min": 0,
301289
"max": 100,
302290
"step": 1,
@@ -317,7 +305,7 @@
317305
},
318306
"toolbar-icon-size": {
319307
"type": "spinbutton",
320-
"default": 20,
308+
"default": 18,
321309
"min": 0,
322310
"max": 100,
323311
"step": 1,
@@ -338,7 +326,7 @@
338326
},
339327
"toolbar-border-width": {
340328
"type": "spinbutton",
341-
"default": 0,
329+
"default": 2,
342330
"min": 0,
343331
"max": 20,
344332
"step": 1,
@@ -347,7 +335,7 @@
347335
},
348336
"toolbar-border-color": {
349337
"type": "colorchooser",
350-
"default": "rgb(0,0,0)",
338+
"default": "rgba(0,0,0, 0.45)",
351339
"description": "Border color",
352340
"tooltip": "Set the toolbar border color (Transparent border will add more padding to toolbar).",
353341
"dependency": "toolbar-border-width>0"

todo@NotSirius-A/files/todo@NotSirius-A/stylesheet.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
color: black;
2222
font-weight: 500;
2323
border-radius: 0.32em;
24-
padding: 0.12em 0.15em;
25-
margin: 0.12em 0;
24+
padding: 0.18em 0.25em;
25+
margin: 0.14em 0;
2626
}
2727

2828
.todo-item:hover {
@@ -41,7 +41,7 @@
4141
padding-left: 0.15em;
4242
padding-right: 0.15em;
4343
margin-left: 0.1em;
44-
margin-right: 0.15em;
44+
margin-right: 0.2em;
4545
}
4646

4747
.todo-item-icon-btn:hover {
@@ -56,7 +56,7 @@
5656
}
5757

5858
.todo-item-entry {
59-
padding: 0.00em 0.1em;
59+
padding: 0.00em 0.15em;
6060
}
6161

6262

0 commit comments

Comments
 (0)