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

Symbols enhancement. #996

Closed
wants to merge 12 commits into from
Closed

Conversation

SNoiraud
Copy link
Member

Add the possibility to set all default values to a string.
Gui configuration improvement.
Possibility to drag and drop a symbol from the symbol list.
In this case, the glyph must be present in the current font to be displayed.

Add the possibility to set all default value to a string.
Gui configuration improvement.
Possibility to drag and drop a symbol from the symbol list.
In this case, the glyph must be present in the current font to be displayed.
@codecov-io
Copy link

codecov-io commented Jan 13, 2020

Codecov Report

Merging #996 into master will decrease coverage by 0.02%.
The diff coverage is 22.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #996      +/-   ##
==========================================
- Coverage   41.94%   41.91%   -0.03%     
==========================================
  Files        1071     1071              
  Lines      145765   145870     +105     
==========================================
+ Hits        61138    61144       +6     
- Misses      84627    84726      +99
Impacted Files Coverage Δ
gramps/plugins/view/pedigreeview.py 0% <0%> (ø) ⬆️
gramps/gui/configure.py 0% <0%> (ø) ⬆️
gramps/plugins/view/relview.py 0% <0%> (ø) ⬆️
gramps/gui/widgets/fanchart.py 0% <0%> (ø) ⬆️
gramps/gen/config.py 92.17% <100%> (+0.24%) ⬆️
gramps/gen/utils/libformatting.py 12.9% <21.42%> (-0.17%) ⬇️
gramps/gen/utils/symbols.py 80% <95%> (-2.82%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2ae7b9...bf41eac. Read the comment docs.

@SNoiraud SNoiraud added this to the v5.2 milestone Jan 13, 2020
@SNoiraud
Copy link
Member Author

Here is a snapshot of what we can see:

symbols 1

@prculley
Copy link
Contributor

I tried this out and I like parts of it. But I decided that the Preferences tab could use some work, it was too large to fit on smaller screens.
I also added more tooltips, including on the symbol characters.
I've created a commit with the changes prculley@526f89f
The commit only affects the Preferences.

I remain concerned that using the symbols sets all of Gramps to the specified font; this is somewhat counter to the style guidelines. I note that in most cases this is not really necessary, the Gtk/fontconfig font substitution seems to find the necessary character glyphs, in fact I have not seen a case where this did NOT work.

But if you think we really need to specify a font, wouldn't it be better to use markup with the symbols, rather than make the whole GUI change? I realize that this would require changes in a lot of places, replacing 'set_text' methods with 'set_markup' or similar. But I think the end result might be better. We could include the necessary markup in the symbol strings...

@Nick-Hall
Copy link
Member

Yes. We shouldn't really change the font for the entire interface.

Perhaps we could create a subclass of Gtk.Label to display symbols, or the text fallback depending on the preference settings? We would probably also need the markup for use in charts which write directly to a Gtk.DrawingArea.

@SNoiraud
Copy link
Member Author

SNoiraud commented Apr 18, 2020

in fact I have not seen a case where this did NOT work.

Did you try this on old OSes without unicode in standard ?
Many users continue to use XP machines or something else.

@SNoiraud
Copy link
Member Author

Symbols small 1
Symbols small 2
Symbols default 1

@prculley
Copy link
Contributor

in fact I have not seen a case where this did NOT work.

Did you try this on old OSes without unicode in standard ?
Many users continue to use XP machines or something else.

The AIO (for Windows) has not supported winxp for several years now, probably sometime in the Gramps 4.0.x timeframe. I would be more concerned about OSX or possibly some older versions of Linux, if they did not support fontconfig.

@jralls
Copy link
Member

jralls commented Apr 18, 2020

Gnome and MacOS X/10 have fully supported Unicode since their inception, no worries there.

On MacOS fontconfig is a small problem as I didn't know about the dependency on python fontconfig and don't include it in the Mac bundle. It's unfortunate that it's necessary because fontconfig has only a minimal annotation for gobject-introspection that doesn't include the API you need.

On the other hand Apple provides a typeface, Apple Symbols, that I think provides glyphs for all of the genealogy code points. It has only symbols so it's not suitable for setting application-wide, but if you can fix Gramps so that it uses the symbol font only for the symbols then we can hard-code the Apple Symbols font for MacOS and skip the search and its dependency on fontconfig.

@prculley
Copy link
Contributor

prculley commented Apr 24, 2020

I spent some time trying to figure out how we might avoid changing the font for the whole interface; and I understand that the changes would be at least extensive, bordering on impossible. Too many places that don't support markup.

I decided to test out your latest commit (using the default font). I observed a problem with the font section combo, due to a mixup in the row to which it was attached. I fixed that and then decided to expand on the idea of the default font.
I added an item to the font selector to allow the user to revert to the default.
I changed the code to allow the symbols to be used even if fontconfig was not installed. And allow death symbol selection even if no font was found/selected. Also simplified the death symbol code a bit.
I fixed up the fontconfig 0.6.0 code to work right (need dict.items() the way you used it).
I moved the 'no fonts' warning to be next to the 'Find font' button, and updated the text a bit.
I fixed up the self.sym_text.get_iter_at_position code to use the returned iter correctly, apparently different versions return these in a different list order; but using the dict value should always work.

I also changed the text of some messages a bit; I think some of these didn't sound right to my American English ear.
My changes are prculley@4f12008
Thanks for starting the work on this; I was not looking forward to trying to get this improved. But I hope that between your ideas and mine, the users will be happier.

gramps/gui/configure.py Outdated Show resolved Hide resolved
gramps/gui/configure.py Outdated Show resolved Hide resolved
@SNoiraud
Copy link
Member Author

When I started this, a few fonts contained all the symbols. It appears now this is no more the case.
I propose to remove the python-fontconfig pre-requisite.
We use the standard font defined for you gui.
In this case, perhaps we could apply this PR to 5.1.3 instead of 5.2
This will solve the new bug request (#11736) for new debian and ubuntu and the problem for mac.

@jralls
Copy link
Member

jralls commented May 17, 2020

You don't really need a python wrapper for most fontconfig commands, they're stand-alone programs. (Try ls /usr/bin/fc-*.) Just shell out (subprocess.Popen) and run them.

@SNoiraud
Copy link
Member Author

You don't really need a python wrapper for most fontconfig commands, they're stand-alone programs.

Yes, I know that and began to write a patch on that. I saw I had 7900 fonts on my system and only 76 didn't have all the symbols. This is why I propose to suppress that and use the standard font defined for the user desktop. Could this generate problems on macs ?

@jralls
Copy link
Member

jralls commented May 17, 2020

Depends on what you mean by problems. On a stock Mac most of the miscellaneous symbols block (U+2600-U+26FF) are provided only by that Apple Symbols face I mentioned earlier.

I guess the simplest work-around is to find some Free TTF that supports the whole basic plane, include it in the bundle, and make it the default for MacOS.

@prculley
Copy link
Contributor

@jralls On the MAC installation does Gtk use fontconfig to do the font substitution? On my systems this seems to work pretty well, as it pulls the necessary glyphs from the closest font that contains the symbol. So I would expect that you would end up with Glyphs from 'Apple Symbols' even when a different font was used as the primary one.

@jralls
Copy link
Member

jralls commented May 17, 2020

@prculley It doesn't do font substitution at all on windows or MacOS unless one forces pango to use the ft2 backend; normally pango uses the native backends (pangowin32 and pangocoretext) neither of which do substitution.

@prculley
Copy link
Contributor

@jralls I guess I should be more specific; the way Gramps AIO is built on Windows (with msys2/mingw) it looks a lot like Linux. It DOES use the fontconfig backend as the default backend. I don't think anyone has ever successfully built Gramps with the MSoft toolset, so the backend used there is not interesting.

But that answers my question about MacOS; no font substitution. So we need a good answer for there.

@jralls
Copy link
Member

jralls commented May 18, 2020

@prculley, Not necessarily. Pango does have a use_fontconfig argument to force using the fontconfig backend instead of the CoreText one. That's a change from the autotools build where it would build pango-ft2 if it found it as well as the native backend. I can try that, but I need a good test to see if it does any good. Do you know of one, ideally in C, or can you sketch out how one would work?

@prculley
Copy link
Contributor

What I know about 'C' and building is just enough to get me in trouble... I've got the Windows code to force fontconfig by inserting:
if(win() and ('PANGOCAIRO_BACKEND' not in os.environ)): os.environ['PANGOCAIRO_BACKEND'] = "fontconfig"
In grampsapp.py run function. Maybe the easiest way to do this is to include MacOS in the 'if'??? But only if the necessary code is included in the build...

@jralls
Copy link
Member

jralls commented May 18, 2020

That might work, libpango-ft2 is in the bundle already and libpangocairo links to it. If not I can try building pango with forcefontconfig set.

But like I said, I need a way to test it. Is there a string somewhere in in data.gramps with one or more of the symbols?

@prculley
Copy link
Contributor

This PR in its current form has the string of all the symbols in the Genealogical Symbols tab of Preferences. Just make sure that the font selected is 'default'. Or paste
♀ ♂ ⚪ ⚢ ⚣ ⚤ ⚥ ⚦ ⚲ ⊛ * ~ ⚬ ⚭ ⚮ ⚯ ⚰ ⚱ ⚔ ‡ ☠ ☥☦ ☧ ☨ ☩ ☪ ♰ ♱ ✚ ✝ ✞ ✠ ✡ Dead
into a Note. BTW, in my browser, some of these look odd, colored etc. But they look more natural in Gramps.

@jralls
Copy link
Member

jralls commented May 20, 2020

Well, I tried setting os.environ['PANGOCAIRO_BACKEND'] = "fontconfig" in the environment and it crashed harfbuzz, so I guess I need to rearrange the build a bit.

@jralls
Copy link
Member

jralls commented May 20, 2020

FWIW I pasted your string into an unadulterated Gramps Notes window and most of them worked. The ones that didn't were
⚪, ⚢ ,⚣, ⚤, ⚦, ⚭, ⚮, ⚯, ✝, ✞, ✠, and ✡. The rest are supported by a more full-featured face, "menlo", and that might be the one that Gramps is using. I'll have to dig a bit to figure that out.

@codecov-commenter
Copy link

codecov-commenter commented May 20, 2020

Codecov Report

Merging #996 into master will decrease coverage by 0.58%.
The diff coverage is 25.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #996      +/-   ##
==========================================
- Coverage   41.94%   41.35%   -0.59%     
==========================================
  Files        1071     1059      -12     
  Lines      145765   143095    -2670     
==========================================
- Hits        61138    59178    -1960     
+ Misses      84627    83917     -710     
Impacted Files Coverage Δ
gramps/gui/configure.py 0.00% <0.00%> (ø)
gramps/gui/widgets/fanchart.py 0.00% <0.00%> (ø)
gramps/plugins/view/pedigreeview.py 0.00% <0.00%> (ø)
gramps/plugins/view/relview.py 0.00% <0.00%> (ø)
gramps/gen/utils/libformatting.py 12.90% <21.42%> (-0.17%) ⬇️
gramps/gen/config.py 91.88% <100.00%> (-0.05%) ⬇️
gramps/gen/utils/symbols.py 86.15% <100.00%> (+3.34%) ⬆️
gramps/plugins/webreport/updates.py 45.70% <0.00%> (-11.54%) ⬇️
gramps/gen/lib/researcher.py 85.71% <0.00%> (-6.13%) ⬇️
gramps/gen/utils/callback.py 78.07% <0.00%> (-5.27%) ⬇️
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2ae7b9...96229ae. Read the comment docs.

@SNoiraud
Copy link
Member Author

I close this PR and make a new one for 5.1.3

@SNoiraud SNoiraud closed this May 26, 2020
@SNoiraud SNoiraud mentioned this pull request May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants