Skip to content

Commit

Permalink
Fix bug in text width measurement
Browse files Browse the repository at this point in the history
Text width should be measured after context is set.
  • Loading branch information
efurmantt committed Aug 21, 2015
1 parent 16a079e commit 6c91360
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/javascript/components/defaultcellrenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var paint = function(gc, config) {

var cellPadding = config.cellPadding || 0;
var halignOffset = 0;
var textWidth = config.getTextWidth(gc, value);
var fontMetrics = config.getTextHeight(font);
var textWidth;
var fontMetrics;

if (gc.font !== config.font) {
gc.font = config.font;
Expand All @@ -30,6 +30,9 @@ var paint = function(gc, config) {
gc.textBaseline = 'middle';
}

textWidth = config.getTextWidth(gc, value);
fontMetrics = config.getTextHeight(font);

if (halign === 'right') {
//textWidth = config.getTextWidth(gc, config.value);
halignOffset = width - cellPadding - textWidth;
Expand Down

0 comments on commit 6c91360

Please sign in to comment.