以可编写脚本的方式将 .rtf 转换为 mac .r 资源

发布于 2024-09-30 13:54:48 字数 179 浏览 1 评论 0原文

我目前有 .rtf 格式的 SLA,将使用 Rez 实用程序使用的中间 .r mac 资源格式将其集成到 .dmg 中。我已经手动完成过一次,但对 .rtf 文件所做的更新难以传播到磁盘映像,并且容易出错。我想自动化此任务,这也可以帮助添加其他语言或变体。

.rtf 到 .r 文本转换过程如何自动化?

谢谢。

I currently have a SLA in a .rtf format, which is to be integrated into .dmg using the intermediary .r mac resource format, which is used by the Rez utility. I had already done it by hand once, but updates made to the .rtf file are overwhelming to propagate to the disk image, and error-prone. I would like to automate this task, which could also help adding other languages or variants.

How could the process of .rtf to .r text conversion be automated?

Thanks.

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

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

发布评论

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

评论(2

瑕疵 2024-10-07 13:54:48

只是因为我没有完全理解接受的答案实际上是如何实现目标的,所以我使用脚本的组合来生成十六进制编码:

#!/usr/bin/env ruby
# Makes resource (.r) text from binaries.

def usage
  puts "usage: #{$0} infile"
  puts ""
  puts "  infile   The file to convert (the output will go to stdout)"
  exit 1
end

infile = ARGV[0]    || usage

data = File.read(infile)
data.bytes.each_slice(16) do |slice|
  hex = slice.each_slice(2).map { |pair| pair.pack('C*').unpack('H*')[0] }.join(' ')

  # We could put the comments in too, but it probably isn't a big deal.
  puts "\t$\"#{hex}\""
end

在构建过程中将其输出插入到变量中,然后该变量最终以模板(我们使用 Ant 来做到这一点,但具体细节并不是特别有趣):

data 'RTF ' (5000, "English SLA") {
@english.licence@
};

其中需要相当长一段时间才能弄清楚的一点是可以使用 'RTF '直接获取资源。 Apple 文档说要单独插入 'TEXT' (仅包含纯文本)和 'styl' (仅包含样式)。当然有一些工具可以做到这一点,但它是又一个需要运行的工具,我永远无法弄清楚如何使超链接在生成的 DMG 中工作。使用 'RTF ',超链接就可以工作。

希望这可以在将来节省某人的时间。

Only because I didn't fully understand how the accepted answer actually achieved the goal, I use a combination of a script to generate the hex encoding:

#!/usr/bin/env ruby
# Makes resource (.r) text from binaries.

def usage
  puts "usage: #{$0} infile"
  puts ""
  puts "  infile   The file to convert (the output will go to stdout)"
  exit 1
end

infile = ARGV[0]    || usage

data = File.read(infile)
data.bytes.each_slice(16) do |slice|
  hex = slice.each_slice(2).map { |pair| pair.pack('C*').unpack('H*')[0] }.join(' ')

  # We could put the comments in too, but it probably isn't a big deal.
  puts "\t$\"#{hex}\""
end

The output of this is inserted into a variable during the build and then the variable ends up in a template (we're using Ant to do this, but the specifics aren't particularly interesting):

data 'RTF ' (5000, "English SLA") {
@english.licence@
};

The one bit of this which did take quite a while to figure out is that 'RTF ' can be used for the resource directly. The Apple docs say to separately insert 'TEXT' (with just the plain text) and 'styl' (with just the style). There are tools to do this of course, but it was one more tool to run and I could never figure out how to make hyperlinks work in the resulting DMG. With 'RTF ', hyperlinks just work.

Hoping that this saves someone time in the future.

菩提树下叶撕阳。 2024-10-07 13:54:48

使用 unrtf 端口(来自 macports),然后使用 shell 脚本格式化行、标题和尾部。

Use the unrtf port (from macports), then format the lines, heading and tail with a shell script.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文