# 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)

*** ** * ** ***


```
public final class PaintCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/graphics/Paint.html`.

## Summary

| ### Public methods |
|---|---|
| `static boolean` | `https://developer.android.com/reference/androidx/core/graphics/PaintCompat#hasGlyph(android.graphics.Paint,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html string)` Determine whether the typeface set on the paint has a glyph supporting the string in a backwards compatible way. |
| `static boolean` | `https://developer.android.com/reference/androidx/core/graphics/PaintCompat#setBlendMode(android.graphics.Paint,androidx.core.graphics.BlendModeCompat)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/graphics/BlendModeCompat blendMode)` Configure the corresponding BlendMode on the given paint. |

## Public methods

### hasGlyph

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

```
public static boolean hasGlyph(@NonNull Paint paint, @NonNull String string)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint` | the paint instance to check |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html string` | the string to test whether there is glyph support |

| Returns |
|---|---|
| `boolean` | 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)

```
public static boolean setBlendMode(@NonNull Paint paint, @Nullable BlendModeCompat blendMode)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Paint.html paint` | target Paint to which the BlendMode will be applied |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/graphics/BlendModeCompat blendMode` | 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` | 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 |