Let me explain what I'm supposed to do first.
My assignment is to take text from a dictionary entry and display it in my client area. This dictionary entry contains characters like \ " ' and text that's written in Greek. There is an image in the upper left hand corner of the word that I'm defining and the text is supposed to flow around this image. Also, when I hover my mouse over any single word, it changes from black to red and returns to black when my mouse does not hover over it.
The way we were told to implement the text part was to construct a class containing a reference to a String and several fields, which are pretty much flags to indicate certain text properties (i.e. m_bold = 1 or 0, m_italic = 1 or 0, etc..). In our main form, we create an array of this class, and initialize the fields. Each string field is a single word from the dictionary entry and the other fields are set based on what the text looks like from the sample dictionary entry we were given. This is so that we can use the Mousemove event to do the color change.
So far, I have almost all of the requirements working. But I'm having some minor, text related problems that I can't seem to get my head around, which are part of the grading criteria. Here are my questions:
1) We were told to use the e.Graphics.MeasureString(...) method to figure out the position of the next word. The way I did this was that if my text was, say, "Hello World" (w/o the quotes), I would first draw "Hello", then call the MeasureString method, take the Width, and add that to the x position of the beginning of the word "Hello" to get the coordinates for the next word, "World". The problem is, MeasureString() tends to return a Width with some padding. My dictionary entry contains some words that have no spacing between them and when I draw all the text out, there's spacing between all of the words. How do I get rid of this padding? I tried subtracting the width a little before drawing, but that causes a bit of overlap sometimes.
2) If I have text of different sizes (i.e. 10 pt and 16 pt), how do I align their baselines so that the characters are not at the top of their cells?