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