Path: blob/master/src/java.desktop/macosx/classes/com/apple/laf/AquaFonts.java
41154 views
/*1* Copyright (c) 2011, 2014, 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;3536@SuppressWarnings("serial") // JDK implementation class37public class AquaFonts {38private static final String MAC_DEFAULT_FONT_NAME = "Lucida Grande";3940private static final RecyclableSingleton<FontUIResource> lucida9Pt = new RecyclableSingleton<FontUIResource>() {41@Override42protected FontUIResource getInstance() {43return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 9);44}45};46//private static final FontUIResource lucida10Pt = new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 10);47private static final RecyclableSingleton<FontUIResource> lucida11Pt = new RecyclableSingleton<FontUIResource>() {48@Override49protected FontUIResource getInstance() {50return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 11);51}52};53private static final RecyclableSingleton<FontUIResource> lucida12Pt = new RecyclableSingleton<FontUIResource>() {54@Override55protected FontUIResource getInstance() {56return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 12);57}58};59private static final RecyclableSingleton<FontUIResource> lucida13Pt = new RecyclableSingleton<FontUIResource>() {60@Override61protected FontUIResource getInstance() {62return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 13);63}64};65private static final RecyclableSingleton<FontUIResource> lucida14Pt = new RecyclableSingleton<FontUIResource>() {66@Override67protected FontUIResource getInstance() {68return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.PLAIN, 14);69}70};7172private static final RecyclableSingleton<FontUIResource> lucida13PtBold = new RecyclableSingleton<FontUIResource>() {73@Override74protected FontUIResource getInstance() {75return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.BOLD, 13);76}77};78private static final RecyclableSingleton<FontUIResource> lucida14PtBold = new RecyclableSingleton<FontUIResource>() {79@Override80protected FontUIResource getInstance() {81return new DerivedUIResourceFont(MAC_DEFAULT_FONT_NAME, Font.BOLD, 14);82}83};8485protected static FontUIResource getMiniControlTextFont() {86return lucida9Pt.get();87}8889protected static FontUIResource getSmallControlTextFont() {90return lucida11Pt.get();91}9293public static FontUIResource getControlTextFont() {94return lucida13Pt.get();95}9697public static FontUIResource getControlTextSmallFont() {98return lucida11Pt.get();99}100101public static FontUIResource getMenuFont() {102return lucida14Pt.get();103}104105public static Font getDockIconFont() {106return lucida14PtBold.get();107}108109public static FontUIResource getAlertHeaderFont() {110return lucida13PtBold.get();111}112113public static FontUIResource getAlertMessageFont() {114return lucida11Pt.get();115}116117public static FontUIResource getViewFont() {118return lucida12Pt.get();119}120121/**122* All fonts derived from this type will also be of this type, and not a plain java.awt.Font123*/124static class DerivedUIResourceFont extends FontUIResource implements UIResource {125public DerivedUIResourceFont(final Font font) {126super(font);127}128129public DerivedUIResourceFont(final String name, final int style, final int size) {130super(name, style, size);131}132133public Font deriveFont(final AffineTransform trans) {134return new DerivedUIResourceFont(super.deriveFont(trans));135}136137public Font deriveFont(final float derivedSize) {138return new DerivedUIResourceFont(super.deriveFont(derivedSize));139}140141public Font deriveFont(final int derivedStyle) {142return new DerivedUIResourceFont(super.deriveFont(derivedStyle));143}144145public Font deriveFont(final int derivedStyle, final AffineTransform trans) {146return new DerivedUIResourceFont(super.deriveFont(derivedStyle, trans));147}148149public Font deriveFont(final int derivedStyle, final float derivedSize) {150return new DerivedUIResourceFont(super.deriveFont(derivedStyle, derivedSize));151}152153public Font deriveFont(final Map<? extends Attribute, ?> attributes) {154return new DerivedUIResourceFont(super.deriveFont(attributes));155}156}157}158159160