By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,706 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,706 IT Pros & Developers. It's quick & easy.

Font in code

P: n/a

Hi,

I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.

Thanks

Carl
http://www.gaihosa.com
Jun 2 '08 #1
Share this Question
Share on Google+
16 Replies


P: n/a
ca**********@gmail.com wrote:
Hi,

I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.

Thanks

Carl
http://www.gaihosa.com
You can send PDF's? And embed fonts.

If you want a tight document format, thats generally the way to do it.

Jun 2 '08 #2

P: n/a
ca**********@gmail.com schreef:
Hi,

I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.

Thanks

Carl
http://www.gaihosa.com
Hi Carl,

PHP doesn't use fonts itself: It is just code.

Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)

What is it excactly you are asking for?

Regards,
Erwin Moller
Jun 2 '08 #3

P: n/a
I know this sounds very odd. I'll better explain what I am trying to
do.

When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}

Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com

Hi Carl,

PHP doesn't use fonts itself: It is just code.

Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)

What is it excactly you are asking for?

Regards,
Erwin Moller
Jun 2 '08 #4

P: n/a
I know this sounds very odd. I'll better explain what I am trying to
do.

When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}

Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com

Hi Carl,

PHP doesn't use fonts itself: It is just code.

Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)

What is it excactly you are asking for?

Regards,
Erwin Moller
Jun 2 '08 #5

P: n/a
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
On May 6, 5:26 am, Erwin Moller

<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
>http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.

When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");

if($mode == font){
echo $font;

}

Ofcourse this doesn't work so I thought I would ask.

Thankyou for all of your answers.

Carl.

http://www.gaihosa.com
Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Jun 2 '08 #6

P: n/a
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.
Jun 2 '08 #7

P: n/a
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.
Jun 2 '08 #8

P: n/a
ca**********@gmail.com wrote:
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
>>On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@sp amyourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com
Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");

Just wondering if there is a way to embed a font in your code such as
in a PDF.
No, as others have said - PHP doesn't use fonts. It generates HTML.

You can create an image, but the font you use must be available in a
font file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #9

P: n/a
On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
ca**********@gmail.com wrote:
>On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>>On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:

On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@s pamyourself.comwrote:
carlberna...@gmail.com schreef:
>Hi,
>I was wondering if there is way use a font that is somehow kept in
>the
>code instead of having to load it? I am working on a single script
>that so far can produce images and html but I have not been able to
>figure out a way that it can also produce a font.
>Thanks
>Carl
>http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to
use.
- You can use fonts when producing images. (In that case the fonts
PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-
etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. Whenmy
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com
Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.

No, as others have said - PHP doesn't use fonts. It generates HTML.

You can create an image, but the font you use must be available in a
font file.

Well, theoretically PHP could create/output a font file, and theoretically
one could 'embed' the binary code in a static variable in the code. Noone
in his right mind would do this of course.
--
Rik Wasmus
Jun 2 '08 #10

P: n/a
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.
Jun 2 '08 #11

P: n/a
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@spam yourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com

Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.
Jun 2 '08 #12

P: n/a
Rik Wasmus wrote:
On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
>ca**********@gmail.com wrote:
>>On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:

On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@ spamyourself.comwrote:
>carlberna...@gmail.com schreef:
>>Hi,
>>I was wondering if there is way use a font that is somehow kept
>>in the
>>code instead of having to load it? I am working on a single script
>>that so far can produce images and html but I have not been able to
>>figure out a way that it can also produce a font.
>>Thanks
>>Carl
>>http://www.gaihosa.com
>Hi Carl,
>PHP doesn't use fonts itself: It is just code.
>Some things that might be relevant:
>- You can produce HTML/CSS that says to the browser which font to
>use.
>- You can use fonts when producing images. (In that case the fonts
>PHP
>needs must be available to PHP, duh).
>- You PHP IDE can in most cases change its font (probably
>options-etc)
>What is it excactly you are asking for?
>Regards,
>Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com
Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Just wondering if there is a way to embed a font in your code such as
in a PDF.

No, as others have said - PHP doesn't use fonts. It generates HTML.

You can create an image, but the font you use must be available in a
font file.


Well, theoretically PHP could create/output a font file, and
theoretically one could 'embed' the binary code in a static variable in
the code. Noone in his right mind would do this of course.
Hi, Rik,

I thought about that, but I suspect the font file accessed with
fopen()/fread() or similar. And since the functions don't take a URL
(AFAIK, anyway), I don't know of any way to duplicate that in PHP.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #13

P: n/a
ca**********@gmail.com wrote:
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.comwrote:
>On 6 May, 13:15, "carlberna...@gmail.com" <carlberna...@gmail.com>
wrote:
>>On May 6, 5:26 am, Erwin Moller
<Since_humans_read_this_I_am_spammed_too_m...@sp amyourself.comwrote:
carlberna...@gmail.com schreef:
Hi,
I was wondering if there is way use a font that is somehow kept in the
code instead of having to load it? I am working on a single script
that so far can produce images and html but I have not been able to
figure out a way that it can also produce a font.
Thanks
Carl
http://www.gaihosa.com
Hi Carl,
PHP doesn't use fonts itself: It is just code.
Some things that might be relevant:
- You can produce HTML/CSS that says to the browser which font to use.
- You can use fonts when producing images. (In that case the fonts PHP
needs must be available to PHP, duh).
- You PHP IDE can in most cases change its font (probably options-etc)
What is it excactly you are asking for?
Regards,
Erwin Moller
I know this sounds very odd. I'll better explain what I am trying to
do.
When my script calls for an image I let the it know via the query
variables as so: <image src="myscript.php?mode=image" />. When my
script is accessed in this fashion it only returns an image. It's also
does the same for the Ajax (which controlls the form), "myscript.php?
mode=ajax" and the HTML, "myscript.php?mode=html". Everything is
inline except the loading of fonts that are not in the GD Library.
That is the last thing I am hoping to accomplish such as so:
$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font");
if($mode == font){
echo $font;
}
Ofcourse this doesn't work so I thought I would ask.
Thankyou for all of your answers.
Carl.
http://www.gaihosa.com
Please do not top post (top posting fixed)

It is still not at all obvious what you are trying to do.

You never load anything into $font, so you can't write it out.

But even ignoring that, what do you expct to be in $font?

Calling imagettftext($image, 10, 0, 3, 15, $text_color, "myscript.php?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?mode=font" is not valid.

An echo command outputs something to the browser, but what you want to
do is have a value for a font, inside the code.

I assume that you are not showing us the whole URLs as "myscript.php?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetruecolor(59, 20);
$text_color = imagecolorallocate($im, 0, 0, 0);
imagettftext($image, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");

Just wondering if there is a way to embed a font in your code such as
in a PDF.
You keep asking this and you keep being told no.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #14

P: n/a
On Tue, 06 May 2008 21:58:13 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
Rik Wasmus wrote:
>On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle
<js*******@attglobal.netwrote:
>>No, as others have said - PHP doesn't use fonts. It generates HTML.

You can create an image, but the font you use must be available in a
font file.
Well, theoretically PHP could create/output a font file, and
theoretically one could 'embed' the binary code in a static variable in
the code. Noone in his right mind would do this of course.

I thought about that, but I suspect the font file accessed with
fopen()/fread() or similar. And since the functions don't take a URL
(AFAIK, anyway), I don't know of any way to duplicate that in PHP.
A quick check here confirms it: normal streams cannot be used as it seems
(probably because it will actually be GD doing the fopen()ing), it has to
be a file.
--
Rik Wasmus
Jun 2 '08 #15

P: n/a
In our last episode,
<39**********************************@j22g2000hsf. googlegroups.com>, the
lovely and talented ca**********@gmail.com broadcast on comp.lang.php:
Just wondering if there is a way to embed a font in your code such as
in a PDF.
This still is not making much sense. I think by "code" you mean html
markup. If so, the answer is 'no,' you cannot use PHP to generate html that
does stuff html cannot do.

If you cannot write a prototype document in HTML that does what you want in
HTML, you cannot get PHP to generate an HTML document that somehow does
something magical that HTML cannot do.

You could have a browser-side script that tried to install a font in the
browser for use with your document, but that isn't HTML and it isn't PHP,
and whether or exactly how to do this is subject matter for a browser-side
scripting group.

You can indicate a preferred font in a style element or attribute in HTML or
in the deprecated font element, but if the browser does not have that font,
it will fall back on something generic --- which is why it is a good idea to
have a list of fonts, increasing in generality up to a generic font family.

If you must have PDF-like control over the appearance of your document,
serve pdf.

--
Lars Eighner <http://larseighner.com/us****@larseighner.com
Countdown: 258 days to go.
Jun 2 '08 #16

P: n/a
In our last episode,
<2a**********************************@m44g2000hsc. googlegroups.com>, the
lovely and talented ca**********@gmail.com broadcast on comp.lang.php:
Just wondering if there is a way to embed a font in your code such as
in a PDF.
Once again, PHP cannot generate magic-HTML that does stuff that is
impossible in HTML. You can ask in an HTML group how to embed a font in
HTML. If (as I have a strong suspicion) the answer is "No way," then the
answer is still "No way" for HTML generated by PHP.

--
Lars Eighner <http://larseighner.com/us****@larseighner.com
Countdown: 258 days to go.
Jun 2 '08 #17

This discussion thread is closed

Replies have been disabled for this discussion.