TORONTO — On a film set in Canton, Miss., two decades ago, Octavia Spencer got a big break, and a foreshadowing that others might be harder to catch. She was in her mid-20s, working as a production assistant on the Matthew McConaughey-Sandra Bullock thriller “A Time to Kill.” She asked the director Joel Schumacher if she could read for a small part: perhaps the woman who starts a riot?

“He said: ‘No, honey, your face is too sweet. You can be Sandy’s nurse,’” she recalled, laughing. She was sitting, regally postured, in a private glassed-in room at a hotel restaurant. That face was youthful at 46 and frequently lit by a signature ear-to-ear grin. “It was so funny because I didn’t know that there was such a thing as typecasting. It’s like, ‘You’re just a nurse face.’ What is a nurse face?” According to IMDB.com, Ms. Spencer has played a nurse 16 times.

Ms. Spencer is African-American, female, in her 40s and not twig-shaped — Venn-diagram those traits atop the circle marked “Available Parts,” and the overlapping area shrinks to pea-size. Still, in the years since, she has built a sturdy résumé as a recognizable character actor on TV and in films. Her breakthrough came in “The Help” (2011), as the subjugated Mississippi maid who cloaks her revenge in pie. But the accolades for the performance, topped by an Oscar for best supporting actress, didn’t immediately expand her options. “I played Mother Earth so much that I can probably whip up some moss for you right now,” she said.

These days, however, Ms. Spencer is slipping past limitations, moving into producing offscreen and guiding her onscreen career away from “nurse face” roles. At Christmas, she will appear in a true story so rarely told that she at first assumed it was fiction. “Hidden Figures” is heart-swelling Oscar bait about the African-American female mathematicians — called “computers” (as in: one who computes) — who worked at NASA in civil rights-era Virginia. Ms. Spencer plays Dorothy Vaughan, a supervisor who teaches herself and her black female staff to program the new IBM mainframe computer. (To better understand her character’s engineering genius, Ms. Spencer tried to build and repair a fan throughout filming. It did not go well.)