2

I one of my big projects the customer just wished to change leading font in whole app. It is quite simple for the fonts allocated by code (I have some kind of theme system which abstracts font creation).

But the problem starts with the fonts used in XIB files. Do I have to go thorough all of them and apply change to properties manually (I have literally dozens of them)?

Are there any smart terminal commands which could do this in more efficient way (combination of ibtool, xargs, find)?

I have accomplished similar problem - extracting all strings used in XIB as mentioned here:

https://stackoverflow.com/a/7754884/229229

And I hope there is some search (and replace) patterns also for any XIB properties.

4

1 回答 1

3

这些.xib文件是普通.xml文件,可以简单地编辑。
文件中只定义了非默认字体.xib。简化示例:

<object class="NSTextField" id="298830314">
    <object class="NSTextFieldCell" key="NSCell" id="386648753">
        <object class="NSFont" key="NSSupport">
            <string key="NSName">Arial-BoldMT</string>
            <double key="NSSize">18</double>
            <int key="NSfFlags">16</int>
        </object>
    </object>
</object> 

换句话说,删除所有<object class="NSFont">路径以恢复为默认字体。
要将所有字体更改NSTextField为特定字体,请添加以下内容:

<object class="NSFont" key="NSSupport">
    <string key="NSName">Arial-BoldMT</string>
    <double key="NSSize">18</double>
    <int key="NSfFlags">16</int>
</object>

对所有人<object class="NSTextField">

Xcode 没有内置功能可以批量自动执行此操作。

编辑 (对评论的回应)

通过单击“字体面板...”按钮选择特定字体:

字体面板按钮

使用字体面板,您可以选择任何字体:

字体面板

于 2012-09-18T15:56:00.803 回答