/    Sign up×
Community /Pin to ProfileBookmark

imagestring text looks funny when using currency symbols in a dynamic image

Im trying to generate an image dynamically and some text within the image may contain a british pound currency symbol £

Instead of it dislaying the symbol correctly it displays some strange looking A with a ^ above the top of the a followed by a t like shape

Instead of displaying the correct £

What am i doing wrong

Im using

[code]imagestring($image, 2, 60, $count, $row[‘name’].’ Gave £’.$row[‘donation’], $tx);[/code]

to test out what it would look like with a british pound symbol in front of the value but cant figure out why it doesnt look right

I tried with a dollar symbol and it displayed just fine

But hen i use pound symbols or yen symbols or euro etc etc it does not display correctly

Is there anything i can do to fix this within my code?

Thaks in advance

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@SheldonMay 08.2008 — Escape the pound symbol?

[code=php]imagestring($image, 2, 60, $count, "{$row['name']} Gave £{$row['donation']}", $tx);[/code]
Copy linkTweet thisAlerts:
@NogDogMay 08.2008 — Not sure, but you could see if this makes a difference:
[code=php]
$pound = chr(163); // Pound currency symbol
imagestring($image, 2, 60, $count, $row['name'].' Gave '.$pound.$row['donation'], $tx);
[/code]
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMay 08.2008 — thanks NogDog that seems to have worked, it doesnt really look like a pound symbol though it kind of has the top curve missing, any ideas why this is?
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMay 08.2008 — i also tried using 165 which is supposed to be the Yen symbol but that didnt display properly looks like an L with single quote mark near the top,

What i need is a way to be able to pic which currency symbol out of pound dollar yen and euro and display that currency, dollar works fine as is pound kind of works with the method you suggested but yen sign displays incorrectly and euro sign doesnt display at all when using the ascii character code method you suggested
Copy linkTweet thisAlerts:
@SheldonMay 08.2008 — maybe it is due to your pages char set ?
Copy linkTweet thisAlerts:
@NogDogMay 08.2008 — thanks NogDog that seems to have worked, it doesnt really look like a pound symbol though it kind of has the top curve missing, any ideas why this is?[/QUOTE]
I would guess it's a limitation of the font being used, perhaps?
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMay 08.2008 — yeah maybe ill try using ttf font stuff with a different font and see if it works

As several character codes work just fine and several dont
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMay 08.2008 — yeah that works now

i did <i>
</i>
$pound = chr(163); // Pound currency symbol

imagettftext($image, 8, 0, 60, $count, $tx, $fontttf, $row['name'].' Gave '.$pound.$row['donation']);


And it displays fine with yen symbol or pound symbol but just not with euro, but im getting there
Copy linkTweet thisAlerts:
@NogDogMay 08.2008 — I didn't know this, but according to the imagettftxt manual page:
[noparse]

The text string in UTF-8 encoding.

May include decimal numeric character references (of the form: &# 8364? [space inserted by me so you can see the actual text] to access characters in a font beyond position 127. The hexadecimal format (like &#xA9? is supported as of PHP 5.2.0. Strings in UTF-8 encoding can be passed directly.

[/noparse][/quote]

[noparse]So you should be able to do the Euro with "& # 128;" and the Pound with "& # 163;" (without the spaces I used here) directly in your quoted string literal.[/noparse]
Copy linkTweet thisAlerts:
@BWWebDesignsauthorMay 08.2008 — Nope when i use the euro symbol in any of the ways mentioned above it always displays as a simple square, the usual thing you see when the character cannot be found and displayed properly
×

Success!

Help @BWWebDesigns spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...