Passing all internal tests.
This commit is contained in:
@@ -146,18 +146,24 @@ class MTCTLineDisplay : MTDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// func set(attrString: NSAttributedString?) {
|
override var textColor: MTColor? {
|
||||||
// attributedString = attrString
|
set {
|
||||||
// line = CTLineCreateWithAttributedString(attributedString!)
|
super.textColor = newValue
|
||||||
// }
|
|
||||||
|
|
||||||
func set(textColor:MTColor) {
|
|
||||||
self.textColor = textColor
|
|
||||||
let attrStr = NSMutableAttributedString(attributedString: self.attributedString!)
|
let attrStr = NSMutableAttributedString(attributedString: self.attributedString!)
|
||||||
let foregroundColor = NSAttributedString.Key(kCTForegroundColorAttributeName as String)
|
let foregroundColor = NSAttributedString.Key(kCTForegroundColorAttributeName as String)
|
||||||
attrStr.addAttribute(foregroundColor, value:self.textColor!.cgColor, range:NSMakeRange(0, attrStr.length))
|
attrStr.addAttribute(foregroundColor, value:self.textColor!.cgColor, range:NSMakeRange(0, attrStr.length))
|
||||||
self.attributedString = attrStr
|
self.attributedString = attrStr
|
||||||
}
|
}
|
||||||
|
get { super.textColor }
|
||||||
|
}
|
||||||
|
|
||||||
|
// func set(textColor:MTColor) {
|
||||||
|
// self.textColor = textColor
|
||||||
|
// let attrStr = NSMutableAttributedString(attributedString: self.attributedString!)
|
||||||
|
// let foregroundColor = NSAttributedString.Key(kCTForegroundColorAttributeName as String)
|
||||||
|
// attrStr.addAttribute(foregroundColor, value:self.textColor!.cgColor, range:NSMakeRange(0, attrStr.length))
|
||||||
|
// self.attributedString = attrStr
|
||||||
|
// }
|
||||||
|
|
||||||
func computeDimensions(_ font:MTFont?) {
|
func computeDimensions(_ font:MTFont?) {
|
||||||
let runs = CTLineGetGlyphRuns(line) as NSArray
|
let runs = CTLineGetGlyphRuns(line) as NSArray
|
||||||
@@ -229,21 +235,31 @@ class MTMathListDisplay : MTDisplay {
|
|||||||
self.recomputeDimensions()
|
self.recomputeDimensions()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setType(_ type:LinePosition) {
|
// func setType(_ type:LinePosition) {
|
||||||
self.type = type
|
// self.type = type
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// func setIndex(_ index:Int) {
|
||||||
|
// self.index = index
|
||||||
|
// }
|
||||||
|
|
||||||
func setIndex(_ index:Int) {
|
// func setTextColor(_ textColor:MTColor) {
|
||||||
self.index = index
|
// // Set the color on all subdisplays
|
||||||
}
|
// self.textColor = textColor
|
||||||
|
// for displayAtom in self.subDisplays {
|
||||||
|
// displayAtom.textColor = textColor
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
func setTextColor(_ textColor:MTColor) {
|
override var textColor: MTColor? {
|
||||||
// Set the color on all subdisplays
|
set {
|
||||||
self.textColor = textColor
|
super.textColor = newValue
|
||||||
for displayAtom in self.subDisplays {
|
for displayAtom in self.subDisplays {
|
||||||
displayAtom.textColor = textColor
|
displayAtom.textColor = newValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
get { super.textColor }
|
||||||
|
}
|
||||||
|
|
||||||
func draw(context: CGContext) {
|
func draw(context: CGContext) {
|
||||||
context.saveGState()
|
context.saveGState()
|
||||||
@@ -341,16 +357,22 @@ class MTFractionDisplay : MTDisplay {
|
|||||||
numerator?.position = CGPointMake(self.position.x + (self.width - numerator!.width)/2, self.position.y + self.numeratorUp)
|
numerator?.position = CGPointMake(self.position.x + (self.width - numerator!.width)/2, self.position.y + self.numeratorUp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPosition(_ position: CGPoint) {
|
override var position: CGPoint {
|
||||||
super.position = position
|
set {
|
||||||
|
super.position = newValue
|
||||||
self.updateDenominatorPosition()
|
self.updateDenominatorPosition()
|
||||||
self.updateNumeratorPosition()
|
self.updateNumeratorPosition()
|
||||||
}
|
}
|
||||||
|
get { super.position }
|
||||||
|
}
|
||||||
|
|
||||||
func setTextColor(_ textColor:MTColor) {
|
override var textColor: MTColor? {
|
||||||
super.textColor = textColor
|
set {
|
||||||
numerator?.textColor = textColor
|
super.textColor = newValue
|
||||||
denominator?.textColor = textColor
|
numerator?.textColor = newValue
|
||||||
|
denominator?.textColor = newValue
|
||||||
|
}
|
||||||
|
get { super.textColor }
|
||||||
}
|
}
|
||||||
|
|
||||||
override func draw(_ context:CGContext) {
|
override func draw(_ context:CGContext) {
|
||||||
@@ -387,6 +409,23 @@ class MTRadicalDisplay : MTDisplay {
|
|||||||
*/
|
*/
|
||||||
var degree:MTMathListDisplay?
|
var degree:MTMathListDisplay?
|
||||||
|
|
||||||
|
override var position: CGPoint {
|
||||||
|
set {
|
||||||
|
super.position = newValue
|
||||||
|
self.updateRadicandPosition()
|
||||||
|
}
|
||||||
|
get { super.position }
|
||||||
|
}
|
||||||
|
|
||||||
|
override var textColor: MTColor? {
|
||||||
|
set {
|
||||||
|
super.textColor = newValue
|
||||||
|
self.radicand!.textColor = newValue
|
||||||
|
self.degree!.textColor = newValue
|
||||||
|
}
|
||||||
|
get { super.textColor }
|
||||||
|
}
|
||||||
|
|
||||||
private var _radicalGlyph:MTDisplay?
|
private var _radicalGlyph:MTDisplay?
|
||||||
private var _radicalShift:CGFloat=0
|
private var _radicalShift:CGFloat=0
|
||||||
|
|
||||||
@@ -430,10 +469,10 @@ class MTRadicalDisplay : MTDisplay {
|
|||||||
self.updateRadicandPosition()
|
self.updateRadicandPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPosition(_ position:CGPoint) {
|
// func setPosition(_ position:CGPoint) {
|
||||||
super.position = position
|
// super.position = position
|
||||||
self.updateRadicandPosition()
|
// self.updateRadicandPosition()
|
||||||
}
|
// }
|
||||||
|
|
||||||
func updateRadicandPosition() {
|
func updateRadicandPosition() {
|
||||||
// The position of the radicand includes the position of the MTRadicalDisplay
|
// The position of the radicand includes the position of the MTRadicalDisplay
|
||||||
@@ -443,11 +482,11 @@ class MTRadicalDisplay : MTDisplay {
|
|||||||
self.radicand!.position = CGPointMake(self.position.x + _radicalShift + _radicalGlyph!.width, self.position.y);
|
self.radicand!.position = CGPointMake(self.position.x + _radicalShift + _radicalGlyph!.width, self.position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTextColor(textColor:MTColor) {
|
// func setTextColor(textColor:MTColor) {
|
||||||
super.textColor = textColor
|
// super.textColor = textColor
|
||||||
self.radicand!.textColor = textColor
|
// self.radicand!.textColor = textColor
|
||||||
self.degree!.textColor = textColor
|
// self.degree!.textColor = textColor
|
||||||
}
|
// }
|
||||||
|
|
||||||
func draw(context: CGContext) {
|
func draw(context: CGContext) {
|
||||||
// draw the radicand & degree at its position
|
// draw the radicand & degree at its position
|
||||||
@@ -663,12 +702,21 @@ class MTLargeOpLimitsDisplay : MTDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPosition(_ position:CGPoint) {
|
override var position: CGPoint {
|
||||||
super.position = position;
|
set {
|
||||||
self.updateLowerLimitPosition()
|
self.updateLowerLimitPosition()
|
||||||
self.updateUpperLimitPosition()
|
self.updateUpperLimitPosition()
|
||||||
self.updateNucleusPosition()
|
self.updateNucleusPosition()
|
||||||
}
|
}
|
||||||
|
get { super.position }
|
||||||
|
}
|
||||||
|
|
||||||
|
// func setPosition(_ position:CGPoint) {
|
||||||
|
// super.position = position;
|
||||||
|
// self.updateLowerLimitPosition()
|
||||||
|
// self.updateUpperLimitPosition()
|
||||||
|
// self.updateNucleusPosition()
|
||||||
|
// }
|
||||||
|
|
||||||
func updateLowerLimitPosition() {
|
func updateLowerLimitPosition() {
|
||||||
if self.lowerLimit != nil {
|
if self.lowerLimit != nil {
|
||||||
@@ -697,12 +745,22 @@ class MTLargeOpLimitsDisplay : MTDisplay {
|
|||||||
nucleus?.position = CGPointMake(self.position.x + (self.width - nucleus!.width)/2, self.position.y);
|
nucleus?.position = CGPointMake(self.position.x + (self.width - nucleus!.width)/2, self.position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTextColor(_ textColor:MTColor) {
|
override var textColor: MTColor? {
|
||||||
super.textColor = textColor
|
set {
|
||||||
self.upperLimit?.textColor = textColor
|
super.textColor = newValue
|
||||||
self.lowerLimit?.textColor = textColor
|
self.upperLimit?.textColor = newValue
|
||||||
nucleus?.textColor = textColor
|
self.lowerLimit?.textColor = newValue
|
||||||
|
nucleus?.textColor = newValue
|
||||||
}
|
}
|
||||||
|
get { super.textColor }
|
||||||
|
}
|
||||||
|
|
||||||
|
// func setTextColor(_ textColor:MTColor) {
|
||||||
|
// super.textColor = textColor
|
||||||
|
// self.upperLimit?.textColor = textColor
|
||||||
|
// self.lowerLimit?.textColor = textColor
|
||||||
|
// nucleus?.textColor = textColor
|
||||||
|
// }
|
||||||
|
|
||||||
override func draw(_ context:CGContext) {
|
override func draw(_ context:CGContext) {
|
||||||
// Draw the elements.
|
// Draw the elements.
|
||||||
@@ -733,10 +791,26 @@ class MTLineDisplay : MTDisplay {
|
|||||||
self.range = range;
|
self.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTextColor(_ textColor:MTColor) {
|
override var textColor: MTColor? {
|
||||||
super.textColor = textColor
|
set {
|
||||||
inner?.textColor = textColor
|
super.textColor = newValue
|
||||||
|
inner?.textColor = newValue
|
||||||
}
|
}
|
||||||
|
get { super.textColor }
|
||||||
|
}
|
||||||
|
|
||||||
|
override var position: CGPoint {
|
||||||
|
set {
|
||||||
|
super.position = newValue
|
||||||
|
self.updateInnerPosition()
|
||||||
|
}
|
||||||
|
get { super.position }
|
||||||
|
}
|
||||||
|
|
||||||
|
// func setTextColor(_ textColor:MTColor) {
|
||||||
|
// super.textColor = textColor
|
||||||
|
// inner?.textColor = textColor
|
||||||
|
// }
|
||||||
|
|
||||||
override func draw(_ context:CGContext) {
|
override func draw(_ context:CGContext) {
|
||||||
self.inner?.draw(context)
|
self.inner?.draw(context)
|
||||||
@@ -757,10 +831,10 @@ class MTLineDisplay : MTDisplay {
|
|||||||
context.restoreGState();
|
context.restoreGState();
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPosition(_ position:CGPoint) {
|
// func setPosition(_ position:CGPoint) {
|
||||||
super.position = position;
|
// super.position = position;
|
||||||
self.updateInnerPosition()
|
// self.updateInnerPosition()
|
||||||
}
|
// }
|
||||||
|
|
||||||
func updateInnerPosition() {
|
func updateInnerPosition() {
|
||||||
self.inner?.position = CGPointMake(self.position.x, self.position.y);
|
self.inner?.position = CGPointMake(self.position.x, self.position.y);
|
||||||
@@ -790,16 +864,33 @@ class MTAccentDisplay : MTDisplay {
|
|||||||
self.range = range
|
self.range = range
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTextColor(_ textColor:MTColor) {
|
override var textColor: MTColor? {
|
||||||
super.textColor = textColor
|
set {
|
||||||
accentee?.textColor = textColor
|
super.textColor = newValue
|
||||||
accent?.textColor = textColor
|
accentee?.textColor = newValue
|
||||||
|
accent?.textColor = newValue
|
||||||
|
}
|
||||||
|
get { super.textColor }
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPosition(_ position:CGPoint) {
|
// func setTextColor(_ textColor:MTColor) {
|
||||||
super.position = position
|
// super.textColor = textColor
|
||||||
|
// accentee?.textColor = textColor
|
||||||
|
// accent?.textColor = textColor
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func setPosition(_ position:CGPoint) {
|
||||||
|
// super.position = position
|
||||||
|
// self.updateAccenteePosition()
|
||||||
|
// }
|
||||||
|
|
||||||
|
override var position: CGPoint {
|
||||||
|
set {
|
||||||
|
super.position = newValue
|
||||||
self.updateAccenteePosition()
|
self.updateAccenteePosition()
|
||||||
}
|
}
|
||||||
|
get { super.position }
|
||||||
|
}
|
||||||
|
|
||||||
func updateAccenteePosition() {
|
func updateAccenteePosition() {
|
||||||
self.accentee?.position = CGPointMake(self.position.x, self.position.y);
|
self.accentee?.position = CGPointMake(self.position.x, self.position.y);
|
||||||
|
|||||||
@@ -1079,40 +1079,39 @@ class MTTypesetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeRadical(_ radicand:MTMathList?, range:NSRange) -> MTRadicalDisplay? {
|
func makeRadical(_ radicand:MTMathList?, range:NSRange) -> MTRadicalDisplay? {
|
||||||
let innerDisplay = MTTypesetter.createLineForMathList(radicand, font:font, style:style, cramped:true)
|
let innerDisplay = MTTypesetter.createLineForMathList(radicand, font:font, style:style, cramped:true)!
|
||||||
var clearance : CGFloat = self.radicalVerticalGap()
|
var clearance = self.radicalVerticalGap()
|
||||||
let radicalRuleThickness : CGFloat = styleFont.mathTable!.radicalRuleThickness
|
let radicalRuleThickness = styleFont.mathTable!.radicalRuleThickness
|
||||||
let radicalHeight = innerDisplay!.ascent + innerDisplay!.descent + clearance + radicalRuleThickness;
|
let radicalHeight = innerDisplay.ascent + innerDisplay.descent + clearance + radicalRuleThickness
|
||||||
|
|
||||||
let glyph = self.getRadicalGlyphWithHeight(radicalHeight)
|
|
||||||
|
|
||||||
|
let glyph = self.getRadicalGlyphWithHeight(radicalHeight)!
|
||||||
|
|
||||||
// Note this is a departure from Latex. Latex assumes that glyphAscent == thickness.
|
// Note this is a departure from Latex. Latex assumes that glyphAscent == thickness.
|
||||||
// Open type math makes no such assumption, and ascent and descent are independent of the thickness.
|
// Open type math makes no such assumption, and ascent and descent are independent of the thickness.
|
||||||
// Latex computes delta as descent - (h(inner) + d(inner) + clearance)
|
// Latex computes delta as descent - (h(inner) + d(inner) + clearance)
|
||||||
// but since we may not have ascent == thickness, we modify the delta calculation slightly.
|
// but since we may not have ascent == thickness, we modify the delta calculation slightly.
|
||||||
// If the font designer followes Latex conventions, it will be identical.
|
// If the font designer followes Latex conventions, it will be identical.
|
||||||
let delta : CGFloat = (glyph!.descent + glyph!.ascent) - (innerDisplay!.ascent + innerDisplay!.descent + clearance + radicalRuleThickness);
|
let delta = (glyph.descent + glyph.ascent) - (innerDisplay.ascent + innerDisplay.descent + clearance + radicalRuleThickness)
|
||||||
if delta > 0 {
|
if delta > 0 {
|
||||||
clearance += delta/2; // increase the clearance to center the radicand inside the sign.
|
clearance += delta/2 // increase the clearance to center the radicand inside the sign.
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to shift the radical glyph up, to coincide with the baseline of inner.
|
// we need to shift the radical glyph up, to coincide with the baseline of inner.
|
||||||
// The new ascent of the radical glyph should be thickness + adjusted clearance + h(inner)
|
// The new ascent of the radical glyph should be thickness + adjusted clearance + h(inner)
|
||||||
let radicalAscent = radicalRuleThickness + clearance + innerDisplay!.ascent;
|
let radicalAscent = radicalRuleThickness + clearance + innerDisplay.ascent
|
||||||
let shiftUp = radicalAscent - glyph!.ascent; // Note: if the font designer followed latex conventions, this is the same as glyphAscent == thickness.
|
let shiftUp = radicalAscent - glyph.ascent // Note: if the font designer followed latex conventions, this is the same as glyphAscent == thickness.
|
||||||
glyph!.shiftDown = -shiftUp;
|
glyph.shiftDown = -shiftUp
|
||||||
|
|
||||||
let radical = MTRadicalDisplay(withRadicand: innerDisplay, glyph: glyph!, position: currentPosition, range: range)
|
let radical = MTRadicalDisplay(withRadicand: innerDisplay, glyph: glyph, position: currentPosition, range: range)
|
||||||
radical.ascent = radicalAscent + styleFont.mathTable!.radicalExtraAscender;
|
radical.ascent = radicalAscent + styleFont.mathTable!.radicalExtraAscender
|
||||||
radical.topKern = styleFont.mathTable!.radicalExtraAscender;
|
radical.topKern = styleFont.mathTable!.radicalExtraAscender
|
||||||
radical.lineThickness = radicalRuleThickness;
|
radical.lineThickness = radicalRuleThickness
|
||||||
// Note: Until we have radical construction from parts, it is possible that glyphAscent+glyphDescent is less
|
// Note: Until we have radical construction from parts, it is possible that glyphAscent+glyphDescent is less
|
||||||
// than the requested height of the glyph (i.e. radicalHeight), so in the case the innerDisplay has a larger
|
// than the requested height of the glyph (i.e. radicalHeight), so in the case the innerDisplay has a larger
|
||||||
// descent we use the innerDisplay's descent.
|
// descent we use the innerDisplay's descent.
|
||||||
radical.descent = max(glyph!.ascent + glyph!.descent - radicalAscent, innerDisplay!.descent);
|
radical.descent = max(glyph.ascent + glyph.descent - radicalAscent, innerDisplay.descent)
|
||||||
radical.width = glyph!.width + innerDisplay!.width;
|
radical.width = glyph.width + innerDisplay.width
|
||||||
return radical;
|
return radical
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Glyphs
|
// MARK: - Glyphs
|
||||||
@@ -1170,9 +1169,7 @@ class MTTypesetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func constructGlyphWithParts(_ parts:[GlyphPart], glyphHeight:CGFloat, glyphs:inout [NSNumber], offsets:inout [NSNumber], height:inout CGFloat) {
|
func constructGlyphWithParts(_ parts:[GlyphPart], glyphHeight:CGFloat, glyphs:inout [NSNumber], offsets:inout [NSNumber], height:inout CGFloat) {
|
||||||
// assert(!glyphs.isEmpty)
|
// Loop forever until the glyph height is valid
|
||||||
// assert(!offsets.isEmpty)
|
|
||||||
|
|
||||||
for numExtenders in 0..<Int.max {
|
for numExtenders in 0..<Int.max {
|
||||||
var glyphsRv = [NSNumber]()
|
var glyphsRv = [NSNumber]()
|
||||||
var offsetsRv = [NSNumber]()
|
var offsetsRv = [NSNumber]()
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ import XCTest
|
|||||||
// Created by Mike Griebling on 2023-01-02.
|
// Created by Mike Griebling on 2023-01-02.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
extension CGPoint {
|
||||||
|
|
||||||
|
func isEqual(to p:CGPoint, accuracy:CGFloat) -> Bool {
|
||||||
|
let p1 = self
|
||||||
|
return abs(p1.x - p.x) < accuracy && abs(p1.y - p.y) < accuracy
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
final class MTTypesetterTests: XCTestCase {
|
final class MTTypesetterTests: XCTestCase {
|
||||||
|
|
||||||
var font:MTFont!
|
var font:MTFont!
|
||||||
@@ -353,8 +362,8 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertNil(radical.degree);
|
XCTAssertNil(radical.degree);
|
||||||
|
|
||||||
let display2 = radical.radicand!
|
let display2 = radical.radicand!
|
||||||
XCTAssertEqual(display2.type, .regular);
|
XCTAssertEqual(display2.type, .regular)
|
||||||
XCTAssertTrue(CGPointEqualToPoint(display2.position, CGPointMake(16.66, 0)))
|
XCTAssertTrue(CGPointMake(16.66, 0).isEqual(to: display2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
||||||
XCTAssertFalse(display2.hasScript);
|
XCTAssertFalse(display2.hasScript);
|
||||||
XCTAssertEqual(display2.index, NSNotFound);
|
XCTAssertEqual(display2.index, NSNotFound);
|
||||||
@@ -632,8 +641,8 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertNotNil(fraction.denominator);
|
XCTAssertNotNil(fraction.denominator);
|
||||||
|
|
||||||
let display2 = fraction.numerator!
|
let display2 = fraction.numerator!
|
||||||
XCTAssertEqual(display2.type, .regular);
|
XCTAssertEqual(display2.type, .regular)
|
||||||
XCTAssertTrue(CGPointEqualToPoint(display2.position, CGPointMake(14.72, 13.54)))
|
XCTAssertTrue(CGPointMake(14.72, 13.54).isEqual(to: display2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
||||||
XCTAssertFalse(display2.hasScript);
|
XCTAssertFalse(display2.hasScript);
|
||||||
XCTAssertEqual(display2.index, NSNotFound);
|
XCTAssertEqual(display2.index, NSNotFound);
|
||||||
@@ -649,8 +658,8 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
let display3 = fraction.denominator!
|
let display3 = fraction.denominator!
|
||||||
XCTAssertEqual(display3.type, .regular);
|
XCTAssertEqual(display3.type, .regular)
|
||||||
XCTAssertTrue(CGPointEqualToPoint(display3.position, CGPointMake(14.72, -13.72)))
|
XCTAssertTrue(CGPointMake(14.72, -13.72).isEqual(to: display3.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(display3.range, NSMakeRange(0, 1)));
|
XCTAssertTrue(NSEqualRanges(display3.range, NSMakeRange(0, 1)));
|
||||||
XCTAssertFalse(display3.hasScript);
|
XCTAssertFalse(display3.hasScript);
|
||||||
XCTAssertEqual(display3.index, NSNotFound);
|
XCTAssertEqual(display3.index, NSNotFound);
|
||||||
@@ -706,7 +715,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
let line2 = sub1 as! MTCTLineDisplay
|
let line2 = sub1 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(27.893, 0)))
|
XCTAssertTrue(CGPointMake(27.893, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
@@ -742,7 +751,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
let line2 = sub1 as! MTCTLineDisplay
|
let line2 = sub1 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(23.313, 0)))
|
XCTAssertTrue(CGPointMake(23.313, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
@@ -820,7 +829,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
let line2 = sub3 as! MTCTLineDisplay
|
let line2 = sub3 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(31.433, 0)))
|
XCTAssertTrue(CGPointMake(31.433, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line1.hasScript);
|
XCTAssertFalse(line1.hasScript);
|
||||||
|
|
||||||
@@ -857,8 +866,8 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertNil(largeOp.upperLimit);
|
XCTAssertNil(largeOp.upperLimit);
|
||||||
|
|
||||||
let display2 = largeOp.lowerLimit!
|
let display2 = largeOp.lowerLimit!
|
||||||
XCTAssertEqual(display2.type, .regular);
|
XCTAssertEqual(display2.type, .regular)
|
||||||
XCTAssertTrue(CGPointEqualToPoint(display2.position, CGPointMake(6.89, -12.09)))
|
XCTAssertTrue(CGPointMake(6.89, -12.00).isEqual(to: display2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)));
|
||||||
XCTAssertFalse(display2.hasScript);
|
XCTAssertFalse(display2.hasScript);
|
||||||
XCTAssertEqual(display2.index, NSNotFound);
|
XCTAssertEqual(display2.index, NSNotFound);
|
||||||
@@ -877,7 +886,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
let line2 = sub3 as! MTCTLineDisplay
|
let line2 = sub3 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(31.1133, 0)))
|
XCTAssertTrue(CGPointMake(31.1133, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line1.hasScript);
|
XCTAssertFalse(line1.hasScript);
|
||||||
|
|
||||||
@@ -916,7 +925,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
|
|
||||||
let display2 = largeOp.lowerLimit!
|
let display2 = largeOp.lowerLimit!
|
||||||
XCTAssertEqual(display2.type, .regular);
|
XCTAssertEqual(display2.type, .regular);
|
||||||
XCTAssertTrue(CGPointEqualToPoint(display2.position, CGPointMake(10.94, -21.664)))
|
XCTAssertTrue(CGPointMake(10.94, -21.664).isEqual(to: display2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)))
|
XCTAssertTrue(NSEqualRanges(display2.range, NSMakeRange(0, 1)))
|
||||||
XCTAssertFalse(display2.hasScript);
|
XCTAssertFalse(display2.hasScript);
|
||||||
XCTAssertEqual(display2.index, NSNotFound);
|
XCTAssertEqual(display2.index, NSNotFound);
|
||||||
@@ -932,7 +941,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
|
|
||||||
let displayU = largeOp.upperLimit!
|
let displayU = largeOp.upperLimit!
|
||||||
XCTAssertEqual(displayU.type, .regular);
|
XCTAssertEqual(displayU.type, .regular);
|
||||||
XCTAssertTrue(CGPointEqualToPoint(displayU.position, CGPointMake(7.44, 23.154)))
|
XCTAssertTrue(CGPointMake(7.44, 23.154).isEqual(to: displayU.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(displayU.range, NSMakeRange(0, 1)))
|
XCTAssertTrue(NSEqualRanges(displayU.range, NSMakeRange(0, 1)))
|
||||||
XCTAssertFalse(displayU.hasScript);
|
XCTAssertFalse(displayU.hasScript);
|
||||||
XCTAssertEqual(displayU.index, NSNotFound);
|
XCTAssertEqual(displayU.index, NSNotFound);
|
||||||
@@ -951,7 +960,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
let line2 = sub3 as! MTCTLineDisplay
|
let line2 = sub3 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
XCTAssertEqual(line2.attributedString?.string, "𝑥");
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(32.2133, 0)))
|
XCTAssertTrue(CGPointMake(32.2133, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(1, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
@@ -1158,9 +1167,9 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertTrue(sub1 is MTCTLineDisplay);
|
XCTAssertTrue(sub1 is MTCTLineDisplay);
|
||||||
let line2 = sub1 as! MTCTLineDisplay
|
let line2 = sub1 as! MTCTLineDisplay
|
||||||
XCTAssertEqual(line2.atoms.count, 1);
|
XCTAssertEqual(line2.atoms.count, 1);
|
||||||
// The x is italicized
|
// The y is italicized
|
||||||
XCTAssertEqual(line2.attributedString?.string, "𝑦");
|
XCTAssertEqual(line2.attributedString?.string, "𝑦")
|
||||||
XCTAssertTrue(CGPointEqualToPoint(line2.position, CGPointMake(21.44, 0)))
|
XCTAssertTrue(CGPointMake(21.44, 0).isEqual(to: line2.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(2, 1)), "Got \(line2.range) instead")
|
XCTAssertTrue(NSEqualRanges(line2.range, NSMakeRange(2, 1)), "Got \(line2.range) instead")
|
||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
@@ -1246,7 +1255,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
|
|
||||||
let row = sub0i as! MTMathListDisplay
|
let row = sub0i as! MTMathListDisplay
|
||||||
XCTAssertEqual(row.type, .regular)
|
XCTAssertEqual(row.type, .regular)
|
||||||
XCTAssertTrue(CGPointEqualToPoint(row.position, CGPointMake(0, rowPos[i])))
|
XCTAssertTrue(CGPointMake(0, rowPos[i]).isEqual(to: row.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(row.range, NSMakeRange(0, 3)));
|
XCTAssertTrue(NSEqualRanges(row.range, NSMakeRange(0, 3)));
|
||||||
XCTAssertFalse(row.hasScript);
|
XCTAssertFalse(row.hasScript);
|
||||||
XCTAssertEqual(row.index, NSNotFound);
|
XCTAssertEqual(row.index, NSNotFound);
|
||||||
@@ -1258,7 +1267,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
|
|
||||||
let col = sub0ij as! MTMathListDisplay
|
let col = sub0ij as! MTMathListDisplay
|
||||||
XCTAssertEqual(col.type, .regular);
|
XCTAssertEqual(col.type, .regular);
|
||||||
XCTAssertTrue(CGPointEqualToPoint(col.position, CGPointMake(cellPos[i][j], 0)))
|
XCTAssertTrue(CGPointMake(cellPos[i][j], 0).isEqual(to: col.position, accuracy: 0.01))
|
||||||
XCTAssertFalse(col.hasScript)
|
XCTAssertFalse(col.hasScript)
|
||||||
XCTAssertEqual(col.index, NSNotFound);
|
XCTAssertEqual(col.index, NSNotFound);
|
||||||
}
|
}
|
||||||
@@ -1554,7 +1563,7 @@ final class MTTypesetterTests: XCTestCase {
|
|||||||
XCTAssertFalse(line2.hasScript);
|
XCTAssertFalse(line2.hasScript);
|
||||||
|
|
||||||
let glyph = accentDisp.accent!
|
let glyph = accentDisp.accent!
|
||||||
XCTAssertTrue(CGPointEqualToPoint(glyph.position, CGPointMake(3.47, 0)))
|
XCTAssertTrue(CGPointMake(3.47, 0).isEqual(to: glyph.position, accuracy: 0.01))
|
||||||
XCTAssertTrue(NSEqualRanges(glyph.range, NSMakeRange(0, 1)))
|
XCTAssertTrue(NSEqualRanges(glyph.range, NSMakeRange(0, 1)))
|
||||||
XCTAssertFalse(glyph.hasScript);
|
XCTAssertFalse(glyph.hasScript);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user