Place sun-dried tomatoes, basil, pine nuts, garlic, and Parmesan cheese in a food processor.
Pulse while slowly drizzling in olive oil until a thick, uniform pesto paste forms.
Spread softened butter evenly on one side of each bread slice.
On the non-buttered side of two slices, spread a generous layer of the sun-dried tomato pesto.
Layer the fontina and shredded Gruyere cheese over the pesto-covered slices.
Top with the remaining bread slices, buttered side facing out.
Preheat a heavy-bottomed skillet or griddle over medium-low heat.
Place sandwiches in the skillet and cook for 4 to 5 minutes per side until the sourdough is golden brown and the cheese is completely melted.
Remove from heat, let rest for 1 minute, slice diagonally, and serve immediately.