• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 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 
17 package android.text;
18 
19 import android.graphics.Paint;
20 
21 /**
22  * TextPaint is an extension of Paint that leaves room for some extra
23  * data used during text measuring and drawing.
24  */
25 public class TextPaint extends Paint {
26 
27     // Special value 0 means no background paint
28     public int bgColor;
29     public int baselineShift;
30     public int linkColor;
31     public int[] drawableState;
32     public float density = 1.0f;
33     /**
34      * Special value 0 means no custom underline
35      * @hide
36      */
37     public int underlineColor = 0;
38     /**
39      * Defined as a multiplier of the default underline thickness. Use 1.0f for default thickness.
40      * @hide
41      */
42     public float underlineThickness;
43 
TextPaint()44     public TextPaint() {
45         super();
46     }
47 
TextPaint(int flags)48     public TextPaint(int flags) {
49         super(flags);
50     }
51 
TextPaint(Paint p)52     public TextPaint(Paint p) {
53         super(p);
54     }
55 
56     /**
57      * Copy the fields from tp into this TextPaint, including the
58      * fields inherited from Paint.
59      */
set(TextPaint tp)60     public void set(TextPaint tp) {
61         super.set(tp);
62 
63         bgColor = tp.bgColor;
64         baselineShift = tp.baselineShift;
65         linkColor = tp.linkColor;
66         drawableState = tp.drawableState;
67         density = tp.density;
68         underlineColor = tp.underlineColor;
69         underlineThickness = tp.underlineThickness;
70     }
71 
72     /**
73      * Defines a custom underline for this Paint.
74      * @param color underline solid color
75      * @param thickness underline thickness
76      * @hide
77      */
setUnderlineText(int color, float thickness)78     public void setUnderlineText(int color, float thickness) {
79         underlineColor = color;
80         underlineThickness = thickness;
81     }
82 }
83