There are dialogues that are written and some that are written especially for stars. And
Girish Dhamija who has written some wonderful dialogues in films like Dushman, Zakhm, Sangharsh, Fareb, Gangster, 1920 etc., says, "Dialogue writers are aware of the power that some stars wield.
So yes, many a time dialogues are written keeping the star in mind. But, when there are newcomers, then dialogues have to be written intelligently.
Like in Gangster, when I was writing for Shiney Ahuja, Emraan Hashmi etc I knew that I'd have to give them effective lines, but ones that are not too long. However, in Zakhm though
Ajay Devgn was a big star and he's superb at dialogue delivery, his character in the film was understated. So when there's a scene where his mother dies and he goes to break this news to his brother, I could have made him say a lengthy dialogue filled with emotion! But after discussing with Mahesh Bhatt we decided that he should just walk up to his brother, who is reading a holy book, and say tow words 'Maa gayi.' His silence at his mother's death bed, his silence after he breaks the news - that was golden."
Speaking more about the art of dialogue writing, Girish Dhamija says, "Dialogues should gel with character! I'll give you an example. While watching a film, somebody in the audience says, 'Kya set lagaya hai yaar' it's bad news for the art director! Because, the set, which is a home, palace, college whatever was meant to look real. Similarly, when a character in a film says a dialogue, often he who immortalizes the lines and the character. And that is the victory of the dialogue writer."