signintech / gopdf

A simple library for generating PDF written in Go lang
MIT License
2.57k stars 280 forks source link

Font size #86

Open ales6164 opened 6 years ago

ales6164 commented 6 years ago

I've forked your project and updated font size types to float64. Now it doesn't display any text. Do you have any idea what could be the issue?

oneplus1000 commented 6 years ago

I just guess, the issue is number format of font size. check your output pdf file (or debugging) format of font size should look like in this picture screen shot 2561-08-24 at 08 51 59

*12 in picture is font size

ales6164 commented 6 years ago

Is this feature/issue something that you would be willing to resolve and implement floating font size in your project? I've been looking at it for quite some time now and haven't made any progress.

futjikato commented 6 years ago

@ales6164 Check https://github.com/signintech/gopdf/blob/master/cache_content_text.go#L127 There your number gets formated as int ( %d ) not as a float ( %f )

I dont know if a float world even work. The specs are pretty non specific about that.

mtcxgarble commented 3 years ago

I dont know if a float world even work.

The PDFReference (for 1.4) says "[font] size is a number representing a scale factor" (TABLE 5.2 "Text state operators", in the description of the Tf-operator). And Section 3.2.2 "Numeric Objects" says "Throughout this book, the term number refers to an object whose type may be either integer or real."

I read that as "font size can be int or float", and looking at PDFs "in the wild", or what other PDF-generating libs do (e.g. iText setFontSize(float))... a float is fine :)

vantaboard commented 4 months ago

@oneplus1000 can you close this issue if it has been resolved? Looks like https://github.com/signintech/gopdf/pull/192 would have resolved the issue.