Permalink
Browse files

Merge pull request #4239 from AnalyticalGraphicsInc/dont-skip-leg-day

Fix handling of oblique fonts
  • Loading branch information...
2 parents bf276e7 + 9bf5151 commit 1ab9c96d31bf416f3358d1f6d86e822fd6178e6a @hpinkos hpinkos committed on GitHub Aug 29, 2016
Showing with 7 additions and 2 deletions.
  1. +1 −0 CHANGES.md
  2. +6 −2 Source/ThirdParty/measureText.js
View
1 CHANGES.md
@@ -21,6 +21,7 @@ Change Log
* Added `GeocoderViewModel.keepExpanded` which when set to true will always keep the GeoCoder in its expanded state.
* Added support for `INT` and `UNSIGNED_INT` in `ComponentDatatype`.
* Added `ComponentDatatype.fromName` for getting a `ComponentDatatype` from its name.
+* Improve label quality for oblique and italic fonts. [#3782](https://github.com/AnalyticalGraphicsInc/cesium/issues/3782)
### 1.24 - 2016-08-01
View
8 Source/ThirdParty/measureText.js
@@ -95,14 +95,16 @@ define(function() {
var metrics = context2D.measureText(textstring),
fontFamily = getCSSValue(context2D.canvas,"font-family"),
fontSize = getCSSValue(context2D.canvas,"font-size").replace("px",""),
+ fontStyle = getCSSValue(context2D.canvas,"font-style"),
+ fontWeight = getCSSValue(context2D.canvas,"font-weight"),
isSpace = !(/\S/.test(textstring));
metrics.fontsize = fontSize;
// for text lead values, we meaure a multiline text container.
var leadDiv = document.createElement("div");
leadDiv.style.position = "absolute";
leadDiv.style.opacity = 0;
- leadDiv.style.font = fontSize + "px " + fontFamily;
+ leadDiv.style.font = fontStyle + " " + fontWeight + " " + fontSize + "px " + fontFamily;
leadDiv.innerHTML = textstring + "<br/>" + textstring;
document.body.appendChild(leadDiv);
@@ -125,8 +127,10 @@ define(function() {
canvas.style.opacity = 1;
canvas.style.fontFamily = fontFamily;
canvas.style.fontSize = fontSize;
+ canvas.style.fontStyle = fontStyle;
+ canvas.style.fontWeight = fontWeight;
var ctx = canvas.getContext("2d");
- ctx.font = fontSize + "px " + fontFamily;
+ ctx.font = fontStyle + " " + fontWeight + " " + fontSize + "px " + fontFamily;
var w = canvas.width,
h = canvas.height,

0 comments on commit 1ab9c96

Please sign in to comment.