From bceb4bfca2dfe5d34306e35c7c2f72b1910e14ff Mon Sep 17 00:00:00 2001 From: David Schnur Date: Tue, 2 Apr 2013 08:20:40 -0400 Subject: [PATCH] Added lineHeight to the font-spec object. Line height is a core font property - it can be specified as part of the unified 'font' definition - and we therefore need to give users access to it when they're manually defining the font. --- API.md | 4 ++++ jquery.flot.js | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/API.md b/API.md index 1350a7c..29696a3 100644 --- a/API.md +++ b/API.md @@ -298,6 +298,7 @@ with this format: ```js { size: 11, + lineHeight: 13, style: "italic", weight: "bold", family: "sans-serif", @@ -306,6 +307,9 @@ with this format: } ``` +The size and lineHeight must be expressed in pixels; CSS units such as 'em' +or 'smaller' are not allowed. + The options "min"/"max" are the precise minimum/maximum value on the scale. If you don't specify either of them, a value will automatically be chosen based on the minimum/maximum data values. Note that Flot diff --git a/jquery.flot.js b/jquery.flot.js index ff5d6c8..4f21497 100644 --- a/jquery.flot.js +++ b/jquery.flot.js @@ -286,7 +286,7 @@ Licensed under the MIT license. // If the font is a font-spec object, generate a CSS font definition if (typeof font === "object") { - textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px " + font.family; + textStyle = font.style + " " + font.variant + " " + font.weight + " " + font.size + "px/" + font.lineHeight + "px " + font.family; } else { textStyle = font; } @@ -453,7 +453,7 @@ Licensed under the MIT license. show: null, // null = auto-detect, true = always, false = never position: "bottom", // or "top" mode: null, // null or "time" - font: null, // null (derived from CSS in placeholder) or object like { size: 11, style: "italic", weight: "bold", family: "sans-serif", variant: "small-caps" } + font: null, // null (derived from CSS in placeholder) or object like { size: 11, lineHeight: 13, style: "italic", weight: "bold", family: "sans-serif", variant: "small-caps" } color: null, // base color, labels, ticks tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)" transform: null, // null or f: number -> number to transform axis @@ -672,6 +672,8 @@ Licensed under the MIT license. family: placeholder.css("font-family") }; + fontDefaults.lineHeight = fontDefaults.size * 1.15; + axisCount = options.xaxes.length || 1; for (i = 0; i < axisCount; ++i) {