Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coin icon covering text #108

Closed
LiviiYS opened this issue Oct 18, 2023 · 3 comments
Closed

Coin icon covering text #108

LiviiYS opened this issue Oct 18, 2023 · 3 comments
Labels
priority: low this issue only has minor effects - adressing it is not immediately required type: compatibility this issue is caused by a compatibility problem

Comments

@LiviiYS
Copy link

LiviiYS commented Oct 18, 2023

When using numismatic with modernui the coin icon partially covers the number,

2023-10-18_18 29 05

@gliscowo gliscowo added type: compatibility this issue is caused by a compatibility problem priority: low this issue only has minor effects - adressing it is not immediately required labels Dec 1, 2023
@gliscowo
Copy link
Member

gliscowo commented Dec 1, 2023

Unfortunately I don't think this issue is a great concern for us, given that ModernUI explicitly causes it - please report it to them instead. This is also more likely to lead to a solution, as they will be much more familiar with the modifications they make to text rendering code, whereas we would need to first reverse-engineer their implementation

I'll leave this issue open for now until we hear from them, but we won't be actively looking into it

Cheers

@BloCamLimb
Copy link

This is a common problem, your code assumes incorrect text layout:

private static Text createPlaceholder(String text) {
String placeholder = "§7 " + text + " ";
return Text.of(placeholder);
}

Modern UI has a Complex Text Layout Engine, the width of space characters depends on FreeType scaler and TrueType designer, and it's context-aware. Thus, you may write a helper method kinda like this, if you want to provide reliable indentation:

// in yarn namespace
static String indentation(TextRenderer tr, int indent) {
    var str = " ";
    while (tr.getWidth(str) < indent) str += " ";
    return str;
}

Notably, you shouldn't measure a single space character and do division. Firstly, getWidth returns the ceiling of string width. Secondly, text layout is context-aware, it's not linear.
But you can cache this indentation string after a resource reload on main thread, to deal with font changes, via net.fabricmc.fabric.api.resource.SimpleResourceReloadListener#apply

@Noaaan Noaaan added the status: scheduled the resolution of this issue is scheduled for the next release label Dec 31, 2023
@Noaaan
Copy link
Member

Noaaan commented Dec 31, 2023

Fixed as of 0.2.12 for 1.20.1 and 1.20.2

@Noaaan Noaaan closed this as completed Dec 31, 2023
@Noaaan Noaaan removed the status: scheduled the resolution of this issue is scheduled for the next release label Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low this issue only has minor effects - adressing it is not immediately required type: compatibility this issue is caused by a compatibility problem
Projects
None yet
Development

No branches or pull requests

4 participants