Bug 101692 - Add methods to get and set the font or at least font size in a FormFieldText
Summary: Add methods to get and set the font or at least font size in a FormFieldText
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: qt frontend (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-04 11:58 UTC by Hans-Ulrich Jüttner
Modified: 2017-09-08 07:07 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Added methods to get and set the font size of text fields (5.42 KB, patch)
2017-07-17 10:22 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (5.59 KB, patch)
2017-07-19 10:40 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (5.65 KB, patch)
2017-08-02 11:54 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (7.21 KB, patch)
2017-08-17 08:11 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (7.22 KB, patch)
2017-08-17 09:34 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (7.29 KB, patch)
2017-08-28 08:44 UTC, Hans-Ulrich Jüttner
Details | Splinter Review
Added methods to get and set the font size of text fields (7.64 KB, patch)
2017-09-06 09:17 UTC, Hans-Ulrich Jüttner
Details | Splinter Review

Description Hans-Ulrich Jüttner 2017-07-04 11:58:44 UTC
It would be nice to have a possibility to get and set the font of the text
in a FormFieldText with poppler.
Comment 1 Hans-Ulrich Jüttner 2017-07-17 10:22:45 UTC
Created attachment 132730 [details] [review]
Added methods to get and set the font size of text fields
Comment 2 Hans-Ulrich Jüttner 2017-07-19 10:40:12 UTC
Created attachment 132756 [details] [review]
Added methods to get and set the font size of text fields

I realized that I also had to change the variable defaultAppearance and call
updateChildrenAppearance() afterwards.
Comment 3 Hans-Ulrich Jüttner 2017-08-02 11:54:14 UTC
Created attachment 133195 [details] [review]
Added methods to get and set the font size of text fields

New patch adapted to changes from the merged better_object branch.
Comment 4 Albert Astals Cid 2017-08-15 22:24:34 UTC
AnnotFreeText::parseAppearanceString is doing very similar parsing to what you're doing.

Can you can try to generalize/reuse it? Having two sets of code that do the same in in slightly different ways is not a good idea.
Comment 5 Hans-Ulrich Jüttner 2017-08-17 08:11:27 UTC
Created attachment 133569 [details] [review]
Added methods to get and set the font size of text fields

I changed AnnotFreeText::parseAppearanceString() to use a new static method
FormFieldText::tokenizeDA() from Form.h.
Comment 6 Hans-Ulrich Jüttner 2017-08-17 09:34:33 UTC
Created attachment 133570 [details] [review]
Added methods to get and set the font size of text fields

Fixes a bug in the last patch.
Comment 7 Albert Astals Cid 2017-08-17 22:47:44 UTC
int FormFieldText::tokenizeDA(GooString* da, GooList* daToks)

returning the position of "Tf" is weird API.

I understand you don't want to search in daToks again since you just searched into it.

To make it less bad i guess you could add a const char * parameter saying "and in addition i want to look for this", is the same but makes the API a bit more saner.

What do you think?
Comment 8 Hans-Ulrich Jüttner 2017-08-28 08:44:04 UTC
Created attachment 133832 [details] [review]
Added methods to get and set the font size of text fields

I changed the weird API according your suggestion.
Comment 9 Albert Astals Cid 2017-09-05 21:09:07 UTC
Any reason you're using isspaces instead of Lexer::isSpace?

In FormFieldText::setTextFontSize if idx is -1 we should give a warning and skip doing all the work for nothing, no? Should we even return false in that case?

Also i'd prefer if we return -1 in  FormFieldText::getTextFontSize if the font size is not found, seems error return like for "it failed" than 0, that while a weird size i can see some cases in which it is "correct-ish"
Comment 10 Hans-Ulrich Jüttner 2017-09-06 07:30:49 UTC
(In reply to Albert Astals Cid from comment #9)
> Any reason you're using isspaces instead of Lexer::isSpace?

No special reason, I just used isspace() from libc because I'm familiar with it.
If Lexer::isSpace() is equivalent and the preferred way to do it in poppler,
I'll replace isspace() with it.

> 
> In FormFieldText::setTextFontSize if idx is -1 we should give a warning and
> skip doing all the work for nothing, no? Should we even return false in that
> case?

Ok, I'll do that.

> 
> Also i'd prefer if we return -1 in  FormFieldText::getTextFontSize if the
> font size is not found, seems error return like for "it failed" than 0, that
> while a weird size i can see some cases in which it is "correct-ish"

Ok, that reasonable.
Comment 11 Albert Astals Cid 2017-09-06 07:57:21 UTC
(In reply to Hans-Ulrich Jüttner from comment #10)
> (In reply to Albert Astals Cid from comment #9)
> > Any reason you're using isspaces instead of Lexer::isSpace?
> 
> No special reason, I just used isspace() from libc because I'm familiar with
> it.
> If Lexer::isSpace() is equivalent and the preferred way to do it in poppler,
> I'll replace isspace() with it.

Well, it's what AnnotFreeText::parseAppearanceString was using so yes, let's continue using it unless you have a strong reason not to :)
Comment 12 Hans-Ulrich Jüttner 2017-09-06 09:17:51 UTC
Created attachment 133987 [details] [review]
Added methods to get and set the font size of text fields

New patch with the changes discussed above.
Comment 13 Albert Astals Cid 2017-09-06 19:18:23 UTC
Do you have any app you plan to use this?
Comment 14 Hans-Ulrich Jüttner 2017-09-07 07:12:28 UTC
(In reply to Albert Astals Cid from comment #13)
> Do you have any app you plan to use this?

Yes, I'm planning to use this in an application of my company filling
PDF forms from the german health system. The rules for these forms say
that the font size on some multi line text fields has to be chosen
depending on the length of the text filled into that fields.
Comment 15 Albert Astals Cid 2017-09-07 19:41:55 UTC
Ok, pushed, i'd be happier if i could try this on an existing application.

Please note that poppler is GPL and that carries some obligations for the application you develop, i'm sure you already know but just a kind reminder :)
Comment 16 Hans-Ulrich Jüttner 2017-09-08 07:07:19 UTC
(In reply to Albert Astals Cid from comment #15)
> Ok, pushed, i'd be happier if i could try this on an existing application.
> 
> Please note that poppler is GPL and that carries some obligations for the
> application you develop, i'm sure you already know but just a kind reminder
> :)

Yes, of course, as we only use this laboratory information system ourselves,
we do comply with the GPL of poppler and other libraries.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.