提交 556b8425 编写于 作者: A Alex Dima

Fixes Microsoft/monaco-editor#127: Set the font on the canvas context...

Fixes Microsoft/monaco-editor#127: Set the font on the canvas context correctly, add an extra 2px for Japanese
上级 538cd9de
......@@ -109,12 +109,14 @@ export class KeyboardHandler extends ViewEventHandler implements IDisposable {
let cs = dom.getComputedStyle(this.textArea.actual);
if (browser.isFirefox) {
// computedStyle.font is empty in Firefox...
context.font = `${cs.fontStyle} ${cs.fontVariant} ${cs.fontWeight} ${cs.fontStretch} ${cs.fontSize} / ${cs.lineHeight} '${cs.fontFamily}'`;
context.font = `${cs.fontStyle} ${cs.fontVariant} ${cs.fontWeight} ${cs.fontStretch} ${cs.fontSize} / ${cs.lineHeight} ${cs.fontFamily}`;
let metrics = context.measureText(e.data);
StyleMutator.setWidth(this.textArea.actual, metrics.width + 2); // +2 for Japanese...
} else {
context.font = cs.font;
let metrics = context.measureText(e.data);
StyleMutator.setWidth(this.textArea.actual, metrics.width);
}
let metrics = context.measureText(e.data);
StyleMutator.setWidth(this.textArea.actual, metrics.width);
}
}));
......
......@@ -117,11 +117,8 @@ export class TextAreaHandler extends Disposable {
this.textareaIsShownAtCursor = true;
// In IE we cannot set .value when handling 'compositionstart' because the entire composition will get canceled.
let shouldEmptyTextArea = true;
if (shouldEmptyTextArea) {
if (!this.Browser.isEdgeOrIE) {
this.setTextAreaState('compositionstart', this.textAreaState.toEmpty());
}
if (!this.Browser.isEdgeOrIE) {
this.setTextAreaState('compositionstart', this.textAreaState.toEmpty());
}
this._onCompositionStart.fire({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册