Application Tool Kit

ATK Text sizing and font issue on iOS

Hey there!

I'm having some problems to change the font and the text size on my app, using the ATK framework.

My goal would be to use a different font for the parsed text. I'm using the following code, but it seems to have no effect:

 UIFont* font = [UIFont fontWithName:@"Gurmukhi MN" size:80];
  [self.singleLineWidget setFont:font];

I've also tried using system's font to see if it was an issue with the font, but it's the same:

[self.singleLineWidget setFont:[UIFont italicSystemFontOfSize:16]];


And then I tried just changing the size of the text, but nothing happen either:
[self.singleLineWidget setTextSize:40];


I'm having problems with the text's color as well, the text get's parsed into black regardless the color I set as "normal color"

Also, when I select a word in the text it gets colored on selection color as expected, but then if I set the cursor somewhere else it gets colored on the normal color for a couple of seconds, but then goes back to black.


Thanks for your help!


Dear Gonzalo,


Thank you for contacting us.


Currently, it is the first time such bejavior is raised. At present, it has always been working fine.


Would it be possible to have your code? Also, which flavor of iOS are you using? A recent one?


Also, please note the ATK is rather old, and we do not plan to update it.


Best regards,


Olivier

Hey Oliver

I'm targeting iOS 9.0, here's a link to the code:
You can open the project at document-fill/Document/ios

The widget configuration lines are on SLWView.m, function configSingleLineWidget


Thanks!

 

Dear Gonzalo,


we found a workaround that allows to change font or textSize. You should proceed as follows in the didChangeText function (line 481 of your SLWView.m):

- (void)singleLineWidget:(SLTWSingleLineWidget *)sender didChangeText:(NSString*)text intermediate:(BOOL)intermediate {
  [self.singleLineWidget setCursorIndex:(int)text.length];
  UIFont* font = [UIFont fontWithName:@"Gurmukhi MN" size:5];
  [self.singleLineWidget setFont:font];
  [self.singleLineWidget setTextSize:5];
  if (!self.isBackspace && !intermediate) {


Best regards,


Olivier


NB: I removed the link to your project from this thread


1 person likes this
Thanks! I disabled the link on my side as well.

This did the trick for font and size, thanks for your help!

Any other workaround for the color issue by any chance?

 

Dear Gonzalo,


After discussing, we could find the below workaround:

-Create an observer on "font" (for example in the configSingleLineWidget function):

  UILabel* lbl = [self.singleLineWidget valueForKey:@"glyphView"];
  [lbl addObserver:self forKeyPath:@"font" options:0 context:nil];

-And then set the color as follows:

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context
{
  NSMutableAttributedString* str = [[self.singleLineWidget valueForKey:@"glyphView"] valueForKey:@"textWithStyle"];
  if (self.singleLineWidget.text.length <= str.length)
    [str addAttribute:NSForegroundColorAttributeName value:TEXT_COLOR range:NSMakeRange(0, self.singleLineWidget.text.length)];
  else
    [str addAttribute:NSForegroundColorAttributeName value:TEXT_COLOR range:NSMakeRange(0, str.length)];
}


Best regards,


Olivier

Hey Oliver! Thanks for your answer!
Sorry it took me long, I just saw the reply today.
I tried the code you said, but when you select a word it turns white for a while and goes back to black then. I tried setting directly textColor on the label, that reduces the time the black appears, but it's still visible.

Regarding the label, I'm having another issue with it (Maybe I should post this in a different thread? Let me know!)
I'm currently splitting the text in lines, and showing on the ATKWidget only the current line where the user is set.
I noticed that if I change from a small line to a long line, the label fails to resize to the right width, and the text get's cut off.



I checked the size of the label and I see it change when I move between two long lines, but when I tried to manually set it's dimensions, the text disappears.

Any idea how can I fix this?

Thanks!

 

Sorry, just noticed the image link is broken, here I attach the image:

image


 Thanks!

Dear Gonzalo,


unfortunately, I am afaire we have no easy solution for both issues.


And as the ATK is no longer updated, it is difficult for us to work on it.


Best regards,


Olivier

Login or Signup to post a comment