Keyboard shortcuts for bold and italics

Previous topic - Next topic

a.l.e

Recently, I've seen people asking again for Scribus having shortcuts for bold and italics.

I gave my standard answer ("it's more complicated than you think"). I also wrote about two possible workarounds (one works in 1.7 -- adding a python script in the script menu and using the action search -- the other needs a patch that is in pending review in the bug tracker, using the style applier based on the action search).
The explanation had a few more details than usual.

After having written that, I was inspired to sketch a way to implement this feature in a "simpler" way.

In short:

  • Scribus gets two actions, "Apply Bold" and "Apply Italics", with a shortcut attached (by default ctrl+shift+b and ctrl+shift-i)
  • The actions are based on three heuristics, two based on rules provided by the user (font styles to be replaced, char styles to be replaced) and one automatic (an automatic algorithm)
  • The action is performed by applying the first matching rule

Here some more details

  • If the user has defined a font replacement ("Noto Sans Regular" -> "Noto Sans Bold") that matches, it will be applied.
  • If the user has defined a char style replacement ('My fancy char' -> 'My fancy bold') that matches, it will be applied.
  • Otherwise, Scribus has an algorithm that helps finding the matching bold face (if the font has a 'bold' face, apply it; if the current face is 'demi' and there is a 'book' face, apply it...). We can improve the algorithm step by step. Enabling the "automatic" step is optional.
  • In a first step, it's an action, not a state switch: it goes through the selected text and switches between bold and "regular", or in the other direction depending, on what matches.
    This allows us to implement the feature without touching at the text representation in memory or in the file.
  • In a second step, the data structure will track if bold has been applied or not, allowing to correctly detect, if the bold face has been applied to all or part of the selection.
    A three states buttons can then be added to the content palette and the feature will work as the user is used from other applications.


My plan is to let defined The rules in the document settings (and maybe also in the preferences: people use different fonts and styles in different documents; not sure how useful global rules can be).
It will be possible to export and import the rules and it should be possible to inherit them by using document templates.

Here a list of tickets that relate to this feature:


I've created a first draft of the configuration dialog:

bold-italics.png

Voilà: any feedback?

a.l.e