- TTF2Vector := TTTFToVectorConverter.Create(DGLForm);
- TTF2Vector.Font := TFont.Create();
- TTF2Vector.Font.Name := 'Arial';
- // Setup spline precision (1 min, 100 max)
- TTF2Vector.Precision := 1;
DGL https://delphigl.com/forum/ |
|
Vector Font (Freetype for pascal?) https://delphigl.com/forum/viewtopic.php?f=19&t=7761 |
Seite 1 von 3 |
Autor: | noeska [ Di Aug 19, 2008 18:13 ] |
Betreff des Beitrags: | Vector Font (Freetype for pascal?) |
Is it possible to use vector fonts with opengl? I know of wgl, but that is windows only. Now there is also freetype2. It is supposed to be able to give access to the vector data of the glyph. That give me 3 questions: 1. Is there a delphi/pascal unit for freetype2? 2. How does rendering a glyph work? Bezier->Polygon->Triangulate? 3. Has someone else already done the hard work? With knowing how point 2 works. The font can also be save in like a milkshape ascii format. So the original font is not needed. |
Autor: | Traude [ Di Aug 19, 2008 19:34 ] |
Betreff des Beitrags: | |
Hallo Noeska, Yes, there is already some code: A project named "TextSuite" by Lossy eX: http://www.delphigl.com/forum/viewtopic.php?t=4859 and I think that he uses also Freetype, but I'm not quite sure A font object named "TStdFont" that I have written myself, to be found here: http://glpasgui.bplaced.net/ And last not least SDL_TTF uses Freetype, as far as I know Traude |
Autor: | Lossy eX [ Di Aug 19, 2008 21:49 ] |
Betreff des Beitrags: | |
But in the TextSuite Library i only use Bitmap Chars. And at this moment the library dosn't support FreeType2. I startet to translate an header for it but the librarys header are around 1MB only interface definition (with much comments but it's still 1MB). I mean FreeType supports reading of raw data. So you can use it with some splines and you will get an "simple" polygon. This you must tesslate into triangles and add an height and the char is done. The difficult part is got the polygon data. In the Windows API there is an function which returns the data. But in FreeType im not 100 percently sure. But it should possible. If i dont forget it i can take an look in the header. May i can find some usefull functions. Anyway i dont know any other polygon fonts for multiple platforms. Only the WGL functions. |
Autor: | Lossy eX [ Mi Aug 20, 2008 13:27 ] |
Betreff des Beitrags: | |
I have taken an short look in the header and if you load an glyph you normally get an FT_OutlineGlyph. And this allready contains the coordinates from the Outlines (it's possible to get more than one contour in one glyph). To get an Bitmap these outline must be rendered. But this isn't necessary for you. |
Autor: | noeska [ Mi Aug 20, 2008 19:03 ] |
Betreff des Beitrags: | |
As always torry is verry helpful as it provides a ttf2vector component. Now this solutions is also windows only. But gives access to the font coords. And allowed me to render with GL_LINES. http://www.torry.net/quicksearchd.php?S ... &Title=Yes so with this i should also be able to extrude etc. I have yet to test it with my experimental 2dpolygon render to see if it can render it solid also, but i expect no problems there. It just needs a good cleanup. And more importantly it is possible to save the font coords. So it is possible to render a font that is not available on the end user system. The ony thing to worry about is precission. Only the font generator application would only run on windows only. But for linux support freetype(2) is really needed. @Lossy eX: where can i get the unit? And can you explain FT_OutlineGlyph a bit more? Example: Init Code:
Render Code:
|
Autor: | Traude [ Do Aug 21, 2008 00:03 ] |
Betreff des Beitrags: | |
Hallo Noeska, But this would mean to implement it two times. Do you know OGLFT: http://oglft.sourceforge.net/ ? On this site you can see what freetype can do for you (b.t.w. OGLFT is built in Blender, too). You can find FT_OutlineGlyph etc. in the FreeType API reference: FT_OutlineGlyph: http://www.freetype.org/freetype2/docs/reference/ft2-glyph_management.html FT_Outline(included in FT_OutlineGlyph): http://www.freetype.org/freetype2/docs/reference/ft2-outline_processing.html#FT_Outline FT_Vector(included in FT_Outline): http://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Vector etc. I did not use FT_OutlineGlyph in my Freetype font object because I wrote a texture font and therefore did not need it. But if you take a look at it you can see a lot of how to handle the freetype library inside this object (it is also a pascal header for Freetype2.DLL but does not provide all Freetype functionality). |
Autor: | Lossy eX [ Do Aug 21, 2008 08:39 ] |
Betreff des Beitrags: | |
Zitat: @Lossy eX: where can i get the unit? At this moment? Nowhere. ![]() http://files.opengl24.de/header/FreeType2_DEV.zip (55kb) In the package there is an simple sample. This works under windows. I think you will understand it if you see it. After FT_Get_Glyph the glyph was copied into the variable glyph. And this mostly should be an outline glyph. For me i need to convert it to an bitmap. Same as Traude. But i actually dosn't use it. Zitat: And can you explain FT_OutlineGlyph a bit more?
I dont know much about the outlines. I have seen it during the header conversion. But the outlines only containing contours. But if you have holes inside an char they have an extra contour. But this contours must be subtracted from the main contour (this will controlled by the outline flag). For example in the Arial font. The char '1' dont have any holes so contours normally = 1. 'a' habe one hole so contours = 2. And 'B' have 2 holes so contours = 3. But if you have funny fonts this values can be different. PS: Don't wonder about the crazy sizes in FreeType. They work with an 26dot6 integer values. The last 6 bits are decimal places. And the bit 7 means the value 1 in normal integer values. |
Autor: | noeska [ Do Aug 21, 2008 20:14 ] |
Betreff des Beitrags: | |
I am using glu tesselation now. And with good results. Only how do i implement it as part of an class? gluTessCallback(tess, GLU_TESS_BEGIN, @tessBeginCB); @tessBeginCB cannot be part of the class and has to be an real procedure with stdcall. But i need to access variable used it the class with these. |
Autor: | Lossy eX [ Fr Aug 22, 2008 09:00 ] |
Betreff des Beitrags: | |
The glu callback always has to be single functions. For windows with stdcall as calling convetion and under linux with cdecl. Thats important. So you can't use classmethods. But if i saw it right (im not sure) it's possible to pass an custom data pointer to the function gluTessBeginPolygon. This data will be sent via the callback GLU_TESS_BEGIN_DATA. But the parameter won't be sent to every call. So you have to cache these value. But in this fact you also can cache this before you tesslate. The result is the same. For an example of the strange description. Code:
I think there is no other way to handle it. BUT. This Method is 100% not threadsafe! If it should possible to use it from different threads you can use threadvars instead of var. So every thread has it's own variable. Or and you can (must) use some technics to make sure that 2 threads dont use it at the same time. I mean TCriticalSection. If your using var you need 1 CriticalSection. If you are using threadvar the critical section also should be an threadvar. But in this fact the initialization of the CriticalSection may be some difficulty. Because linux dosn't support the initialization part of Pascal. |
Autor: | noeska [ Fr Aug 22, 2008 11:56 ] |
Betreff des Beitrags: | |
You classvar method is cleaner then my solution where i made a procedurevar for each command. Both are not threadsave. |
Autor: | noeska [ Fr Aug 22, 2008 16:33 ] |
Betreff des Beitrags: | |
My TPolygon Class: (MPL license) Code:
|
Autor: | noeska [ Fr Aug 22, 2008 18:29 ] |
Betreff des Beitrags: | |
My PolygonFont class: (MPL license) Needs to be improved. Also only does a..z lowercase only. And needs freetype integration. Code:
|
Autor: | bero [ Fr Aug 22, 2008 22:14 ] | ||
Betreff des Beitrags: | |||
Here http://bero.freqvibez.net/BeRoVectorFont.zip (or at post attachment) is my native own typetype font loader with pas src, but please give credits! I'm using it in my own complete-SVG-compliant rendering engine and vector artist software.
|
Autor: | noeska [ Sa Aug 23, 2008 10:54 ] |
Betreff des Beitrags: | |
You have a native pascal ttf reader. No need for freetype2 or even windows? Nice work. So with GetCommand i can set a char or even a text and i get back an array of fontcommands. So that still has to be converted to strokes to get a flat font outline. My goal is to get a opengl accelerated vector gui. svg/xaml is not a goal for me. |
Autor: | noeska [ Mo Aug 25, 2008 13:20 ] | ||
Betreff des Beitrags: | |||
I am getting a bug when rendering outlines (see attached image). It only happens with characters that consist of multiple parts like the i . As i use the outlines also for extruding that also fails. So how do i detect the beginning of a new part? Does the font-data give info on this?
|
Seite 1 von 3 | Alle Zeiten sind UTC + 1 Stunde |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |