The hinges are adjustable, along with the striker pin for the door.
From the damage in the pic, I would say that you need to adjust the windshield frame back a little, which will make the hard top line up better with the door. Doesn't have to be very much, 1/8" to a 1/4" will make a world of difference.
'87 YJ, 4.2L built and bored, 8.5" of lift, 8.8 rear, AX15/NP 231, Tom Woods drive shafts, Flat fenders, 12,000LB winch, Custom bumpers, Rattle can paint job. Never completed...