Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/macosx/classes/com/apple/laf/AquaFonts.java
38831 views
/*1* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.apple.laf;2627import java.awt.Font;28import java.awt.geom.AffineTransform;29import java.text.AttributedCharacterIterator.Attribute;30import java.util.Map;3132import javax.swing.plaf.*;3334import com.apple.laf.AquaUtils.RecyclableSingleton;3536public class AquaFonts {37private static final String MAC_DEFAULT_FONT_NAME = "Lucida Grande";3839private static final RecyclableSingleton<FontUIResource> lucida9Pt = new RecyclableSingleton<FontUIResource>() {40@Override41protected FontUIResource getInstance() {42return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 9);43}44};45//private static final FontUIResource lucida10Pt = new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 10);46private static final RecyclableSingleton<FontUIResource> lucida11Pt = new RecyclableSingleton<FontUIResource>() {47@Override48protected FontUIResource getInstance() {49return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 11);50}51};52private static final RecyclableSingleton<FontUIResource> lucida12Pt = new RecyclableSingleton<FontUIResource>() {53@Override54protected FontUIResource getInstance() {55return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 12);56}57};58private static final RecyclableSingleton<FontUIResource> lucida13Pt = new RecyclableSingleton<FontUIResource>() {59@Override60protected FontUIResource getInstance() {61return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 13);62}63};64private static final RecyclableSingleton<FontUIResource> lucida14Pt = new RecyclableSingleton<FontUIResource>() {65@Override66protected FontUIResource getInstance() {67return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 14);68}69};7071private static final RecyclableSingleton<FontUIResource> lucida13PtBold = new RecyclableSingleton<FontUIResource>() {72@Override73protected FontUIResource getInstance() {74return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.BOLD, 13);75}76};77private static final RecyclableSingleton<FontUIResource> lucida14PtBold = new RecyclableSingleton<FontUIResource>() {78@Override79protected FontUIResource getInstance() {80return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.BOLD, 14);81}82};8384protected static FontUIResource getMiniControlTextFont() {85return lucida9Pt.get();86}8788protected static FontUIResource getSmallControlTextFont() {89return lucida11Pt.get();90}9192public static FontUIResource getControlTextFont() {93return lucida13Pt.get();94}9596public static FontUIResource getControlTextSmallFont() {97return lucida11Pt.get();98}99100public static FontUIResource getMenuFont() {101return lucida14Pt.get();102}103104public static Font getDockIconFont() {105return lucida14PtBold.get();106}107108public static FontUIResource getAlertHeaderFont() {109return lucida13PtBold.get();110}111112public static FontUIResource getAlertMessageFont() {113return lucida11Pt.get();114}115116public static FontUIResource getViewFont() {117return lucida12Pt.get();118}119120/**121* All fonts derived from this type will also be of this type, and not a plain java.awt.Font122*/123static class DerivedUIResourceFont extends FontUIResource implements UIResource {124public DerivedUIResourceFont(final Font font) {125super(font);126}127128public DerivedUIResourceFont(final String name, final int style, final int size) {129super(name, style, size);130}131132public Font deriveFont(final AffineTransform trans) {133return new DerivedUIResourceFont(super.deriveFont(trans));134}135136public Font deriveFont(final float derivedSize) {137return new DerivedUIResourceFont(super.deriveFont(derivedSize));138}139140public Font deriveFont(final int derivedStyle) {141return new DerivedUIResourceFont(super.deriveFont(derivedStyle));142}143144public Font deriveFont(final int derivedStyle, final AffineTransform trans) {145return new DerivedUIResourceFont(super.deriveFont(derivedStyle, trans));146}147148public Font deriveFont(final int derivedStyle, final float derivedSize) {149return new DerivedUIResourceFont(super.deriveFont(derivedStyle, derivedSize));150}151152public Font deriveFont(final Map<? extends Attribute, ?> attributes) {153return new DerivedUIResourceFont(super.deriveFont(attributes));154}155}156}157158159