SwiftMath icon indicating copy to clipboard operation
SwiftMath copied to clipboard

Text does not fit in view

Open AtaberkKilinctekin opened this issue 1 year ago • 1 comments

`struct MathView: UIViewRepresentable { var equation: String var font: MathFont = .firaFont var textAlignment: MTTextAlignment = .left var fontSize: CGFloat = 20 var labelMode: MTMathUILabelMode = .display var insets: MTEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 20)

func makeUIView(context: Context) -> MTMathUILabel {
	let view = MTMathUILabel()
	return view
}

func updateUIView(_ view: MTMathUILabel, context: Context) {
	view.latex = equation
	view.font = MTFontManager().font(withName: font.rawValue, size: fontSize)
	view.textAlignment = textAlignment
	view.labelMode = labelMode
	view.textColor = MTColor.primaryGreen
	view.contentInsets = insets
}

}`

Here is my code and the view looks like in the picture

Screenshot 2024-12-25 at 16 20 32

The question text is:

"18.\ \text{Harry wants to paint the side of his house. The total perimeter is 32 metres. What is the length of X?}\\\n\n19.\ \text{What is the area of the side of his house?}\\\n\n20.\ \text{Harry uses 3 litres of red paint, 4 litres of blue paint and 5 litres of white paint}\\\\\n\text{to paint the side of his house. What percentage of the paint was red?}"

Parent view has a frame. The code is complex so that I cannot provide all code here.

How can I solve this problem?

AtaberkKilinctekin avatar Dec 25 '24 13:12 AtaberkKilinctekin

Did you solve this? It seems that this library uses weird framing and makes it hard to control. It seems to want to expand infinitely horizontally and/or vertically depending on what container it's in. :-(

marklambourne avatar Feb 13 '25 08:02 marklambourne