-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'toFont' helper can affect lineHeight if called with a result object from a previous 'toFont' invocation #11297
Comments
But if you increase your font size it should also increase the lineheight otherwise it wont fit 🤔 |
@LeeLenaleee I agree but my concern is related to the "meaning" of Let me start from some assumptions.
The
Coming back from the simple test (see comments): const original = {
size: 12
}; // Original doesn't have any lineHeight, therefore default 1.2 is used (factor)
const first = Chart.helpers.toFont(original);
// First (which is a font) has got lineHeight with value 14.4 therefore the meaning of lineHeight is changed
// not longer a factor but real line height That's why I'm proposing that Original: {
"size": 12
}
First: {
"family": "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
"lineHeight": 1.2,
"size": 12,
"style": "normal",
"weight": null,
"lh": 14.399999999999999,
"string": "normal 12px 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
}
Second: {
"family": "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
"lineHeight": 1.2,
"size": 12,
"style": "normal",
"weight": null,
"lh": 14.399999999999999,
"string": "normal 12px 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"
} and therefore, invoking several times @LeeLenaleee what do you think? Am I wrong? And apologize for long reply. |
@LeeLenaleee I thought more about that even if it's not 100% correct. Assuming that the current And currently changing the size or whatever other property of Something like (in proposed new const font = {
family: valueOrDefault(options.family, fallback.family),
lineHeight: valueOrDefault(options.lineHeight, fallback.lineHeight),
size,
style,
weight: valueOrDefault(options.weight, fallback.weight),
// new calculated and readonly properties
get string() {
return toFontString(this);
},
get heightOfLine() {
return toLineHeight(this.lineHeight, this.size);
}
};
return font; In this way, you could
Let me also add another topic (i think it's an issue that I would like to fix by PR).
/**
* Parses font options and returns the font object.
* @param options - A object that contains font options to be parsed.
* @param fallback - A object that contains fallback font options.
* @return The font object.
* @private
*/
export function toFont(options: Partial<FontSpec>, fallback?: Partial<FontSpec>) { |
Feature Proposal
Currently, if you invoke
toFont
helpers function passing as an argument the result object (anyway a font object), thelineHeight
property is not correct because the originallineHeight
overridden.Result:
I think the
lineHeight
property should maintain always the original value and adding another property for the resultlineHeight
.Possible Implementation
Current Implementation (
helpers.options.ts
, row 130):Possible implementation;
Of course, if implemented, it will be a breaking change.
What do you think?
The text was updated successfully, but these errors were encountered: