jackyr / multi-clamp

Simple, efficient and easy-to-use multiline text clamp module. (supports reverse clamp)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

computation is off on firefox with roboto font weight 900

bitboxer opened this issue · comments

I just tried to use your nice library in a small side project, but sadly it fails to clamp correctly on Firefox 67.0.2 (64-bit) on my Linux machine. When using the Roboto Font with a font-weight of 900, it has too many characters. It should clamp after two lines, but the result is this:

Screenshot from 2019-06-15 13-28-49

With the font-weight of 400 it works.

Do you have an idea what is going on there? Would love to help out and fix it.

@bitboxer Thanks for using my library. I can't reproduce this problem with my Firefox browser, could you give me a real example in codepen?

Yes, of course. Will try to reproduce it on a codepen. Hope I can do it before thursday.

Sorry, didn't manage to provide you this. Sadly I am going to the euruko conference over the weekend. Will come back to you next week with this.

That's fine, have a good weekend.

It took me some time to figure out what went on, but now I found it. The library adds a span while trying out what text will fit into the element. And the css i used only added a specific font weight to the element, not the child elements. So the library calculated with the wrong font weight and then replaced the span with the text and then the css displayed the text in the correct weight again.

So one question: is the adding of the span really needed? Or can that part be rewritten to not do that? Otherwise other people might run into the same problem.

Thanks for pointing out the problem. I'll try to find another way instead of adding a span, and that may be a breaking change, so it will be solved in version 2.0.

Thank you! If you need anything, just ping. I would love to help out.

Multi-clamp v2.0 beta published, it will no longer add a span. Welcome feedback.

Hm, just tried with the 2.0 beta and it looks like it doesn't clamp at all in Firefox, but in Chrome it continues to work.

Here's an online cross-platform browser compatibility test website:
http://browsershots.org/https://jackyr.github.io/multi-clamp/example/index.html
I just test the demo page(v2.0.0-beta.0), and it works well in Firefox of any version and any platform. So I have no idea about what happened in your environment.

I will debug in more detail soonish.

Ah related: firefox 68 now supports --webkit-line-clamp

I see that. If there are no more problems with multi-clamp, the v2.0 official version will be released.