Mark- Posted February 28, 2015 Share Posted February 28, 2015 Hi, We have a Windows program that lets the user create graphics, rectangles, circles, text etc.. The user sets the text size for the font. For example, a 12pt Tahoma font is the same size in all other programs run on Windows. We take the drawing and convert to Javascript so it can be viewed in a browser, a new feature for us. All the shapes are the correct size. The text is not. I have searched and searched for a solution to the text size on Windows and the text size in the browser, how to make them match. I cannot be the first to run into this issue and I assume it is something simple I am missing. I am using jCanvas to draw the shapes and it wants the font size in pixels which is not the same as a Windows font size. Ideas? Thanks, Mark Link to comment Share on other sites More sharing options...
Mark- Posted March 1, 2015 Author Share Posted March 1, 2015 Hello, Well, there seems to be no fixed conversion value. After much reading and measuring, it appears a Windows font size multiplied by 1.33 gives the best result. Regards, Mark Link to comment Share on other sites More sharing options...
Ingolme Posted March 1, 2015 Share Posted March 1, 2015 pt is an absolute unit, while pixels are relative to the size of the screen. To transform from pt to px you need to know exactly how large a pixel on the user's monitor in real life. The information isn't available or if it is it's usually wrong. I tested using CSS's centimeter unit on a box and measured the screen with a ruler, the result turned out to be 9 millimeters, or 0.9 centimeters. So there's no real way to know for sure how many pt is a px. Using 1.33 might work on your screen, but on somebody else's screen it might not. If you can get the desktop program to use pixels instead that would work better. Either that, or use a different framework than jCanvas. As far as I know, the <canvas> element allows other units for its fonts including pt. Link to comment Share on other sites More sharing options...
Mark- Posted March 1, 2015 Author Share Posted March 1, 2015 Hi, Thanks for the response. >Using 1.33 might... I did not determine that from only my screen. I found several tables on the web for conversion. Regards, Mark Link to comment Share on other sites More sharing options...
Ingolme Posted March 2, 2015 Share Posted March 2, 2015 Hmm, maybe Windows has its own idea of how many points are to a pixel. I'd have to research and see why people suggest that number. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 2, 2015 Share Posted March 2, 2015 Why not just set the font size in points instead of pixels? Link to comment Share on other sites More sharing options...
Mark- Posted March 2, 2015 Author Share Posted March 2, 2015 (edited) Hi, Thanks for the response. >Why not just... I tried that and the fonts were the same size regardless of points or pixels. The author of jCanvas posted today that was a bug and it would be corrected very soon. Mark Edited March 2, 2015 by Mark- Link to comment Share on other sites More sharing options...
Mark- Posted March 3, 2015 Author Share Posted March 3, 2015 Hello, To wrap up, the jCanvas author released a new version today and corrected the font sizing issue. Using the point syntax , e.g. 12pt, the text sizes are correct. Regards, Mark Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now