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

Login or Signup to post a comment