Use CGColor and remove PlatformColor
This commit is contained in:
@@ -5,8 +5,8 @@ import Foundation
|
||||
extension CGContext {
|
||||
func draw(_ displayNode: Math.DisplayNode, foregroundColor: CGColor) {
|
||||
let foregroundColor =
|
||||
displayNode.localTextColor?.cgColor
|
||||
?? displayNode.textColor?.cgColor
|
||||
displayNode.localTextColor
|
||||
?? displayNode.textColor
|
||||
?? foregroundColor
|
||||
|
||||
switch displayNode {
|
||||
|
||||
@@ -9,9 +9,9 @@ extension Math {
|
||||
var position: CGPoint = .zero
|
||||
var range: NSRange = NSRange(location: 0, length: 0)
|
||||
var hasScript: Bool = false
|
||||
var textColor: PlatformColor?
|
||||
var localTextColor: PlatformColor?
|
||||
var localBackgroundColor: PlatformColor?
|
||||
var textColor: CGColor?
|
||||
var localTextColor: CGColor?
|
||||
var localBackgroundColor: CGColor?
|
||||
|
||||
func bounds() -> CGRect {
|
||||
CGRect(x: position.x, y: position.y - descent, width: width, height: ascent + descent)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import CoreGraphics
|
||||
import CoreText
|
||||
import Foundation
|
||||
|
||||
@@ -423,7 +424,9 @@ extension Math {
|
||||
return line
|
||||
}
|
||||
|
||||
static var placeholderColor: PlatformColor { PlatformColor.blue }
|
||||
static var placeholderColor: CGColor {
|
||||
CGColor(srgbRed: 0, green: 0, blue: 1, alpha: 1)
|
||||
}
|
||||
|
||||
init(
|
||||
withFont font: PlatformFont?, style: Style.Level, cramped: Bool, spaced: Bool,
|
||||
@@ -986,7 +989,7 @@ extension Math {
|
||||
let colorAtom = atom as! Color
|
||||
let display = Typesetter.createLineForMathList(
|
||||
colorAtom.innerList, font: font, style: style, maxWidth: maxWidth)
|
||||
display!.localTextColor = PlatformColor(fromHexString: colorAtom.colorString)
|
||||
display!.localTextColor = CGColor.fromHexString(colorAtom.colorString)
|
||||
|
||||
// Check if we need to break before adding this colored content
|
||||
let shouldBreak = shouldBreakBeforeDisplay(
|
||||
@@ -1013,7 +1016,7 @@ extension Math {
|
||||
let colorAtom = atom as! TextColor
|
||||
let display = Typesetter.createLineForMathList(
|
||||
colorAtom.innerList, font: font, style: style, maxWidth: maxWidth)
|
||||
display!.localTextColor = PlatformColor(fromHexString: colorAtom.colorString)
|
||||
display!.localTextColor = CGColor.fromHexString(colorAtom.colorString)
|
||||
|
||||
// Check if we need to break before adding this colored content
|
||||
let shouldBreak = shouldBreakBeforeDisplay(
|
||||
@@ -1051,7 +1054,7 @@ extension Math {
|
||||
let display = Typesetter.createLineForMathList(
|
||||
colorboxAtom.innerList, font: font, style: style, maxWidth: maxWidth)
|
||||
|
||||
display!.localBackgroundColor = PlatformColor(fromHexString: colorboxAtom.colorString)
|
||||
display!.localBackgroundColor = CGColor.fromHexString(colorboxAtom.colorString)
|
||||
|
||||
// Check if we need to break before adding this colorbox
|
||||
let shouldBreak = shouldBreakBeforeDisplay(
|
||||
@@ -1387,7 +1390,7 @@ extension Math {
|
||||
let color = Typesetter.placeholderColor
|
||||
current = NSAttributedString(
|
||||
string: atom.nucleus,
|
||||
attributes: [kCTForegroundColorAttributeName as NSAttributedString.Key: color.cgColor]
|
||||
attributes: [kCTForegroundColorAttributeName as NSAttributedString.Key: color]
|
||||
)
|
||||
} else {
|
||||
current = NSAttributedString(string: atom.nucleus)
|
||||
|
||||
Reference in New Issue
Block a user