Re: Using Javascript to Detect Script Support in a Browser

From: Philippe Verdy (verdy_p@wanadoo.fr)
Date: Mon Jun 21 2010 - 17:10:09 CDT

  • Next message: Philippe Verdy: "RE: Writing a proposal for an unusual script: SignWriting"

    - For Japanese and Hangul scripts at least, you may detect the
    difference of widths between wide and narrow versions of the same
    character (I think that almost all of these fonts support both
    versions simultaneously, but I may be wrong).

    - For Simplified Chinese fonts, you may try to detect the difference
    of width between Bopomofo and Ideograms ; fonts for the PRC should
    also contain all Bopomofo characters (needed in Southern China,
    including Hong Kong and Macau), as mandated by the national GB18030
    standard (I may be wrong because not all the GB8030 requirements are
    mandated for systems used in Singapore).

    - For Traditional Chinese fonts, I have no suggestion, as Taiwan does
    not seem to mandate the support of Bopomofo in its national standard
    (but Traditional Chinese characters are also used in Southern China,
    including notably Hong Kong where the support of GB18030 for
    Simplified Chinese characters is however just an alternative to the
    support of Traditional Chinese characters, which are still acceptable
    there).

    - For the vertical traditional Mongolian script and for the Tibetan
    script (using vertically stacked compounds), you may also detect the
    difference of heights between various character sequences of those
    scripts, with the same font-family and same font-height (this may fail
    if the fallback squares are still vertically stacked by the browser's
    text renderer).

    - For the double diacritics, you may test the difference of widths
    between a pair of large Latin letters and a pair of the same letters
    with an intermediate double diacritic (but this may still fail as
    well).

    All these ideas will require tests on large sets of known fonts for
    each script (I have not tested them with the available fonts commonly
    found in those areas).

    Philippe.

    > On Tue, Jun 15, 2010 at 11:13 AM, Ed Trager <ed.trager@gmail.com> wrote:
    > > For monospaced scripts, I tried doing this:
    > >
    > > * In the first div put U+FFFE. Every browser I tested rendered
    > > U+FFFE as a square box.
    > > * In the second div put a representative character from the
    > > script, such as "中" or "文" for Chinese.
    > >
    > > In theory, the U+FFFE will always be rendered as a box with a fixed
    > > width, and one would expect that there is a fairly good probability
    > > that the fixed width of any Chinese font on the machine will not be
    > > exactly the same as the width of the fallback square box.
    > >
    > > But in practice, based on my tests, this does not work. One problem
    > > is that Firefox's fallback square boxes contain the Unicode code point
    > > hex digits -- and these fallback square boxes can actually be of
    > > different widths depending on the hex codes contained therein. Also
    > > it might just happen that the fixed width of the Chinese glyph is
    > > exactly the same width as that of the fallback box used to render the
    > > U+FFFE.
    > >
    > > It would be very nice to come up with a reliable solution for scripts
    > > that are traditionally monospaced. Does anyone have any brilliant
    > > ideas?



    This archive was generated by hypermail 2.1.5 : Mon Jun 21 2010 - 17:15:01 CDT