SVG/PNG Fancy Text and Logo Generator

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#16 Post by musher0 »

HI vovchik.

Ok, your offset trick works, but:
-- this example was done using the DejaVu font.
Is that font badly crafted too?

Because I find it a bit too easy to blame the shortcomings of one's app on
the font designer. The font designers at Arkandis Digital Foundry have a
very good reputation. A programmer of your level shouldn't do that.

It may be that I have ticked or not ticked some essential configuration
item because of inexperience. That is entirely possible.

But to say off the bat that a certain font or group of fonts is bad? Then
please provide as much evidence as you can that that font is indeed bad,
according to font standards, not merely out of your opinion.

-- your app still does not place the text in the right order.
Did I forget to tick something in the config panel?

TIA for any pointers.
Attachments
SwitzeraADF-is-OK.jpg
(110.05 KiB) Downloaded 245 times
Hum(2)...jpg
(102.82 KiB) Downloaded 245 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#17 Post by MochiMoppel »

Hi vovchik, thank you for the update. My font box looks much cleaner now :lol:

No further issues so far, but one question:
Many of my fonts don't support the setting of font weight. For logos etc. it would be nice to be able to make the fonts a bit fatter.
I looked into the generated svg code and found the line

Code: Select all

<g stroke-width='0' stroke='black'
I appears that this stroke is a king of outline and by giving it a value the font gains weight. For the screenshot I've changed the color to red so that the difference becomes apparent. Leaving it black would result in a nice, bold font. Can these 2 parameters be set from the GUI? Obviously they are in the generated code, but I can't find them in the GUI.
Attachments
fake_font_weight.jpg
(69.44 KiB) Downloaded 256 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#18 Post by vovchik »

Dear musher0,

I didn't mean to trash a particular font designer, but I have examined, say, a hundred or so TTFs character by character when making/designing a TTF vector display for open gl canvas (drawing individual glyphs after extracting and analysing the internal vector tables). I converted heaps of fonts glyph-by-glyph and put those into into c header files. In those files I can then see the bounding box info provided for each glyph, plus kerning info, baselines, descenders etc., and have noted that many font designers have gone off a bit on their own. And I wasn't absolutely categorical in that I did say in my commment "most probably". I have attached one of my own test progs that "embeds" a standard ttf (unisans), takes it apart, grabs all the vector and other info and displays the resulting Beziers (Tahr 32-bit, needs openGL).

But your particular problem is vexing, since I simply take the contents of a standard gtk edit box, wrap it in svg syntax and display. Why it is inverting the order of lines on your machine is a mystery, since this hasn't happened to me and I do not see how it can happen programatically, given the very simple code I use in grabbing the text and processing it. Can you post the resulting svg so that I can have a look? And has anybody else experienced this, too? Please report if you have had this problem!

With kind regards,
vovchik
Attachments
ttf-vertex-bezier-svg-unisans_s1.tar.gz
(60.57 KiB) Downloaded 172 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#19 Post by vovchik »

Dear MochiMoppel,

Thanks for testing. I am glad that you did not experience musher0's problems (I hope). You are right about the usefulness of having a stroke-width spinbox. Since I am basically lazy (:)), I don't want to redesign the entire gui yet (but I will probably have to once I include skewX/Y and matrix), I could fit a little spinbox after the "Font style" combo box. Would that be OK?

With kind regards,
vovchik

User avatar
souleau
Posts: 148
Joined: Sun 23 Oct 2016, 15:24

#20 Post by souleau »

Great work vovchik!

I wonder, is there perhaps a chance some time in the future to add a filter function to the backround as well? It would make backrounds like these a possiblity:

Code: Select all

<svg xmlns="http://www.w3.org/2000/svg" width="640" height="480">
<defs>
	<filter id="myFilter01" x="0" y="0" width="100%" height="100%">
	<feTurbulence baseFrequency=".005" numOctaves="1" seed="6" type="turbulence"/>
	<feComponentTransfer>
	<feFuncA type="table" tableValues="1 0"/>
	</feComponentTransfer>
	</filter>
	<filter id="myFilter02" x="0" y="0" width="100%" height="100%">
	<feColorMatrix type="hueRotate" values="180" result="A" />
	</filter>
</defs>
<g filter="url(#myFilter02)" >
<g filter="url(#myFilter01)" >
<rect width="640" height="480" />
</g>
</g>
</svg>
I know it's a tall order. I was actually surprised you went anywhere near the filter functions in the first place.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#21 Post by MochiMoppel »

vovchik wrote:I am glad that you did not experience musher0's problems
I didn't even experience his 2nd problem (?). Here with Autoscaling enabled and Offset y=86 the text shifts down, his text stays centered.
I could fit a little spinbox after the "Font style" combo box. Would that be OK?
Up to you, I don't think it's urgent.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#22 Post by vovchik »

Dear MochiMoppel,

Thanks for your testing and suggestions. I have already implemented the stroke-width spinbox and it is VERY USEFUL. And it's good that you did not have musher0's problems. I cannot understand how the string sequence gets inverted by newline, since I go line by line in assembling the SVG. I wonder whether he has some BIDI setting active.

Let me know how the stroke-width spinbox is working with your fonts.

With kind regards,
vovchik

PS. Will post the new version (binary and source) in a few minutes.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#23 Post by vovchik »

Dear souleau,

Thanks - it is a nice idea. I will have to have a think about how to implement filters for backgrounds. It shouldn't be too daunting a task, I think. :)

With kind regards,
vovchik

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#24 Post by MochiMoppel »

vovchik wrote:Let me know how the stroke-width spinbox is working with your fonts.
Works perfectly (see screenshot)

I'm still puzzled by the autoscaling behavior. Something is not right here.
Manual scaling 148x172 Offset y=89: looks OK
Autoscaling changes values in code to
148x83 Offset y=89: This can't work. Produces empty box. Impossible to show anything in a 83px tall box with a 89px vertical offset.
Attachments
svg_font_stroke.png
font size 200. Stroke 0 vs. stroke 10
(57.8 KiB) Downloaded 207 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#25 Post by musher0 »

@vovchik,

Please find attached requested svg.

BFN.
Attachments
root_20170505_17h07m49s_switzera_adf-56-none.svg.zip
(739 Bytes) Downloaded 108 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#26 Post by vovchik »

@musher0

:):):) I understand what is happening. You have French for your numbers, so the amout of y-axis displacement (in decimal ems) is nonsense in an SVG. SVGs want decimals with a dot ("."), and not commas, and your SVG, running with localization, is created with the value "2,122em" and not "2.122em". I will have to think of how to fix that in the program, but will have to ponder consequences, since decimal numerics in SVGs have to be with the dot and not a comma, as I understand (although there might be an override needed in the header info about charset). In the meantime, you can run the prog from the command line or in a script as follows :

Code: Select all

export LC_NUMERIC=en_AU.UTF-8 ./txt2svg
Thanks for posting the SVG. It told me everything I wanted to know to understand the problem. All we need now is an evegant and simple solution. :)

@ MochiMoppel

The autoscaling is done by pango, given a particular font and size. It returns the size of the bounding box in two variables. I multiply the width and height by factors to give room for some shadow effects, which pango cannot know about. The offsets are not affected or reset by autoscaling, so you have to null them after doing manual dimensioning and then autoscaling. I will think about whether it is useful to set x and y offsets to zero following an autscaling operation.

With kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#27 Post by vovchik »

Dear musher0,

Can you try the latest binary, just uploaded? I added LC_NUMERIC=C (posix) to the code in an attempt to override user locale decimal settings in the hope that the SVGs generated are with period decimal separators. That was the problem with your generated SVG. The last text entry in the SVG had a comma, rather than a period, as the decimal separator for the vertical displacement.

With kind regards,
vovchik

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#28 Post by musher0 »

Hello vovchik.

Thanks for your kind reply.

I tried your new version, but the problem remains the same. However,
following your hunch about LANG above, if I launch your progam like this:

Code: Select all

LANG=en_CA.utf8;txt2svg 
instead of with my usual LANG=fr_CA.utf8, the results are as expected.

Illustration with console and app attached.

BFN.
Attachments
The-Ottawa-River-is-in-flood.jpg
(210.88 KiB) Downloaded 137 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#29 Post by vovchik »

@musher0

I am glad you could solve the problem by changing the environment temporarily. I would stuill like a better soluion, so as not to give people headaches.

@all

We now have patterns,. :) Source and Tahr binary will be updated in a few minutes.
Attachments
vovchik_20170506_18h05m30s_times_new_roman-156-relief.png
(239.53 KiB) Downloaded 143 times
txt2png5.png
(107.64 KiB) Downloaded 139 times

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#30 Post by musher0 »

Patterns? Yuk! :lol: (This is irony, my friends, irony!!!)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
OscarTalks
Posts: 2196
Joined: Mon 06 Feb 2012, 00:58
Location: London, England

#31 Post by OscarTalks »

Hello vovchik,

Your pre-compiled static binary does run in DpupWheezy but I wanted to test a build from source. The native bacon was too old so I compiled the latest (3.5.4) with no problems. I also grabbed the HUG file from the website as suggested. Source then compiles and runs fine. Thanks for your excellent work.
Oscar in England
Image

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#32 Post by vovchik »

@ musher0 and all

Just added a "yucky" diagonal pattern (best viewed with the solidify and relief filters) and incorporated a very useful mod by alexfish at basic-converter.org that prevents exiting the app by inadvertently clicking on the close button on the taskbar.

@OscarTalks

Great that that your compilation went OK. After I compile, I usually strip and upx, operations that reduce the size of the resulting HUG-based binaries by some 75%, just to keep things small. :)

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#33 Post by fredx181 »

Hello vovchik,

Thanks for your beautiful program!

Tested on Debian(Dog) , first didn't run but found that a symlink libpangocairo-1.0.so > libpangocairo-1.0.so.0 is required to make it work.
So I thought changing line 59 in txt2svg.bac

Code: Select all

CONST pango$ = "libpangocairo-1.0.so"
To:

Code: Select all

CONST pango$ = "libpangocairo-1.0.so.0"
and recompile should do.
But when compiling I get:

Code: Select all

root@jessie:~/src# bacon -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections txt2svg.bac
Converting 'txt2svg.bac'... 1157
Syntax error: could not parse line 1157 in file 'txt2svg.bac'! 
Any idea what I'm possibly missing?
I should note that the error was also already when I tried before making the edit libpangocairo-1.0.so.0 in txt2svg.bac

Fred

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#34 Post by vovchik »

Dear fredx181,

Thanks. And good that you acre trying to compile it yourself. I think you might be using an older version of bacon. Get the latest, and the latest HUG, from www.bacon-converter.org. The line that cause the stutter was:

Code: Select all

SAVE mysvg$ TO "/tmp/txt2svg.svg"
and that syntax (SAVE TO) appeared only recently. That is probaby the only reason for the error. As for libpangocairo, I have compiled on various systems, including Mint, Tahr and Raspbian Debian for Pi, and got no errors regarding the lib location. Weird.

With kind regards,
vovchik

PS. I am posting a new version soon with hatch, crosshatch and other pattern fills. :)
Attachments
pi_20170508_00h10m00s_trebuchet_ms-153-solidify.png
(79.99 KiB) Downloaded 361 times
Last edited by vovchik on Sun 07 May 2017, 22:12, edited 1 time in total.

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#35 Post by fredx181 »

vovchik wrote:I think you might be using an older version of bacon
Ah, yes, thanks vovchik, compiled fine now (also needed latest hug.bac, indeed)
As for libpangocairo, I have compiled on various systems, including Mint, Tahr and Raspbian Debian for Pi, and got no errors regarding the lib location. Weird.


For Debian-Jessie (don't know about other distros) I think the point is that the package libpango1.0-dev has the symlink libpangocairo-1.0.so, but the package libpangocairo1.0 doesn't (has only libpangocairo-1.0.so.0) see screenshot
So I'd like it to work (just to run txt2svg binary, not compiling) also without the dev package installed, which I did now, thanks again :)

Fred
Attachments
libpangocairo.png
libpangocairo-1.0.so.0 in libpangocairo1.0
(23.51 KiB) Downloaded 410 times

Post Reply