<tfoot id='LrUcb'></tfoot>

  • <i id='LrUcb'><tr id='LrUcb'><dt id='LrUcb'><q id='LrUcb'><span id='LrUcb'><b id='LrUcb'><form id='LrUcb'><ins id='LrUcb'></ins><ul id='LrUcb'></ul><sub id='LrUcb'></sub></form><legend id='LrUcb'></legend><bdo id='LrUcb'><pre id='LrUcb'><center id='LrUcb'></center></pre></bdo></b><th id='LrUcb'></th></span></q></dt></tr></i><div id='LrUcb'><tfoot id='LrUcb'></tfoot><dl id='LrUcb'><fieldset id='LrUcb'></fieldset></dl></div>

    <small id='LrUcb'></small><noframes id='LrUcb'>

    <legend id='LrUcb'><style id='LrUcb'><dir id='LrUcb'><q id='LrUcb'></q></dir></style></legend>
      <bdo id='LrUcb'></bdo><ul id='LrUcb'></ul>

      1. 带有字体手提箱的 iPhone 自定义字体

        iPhone Custom Fonts with Font Suitcase(带有字体手提箱的 iPhone 自定义字体)
          <bdo id='65IU6'></bdo><ul id='65IU6'></ul>
                <i id='65IU6'><tr id='65IU6'><dt id='65IU6'><q id='65IU6'><span id='65IU6'><b id='65IU6'><form id='65IU6'><ins id='65IU6'></ins><ul id='65IU6'></ul><sub id='65IU6'></sub></form><legend id='65IU6'></legend><bdo id='65IU6'><pre id='65IU6'><center id='65IU6'></center></pre></bdo></b><th id='65IU6'></th></span></q></dt></tr></i><div id='65IU6'><tfoot id='65IU6'></tfoot><dl id='65IU6'><fieldset id='65IU6'></fieldset></dl></div>

                <small id='65IU6'></small><noframes id='65IU6'>

              • <legend id='65IU6'><style id='65IU6'><dir id='65IU6'><q id='65IU6'></q></dir></style></legend>

                <tfoot id='65IU6'></tfoot>

                  <tbody id='65IU6'></tbody>

                1. 本文介绍了带有字体手提箱的 iPhone 自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 iOS4 应用程序中使用 Font Suitcase 作为自定义字体,但没有成功.

                  我已阅读其他记录如何使用自定义字体的帖子,因此已将手提箱复制到我的项目中,将其添加到资源和 Info.plist '应用程序数组提供的字体,并尝试在 Interface Builder 和代码中使用它.但它不起作用!

                  我发现的所有关于自定义字体的示例都显示将它们与 ttf 或 otf 文件一起使用,但没有与手提箱一起使用.可以做到吗?如果没有,我如何将字体册中的内容放入可用作自定义字体的文件结构中?

                  解决方案

                  我遇到了同样的问题,刚刚解决了.朋友给了我几个压缩的字体,我解压缩然后文件大小为零 kb,我无法将它们安装到 Font Book 中.所以我搜索了一下,发现我的朋友应该使用 StuffIt Expander 进行压缩.于是他又把文件发给我,我用 StuffIt Expander 解压.然后我可以将字体安装到我的字体册中.

                  但是,这些字体在我的 iOS 应用程序中仍然不可用.所以下面是我所做的:

                  1. 我发现我需要转换字体,所以我安装了Fonduhttp://fondu.sourceforge.net/安装到最后说不成功,后来还是可以用的.

                  2. 然后我意识到我需要 Rosetta 来运行 Fondu,所以我查看了此页面上的说明.取出我的 Snow Leopard CD 并安装可选包http://www.macobserver.com/tmo/article/snow_leopard_installing_rosetta/p>

                  3. 打开终端并转到您的字体所在的目录.键入命令:火锅 [字体文件]然后你会得到一个提示,询问你是否要保存[字体文件].pfb选择是.

                  4. 现在在您的 XCode 中,将 pfb 文件添加到您的项目中.然后转到 info.plist 并将文件添加到 UIAppFonts(包括 .pfb 扩展名).

                  5. 我在 UITableViewCell 中测试了字体

                  cell.textLabel.font = [UIFont fontWithName:@"[字体文件]" size:30];//不包含 .pfb 扩展名

                  字体显示正常.我最初认为 iOS 需要一个 .ttf 文件,但看起来 .pfb 也可以.

                  希望这会有所帮助.

                  其他测试提示:如上所示添加 UIAppFonts plist 数组后,在 appDidFinishLaunchingWithOptions 方法和控制台类型中添加断点

                  po [UIFont familyNames]

                  这将为您提供已安装字体的列表,因此请搜索您的字体系列名称.将其复制并粘贴到此:

                  po [UIFont fontNamesForFamilyName:@"familyname"]

                  这将为您获取您在代码中引用的字体名称.我没有尝试过 [font filename] 方法,但这为您提供了应用程序用来引用您想要的确切字体的名称.当字体包含一系列变体或您从同一个系列安装了多个变体时,这一点很重要.例如 helvetica 有四种变体,因此您可以通过这种方式选择正确的一种:

                  lblMyLabel.font = [UIFont fontWithName:@"fontname" size:lblMyLabel.font.pointSize]

                  例如

                  lblMyLabel.font = [UIFont fontWithName:@"Helvetica-Oblique" size:lblMyLabel.font.pointSize]

                  这会保留您最初用于标签的字体磅值.我也只有在视图加载后才成功.

                  I am attempting to use a Font Suitcase for a custom font in an iOS4 app but am not having any success.

                  I have read other posts that have documented how to use custom fonts, so have copied the suitcase into my project, added it to resources and the Info.plist ' Fonts provided by application' array, and attempted to use it both in Interface Builder and in code. But it doesn't work!

                  All examples I've found regarding custom fonts show using them with ttf or otf files, but nothing with a suitcase. Can it be done? If not, how do I get something out of the Font Book into a file structure that can be used as a custom font?

                  解决方案

                  I had the same problem and just solved it. Friend gave me a couple of fonts zipped, I unzipped and then the file sizes are zero kb and I couldn't install them into Font Book. So I googled and found out that my friend should have used StuffIt Expander to zip. So he sent me the file again, and I used StuffIt Expander to unzip. I was then able to install the fonts into my Font Book.

                  However, the fonts are still not usable in my iOS app. So below is what I did:

                  1. I found out I need to convert the font, so I installed Fondu http://fondu.sourceforge.net/ The installation ended up saying not successful, but later I was still able to use.

                  2. Then I realise I need Rosetta to run Fondu, so I looked at the instructions on this page. Got my Snow Leopard CD out and install optional package http://www.macobserver.com/tmo/article/snow_leopard_installing_rosetta/

                  3. Open Terminal and go to the directory where your font is. Type the command: fondu [font file] Then you will get a prompt asking if you want to save [font file].pfb Choose yes.

                  4. Now in your XCode, add the pfb file into your project. Then go to info.plist and add the file to UIAppFonts (include the .pfb extension).

                  5. I tested the font in a UITableViewCell

                  cell.textLabel.font = [UIFont fontWithName:@"[font file]" size:30]; // do not include .pfb extension

                  And the font is showing up fine. I initially thought iOS will require a .ttf file but looks like .pfb is fine also.

                  Hope this helps.

                  Additional testing tips: Once you add the UIAppFonts plist array as shown above add a breakpoint in your appDidFinishLaunchingWithOptions method and at the console type

                  po [UIFont familyNames]
                  

                  That gets you a list of installed fonts so search for your font family name. Copy that and paste it into this:

                  po [UIFont fontNamesForFamilyName:@"familyname"]
                  

                  This gets you the font name you reference in your code. I've not tried the [font filename] approach but this gives you the name the app uses to reference the exact font you want. This is important when a font contains a series of variants or you have multiple installed from the same family. For example helvetica has four variants so you can pick the right one this way:

                  lblMyLabel.font = [UIFont fontWithName:@"fontname" size:lblMyLabel.font.pointSize]
                  

                  E.g.

                  lblMyLabel.font = [UIFont fontWithName:@"Helvetica-Oblique" size:lblMyLabel.font.pointSize]
                  

                  This keeps the font point size you used originally for the label. I've also only had success once the view is loaded.

                  这篇关于带有字体手提箱的 iPhone 自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                  Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                  ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                  How to get indexPath.row of tableView which is currently being displayed?(如何获取当前正在显示的 tableView 的 indexPath.row?)
                  Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                  MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                    <bdo id='ON4bE'></bdo><ul id='ON4bE'></ul>

                          <tbody id='ON4bE'></tbody>

                        <small id='ON4bE'></small><noframes id='ON4bE'>

                        • <i id='ON4bE'><tr id='ON4bE'><dt id='ON4bE'><q id='ON4bE'><span id='ON4bE'><b id='ON4bE'><form id='ON4bE'><ins id='ON4bE'></ins><ul id='ON4bE'></ul><sub id='ON4bE'></sub></form><legend id='ON4bE'></legend><bdo id='ON4bE'><pre id='ON4bE'><center id='ON4bE'></center></pre></bdo></b><th id='ON4bE'></th></span></q></dt></tr></i><div id='ON4bE'><tfoot id='ON4bE'></tfoot><dl id='ON4bE'><fieldset id='ON4bE'></fieldset></dl></div>
                          <legend id='ON4bE'><style id='ON4bE'><dir id='ON4bE'><q id='ON4bE'></q></dir></style></legend>

                            <tfoot id='ON4bE'></tfoot>