-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Char spacing #4642
Merged
Merged
Char spacing #4642
Changes from 9 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
a177f04
Fixed nested stencil masks not rendering correctly.
44fc6ec
Merge branch 'dev' of https://github.com/ceco-fmedia/pixi.js into dev
d350dfc
Fixed jslint errors.
208141e
Merge branch 'dev' into dev
ceco-fmedia 9da7205
Merge branch 'dev' into dev
bigtimebuddy 79e7988
Documented the changes.
d14c7f4
Merge remote-tracking branch 'upstream/dev' into dev
3287f11
Additional property: letterSpacing in BitmapText to set extra amount …
53d4cda
Fixed lint errors.
8f535bb
Fixed _maxWidth used instead of _letterSpacing.
609ae3f
Merge branch 'char_spacing' of https://github.com/ceco-fmedia/pixi.js…
c904b9e
Merge branch 'dev' of https://github.com/pixijs/pixi.js into dev
e1e0d49
Merge branch 'dev' of https://github.com/pixijs/pixi.js into char_spa…
c38b506
Merge branch 'dev' into char_spacing
25d0f95
Fixed word not moved to the next line when the next character is space.
7b3ece1
Break line after the following characters: -\/.,?!;:;
9875aff
Merge remote-tracking branch 'remotes/upstream/dev' into char_spacing
ceco-fmedia 76bf9fd
Fixed last line width when last character is space.
ceco-fmedia 6c2435c
Fixed typo.
ceco-fmedia e6351fb
Merge remote-tracking branch 'remotes/upstream/dev' into char_spacing
ceco-fmedia 79b349b
Merge branch 'dev' into char_spacing
ceco-fmedia eab47d2
Fixed line break characters not incrementing spacesRemoved.
ceco-fmedia ce8fea3
Merge branch 'char_spacing' of https://github.com/ceco-fmedia/pixi.js…
ceco-fmedia 824cca3
Merge branch 'dev' into char_spacing
bigtimebuddy f35fe1d
Merge branch 'dev' into char_spacing
ceco-fmedia 729f5f7
Merge branch 'dev' into char_spacing
bigtimebuddy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,13 @@ export default class BitmapText extends core.Container | |
*/ | ||
this._maxLineHeight = 0; | ||
|
||
/** | ||
* Letter spacing. This is useful for setting the space between characters. | ||
* @member {number} | ||
* @public | ||
*/ | ||
this._letterSpacing = 0; | ||
|
||
/** | ||
* Text anchor. read-only | ||
* | ||
|
@@ -205,10 +212,10 @@ export default class BitmapText extends core.Container | |
texture: charData.texture, | ||
line, | ||
charCode, | ||
position: new core.Point(pos.x + charData.xOffset, pos.y + charData.yOffset), | ||
position: new core.Point(pos.x + charData.xOffset + (this._letterSpacing / 2), pos.y + charData.yOffset), | ||
}); | ||
lastLineWidth = pos.x + (charData.texture.width + charData.xOffset); | ||
pos.x += charData.xAdvance; | ||
pos.x += charData.xAdvance + this._letterSpacing; | ||
lastLineWidth = pos.x; | ||
maxLineHeight = Math.max(maxLineHeight, (charData.yOffset + charData.texture.height)); | ||
prevCharCode = charCode; | ||
} | ||
|
@@ -484,6 +491,25 @@ export default class BitmapText extends core.Container | |
return this._textWidth; | ||
} | ||
|
||
/** | ||
* Additional space between characters. | ||
* | ||
* @member {number} | ||
*/ | ||
get letterSpacing() | ||
{ | ||
return this._letterSpacing; | ||
} | ||
|
||
set letterSpacing(value) // eslint-disable-line require-jsdoc | ||
{ | ||
if (this._maxWidth !== value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be this._letterSpacing |
||
{ | ||
this._letterSpacing = value; | ||
this.dirty = true; | ||
} | ||
} | ||
|
||
/** | ||
* The height of the overall text, different from fontSize, | ||
* which is defined in the style object | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this isn't public. The getter is what's public