The 30-year-old Swiss maestro has not played since losing to Andy Roddick at the Sony Ericsson Open at the end of March. He said he needed some time away from tennis to recharge his batteries and rid himself of one or two niggling injuries.
Federer has played some of his best tennis in years in winning three titles this year, including the Indian Wells Masters event, but knows that challenging Rafa Nadal on the Spaniard's favoured clay and stealing his French Open crown in Paris starting at the end of this month will be a tall order.
"I feel good about my chances of playing well in the next few months," the world number three told a news conference at the Madrid Open on Sunday.
"But then again I am coming back on clay and Rafa has been so dominant on this surface for so many years so I know the task ahead of me," added the 16-times grand slam singles champion.
Federer said he had needed time out after an intense start to the year when he played 23 matches and lost just three, reaching the semi-finals of the Australian Open before falling to Nadal. He won events in Rotterdam and Dubai to add to his success in Indian Wells.
He also had a busy end to 2011, triumphing at the World Tour finals in London in November after victories at the Paris Masters and his home event in Basel.
The rest was vital, said Federer
"I needed it because I did play so, so much and this break was also looking ahead to what's to come and there's a lot on my plate and want to be fresh in my mind and fit in my body for those big goals ahead," he added.
"It was more about relaxing my body because I had been playing with some niggling injuries over a few weeks, or a few months almost, and I am happy they went away.
"It was just to get away from tennis for a while really, get away from the craziness that surrounds it, the matches and the press and all that stuff.
"So that was nice to just recharge the batteries, that was the key during this break."
If Federer can leapfrog number two Nadal and topple Djokovic he would equal Pete Sampras's record of 286 weeks at the top of the rankings and the Swiss said he was in a "pretty good position" to do it over the coming months.
"All of a sudden if you do win a grand slam again you have a shot and if I do I'll probably be extremely close to world number one," he said.
"Then again - easier said than done. I know what it takes to win a grand slam. It's hard, it's always been hard.
"It's still far away for me and my focus is on my next match here on Wednesday.
"But it is a dream for me this year try to achieve that again. I'll try to chase that as hard as I can and see if it's possible. If not it's no problem and I'll just try to win tournaments which is a thrill in itself."
Federer, who has a bye into the second round, begins his Madrid Open campaign on Wednesday against the winner of the first-round match between fast-rising Canadian Milos Raonic and former world number three David Nalbandian of Argentina.