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

Support mixed font rendering #627

Closed
konomikitten opened this issue Sep 7, 2019 · 30 comments
Closed

Support mixed font rendering #627

konomikitten opened this issue Sep 7, 2019 · 30 comments

Comments

@konomikitten
Copy link

Expected Behavior

Rendering of mixed fonts.

Current Behavior

At the moment qterminal only allows for using a single font for rendering. A good example for this is how you're unable to see emoji from the Noto Color Emoji font when not using it as your main font for qterminal.

qterminal-xfce-terminal

Possible Solution

None.

Steps to Reproduce (for bugs)
  1. Select a font other than Noto Color Emoji
  2. Copy some emoji to your clipboard
  3. Paste it into qterminal
Context

Not sure what to put here.

System Information
@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

Would you please name a terminal emulator that does that? I do the same thing with gnome-terminal and it shows nothing at all.

@konomikitten
Copy link
Author

@tsujan the image shows qterminal on the left and xfce4-terminal on the right. xfce4-terminal supports mixed rendering.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

xfce4-terminal is exactly like gnome-terminal here: shows nothing at all, even when I choose Noto Color Emoji as its font. It should be some other setting in your case.

@konomikitten
Copy link
Author

xfce4-terminal is exactly like gnome-terminal here: shows nothing at all, even when I choose Noto Color Emoji as its font. It should be some other setting in your case.

I think you must have something wrong on your end because I can clearly get it working here. Screenshot below.

xfce4-terminal-rendering-multiple-fonts

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

Back to front: xfce4-terminal, gnome-terminal, qterminal:

terminals

xfce4-terminal's settings are as in your screenshot.

@konomikitten
Copy link
Author

@tsujan could be your distro I'm not sure I know for a fact on two Debian bullseye installs this works correctly on xfce terminal.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

I may be wrong but I guess this isn't about the terminal itself.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@yan12125 is the expert in this area. Let's wait for him to see this.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

OK, I was right: This doesn't have anything to do with terminals.

Read https://www.reddit.com/r/linux/comments/ao0mp3/how_to_better_enable_color_emojis/ , do as it says, and you'll have colored emoji inside QTerminal, FeatherPad,... without needing to change their fonts.

EDIT: For me, adding these lines to fonts.conf was enough:

 <!-- For colored emojis: -->
 <match target="pattern">
  <test name="family"><string>monospace</string></test>
  <edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
 </match>

@tsujan tsujan closed this as completed Sep 7, 2019
@agaida
Copy link
Member

agaida commented Sep 7, 2019

ok - after 0.15 - maybe before, we have to polish some configurations - font config is one of them, there is an ancient debian report about and the report is right - will file something if not in our bugs yet

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@agaida These emojis need special fonts. Adding 4 lines to fonts.conf is easy but font config should first check if the required font(s) are installed.

Anyhow, although this report wasn't valid, it had a good result.

@agaida
Copy link
Member

agaida commented Sep 7, 2019

grml - we shouldn't use fonts:conf any longer - thats what the debian report is about - instead we should use fonts.conf.d

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=834599

EDIT: More precise - Nobody should use generic configurations if there is a config dir available for a certain application

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

OK. In any of these cases, two things need to be added:

  1. High priority: A configuration for monospace, so that the user could choose it (if he/she wants to).

  2. Low priority: Another configuration for choosing a monospace (colored) emoji font.

Would you open an issue for them and also for fonts.conf.d?

@konomikitten
Copy link
Author

The ~/.fonts.conf vs ~/.config/fontconfig/conf.d/ is not an issue as I was able to get fonts rendering this way:

sudo editor ~/.config/fontconfig/conf.d/99-noto-mono-color-emoji.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="pattern">
    <test qual="any" name="family"><string>mono</string></test>
    <edit name="family" mode="assign"><string>monospace</string></edit>
  </match>
  <match>
    <test name="family"><string>monospace</string></test>
    <edit name="family" mode="prepend" binding="strong"><string>Noto Color Emoji</string></edit>
  </match>
</fontconfig>

fc-cache -rf

Working emoji terminus and Noto:

sort-of-working

But doing things like this have side affects, whatever font you match in this case monospace will be affected by the change and now in Feather you can see it affecting all monospace fonts.

With ~/.config/fontconfig/conf.d/99-noto-mono-color-emoji.conf.

with config

Without ~/.config/fontconfig/conf.d/99-noto-mono-color-emoji.conf.

without-config

Using font-config matching is not the answer, though I am not saying that I do know what xfce4-terminal is doing to render correctly and I certainly didn't have to go messing about with font-config matching it just worked.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

But doing things like this have side affects, whatever font you match in this case monospace will be affected by the change

→ What I said above about monospace. Something like this:

 <alias>
  <family>monospace</family>
  <prefer>
   <family>DejaVu Sans Mono</family>
  </prefer>
 </alias>

...didn't have to go messing about....

This isn't "messing" but "configuring". Of course, anyone could mess with any configuration.

@agaida
Copy link
Member

agaida commented Sep 7, 2019

@tsujan - right now i'm working on lxqt-kcm-integration - will file the bugs afterwards - and if the kcm integration is done we can have i look what we can and should borrow from the KDE guys.

The basic KCM thing is dead simple, but the sorting need to be refined i guess - same for run-time dependencies, different story.

@konomikitten
Copy link
Author

his isn't "messing" but "configuring". Of course, anyone could mess with any configuration.

That will still make DejaVu Sans Mono render incorrectly and once again xfce terminal did not need configuring and works even without the fontconfig changes you've shown so how do you explain that?

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@konomikitten

All in all:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <!-- Previous lines, if any -->
 <!-- For colored emojis: -->
 <match target="pattern">
  <test name="family"><string>monospace</string></test>
  <edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
 </match>
 <!-- To fix monospace: -->
 <alias>
  <family>monospace</family>
  <prefer>
   <family>DejaVu Sans Mono</family>
  </prefer>
 </alias>
</fontconfig>

LXQt font config should do it automatically in future.

@agaida I don't think KDE has what I requested above. I might look into it when I find the time.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

how do you explain that?

I can't explain what a GTK terminal does -- a terminal that can't insert emojis even with the correct font and have problems in text rendering (see my screenshot). GTK apps may need some things that only GTK DEs provide.

@konomikitten
Copy link
Author

Just a little note that tripped me up for a bit, configs in ~/.config/fontconfig/conf.d/ should start with a number or they are ignored.

@konomikitten
Copy link
Author

@tsujan I refined the config down you don't need the work around alias.

~/.config/fontconfig/conf.d/99-emoji.conf

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <match target="pattern">
    <test name="family"><string>monospace</string></test>
    <edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
  </match>
</fontconfig>

This seems to work with no issues and be the most minimal form, being a conf.d file qterminal wouldn't have to worry about clobbering the users config either.

@konomikitten
Copy link
Author

konomikitten commented Sep 7, 2019

Also interestingly even with the config there are still differences between two terminals. Note the flags at the bottom.

xfce-terminal
xfce-terminal

qterminal with config change
qterminal-with-config

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@konomikitten

It depends on the system and its font configs. Hopefully, we won't need to edit the file manually in near future.

Those flags are OK in FeatherPad with U+E006E U+E0067 , U+E0063 U+E0074 ,... but not in QTerminal. They don't have a single code; that may be somehow relevant.

As for how GTK does it, I think it has its own settings. In Arch, xfce4-terminal needs libxfce4ui, libxfce4util and xfconf but they can't fix xfce4-terminal's problem. Maybe another xfce package is needed too. For now, I don't have time to investigate it.

@konomikitten
Copy link
Author

@tsujan least this gets it somewhat usable now.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@konomikitten If you find time, please see what happens with Konsole. I'm like this now: 🤪

@konomikitten
Copy link
Author

@tsujan the config works fine with konsole too, ignore the weird spacing when typing it isn't related to the config

Konsole
konsole

@agaida
Copy link
Member

agaida commented Sep 7, 2019

@konomikitten - the numbers are important in cases where the sort in which the configs are readed is important - so it is good practice that the basic configurations (upstream) are read first, afterwards the distribution configs - after that the derivatives and other configs - so we should not provide 99-foo.conf as upstream :P

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

@konomikitten Thanks! So, those flags aren't specific to QTerminal, although they aren't related to Qt either. QTerminal was forked from Konsole a long time ago.

@tsujan
Copy link
Member

tsujan commented Sep 7, 2019

Attached are thousands of emojis for those who want to test quickly. All of them should be seen correctly in FeatherPad if the font config is right.

emojis.zip

@yan12125
Copy link
Member

I have enabled wiki for qterminal some time ago. Feel free to write fontconfig tricks there. https://github.com/lxqt/qterminal/wiki

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

No branches or pull requests

4 participants