Text and Typography in Mobile Development: What It Is, Tools, and How It Works

Author: IT Sectr Published: 2026-08-04 Reading time: 10 min

Working with text is a key task when creating interfaces for modern mobile applications. From font selection to adjusting character spacing — every aspect affects the perception of the product. According to Apple NSAttributedString Documentation, proper text formatting is directly related to readability and interface accessibility.

Key Takeaways

  • NSAttributedString — iOS class for creating formatted text with font, color, and spacing attributes.
  • SpannableString — Android equivalent that uses Span objects to style individual text fragments.
  • UIFont and Typeface — main font classes on iOS and Android; custom fonts are added via Info.plist and res/font.
  • Kerning and Ligatures — typographic parameters that control spacing between characters and their merging into a single glyph.
  • Variable Fonts — a single font file contains multiple styles, reducing app size.

Text in Mobile Apps: NSAttributedString on iOS

NSAttributedString is the fundamental iOS class for working with formatted text. It allows applying attributes to individual characters or ranges: font via UIFont, color via UIColor, character spacing via kern, and line spacing via NSMutableParagraphStyle. In mobile apps, NSAttributedString is used everywhere — from UILabel to complex UITextView with editing support.

UIFont and Font Configuration

UIFont is the main class for working with fonts on iOS. It supports system typefaces, custom fonts, and Dynamic Type. UIFont(name:size:) loads a font by name, UIFont.systemFont(ofSize:weight:) loads the system font. UIFontDescriptor allows modifying an existing font: changing size, weight, or adding a transformation matrix. For custom fonts, the .ttf file is added to the project and registered in Info.plist under the Fonts provided by application key.

swift
let attributes: [NSAttributedString.Key: Any] = [
    .font: UIFont(name: "HelveticaNeue-Bold", size: 18) as Any,
    .foregroundColor: UIColor.darkGray as Any,
    .kern: 1.5 as Any
]
let attributedString = NSAttributedString(
    string: "Форматированный текст",
    attributes: attributes
)
label.attributedText = attributedString

NSMutableParagraphStyle and Paragraph Formatting

NSMutableParagraphStyle is a mutable version of ParagraphStyle for configuring paragraph display. It controls alignment, line spacing (lineSpacing), indentation (headIndent, tailIndent), and truncation mode (lineBreakMode). ParagraphStyle is critical for readability of long texts on mobile devices: proper lineSpacing prevents line merging, and lineBreakMode prevents word clipping. The paragraphSpacing setting defines the space between paragraphs.

Text in Mobile Apps: SpannableString on Android

SpannableString is the main tool for text formatting on Android. It works through a mechanism of Span objects, each responsible for one aspect: StyleSpan for bold or italic, ForegroundColorSpan for color, URLSpan for links, UnderlineSpan for underline. SpannableStringBuilder is the equivalent of NSMutableAttributedString, allowing you to build text from multiple fragments. Understanding SpannableString is essential for creating flexible interfaces with formatted text in mobile apps.

Typeface and Custom Fonts on Android

Typeface is the class for working with fonts on Android. It supports system typefaces Roboto and Noto, as well as custom fonts. Typeface.createFromResource() loads a font from res/font/, Typeface.createFromAsset() loads from the assets folder. Android 8.0+ supports font families in XML, combining multiple font files into a single resource. A custom font for text in mobile apps on Android is set via the android:fontFamily attribute or programmatically using setTypeface().

TextMeasurer and Text Measurement

TextMeasurer (API 29+) is a modern tool for measuring text without binding to a View. It calculates width, height, and character positions before rendering. On older APIs, Paint.measureText() is used for single-line text or StaticLayout for multi-line text. TextMeasurer is especially useful in custom Views where text is drawn via Canvas.drawText(). Correct measurement prevents character clipping in the interface.

kotlin
val spannable = SpannableString("Жирный текст с цветом")
spannable.setSpan(
    StyleSpan(Typeface.BOLD),
    0, 6,
    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
spannable.setSpan(
    ForegroundColorSpan(Color.RED),
    14, 19,
    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
textView.text = spannable

Typography in Mobile Development: Kerning, Ligatures, and Tracking

Typography in mobile apps is a comprehensive configuration of fonts, character spacing, and line spacing. Proper typography in mobile development directly affects text readability and the visual perception of the interface. Let's look at the key parameters available on both platforms.

Kerning and Tracking

Kerning is the adjustment of space between specific character pairs (AV, To, Wa). Tracking is uniform character spacing for the entire text or a portion of it. On iOS, kerning is set via NSKernAttributeName, on Android — via the letterSpacing property of TextView. Negative values bring characters closer together, positive values spread them apart. Typography in mobile development requires careful tuning of these parameters: for large headings, character spacing is usually increased, for body text it remains standard.

ParameteriOSAndroid
Styled StringNSAttributedStringSpannableString
FontUIFont / CTFontTypeface
Character SpacingNSKernAttributeNameletterSpacing
Line SpacinglineSpacinglineSpacingExtra
LigaturesNSLigatureAttributeNameOpenType features
EllipsislineBreakMode .byTruncatingTailandroid:ellipsize

Ligatures

Ligatures are special glyphs that replace combinations of two or more characters: fi, fl, ffi. On iOS, ligatures are controlled via NSLigatureAttributeName: 0 — disabled, 1 — standard, 2 — all available. On Android, ligatures are controlled at the font level through OpenType features. Enabling ligatures improves text appearance, especially in serif typefaces. Typography in mobile development uses ligatures primarily for headings and logos.

Custom Fonts in Mobile Apps: Loading and Configuration

Custom fonts are one of the main tools for creating a unique visual style for an app. They help highlight the brand and improve the user experience. In mobile apps, custom fonts are used for headings, logos, accent elements, and corporate identity.

Variable Fonts

Variable Fonts are a modern font technology where a single file contains multiple styles: from thin to extra bold, from narrow to wide. This reduces app size by replacing several font files with one. On iOS, Variable Fonts are supported via UIFont with the weight parameter. On Android — via Typeface.Builder specifying variability axes wght, wdth, slnt. Using Variable Fonts simplifies typography in mobile apps: the developer doesn't need to load separate files for each style.

swift
let customFont = UIFont(name: "CustomFont-Regular", size: 16)
let scaledFont = UIFontMetrics.default
    .scaledFont(for: customFont)
label.font = scaledFont
label.adjustsFontForContentSizeCategory(true)

NSTextAttachment and ImageSpan

NSTextAttachment on iOS allows embedding UIImage inside NSAttributedString — the image aligns to the baseline and wraps with text. On Android, the equivalent is ImageSpan inside SpannableString. Both approaches are useful for chat with emojis, news feeds with icons, and forms with custom checkboxes. It's important to properly scale the image to match the font height so that text and graphics look harmonious.

Text Effects, Alignment, and Ellipsis

Beyond basic formatting, text in mobile apps supports additional visual effects: shadows, outlines, strikethrough, and underline. These tools expand the possibilities of typography but require careful application to maintain readability.

Text Shadow and Outline

Text shadow on iOS is set via NSShadow with offset, blurRadius, and color. Outline — via NSStrokeWidthAttributeName: negative values create fill with outline, positive values create only the contour. Strikethrough — NSUnderlineStyle (.single, .thick, .double). On Android, TextView shadow is configured via android:shadowRadius, android:shadowDx, android:shadowDy. SpannableString supports StrikethroughSpan and UnderlineSpan. Text outline on Android is implemented via OutlineSpan or a custom font.

Ellipsis and Marquee

Ellipsis is text truncation with an ellipsis when the container overflows. On iOS, it's configured via lineBreakMode .byTruncatingTail and numberOfLines. On Android — via android:ellipsize="end" and android:maxLines. Marquee is a scrolling text animation available on Android via android:ellipsize="marquee". On iOS, there is no built-in equivalent — the MarqueeLabel library is used. Ellipsis is mandatory for all single-line texts in mobile apps to avoid content clipping.

Dynamic Type on iOS

Dynamic Type is an adaptive text system in iOS that adjusts font size based on the user's Accessibility settings. Use UIFontMetrics to scale custom fonts. Dynamic Type is mandatory for Accessibility-compliant apps. On Android, the equivalent is sp units and scaledPixels, which scale according to system text size settings.

Frequently Asked Questions

What is NSAttributedString?

NSAttributedString is an iOS class for creating formatted text with font, color, and style attributes at the character and range level.

What is SpannableString on Android?

SpannableString is an Android class for text markup via Span objects: ForegroundColorSpan, StyleSpan, URLSpan, UnderlineSpan.

How to add a custom font in iOS?

Add the .ttf file to the project, specify it in Info.plist under the Fonts provided by application key, then use UIFont(name:).

How to load a custom font on Android?

Place the .ttf file in res/font/, create an XML font family, and specify android:fontFamily or use Typeface.createFromAsset().

What are kerning and ligatures?

Kerning is the space between character pairs. Ligatures are special glyphs for letter combinations. They are controlled via NSKernAttributeName and NSLigatureAttributeName.

Summary

  • NSAttributedString — the main text formatting tool on iOS, supporting fonts, colors, character spacing, and paragraph styles.
  • SpannableString — the Android equivalent using Span objects: StyleSpan for weight, ForegroundColorSpan for color, URLSpan for links.
  • UIFont and Typeface — font classes on iOS and Android; custom fonts are added via Info.plist and res/font respectively.
  • Kerning and Tracking — control character spacing; kerning for individual pairs, tracking uniformly for the entire text.
  • Ligatures — replace character combinations with single glyphs; controlled via NSLigatureAttributeName on iOS and OpenType on Android.
  • Variable Fonts and Dynamic Type — modern technologies: one file for multiple styles and automatic adaptation to user settings.
  • Typography in mobile development encompasses fonts, line spacing, ligatures, shadows, and ellipsis to ensure readability.

We will develop a mobile application turnkey

IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.

Discuss the project