Olaniyan Adefumi arrived at Fern Rock to hawk newspapers at the usual time, 4:30 a.m. Wednesday, and between trains he talked about physics. And statistics. And poetry, lots of poetry.

"Away from the music box of noise," begins a new composition about a trip to the Shore. "With dancing little children. . . ."

The 52-year-old works for The Inquirer and the Philadelphia Daily News in a program that provides piecework for those down on their luck.

His luck is about to change.

For most of the last decade, the former assistant librarian has been fighting the city in court, contending he was forced to retire after a serious bicycle accident left him impaired.

He lost his house. He's had to split his time between homeless shelters and relatives' places. During that time, he managed to get his degree in biology, commuting 40 miles a day to Cheyney University by bike.

His lawsuits have faltered. In his latest case, he represents himself, and the federal magistrate hearing the matter has told the parties she's inclined to dismiss.

But the magistrate has asked the city to do something almost unheard of, something that feels right this time of year.

She's told the city's lawyers to find the man a house.

Adefumi is short and wiry, with the build of a marathoner and the patience of a mathematician. His beard shows more salt than pepper. His eyes are wide, his smile easy. He exudes warmth.

"So humble and such a wonderful, friendly spirit," says Carly Ianuzzi, a Temple senior who volunteers with LIFT-Philadelphia, a poverty-fighting program, and who has helped Adefumi since the summer.

Born Earl Redding, Adefumi spent his early years in South Philadelphia, in the Hawthorne Square housing project. "I called it 13th and Crime," Adefumi said.

After Benjamin Franklin High, he took three years to get a community college degree, then started at Temple, where he studied economics but didn't graduate.

He worked a variety of jobs - cashier, security guard, insurance clerk - before moving to the Free Library in 1988. He sorted books at the Kingsessing and Mantua Branches and was promoted to supervisor in 1995.

He'd already begun his epic bike rides, cycling thousands of miles to raise awareness for education. An Inquirer column about one of his treks dubbed him North Philadelphia's Don Quixote.

By then he'd changed his name. In Yoruba, "Olaniyan" means "honor surrounds me." Back at the library, he was having some trouble with colleagues.

Adefumi contended in a 2003 suit that an African American female coworker told him black men were lazy and didn't provide for their families.

When the library's management asked him to document his complaints, he wrote what the judge described as "an aggressively worded and often incoherent seven-page, single-spaced manifesto" titled "Harassment."

His tone led management to have him evaluated by a city psychiatrist, who in 1997 found him fit to work at the library.

That September he was cycling at night through Baton Rouge, La., trying to raise money for scholarships, when a truck hit him. He went into a coma. After Adefumi returned home, to Temple University Hospital, a neurosurgeon wrote that he was uncertain whether Adefumi would be able to work.

But within a half-year, Adefumi had fully recovered, he told the court. A city psychiatrist disagreed, finding "severe cognitive impairment." Adefumi wished the doctor had examined him in person.

The case was dismissed, as was a subsequent suit that repeated his complaint about his forced retirement. But Adefumi found a supporter for his third go-round in federal Magistrate Judge Carol Sandra Moore Wells.

Wells has issued no order and would not comment on the case. But according to Nicole Morris, a deputy city solicitor, and Allen Pan, a University of Pennsylvania law student who works with the homeless, Wells was impressed at a Dec. 3 hearing by all that Adefumi had done to right himself.

Rather than apply for disability payments, he worked when he could. After getting his newspaper job in the fall, Adefumi moved out of Our Brother's Place and rented a room at 15th and Erie, where he is preparing for podiatry school entrance exams. He's also applying for substitute teaching jobs.

"He's a hardworking individual who's had tough times," Morris said. "He's really pulled himself up. The court has asked us to find a house that he can purchase, that he could rehab for himself, and that is what we are going to do."

She said the judge felt "this is what fairness dictates."

Adefumi sounded overwhelmed by the prospect of having his own place.

"Wow," he said, and talked about not having to share a bathroom, not having to meet a curfew, not worrying about that music box of noise.

Contact Daniel Rubin at 215-854-5917 or drubin@phillynews.com.