Text formatting
-
I'm trying to add spacing to the beginning of some text so that I can put small symbols before specific lines of text. The size of the symbols is always the same, 10x10 pixels, however the number of symbols can range from none to half a dozen. The problem I'm running in to is figuring out the number of spaces to indent the text. Normally I'd simply move the bounding box over by the size of the bullets, but in this case, the next line of text needs to wrap under the graphics I'm inserting, so moving the bounding box cuts down on the space available for text. Right now I'm just adding in 3 * the number of spaces as there are symbols in hopes of getting close, but it's a bit off. I've tried using MeasureString to get the size of a space, then adding enough spaces to move the text, but it comes out too little with only 1 symbol and not nearly enough by the time there are 4 or more symbols. Any suggestions?
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
-
I'm trying to add spacing to the beginning of some text so that I can put small symbols before specific lines of text. The size of the symbols is always the same, 10x10 pixels, however the number of symbols can range from none to half a dozen. The problem I'm running in to is figuring out the number of spaces to indent the text. Normally I'd simply move the bounding box over by the size of the bullets, but in this case, the next line of text needs to wrap under the graphics I'm inserting, so moving the bounding box cuts down on the space available for text. Right now I'm just adding in 3 * the number of spaces as there are symbols in hopes of getting close, but it's a bit off. I've tried using MeasureString to get the size of a space, then adding enough spaces to move the text, but it comes out too little with only 1 symbol and not nearly enough by the time there are 4 or more symbols. Any suggestions?
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
Why not always start the text with a symbol? Use a blank one instead of your spaces and off you go. I don't think spaces are a good way to go; the width of a space can vary depending on the font - start a reply to this and compare the width of a space in the "Subject" and "Text" areas. The font size is the same, but the space width is different.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
Why not always start the text with a symbol? Use a blank one instead of your spaces and off you go. I don't think spaces are a good way to go; the width of a space can vary depending on the font - start a reply to this and compare the width of a space in the "Subject" and "Text" areas. The font size is the same, but the space width is different.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
That's why I was using measurestring to check the size of the space in whatever font was being used at that moment. As for always using a symbol, that would be simple, except the number of symbols changes. What would be nice is if there were a way to indent text within a bounding box, by a set number of pixels. Just like in a text editor where if you go to the beginning of a paragraph and insert tab, everything indents and the word wrap updates to fit each following line. The only other thing I've thought of so far would be doing the word wrap manually by measuring each line and breaking up the string until it fit. I've just hoped to avoid that since it's going to involve rounding between lines, making the line spacing squirrely.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
-
That's why I was using measurestring to check the size of the space in whatever font was being used at that moment. As for always using a symbol, that would be simple, except the number of symbols changes. What would be nice is if there were a way to indent text within a bounding box, by a set number of pixels. Just like in a text editor where if you go to the beginning of a paragraph and insert tab, everything indents and the word wrap updates to fit each following line. The only other thing I've thought of so far would be doing the word wrap manually by measuring each line and breaking up the string until it fit. I've just hoped to avoid that since it's going to involve rounding between lines, making the line spacing squirrely.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
But if your symbols are always the same size (as you said) just use the appropriate number of blank symbols. You cannot guarentee to get the same size with spaces - there may not be a neat multiple to ten, twenty and so on pixels. Avoid manual word wrap - I had to do it yonks ago (pre windows) and it is a PITA.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
-
But if your symbols are always the same size (as you said) just use the appropriate number of blank symbols. You cannot guarentee to get the same size with spaces - there may not be a neat multiple to ten, twenty and so on pixels. Avoid manual word wrap - I had to do it yonks ago (pre windows) and it is a PITA.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
Each Symbol is the same size, however if there's only 1 symbol and I leave room for 6 of them, then I've lost half of that line of text. The print out is about 2.25" x 2.25" a little smaller than half a playing card. So each bit of space is a premium.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
-
But if your symbols are always the same size (as you said) just use the appropriate number of blank symbols. You cannot guarentee to get the same size with spaces - there may not be a neat multiple to ten, twenty and so on pixels. Avoid manual word wrap - I had to do it yonks ago (pre windows) and it is a PITA.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones
Sadly, doing my own word wrap ended up being the solution. For now it's only the first line, I'm going to end up having to do the rest of it though. There are going to end up being symbols in the middle of the text later on. The bugger I'm just realizing is that I can't even cheat and make my own font since the text around the symbols would be in a different (varying size) font, requiring separate calls to Drawstring. On the bright side, the output is a printed label, so at least I don't have to worry about keeping up a frame rate.
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.