Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome wrapping text when using multiple languages and web fonts on windows

I have a site that has content in Arabic and English, I'm using a web font for styling the headers and some buttons Source Sans Pro for English and Droid Arabic Kufi for Arabic, so basically my css would look like this:

.header {
    font-family: 'Droid Arabic Kufi', 'Source Sans Pro', sans-serif;
}

The problem happens in Chrome on Windows when the element has a float style or is displayed as an inline-block, it for some reason wraps the text even it's not necessary, here is an example:

This is the sample on Mac, it shows on one line, with 156px width.

Mac

This is the sample on Windows, it shows on two lines with 154px width.

enter image description here

If I add white-space: nowrap; to the element windows will show it right, and what really makes it weird is that it uses the same width 154px.

enter image description here

I don't want to apply white-space: nowrap; because sometimes I need to wrap the text, and it's not an easy job to look for places where we need to use the custom font and not wrap the text.

I think the problem has something to do with white spaces, especially because I faced an issue that sometimes whitespace is replaced by a rectangle on Chrome

This issue only shows in Chrome on Windows.

like image 448
mpcabd Avatar asked Oct 21 '22 02:10

mpcabd


2 Answers

I have a similar problem, and using white-space: nowrap; is not an option.

We just have to wait for a chrome update, as I tested the same page in chrome beta channel v32 and no unnecessary wrapping was performed.

like image 151
MK. Avatar answered Oct 24 '22 01:10

MK.


I had a similar problem with various Google Web fonts in Chrome.

I added a space to the end of the printed text and chrome was able to resolve the length and wrapping properly.

My 2c on why this works

My guess is there is some extra step in rendering web-fonts and executes after the css-preprocessor has worked out the font spacing. Adding the extra space acts as a buffer for the css preprocessor.

like image 30
Ashley Coolman Avatar answered Oct 24 '22 03:10

Ashley Coolman