Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line height is too low #4300

Closed
eugen1j opened this issue May 18, 2020 · 10 comments
Closed

Line height is too low #4300

eugen1j opened this issue May 18, 2020 · 10 comments

Comments

@eugen1j
Copy link

eugen1j commented May 18, 2020

Hello!

I have a strange behavior of Ace editor on websites. Editor lines overlap each other.

https://ace.c9.io/
image

https://editor.swagger.io/
image

Here the same problem in Postman:
postmanlabs/postman-app-support#6760

Environment:

  • Chrome Version 81.0.4044.138
  • MacOS Catalina 10.15.4

How can I solve this problem?

@nightwing
Copy link
Member

Hi, this is very strange, seems like line height is not calculated correctly, but i could not reproduce the issue.

Does this happen on firefox too?

What happens when running editor.renderer.$textLayer.$fontMetrics.$measureSizes() in browser console on ace.c9.io ?

@eugen1j
Copy link
Author

eugen1j commented May 19, 2020

@nightwing

Chrome:

{
    height: 5, 
    width: 7.203125
}

image

Firefox looks good:

 { 
    height: 14, 
    width: 7.19921875 
}

image

@nightwing
Copy link
Member

Thanks! I am very sorry but i have to ask you for more help, because i don't have any idea what could cause the height of measure node to be smaller than the font size.

Could you try running the following code

console.log(el.getBoundingClientRect())
console.log(el.style.cssText)
el = editor.renderer.$textLayer.$fontMetrics.$measureNode; 
el.style.visibility = "visible"; 
el.style.background="gold"
el.style.zIndex = 10000;
el.parentNode.style.overflow = ""
el.clientHeight

and if the above doens't help

editor.container.style.lineHeight=2 

Also sometimes issues like this can be caused by browser extensions, could you check if editor works in an incognito tab?

@eugen1j
Copy link
Author

eugen1j commented May 19, 2020

@nightwing Yes, sure.

I try the following code in an incognito tab with no luck.

image

editor.container.style.lineHeight=2 

This code helps to expand rows

image

Also, I find this bug in Postman postmanlabs/postman-app-support#6760

@nightwing
Copy link
Member

Interesting, this looks like a bug in chrome.
could you try running getComputedStyle(editor.container).lineHeight to see if the value is default "normal" as it should be
Then try to explicitly set line height editor.container.lineHeight = "normal" ,
and then try another font editor.container.style.fontFamily = "Courier", maybe this will help us to isolate minimal testcase that reproduces the issue.

@eugen1j
Copy link
Author

eugen1j commented May 19, 2020

Yes, editor.container.style.fontFamily = "Courier" fixes the problem

image

So, how can I set default fontFamily for Chrome and Postman?

@nightwing
Copy link
Member

Maybe there is a broken/(not supported by chrome) font installed on your computer.
Try running the following code several times until you find the one which is rendered with 5px height, and then one which is rendered normally.

editor.fonts = editor.fonts || 'Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace'.split(/,\s*/)
editor.container.style.fontFamily = editor.fonts.shift()

Then try finding the file for that font. (the file may be useful for submitting to chrome bug tracker)

@eugen1j
Copy link
Author

eugen1j commented May 20, 2020

Yes, it was a problem with font Monaco on my computer. I had two copies of this font, one was broken. I deleted it using Font Book for MacOS. Now the editor looks good.

image

Thank you, @nightwing!

@nightwing
Copy link
Member

Is there a way you can recover the deleted font file? I think we should report the bug to chrome, because firefox didn't have a problem with that font.

@eugen1j
Copy link
Author

eugen1j commented May 21, 2020

@nightwing I had two copies of font Monaco. I suppose Firefox used the first, correct font file.

The second one looked bad in Font Book so it isn't chrome's bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants