Skip to main content
Version: 5.21.0

Typography

ChatTypography controls two SDK typography layers:

  1. Font sizes — 6 semantic tokens (big, medium, mediumUpper, regular, small, error). These are ChatTypography(...) constructor parameters, each is a ChatFontStyle instance.
  2. Custom fonts — 20 TTF substitution points (*FontPath: String?). These are var properties in the class body; set them after creating the object (via apply { ... } or direct assignment), not through the constructor. Paths are relative to app/src/main/assets/.
Only what is listed here

The tables below list all SDK-configurable fonts and sizes. If you find a field in the SDK code that is not in these lists, it is not part of the public API and cannot be changed.

Font sizes

FieldTypeDefault sizeDescription
bigChatFontStyle20 sp (R.dimen.ecc_text_big)Large font (titles, accents)
mediumUpperChatFontStyle18 sp (R.dimen.ecc_text_medium_upper)Slightly larger than medium
mediumChatFontStyle16 sp (R.dimen.ecc_text_medium)Medium font
regularChatFontStyle14 sp (R.dimen.ecc_text_regular)Main SDK font (message text)
smallChatFontStyle12 sp (R.dimen.ecc_text_small)Small font (timestamps, captions)
errorChatFontStyle11 sp (R.dimen.ecc_error_text_size)Font for error messages

ChatFontStyle stores the size as a dimen resource reference in sp units (which preserves accessibility scaling at the system level) — changes to the system font scale automatically scale all 6 semantic tokens.

Custom fonts — 20 substitution points

All fields are String? with a default of null (system font is used). The value is a path relative to app/src/main/assets/, for example "fonts/Roboto-Regular.ttf".

FieldDescription
defaultFontRegularPathDefault font (Regular)
defaultFontBoldPathDefault bold font
defaultFontLightPathDefault thin font
toolbarTitleFontPathToolbar title
toolbarSubtitleFontPathToolbar subtitle
placeholderTitleFontPathWelcome screen title
placeholderSubtitleFontPathWelcome screen subtitle
quoteHeaderFontPathQuote header
quoteAuthorFontPathQuote author
quoteMessageFontPathQuoted message text
quoteTimeFontPathQuote timestamp
inputQuotedMessageFontPathQuoted message in the input field
bubbleMessageFontPathChat message text
bubbleTimeFontPathChat timestamp
messageHeaderFontPathDate/time headers between messages
typingFontPathTyping indicator
scheduleAlertFontPathSchedule notice
systemMessageFontPathSystem messages
emptyMediaAndFilesHeaderFontPathEmpty "Media and files" list header
emptyMediaAndFilesDescriptionFontPathEmpty "Media and files" list description

Basic setup

val typography = ChatTypography().apply {
// Global defaults — fill all other fields if they are null
defaultFontRegularPath = "fonts/MyFont-Regular.ttf"
defaultFontBoldPath = "fonts/MyFont-Bold.ttf"
defaultFontLightPath = "fonts/MyFont-Light.ttf"

// Per-element overrides
toolbarTitleFontPath = "fonts/MyFont-Medium.ttf"
bubbleMessageFontPath = "fonts/MyFont-Regular.ttf"
}

val theme = ChatTheme(
applicationContext,
typography = typography
)
Global defaults + per-element override

First set defaultFontRegularPath / defaultFontBoldPath / defaultFontLightPath — this covers 95% of the surface. Then add *FontPath only for elements that need a different font.

TypefaceCache does not render the file if the path is invalid

The SDK caches Typeface through an internal TypefaceCache. If the file at the given path is missing from assets/, the SDK silently falls back to the system font — no exception. Check the list of files in app/src/main/assets/fonts/ before release.

Full brand kit

Overriding both fonts and sizes. Semantic tokens are set via the constructor; *FontPath fields — via apply { ... }.

Resources live in the app, the fontSize type is strictly @DimenRes

R.dimen.brand_text_* and R.color.brand_* below are placeholders. Declare them in your app's app/src/main/res/values/dimens.xml (or the corresponding colors.xml) before the build, otherwise you'll get an Unresolved reference.

ChatFontStyle.fontSize: Int? is declared without the @DimenRes annotation, but in most SDK pipelines the value is processed via Resources.getDimension(...) (see TextViewFabric, InputViewFabric). Pass only an R.dimen.* identifier. A literal in sp (fontSize = 22) will lead either to Resources$NotFoundException or to an incorrect size (for example, in spannable text where the value is applied as a raw pixel size).

val brandTypography = ChatTypography(
big = ChatFontStyle(fontSize = R.dimen.brand_text_big), // e.g., 22 sp
regular = ChatFontStyle(fontSize = R.dimen.brand_text_regular), // e.g., 15 sp
small = ChatFontStyle(fontSize = R.dimen.brand_text_small) // e.g., 13 sp
).apply {
defaultFontRegularPath = "fonts/Brand-Regular.ttf"
defaultFontBoldPath = "fonts/Brand-Bold.ttf"
defaultFontLightPath = "fonts/Brand-Light.ttf"
toolbarTitleFontPath = "fonts/Brand-Medium.ttf"
}

val theme = ChatTheme(
applicationContext,
colors = brandColors,
images = brandImages,
typography = brandTypography
)

A detailed scenario of building light and dark themes is in Themes.