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

Question about rendering unicode in plot labels #128

Closed
fpalazzolo opened this issue Mar 27, 2024 · 6 comments
Closed

Question about rendering unicode in plot labels #128

fpalazzolo opened this issue Mar 27, 2024 · 6 comments
Assignees

Comments

@fpalazzolo
Copy link
Contributor

fpalazzolo commented Mar 27, 2024

I notced that if my QStrings are internationalized (Japanese or Chinese encoded UTF-16), they don't render correctly on plot axes labels, etc, if I just use setAxisLabel(). Is there an easy way to make the MathText labels on the plots just render the QStrings like Qt normally would? Thanks!

@fpalazzolo
Copy link
Contributor Author

FWIW - I found that using the Verbatim environment ( "\verb!" + "!" ) causes the UTF-16 to be rendered ok. Hopefully that is the right answer.

@fpalazzolo
Copy link
Contributor Author

It looks like I am stuck with the verbatim font if I do this. I'd really like to change the fonts around as well. In fact, I can't even sort out how to do that with regular text for the titles and axislables. None of the latex commands related to fonts seem to have any effect, except to change the size.

@jkriege2 jkriege2 self-assigned this Mar 28, 2024
jkriege2 added a commit that referenced this issue Mar 28, 2024
…icode characters were not rendered if they are not in the currently active font, as fallback-rendering was switched off. It is now switched on again for text and verbatim nodes. Thanks to user:fpalazzolo for reporting this bug

FIXED font rendering was not always anti-aliased
@jkriege2
Copy link
Owner

Hi!
yes, I can confirm this behaviour ... actually I didn't look into Unicode-rendering all that much yet ... There are instructions like \unicode{} that let you specify a codepoint as a number... but that does not really solve your problem.

The rendering occurs in the given way, because it was necessary (at one point during development) for the correct rendering of Blackboard-fonts with unicode characters (so not requiring a special font)... or so I thought ... basically the option QFont::NoFontMerging was set for all QFont's used for rendering text. Therefore the fallback is switched off, but the rendering is possibly more consistent when selecting e.g. a fancy font as no characters from other fonts are mixed in.

in \verb!! that option is not set ... as you found out, verb-text does use a special font, the typewriter-font, which can be set JKQTMathText::setFontTypewriter() and you can access the JKQTMathText-instance used by a JKQTPlotter via JKQTBasePlotter::getMathText().

But in the end, you are right to expect unicode-rendering to work out of the box. I therefore changed the behaviour of the text and verbatim-nodes. Now it should work as expected (I just selected random unicode characters):

image
image

Here's what happens when you code does not support the characters:
image
image

But in the end, that seems to me the better compromise than not showing the characters at all ...

So: there you go ;-) ... hope that helps.

@jkriege2
Copy link
Owner

Please check aa4ac4c for the fix ... and close this issue, if you're happy ;-)

@jkriege2
Copy link
Owner

jkriege2 commented Apr 7, 2024

@fpalazzolo Can I close this Issue?

@fpalazzolo
Copy link
Contributor Author

Thank you!

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

No branches or pull requests

2 participants