let's assume you can use a font which renders exactly the same in all browsers and is per default installed on all OSes...

You can use Javascript to determine the pixel length of this font!

E.g. by reading the coordinates of embracing links, this already worked with Netscape4-"DOM" and I used it this way to get font-width.

So just send a HTML-Page to your browser with the font and the JS and read out the results.

You can do it via a webserver and a form-submit (or AJAX's XmlHttpRequest) with the results or even by remotely telling a local Firefox to load and save the (enriched) local webpage (-remote option)

Cheers Rolf

UPDATE: Should even be possible to send the JS-Code via telnet to a MozRepl AddOn in FF.

NOTA BENE:This solution implies at least one running webbrowser, but gives you real control and testing over the resulting page.

UPDATE2: Well seems NS4 was also the last browser to support link-coordinates, but I'm sure that standard DOM has even much richer possibilities. ... indeed style.left, style.top or offsetLeft, offsetTop


In reply to Re: Pixel length of strings (Javascript+DOM) by LanX
in thread Pixel length of strings by TruthSeeker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.