disable bold style if font doesn't support it
This commit is contained in:
parent
49a120990f
commit
c6523b8fea
3 changed files with 23 additions and 14 deletions
|
|
@ -42,7 +42,8 @@ var Text = function(parentEl) {
|
||||||
this.element.className = "ace_layer ace_text-layer";
|
this.element.className = "ace_layer ace_text-layer";
|
||||||
parentEl.appendChild(this.element);
|
parentEl.appendChild(this.element);
|
||||||
|
|
||||||
this.$characterSize = this.$measureSizes() || {width: 0, height: 0};
|
this.$characterSize = {width: 0, height: 0};
|
||||||
|
this.checkForSizeChanges();
|
||||||
this.$pollSizeChanges();
|
this.$pollSizeChanges();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -72,7 +73,11 @@ var Text = function(parentEl) {
|
||||||
this.checkForSizeChanges = function() {
|
this.checkForSizeChanges = function() {
|
||||||
var size = this.$measureSizes();
|
var size = this.$measureSizes();
|
||||||
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
|
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
|
||||||
|
this.$measureNode.style.fontWeight = "bold";
|
||||||
|
var boldSize = this.$measureSizes();
|
||||||
|
this.$measureNode.style.fontWeight = "";
|
||||||
this.$characterSize = size;
|
this.$characterSize = size;
|
||||||
|
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
|
||||||
this._emit("changeCharacterSize", {data: size});
|
this._emit("changeCharacterSize", {data: size});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
}
|
}
|
||||||
/* bold keywords cause cursor issues for some fonts */
|
/* bold keywords cause cursor issues for some fonts */
|
||||||
/* this disables bold style for editor and keeps for static highlighter */
|
/* this disables bold style for editor and keeps for static highlighter */
|
||||||
.ace-github.ace_editor .ace_line > span {
|
.ace-github.ace_nobold .ace_line > span {
|
||||||
font-weight: normal !important;
|
font-weight: normal !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,6 @@ var VirtualRenderer = function(container, theme) {
|
||||||
|
|
||||||
this.$markerFront = new MarkerLayer(this.content);
|
this.$markerFront = new MarkerLayer(this.content);
|
||||||
|
|
||||||
this.characterWidth = textLayer.getCharacterWidth();
|
|
||||||
this.lineHeight = textLayer.getLineHeight();
|
|
||||||
|
|
||||||
this.$cursorLayer = new CursorLayer(this.content);
|
this.$cursorLayer = new CursorLayer(this.content);
|
||||||
this.$cursorPadding = 8;
|
this.$cursorPadding = 8;
|
||||||
|
|
||||||
|
|
@ -136,12 +133,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$textLayer.addEventListener("changeCharacterSize", function() {
|
this.$textLayer.addEventListener("changeCharacterSize", function() {
|
||||||
_self.characterWidth = textLayer.getCharacterWidth();
|
_self.updateCharacterSize();
|
||||||
_self.lineHeight = textLayer.getLineHeight();
|
|
||||||
_self.$updatePrintMargin();
|
|
||||||
_self.onResize(true);
|
_self.onResize(true);
|
||||||
|
|
||||||
_self.$loop.schedule(_self.CHANGE_FULL);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$size = {
|
this.$size = {
|
||||||
|
|
@ -172,7 +165,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.$loop.schedule(this.CHANGE_FULL);
|
this.$loop.schedule(this.CHANGE_FULL);
|
||||||
|
|
||||||
this.setPadding(4);
|
this.setPadding(4);
|
||||||
this.$updatePrintMargin();
|
this.updateCharacterSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
@ -191,6 +184,17 @@ var VirtualRenderer = function(container, theme) {
|
||||||
this.CHANGE_H_SCROLL = 1024;
|
this.CHANGE_H_SCROLL = 1024;
|
||||||
|
|
||||||
oop.implement(this, EventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
|
this.updateCharacterSize = function() {
|
||||||
|
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
|
||||||
|
this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
|
||||||
|
this.setStyle("ace_nobold", !this.$allowBoldFonts);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.characterWidth = this.$textLayer.getCharacterWidth();
|
||||||
|
this.lineHeight = this.$textLayer.getLineHeight();
|
||||||
|
this.$updatePrintMargin();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VirtualRenderer.setSession(session)
|
* VirtualRenderer.setSession(session)
|
||||||
|
|
@ -1362,8 +1366,8 @@ var VirtualRenderer = function(container, theme) {
|
||||||
*
|
*
|
||||||
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
|
* [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle}
|
||||||
**/
|
**/
|
||||||
this.setStyle = function setStyle(style) {
|
this.setStyle = function setStyle(style, include) {
|
||||||
dom.addCssClass(this.container, style);
|
dom.setCssClass(this.container, style, include != false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1373,7 +1377,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
|
* [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle}
|
||||||
**/
|
**/
|
||||||
this.unsetStyle = function unsetStyle(style) {
|
this.unsetStyle = function unsetStyle(style) {
|
||||||
dom.removeCssClass(this.container, style);
|
dom.removeCssClass(this.container, style);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue