7

I'm trying to add 2 different font sizes for iphone and ipad layouts using size classes. It works cool with a default System font but doesn't work with custom font(I'm using PragmataPro in my project). If I add the second size for wR hR then font looks correctly in interface builder(I even checked xml) but in simulator and on device it becomes System instead of PragmataPro. But if I remove wR hR(or whatever layout I'm using for another size) then font shows correctly. Any idea how to solve this issue? Thanks!

Oleg Korban
  • 249
  • 3
  • 14
  • same question here: http://stackoverflow.com/questions/26166737/custom-font-sizing-in-ios-8-size-classes-not-working-properly-w-custom-fonts – osrl Jan 13 '15 at 23:53

3 Answers3

3

Subclass UILabel and override "layoutSubviews" method like:

- (void)layoutSubviews
{
 [super layoutSubviews];
 // Implement font logic depending on screen size
  self.font = [UIFont fontWithName:@"CustomFont" size:self.font.pointSize];
}
Shruti
  • 1,849
  • 1
  • 13
  • 21
  • That will work, but I am wondering why I cannot do the same in the xib itself. – Ramaraj T Apr 02 '15 at 12:20
  • check this... http://stackoverflow.com/questions/9090745/custom-font-in-a-storyboard – Shruti Apr 02 '15 at 12:32
  • 2
    I think u misunderstand the problem here. The problem is not using the custom font in xib/storyboard. The problem is using different sizes of custom font for different size classes. The single font size doesn't create any problem unless you add different font size for different layouts. – Ramaraj T Apr 02 '15 at 12:41
  • @RamarajT did you find a solution – Jules Nov 12 '15 at 19:17
0

Follow the link (it is a step-by-step from Apple):
https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/ChangingtheFontforaSizeClass.html

-1

The 'custom' is there to define one single setting per type class. If you don't define a 'custom' library with all the variations you want than I don't really think there to be a solution, mainly because by 'custom' you mean ONE SINGLE COMPONENT OF A GIVEN LIST OF CHOICES...