# PaintCompat

# PaintCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/graphics/PaintCompat.java+class:androidx.core.graphics.PaintCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/graphics/PaintCompat "View this page in Java")

<br />

```
class PaintCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[Paint](https://developer.android.com/reference/android/graphics/Paint.html).

## Summary

|                                       ### Public functions                                        |
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [hasGlyph](https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String))`(paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)`, string: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Determine whether the typeface set on the paint has a glyph supporting the string in a backwards compatible way.   |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [setBlendMode](https://developer.android.com/reference/kotlin/androidx/core/graphics/PaintCompat#setBlendMode(android.graphics.Paint,androidx.core.graphics.BlendModeCompat))`(paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)`, blendMode: `[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`?)` Configure the corresponding BlendMode on the given paint. |

## Public functions

### hasGlyph

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun hasGlyph(paint: Paint, string: String): Boolean
```

Determine whether the typeface set on the paint has a glyph supporting the string in a backwards compatible way.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|---------------------------------------------------|
| `paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)       | the paint instance to check                       |
| `string: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | the string to test whether there is glyph support |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if the typeface set on the given paint has a glyph for the string |

### setBlendMode

Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)  

```
java-static fun setBlendMode(paint: Paint, blendMode: BlendModeCompat?): Boolean
```

Configure the corresponding BlendMode on the given paint. If the Android platform supports the blend mode natively, it will fall back on the framework implementation of either BlendMode or PorterDuff mode. If it is not supported then this method is a no-op  

|                                                        Parameters                                                        |
|--------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `paint: `[Paint](https://developer.android.com/reference/android/graphics/Paint.html)                                    | target Paint to which the BlendMode will be applied                                                                                                                 |
| `blendMode: `[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`?` | BlendMode to configure on the paint if it is supported by the platform version. A value of null removes the BlendMode from the Paint and restores it to the default |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true if the specified BlendMode as applied successfully, false if the platform version does not support this BlendMode. If the BlendMode is not supported, this falls back to the default BlendMode |