I have both pepper spray and firearms.

I wouldn't want to face an angry charging bear with pepper spray. I wouldn't want to face an angry charging bear with a firearm. I wouldn't want to face an angry charging bear period. So my first choice would be to avoid the encounter entirely.

If I couldn't avoid the encounter, I would want to engage the bear for the farthest distance away (of course, only AFTER identifying him as an actual threat). That favors a firearm. But you would need to have enough gun for the job, and know the vital areas of a bear in order to shoot effectively. Many people fail in both of these categories. So that would favor pepper spray, which you would instinctively aim at the correct place - the face. Unfortunately, that face would have to be right in YOUR face for the pepper spray to be useful with its limited range.

You are not guaranteed to win no matter which defensive choice you make. Best to avoid playing the game in the first place. If I absolutely had to choose, it would be a rifle. Minimum cartridge choice would be full load .45-70gov. Best of both worlds would be to wrap the pepper spray in bacon and toss it to the bear. While he's munching on it, shoot the can with the .45-70 (idea stolen from the first Jaws movie!)