1

I have spent a long time looking at numerous solutions but to no avail. I used the following approach but am still stuck: Custom font is not working in my App?

I am currently trying to use a font family called "DFPGyoSho-Lt" In my font book, there is only one font under the family called "Regular"

Here's the steps I've taken:

  • Successfully added the font "DFPGyoSho-Lt.ttf" into my project and handled it in the plist.
  • Got the family name successfully using [UIFont familynames].
  • Found the actual name of the font using [UIFont fontNamesForFamilyName] method, which is: "DFGyoSho-Lt-MP-RKSJ-H"
  • Used [UIFont fontWithName...] to display the font in a UILabel. However, the font is incorrectly displayed.

The font itself displays correctly in XCode when I click on the ttf file so it does seem like XCode is able to read it. Unfortunately, I can't seem to access the file properly or something.

Also, I do have other custom fonts (otf format) that have been used successfully within the same project. It is only with this particular font that I have difficulty.

Appreciate your help! Thanks!


Update: Someone else passed me a similar (if not the same) set of fonts and those fonts worked fine.

So I think the font that I was initially using must have been corrupted. Strangely enough, that font was still being displayed successfully in the Font Book and when I use it with other programmes such as Open Office.

Moral of the story: If a set of code for custom font is working and a particular font does not work, then the fault is likely to lie with that particular font.

Community
  • 1
  • 1
Jon
  • 241
  • 2
  • 7

2 Answers2

0

Update: Someone else passed me a similar (if not the same) set of fonts and those fonts worked fine.

So I think the font that I was initially using must have been corrupted. Strangely enough, that font was still being displayed successfully in the Font Book and when I use it with other programmes such as Open Office.

Moral of the story: If a set of code for custom font is working and a particular font does not work, then the fault is likely to lie with that particular font.

Jon
  • 241
  • 2
  • 7
0

I think you are getting the font name correct.

particular font which doesn't work, still font name can be diffrent from font file name you can open the font file to check it or see this LINK.

Mayur Birari
  • 5,837
  • 8
  • 34
  • 61
amar
  • 1