-
Notifications
You must be signed in to change notification settings - Fork 483
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
implement styling of fill/stroke/strokeWidth when using Font.draw() or Glyph.draw() #626
base: master
Are you sure you want to change the base?
Conversation
I'll review this later today. |
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.
One discrepancy here with regard to other font renderers is the fact that lineWidth draws half the line inside the fill area, which means our stroke is actually half-width this way (at least with canvas, not sure about SVG). Also, Miter type becomes important when rendering the stroke on text, so we need to do some additional research with regards to that before this can go through. In my code base I'm using lineCap = "round"
and lineJoin = "round"
but this may only be correct for my use case.
I ended up having a little time to go through it now before work. |
I would treat the outline positioning as a separate follow-up issue. It comes into play during the actual canvas drawing and we'll have to take it into account there, but at least the values get passed along with the Path now. But good point with the line behaviour. We should take a look at that and find good values for it, and probably add an option to influence it according to one's needs. |
In my codebase I'm doing a kind of dirty hack by multiplying the outline width by 2 then filling the text with |
59e9008
to
64b0936
Compare
That's what I thought of doing. Doesn't even feel too dirty to me. |
The problem with that is that it doesn't work for SVG output, unless we want to use masking. |
64b0936
to
567ad16
Compare
Description
Implements a new method
Path.applyStyles()
, which applies valid style properties (fill, stroke, strokeWidth) to the Path. This is used inGlyph.getPath()
andFont.getPath()
and allows to specify styling options e.g. when usingFont.draw()
orGlyph.draw()
.Motivation and Context
Implements #623.
How Has This Been Tested?
Temporarily modifying
docs/index.html
Screenshots (if appropriate):
options in
renderText()
ofdocs/index.html
result:
Types of changes
Checklist:
npm run test
and all tests passed green (including code styling checks).