在 Xcode 中的 UILabel 上编写印地语

发布于 2024-12-05 16:20:38 字数 232 浏览 1 评论 0原文

我编写了一个代码,需要在 UILabel 上显示印地文数字。我使用梵文字体来显示该值,但它不起作用。它只是改变了外观,但没有改变语言。

我正在使用:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;

但它不起作用。谁能帮我解决这个问题吗?

I have written a code where I need to display hindi numbers on the UILabel. I used devanagari font to show that value but it doesn't work. It just changes the look but not the language.

I was using:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16];
myLabel.font = font;

But it's not working. Can anyone please help me with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凹づ凸ル 2024-12-12 16:20:38

你把字体名称弄错了。字体名称是 DevanagariSangamMN 而不是 DevanagarSangamMN(请注意您的名字中缺少“i”)。因此,您的代码应该是:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;

查找有关 iOS 字体的更多信息。我推荐这个网站,它拥有iOS中可用的所有字体

此外,如果您在标签中输入英文字符,您将得到返回的是英文版本而不是印地语翻译。它不会为您进行翻译。使用 DevanagariSangamMN 只允许您显示印地语字符,因为通常使用的 Helvetica 等字体不包含印地语字形。例如:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"Testing";

这将返回英语的“Testing”,而不是印地语。但是,如果你这样做:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"परीक्षण";

那么你会得到“परीक्षण”,这是印地语中的“测试”(我使用谷歌翻译,所以它可能是错误的)。因此,要获得印地语版本 (४) 的数字“4”,您需要执行以下操作:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"४";

You have got the font name wrong. The font name is DevanagariSangamMN not DevanagarSangamMN (note the missing 'i' in your name). Your code should therefore be:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;

To find more information about the iOS Fonts. I recommend this website which has all the fonts available in iOS

Also, if you type English characters into the Label, you will get returned the English version NOT the Hindi translation. It doesn't do the translation for you. Using the DevanagariSangamMN only allows you to show the Hindi Characters because the fonts such as Helvetica which are normally used do not include the Hindi glyphs. For example:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"Testing";

This will return 'Testing' in English, Not in Hindi. However if you do:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"परीक्षण";

Then you will get 'परीक्षण' which is the Hindi for 'Testing' (I used Google Translate so it could be wrong). So to get the number '4' with the Hindi version (४), you need to do the following:

UIFont *font = [UIFont fontWithName:@"DevanagariSangamMN" size:16]; 
myLabel.font = font;
myLabel.text = @"४";
雪落纷纷 2024-12-12 16:20:38

您是否以 unicode 分配 UILabel 文本?试试这个 -

myLabel.text = [NSString stringWithFormat:@"String with unicode %C", 0x207F];

are you assigning your UILabel text in unicode? Try this -

myLabel.text = [NSString stringWithFormat:@"String with unicode %C", 0x207F];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文