This is a discussion on Font in code within the PHP Language forums, part of the PHP Programming Forums category; On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: > On 6 May, 13:15, &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> 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.com> wrote: > > > 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. |
|
|||
|
On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> 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.com> wrote: > > > 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. |
|
|||
|
Rik Wasmus wrote:
> On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle > <jstucklex@attglobal.net> wrote: > >> carlbernardi@gmail.com wrote: >>> On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: >>>> 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.com> wrote: >>>>>> 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. jstucklex@attglobal.net ================== |
|
|||
|
carlbernardi@gmail.com wrote:
> On May 6, 8:51 am, Captain Paralytic <paul_laut...@yahoo.com> wrote: >> 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.com> wrote: >>>> 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. jstucklex@attglobal.net ================== |
|
|||
|
On Tue, 06 May 2008 21:58:13 +0200, Jerry Stuckle
<jstucklex@attglobal.net> wrote: > Rik Wasmus wrote: >> On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle >> <jstucklex@attglobal.net> wrote: >>> 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 |
|
|||
|
In our last episode,
<3948dd84-cb88-402d-9d6a-868e4f4af449@j22g2000hsf.googlegroups.com>, the lovely and talented carlbernardi@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/> usenet@larseighner.com Countdown: 258 days to go. |
|
|||
|
In our last episode,
<2ac931e3-b66d-4d74-bb8e-d0b3e6373441@m44g2000hsc.googlegroups.com>, the lovely and talented carlbernardi@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/> usenet@larseighner.com Countdown: 258 days to go. |