String space " "
-
On 31/08/2014 at 05:05, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;---------
Hi folks,I'm trying to add a space to the beginning of a string for drawing inside of a user area, but the spaces added to the beginning of a string to draw seem to be ignored. The string is taken from a line fed into a function that splits the line of text into a series of strings (necessary as I'm colouring the text). Before going into workarounds like off-setting the text's draw, it would be simpler if I could just use the space as what they are meant for - a space! I've tried the following, but neither seem to work:
String str = ""; str += " "; // doesn't work str += "\40" // doesn't work (ASCI Oct character table equivalent)
Depending on the line that's fed to the function, there could be any number of spaces preceding the next bit of visible text. Is there a way to force the string variable to accept a space, or spaces, in the beginning? Or, is there a way to do this using the operator and/or cstring-related steps (I'm not really familiar with working on strings at this level - but am happy to learn and use them!)?
Cheers,
WP.
-
On 31/08/2014 at 17:43, xxxxxxxx wrote:
Ok, further testing suggests it might be an issue with the way the loop is running over the string where the space is counted as a character but not added to anything. Will update when I know a bit more.
WP.
-
On 01/09/2014 at 07:25, xxxxxxxx wrote:
Give this a shot:
//This code adds empty spaces to the front of a string String text = "Hello"; String space = " "; for(LONG i=0; i<5; i++) { String combined = space.operator+=(space); } String combined = space.operator+=(text); GePrint(combined);
-ScottA
-
On 01/09/2014 at 22:23, xxxxxxxx wrote:
Thanks again Scott,
I think the problem was indeed what was mentioned in the second post. The coloured text seems to be working now.
One thing I'll add, just for anyone else running test prints with spaces etc, is I've been testing prints with the "|" character in front of the space text. That way I can see there's a gap between the "|" and the character after the space. So something like the following:
String str = " space"; GePrint("|" + str); // which should then print "| space"
Just seems to help see the space a little easier.
WP.
-
On 02/09/2014 at 01:35, xxxxxxxx wrote:
Just while I'm on drawing fonts, is there an example somewhere for changing font attributes (e.g. size and font type) when drawing into a user area? I can only find font draws related to clip maps or description elements - or can the same functions be used in user area draws?
WP.