正如您在图片中看到的那样,字体的名称是" Helvetica"在开始时,我调用font.fontDescriptor.withSymbolicTraits:
来创建字体描述符,然后使用描述符创建一个newFont。但新字体的名称变为Arial-ItalicMT
。怎么会发生?感谢。
答案 0 :(得分:1)
TL; DR: adding SELECT * FROM `users` where Number IN ('1212','0921');
will get you the expected result:
inputChangeHandler: function ({ target: { id, value }) {
this.setState({ [id]: value });
},
An withFamily()
is like filtering criteria for fonts. Based on how you configure this object, the system will find matching fonts. Let's examine the descriptor of your first font:
let font = NSFont(name: "Helvetica", size: 18)!
let descriptor = font.fontDescriptor.withFamily(font.familyName!).withSymbolicTraits(.italic)
let newFont = NSFont(descriptor: descriptor, size: 18)!
print(font.fontName) // Helvetica
print(newFont.fontName) // Helvetica-Oblique
A font with name of Helvetica and size 18. So far so good. Now, let's check your second descriptor:
NSFontDescriptor
There's no mention of Helvetica anywhere! If you initialize an let font = NSFont(name: "Helvetica", size: 18)!
print(font.fontDescriptor)
/*
NSCTFontDescriptor <0x1016168d0> = {
NSFontNameAttribute = Helvetica;
NSFontSizeAttribute = 18;
}
*/
with this descriptor, the OS wil find the first available italic font on your computer, which is let descriptor = font.fontDescriptor.withSymbolicTraits(.italic)
print(descriptor)
/*
NSCTFontDescriptor <0x10161b0e0> = {
NSCTFontTraitsAttribute = {
NSCTFontSymbolicTrait = 1;
};
NSFontSizeAttribute = 18;
}
*/
. You can check by openning Font Book.
You need to specify that you are looking for an italic font in the Helvetica family:
NSFont
To make it more generic, you can replace the string Arial-ItalicMT
with the let descriptor = font.fontDescriptor.withSymbolicTraits(.italic).withFamily("Helvetica")
print(descriptor)
/*
NSCTFontDescriptor <0x10113baa0> = {
NSCTFontTraitsAttribute = {
NSCTFontSymbolicTrait = 1;
};
NSFontFamilyAttribute = Helvetica;
NSFontSizeAttribute = 18;
}
*/
let newFont = NSFont(descriptor: descriptor, size: 18)! // Helvetica-Oblique
of the first "Helvetica"
object.
答案 1 :(得分:0)
实例方法。withSymbolicTraits
返回一个新的字体描述符,该描述符与接收者相同,但具有指定的符号特征,优先于现有的优先级。 Source
从我的理解。排名中的第一个字体将基于fonts included with macOS Sierra返回。
在您的情况下,.italic
将返回Arial-ItalicMT
或.bold
返回AlBayan-Bold