Exercise 2: Uppercase Measures Wider Than Lowercase — Possible Solution ==================================================================== THE TEST ------------------------------ char_width_px('a', 16.0) char_width_px('A', 16.0) RESULT ------------------------------ 'a' -> 8.0 (CHAR_WIDTHS_EM['a'] = 0.50, times 16.0) 'A' -> 10.72 (CHAR_WIDTHS_EM['A'] = 0.67, times 16.0) 'A' is genuinely wider than 'a' at the identical 16px font-size -- 10.72 > 8.0. WHY THE TABLE ASSIGNS DIFFERENT EM VALUES TO THE SAME LETTER ------------------------------ CHAR_WIDTHS_EM stores 'a' and 'A' as two completely separate dictionary keys, each with its own independently-chosen em value (0.50 for the lowercase form, 0.67 for the uppercase form). There's no shared "letter A" concept in the table at all -- case is simply part of the character's own identity for lookup purposes, exactly the same way a real font's own glyph outlines for lowercase and uppercase letters are two entirely separate drawings, not a single shape scaled or reused. WHY THIS MATCHES REAL TYPOGRAPHY, NOT AN ARBITRARY CHOICE ------------------------------ In the overwhelming majority of real fonts, capital letters are drawn with more strokes, wider bowls, and generally more visual "bulk" per character than their lowercase counterparts -- an 'A' has two diagonal strokes plus a crossbar; a lowercase 'a' is a single compact, rounder shape. This isn't specific to any one font; it's a near- universal property of Latin-script typography, which is exactly why a plausible, hand-estimated width table (like this chapter's own simplified one) can assign uppercase letters systematically larger em values across the board -- most of the uppercase entries in CHAR_WIDTHS_EM (0.61-0.94) sit meaningfully higher than their lowercase counterparts (0.28-0.78), reflecting this same real-world pattern consistently, not just for 'A' specifically. WHY THIS WORKS AS AN ANSWER ------------------------------ This exercise demonstrates the table captures a genuine STRUCTURAL property of real text (case affects width, systematically, not randomly) rather than being an arbitrary or decorative set of numbers. It also reinforces why a flat, single-width-per-character-count model (this chapter's own predecessor bug) can never be fixed by simply picking "one better number" -- the actual distribution of character widths in real text depends on which SPECIFIC characters appear, case included, not just how many characters there are.