Detect resolution of X display and change font accordingly
You wrote calls to setq-default twice, with blah-blah-size-34-or-18. Call it just once, with a :size of an if expression that evaluates to 34 or 18.

Put another way, your "then / else" clauses are evaluated for side effects. I'm suggesting to exploit the functional aspect of if, where its return value comes either from the "then" clause or from the "else" clause.