Determining the font characteristics of any web page?

P

Peter Olcott

What is a method or set of methods that can determine all of the font
characteristics of any web page? By font characteristics I mean typeface name,
point size, foreground color, background color, bold, underline, et cetera. I am
a visual C++ programmer, and will be learning .NET very soon, so if there is a
simplified way using either of these tools, I would prefer this simpler way.
 
B

Beauregard T. Shagnasty

In alt.html, Peter Olcott wrote:

I don't know where you are reading this, so I left the massive
cross-posting intact.
What is a method or set of methods that can determine all of the font
characteristics of any web page?

Use CSS. Do you know what this is at this point?
By font characteristics I mean typeface name, point size, foreground
color, background color, bold, underline, et cetera.

Forget about 'point size'. Points are for printing. Use percentages for
font sizing (discussed almost daily in these groups). Don't use pixels,
either, for the oft-stated reasons.

body {
background-color: #f5f5f5;
font-family: sans-serif;
font-size: 100%;
color: #000000;
}

For bold text:
This is <strong>bold text</strong> in most browsers. This is
<u>underlined</u> in most browsers, though you shouldn't use it because
I am a visual C++ programmer, and will be learning .NET very soon, so
if there is a simplified way using either of these tools, I would
prefer this simpler way.

It is a very simple task to add a link in the <head> of the document to
a style sheet that will work for the entire web site.
 
P

Peter Olcott

Beauregard T. Shagnasty said:
In alt.html, Peter Olcott wrote:

I don't know where you are reading this, so I left the massive
cross-posting intact.


Use CSS. Do you know what this is at this point?
I am not writing webpages I am parsing websites. I have no choice in how any of
these websites are written.
Forget about 'point size'. Points are for printing. Use percentages for
font sizing (discussed almost daily in these groups). Don't use pixels,
either, for the oft-stated reasons.

I must know the point size. Imagine that I am writing a browser, and must
display any webpage.
 
B

Beauregard T. Shagnasty

I am not writing webpages I am parsing websites. I have no choice in
how any of these websites are written.

OK, you did not make that clear at all.
I must know the point size. Imagine that I am writing a browser, and
must display any webpage.

Then, as I see it, you are doomed before you start. What will your
parser do when it comes to a site - with no HTML presentation - that has
"font-size: smaller" in the CSS file? The actual size of the appearance
of the text in my browser is entirely dependant on my local settings.

Points are still for printing.
 
P

Peter Olcott

Beauregard T. Shagnasty said:
OK, you did not make that clear at all.


Then, as I see it, you are doomed before you start. What will your
parser do when it comes to a site - with no HTML presentation - that has
"font-size: smaller" in the CSS file? The actual size of the appearance
of the text in my browser is entirely dependant on my local settings.

It will do whatever the browser does, the browser must ultimately determine a
point size, so by whatever means the browser uses, I must also use.
 
J

Jonathan N. Little

Peter said:
"Beauregard T. Shagnasty" <[email protected]> wrote in message
It will do whatever the browser does, the browser must ultimately determine a
point size, so by whatever means the browser uses, I must also use.

You are missing BTS's point. What the ultimate font size depends on user
settings so *my* browser may display the same page differently that
BTS's and differently from yours! So when your say "It will do whatever
the browser does" who's browser?

BTS is also correct here, *points* are a measurement for outputting to a
printer not a display! The units pt, cm, in reality do not work for
displays because all depend on the monitor settings.
 
P

Peter Olcott

Jonathan N. Little said:
You are missing BTS's point. What the ultimate font size depends on user
settings so *my* browser may display the same page differently that BTS's and
differently from yours! So when your say "It will do whatever the browser
does" who's browser?

All the I need it the point size that the browser the user is using determines.
It okay is this is not the same on any other browser as long as it is this same
as the specific browser that the user is using.
 
J

Jonathan N. Little

Peter said:
All the I need it the point size that the browser the user is using determines.
It okay is this is not the same on any other browser as long as it is this same
as the specific browser that the user is using.

I have a short and sweet answer for you and you ain't going to like it!
You can't. It is a user setting on the browser, you cannot get that
info. You cannot get what the user has for the default font size any
more than what font he is using for his monospace font, or what he has
installed on his system.

Here is what you can see about the browser:

<script type="text/javascript">
var n=navigator;

for( var e in n){
document.write( e + " is " + n[e] + "<br>");
}

</script>
 
B

Beauregard T. Shagnasty

All the I need it the point size that the browser the user is using
determines. It okay is this is not the same on any other browser as
long as it is this same as the specific browser that the user is
using.

Is this - whatever you are tasked with writing - supposed to be a
browser plug-in some specific group of surfers will use? Further
description of exactly what and how (and even why) you are supposed to
do this job would help. 'Cause there ain't no way I can see where any
external program could tell you what a browser is going to do. Unless of
course you are writing an entire browser... kind of pointless since
there are already quite a few good ones.

Thanks, Jonathan. For trimming the groups, too.
 
J

Jonathan N. Little

Beauregard said:
Thanks, Jonathan. For trimming the groups, too.

Had too, one of the x-posted groups I must not have available on my
server and I kept getting an error, so rather figure out which one I
just trimmed to the one I know is good!
 
D

David Dorward

Peter Olcott wrote:

(Follow ups set to alt.html as its the only group in the list I read)
What is a method or set of methods that can determine all of the font
characteristics of any web page? By font characteristics I mean typeface
name, point size, foreground color, background color, bold, underline, et
cetera.

It depends on what:

* Presentational HTML is used
* Author stylesheets are set (which may be modified by JavaScript, e.g. I've
seen scripts that change the font size based on the window width)
* User stylesheets are set
* Browser default stylesheets are set (or whatever means of determining
default rendering the browser uses if not stylesheets)
* User preferences
* Fonts installed on the system displaying the page

http://www.w3.org/TR/CSS2/ describes CSS and includes a suggested browser
default stylesheet for HTML 4.
 
N

Neredbojias

I am not writing webpages I am parsing websites. I have no choice in
how any of these websites are written.


I must know the point size. Imagine that I am writing a browser, and
must display any webpage.

Display where? If in users' browsers, just keyphrase-identify all the
various valid (and some invalid) possible font-designators and copy their
attributes verbatim. However, if your process depends upon determining
each user's browser default font-size, etc., to accomplish its task, that
really isn't possible.
 
T

TC

Peter said:
All the I need it the point size that the browser the user is using determines.
It okay is this is not the same on any other browser as long as it is this same
as the specific browser that the user is using.

*What* "specfic browser that the user is using" ?

At present I use two browsers (IE and NS), and for reasons that aren't
important here, I have each of them set to a *different default font
size*.

So for me, most pages render differently, depending on which browser I
use.

So what is the "specific browser" that I am usng? Which of the *two*
default font sizes do you need?

I think you will see, from this example, that your question actually
does not make sense. There is no "specific" browser per user. There is
no "one" default font size per user. The concept that you have in your
mnd, does not reflect how things actually work.

HTH,
TC (MVP MSAccess)
http://tc2.atspace.com
 
P

Peter Olcott

Jonathan N. Little said:
I have a short and sweet answer for you and you ain't going to like it! You
can't.

If it can't be done then browsers couldn't do it, browsers do it therefore it
can be done.
It is a user setting on the browser, you cannot get that info. You cannot get
what the user has for the default font size any more than what font he is using
for his monospace font, or what he has installed on his system.

Here is what you can see about the browser:

<script type="text/javascript">
var n=navigator;

for( var e in n){
document.write( e + " is " + n[e] + "<br>");
}

</script>
 
P

Peter Olcott

Neredbojias said:
Display where? If in users' browsers, just keyphrase-identify all the
various valid (and some invalid) possible font-designators and copy their
attributes verbatim. However, if your process depends upon determining
each user's browser default font-size, etc., to accomplish its task, that
really isn't possible.

Then browsers couldn't do it, and since they do it, therefore its not
impossible.
 
P

Peter Olcott

TC said:
*What* "specfic browser that the user is using" ?

At present I use two browsers (IE and NS), and for reasons that aren't
important here, I have each of them set to a *different default font
size*.

So for me, most pages render differently, depending on which browser I
use.

So what is the "specific browser" that I am usng? Which of the *two*
default font sizes do you need?

I think you will see, from this example, that your question actually
does not make sense. There is no "specific" browser per user. There is
no "one" default font size per user. The concept that you have in your
mnd, does not reflect how things actually work.

I need the exact FontInstance (a term that I coined) for whatever web-page the
user is currently viewing on whatever browser that they are using. A
FontInstance specifies all of the characteristics of the font rendering.
Typeface name, foreground color, background color, italic, bold, underline,
strikethrough. The most important thing that I need is typeface name, the next
most important thing that I need is point size. I also must have foreground and
background color.
 
P

Philip

I need the exact FontInstance (a term that I coined) for whatever web-page
the
user is currently viewing on whatever browser that they are using. A
FontInstance specifies all of the characteristics of the font rendering.
Typeface name, foreground color, background color, italic, bold, underline,
strikethrough. The most important thing that I need is typeface name, the
next
most important thing that I need is point size. I also must have foreground
and
background color.

Peter,
As someone else suggested, can you give us a clue as to what context
your code runs in? If you're writing a browser plugin, then what you're
asking for is probably possible. If your code doesn't run in the context
of the browser, you're going to have to code a bunch of fragile hacks
AFAICT.
 
P

Peter Olcott

Philip said:
Peter,
As someone else suggested, can you give us a clue as to what context
your code runs in? If you're writing a browser plugin, then what you're
asking for is probably possible. If your code doesn't run in the context
of the browser, you're going to have to code a bunch of fragile hacks
AFAICT.
If it would be easier to do, I could write some code that runs in the context of
the browser and then pass the results to the code that needs it that does not
run within the context of the browser.
 
B

Beauregard T. Shagnasty

Peter said:
If it would be easier to do, I could write some code that runs in the
context of the browser and then pass the results to the code that
needs it that does not run within the context of the browser.

Are the persons who will be running this code going to be a controlled
group? Such as an intranet? (You've not responded to that yet, afais.)

If not, how will you get this external code onto everyone's computer? Is
this just for your web site, or any/all sites visited?
 
P

Peter Olcott

Beauregard T. Shagnasty said:
Are the persons who will be running this code going to be a controlled
group? Such as an intranet? (You've not responded to that yet, afais.)

If not, how will you get this external code onto everyone's computer? Is
this just for your web site, or any/all sites visited?

Its for a commercial product. They will buy it and install it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top