I have released an new version of the TextSuite library. This versions only contains some small fixes and one feature of the latest developer version.
- Bugfix: The parameters TS_BLOCK_OFFSET_X and TS_BLOCK_OFFSET_Y were swapped. X affected vertical offset and Y the horizontal.
- Now the library is compatible with Delphi 2009 and 2010.
- I've added the parameter TS_CREATOR_ADD_RESIZING_BORDER. This parameter will add an border to all new created chars after als post prcessings done. This border allows you to resize the chars inside of OpenGL. This may usefull if you want to resize fonts via glScale or you are using them in 3D.
Dear Steffen, I am
Dear Steffen,
I am wondering if there is some way to use TextSuite to input text with discrete superscript and subscript letters?
TextSuite can output superscript and subscript letters, as shown in one of the "Formula" demos. Now, say that I have a scene which I use OpenGL/TextSuite to draw. I would like to allow user to click at certain positions. Then a "simulated" text edit with a bounding box is shown. Then the user can type in text with discrete superscript and subscript letters. Could you help to suggest how can I simulate a text edit which allows user to input discrete superscript and subscript letters using TextSuite?
If I didn't make my situation clear, please tell me so that I may explain more! Thank you very much for your time!
Best wishes,
Xichen
Sample picture and related
Sample picture and related comments:
The sample picture can be viewed at:
http://i770.photobucket.com/albums/xx349/jiucenglou/chemdraw_textsuite.png
or downloaded at:
http://uploadmirrors.com/download/NNK5TECR/chemdraw_textsuite_0.png
The application used in the sample picture is ChemDraw. It seems that ChemDraw used its own simulated Text Edit. Consequently, it used its own properties to denote superscript and subscript, which is nothing related to the Rich Text Format. The XML content shown in the above picture can be downloaded at:
http://uploadmirrors.com/download/0GPJEAUU/chemdraw_textsuite.cdxml
I am wondering how could I simulate this kind of Text Edit using TextSuite? (I plan to make a "Simple diagram utility". By clicking and add caption and values, people can add entities. The values of entities are then used to draw energy diagram used in chemistry literature.)
Hello Xichen. I think you
Hello Xichen.
I think you have to do this by yourself. The library has no help in this case. But the library also won't block this. To combine subscript and superscript you need to use three different fonts. The super and subscript fonts needs to be an bit smaller and an offset done with baselineoffset. To draw these texts you can use easily the blockmode. But in the blockmode you can't controll any of the text. So i think the best way is to use the singlelinemode and construct the text by yourself. You have to store informations about the text. The user typed an word and the he switched to subscript and typed an other word. You have to store the informations what the user has done. For example your structs (or whatever you want) contains: (normal) 'Sample'#32 (subscript) 'subscript'. If you wants to draw your text you activate the Font and draw the text. For the next word you hav to query the length of the part and add them to your offset.
To draw an carret you have to save the position of the carret in chars inside your edit. Means the carret is after the char number 12. To calculate the position of the char you have to query the length of the whole parts before the carret. If the carret is inside an part you have two different ways. Create an text they only contains all chars until the carret position and query the length of them. Or you query the advance of every char and add them to you offset. Avoids text creation but results in more library calls. At the calculated position you can draw your carret. Thats "all".
To support mouseclicks you have to do somethink like before. Test in which textblock the user clicked and then test which char is below. But for this quering every single char is better than creating many texts they only one char longer that the previous. You should consider this in your plans for the future of your edit.
Only chance to optimize is to cache calculated values of the blocks/chars. To avoid quering always the same values from the library. It should be faster if you store this directly in your structs.
Greetings
Dear Steffen, Thank you
Dear Steffen,
Thank you very much for your knowledgeable instructions! I will try and see if I can get it done.
Merry Christmas!
How can I enter superscript and subscript at the same place
Dear Steffen,
I am wondering if there is some way to use TextSuite to output superscript and subscript at the same place? I've uploaded two pictures if I didn't make my question clear. Thank you very much!
The superscript and subscript are at the same space, made by MathType.
http://i770.photobucket.com/albums/xx349/jiucenglou/sup_sub_same_space.gif
The superscript and subscript are adjacent, made by most other software.
http://i770.photobucket.com/albums/xx349/jiucenglou/sup_sub_adjacent_spa...
Best wishes,
Xichen
Hello Xichen. For super or
Hello Xichen.
For super or subscript you need additional fonts. They should have smaller fontsize and they must use the parameter TS_FONT_BASELINE_OFFSET to move the baseline to the top or to the bottom. Simple set them after the creation. It will apply to the whole font.
There is no direct way to do print text like mathlab. You always has to do some handwork. In Multilinemode it's not possible to create some results like mathlab. Because all text will printed after another.
But in the singleline mode it should possible to construct them. You has to print you "BD" and query the width of them. After this you translate the opengl coord. And then you can print the text with you superscript font and the text with your subscript font. If you want to print text after this you has to query both widthes and translate opengl with the greater one. Then you can bind the normal font and print more text. I think that's the only possible way to print text like this with the TextSuite.
Greetings Steffen
Dear Steffen, I thought I
Dear Steffen,
I thought I have thanked for your helpful comments but apparently I didn't!! I am sincerely sorry!!
Best wishes,
Xichen Li
Could I get the vertex and texture array data from TextSuite and
Could I get the vertex and texture array data from TextSuite and draw quite a lot texts using one glDrawElements call?
Say I have 1000 circles now. The goal is to output these 1000 circles, and different texts centered in each circle. Because the efficient way to output large amount of circles would be the vertex array (or vertex buffer object), I am wondering whether I could get the vertex array data of the outputted texts and output them at one batch, instead of calling tsTextOut 1000 times?
Thank you very much for your time!
It seems that in the
It seems that in the procedure TtsRendererOpenGL.DrawChar, essentially the following OpenGL calls produce one Char:
glBegin(GL_QUADS);
glTexCoord2fv(@TexCoords[0]);
glVertex2fv(@TempVertex[0]);
glTexCoord2fv(@TexCoords[1]);
glVertex2fv(@TempVertex[1]);
glTexCoord2fv(@TexCoords[2]);
glVertex2fv(@TempVertex[2]);
glTexCoord2fv(@TexCoords[3]);
glVertex2fv(@TempVertex[3]);
glEnd;
, and in the procedure TtsRenderer.DrawLine, there is looped calls to the above TtsRendererOpenGL.DrawChar.
I am wondering whether one could "accumulate" the above vertex/texture array data (and do only one glDrawElements call per repaint event) with the help of TextSuite?
Yes the function
Yes the function TtsRendererOpenGL.DrawChar draws one single char. This function gets called from DrawLine. But there is no way to get or collect the vertex data in the current structure. But it's not so easy as you think. The chars won't stored in one texture. If you have luck your chars could split over two or more textures. Because the texturespace manager stores the chars whereever enough space is. If it's not enough he will create an new empty texture and use this. So if you plan to use vertexarrays you have to sort the chars of used textures.
In the future i have the plan to support vertext buffer objects. But not in that way you want to do. Only to speed up line output or complete blocks. But not to combine completly different calls.
Maybe you can speedup your code if you use vertex arrays or vertex buffer object for your circles to draw them once and than draw all texts at once. But this won't work if you have overlapping circles. If you want to speed up this much more it's could be better to use an offline font generator. Only create the chars you need in one texture and than you have to draw textured quads. So you have the full control to use vertex arrays for your drawing and so on. The TextSuite was more designed to draw complex text blocks with different fonts/sizes without knowing much from the fonts and the design of fonts.