The answer by Jean-Paul Calderone correctly specified how much population the food can support. I'm not focusing on that at all in my answer; I'm only focusing on energy.
This answer, however, did not take into account energy aspects, only mentioning than an unlimited supply of natural gas is needed. That is most certainly false: methane can be created with only energy, carbon dioxide and water as the source materials. As we all know, there is no shortage of carbon dioxide.
Carbon dioxide can be recycled in industrial processes, and natural gas can be synthetically created using water electrolysis and Sabatier reaction.
Thus, the only problem is how much input energy we can harness. Solar radiation is 1000 W / square meter on non-cloudy days, and Earth receives 1.27*10^14 square meters of radiation minus clouds. If we could harness only 1% of the radiation before clouds (seems doable), we have 1275 terawatts of radiation. This is 11166905 terawatt hours per year.
US primary energy use is 88000 kWh / year / capita (source). Thus, it is possible to support 127 billion people having US lifestyle.
More likely, the answer would be larger, as 30% of Earth is land, cloudy days are perhaps 50% of the days and we could perfectly well use 15% of landmass for solar power and the rest 85% for other purposes. Thus, 0.30 * 0.50 * 0.15 = 0.0225, or 2.25%, larger than 1%.
So, even with solar radiation as the only energy source, a US lifestyle is possible for hundreds of billions of people.
If we want to support a larger number of people, e.g. thousands of billions of people all having a western lifestyle, we cannot do it with solar power only, but there is always the nuclear option. Once-through fission cycle will quickly lead to exhaustion of cheap uranium. However, it is possible to build breeder reactors that use uranium 50-100 times more efficiently than current reactors.
With such breeder reactors, at the current consumption level, uranium will last for billions of years (source).
Multiply the population having a western lifestyle by 1000, and uranium is still enough for millions of years. Some could consider it unsustainable if the human population runs out of energy in millions years. Some other could consider it sustainable enough.
I'm not saying these breeder reactors are the optimal solution. Growth to population of 127 billion seems unlikely, so it is likely that exponentially reducing solar power production costs mean solar power will be enough and needs not be supplemented by nuclear.
Also, with a population of 1000 billion, all using nuclear power to have a western lifestyle, the waste heat would be enormous and could somewhat heat up the planet directly.
Some might protest that solar can be generated only when sun shines and there are not enough battery minerals for storing that electricity for cloudy days. The most likely solution to this problem is power-to-gas, where solar power is stored as synthetic hydrogen or synthetic methane (along with carbon dioxide recycling, of course, if methane is selected instead of hydrogen). Enormous amounts of energy can be stored as gas, with no need for battery minerals.