• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.messaging.util;
17 
18 import android.graphics.Typeface;
19 
20 /**
21  * Provides access to typefaces used by code. Specially important for typefaces coming from assets,
22  * which appear (from platform code inspection) to not be cached.
23  * Note: Considered making this a singleton provided by factory/appcontext, but seemed too simple,
24  * not worth stubbing.
25  */
26 public class Typefaces {
27     private static Typeface sRobotoBold;
28     private static Typeface sRobotoNormal;
29 
getRobotoBold()30     public static Typeface getRobotoBold() {
31         Assert.isMainThread();
32         if (sRobotoBold == null) {
33             sRobotoBold = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
34         }
35         return sRobotoBold;
36     }
37 
getRobotoNormal()38     public static Typeface getRobotoNormal() {
39         Assert.isMainThread();
40         if (sRobotoNormal == null) {
41             sRobotoNormal = Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
42         }
43         return sRobotoNormal;
44     }
45 }
46