ios - Setting other font than system in WatchKit (Apple Watch) -


i have 1 apple watch app using menlo bold font label.

in first version of xcode supported watchkit able change font of label in storyboard menlo bold 36 , working fine.

in curent version (xcode 6.2) not possible more, found tutorial on how set custom font in apple watch, http://www.tech-recipes.com/rx/53710/how-do-i-use-custom-fonts-in-my-apple-watch-app/

i tutorial found code:

func printfonts() {     let fontfamilynames = uifont.familynames()     familyname in fontfamilynames {         println("------------------------------")         println("font family name = [\(familyname)]")         let names = uifont.fontnamesforfamilyname(familyname string)         println("font names = [\(names)]")     } } 

this code print available fonts.
used see why name of font have added.

at stage have not added custom font, run function see font available on apple watch default.
after running found:

/* lot of fonts before */ ------------------------------ font family name = [menlo] font names = [[menlo-bolditalic, menlo-regular, menlo-bold, menlo-italic]] ------------------------------ /* lot of fonts after */ 

it menlo-bold available on apple watch, can not select in storyboard.

so , think good, not need add font use it.

this code:

    // must maee attributed text     let attributedtextforhour = nsattributedstring(         string: "is working",         attributes: nsdictionary(object: uifont(name: "menlo-bold", size: 36)!, forkey:nsfontattributename))      // atributex text     mylabel.setattributedtext(attributedtextforhour) 

when run code in simulator, font of label not changed.
, here other strange things:

  • in debugger, when set break point on mylabel.setattributedtext(attributedtextforhour) , quick on attributedtextforhour showed in correct font.

so in debugger fine, on simulator not.

so how fix ?

i not have apple watch, can see happening on real device.

so, no know there problem in code or bug form apple.

if can test on computer , report results, useful also.

maybe whole problem because have not added menlo bold font outside , using printfont() function has shown. if know can download menlo bold font, please provide link, can test also.

i manage solve problem, posting future generations.

there few things have learned (after 3h of work)

if want add font printed in printfonts() things become complicated.

you can not add same name, must add different name, called menlo-bold-my.otf, , must change id of font. menlo-bold-my.otf same menlo-bold.otf apple.

for converting, manipulating fonts used program http://fontforge.github.io/en-us/


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -