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

LaTeX \textit{..} is not redered correctly in Main table #3356

Closed
halirutan opened this issue Oct 26, 2017 · 26 comments
Closed

LaTeX \textit{..} is not redered correctly in Main table #3356

halirutan opened this issue Oct 26, 2017 · 26 comments

Comments

@halirutan
Copy link
Collaborator

halirutan commented Oct 26, 2017

Entry to reproduce:

@Article{Abdala2007,
  author    = {Fernando Abdala},
  title     = {{{Redescription} {of} \textit{Platycraniellus elegans} ({Therapsida}, {Cynodontia}) {from} {the} {Lower} {Triassic} {of} {South} {Africa}, {and} {the} {cladistic} {relationships} {of} {eutheriodonts}}},
  journal   = {Palaeontology},
  year      = {2007},
  volume    = {50},
  number    = {3},
  pages     = {591--618},
  month     = {may},
  doi       = {10.1111/j.1475-4983.2007.00646.x},
  file      = {Abdala2007.pdf:Abdala2007.pdf:PDF},
  groups    = {Nanictosaurus, Ictidosuchoides},
  keywords  = {Platycraniellus elegans, Cynodontia, galesaurids, Early Triassic, South Africa.},
  publisher = {Wiley-Blackwell},
  url       = {http://dx.doi.org/10.1111/j.1475-4983.2007.00646.x},
}

Gives the following representation in the main table

screen shot 2017-10-26 at 12 38 55

The Preview is not affected.

MacOS Sierra 10.12.6
JabRef current master branch
Mac OS X 10.12.6 x86_64 
Java 1.8.0_144
@halirutan halirutan changed the title LaTeX ` LaTeX \textit{..} is not redered correctly in Main table on OSX Oct 26, 2017
@halirutan
Copy link
Collaborator Author

This issue seems not related to JabRef. It is related to JLabel and Swing. A minimal working example can be found here (I'll attach the code below). I'm not setting any different font or font size. Still, what I get is

screen shot 2017-10-26 at 14 37 44

Note that I see the correctly rendered label in the debugger. So the Unicode conversion is correct

screen shot 2017-10-26 at 14 38 53

There are several similar issues on SO but none fits to such a simple example. Can someone on OS X try this by creating a class in the jabref package and pasting the content?

package org.jabref;


import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import org.jabref.model.strings.LatexToUnicodeAdapter;

public class SwingJLabelTester extends JPanel{

    private SwingJLabelTester() {
        super(new GridLayout(3,1));  //3 rows, 1 column
        final String latexString = LatexToUnicodeAdapter.format("This is a \\textit{test for italics} and \\textbf{a test for bold}");
        final JLabel label = new JLabel(latexString, SwingConstants.CENTER);
        label.setVerticalTextPosition(SwingConstants.BOTTOM);
        label.setHorizontalTextPosition(SwingConstants.CENTER);
        add(label);
    }

    private static void createAndShowGUI() {
        final JFrame frame = new JFrame("LabelDemo");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(new SwingJLabelTester());
        frame.setSize(400,400);
        frame.setVisible(true);
    }

    public static void main(final String[] args) {
        SwingUtilities.invokeLater(SwingJLabelTester::createAndShowGUI);
    }

}

@Siedlerchr
Copy link
Member

The problem reminded me of the issue #2784 and the follow up discussion we had on this.

@AEgit
Copy link

AEgit commented Oct 26, 2017

See discussion here:
#2784
here:
#2752
and here:
#3008

I thought this was fixed with #3008, but I encounter this issue again in:
JabRef 4.1-dev--snapshot--2017-10-23--master--451b6f3de
Windows 10 10.0 amd64
Java 1.8.0_151

Could it be that when reinstalling a new version of JabRef, old preferences for system fonts are imported, which cause the issue (see also #3008)?

@halirutan
Copy link
Collaborator Author

@Siedlerchr @AEgit Oh god, this is a lot of information. I only skimmed over some issues to see if this has been reported recently. This quote from @lenhard

Before that change, you could have italics in the main table with the right font. Now, I can't find one that supports it.

It was my first guess as well and I tried different settings but nothing helped. That's why I implemented the test-class. Additionally, I read through some SO posts and finally asked with this minimal example here.

When it is indeed a font issue that comes and goes with setting different fonts it would be bad since users can change this as they like. Since the main table is only displayed and not edited directly, would it be an option to use HTML like we do in the preview?

@Siedlerchr
Copy link
Member

HTML could be an option, should be possible, https://docs.oracle.com/javase/tutorial/uiswing/components/html.html
In JabRef all MainTable stuff is in the org.jabref.gui.maintable package

@AEgit
Copy link

AEgit commented Oct 26, 2017

Maybe a stupid question: Was there a reason for why HTML wasn't used in the first place for the main table? Could this influence the performance in large databases?

@AEgit
Copy link

AEgit commented Oct 27, 2017

The first time I started (after new installation)

JabRef 4.1-dev--snapshot--2017-10-26--master--3d4b5104d
Windows 10 10.0 amd64
Java 1.8.0_151

this issue seemed to be fixed, i. e. the \textit{} was interpreted correctly and text appeared in italics in the main table.

The second time I started the same JabRef version, the issue reported above reappeared, i. e. text that should render in italics is replaced by squares in the main table. This issue persists when restarting JabRef. This indicates, I guess, that something changes in the default settings between the first installation of JabRef and subsequent use.

@Siedlerchr
Copy link
Member

We could use the latex2html converter, similar as in #3574

@tobiasdiez tobiasdiez changed the title LaTeX \textit{..} is not redered correctly in Main table on OSX LaTeX \textit{..} is not redered correctly in Main table Jan 2, 2018
@tobiasdiez
Copy link
Member

This should be fixed in the latest development version. Could you please check the build from https://builds.jabref.org/maintable-beta/. Thanks! Note this version is in a very early beta stage and might not work as expected. See #3621 for further details.

@AEgit
Copy link

AEgit commented Jan 30, 2018

I can confirm that this has been fixed in:

JabRef 4.2-dev--snapshot--2018-01-30--maintable-beta--85342350f
Windows 10 10.0 amd64
Java 1.8.0_161

Thank you for your help!

Note, however, that the performance of the search has dropped significantly in the new build and other issues appear to persist (see #1513 (comment)).

@tolot27
Copy link
Contributor

tolot27 commented Feb 6, 2018

Unfortunately, the problem still exists with JabRef_windows-x64_4_2-dev--snapshot--2018-02-05--master--e33bd5888 and Windows 8.1 with JRE 8 (Update 166).
Interstingly, it works with Win10.

@lenhard
Copy link
Member

lenhard commented Feb 6, 2018

@tolot27 You are using the wrong branch. This is not yet in master, but in the maintable-beta branch linked by @tobiasdiez above.

@tolot27
Copy link
Contributor

tolot27 commented Feb 6, 2018

I've tried the maintable-beta branch but the problem persists.

@tobiasdiez tobiasdiez reopened this Jul 25, 2018
@tobiasdiez
Copy link
Member

As the discussion in #4236 shows, more users have problems with italics even with the new master branch. I'll thus reopen it. Probably, it depends on the active (system?) font.

@AEgit
Copy link

AEgit commented Jul 25, 2018

Cannot reproduce this issue for:

JabRef 5.0-dev--snapshot--2018-07-25--master--077fdacc2
Windows 10 10.0 amd64
Java 1.8.0_181

Note, however, my post here: #3356 (comment)
If this issue exists, it might be difficult to reproduce it consistently if it has to do with the way JabRef is closed/the database is saved. I have tried to reopen my database multiple times and did not encounter the issue, but I cannot guarantee, that this is the case for everyone.

@tolot27
Copy link
Contributor

tolot27 commented Jul 25, 2018

I tested it with 4.3.1 and 5.0-dev--snapshot--2018-07-25--master--077fdacc2 and cannot reproduce the bug anymore.

@Siedlerchr
Copy link
Member

It might be a font Unicode issue on older Windows Versions.

It would be nice if someone of the Mac or Linux user can check that as well.

@halirutan
Copy link
Collaborator Author

@Siedlerchr In Linux, with Java 1.7u162 this works for me. If someone wonders how to quickly use the test-code that I provide here in IDEA:

  1. Copy the code
  2. Have the JabRef project open
  3. Create a new scratch file using Ctrl+Shift+A and type scratch. Select Java
  4. Paste the code in there, go over the class error and press Alt+Enter to rename the file to the class name
  5. Use the small "run" button on the left side, next to the main method

It should look like this

img

Although I don't see a vast difference between plain and bold text, at least I have no missing characters.

@Siedlerchr
Copy link
Member

Thanks for the test, but are you aware that it runs completely on JavaFX now (maintable and entry editor)?

I think we can close this again, as windows 7 specific

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

k3KAW8Pnf7mkmdSMPHz27 commented May 28, 2020

@Siedlerchr this "problem" might still exists in Mac OS X.

Skärmavbild 2020-05-28 kl  13 33 12

I have managed to get some inconsistent behaviours on this one (sometimes italic and bold works as expected and sometimes not at all, and sometimes like on the screenshot, it partially works).

Should I open up a new issue or is this better solved in some other way?

Version of screenshot is
JabRef 5.1--2020-05-28--ffa07cd
Mac OS X 10.15.5 x86_64
Java 14.0.1

red highlights are added by me

@Siedlerchr
Copy link
Member

For the author/editor field it's not that relevant, title or any other fields are more important

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

k3KAW8Pnf7mkmdSMPHz27 commented May 28, 2020

I could look at it tomorrow, the behaviour is the same/similar in author/title and I can get it to both work/break, the only difference between the 2 screenshots are a resizing event.

Skärmavbild 2020-05-28 kl  14 38 21

Skärmavbild 2020-05-28 kl  14 38 37

Also note that the preview in the bottom right doesn't display the same thing as the maintable. Even if this is just a Mac OS X "thing", does it seem reasonable that I take a closer look at it?

@Siedlerchr
Copy link
Member

@k3KAW8Pnf7mkmdSMPHz27 The entry preview is controlled over html code in the preferences under Entry preview. It's essentially a web browser component. (WebView)
The main table uses plain Unicode as it does not support html formatting,

I guess there is something wrong with the latex2unicode parsing as well
And tip: you can also make the preview a new tab in the entry editor

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

And tip: you can also make the preview a new tab in the entry editor
I see 😀

I'll not put more time into this then, I am off to find some more beginner friendly issue to tackle 😎

@Siedlerchr
Copy link
Member

Feel free to take any open issue you want.
We still have enough for everyone 😉😜
Easy beginner issues are also tagged with the good first issue label

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

No branches or pull requests

7 participants