Unable to Display Text Fully in Text() SwiftUI

Hi!

I am working on an app that requires displaying special characters and I have currently implemented it to just use Text() in swiftUI.

Unfortunately, it can't display the full height of the text.

Attached is one example of this happening.

I have attempted to do .linespacing() but that method doesn't work. .frame also doesn't seem to make a change. Does anyone have a solution to this?

Thanks!

Answered by Claude31 in 796327022

Effectively, it does not display the circle below g:

Adding a baseline offset makes it work:

struct ContentView: View {
    
    var body: some View {
        Text("[ɡ̠̥ɑʔ͡t]")
            .baselineOffset(10)
            .font(.title)
            .fontWeight(.semibold)
            .padding()
    }
}

I did the test with Xcode 16.0ß2.

How did you set the frame height for the Text ?

Text("some text")
.frame(height: 60)  // Adjust as needed

Could you post the code (and indicate which language it is), so that we can make some tests ?

Yea I tried setting the frame height for the Text and it doesn't change it...

Apologies in advance for not so good code (should probably used case)

Here is the swift code block

@ViewBuilder
    var answer: some View {
            VStack {
                Spacer()
                if viewModel.result_string == "lessthantwo" {
                    FormattedAnswerView(text: "Invalid Input")
                } else if viewModel.result_string == "cannotRecogniseCharacter" {
                    FormattedAnswerView(text: "Are you sure that is IPA?")
                } else {
                    Text(viewModel.result_string)
                        .font(.title)
                        .fontWeight(.semibold)
                        .padding()
                }
                Spacer()
                Button(action: {
                    if !viewModel.result_string.isEmpty {
                        UIPasteboard.general.string = viewModel.result_string
                    }
                }) {
                    Label("Copy", systemImage: "square.on.square")
                        .fontWeight(.semibold)
                        .foregroundStyle(Color("themeColor"))
                        .padding()
                }
            }
    }

Happy to provide more code and context if it helps to find a solution!

Thanks, but I would need to see the part of code with Text("") which does not display correctly (with the exact string with large height).

So the specific part is this

Text(viewModel.result_string)
    .font(.title)
    .fontWeight(.semibold)
    .padding()

If you want the exact string then it will look like this:

Text(["ɡ̠̥ɑʔ͡t]")
    .font(.title)
    .fontWeight(.semibold)
    .padding()
Accepted Answer

Effectively, it does not display the circle below g:

Adding a baseline offset makes it work:

struct ContentView: View {
    
    var body: some View {
        Text("[ɡ̠̥ɑʔ͡t]")
            .baselineOffset(10)
            .font(.title)
            .fontWeight(.semibold)
            .padding()
    }
}

I did the test with Xcode 16.0ß2.

Ah alright, let me give that a try 🙇🏻‍♂️

Thanks so much for the help I was genuinely lost and couldn't find any solutions anywhere else!

Unable to Display Text Fully in Text() SwiftUI
 
 
Q