Search code examples
codemirrorreact-codemirror

CodeMirror text width for custom font


I have a custom theme for CM, important part is just this:

.CodeMirror, .CodeMirror * {
  font-family: "Roboto Mono" !important;
  font-size: 14px;
}

Using this theme causes the text to be measured incorrectly at first render, but it looks good after the editor updates:

enter image description here

Is there any way I could force the Editor/Doc to re-measure the text? Couldn't find any API methods.


Solution

  • I've added the CSS that you provided and it works very fine. Just you don't need to use the .CodeMirror *

    I think that your problem may be due to something else. Try to call editor.refresh(); after the page loaded.