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

Use FontFace and consistent text sizing #988

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

boatbomber
Copy link
Member

@boatbomber boatbomber commented Nov 6, 2024

The Gotham font we use no longer exists. This PR upgrades to using FontFace, and also unifies our styling by putting fonts and text sizes into Theme instead of hardcoding them inline. This will make it easier to adjust our UI in the future (or perhaps add accessibility settings).

It's pretty much identical to before, but all the text sizes are consistent (no more 14 vs 15) and the notifs and tooltips are better at getting the correct text bounds (no cutting off edge cases anymore).

Screenshot 2024-11-05 180127

@boatbomber boatbomber added scope: plugin Relevant to the Roblox Studio plugin type: tech debt Internal work that needs to happen skip changelog PRs that may skip the changelog enforcement check labels Nov 6, 2024
Copy link
Member

@kennethloeffler kennethloeffler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, and this can probably be included in the changelog as "Fixed notification and tooltip text sometimes getting cut off"


local params = Instance.new("GetTextBoundsParams")

local function getTextBounds(text: string, font: Font, textSize: number, width: number, richText: boolean?): Vector2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can yield, so it should probably have a name that reflects this - and it's also not OK to yield in Roact! I'm not sure exactly when it will yield, and our TextService:GetTextBoundsAsync usage has seemed fine so far, but it probably warrants further review. You're more familiar with this area of the codebase so you'll be more able to tell if it's a problem or not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetTextBoundsAsync only yields when the font isn't loaded, as per Roblox's own docs. Assuming we trust them, we could ensure it never yields by preloading the fonts when the plugin initializes.

That said, I suspect that builtin fonts are just always loaded in Studio or load quick enough that it won't matter. This would be more of a concern if we were using a custom font.

local params = Instance.new("GetTextBoundsParams")

local function getTextBounds(text: string, font: Font, textSize: number, width: number, richText: boolean?): Vector2
params.Text = text
Copy link
Member

@kennethloeffler kennethloeffler Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property set should probably have a check for text with length >= 200000, right now it's possible to brick the entire Rojo UI by trying to view an extremely large script in the diff viewer

Copy link
Member

@Dekkonot Dekkonot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ken already addressed the concerns I have; this needs a changelog entry, and our text bound check might yield. Otherwise, looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: plugin Relevant to the Roblox Studio plugin skip changelog PRs that may skip the changelog enforcement check type: tech debt Internal work that needs to happen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants