286 | - * The default size is 12 and the default style is PLAIN.
287 | + * The default size is 9 and the default style is PLAIN.
288 | * If str
does not specify a valid size, the returned
289 | - * Font
has a size of 12. If str
does not
290 | + * Font
has a size of 9. If str
does not
291 | * specify a valid style, the returned Font has a style of PLAIN.
292 | * If you do not specify a valid font name in
293 | * the str
argument, this method will return
294 | @@ -1477,7 +1477,7 @@ public class Font implements java.io.Ser
295 | * your system, use the
296 | * {@link GraphicsEnvironment#getAvailableFontFamilyNames()} method.
297 | * If str
is null
, a new Font
298 | - * is returned with the family name "Dialog", a size of 12 and a
299 | + * is returned with the family name "Dialog", a size of 9 and a
300 | * PLAIN style.
301 | * @param str the name of the font, or null
302 | * @return the Font
object that str
303 | @@ -1489,7 +1489,7 @@ public class Font implements java.io.Ser
304 | public static Font decode(String str) {
305 | String fontName = str;
306 | String styleName = "";
307 | - int fontSize = 12;
308 | + int fontSize = 9;
309 | int fontStyle = Font.PLAIN;
310 |
311 | if (str == null) {
312 | @@ -1508,7 +1508,7 @@ public class Font implements java.io.Ser
313 | fontSize =
314 | Integer.valueOf(str.substring(sizeIndex+1)).intValue();
315 | if (fontSize <= 0) {
316 | - fontSize = 12;
317 | + fontSize = 9;
318 | }
319 | } catch (NumberFormatException e) {
320 | /* It wasn't a valid size, if we didn't also find the
321 | Index: jdk8u152-b16/jdk/src/share/classes/java/awt/font/FontRenderContext.java
322 | ===================================================================
323 | --- jdk8u152-b16.orig/jdk/src/share/classes/java/awt/font/FontRenderContext.java
324 | +++ jdk8u152-b16/jdk/src/share/classes/java/awt/font/FontRenderContext.java
325 | @@ -30,6 +30,7 @@
326 | package java.awt.font;
327 |
328 | import java.awt.RenderingHints;
329 | +import java.awt.Toolkit;
330 | import static java.awt.RenderingHints.*;
331 | import java.awt.geom.AffineTransform;
332 |
333 | @@ -69,13 +70,27 @@ public class FontRenderContext {
334 | private transient Object fmHintValue;
335 | private transient boolean defaulting;
336 |
337 | + private static class LazyDefaults {
338 | +
339 | + private static final Object DEFAULT_TEXT_ANTIALIASING_HINT = discoverDefaultTextAntialiasingHint();
340 | +
341 | + private static Object discoverDefaultTextAntialiasingHint() {
342 | + Toolkit toolkit = Toolkit.getDefaultToolkit();
343 | + Object hint = toolkit.getDesktopProperty("ui.defaultFont.antialiasing");
344 | + if (hint != null) {
345 | + return hint;
346 | + }
347 | + return VALUE_TEXT_ANTIALIAS_DEFAULT;
348 | + }
349 | + }
350 | +
351 | /**
352 | * Constructs a new FontRenderContext
353 | * object.
354 | *
355 | */
356 | protected FontRenderContext() {
357 | - aaHintValue = VALUE_TEXT_ANTIALIAS_DEFAULT;
358 | + aaHintValue = LazyDefaults.DEFAULT_TEXT_ANTIALIASING_HINT;
359 | fmHintValue = VALUE_FRACTIONALMETRICS_DEFAULT;
360 | defaulting = true;
361 | }
362 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/UIManager.java
363 | ===================================================================
364 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/UIManager.java
365 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/UIManager.java
366 | @@ -59,6 +59,7 @@ import sun.security.action.GetPropertyAc
367 | import sun.swing.SwingUtilities2;
368 | import java.lang.reflect.Method;
369 | import java.util.HashMap;
370 | +import javax.swing.plaf.FontUIResource;
371 | import sun.awt.AppContext;
372 | import sun.awt.AWTAccessor;
373 |
374 | @@ -1409,6 +1410,22 @@ public class UIManager implements Serial
375 |
376 | private static void initializeSystemDefaults(Properties swingProps) {
377 | getLAFState().swingProps = swingProps;
378 | + Font defaultFont;
379 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
380 | + if (o instanceof Font) { // implicit null check
381 | + defaultFont = (Font) o;
382 | + } else {
383 | + defaultFont = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
384 | + }
385 | + defaultFont = new FontUIResource(defaultFont);
386 | + UIDefaults systemDefaults = getLAFState().getSystemDefaults();
387 | + if (systemDefaults == null) {
388 | + systemDefaults = new UIDefaults();
389 | + getLAFState().setSystemDefaults(systemDefaults);
390 | + }
391 | + systemDefaults.put("ui.defaultFont", defaultFont);
392 | + systemDefaults.put("ui.defaultFont.size", defaultFont.getSize());
393 | + systemDefaults.put("customFontSize", defaultFont.getSize());
394 | }
395 |
396 |
397 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/border/TitledBorder.java
398 | ===================================================================
399 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/border/TitledBorder.java
400 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/border/TitledBorder.java
401 | @@ -687,7 +687,7 @@ public class TitledBorder extends Abstra
402 | return font;
403 | }
404 | }
405 | - return new Font(Font.DIALOG, Font.PLAIN, 12);
406 | + return UIManager.getFont("ui.defaultFont");
407 | }
408 |
409 | private Color getColor(Component c) {
410 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/colorchooser/DefaultPreviewPanel.java
411 | ===================================================================
412 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/colorchooser/DefaultPreviewPanel.java
413 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/colorchooser/DefaultPreviewPanel.java
414 | @@ -61,7 +61,7 @@ class DefaultPreviewPanel extends JPanel
415 |
416 |
417 | private int textGap = 5;
418 | - private Font font = new Font(Font.DIALOG, Font.PLAIN, 12);
419 | + private Font font = UIManager.getFont("ui.defaultFont");
420 | private String sampleText;
421 |
422 | private int swatchWidth = 50;
423 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
424 | ===================================================================
425 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
426 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java
427 | @@ -459,29 +459,31 @@ public abstract class BasicLookAndFeel e
428 | Long oneThousand = new Long(1000);
429 |
430 | // *** Shared Fonts
431 | - Integer twelve = new Integer(12);
432 | - Integer fontPlain = new Integer(Font.PLAIN);
433 | - Integer fontBold = new Integer(Font.BOLD);
434 | - Object dialogPlain12 = new SwingLazyValue(
435 | + Font f;
436 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
437 | + if (o instanceof Font) { // implicit null check
438 | + f = (Font) o;
439 | + } else {
440 | + f = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
441 | + }
442 | + Integer fontSize = f.getSize();
443 | + Object dialogPlain = new SwingLazyValue(
444 | "javax.swing.plaf.FontUIResource",
445 | null,
446 | - new Object[] {Font.DIALOG, fontPlain, twelve});
447 | - Object serifPlain12 = new SwingLazyValue(
448 | + new Object[] {f.getFamily(), f.getStyle(), fontSize});
449 | + Object serifPlain = new SwingLazyValue(
450 | "javax.swing.plaf.FontUIResource",
451 | null,
452 | - new Object[] {Font.SERIF, fontPlain, twelve});
453 | - Object sansSerifPlain12 = new SwingLazyValue(
454 | + new Object[] {Font.SERIF, Font.PLAIN, fontSize});
455 | + Object sansSerifPlain = dialogPlain;
456 | + Object monospacedPlain = new SwingLazyValue(
457 | "javax.swing.plaf.FontUIResource",
458 | null,
459 | - new Object[] {Font.SANS_SERIF, fontPlain, twelve});
460 | - Object monospacedPlain12 = new SwingLazyValue(
461 | + new Object[] {Font.MONOSPACED, Font.PLAIN, fontSize});
462 | + Object dialogBold = new SwingLazyValue(
463 | "javax.swing.plaf.FontUIResource",
464 | null,
465 | - new Object[] {Font.MONOSPACED, fontPlain, twelve});
466 | - Object dialogBold12 = new SwingLazyValue(
467 | - "javax.swing.plaf.FontUIResource",
468 | - null,
469 | - new Object[] {Font.DIALOG, fontBold, twelve});
470 | + new Object[] {f.getFamily(), Font.BOLD, fontSize});
471 |
472 |
473 | // *** Shared Colors
474 | @@ -670,7 +672,7 @@ public abstract class BasicLookAndFeel e
475 | Integer ten = new Integer(10);
476 | Object optionPaneBorder = new SwingLazyValue(
477 | "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
478 | - new Object[] {ten, ten, twelve, ten});
479 | + new Object[] {ten, ten, fontSize, ten});
480 |
481 | Object optionPaneButtonAreaBorder = new SwingLazyValue(
482 | "javax.swing.plaf.BorderUIResource$EmptyBorderUIResource",
483 | @@ -760,7 +762,7 @@ public abstract class BasicLookAndFeel e
484 |
485 | // *** Buttons
486 | "Button.defaultButtonFollowsFocus", Boolean.TRUE,
487 | - "Button.font", dialogPlain12,
488 | + "Button.font", dialogPlain,
489 | "Button.background", control,
490 | "Button.foreground", controlText,
491 | "Button.shadow", controlShadow,
492 | @@ -778,7 +780,7 @@ public abstract class BasicLookAndFeel e
493 | "released ENTER", "released"
494 | }),
495 |
496 | - "ToggleButton.font", dialogPlain12,
497 | + "ToggleButton.font", dialogPlain,
498 | "ToggleButton.background", control,
499 | "ToggleButton.foreground", controlText,
500 | "ToggleButton.shadow", controlShadow,
501 | @@ -795,7 +797,7 @@ public abstract class BasicLookAndFeel e
502 | "released SPACE", "released"
503 | }),
504 |
505 | - "RadioButton.font", dialogPlain12,
506 | + "RadioButton.font", dialogPlain,
507 | "RadioButton.background", control,
508 | "RadioButton.foreground", controlText,
509 | "RadioButton.shadow", controlShadow,
510 | @@ -814,7 +816,7 @@ public abstract class BasicLookAndFeel e
511 | "RETURN", "pressed"
512 | }),
513 |
514 | - "CheckBox.font", dialogPlain12,
515 | + "CheckBox.font", dialogPlain,
516 | "CheckBox.background", control,
517 | "CheckBox.foreground", controlText,
518 | "CheckBox.border", radioButtonBorder,
519 | @@ -830,7 +832,7 @@ public abstract class BasicLookAndFeel e
520 | "FileChooser.useSystemExtensionHiding", Boolean.FALSE,
521 |
522 | // *** ColorChooser
523 | - "ColorChooser.font", dialogPlain12,
524 | + "ColorChooser.font", dialogPlain,
525 | "ColorChooser.background", control,
526 | "ColorChooser.foreground", controlText,
527 |
528 | @@ -839,7 +841,7 @@ public abstract class BasicLookAndFeel e
529 | "ColorChooser.swatchesDefaultRecentColor", control,
530 |
531 | // *** ComboBox
532 | - "ComboBox.font", sansSerifPlain12,
533 | + "ComboBox.font", sansSerifPlain,
534 | "ComboBox.background", window,
535 | "ComboBox.foreground", textText,
536 | "ComboBox.buttonBackground", control,
537 | @@ -885,7 +887,7 @@ public abstract class BasicLookAndFeel e
538 | "FileView.floppyDriveIcon", floppyDriveIcon,
539 |
540 | // *** InternalFrame
541 | - "InternalFrame.titleFont", dialogBold12,
542 | + "InternalFrame.titleFont", dialogBold,
543 | "InternalFrame.borderColor", control,
544 | "InternalFrame.borderShadow", controlShadow,
545 | "InternalFrame.borderDarkShadow", controlDkShadow,
546 | @@ -971,7 +973,7 @@ public abstract class BasicLookAndFeel e
547 | }),
548 |
549 | // *** Label
550 | - "Label.font", dialogPlain12,
551 | + "Label.font", dialogPlain,
552 | "Label.background", control,
553 | "Label.foreground", controlText,
554 | "Label.disabledForeground", white,
555 | @@ -979,7 +981,7 @@ public abstract class BasicLookAndFeel e
556 | "Label.border", null,
557 |
558 | // *** List
559 | - "List.font", dialogPlain12,
560 | + "List.font", dialogPlain,
561 | "List.background", window,
562 | "List.foreground", textText,
563 | "List.selectionBackground", textHighlight,
564 | @@ -1078,7 +1080,7 @@ public abstract class BasicLookAndFeel e
565 | }),
566 |
567 | // *** Menus
568 | - "MenuBar.font", dialogPlain12,
569 | + "MenuBar.font", dialogPlain,
570 | "MenuBar.background", menu,
571 | "MenuBar.foreground", menuText,
572 | "MenuBar.shadow", controlShadow,
573 | @@ -1087,8 +1089,8 @@ public abstract class BasicLookAndFeel e
574 | "MenuBar.windowBindings", new Object[] {
575 | "F10", "takeFocus" },
576 |
577 | - "MenuItem.font", dialogPlain12,
578 | - "MenuItem.acceleratorFont", dialogPlain12,
579 | + "MenuItem.font", dialogPlain,
580 | + "MenuItem.acceleratorFont", dialogPlain,
581 | "MenuItem.background", menu,
582 | "MenuItem.foreground", menuText,
583 | "MenuItem.selectionForeground", textHighlightText,
584 | @@ -1104,8 +1106,8 @@ public abstract class BasicLookAndFeel e
585 | "MenuItem.arrowIcon", menuItemArrowIcon,
586 | "MenuItem.commandSound", null,
587 |
588 | - "RadioButtonMenuItem.font", dialogPlain12,
589 | - "RadioButtonMenuItem.acceleratorFont", dialogPlain12,
590 | + "RadioButtonMenuItem.font", dialogPlain,
591 | + "RadioButtonMenuItem.acceleratorFont", dialogPlain,
592 | "RadioButtonMenuItem.background", menu,
593 | "RadioButtonMenuItem.foreground", menuText,
594 | "RadioButtonMenuItem.selectionForeground", textHighlightText,
595 | @@ -1120,8 +1122,8 @@ public abstract class BasicLookAndFeel e
596 | "RadioButtonMenuItem.arrowIcon", menuItemArrowIcon,
597 | "RadioButtonMenuItem.commandSound", null,
598 |
599 | - "CheckBoxMenuItem.font", dialogPlain12,
600 | - "CheckBoxMenuItem.acceleratorFont", dialogPlain12,
601 | + "CheckBoxMenuItem.font", dialogPlain,
602 | + "CheckBoxMenuItem.acceleratorFont", dialogPlain,
603 | "CheckBoxMenuItem.background", menu,
604 | "CheckBoxMenuItem.foreground", menuText,
605 | "CheckBoxMenuItem.selectionForeground", textHighlightText,
606 | @@ -1136,8 +1138,8 @@ public abstract class BasicLookAndFeel e
607 | "CheckBoxMenuItem.arrowIcon", menuItemArrowIcon,
608 | "CheckBoxMenuItem.commandSound", null,
609 |
610 | - "Menu.font", dialogPlain12,
611 | - "Menu.acceleratorFont", dialogPlain12,
612 | + "Menu.font", dialogPlain,
613 | + "Menu.acceleratorFont", dialogPlain,
614 | "Menu.background", menu,
615 | "Menu.foreground", menuText,
616 | "Menu.selectionForeground", textHighlightText,
617 | @@ -1176,7 +1178,7 @@ public abstract class BasicLookAndFeel e
618 | "Menu.preserveTopLevelSelection", Boolean.FALSE,
619 |
620 | // PopupMenu
621 | - "PopupMenu.font", dialogPlain12,
622 | + "PopupMenu.font", dialogPlain,
623 | "PopupMenu.background", menu,
624 | "PopupMenu.foreground", menuText,
625 | "PopupMenu.border", popupMenuBorder,
626 | @@ -1210,7 +1212,7 @@ public abstract class BasicLookAndFeel e
627 | // You can additionaly define OptionPane.messageFont which will
628 | // dictate the fonts used for the message, and
629 | // OptionPane.buttonFont, which defines the font for the buttons.
630 | - "OptionPane.font", dialogPlain12,
631 | + "OptionPane.font", dialogPlain,
632 | "OptionPane.background", control,
633 | "OptionPane.foreground", controlText,
634 | "OptionPane.messageForeground", controlText,
635 | @@ -1240,12 +1242,12 @@ public abstract class BasicLookAndFeel e
636 | "OptionPane.buttonClickThreshhold", fiveHundred,
637 |
638 | // *** Panel
639 | - "Panel.font", dialogPlain12,
640 | + "Panel.font", dialogPlain,
641 | "Panel.background", control,
642 | "Panel.foreground", textText,
643 |
644 | // *** ProgressBar
645 | - "ProgressBar.font", dialogPlain12,
646 | + "ProgressBar.font", dialogPlain,
647 | "ProgressBar.foreground", textHighlight,
648 | "ProgressBar.background", control,
649 | "ProgressBar.selectionForeground", control,
650 | @@ -1301,7 +1303,7 @@ public abstract class BasicLookAndFeel e
651 | }),
652 | "ScrollBar.width", new Integer(16),
653 |
654 | - "ScrollPane.font", dialogPlain12,
655 | + "ScrollPane.font", dialogPlain,
656 | "ScrollPane.background", control,
657 | "ScrollPane.foreground", controlText,
658 | "ScrollPane.border", textFieldBorder,
659 | @@ -1329,12 +1331,12 @@ public abstract class BasicLookAndFeel e
660 | "ctrl PAGE_DOWN", "scrollLeft",
661 | }),
662 |
663 | - "Viewport.font", dialogPlain12,
664 | + "Viewport.font", dialogPlain,
665 | "Viewport.background", control,
666 | "Viewport.foreground", textText,
667 |
668 | // *** Slider
669 | - "Slider.font", dialogPlain12,
670 | + "Slider.font", dialogPlain,
671 | "Slider.foreground", control,
672 | "Slider.background", control,
673 | "Slider.highlight", controlLtHighlight,
674 | @@ -1372,7 +1374,7 @@ public abstract class BasicLookAndFeel e
675 | "Slider.onlyLeftMouseButtonDrag", Boolean.TRUE,
676 |
677 | // *** Spinner
678 | - "Spinner.font", monospacedPlain12,
679 | + "Spinner.font", monospacedPlain,
680 | "Spinner.background", control,
681 | "Spinner.foreground", control,
682 | "Spinner.border", textFieldBorder,
683 | @@ -1417,7 +1419,7 @@ public abstract class BasicLookAndFeel e
684 | }),
685 |
686 | // *** TabbedPane
687 | - "TabbedPane.font", dialogPlain12,
688 | + "TabbedPane.font", dialogPlain,
689 | "TabbedPane.background", control,
690 | "TabbedPane.foreground", controlText,
691 | "TabbedPane.highlight", controlLtHighlight,
692 | @@ -1466,7 +1468,7 @@ public abstract class BasicLookAndFeel e
693 |
694 |
695 | // *** Table
696 | - "Table.font", dialogPlain12,
697 | + "Table.font", dialogPlain,
698 | "Table.foreground", controlText, // cell text color
699 | "Table.background", window, // cell background color
700 | "Table.selectionForeground", textHighlightText,
701 | @@ -1585,7 +1587,7 @@ public abstract class BasicLookAndFeel e
702 | "Table.sortIconColor" }),
703 | "Table.sortIconColor", controlShadow,
704 |
705 | - "TableHeader.font", dialogPlain12,
706 | + "TableHeader.font", dialogPlain,
707 | "TableHeader.foreground", controlText, // header text color
708 | "TableHeader.background", control, // header background
709 | "TableHeader.cellBorder", tableHeaderBorder,
710 | @@ -1614,7 +1616,7 @@ public abstract class BasicLookAndFeel e
711 | }),
712 |
713 | // *** Text
714 | - "TextField.font", sansSerifPlain12,
715 | + "TextField.font", sansSerifPlain,
716 | "TextField.background", window,
717 | "TextField.foreground", textText,
718 | "TextField.shadow", controlShadow,
719 | @@ -1630,7 +1632,7 @@ public abstract class BasicLookAndFeel e
720 | "TextField.border", textFieldBorder,
721 | "TextField.margin", zeroInsets,
722 |
723 | - "FormattedTextField.font", sansSerifPlain12,
724 | + "FormattedTextField.font", sansSerifPlain,
725 | "FormattedTextField.background", window,
726 | "FormattedTextField.foreground", textText,
727 | "FormattedTextField.inactiveForeground", textInactiveText,
728 | @@ -1689,7 +1691,7 @@ public abstract class BasicLookAndFeel e
729 | "KP_DOWN", "decrement",
730 | }),
731 |
732 | - "PasswordField.font", monospacedPlain12,
733 | + "PasswordField.font", monospacedPlain,
734 | "PasswordField.background", window,
735 | "PasswordField.foreground", textText,
736 | "PasswordField.inactiveForeground", textInactiveText,
737 | @@ -1702,7 +1704,7 @@ public abstract class BasicLookAndFeel e
738 | "PasswordField.margin", zeroInsets,
739 | "PasswordField.echoChar", '*',
740 |
741 | - "TextArea.font", monospacedPlain12,
742 | + "TextArea.font", monospacedPlain,
743 | "TextArea.background", window,
744 | "TextArea.foreground", textText,
745 | "TextArea.inactiveForeground", textInactiveText,
746 | @@ -1713,7 +1715,7 @@ public abstract class BasicLookAndFeel e
747 | "TextArea.border", marginBorder,
748 | "TextArea.margin", zeroInsets,
749 |
750 | - "TextPane.font", serifPlain12,
751 | + "TextPane.font", serifPlain,
752 | "TextPane.background", white,
753 | "TextPane.foreground", textText,
754 | "TextPane.selectionBackground", textHighlight,
755 | @@ -1724,7 +1726,7 @@ public abstract class BasicLookAndFeel e
756 | "TextPane.border", marginBorder,
757 | "TextPane.margin", editorMargin,
758 |
759 | - "EditorPane.font", serifPlain12,
760 | + "EditorPane.font", serifPlain,
761 | "EditorPane.background", white,
762 | "EditorPane.foreground", textText,
763 | "EditorPane.selectionBackground", textHighlight,
764 | @@ -1742,12 +1744,12 @@ public abstract class BasicLookAndFeel e
765 | BasicLookAndFeel.class,
766 | "icons/image-failed.png"),
767 | // *** TitledBorder
768 | - "TitledBorder.font", dialogPlain12,
769 | + "TitledBorder.font", dialogPlain,
770 | "TitledBorder.titleColor", controlText,
771 | "TitledBorder.border", etchedBorder,
772 |
773 | // *** ToolBar
774 | - "ToolBar.font", dialogPlain12,
775 | + "ToolBar.font", dialogPlain,
776 | "ToolBar.background", control,
777 | "ToolBar.foreground", controlText,
778 | "ToolBar.shadow", controlShadow,
779 | @@ -1773,7 +1775,7 @@ public abstract class BasicLookAndFeel e
780 | }),
781 |
782 | // *** ToolTips
783 | - "ToolTip.font", sansSerifPlain12,
784 | + "ToolTip.font", sansSerifPlain,
785 | "ToolTip.background", table.get("info"),
786 | "ToolTip.foreground", table.get("infoText"),
787 | "ToolTip.border", blackLineBorder,
788 | @@ -1793,7 +1795,7 @@ public abstract class BasicLookAndFeel e
789 | // *** Tree
790 | "Tree.paintLines", Boolean.TRUE,
791 | "Tree.lineTypeDashed", Boolean.FALSE,
792 | - "Tree.font", dialogPlain12,
793 | + "Tree.font", dialogPlain,
794 | "Tree.background", window,
795 | "Tree.foreground", textText,
796 | "Tree.hash", gray,
797 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java
798 | ===================================================================
799 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java
800 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java
801 | @@ -89,106 +89,29 @@ import sun.swing.SwingUtilities2;
802 | * @author Steve Wilson
803 | */
804 | public class DefaultMetalTheme extends MetalTheme {
805 | - /**
806 | - * Whether or not fonts should be plain. This is only used if
807 | - * the defaults property 'swing.boldMetal' == "false".
808 | - */
809 | - private static final boolean PLAIN_FONTS;
810 | -
811 | - /**
812 | - * Names of the fonts to use.
813 | - */
814 | - private static final String[] fontNames = {
815 | - Font.DIALOG,Font.DIALOG,Font.DIALOG,Font.DIALOG,Font.DIALOG,Font.DIALOG
816 | - };
817 | - /**
818 | - * Styles for the fonts. This is ignored if the defaults property
819 | - * swing.boldMetal
is false, or PLAIN_FONTS is true.
820 | - */
821 | - private static final int[] fontStyles = {
822 | - Font.BOLD, Font.PLAIN, Font.PLAIN, Font.BOLD, Font.BOLD, Font.PLAIN
823 | - };
824 | - /**
825 | - * Sizes for the fonts.
826 | - */
827 | - private static final int[] fontSizes = {
828 | - 12, 12, 12, 12, 12, 10
829 | - };
830 | -
831 | - // note the properties listed here can currently be used by people
832 | - // providing runtimes to hint what fonts are good. For example the bold
833 | - // dialog font looks bad on a Mac, so Apple could use this property to
834 | - // hint at a good font.
835 | - //
836 | - // However, we don't promise to support these forever. We may move
837 | - // to getting these from the swing.properties file, or elsewhere.
838 | - /**
839 | - * System property names used to look up fonts.
840 | - */
841 | - private static final String[] defaultNames = {
842 | - "swing.plaf.metal.controlFont",
843 | - "swing.plaf.metal.systemFont",
844 | - "swing.plaf.metal.userFont",
845 | - "swing.plaf.metal.controlFont",
846 | - "swing.plaf.metal.controlFont",
847 | - "swing.plaf.metal.smallFont"
848 | - };
849 |
850 | /**
851 | * Returns the ideal font name for the font identified by key.
852 | */
853 | static String getDefaultFontName(int key) {
854 | - return fontNames[key];
855 | + return LazyDefaultFonts.defaultFont.getFamily();
856 | }
857 |
858 | /**
859 | * Returns the ideal font size for the font identified by key.
860 | */
861 | static int getDefaultFontSize(int key) {
862 | - return fontSizes[key];
863 | + if (key == SUB_TEXT_FONT) {
864 | + return LazyDefaultFonts.smallFont.getSize();
865 | + }
866 | + return LazyDefaultFonts.defaultFont.getSize();
867 | }
868 |
869 | /**
870 | * Returns the ideal font style for the font identified by key.
871 | */
872 | static int getDefaultFontStyle(int key) {
873 | - if (key != WINDOW_TITLE_FONT) {
874 | - Object boldMetal = null;
875 | - if (AppContext.getAppContext().get(
876 | - SwingUtilities2.LAF_STATE_KEY) != null) {
877 | - // Only access the boldMetal key if a look and feel has
878 | - // been loaded, otherwise we'll trigger loading the look
879 | - // and feel.
880 | - boldMetal = UIManager.get("swing.boldMetal");
881 | - }
882 | - if (boldMetal != null) {
883 | - if (Boolean.FALSE.equals(boldMetal)) {
884 | - return Font.PLAIN;
885 | - }
886 | - }
887 | - else if (PLAIN_FONTS) {
888 | - return Font.PLAIN;
889 | - }
890 | - }
891 | - return fontStyles[key];
892 | - }
893 | -
894 | - /**
895 | - * Returns the default used to look up the specified font.
896 | - */
897 | - static String getDefaultPropertyName(int key) {
898 | - return defaultNames[key];
899 | - }
900 | -
901 | - static {
902 | - Object boldProperty = java.security.AccessController.doPrivileged(
903 | - new GetPropertyAction("swing.boldMetal"));
904 | - if (boldProperty == null || !"false".equals(boldProperty)) {
905 | - PLAIN_FONTS = false;
906 | - }
907 | - else {
908 | - PLAIN_FONTS = true;
909 | - }
910 | + return LazyDefaultFonts.defaultFont.getStyle();
911 | }
912 |
913 | private static final ColorUIResource primary1 = new ColorUIResource(
914 | @@ -204,8 +127,6 @@ public class DefaultMetalTheme extends M
915 | private static final ColorUIResource secondary3 = new ColorUIResource(
916 | 204, 204, 204);
917 |
918 | - private FontDelegate fontDelegate;
919 | -
920 | /**
921 | * Returns the name of this theme. This returns {@code "Steel"}.
922 | *
923 | @@ -330,17 +251,13 @@ public class DefaultMetalTheme extends M
924 | }
925 |
926 | private FontUIResource getFont(int key) {
927 | - return fontDelegate.getFont(key);
928 | + if (key == SUB_TEXT_FONT) {
929 | + return LazyDefaultFonts.smallFont;
930 | + }
931 | + return LazyDefaultFonts.defaultFont;
932 | }
933 |
934 | void install() {
935 | - if (MetalLookAndFeel.isWindows() &&
936 | - MetalLookAndFeel.useSystemFonts()) {
937 | - fontDelegate = new WindowsFontDelegate();
938 | - }
939 | - else {
940 | - fontDelegate = new FontDelegate();
941 | - }
942 | }
943 |
944 | /**
945 | @@ -351,83 +268,23 @@ public class DefaultMetalTheme extends M
946 | }
947 |
948 | /**
949 | - * FontDelegates add an extra level of indirection to obtaining fonts.
950 | - */
951 | - private static class FontDelegate {
952 | - private static int[] defaultMapping = {
953 | - CONTROL_TEXT_FONT, SYSTEM_TEXT_FONT,
954 | - USER_TEXT_FONT, CONTROL_TEXT_FONT,
955 | - CONTROL_TEXT_FONT, SUB_TEXT_FONT
956 | - };
957 | - FontUIResource fonts[];
958 | -
959 | - // menu and window are mapped to controlFont
960 | - public FontDelegate() {
961 | - fonts = new FontUIResource[6];
962 | - }
963 | -
964 | - public FontUIResource getFont(int type) {
965 | - int mappedType = defaultMapping[type];
966 | - if (fonts[type] == null) {
967 | - Font f = getPrivilegedFont(mappedType);
968 | -
969 | - if (f == null) {
970 | - f = new Font(getDefaultFontName(type),
971 | - getDefaultFontStyle(type),
972 | - getDefaultFontSize(type));
973 | - }
974 | - fonts[type] = new FontUIResource(f);
975 | - }
976 | - return fonts[type];
977 | - }
978 | -
979 | - /**
980 | - * This is the same as invoking
981 | - * Font.getFont(key)
, with the exception
982 | - * that it is wrapped inside a doPrivileged
call.
983 | - */
984 | - protected Font getPrivilegedFont(final int key) {
985 | - return java.security.AccessController.doPrivileged(
986 | - new java.security.PrivilegedAction() {
987 | - public Font run() {
988 | - return Font.getFont(getDefaultPropertyName(key));
989 | - }
990 | - }
991 | - );
992 | - }
993 | - }
994 | -
995 | - /**
996 | - * The WindowsFontDelegate uses DesktopProperties to obtain fonts.
997 | + * Guarantee lazyness of font initialization. We don't want to waste the memory
998 | + * if user will never use those fonts.
999 | */
1000 | - private static class WindowsFontDelegate extends FontDelegate {
1001 | - private MetalFontDesktopProperty[] props;
1002 | - private boolean[] checkedPriviledged;
1003 | -
1004 | - public WindowsFontDelegate() {
1005 | - props = new MetalFontDesktopProperty[6];
1006 | - checkedPriviledged = new boolean[6];
1007 | - }
1008 | -
1009 | - public FontUIResource getFont(int type) {
1010 | - if (fonts[type] != null) {
1011 | - return fonts[type];
1012 | - }
1013 | - if (!checkedPriviledged[type]) {
1014 | - Font f = getPrivilegedFont(type);
1015 | -
1016 | - checkedPriviledged[type] = true;
1017 | - if (f != null) {
1018 | - fonts[type] = new FontUIResource(f);
1019 | - return fonts[type];
1020 | - }
1021 | - }
1022 | - if (props[type] == null) {
1023 | - props[type] = new MetalFontDesktopProperty(type);
1024 | - }
1025 | - // While passing null may seem bad, we don't actually use
1026 | - // the table and looking it up is rather expensive.
1027 | - return (FontUIResource)props[type].createValue(null);
1028 | + private static class LazyDefaultFonts {
1029 | + private static FontUIResource defaultFont;
1030 | + private static FontUIResource smallFont;
1031 | + static {
1032 | + Font f;
1033 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
1034 | + if (o instanceof Font) { // implicit null check
1035 | + f = (Font) o;
1036 | + } else {
1037 | + f = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
1038 | + }
1039 | + // 90% of size will be small font:
1040 | + defaultFont = new FontUIResource(f);
1041 | + smallFont = new FontUIResource(f.getFamily(), f.getStyle(), (f.getSize() * 9 / 10));
1042 | }
1043 | }
1044 | }
1045 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
1046 | ===================================================================
1047 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
1048 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template
1049 | @@ -46,6 +46,7 @@ import java.awt.Dimension;
1050 | import java.awt.Font;
1051 | import java.awt.Graphics2D;
1052 | import java.awt.Insets;
1053 | +import java.awt.Toolkit;
1054 | import java.awt.image.BufferedImage;
1055 | import static java.awt.image.BufferedImage.*;
1056 | import java.beans.PropertyChangeEvent;
1057 | @@ -124,6 +125,15 @@ final class ${LAF_NAME}Defaults {
1058 | UIManager.getDefaults().removePropertyChangeListener(colorTree);
1059 | }
1060 |
1061 | + private FontUIResource defaultFont() {
1062 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
1063 | + if (o instanceof Font) { // implicit null check
1064 | + Font f = (Font) o;
1065 | + return FontUtilities.getFontConfigFUIR(f.getFamily(), f.getStyle(), f.getSize());
1066 | + }
1067 | + return FontUtilities.getFontConfigFUIR(Font.SANS_SERIF, Font.PLAIN, 9);
1068 | + }
1069 | +
1070 | /**
1071 | * Create a new ${LAF_NAME}Defaults. This constructor is only called from
1072 | * within ${LAF_NAME}LookAndFeel.
1073 | @@ -135,7 +145,7 @@ final class ${LAF_NAME}Defaults {
1074 | //regions and their states that this class will use for later lookup.
1075 | //Additional regions can be registered later by 3rd party components.
1076 | //These are simply the default registrations.
1077 | - defaultFont = FontUtilities.getFontConfigFUIR("sans", Font.PLAIN, 12);
1078 | + defaultFont = defaultFont();
1079 | defaultStyle = new DefaultSynthStyle();
1080 | defaultStyle.setFont(defaultFont);
1081 |
1082 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java
1083 | ===================================================================
1084 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java
1085 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/text/html/StyleSheet.java
1086 | @@ -881,7 +881,7 @@ public class StyleSheet extends StyleCon
1087 | * Fetches the font to use for the given set of attributes.
1088 | */
1089 | public Font getFont(AttributeSet a) {
1090 | - return css.getFont(this, a, 12, this);
1091 | + return css.getFont(this, a, UIManager.getInt("ui.defaultFont.size"), this);
1092 | }
1093 |
1094 | /**
1095 | @@ -2467,19 +2467,20 @@ public class StyleSheet extends StyleCon
1096 | CSS.BackgroundPosition pos = (CSS.BackgroundPosition)a.getAttribute
1097 | (CSS.Attribute.BACKGROUND_POSITION);
1098 | if (pos != null) {
1099 | + int defaultFontSize = UIManager.getInt("ui.defaultFont.size");
1100 | hPosition = pos.getHorizontalPosition();
1101 | vPosition = pos.getVerticalPosition();
1102 | if (pos.isHorizontalPositionRelativeToSize()) {
1103 | flags |= 4;
1104 | }
1105 | else if (pos.isHorizontalPositionRelativeToSize()) {
1106 | - hPosition *= css.getFontSize(a, 12, ss);
1107 | + hPosition *= css.getFontSize(a, defaultFontSize, ss);
1108 | }
1109 | if (pos.isVerticalPositionRelativeToSize()) {
1110 | flags |= 8;
1111 | }
1112 | else if (pos.isVerticalPositionRelativeToFontSize()) {
1113 | - vPosition *= css.getFontSize(a, 12, ss);
1114 | + vPosition *= css.getFontSize(a, defaultFontSize, ss);
1115 | }
1116 | }
1117 | // Determine any repeating values.
1118 | @@ -3331,7 +3332,7 @@ public class StyleSheet extends StyleCon
1119 | * The HTML/CSS size model has seven slots
1120 | * that one can assign sizes to.
1121 | */
1122 | - static final int sizeMapDefault[] = { 8, 10, 12, 14, 18, 24, 36 };
1123 | + static final int sizeMapDefault[] = { 4, 6, 7, 9, 11, 14, 20 };
1124 |
1125 | private int sizeMap[] = sizeMapDefault;
1126 | private boolean w3cLengthUnits = false;
1127 | Index: jdk8u152-b16/jdk/src/share/classes/javax/swing/text/html/default.css
1128 | ===================================================================
1129 | --- jdk8u152-b16.orig/jdk/src/share/classes/javax/swing/text/html/default.css
1130 | +++ jdk8u152-b16/jdk/src/share/classes/javax/swing/text/html/default.css
1131 | @@ -26,8 +26,8 @@
1132 | /*
1133 | */
1134 |
1135 | -body {font-size: 14pt;
1136 | - font-family: Serif;
1137 | +body {font-size: 9pt;
1138 | + font-family: sans-serif;
1139 | font-weight: normal;
1140 | margin-left: 0;
1141 | margin-right: 0;
1142 | @@ -174,12 +174,12 @@ big {font-size: x-large}
1143 | small {font-size: x-small}
1144 |
1145 | samp {font-size: small;
1146 | - font-family: Monospaced}
1147 | + font-family: monospace}
1148 |
1149 | cite {font-style: italic}
1150 |
1151 | code {font-size: small;
1152 | - font-family: Monospaced}
1153 | + font-family: monospace}
1154 |
1155 | dfn {font-style: italic}
1156 |
1157 | @@ -190,7 +190,7 @@ i {font-style: italic}
1158 | b {font-weight: bold}
1159 |
1160 | kbd {font-size: small;
1161 | - font-family: Monospaced}
1162 | + font-family: monospace}
1163 |
1164 | s {text-decoration: line-through}
1165 |
1166 | @@ -254,7 +254,7 @@ center {text-align: center}
1167 |
1168 | pre {margin-top: 5;
1169 | margin-bottom: 5;
1170 | - font-family: Monospaced}
1171 | + font-family: monospace}
1172 |
1173 | pre p {margin-top: 0}
1174 |
1175 | Index: jdk8u152-b16/jdk/src/share/classes/sun/awt/SunHints.java
1176 | ===================================================================
1177 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/awt/SunHints.java
1178 | +++ jdk8u152-b16/jdk/src/share/classes/sun/awt/SunHints.java
1179 | @@ -113,6 +113,11 @@ public class SunHints {
1180 | }
1181 |
1182 | public static Value get(int keyindex, int valueindex) {
1183 | + // array is initialized by accessing RenderingHints,
1184 | + // but it is possible that no one did it before us,
1185 | + // to prevent empty array here we have to touch RenderingHints
1186 | + // ourselves:
1187 | +// RenderingHints.Key key = RenderingHints.KEY_TEXT_ANTIALIASING;
1188 | return ValueObjects[keyindex][valueindex];
1189 | }
1190 |
1191 | Index: jdk8u152-b16/jdk/src/share/classes/sun/awt/image/OffScreenImage.java
1192 | ===================================================================
1193 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/awt/image/OffScreenImage.java
1194 | +++ jdk8u152-b16/jdk/src/share/classes/sun/awt/image/OffScreenImage.java
1195 | @@ -32,6 +32,7 @@ import java.awt.Font;
1196 | import java.awt.Graphics;
1197 | import java.awt.Graphics2D;
1198 | import java.awt.GraphicsEnvironment;
1199 | +import java.awt.Toolkit;
1200 | import java.awt.image.BufferedImage;
1201 | import java.awt.image.ImageProducer;
1202 | import java.awt.image.ColorModel;
1203 | @@ -88,7 +89,12 @@ public class OffScreenImage extends Buff
1204 | Font font = c.getFont();
1205 | if (font == null) {
1206 | if (defaultFont == null) {
1207 | - defaultFont = new Font("Dialog", Font.PLAIN, 12);
1208 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
1209 | + if (o instanceof Font) { // implicit null check
1210 | + defaultFont = (Font)o;
1211 | + } else {
1212 | + defaultFont = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
1213 | + }
1214 | }
1215 | font = defaultFont;
1216 | }
1217 | Index: jdk8u152-b16/jdk/src/share/classes/sun/awt/image/SunVolatileImage.java
1218 | ===================================================================
1219 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/awt/image/SunVolatileImage.java
1220 | +++ jdk8u152-b16/jdk/src/share/classes/sun/awt/image/SunVolatileImage.java
1221 | @@ -32,6 +32,7 @@ import java.awt.Font;
1222 | import java.awt.Graphics2D;
1223 | import java.awt.GraphicsConfiguration;
1224 | import java.awt.ImageCapabilities;
1225 | +import java.awt.Toolkit;
1226 | import java.awt.Transparency;
1227 | import java.awt.image.BufferedImage;
1228 | import java.awt.image.ImageObserver;
1229 | @@ -40,6 +41,7 @@ import sun.java2d.SunGraphics2D;
1230 | import sun.java2d.SurfaceManagerFactory;
1231 | import sun.java2d.DestSurfaceProvider;
1232 | import sun.java2d.Surface;
1233 | +
1234 | import static sun.java2d.pipe.hw.AccelSurface.*;
1235 |
1236 | /**
1237 | @@ -203,7 +205,12 @@ public class SunVolatileImage extends Vo
1238 | return comp.getFont();
1239 | } else {
1240 | if (defaultFont == null) {
1241 | - defaultFont = new Font("Dialog", Font.PLAIN, 12);
1242 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
1243 | + if (o instanceof Font) { // implicit null check
1244 | + defaultFont = (Font)o;
1245 | + } else {
1246 | + defaultFont = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
1247 | + }
1248 | }
1249 | return defaultFont;
1250 | }
1251 | Index: jdk8u152-b16/jdk/src/share/classes/sun/font/FreetypeFontScaler.java
1252 | ===================================================================
1253 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/font/FreetypeFontScaler.java
1254 | +++ jdk8u152-b16/jdk/src/share/classes/sun/font/FreetypeFontScaler.java
1255 | @@ -24,12 +24,12 @@
1256 | */
1257 |
1258 | package sun.font;
1259 | -
1260 | +import java.awt.geom.AffineTransform;
1261 | +import java.awt.GraphicsEnvironment;
1262 | import java.awt.geom.GeneralPath;
1263 | import java.awt.geom.Point2D;
1264 | import java.awt.geom.Rectangle2D;
1265 | import java.lang.ref.WeakReference;
1266 | -
1267 | /* This is Freetype based implementation of FontScaler.
1268 | *
1269 | * Note that in case of runtime error it is expected that
1270 | @@ -214,8 +214,14 @@ class FreetypeFontScaler extends FontSca
1271 | int aa, int fm, float boldness, float italic,
1272 | boolean disableHinting) {
1273 | if (nativeScaler != 0L) {
1274 | + double ptToPxScale = 1.0d;
1275 | + GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
1276 | + if (!graphicsEnvironment.isHeadlessInstance()) {
1277 | + AffineTransform normalizingTransform = graphicsEnvironment.getDefaultScreenDevice().getDefaultConfiguration().getNormalizingTransform();
1278 | + ptToPxScale = normalizingTransform.getScaleY();
1279 | + }
1280 | return createScalerContextNative(nativeScaler, matrix,
1281 | - aa, fm, boldness, italic);
1282 | + aa, fm, boldness, italic, ptToPxScale);
1283 | }
1284 | return NullFontScaler.getNullScalerContext();
1285 | }
1286 | @@ -254,7 +260,7 @@ class FreetypeFontScaler extends FontSca
1287 | private native long getUnitsPerEMNative(long pScaler);
1288 |
1289 | native long createScalerContextNative(long pScaler, double[] matrix,
1290 | - int aa, int fm, float boldness, float italic);
1291 | + int aa, int fm, float boldness, float italic, double ptToPxScale);
1292 |
1293 | /* Freetype scaler context does not contain any pointers that
1294 | has to be invalidated if native scaler is bad */
1295 | Index: jdk8u152-b16/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
1296 | ===================================================================
1297 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
1298 | +++ jdk8u152-b16/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
1299 | @@ -210,8 +210,6 @@ public final class SunGraphics2D
1300 |
1301 | protected static final Stroke defaultStroke = new BasicStroke();
1302 | protected static final Composite defaultComposite = AlphaComposite.SrcOver;
1303 | - private static final Font defaultFont =
1304 | - new Font(Font.DIALOG, Font.PLAIN, 12);
1305 |
1306 | public Paint paint;
1307 | public Stroke stroke;
1308 | @@ -278,7 +276,7 @@ public final class SunGraphics2D
1309 |
1310 | renderHint = SunHints.INTVAL_RENDER_DEFAULT;
1311 | antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
1312 | - textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
1313 | + textAntialiasHint = SunGraphicsEnvironment.LazyDefaults.textAntialiasingHintValue;
1314 | fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
1315 | lcdTextContrast = lcdTextContrastDefaultValue;
1316 | interpolationHint = -1;
1317 | @@ -297,7 +295,7 @@ public final class SunGraphics2D
1318 |
1319 | font = f;
1320 | if (font == null) {
1321 | - font = defaultFont;
1322 | + font = SunGraphicsEnvironment.LazyDefaults.font;
1323 | }
1324 |
1325 | setDevClip(sd.getBounds());
1326 | @@ -563,7 +561,7 @@ public final class SunGraphics2D
1327 |
1328 | public Font getFont() {
1329 | if (font == null) {
1330 | - font = defaultFont;
1331 | + font = SunGraphicsEnvironment.LazyDefaults.font;
1332 | }
1333 | return font;
1334 | }
1335 | @@ -1217,7 +1215,7 @@ public final class SunGraphics2D
1336 | if (stateChanged) {
1337 | textStateChanged =
1338 | (textAntialiasHint ==
1339 | - SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT);
1340 | + SunGraphicsEnvironment.LazyDefaults.textAntialiasingHintValue);
1341 | if (strokeState != STROKE_CUSTOM) {
1342 | validateBasicStroke((BasicStroke) stroke);
1343 | }
1344 | @@ -1354,7 +1352,7 @@ public final class SunGraphics2D
1345 | this.hints = null;
1346 | renderHint = SunHints.INTVAL_RENDER_DEFAULT;
1347 | antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF;
1348 | - textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
1349 | + textAntialiasHint = SunGraphicsEnvironment.LazyDefaults.textAntialiasingHintValue;
1350 | fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF;
1351 | lcdTextContrast = lcdTextContrastDefaultValue;
1352 | interpolationHint = -1;
1353 | Index: jdk8u152-b16/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java
1354 | ===================================================================
1355 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java
1356 | +++ jdk8u152-b16/jdk/src/share/classes/sun/java2d/SunGraphicsEnvironment.java
1357 | @@ -60,6 +60,7 @@ import sun.awt.AppContext;
1358 | import sun.awt.DisplayChangedListener;
1359 | import sun.awt.FontConfiguration;
1360 | import sun.awt.SunDisplayChanger;
1361 | +import sun.awt.SunHints;
1362 | import sun.font.CompositeFontDescriptor;
1363 | import sun.font.Font2D;
1364 | import sun.font.FontManager;
1365 | @@ -78,7 +79,31 @@ public abstract class SunGraphicsEnviron
1366 | implements DisplayChangedListener {
1367 |
1368 | public static boolean isOpenSolaris;
1369 | - private static Font defaultFont;
1370 | + static class LazyDefaults {
1371 | +
1372 | + static final Font font;
1373 | + static final Object textAntialiasingHint;
1374 | + static final int textAntialiasingHintValue;
1375 | +
1376 | + static {
1377 | + Toolkit toolkit = Toolkit.getDefaultToolkit();
1378 | + Object o = toolkit.getDesktopProperty("ui.defaultFont");
1379 | + if (o instanceof Font) { // implicit null check
1380 | + font = (Font) o;
1381 | + } else {
1382 | + font = new Font(Font.SANS_SERIF, Font.PLAIN, 9);
1383 | + }
1384 | + Object hint = toolkit.getDesktopProperty("ui.defaultFont.antialiasing");
1385 | + if (hint instanceof SunHints.Value) { // implicit null check
1386 | + SunHints.Value value = (SunHints.Value) hint;
1387 | + textAntialiasingHint = value;
1388 | + textAntialiasingHintValue = value.getIndex();
1389 | + } else {
1390 | + textAntialiasingHint = SunHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
1391 | + textAntialiasingHintValue = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT;
1392 | + }
1393 | + }
1394 | + }
1395 |
1396 | public SunGraphicsEnvironment() {
1397 | java.security.AccessController.doPrivileged(
1398 | @@ -118,9 +143,6 @@ public abstract class SunGraphicsEnviron
1399 | } catch (Exception e) {
1400 | }
1401 |
1402 | - /* Establish the default font to be used by SG2D etc */
1403 | - defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
1404 | -
1405 | return null;
1406 | }
1407 | });
1408 | @@ -183,7 +205,7 @@ public abstract class SunGraphicsEnviron
1409 | throw new NullPointerException("BufferedImage cannot be null");
1410 | }
1411 | SurfaceData sd = SurfaceData.getPrimarySurfaceData(img);
1412 | - return new SunGraphics2D(sd, Color.white, Color.black, defaultFont);
1413 | + return new SunGraphics2D(sd, Color.white, Color.black, LazyDefaults.font);
1414 | }
1415 |
1416 | public static FontManagerForSGE getFontManagerForSGE() {
1417 | Index: jdk8u152-b16/jdk/src/share/classes/sun/java2d/SurfaceData.java
1418 | ===================================================================
1419 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/java2d/SurfaceData.java
1420 | +++ jdk8u152-b16/jdk/src/share/classes/sun/java2d/SurfaceData.java
1421 | @@ -504,8 +504,7 @@ public abstract class SurfaceData
1422 | // For now the answer can only be true in the following cases:
1423 | if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
1424 | sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
1425 | - sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR &&
1426 | - sg2d.surfaceData.getTransparency() == Transparency.OPAQUE)
1427 | + sg2d.clipState <= SunGraphics2D.CLIP_RECTANGULAR)
1428 | {
1429 | if (haveLCDLoop == LOOP_UNKNOWN) {
1430 | DrawGlyphListLCD loop =
1431 | Index: jdk8u152-b16/jdk/src/share/classes/sun/java2d/loops/BlitBg.java
1432 | ===================================================================
1433 | --- jdk8u152-b16.orig/jdk/src/share/classes/sun/java2d/loops/BlitBg.java
1434 | +++ jdk8u152-b16/jdk/src/share/classes/sun/java2d/loops/BlitBg.java
1435 | @@ -29,6 +29,7 @@ import java.awt.Font;
1436 | import java.awt.Color;
1437 | import java.awt.Composite;
1438 | import java.awt.AlphaComposite;
1439 | +import java.awt.Toolkit;
1440 | import java.awt.Transparency;
1441 | import java.awt.image.ColorModel;
1442 | import java.awt.image.WritableRaster;
1443 | @@ -181,7 +182,14 @@ public class BlitBg extends GraphicsPrim
1444 | 0, 0, dstx, dsty, width, height);
1445 | }
1446 |
1447 | - private static Font defaultFont = new Font("Dialog", Font.PLAIN, 12);
1448 | + private static Font defaultFont = defaultFont();
1449 | + private static Font defaultFont() {
1450 | + Object o = Toolkit.getDefaultToolkit().getDesktopProperty("ui.defaultFont");
1451 | + if (o instanceof Font) { // implicit null check
1452 | + return (Font) o;
1453 | + }
1454 | + return new Font(Font.SANS_SERIF, Font.PLAIN, 9);
1455 | + }
1456 | }
1457 |
1458 | public GraphicsPrimitive traceWrap() {
1459 | Index: jdk8u152-b16/jdk/src/share/native/sun/font/freetypeScaler.c
1460 | ===================================================================
1461 | --- jdk8u152-b16.orig/jdk/src/share/native/sun/font/freetypeScaler.c
1462 | +++ jdk8u152-b16/jdk/src/share/native/sun/font/freetypeScaler.c
1463 | @@ -92,6 +92,7 @@ typedef struct FTScalerContext {
1464 | int renderFlags; /* configuration specific to particular engine */
1465 | int pathType;
1466 | int ptsz; /* size in points */
1467 | + int dpi; /* screen dpi */
1468 | RenderingProperties* renderingProperties;
1469 | } FTScalerContext;
1470 |
1471 | @@ -487,7 +488,7 @@ static double euclidianDistance(double a
1472 | JNIEXPORT jlong JNICALL
1473 | Java_sun_font_FreetypeFontScaler_createScalerContextNative(
1474 | JNIEnv *env, jobject scaler, jlong pScaler, jdoubleArray matrix,
1475 | - jint aa, jint fm, jfloat boldness, jfloat italic) {
1476 | + jint aa, jint fm, jfloat boldness, jfloat italic, jdouble ptToPxScale) {
1477 | double dmat[4], ptsz;
1478 | FTScalerContext *context =
1479 | (FTScalerContext*) calloc(1, sizeof(FTScalerContext));
1480 | @@ -504,6 +505,11 @@ Java_sun_font_FreetypeFontScaler_createS
1481 | //text can not be smaller than 1 point
1482 | ptsz = 1.0;
1483 | }
1484 | +
1485 | + // because we operate with quite high numbers - no need to round up DPI:
1486 | + double dpi = 72.0 * ptToPxScale;
1487 | +
1488 | + context->dpi = (int)dpi;
1489 | context->ptsz = (int)(ptsz * 64);
1490 | context->transform.xx = FloatToFTFixed((float)dmat[0]/ptsz);
1491 | context->transform.yx = -FloatToFTFixed((float)dmat[1]/ptsz);
1492 | @@ -538,7 +544,12 @@ static int setupFTContext(JNIEnv *env,
1493 |
1494 | FT_Set_Transform(scalerInfo->face, &context->transform, NULL);
1495 |
1496 | - errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
1497 | + // we could use calculated pixel size for this,
1498 | + // but who knows if we guessed with rounding up,
1499 | + // so we will leave it up to freetype2 to decide the pixel size
1500 | + // based on DPI value:
1501 | + //errCode = FT_Set_Pixel_Sizes(scalerInfo->face, 0, context->pxsz);
1502 | + errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 0, context->dpi);
1503 |
1504 | if (errCode == 0) {
1505 | errCode = FT_Activate_Size(scalerInfo->face->size);
1506 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java
1507 | ===================================================================
1508 | --- jdk8u152-b16.orig/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java
1509 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java
1510 | @@ -257,7 +257,7 @@ public abstract class InfoWindow extends
1511 | private final static int BALLOON_ICON_HEIGHT = 32;
1512 | private final static int BALLOON_TRAY_ICON_INDENT = 0;
1513 | private final static Color BALLOON_CAPTION_BACKGROUND_COLOR = new Color(200, 200 ,255);
1514 | - private final static Font BALLOON_CAPTION_FONT = new Font(Font.DIALOG, Font.BOLD, 12);
1515 | + private final static Font BALLOON_CAPTION_FONT = new Font(FontDefaults.font.getFamily(), Font.BOLD, FontDefaults.font.getSize());
1516 |
1517 | private Panel mainPanel = new Panel();
1518 | private Panel captionPanel = new Panel();
1519 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XAWTLookAndFeel.java
1520 | ===================================================================
1521 | --- jdk8u152-b16.orig/jdk/src/solaris/classes/sun/awt/X11/XAWTLookAndFeel.java
1522 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XAWTLookAndFeel.java
1523 | @@ -85,12 +85,11 @@ class XAWTLookAndFeel extends MotifLookA
1524 | protected void initComponentDefaults(UIDefaults table) {
1525 | super.initComponentDefaults(table);
1526 |
1527 | - FontUIResource dialogPlain12 = new FontUIResource(Font.DIALOG,
1528 | - Font.PLAIN, 12);
1529 | - FontUIResource sansSerifPlain12 = new FontUIResource(Font.SANS_SERIF,
1530 | - Font.PLAIN, 12);
1531 | - FontUIResource monospacedPlain12 = new FontUIResource(Font.MONOSPACED,
1532 | - Font.PLAIN, 12);
1533 | + Font f = FontDefaults.font;
1534 | + FontUIResource dialogPlain = new FontUIResource(f);
1535 | + FontUIResource sansSerifPlain = dialogPlain;
1536 | + FontUIResource monospacedPlain = new FontUIResource(Font.MONOSPACED,
1537 | + Font.PLAIN, f.getSize());
1538 | ColorUIResource red = new ColorUIResource(Color.red);
1539 | ColorUIResource black = new ColorUIResource(Color.black);
1540 | ColorUIResource white = new ColorUIResource(Color.white);
1541 | @@ -289,7 +288,7 @@ class XAWTLookAndFeel extends MotifLookA
1542 | "END", "maxScroll"
1543 | }),
1544 |
1545 | - "ScrollPane.font", dialogPlain12,
1546 | + "ScrollPane.font", dialogPlain,
1547 | "ScrollPane.background", scrollBarBackground,
1548 | "ScrollPane.foreground", table.get("controlText"),
1549 | "ScrollPane.border", null,
1550 | @@ -360,7 +359,7 @@ class XAWTLookAndFeel extends MotifLookA
1551 | "TextField.selectionForeground", table.get("textHighlightText"),
1552 | "TextField.background", table.get("window"),
1553 | "TextField.foreground", table.get("textText"),
1554 | - "TextField.font", sansSerifPlain12,
1555 | + "TextField.font", sansSerifPlain,
1556 | "TextField.border", textFieldBorder,
1557 | "TextField.focusInputMap", fieldInputMap,
1558 |
1559 | @@ -371,7 +370,7 @@ class XAWTLookAndFeel extends MotifLookA
1560 | "PasswordField.selectionForeground", table.get("textHighlightText"),
1561 | "PasswordField.background", table.get("window"),
1562 | "PasswordField.foreground", table.get("textText"),
1563 | - "PasswordField.font", sansSerifPlain12,
1564 | + "PasswordField.font", sansSerifPlain,
1565 | "PasswordField.border", textFieldBorder,
1566 | "PasswordField.focusInputMap", passwordInputMap,
1567 |
1568 | @@ -382,7 +381,7 @@ class XAWTLookAndFeel extends MotifLookA
1569 | "TextArea.selectionForeground", table.get("textHighlightText"),
1570 | "TextArea.background", table.get("window"),
1571 | "TextArea.foreground", table.get("textText"),
1572 | - "TextArea.font", monospacedPlain12,
1573 | + "TextArea.font", monospacedPlain,
1574 | "TextArea.border", marginBorder,
1575 | "TextArea.focusInputMap", multilineInputMap
1576 | };
1577 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
1578 | ===================================================================
1579 | --- jdk8u152-b16.orig/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
1580 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java
1581 | @@ -187,7 +187,7 @@ class XFileDialogPeer extends XDialogPee
1582 |
1583 | // add components to GridBagLayout "gbl"
1584 |
1585 | - Font f = new Font(Font.DIALOG, Font.PLAIN, 12);
1586 | + Font f = FontDefaults.font;
1587 |
1588 | Label label = new Label(pathLabelText);
1589 | label.setFont(f);
1590 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
1591 | ===================================================================
1592 | --- jdk8u152-b16.orig/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
1593 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
1594 | @@ -1489,6 +1489,15 @@ public final class XToolkit extends UNIX
1595 | desktopProperties.put("awt.mouse.numButtons",
1596 | Integer.valueOf(getNumberOfButtons()));
1597 | }
1598 | + desktopProperties.put("ui.defaultFont", FontDefaults.font);
1599 | + desktopProperties.put("ui.defaultFont.antialiasing", FontDefaults.antialiasingHint);
1600 | + }
1601 | +
1602 | + @Override
1603 | + protected RenderingHints getDesktopAAHints() {
1604 | + // RenderingHints is mutable class, so we have to return new instance
1605 | + // every time to be on the safe side:
1606 | + return new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, FontDefaults.antialiasingHint);
1607 | }
1608 |
1609 | /**
1610 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XWindow.java
1611 | ===================================================================
1612 | --- jdk8u152-b16.orig/jdk/src/solaris/classes/sun/awt/X11/XWindow.java
1613 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/XWindow.java
1614 | @@ -104,7 +104,7 @@ class XWindow extends XBaseWindow implem
1615 |
1616 | static synchronized Font getDefaultFont() {
1617 | if (null == defaultFont) {
1618 | - defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
1619 | + defaultFont = FontDefaults.font;
1620 | }
1621 | return defaultFont;
1622 | }
1623 | Index: jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/FontDefaults.java
1624 | ===================================================================
1625 | --- /dev/null
1626 | +++ jdk8u152-b16/jdk/src/solaris/classes/sun/awt/X11/FontDefaults.java
1627 | @@ -0,0 +1,174 @@
1628 | +package sun.awt.X11;
1629 | +
1630 | +import java.awt.Font;
1631 | +import java.awt.RenderingHints;
1632 | +import java.io.File;
1633 | +import java.io.FileInputStream;
1634 | +import java.io.InputStreamReader;
1635 | +import java.io.Reader;
1636 | +import java.security.AccessController;
1637 | +import java.security.PrivilegedAction;
1638 | +import java.util.Arrays;
1639 | +import java.util.List;
1640 | +import java.util.Optional;
1641 | +import java.util.Properties;
1642 | +import java.util.function.Supplier;
1643 | +
1644 | +/**
1645 | + * Configuration hierarchy follows "first found":
1646 | + *
1647 | + *
1653 | + */
1654 | +class FontDefaults {
1655 | +
1656 | + static final Font font;
1657 | + static final Object antialiasingHint;
1658 | +
1659 | + static {
1660 | + FontDefaults resolver = new FontDefaults();
1661 | + List