Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Text in multimedia

How text is represented, laid out and rendered in multimedia: fonts, glyphs, metrics, encoding (Unicode), layout (wrapping, shaping, bidi), rendering methods (bitmap, vector, signed-distance fields), and practical concerns for captions, subtitles and scalable display.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Text is one of the most common multimedia elements: user interfaces, captions, subtitles, menus, search metadata and accessibility content use text. Engineers must choose encodings, fonts, layout and rendering methods so text is readable, scalable, searchable and accessible across screens, resolutions and languages.

Key ideas

All terms are defined before they are used.

  • Text: a sequence of characters meant to be read; in multimedia, text can be stored as encoded characters (searchable) or as pixels (bitmap) or geometry (vector). Use the type appropriate to the task: searchable vs purely visual.
  • Character: an abstract unit of writing (for example, the letter A). Characters are what authors think in.
  • Code point: a numeric value that identifies a character in an encoding system (example: U+0041 is Latin capital letter A). A code point is not yet bytes on disk.
  • Encoding: a mapping from code points to bytes (examples: UTF-8, UTF-16). Encoding decides how many bytes each code point consumes.
  • Glyph: the visual shape that represents one or more characters (for example, the shape used to draw the letter A or a ligature “fi”). A single character can map to multiple glyphs (contextual forms), and multiple characters can map to a single glyph (ligature).
  • Typeface: a consistent design of glyphs (for example, "Times New Roman").
  • Font: a specific instantiation of a typeface with size, weight and style (for example, "Times New Roman Bold 12pt").
  • Point (pt): a typographic unit where by convention 1 point = 1/72 inch. (Used to convert printed type size to physical measurements.)
  • DPI / PPI: dots per inch or pixels per inch, the number of device pixels per physical inch.
  • Glyph metrics: numeric values that tell layout engines how to place glyphs. Important metrics: baseline, ascent, descent, leading (line gap), advance width, x-height, cap-height, side bearings.
    • Draw for exam: a horizontal baseline line. Above it, draw three horizontal lines for ascent (ascender line), cap height, and x-height. Below baseline draw descent. Around glyphs draw bounding box. Label baseline, ascent, descent, cap height and x-height.
  • Kerning: pairwise adjustments to the horizontal spacing between two glyphs to improve visual appearance (e.g. AV).
  • Tracking (letter-spacing): uniform adjustment of spacing across a range of glyphs.
  • Ligature: a single glyph representing two or more characters (e.g. "fi").
  • Hinting: instructions in vector fonts to improve rasterisation quality at small sizes by aligning strokes to pixel grid.
  • Rasterisation / Rasterization: converting vector outlines of glyphs into pixels for display.
  • Bitmap (raster) fonts: pre-rendered glyph bitmaps for specific sizes. Fast but not scalable.
  • Outline (vector) fonts: fonts storing glyph outlines (usually Bézier curves) that are rasterised at render time. Scalable and common (TrueType, OpenType).
  • Subpixel rendering: using subpixel layout of color channels in LCD screens to increase apparent horizontal resolution for text (e.g. ClearType). Requires careful color handling.
  • Anti-aliasing: smoothing edge stair-step effects when rasterising shapes to pixels (grayscale or color-aware subpixel).
  • Signed distance field (SDF): a texture where each texel stores the signed distance to the nearest glyph edge; used to render sharp scalable text in GPU with small textures and simple shaders.
  • Text shaping: the process of turning a sequence of characters (code points) into positioned glyphs according to script rules, OpenType features, contextual forms and ligatures. Uses a shaping engine (e.g. HarfBuzz).
  • Bidirectional (Bidi) text: when text contains left-to-right (LTR) and right-to-left (RTL) scripts (e.g. English + Arabic). Use the Unicode Bidirectional Algorithm to determine visual order.
  • Line breaking: deciding where to wrap text to the next line; algorithms include simple greedy wrap and advanced methods like Knuth–Plass for paragraph composition (used in high-quality typesetting).
  • Subtitles vs Captions: subtitles display spoken dialogue (may exclude non-speech sounds) for viewers who can hear; captions include non-speech audio information (sound effects, speaker IDs) and are intended for deaf or hard-of-hearing viewers. Closed captions can be toggled on/off, open captions are burned into the video.
  • Searchability and accessibility: storing text as encoded characters (not burned-in pixels) preserves search, copying, indexing and screen-reader accessibility.
  • Performance and memory: common strategies include glyph caching, texture atlases, and pre-rendering to bitmaps or SDFs; trade-offs exist between memory, CPU rasterisation cost and visual quality.

Derivation universities commonly ask for (pixel size from point size):

  1. Start from definition 1 pt = 1/72 inch.
  2. Device has DPI pixels per inch.
  3. Therefore font size in pixels = point_size × (DPI / 72). Draw a short diagram: an inch ruler, mark 1/72 inch segments labeled pt; show DPI pixels inside the inch.

Describe a rendering pipeline to draw text in multimedia (step list):

  1. Input text (code points) stored with an encoding (e.g. UTF-8). Validate and decode into a sequence of Unicode code points.
  2. Apply text segmentation (grapheme clusters, normalization if needed).
  3. Run shaping: map code points to glyph indices, apply OpenType features, ligatures, contextual alternates.
  4. Compute glyph positions: advances, kerning, line breaks, vertical metrics.
  5. Select rendering method: raster (bitmap), outline rasterisation with anti-aliasing, SDF, or GPU vector tessellation.
  6. Composite text into final image/video frame using correct gamma and color management.

Where unsure: see verify list at the end. Verify list: check encoding and valid code points (UTF-8/UTF-16; no surrogate code points in UTF-8), normalization needs (e.g., NFC/NFKC as appropriate), script direction and Bidi controls, line breaking rules (UAX #14), shaping support in the chosen font (OpenType features), DPI/PPI mapping for point-to-pixel conversions, and gamma/color management during compositing.

Formulas

pixel_size = point_size × (DPI / 72) — pixel_size: font size in pixels (px); point_size: font size in points (pt); DPI: dots or pixels per inch (dpi or ppi). Applies when converting typographic point sizes to device pixels.

memory_bytes = width_px × height_px × bytes_per_pixel — memory_bytes: memory used by a texture region (B); width_px, height_px: texture dimensions in pixels (px); bytes_per_pixel: bytes per pixel (B/px), for example 1 for 8-bit SDF, 4 for RGBA8. Applies to texture atlas or glyph bitmap memory.

total_atlas_memory = glyph_count × glyph_tile_width × glyph_tile_height × bytes_per_pixel — same symbols extended: glyph_count: number of glyph tiles stored.

unicode_range_max = 0x10FFFF — highest Unicode code point allowed; unitless. Applies to Unicode standard scalar values.

Notes on units: pt → inch uses 1 pt = 1/72 in; DPI is px per inch. Use SI units if physical measurements are needed (1 inch = 0.0254 m) for converting to metres.

Worked examples

Example 1 — Convert font size from points to pixels Question: On a desktop monitor with 96 DPI, how many pixels high is a 12 pt font? Show steps.

  1. Formula: pixel_size = point_size × (DPI / 72).
  2. Substitute: pixel_size = 12 pt × (96 px/in ÷ 72 pt/in).
  3. Compute: 96 ÷ 72 = 4/3 = 1.333..., times 12 = 16.
  4. Units: result in pixels. Answer: 16 px.

Example 2 — Texture atlas memory for SDF glyphs Question: You want to store 500 glyphs in an SDF atlas. Each glyph tile is 64 × 64 pixels and each texel is one 8-bit channel. Calculate memory in bytes and in MiB (1 MiB = 2^20 bytes).

  1. Formula: total_atlas_memory = glyph_count × glyph_tile_width × glyph_tile_height × bytes_per_pixel.
  2. Substitute: = 500 × 64 × 64 × 1 bytes.
  3. Compute: 64 × 64 = 4096; 4096 × 500 = 2,048,000 bytes.
  4. Convert to MiB: 2,048,000 ÷ 1,048,576 ≈ 1.953125 MiB. Answer: 2,048,000 bytes (≈ 1.953 MiB).

Example 3 — Shaping trace for a small input with a ligature Question: Show a shaping trace for the character sequence ['f'(U+0066), 'i'(U+0069)]. Assume the font provides an "fi" ligature.

  1. Input code points: U+0066, U+0069.
  2. Shaping engine looks up glyphs: maps U+0066 → glyph id 45, U+0069 → glyph id 46.
  3. Engine applies OpenType substitution lookup: sequence [45,46] matches ligature substitution → replace with glyph id 200 (the ligature).
  4. Resulting glyph sequence: [200]. Advance widths: use glyph 200 advance. Kerning between 45 and 46 is replaced by the ligature metrics.
  5. Rendering: draw glyph 200 at computed position. Answer: final positioned glyphs contain the single ligature glyph; positioning reflects advance of glyph 200. (This is the behaviour expected from a shaping engine like HarfBuzz.)

Common mistakes

  • Using 1 pt = 1 px; forgetting dependency on DPI/ PPI when converting points to pixels.
  • Treating a code point as the same as a glyph — they are distinct concepts.
  • Assuming UTF-8 = Unicode; UTF-8 is an encoding of Unicode code points, not the character set itself.
  • Forgetting to perform Unicode normalization when required (e.g., before comparing strings for canonical equivalence); note that grapheme cluster segmentation (Unicode UAX #29) does not require normalization.
  • Ignoring bidirectional reordering when displaying mixed LTR and RTL text.
  • Overlooking hinting or small-size rasterisation artifacts when designing UI for low-DPI screens.
  • Using SDF without sufficient padding around glyphs, which causes incorrect edges when scaled.

For your exam

Possible question types:

  • Definitions and short notes (define glyph, font, typeface, kerning, hinting, SDF).
  • Derivations (convert pt to pixels; compute texture memory; show pipeline steps).
  • Algorithmic traces (shaping example, bidi reorder example, line-wrapping greedy vs Knuth–Plass trace).
  • Diagram tasks (draw baseline, ascent, descent; label metrics; show glyph bounding boxes and side bearings).
  • Practical design questions (choose rendering approach for captions in a mobile app and justify trade-offs).

What full-marks answers include:

  • Precise definitions with bold term names.
  • Correct unit usage and stepwise derivations for numeric answers; final value with units.
  • For algorithms, a clear step-by-step trace showing inputs and intermediate states (shaping tables, glyph indices, line breaks).
  • For diagrams, clear labels: baseline, ascent, descent, cap height, x-height, advance width, left/right side bearing.
  • For design questions, list trade-offs (quality vs performance vs memory vs accessibility) and recommend concrete choices (e.g. SDF for scalable GPU-rendered UI, outline rasterisation for print-quality text, store captions as text for accessibility).

Quick check

  1. What is the difference between a glyph and a code point?
  2. Compute pixel height of a 18 pt font on a 96 DPI screen.
  3. What is a Signed Distance Field (SDF) used for in text rendering?

Answers: 1) A glyph is a visual shape; a code point is an abstract numeric identifier for a character. 2) pixel_size = 18 × (96/72) = 24 px. 3) SDF stores distance to glyph edges in a texture to render sharp, scalable text with small textures on the GPU.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?