Sometimes being famous is like attending your own funeral.

Chris Colfer learned as much at the ripe age of 18, when he was cast as the plucky gay countertenor Kurt Hummel on "Glee." Armed with a golden voice and an uncanny ability to cry on cue (his secret: think of eye injuries), Colfer became a poster boy for bullying issues and the show's breakout star.

But back in his hometown of Clovis, things got weird.

"People that I went to school with almost acted as if I had died," Colfer, now 22, said in a recent interview at New York's Trump SoHo hotel. Classmates who once treated him like toxic waste were now bragging on Facebook that they had been best of friends. "I thought, Wow, this must be what someone feels like at their eulogy."

Chris Colfer attends the 17th Annual Screen Actors Guild Awards at the Shrine Auditorium on January 30, 2011. (Kirk McKoy/Los Angeles Times/MCT)
Chris Colfer attends the 17th Annual Screen Actors Guild Awards at the Shrine Auditorium on January 30, 2011. (Kirk McKoy/Los Angeles Times/MCT) (Kirk McKoy)

That old Tom Sawyer fantasy is the basis of "Struck by Lightning," a film that Colfer wrote and stars in. After having its premiere at the Tribeca Film Festival, it was recently released on video on demand and opens in select theaters Jan. 11.

Colfer plays Carson Phillips, a high-school outcast who, in the hope of getting into Northwestern University, blackmails classmates into contributing to his literary magazine. The film is told in flashback: In the first scene, Carson is, indeed, struck by lightning and dies.

Colfer conceived the story when he was 16, well before landing on TV. He first performed it in high school, as a monologue for his speech and debate team.

But the movie isn't just deferred juvenilia. It's part of Colfer's bid to become a multiplatform showbiz hyphenate. In 2011, he signed a two-book deal with Little, Brown. The first book, "The Land of Stories," which came out this summer, is a young-adult adventure novel that upends classic fairy tales, in the manner of Gregory Maguire. (He's at work on a sequel.) He also published a companion book to "Struck by Lightning," written as Carson's journal.

Colfer's literary ambitions, coupled with his piccolo-voiced demeanor, underscore how unconventional his stardom is. Playing a flamboyantly gay TV character means that Colfer has faced a nagging interest in his own sexuality, as well as questions about his long-term casting potential.

But on this front, too, he has broken ground. Though Colfer is reticent about his personal life, he has never denied being gay. In an Entertainment Weekly cover article this summer, "The New Art of Coming Out," the writer Mark Harris contrasted Colfer with slightly older gay celebrities like Neil Patrick Harris and Zachary Quinto, whose coming-out stories, while tellingly understated, were still news.

"There are more and more actors like Chris Colfer, whose transformation from an unknown 19-year-old to a TV star in 2009 was accomplished without any 'coming out' moment at all," Harris wrote. "He was simply out, and therefore didn't have to manage or strategize any revelation once he became famous."

Still, it's possible to see Colfer's diversity of creative outlets as a kind of insurance policy. By writing his own material, he can circumvent casting directors and define his screen persona for himself.

In some cases, that means leaving things vague. His "Struck by Lightning" character is conspicuously asexual. "I wanted everyone to universally be able to be inspired by this character, so I didn't address it," he explained. (In the book version, the subject is acknowledged, if inconclusively: Carson confesses to having a crush on Rachel Maddow.)

While not strictly autobiographical, the story stems from Colfer's fraught upbringing. When he was 7, his younger sister was found to have severe epilepsy. "She'd have these horrid, horrid epileptic fits in the middle of the night," he recalled. Colfer, who craved attention, was now deprived of it. Family friends would inquire about his sister's condition: "It was always, 'So when you grow up, are you going to come up with a cure for your sister?' I would say, 'Nope, I'm going to be an actor!' "

He came to see the unbalanced family dynamic as "an evil curse." Retreating into his imagination, he began writing fairy tales, which formed the basis of "The Land of Stories."

"It's all related to childhood traumas," he said with a laugh.

Things got worse -- as they often do -- in middle school. Colfer transformed from a skinny sixth-grader into a pudgy seventh-grader whose voice hadn't dropped. (It still hasn't, essentially.) Bullies vandalized his locker and defaced his gym clothes. He kept his travails mostly hidden. "I always assumed that my parents were busy with my sister," he said. "They didn't need any woes from me. So I never told them. I've still never told them the extent of what I experienced."

But he did confide in his grandmother. She alerted his parents, who pulled him from school and put him in a home-schooling program for a year and a half.

In the meantime, he kept writing. "Words were the only way I could get people to listen to me without them wondering what was wrong with my voice," he said.

In ninth grade, he transferred to Clovis East High School, which had a strong performing-arts program but also a strict conservative philosophy, fostered by its founding superintendent, Floyd Buchanan, known as Doc. Buchanan enforced an ironclad dress code: no facial piercings, no pro sports jerseys, and boys' hair couldn't reach their collars.

Colfer acted in community theater productions and became president of the school writers club. Not that there was much competition. At the homecoming parade -- this became a scene in "Struck by Lightning" -- he and the club's sole other member piloted a two-person float atop his father's pickup truck. "When we came around the corner, the crowd went dead silent," he recalled. "They felt so sorry for us."

At the same time, he became a speech and debate champion, with Mikendra McCoy as his mentor. (She has a cameo in the film as Carson's science teacher.) Her most enduring maxim, which could double as Kurt Hummel's, was: "As long as you truly own who you are, no one can ever use you against you."

The lesson held true when Colfer was cast in "Glee" in 2009. He originally auditioned for Artie, the paraplegic. But the series' creator, Ryan Murphy, conceived the role of Kurt -- a bully-dodging show queen who gives killer makeovers -- especially for him. At first, Colfer was hesitant about playing a gay character on national TV. "I was very nervous about people in my hometown," he said, recalling how he had seen local church groups campaigning for Proposition 22, a same-sex marriage ban.

He was also skittish about being typecast. "The first thing that was ever written about me was that I was fantastic in 'Glee,' but it would be the last and only thing I ever did," he said.

At first, a part of him believed that. But as the show caught on, the character deepened. In the second season, Murphy introduced a love interest, Blaine Anderson, played by Darren Criss. Kurt and Blaine's tumultuous relationship became one of the show's most nuanced -- and pioneering -- storylines. Last season, they lost their virginity to each other, in a barrier-breaking sex scene that Colfer compared to Maude's abortion.

"When this show comes to an end, that'll be one of the biggest things that stands out," he predicted. He credited Murphy for not relegating Kurt to sassy-sidekick status or painting him as a victim, like many of his TV predecessors. (Ricky from "My So-Called Life" comes to mind.)

Much to the contrary, this season Kurt has graduated from high school and is pursuing his dreams in New York City. Freshly pompadoured, he shares an improbably large Bushwick, Brooklyn, apartment with Rachel (Lea Michele) and interns for a Vogue editor played by Sarah Jessica Parker, in a storyline even more fantastical than Parker's previous series.

The show's recent New York focus has meant shooting on location in Bryant Park and other high-traffic spots, which has drawn gawking crowds. One of the stranger aspects of Colfer's career is his relationship with his young fans, who mob him everywhere he goes. Not long ago, when he tried going to a public movie theater, the resulting hysteria left him with bruises.

None of this is unusual for a tween idol, of course. But Colfer's sexuality makes the situation curious. Surely, Kurt has served as a role model for countless gay teenagers. But the vast majority of his admirers, he said, are girls, who shower him with photo albums and even erotic fan fiction ("more than most of my male co-stars"). Tumblr is rife with fan pages dedicated to Kurt and Blaine (aka Klaine), much like the ones you would find for Bella and Edward of "Twilight."

Certainly, the phenomenon speaks to the ubiquity of gay characters in popular culture, and suggests that Colfer's future as a crossover star is bright. But unlike, say, Robert Pattinson or Zac Efron, he is hardly a typical fantasy boyfriend, since he offers his female fans no logical hope of consummation.

What's in it for them?

"The new generation doesn't see people in black and white anymore," he said. "These girls identify with Kurt, because Kurt had something different about him. Who doesn't have that?"

He added, with a shrug: "I don't know too much about the female brain."

'struck by lightning'

Special screening of film followed by a Q-and-A with Chris Colfer via live satellite

When: 5 p.m. Jan. 6
Where: The Historic Balboa Theatre, 3630 Balboa St., San Francisco.
More info: www.cinemasf.com/balboa