- 实现EPUB阅读器搜索功能及选中注释功能 - 优化CFI模块,修复代码审查发现的11个问题 - 实现大书远距目录跳转与后台补全优化方案 - 优化设置面板与章节运行时联动 - 重构及大量改进优化
20 lines
629 B
Swift
20 lines
629 B
Swift
import CoreText
|
|
import UIKit
|
|
|
|
#if canImport(DTCoreText)
|
|
import DTCoreText
|
|
#endif
|
|
|
|
struct RDEPUBTextLayouter {
|
|
private let counter: RDEPUBChapterPageCounter
|
|
|
|
init(attributedString: NSAttributedString, pageSize: CGSize, config: RDEPUBTextLayoutConfig = .default) {
|
|
let factory = RDEPUBCoreTextPageFrameFactory(attributedString: attributedString, pageSize: pageSize, config: config)
|
|
self.counter = RDEPUBChapterPageCounter(factory: factory)
|
|
}
|
|
|
|
func layoutFrames(fragmentOffsets: [String: Int] = [:]) -> [RDEPUBTextLayoutFrame] {
|
|
counter.layoutFrames(fragmentOffsets: fragmentOffsets)
|
|
}
|
|
}
|