Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

getting typical font size for applet

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
nick5454
Asked:
nick5454
  • 3
  • 2
  • 2
  • +1
1 Solution
 
kennethxuCommented:
>> 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
 
objectsCommented:
Use the FontMetrics class to get details about rendering a font on a particular screen.
0
 
nick5454Author Commented:
I use the smaller small, x-small descriptions. Will the font metrics do this for me
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
objectsCommented:
> 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
 
nick5454Author Commented:
smaller, x-smaller is html default sizes that are in relation to thew browser

i.e..

style"font-size:small"
0
 
objectsCommented:
I'm confused, are we talking about fonts in the applet, or the html?
0
 
kennethxuCommented:
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
 
girionisCommented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now