-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Simplify setSubscript, setSuperscript #4190
Conversation
@denim2x this is how i prefer the code to be. If you want to discuss about why/ho or if you see something wrong in this approach, or you have strong opinions on the good in your version, i m very open to talk about it. |
var fontSize = this.getValueOfPropertyAt(line, char, 'fontSize'), | ||
baseline = this.getValueOfPropertyAt(line, char, 'deltaY') + fontSize * schema.baseline; | ||
this.setPropertyAt(line, char, 'deltaY', baseline); | ||
this.setPropertyAt(line, char, 'fontSize', fontSize * schema.size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this;
src/shapes/text.class.js
Outdated
|
||
_setScript: function(line, char, schema) { | ||
var fontSize = this.getValueOfPropertyAt(line, char, 'fontSize'), | ||
baseline = this.getValueOfPropertyAt(line, char, 'deltaY') + fontSize * schema.baseline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's supposed to be ... + fontSize * -schema.baseline (follows the baseline-shift attribute from SVG)
src/shapes/text.class.js
Outdated
return this._setScript(line, char, this.subscript); | ||
}, | ||
|
||
_setScript: function(line, char, schema) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some checks are missing here
... the rest looks ok |
after swapping the signs we should either rename |
Names are fine. We do not mirror any name other that for comfort. Fabric will not have support for baseline has people knows it, |
fine |
There are some reasons behind having the code in this simpler form:
providing that we are not duplicating code or violating any normal coding good practice, this code is smaller.
The functionality behind
*fontSize
was a singular case that would have need its own doc, explanationall the fabric functions for style set char by char, introducing a
many lines, many chars
would have make the other methods impair. Also we have setSelectionStyles to do this and can be used in the same way.i believe that for who comes tomorrow this function _setScript is very easy to read.