?
Solved

getting typical font size for applet

Posted on 2003-03-03
9
Medium Priority
?
292 Views
Last Modified: 2013-12-02
Yes, I need to get typical font sizes from the browser. a 12pt in a 600x800 looks different than a 768x1200 browser. Or if you know another way to get the same size based on the browser?

I guess a way through java script to pass in the smaller font object.

I need to display 3 different font sizes in my applet embedded in the browser

thanks,
nick
0
Comment
Question by:nick5454
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 8059711
>> a 12pt in a 600x800 looks different than a 768x1200 browser
yes, but the font is still 12pt in size.
do you want to know the font size or resolution?
0
 
LVL 92

Expert Comment

by:objects
ID: 8061012
Use the FontMetrics class to get details about rendering a font on a particular screen.
0
 

Author Comment

by:nick5454
ID: 8072993
I use the smaller small, x-small descriptions. Will the font metrics do this for me
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 8074750
> I use the smaller small, x-small descriptions.

Sorry I'm not sure what you mean.

> Will the font metrics do this for me

The font metrics class will help you determine the size characters will be rendered at.
0
 

Author Comment

by:nick5454
ID: 8145566
smaller, x-smaller is html default sizes that are in relation to thew browser

i.e..

style"font-size:small"
0
 
LVL 92

Expert Comment

by:objects
ID: 8145657
I'm confused, are we talking about fonts in the applet, or the html?
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 400 total points
ID: 8147061
As I said the font size is not related to resolution. you can get the browser base fontsize by using this javascript:

<html>
<head>
<script language="JavaScript">
<!--
function getDefaultFontSize() {
  var getElement = document.getElementsByTagName("html");
  var ele = getElement[0];
 
  if (document.defaultView) {    
    var currentFontSize = document.defaultView.getComputedStyle(ele, null).getPropertyValue(fontSize);  
  }
  else if (ele.currentStyle) {    
    var currentFontSize = ele.currentStyle.fontSize;
  }
     
  var currFontSize = parseInt(currentFontSize, 10);

  return( currFontSize );
}
-->
</script>
</head>
<body>
  <p>abcdef ABCDEF 12345</p>
  <p>default font size: <script> document.write( getDefaultFontSize() ); </script></p>
</body>
</html>

you can change the IE's text size setting and refresh this page to see what you get. this is what I get from IE6:
large: 16pt, larger: 14pt, default: 12pt, smaller: 10pt, smallest: 9pt.

here is how you can communicate between javascript and applet:
http://www.codeguru.com/java/Applet/Javascript-LiveConnect/index.shtml
0
 
LVL 35

Expert Comment

by:girionis
ID: 10040899
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to kennethxu

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question