Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve "Show available fonts" dialog #1075

Closed
wants to merge 127 commits into from
Closed

Conversation

uliska
Copy link
Collaborator

@uliska uliska commented Jul 17, 2018

Closes #420
Closes #1077

This PR is not ready to be merged but I would like to get some feedback. I want more functionality, but actually the code would be a significant improvement already now.

[EDIT:] I've removed the "WIP" from the title and consider the PR ready by now.

The output of the LilyPond=>Show Available Fonts... command is practically unusable when more than a few fonts are available on a system. It is totally overwhelming, and the structure is hard to understand. Therefore I wanted to have an improved presentation of the data.

In its initial state the PR doesn't simply print out the LilyPond output but parses it to a number of dictionaries. The most important one is the families dictionary with entries for each font family. For now an ordered and structured list is printed to the same log window as was previously in that dialog. The "filter" line edit is still non-functional.

image

To be done:

  • Replace the log widget with a custom widget. What I think would be appropriate is a list-style widget where initially only the font families are listed. Only upon "opening" an entry will additional information be loaded and displayed (and these can then be pretty detailed).
  • Implement the filter edit. When some text is typed into that line edit all fonts not matching the pattern should be suppressed by making their parent widget invisible.
  • Add an export/print/save function

The code could be merged without these additional features, after removing the non-functional filter edit.

This is the first installment fo an improved dialog for showing available
fonts. So far this parses the results to a number of dictionaries and lists
but doesn't do anything with it.

TODO: Properly parse the details of a font family
TODO: Create a new custom widget:
  - show all font families as a table
  - each table row can be expanded to show more details about the family
TODO: Search/Filter
  - An additional text input allows for incremental filtering for font families
QUESTION: Do we need to show config files and font dirs?
This is the preparation for a usable presentation to be done in a next
step. The available font families are parsed into a dictionary, which
can be used to populate the data model of a to-be-determined visualization widget.
@fedelibre
Copy link
Member

This PR and in particular the filter would fix issue #420

@uliska
Copy link
Collaborator Author

uliska commented Jul 18, 2018

Oh yes, I had completely forgotten about that open issue.

In order to proceed we need

  • A suitable GUI "view" widget for display (see below)
  • A (custom?) Qt "model"
  • A QSortFilterProxyModel that will help with the sorting and filtering.

I haven't done anything with Qt's model-view-controller paradigm, and I don't know which UI interface would be suitable. It has to be something that allows unfolding a details section like in QTreeView. I think this would be my first try:

  • Have the family name as the first column of a toplevel entry
  • If there is only one sub-font (Hack would be an example) put the style name(s) in the second column
  • If there are more than one sub-fonts (Helvetica LT has ...Cond, ...Fractions, ...ExtCompressed etc.) create child elements for each.
  • If the sub-font has only one style put the style name(s) in the second column
  • If the sub-font has more styles (Helvetica LT Cond has Black, Black Oblique, Bold, Regular, Oblique, Light and Light Oblique on my PC) create child elements for each.
  • The style sub-sub-elements can have the style name(s) in the single first column
- Hack => Regular
+ Aachen Std
  - Aachen Std => Regular, Bold
  - Aachen Std Bold => Regular, Bold
+ Helvetica LT Std
  + Cond
    - Condensed, Regular
    - Bold Condensed, Bold
    - Bold Condensed Oblique, Bold Italic
    - Condensed Oblique, Italic
  + Regular
   ...

(BTW the screenshot and the initial PR incorrectly merges the third level styles, presumably having the last one overwrite all the others.)

Displaying the log output lets the user inspect the raw material if they
want to. In addition it makes the waiting time for the results feel more
"natural".
The results are displayed in the second tab which is automatically
opened when the job has completed.

TODO:
So far this still uses a Log() for the result display, which is completely
inappropriate.
This commit fixes an issue with parsing and attaching multiple styles.
Additionally it fleshes out the routine to display the fonts in hierarchical
order. So far this is done into the old Log widget but the logic behind
the "tree building" should be portable to any new approach using the
model-view structure.
These hat previously been overlooked (case in point for the need for this
improvement ;-) )
@uliska
Copy link
Collaborator Author

uliska commented Jul 18, 2018

I've improved (ehm, fixed) the parsing and mapping of font families, weights and styles into a dictionary and provided a preliminary reporting. Additionally I've added a tab widget to have access to the original LilyPond output and the other provided information:

image

Next steps (but I'm afraid I have to turn to other things first):

  • Display the font families using QTreeView, QSortFilterProxyModel and a custom (?) model
  • Make the line input work with the filter proxy

This dialog will become a little bit more sophisticated, and I think
it shouldn't be squeezed in the engrave.lytools module
@uliska
Copy link
Collaborator Author

uliska commented Jul 18, 2018

I would like this to be tested now, especially with regard to the hierarchy and display of the font tree. I've now changed the presentation from the hijacked Log window to a proper tree view:

image

Still to be done: Filtering (but given today's experience with the tree view and Qt's model/view architecture this may be pretty straightforward).

Also to be done: The results should be cached and only be updated when requested explicitly.

In repsonse to wish #1077 this makes the toplevel entries consistently
behave only as an index with the family name. All details go to
child entries, even if there is only one name.
Previously a filter was also applied to child elements,
effectively hiding style entries that don't carry the family name anymore.
@fedelibre
Copy link
Member

I've tested it and it looks great!

System fonts are grouped and listed correctly.
I have only an issue with notation fonts, namely LilyPond's Emmentaler and the fonts made by Abraham (an old version, last modification time is october 2015).
As you can see below, the various font sizes are not grouped together so the output is a bit confusing:

Emmentaler font

initial list

filtered list for jazz

@uliska
Copy link
Collaborator Author

uliska commented Jul 19, 2018

Thanks. I will have a look into it and see if I can fix that too. Apart from that things have even more improved by now, and I think we're soon ready to merge:

  • A styled sample is given for each font style (translatable string BTW)
  • Results are cached, so LilyPond is run only once (TODO: Button to manually refresh that)

image

Note that you can use regular expressions in the line edit. Specifically useful are the begin/end characters ^ and $.

@uliska
Copy link
Collaborator Author

uliska commented Sep 9, 2019

Finally ;-)

grafik

This partially reverts commit 37ae63e.
The modifications to logwidget.py had been committed erroneously
The "Music font repository" is a local directory where the
user can save their notation fonts. If that is set all fonts
can be directly installed without having to look up the directory
with the "Install..." button.

With the "Auto install" option this will be done whenever the
font dialog is opened, so any new LilyPond installation can
automatically be provided with the notation fonts.
Update the existing page for "Paths" Preferences
This doesn't properly work yet and is only committed
in order to make it possible to test the issue.
As explained in a comment to #1169 the user guide is
displayed *behind* the dialog (or even the application window),
or probably the other way round: the dialog insists on
remaining at the front.
Have one global MusicFontRepo object (if the path is given
in the preferences).
This replaces Pull Request #949 with proper implementations
(and more)

# Add fileMode argument to __init__

While not changing the default this allows setting the
filemode upon instantiation.

# Add mustExist validagion

If set to True the file must exist. As long as the path set
in the lineEdit doesn't exist the text is colored,
and when trying to leave the widget while it points to a
non-existent path it is instead reset to its previous value.

# Add editingFinished signal

Signal is emitted when the editing has finished.
Treats the lineEdit and the dialog as one entity:
When the lineEdit loses focus because the button
has been clicked the signal is *not* emitted.
Streamline the creation process of the dialog and its subwidgets.
Review responsibilities (store/do stuff where it belongs)
Base The Document Fonts dialog on QDialog instead of
widgets.dialog.Dialog.
Streamline the dialog creation,
make more stuff available through methods,
reduce dependencies between objects.
This fixes the issue with the Help button described in
#1169 (comment)
Referring to the main dialog through subwidgets' self.window()
method instead of keeping a manual reference (self._dialog)
ensures proper destruction of all objects upon closing of the
dialog.
This fixes the main issue in #1169, the exception in
app.aboutToQuit.
This was a workaround to a side-effect from #1169
that isn't necessary anymore.
The cleaning up was not only necessary as part of
the workaround but also to ensure current jobs are canceled when the
preview restarts prematurely (due to the rather new handling in the job queue).
A (semi-)transparent "waiting" animation that can be attached
to arbitrary QWidgets.
as provided by Abraham Lee
@uliska
Copy link
Collaborator Author

uliska commented Sep 12, 2019

With the exception of the manual page I think I'm now through with what I want to have included in the merge - anything else may go to the future wishlist ...

This screencast shows:

  • The new (unpolished) glyph specimen sheet
  • The (slightly) rewritten dialog
  • (again:) Caching in place, only some changes trigger a compilation
  • A completely new "waiting" animation instead of a progress bar. This was necessary because the progress bar doesn't have any meaningful estimate of the time the compilation will take. The animation is done as a new widget that can very easily be attached to other widgets in the application.

Frescobaldi-font-dialog-glyph-sheet-waiting-animation

@uliska uliska mentioned this pull request Sep 13, 2019
@uliska
Copy link
Collaborator Author

uliska commented Sep 13, 2019

Superseded by #1173

@uliska uliska closed this Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Available Fonts: Show samples add search to "Show available fonts"
5 participants