Reputation: 1
Today I find a big problem for my application in swift 3: all greek letter (as picture) don't appear in the app storyboard and layout; all other emoji and special character work.
It's a Swift bug? I need of this characters for my Math application.
Upvotes: 0
Views: 6848
Reputation: 47896
I have checked the three characters in your comment (such info needs to be in your question, not in comment), and they all are non-BMP characters in the Mathematical Alphanumeric Symbols code block.
"𝛌" //MATHEMATICAL BOLD SMALL LAMDA U+1D6CC
"𝛗" //MATHEMATICAL BOLD SMALL PHI U+1D6D7
"𝛿" //MATHEMATICAL ITALIC SMALL DELTA U+1D6FF
iOS
As far as I tested, all fonts installed in iOS 10 simulator does not have mapped glyphs for these characters.
You may need to:
or
NSAttribtedString
utilizing usual greek lettersThis is a small code snippet you can test in the Playground of iOS:
(λ, φ and δ are just simple Greek letters, U+03BB, U+03C6 and U+03B4.)
import UIKit
var maStr = NSMutableAttributedString()
let boldFont = UIFont(name: "Times-Bold", size: 18.0)!
maStr.append(NSAttributedString(string: "λ φ", attributes: [NSFontAttributeName: boldFont]))
let italicFont = UIFont(name: "Times-Italic", size: 18.0)!
maStr.append(NSAttributedString(string: " δ", attributes: [NSFontAttributeName: italicFont]))
maStr
If this cannot fulfil your requirement, you need to update your question and explain your requirement precisely.
macOS (OS X)
In my OS X El Capitan (10.11.5) -- sorry not yet Sierra -- , I have found two fonts (in the same font family) which can show such characters.
STIXGeneral-Bold
STIXGeneral-Regular
So in a usual text system which can choose alternative font, such mathematical symbols can be shown.
For example, you can test in the Playground for macOS:
import Cocoa
var str = "Hello, playground"
let label = NSTextField(frame: CGRect(x:0, y:0, width: 320, height: 100))
label.stringValue = "𝛌 𝛗 𝛿"
And the storyboard editor of Xcode 8.2.1 actually shows these characters.
Upvotes: 1