mnater / Hyphenopoly

Hyphenation for node and Polyfill for client-side hyphenation.
http://mnater.github.io/Hyphenopoly/
MIT License
689 stars 45 forks source link

Hyphenopoly doesn't seem to work with Firefox 94 #175

Closed rajeeshknambiar closed 2 years ago

rajeeshknambiar commented 2 years ago

Thank you for the excellent Hyphenopoly script; it is made use of in open-access publishing of classic works in Malayalam language at https://books.sayahna.org/.

Since upgrading to Firefox 94, I have noticed that hyphenation does not seem to work. On debugging, the scripts seems to load; but does not hyphenate words. Chrom{e,ium} and Safari works fine; so does old versions of Firefox.

Could you take a look at this website and suggest if there is something to be corrected in the script loading; or is it an issue with Hyphenopoly?

mnater commented 2 years ago

Hi

Thank you for your kind words.

It's strange: I've just checked the website in FF 94.0.1 on Windows and everything looks good. I'll check on Mac OS this evening. Your code looks correct, too.

Are there any error messages in the Web Developer Tools Console?

mnater commented 2 years ago

Just checked on Mac OS and it works fine: image

rajeeshknambiar commented 2 years ago

It's strange: I've just checked the website in FF 94.0.1 on Windows and everything looks good. I'll check on Mac OS this evening. Your code looks correct, too.

Thank you for taking a look; and it is good to know that hyphenation works on Windows and macOS. I am on Linux, not sure if that has any impact. I have a few addons installed, notably NoScript but all domains on this site are fully trusted to execute javascript code. I tried disabling it to ensure that is not a factor; and does not seem to have made a difference.

Are there any error messages in the Web Developer Tools Console?

There are no error messages, only a warning. I am suspecting some issue local to my system (going to check with few users to confirm).

Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content.

at Hyphenopoly_Loader.js:266:38.

image

mnater commented 2 years ago

I just checked with Firefox 94.0.2 on Ubuntu and it works for me.

The warning about forced layout is due to the feature test. Hyphenopoly_Loader checks if the browser has native support for hyphenation in the specified language(s) - Malayalam in your case - and needs to measure the text-height which triggers a layout.

Since AFAIK no browser currently supports native hyphenation of Malayalam you could use FORCEHYPHENOPOLY:

var Hyphenopoly = {
    require: {
        "ml": "FORCEHYPHENOPOLY"
    }, 
    paths: {
        patterndir: "./script/patterns/",
        maindir: "./script/"
    },
    setup: {
        selectors: {
            ".container": {
                hyphen: "\u200B",
                 leftmin: 3,
                 rightmin: 3
            }
        }
    }
};

This triggers hyphenation by Hyphenopoly and thus prevents the feature check (and the forced layout).

rajeeshknambiar commented 2 years ago

Thanks very much for verifying this. Another Linux user independently verified that it works for them; so this is very likely an issue on my end. I am closing this but report.

Thanks also for the tip to force enable Hyphenopoly.

BTW, Chrom{e,ium} (since 88, I guess) natively supports Malayalam hyphenation; Firefox unfortunately hasn't incorporated it since 6 years the code was made available and reporting a bug.