Skip to content

Commit

Permalink
fix: 系统字体中,不支持斜体中文,所以在导出到html时,斜体属性在富文本的NSOriginFont里,此时用NSOriginFont…
Browse files Browse the repository at this point in the history
…来覆盖原NSFont
  • Loading branch information
rztime committed Dec 14, 2023
1 parent 5fbb4eb commit 0f15557
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion RZRichTextView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'RZRichTextView'
s.version = '2.1.1'
s.version = '2.1.2'
s.summary = 'RZRichTextView. 原生UITextView,支持富文本输入(图片,视频,列表序号,文本颜色大小各种样式等等)'

# This description is used to generate tags and improve search results.
Expand Down
18 changes: 18 additions & 0 deletions RZRichTextView/Classes/RZCss.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,24 @@ public extension [NSAttributedString.Key: Any] {
default: break
}
}
/// 系统字体不支持斜体中文,导致self[.font]拿到的字体NSFont不包含斜体,但是会加一个NSOriginalFont,所以这里以NSOriginalFont来覆盖上边设置过的
if let font = self[.init(rawValue: "NSOriginalFont")] as? UIFont {
switch font.fontType {
case .boldItalic:
styletexts.removeAll(where: {$0.contains("font-weight:bold;")})
styletexts.removeAll(where: {$0.contains("font-style:italic;")})
styletexts.append("font-weight:bold;")
styletexts.append("font-style:italic;")
case .bold:
styletexts.removeAll(where: {$0.contains("font-weight:bold;")})
styletexts.append("font-weight:bold;")
case .italic:
styletexts.removeAll(where: {$0.contains("font-style:italic;")})
styletexts.append("font-style:italic;")
case .normal:
break
}
}
return styletexts.joined()
}
}
Expand Down
3 changes: 3 additions & 0 deletions UpdataLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* v2.1.2
* . 系统字体中,不支持斜体中文,所以在导出到html时,斜体属性在富文本的NSOriginFont里,此时用NSOriginFont来覆盖原NSFont

* v2.1.1
* . 修复只有一个附件,删除时,uploadAttachmentsComplete重新设值

Expand Down

0 comments on commit 0f15557

Please sign in to comment.