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

C++: Windows Fallback Font / Can't Type Multiple Newlines (interrelated bugs) #1065

Closed
metal450 opened this issue Jul 29, 2020 · 29 comments · Fixed by #1278
Closed

C++: Windows Fallback Font / Can't Type Multiple Newlines (interrelated bugs) #1065

metal450 opened this issue Jul 29, 2020 · 29 comments · Fixed by #1278

Comments

@metal450
Copy link
Contributor

In the current C++ master (built from source on Windows), I'm not able to enter more than one blank newline at a time. To reproduce:

  1. Create a new node
  2. Type a few characters
  3. Press Enter. At this point, the flashing cursor disappears, but we can assume the cursor is at the start of the 2nd line
  4. Press Enter again
  5. Type a few more characters

The result is that the two lines of characters are right on top of each other. The expectation is that there should be a blank line between them. In other words, it only registered one "enter" press, even if I press "enter" i.e. 2x (or more).

You can also reproduce this by i.e. typing some characters, moving the cursor to the middle of those characters, then pressing Enter a bunch of times. Only the first press of "enter" registered.

@metal450
Copy link
Contributor Author

Edit: another observation - if you start a line with "space," then suddenly you can input multiple newlines (and the cursor doesn't disappear anymore). i.e. type SPACE, then enter, enter, enter - it properly registers all the enters. But only if you begin with the space.

@metal450
Copy link
Contributor Author

Another scenario where I can't type a newline:

  1. Insert a file attachment
  2. Press enter (with the cursor at the end of the line after the attachment - i.e. right after attaching)

Again, the cursor disappears, and I'm unable to type a new line. In order to get it to let me type a new line, I have to type "space," then go back so that the cursor is between the attachment & space - then I can hit "enter" and it works.

@txe
Copy link
Contributor

txe commented Jul 30, 2020

HA, there is a bug about this on https://gitlab.gnome.org/GNOME/gtk/-/issues/2394
Edit: they moved the bug in https://gitlab.gnome.org/GNOME/pango/-/issues/482

@txe
Copy link
Contributor

txe commented Jul 30, 2020

if I set an environment var PANGOCAIRO_BACKEND in console like
set PANGOCAIRO_BACKEND=fc
and start cherrytree in console, then it works ok.

I would like to know how to set this stuff inside the program, so user don't have to do it.

@txe
Copy link
Contributor

txe commented Jul 30, 2020

I added a temporary workaround for now, though it might cause other issues with fonts on windows.

@metal450
Copy link
Contributor Author

Cool, will let u know if I spot any

@metal450
Copy link
Contributor Author

Just built & tried the new version, it looks completely different - some letters are blurry & odd-looking (i.e. f's and t's), & overall looks nothing like Calibri. It's not really usable.

However, I noticed that the ayout of my notes are completely different - there are a bunch of extra newlines now that weren't shown previously. So I went back to before the fallback font was added to see if this is an issue created wit the current build, or by the fallback. It's the fallback. In other words, the current version renders like the version pre-fallback, & all of the notes I added while the fallback was there actually have a bunch of extra newlines that weren't showing, & thus seem to not be layed out properly.

Darn. So I'm gonna go back to & use the pre-fallback-font version for now, I guess, & cleanup all the notes :/

@metal450
Copy link
Contributor Author

(I wish there were a way to sort notes by date-created, so I can figure out which ones I need to go back & fix - I have no idea which ones were created w/ the newline bug & which were before :/

@txe
Copy link
Contributor

txe commented Jul 30, 2020

I don't think the pango team is going to fix this issue soon, so I may try to fix it myself, though it also can take time.
I think it is better to remove support fallback font meanwhile. Other users will no be happy with current results, and you can use other font until it gets fixed. What do you say?

@metal450
Copy link
Contributor Author

Agreed. If the two current options are "No fallback" or "Fallback but erroneous newlines," the former is definitely better.

@txe
Copy link
Contributor

txe commented Jul 30, 2020

I removed fallback font, and happiness was so close so close

@giuspen
Copy link
Owner

giuspen commented Jul 30, 2020

:D

@metal450
Copy link
Contributor Author

I know, right? So close yet so far.

@metal450
Copy link
Contributor Author

metal450 commented Jul 30, 2020

@txe, actually here's a new observation: I just rebooted & tested in Linux (where I also have the Calibri font installed), and its appearance there is like it had been with the latest fix on Windows (i.e. the letters are very blocky, t & f look blurry). In other words, it looks like setting that environment variable on Windows just made Calibri look like it does on Linux - which is very bad. Note that I do use Calibri in other applications on Linux though (i.e. WPS Office), & the font looks fine there - no blockiness or bluriness. I wonder why.

(relates to: #1055)

@txe
Copy link
Contributor

txe commented Jul 30, 2020

Gtk3/Cairo uses different backends to draw fonts on Linux and Windows. PANGOCAIRO_BACKEND=fc switches from win which uses native Windows functions to fontconfig backend.

Maybe blocky font appearance is related to https://wiki.archlinux.org/index.php/Font_configuration#Calibri,_Cambria,_Monaco,_etc._not_rendering_properly

Maybe other applications with normal view drawing are based not on Gtk3/Cairo, but Qt or chrome, or something else.

@metal450
Copy link
Contributor Author

So if I understand correctly: if the bug you previously posted gets fixed, it could use the windows backend & thus appear well on Windows (with fallbacks) - but probably in any case, it would never display them well on Linux?

@txe
Copy link
Contributor

txe commented Jul 30, 2020

I don't know, fonts on linux always have problems. But you can use a good replacement:
Google released a freely-licensed font called Carlito, which is metric-compatible to Calibri

@metal450
Copy link
Contributor Author

Oh cool, good to know, thanks! :)

@metal450
Copy link
Contributor Author

So I had a thought about this: essentially what we're dealing with are 3 interrelated issues:

*Fallback font (for when a given character doesn't exist in the selected font)
*Newlines/return key working as expected
*Calibri font displaying correctly (non-garbled/blocky)

The original cherrytree version had the 1st item broken.
The first fix you tried fixed the first issue, but then introduced the 2nd.
The next fix you tried fixed the 2nd issue, but introduced the 3rd. However, note that this solution essentially makes the Windows version work just like the Linux version (fallback works, newlines work, but it just doesn't display Calibri well). And I realized that if Carlito is available as an alternative to Calibri...then that actually seems to solve everything - just if a user wants to use a Calibri-like font, they can use Carlito rather than Calibri, both on Linux & Windows. I tried it on Linux, and it worked great: with Carlito selected, 1 2 & 3 were all OK.

....However, on Windows: I installed Carlito, but the 3rd build couldn't see the font as available - i.e. it wasn't listed in the fonts dialog. Other Windows applications could, and even the original cherrytree build (before the fallback font fix) could. I tried selecting Carlito via that previous ct build, but when I then ran the fixed build, its font setting fell back to 'none.'

...So I guess there's a 4th issue: not being able to see Carlito. I've no idea why that would happen - but if you do...then your final fix may actually be the best, as if Carlito could be used, it fixes the fallback issue & everything else too :)

@metal450 metal450 changed the title C++ Bug: Can't Type Multiple Newlines C++: Windows Fallback Font / Can't Type Multiple Newlines (interrelated bugs) Jul 31, 2020
@txe
Copy link
Contributor

txe commented Aug 4, 2020

I added a merge request for the pango fix, https://gitlab.gnome.org/GNOME/pango/-/merge_requests/217.
But even if they don't merge it, we can provide pango library with the fix.

@metal450
Copy link
Contributor Author

metal450 commented Aug 4, 2020

Awesome :)

@txe
Copy link
Contributor

txe commented Aug 21, 2020

The fix was merged in cairo pango, so it will be in the next release 1.46.2 maybe in one or two weeks.
The next quest will be to ask the msys2 maintainers to update it, they use now quite old one 1.43

@giuspen
Copy link
Owner

giuspen commented Aug 21, 2020

Well done!

@txe
Copy link
Contributor

txe commented Oct 25, 2020

@giuspen , it doesn't look that cairo pango was updated in msys2. We can either ask them to update cairo pango or just build it ourselves.

@giuspen
Copy link
Owner

giuspen commented Oct 25, 2020

@txe some time ago I raised a GitHub issue asking to include cpputest and they did it in few days, if you can do it since you know better the details, please post here the link to the issue - if they don't answer I'll also comment asking for their help. Should be under https://github.com/msys2/MINGW-packages/issues

@txe
Copy link
Contributor

txe commented Oct 25, 2020

Here we go
msys2/MINGW-packages#7172

@txe
Copy link
Contributor

txe commented Oct 25, 2020

Well, it was a bit awkward, they already have updated pango (while I was mistakenly looking for cairo)
So I just can return fallback font code back.

@giuspen
Copy link
Owner

giuspen commented Oct 25, 2020

Great!

@txe
Copy link
Contributor

txe commented Oct 26, 2020

The issue was fixed, the update will be in 0.99.18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants