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

Text range styling functions #6

Open
11 tasks
svallory opened this issue Aug 19, 2023 · 0 comments
Open
11 tasks

Text range styling functions #6

svallory opened this issue Aug 19, 2023 · 0 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@svallory
Copy link
Member

Original issue: react-figma#18

Are there any plans to add getRange... setRange... methods like getRangeFontName, setRangeFontName etc?

How it should work?

The functions mentioned in the issue are used to modify the styling of a part of a text. The "range" refers to the part of the text the styling will be applied to. I believe it will not be a simple implementation of returning certain results as Figma docs suggests right at the beginning that there may be several edge cases.

From Figma's documentation on Working with text
When working with text nodes, there are a lot of things to consider:

  • Mixed styles
  • Loading fonts
  • Missing fonts

To Do

Preparation

  • Read the documentation for:
  • make notes of cases we need to cover
    If needed, new items will be added to this list
  • See if there are cases, like missing fonts, that may be shared between multiple cases, e.g., setRangeFontName(), and setRangeTextStyleId()
  • Propose an implementation architecture before proceeding
    We should try to reduce rewriting boilerplate code. I have the feeling these function implementations will be very similar, but it may not be obvious how to generalize to one or two generic solutions

Implementation

NOTE: Each function needs to be added to both TextNode and TextSublayer

  • setRangeFontSize()
  • setRangeFontName()
  • setRangeTextCase()
  • setRangeTextDecoration()
  • setRangeLetterSpacing()
  • setRangeLineHeight()
  • setRangeTextStyleId()
@svallory svallory added this to the Clearing issues and PRs milestone Aug 19, 2023
@svallory svallory added the help wanted Extra attention is needed label Aug 19, 2023
@svallory svallory assigned svallory and unassigned svallory Aug 19, 2023
@albnunes albnunes self-assigned this Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants