-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Add align type Justify to texts #460
Add align type Justify to texts #460
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #460 +/- ##
==========================================
- Coverage 85.71% 84.60% -1.11%
==========================================
Files 61 61
Lines 2155 2174 +19
==========================================
- Hits 1847 1839 -8
- Misses 281 308 +27
Partials 27 27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Awesome contribution, I just added a couple of comments. Could you solve them? |
internal/providers/gofpdf/text.go
Outdated
for _, word := range words { | ||
s.pdf.Text(x, yColOffset+top, word) | ||
x += s.pdf.GetStringWidth(word) + spaceWidth | ||
} |
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.
If you see the other alignments there are a logic as:
if textProp.Hyperlink != nil {
s.pdf.LinkString(dx+xColOffset+left, yColOffset+top-fontHeight, textWidth, fontHeight, *textProp.Hyperlink)
s.pdf.LinkString(dx+xColOffset+left, yColOffset+top-fontHeight, textWidth, fontHeight, *textProp.Hyperlink)
}
This is important to apply a link to text if required, I think that we have to add this here too. Otherwise, we will introduce a bug that links doesn't work with justify.
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.
Thanks for the tip.
I added the hyperlink in the justified text.
There are some lint issues pointed out too. About the unit tests you can let without. I'm about to refactor this text component entirely. |
Awesome work @ArianeASA ! |
Description
Added the justified alignment type for texts, which aligns the text with the margins.
The new type calculates the size of white space needed to completely fill a line.
Related Issue
Checklist
func (<first letter of struct> *struct) method() {}
name style.when,should
naming pattern.m := mocks.NewConstructor(t)
.m.EXPECT().MethodName()
method to mock methods.example_test.go
.make dod
with none issues pointed out bygolangci-lint