【问题标题】:why is pt font smaller than px font in JTextPane when using the same number?为什么使用相同数字时,JTextPane 中的 pt 字体小于 px 字体?
【发布时间】:2017-04-21 21:32:08
【问题描述】:
public static void main(String[] args) {
    JFrame frame = new JFrame("Test");
    JTextPane pane = new JTextPane();
    pane.setContentType("text/html");
    pane.setText("<html>"
            + "<head>"
            + "<title> New Document </title>"
            + "</head>"
            + "<body>"
            + "<div style=\"font-size:20pt\">bbbbbbbb-20pt</div>"
            + "<div style=\"font-size:20px\">bbbbbbbb-20px</div>"
            + "</body>"
            + "</html>");
    frame.add(pane, BorderLayout.CENTER);
    frame.setSize(500, 600);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
}

框架显示:

但相同的 HTML 在浏览器中的显示方式不同:

【问题讨论】:

标签: html font-size jtextpane


【解决方案1】:

简而言之:像素和点是不同的单位,表示不同的东西。

一个像素在您的显示器上小于 1/72 英寸(或至少在您的平台认为您的显示器是什么)。

【讨论】:

    猜你喜欢
    • 2016-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    相关资源
    最近更新 更多