Skip to content
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

Merged
merged 4 commits into from
Aug 16, 2017
Merged

Simplify setSubscript, setSuperscript #4190

merged 4 commits into from
Aug 16, 2017

Conversation

asturur
Copy link
Member

@asturur asturur commented Aug 12, 2017

There are some reasons behind having the code in this simpler form:

  1. providing that we are not duplicating code or violating any normal coding good practice, this code is smaller.

  2. The functionality behind *fontSize was a singular case that would have need its own doc, explanation

  3. all 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.

  4. i believe that for who comes tomorrow this function _setScript is very easy to read.

@asturur
Copy link
Member Author

asturur commented Aug 12, 2017

@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.

@asturur asturur changed the title Semplify setSubscript, setSuperscript Simplify setSubscript, setSuperscript Aug 12, 2017
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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return this;


_setScript: function(line, char, schema) {
var fontSize = this.getValueOfPropertyAt(line, char, 'fontSize'),
baseline = this.getValueOfPropertyAt(line, char, 'deltaY') + fontSize * schema.baseline;
Copy link

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)

return this._setScript(line, char, this.subscript);
},

_setScript: function(line, char, schema) {
Copy link

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

@denim2x
Copy link

denim2x commented Aug 15, 2017

... the rest looks ok

@denim2x
Copy link

denim2x commented Aug 16, 2017

after swapping the signs we should either rename deltaY to baseline - or change the schemas' baseline into deltaY - correct?

@asturur
Copy link
Member Author

asturur commented Aug 16, 2017

Names are fine. We do not mirror any name other that for comfort.
Subscript/superScript can have any name in the style as long as it moves the thing in the right direction.
Having to swap the sign of schema multiplier is an added notion that a dev should remember, that is why i moved the signs.

Fabric will not have support for baseline has people knows it,
Fabric supports just baseline alphabetic and i do not want to give impression that they can use other values giving a a property with the same name in the style.

@asturur asturur merged commit d8748bd into baseline-shift Aug 16, 2017
@denim2x
Copy link

denim2x commented Aug 16, 2017

fine

@asturur asturur deleted the pr-branch branch August 17, 2017 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants