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

Linux: JLabel html rendering changes font size #912

Closed
cmadsen opened this issue Nov 22, 2024 · 3 comments
Closed

Linux: JLabel html rendering changes font size #912

cmadsen opened this issue Nov 22, 2024 · 3 comments
Milestone

Comments

@cmadsen
Copy link

cmadsen commented Nov 22, 2024

JLabel html rendering changes font size with java 17 using flatlaf 3.5.2

JLabel l1 = new JLabel("Destination");
String htmlDestination = "<HTML><A HREF=http://destination>Destination</A></HTML>";
JLabel l2 = new JLabel(htmlDestination);

unnamed

Without flatlaf

unnamed

The following code can be used to reproduce the issue:

import static javax.swing.SwingUtilities.*;

import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

import org.jdesktop.swingx.JXFrame;

import com.formdev.flatlaf.FlatLightLaf;

import net.miginfocom.swing.MigLayout;

public class FlatLafTextFieldHtmlIssue extends JXFrame {

	public FlatLafTextFieldHtmlIssue() {
		try {
			UIManager.setLookAndFeel(new FlatLightLaf());
		} catch (Exception e) {
			e.printStackTrace();
		}
		JPanel p = new JPanel(new MigLayout());
		JLabel l1 = new JLabel("Destination");
		p.add(l1, "wrap");
		String htmlDestination = "<HTML><A HREF=http://destination>Destination</A></HTML>";
		JLabel l2 = new JLabel(htmlDestination);
		p.add(l2, "wrap");
		getContentPane().add(p);
		Font f1 = l1.getFont();
		Font f2 = l2.getFont();
		System.out.println(f1);
		System.out.println(f2);
		setTitle("Flat Laf Html Text Issue");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		pack();
		setVisible(true);
	}

	public static void main(String[] args) {
		invokeLater(() -> {
			new FlatLafTextFieldHtmlIssue();
		});
	}

}
@DevCharly
Copy link
Collaborator

Which operating system do you use?

@cmadsen
Copy link
Author

cmadsen commented Nov 22, 2024

Fedora 40, KDE, Xorg session

DevCharly added a commit that referenced this issue Dec 4, 2024
…aint HTML text when default font family is _Cantarell_ (e.g. on Fedora) (issue #912)

the removed use of floating point font size is similar to what is done in JDK for GTK Look and Feel:
- https://bugs.openjdk.org/browse/JDK-6979979
- openjdk/jdk@306f12d
@DevCharly
Copy link
Collaborator

Fixed in latest 3.5.3-SNAPSHOT: https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 3.5.3 milestone Dec 4, 2024
@DevCharly DevCharly changed the title JLabel html rendering changes font size Linux: JLabel html rendering changes font size Dec 4, 2024
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

2 participants