|
Post by vovchik on Jun 19, 2016 13:02:02 GMT 1
Dear guys, I have made some headway in extracting glyphs from TTFs using STB_TTF. In theory, once we convert these simple lines (a kind of proof of concept) into quadratic beziers, we can create SVG text on the fly, without having to rely on my premade and large svg glyph path tables. All ideas, mods and enhancements welcome. With kind regards, vovchik Attachments:
ttf-vertex.tar.gz (12.64 KB)
|
|
|
Post by vovchik on Jun 20, 2016 16:22:10 GMT 1
Dear all, Making good progress with the rendering of TTF quadratic beziers. The next step is to spit out SVG paths, since we can now get a reasonable representation of any TTF char. Useful data are dumped to the terminal. With kind regards, vovchik PS. With this little prog, you can really see the "dirty laundry" in font design. Look at the zero character (ASCII 48). The outer left side of the '0' is drawn using three vertices (great and economical). The right side has 12 or so vertices. And the inside is ridiculous and could also have been done with 3 x 2 vertices. The letter 'O' (ASCII 79) is much better, but still inconsistent and a bit long-winded. . Cheers!
|
|
|
Post by vovchik on Jun 21, 2016 10:34:48 GMT 1
Dear all, Well, here it is. This little program extracts glyphs from a TTF, displays as canvas lines and quadratic beziers and also generates an SVG (gold and red char at bottom). We can now generate SVG font text on the fly, without the need for prefabricated SVG glyph paths. I am not displeased this morning. With kind regards, vovchik PS. UPDATED since the SVG ">" char was not showing because of ch_name=">" in path string. Fixed.
|
|
|
Post by anurup on Jun 21, 2016 17:53:30 GMT 1
@peter : My apologies for the delay in getting back. SDL segfaults without the canvas starting up even. I do not know whether this is due to the lack of any libraries on my part... vovchik : Sorry for stepping on your glyph's toes!
|
|
|
Post by basica on Jun 21, 2016 21:54:35 GMT 1
vovchik, ttf-vertex-bezier-svg.bac looks very interesting and I've just downloaded it. I'll need about a week to really understand everything, but when you say "you're not displeased", it's probably really quite good Thanks and regards, basica
|
|
|
Post by vovchik on Jun 22, 2016 19:00:20 GMT 1
Dear basica,
I hope it is working for you. Now we need to write a routine that will aggregate the svg paths and, on the basis of each path's ch_width, do the appropriate translate(xxxx, 0) statements for the next char's xpos. Then we can display svg strings pretty easily, and use gradients and other effects.
With kind regards, vovchik
|
|
|
Post by vovchik on Jun 23, 2016 20:09:16 GMT 1
Dear basica, I fixed up some little problems in the generated svg (translate(xxx,yyy)) and also included a demo with ttf loading. Now, just to fix up the concatenation of paths - which is the next step. With kind regards, vovchik UPDATED: Had error in the BLOAD version. Attachments:ttf-vertex-svg.tar.gz (30.64 KB)
|
|
|
Post by basica on Jun 24, 2016 23:49:39 GMT 1
vovchik,
The first, "ttf-vertex-bezier-svg.bac" compiles and runs nicely.
The latest, "ttf-vertex-svg.tar.gz" gives me segfaults and also seems to be missing the file "garcyr_ttf.h".
Regards, basica
|
|
|
Post by vovchik on Jun 25, 2016 8:28:35 GMT 1
Dear basica, Thanks for testing. Bad me! There was indeed an error in the BLOAD version, which is supposed to load steamerregular.ttf. Fixed, I hope (archive above). With kind regards, vovchik
|
|
|
Post by Pjot on Jun 25, 2016 12:50:32 GMT 1
Hi vovchik, Very interesting stuff! All works fine on my system. Thanks Peter
|
|
|
Post by basica on Jun 25, 2016 15:01:42 GMT 1
vovchik,
Smooth.. All working nicely. Thanks.
Great presentation of concept.
Regards, basica
|
|
|
Post by alexfish on Jun 26, 2016 22:05:20 GMT 1
Hi Vovchik
most of the fonts are working until ::
Letter: � ASCII: 138 Array index: 109 Vertices: 0 advanceWidth: 789 leftSideBearing: 24
<svg width='150' height='150' viewBox='0 0 650 650' transform='translate(0, 0)' > <path ch_name='�' ch_width='394.5' ch_xoff='12' fill='red' stroke='gold' stroke-width='15' d='' /> </svg>
Letter: � ASCII: 139 Array index: 110 Vertices: 0 advanceWidth: 691 leftSideBearing: 31
<svg width='150' height='150' viewBox='0 0 650 650' transform='translate(0, 0)' > <path ch_name='�' ch_width='345.5' ch_xoff='15.5' fill='red' stroke='gold' stroke-width='15' d='' /> </svg>
ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.
BR Alex
|
|
|
Post by vovchik on Jun 26, 2016 22:49:57 GMT 1
Dear Alex,
Thanks for testing. I can't now remember whether I check for the size of the vertices array, but that would be in order for any font that is not whittled down and predigested, like my unicode sans header file was. steamerregular.ttf has high-ASCII chars, and I do not get the segfault at all, and I get chars which exists displaying up to array index 235. I think that might be something PI might be doing, though I'm not certain. Peter and basica should check the BLOAD version and click away and see whether they experience the same. In any case, we should be able to retreive the max elements and not exceed.
With kind regards, vovchik
|
|
|
Post by basica on Jun 27, 2016 14:46:04 GMT 1
vovchik, Clicked up to 138 and then had the same experience as Alex - segfault. When I tested earlier, I had stopped just short Regards, basica
|
|
|
Post by vovchik on Jun 27, 2016 18:03:38 GMT 1
Dear basica and Alex, I am getting the same but on array_index = 98 with no vertices, so the problem is occurring during an stb call prior to the for=next loop. I have revised both programs to take account of the nuumber of glyphs, which stb returns just fine. Have a look, and time for some head-scratching. WIth kind regards, vovchik Attachments:ttf-vertex-svg.tar.gz (34.45 KB)
|
|