Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3849 from adobe/randy/issue-3478-again
Browse files Browse the repository at this point in the history
Use integer line-height to avoid rounding differences
  • Loading branch information
TomMalbran committed May 17, 2013
2 parents 6a8bcdb + 6bc0a9a commit c918b0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/view/ViewCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ define(function (require, exports, module) {
* The ratio of line-height to font-size when they use the same units
* @type {float}
*/
var LINE_HEIGHT = 1.3;
var LINE_HEIGHT = 1.25;

/**
* @private
Expand Down Expand Up @@ -171,7 +171,14 @@ define(function (require, exports, module) {
var lhOld = parseFloat(lhStyle.substring(0, lhStyle.length - 2));

var fsNew = fsOld + (delta * adjustment);
var lhNew = (fsUnits === lhUnits) ? fsNew * LINE_HEIGHT : lhOld;
var lhNew = lhOld;
if (fsUnits === lhUnits) {
lhNew = fsNew * LINE_HEIGHT;
if (lhUnits === "px") {
// Use integer px value to avoid rounding differences
lhNew = Math.ceil(lhNew);
}
}

var fsStr = fsNew + fsUnits;
var lhStr = lhNew + lhUnits;
Expand Down
6 changes: 3 additions & 3 deletions test/spec/ViewCommandHandlers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ define(function (require, exports, module) {
});

it("should keep the same font size when opening another document", function () {
var promise, expectedSize, editor;
var promise, originalSize, editor;

runs(function () {
editor = EditorManager.getCurrentFullEditor();
expectedSize = editor.getTextHeight() + 1;
originalSize = editor.getTextHeight();

promise = CommandManager.execute(Commands.VIEW_INCREASE_FONT_SIZE);
waitsForDone(promise, "Increase font size");
Expand All @@ -139,7 +139,7 @@ define(function (require, exports, module) {

runs(function () {
editor = EditorManager.getCurrentFullEditor();
expect(editor.getTextHeight()).toBe(expectedSize);
expect(editor.getTextHeight()).toBeGreaterThan(originalSize);
});

// This must be in the last spec in the suite.
Expand Down

0 comments on commit c918b0b

Please sign in to comment.