473,738 Members | 11,192 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Font in code


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
16 1879
ca**********@gm ail.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
ca**********@gm ail.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
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.p hp?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.p hp?
mode=ajax" and the HTML, "myscript.php?m ode=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 = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
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_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
carlberna...@gm ail.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
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.p hp?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.p hp?
mode=ajax" and the HTML, "myscript.php?m ode=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 = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
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_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
carlberna...@gm ail.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
On 6 May, 13:15, "carlberna...@g mail.com" <carlberna...@g mail.com>
wrote:
On May 6, 5:26 am, Erwin Moller

<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
carlberna...@gm ail.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.p hp?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.p hp?
mode=ajax" and the HTML, "myscript.php?m ode=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 = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
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($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?m ode=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.p hp?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, $_GET['fonttype'], "my
font");
Jun 2 '08 #6
On May 6, 8:51 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 6 May, 13:15, "carlberna...@g mail.com" <carlberna...@g mail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
carlberna...@gm ail.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.p hp?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.p hp?
mode=ajax" and the HTML, "myscript.php?m ode=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 = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
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($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?m ode=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.p hp?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 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
On May 6, 8:51 am, Captain Paralytic <paul_laut...@y ahoo.comwrote:
On 6 May, 13:15, "carlberna...@g mail.com" <carlberna...@g mail.com>
wrote:
On May 6, 5:26 am, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
carlberna...@gm ail.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.p hp?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.p hp?
mode=ajax" and the HTML, "myscript.php?m ode=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 = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
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($i mage, 10, 0, 3, 15, $text_color, "myscript.p hp?
mode=font", "my font"); will put the text "my font" into the image,
except that the font you have specified
"myscript.php?m ode=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.p hp?
mode=image" has no way to specify what image is to be retrieved.

Is this possibly what you are looking for:

$image = imagecreatetrue color(59, 20);
$text_color = imagecoloralloc ate($im, 0, 0, 0);
imagettftext($i mage, 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
On Tue, 06 May 2008 21:58:13 +0200, Jerry Stuckle
<js*******@attg lobal.netwrote:
Rik Wasmus wrote:
>On Tue, 06 May 2008 19:18:01 +0200, Jerry Stuckle
<js*******@att global.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
theoreticall y 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 #9
In our last episode,
<39************ *************** *******@j22g200 0hsf.googlegrou ps.com>, the
lovely and talented ca**********@gm ail.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****@larseigh ner.com
Countdown: 258 days to go.
Jun 2 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
638
by: Shmuel (Seymour J.) Metz | last post by:
I've got a document that StarOffice converted into HTML, and I'm trying to clean up the cuft that it generated. I put together some basic styles, and tied using them: the results are puzzling. The style definition is: <STYLE> <!-- @page { size: 8.5in 11in; margin: 0.79in } div.res dl dt { font-weight: bold;
10
4048
by: Richard R Plourde | last post by:
I've got a problem that IE doesn't seem to use the entire font unicode subgroups from a hinted font file. When I display the following web page in IE 6 as opposed to Firefox 1.0 PR. Check out the web page in question... http://clientserver.home.comcast.net/unicode.html If you examine, for a few examples, characters such as square root (&amp;#8730;), prime (&amp;#8242;) and double prime (&amp;#8243;).
3
7217
by: Barry Anderberg | last post by:
I'm using the .NET Memory Profiler by Sci Tech and I wrote a little test application to verify something odd I observed and it appears that System.Drawing.Font fails to dispose of its FontFamily. I run the following code: // BEGIN while( true ) { System.Drawing.Graphics dc=lblClock.CreateGraphics();
4
4945
by: Eric Eggermann | last post by:
Hello all, I'm building an app that lays out and prints flash cards. Now the card might be any size, but when the user is working on the card, I draw the preview isotropically, as large as possible. The user specifies a font size for the document, but I need to scale this for the preview. The scaling code I have is very close but not right. I can only notice that it's wrong occasionally when I have a piece of text that wraps, and the...
7
2972
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and already formatted as "Shopping" ---Bold "for" -----Regular Now I want to underline whole text by preserving old style i.e. Bold and
6
8098
by: BobAchgill | last post by:
Has anyone had success with writing text using a private font that was not already installed to the system? When I try the example code in NET Framework Developer's Guide called “Creating a Private Font Collection” .... I only see a default font written to the form NOT the private font that was loaded. Ofcourse I see the right font written if the font is already one that is installed in the system. But if the private font that I...
24
2837
by: Tony Girgenti | last post by:
Hello. Developing a Windows Form program in VS.NET VB, .NET Framework 1.1.4322 on a windows XP Pro, SP2. Before printing a document, i want to set the font to a font that is only available with the printer that i am printing to(Zebra TLP2844). When i open Word and look at the fonts available for the default printer, it does not show the fonts i want. If i cahnge the printer to the printer that
2
6572
by: Patti | last post by:
I am building an application using VB.NET 1.1 and I have an issue with Font properties in my Radio Button Lists and Check Box Lists. My issue is that the Font Names and Font Size for these controls have become "Read Only" and I have no idea how they became read only. I didn't set anything to read only and was able to change these fonts just last week - so I must have messed something up. Below is a snippet of my HTML code I used...
2
3629
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts" are supposed to be in the font: Georgia, but they are showing up in "Times New Roman"...blah! I can't find anything wrong in the code, but who am I trying to fool? I know nothing about this stuff. The code is below. The parts that I *think*...
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.