Re: string resizing

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Russ (russk2_at_eticomm.net)
Date: 06/22/04


Date: Tue, 22 Jun 2004 11:21:51 -0400

It's not so easy. First you have to know what font is being used in
the browser. Then you need a table of character widths in pixels.
Finally you need to write a routine to index into the table and add up
all the widths for each character you want to display. You need to
know any scaling factor that has been applied to the font so you can
also apply it to your calculation.

I do this in order to center strings in a form when printing to a HP
printer and it works fine. But when you are dealing with unknowns
like "what browser and what font and what size?", it becomes a lot
more difficult. Perhaps there is a way to know the above information
- someone else will have to tell you about that.

HTH, Russ

On Mon, 21 Jun 2004 17:19:18 -0400, "Matt MacDonald"
<mattsmac@hotmail.com> wrote:

>Here's a pretty easy one i think.
>
>How do I trim a string to a certain (physical) length i.e. in pixels, as
>opposed to characters?
>
>I'm tring to fit strings in data cells in an asp datagrid.
>
>Thanks alot,
>Matt
>



Relevant Pages

  • Re: Encoding/characterset/font family confusion
    ... Browsers are *supposed* to switch fonts when they encounter a character ... the 'browser' in question was IE6. ... would have been nicer to have the same font all over the page. ... euro-sign with another font-family to get the Euro ...
    (comp.lang.php)
  • Re: Proportional font
    ... I include the style attribute just for completeness, to check that even if a specific font is suggested, the browser resorts to a backup font, which is proportional. ... The conclusion is, of course, that monospace fonts should not be used for text that contains characters that have some inherent width, i.e. some specific width is part of the definition of the character. ... Conceivably, if THIN SPACE appears and no available font contains a glyph for it, a browser could either just leave horizontal space accordingly or use SPACE instead - after all, THIN SPACE is a compatibility character, with the composition SPACE. ...
    (comp.infosystems.www.authoring.html)
  • Re: Layout of numbered equations?
    ... Well, I've just set Firefox to full screen width, 3/7 height, and zoomed ... Actual display depends on the character, not the way of representing it ... font settings in CSS, and on the browser (IE being the most ... (I allow my readers to use their chosen font). ...
    (comp.infosystems.www.authoring.html)
  • Re: Japanese characters in TITLE element
    ... My computer's language character set presumably stays the same ... It is not the browser, ... Window title is mart of the chrome and therefore under the ... If a font is not available ...
    (alt.html)
  • Re: How does MS Word arrange the inter word space?
    ... I posted some code recently in microsoft.public.word.printingfonts to extract the character widths for the ASCII character set. ... spaces is defined in the TrueType font which is the MS' default font. ... Jonathan West - Word MVP ...
    (microsoft.public.word.formatting.longdocs)