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

Unset text formatting? #5

Open
awagner-mainz opened this issue Dec 17, 2020 · 4 comments
Open

Unset text formatting? #5

awagner-mainz opened this issue Dec 17, 2020 · 4 comments

Comments

@awagner-mainz
Copy link

I hope this is a proper place to ask this:

I am successfully producing a document, but to me it seems like once I set a text attribute, it stays put. And when I add more text, the formatting remains active.

d := rtfdoc.NewDocument()

d.SetOrientation(rtfdoc.OrientationPortrait)
d.SetFormat(rtfdoc.FormatA4)

p := d.AddParagraph()
txt := p.AddText("Test:", 48, rtfdoc.FontTimesNewRoman, rtfdoc.ColorBlack)
txt.SetBold().SetUnderlining()

txt2 := p.AddText(" Blabla", 48, rtfdoc.FontTimesNewRoman, rtfdoc.ColorBlack)
txt2.SetItalic()

p.AddNewLine()
p.AddText("Even more blabla", 48, rtfdoc.FontTimesNewRoman, rtfdoc.ColorBlack)

This results in everything being bold and underlined, whereas I would like (at least) the second line to be regular font weight and non-underlined. Also, starting after "Test:", everything is in italics, whereas the second line should not be.

What I get:

Test: Blabla
Even more blabla

What I'd want:

Test: Blabla
Even more blabla

(github markdown has no underlining.)

How do I achieve this?

@awagner-mainz
Copy link
Author

Is it the case that text.SetItalic produces \i{text}, whereas it should produce {\i text}?
I'll probably resort to coding my rtf "by hand", i.e. without importing a special library for it, but I'll try to keep an eye on this one...

@therox
Copy link
Owner

therox commented Jul 21, 2021

@awagner-mainz Thanks a lot for your issue. You're absolutely right about this problem. Fixed.

@entonio
Copy link

entonio commented Jan 9, 2022

Hi! I've come across this same issue today, with SetBold, when trying out your lib. Is there a solution for it? Thanks!

@therox
Copy link
Owner

therox commented Aug 4, 2022

@entonio can you provide your code? Can't reproduce this case.

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

No branches or pull requests

3 participants