Skip to content

Commit

Permalink
Merge pull request #7356 from dhowe/type-2.0
Browse files Browse the repository at this point in the history
Type 2.0
  • Loading branch information
davepagurek authored Dec 5, 2024
2 parents 7af092f + ecf8326 commit 584504d
Show file tree
Hide file tree
Showing 165 changed files with 10,058 additions and 5,370 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"author": "",
"husky": {
"hooks": {
"pre-commit": "lint-staged"

}
},
"msw": {
Expand Down
5 changes: 2 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ import math from './math';
math(p5);

// typography
import './typography/attributes';
import './typography/loading_displaying';
import './typography/p5.Font';
import type from './type'
type(p5);

// utilities
import utilities from './utilities';
Expand Down
16 changes: 12 additions & 4 deletions src/core/p5.Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ class Renderer {
imageMode: constants.CORNER,
rectMode: constants.CORNER,
ellipseMode: constants.CENTER,

textFont: 'sans-serif',
textLeading: 15,
leadingSet: false,
textSize: 12,
textAlign: constants.LEFT,
textBaseline: constants.BASELINE,
textStyle: constants.NORMAL,
textWrap: constants.WORD
textWrap: constants.WORD,

// added v2.0
fontStyle: constants.NORMAL, // v1: textStyle
fontStretch: constants.NORMAL,
fontWeight: constants.NORMAL,
lineHeight: constants.NORMAL,
fontVariant: constants.NORMAL,
direction: 'inherit'
};
this._pushPopStack = [];
// NOTE: can use the length of the push pop stack instead
Expand Down Expand Up @@ -194,13 +202,13 @@ class Renderer {
s === constants.BOLD ||
s === constants.BOLDITALIC
) {
this.states.textStyle = s;
this.states.fontStyle = s;
}

return this._applyTextProperties();
}

return this.states.textStyle;
return this.states.fontStyle;
}

textAscent () {
Expand Down
2 changes: 1 addition & 1 deletion src/shape/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function attributes(p5, fn){
) {
this._renderer.states.rectMode = m;
}
return this;
return this; // return current rectMode ?
};

/**
Expand Down
9 changes: 9 additions & 0 deletions src/type/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import text2d from './text2d.js';
import p5font from './p5.Font.js';

export default function(p5){
p5.registerAddon(text2d);
p5.registerAddon(p5font);
}

Loading

0 comments on commit 584504d

Please sign in to comment.