Preheat oven to 300 degrees. Whisk flour, nuts, rosemary, and salt in a large bowl.
Put butter and sugars into the bowl of an electric mixer fitted with the paddle attachment. Mix on medium speed until lightened, about 3 minutes. Mix in vanilla. Reduce speed to low. Add flour mixture; mix until dough comes together and is smooth, about 3 minutes.
Turn out dough onto parchment paper, and pat into a round. Place parchment paper on top; roll into a 12-inch round, 1/4 inch thick. Transfer to a baking sheet; refrigerate until firm, about 30 minutes.
Cut out cookies using various sizes of heart-shape cutters (1/2 inch to 3 inches); transfer to parchment-lined baking sheets. (Keep same-size cookies on same sheet.) Roll scraps; cut out. Gently press raw sugar onto edges of cookies.
Bake until just golden, 15 to 18 minutes. Let cool on sheets on wire racks. Cookies can be stored in an airtight container at room temperature up to 5 days.