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

Strikethrough text needs an implementation on coregraphics and cairo #301

Open
smmalis37 opened this issue Sep 6, 2020 · 2 comments
Open
Labels
piet-coregraphics issue in the CoreGraphics backend text

Comments

@smmalis37
Copy link
Collaborator

See #299. For coregraphics https://www.cocoanetics.com/2011/01/befriending-core-text/ has some useful details.

@cmyr cmyr added piet-cairo issue in the cairo backend piet-coregraphics issue in the CoreGraphics backend text labels Sep 7, 2020
@cmyr
Copy link
Member

cmyr commented Sep 7, 2020

Looking into this it's a bit annoying; we really would want to do strikethrough run-by-run, since the position and width of the strikethrough depends on the font, unlike underline, which uses the same style or each line.

My inclination is to not invest too much in this right now, and we can revisit for a future cycle.

@cmyr cmyr removed the piet-cairo issue in the cairo backend label Sep 3, 2021
@cmyr
Copy link
Member

cmyr commented Sep 3, 2021

So, on doing this for core-graphics:

  • we need to pick a strikethrough position. This can be a heuristic; I would start by trying 50% of the font's reported x-height.
  • we need to decide how to handle lines with multiple runs of different fonts or different sizes. Since we don't paint run-by-run, we will have to just pick a single position, and it will not look right if fonts have different heights, but I think that's okay for now; so I would just go with the first font in the region?
    • (actually, maybe we can keep track of this per run? we know the offsets of the runs, and we're drawing ourselves, so this should be doable? but I don't mind if we keep things simple for now)
    • we need to pick a stroke width. I don't have any insight here. There is CTFontGetUnderlineThickness which might be a good proxy, but we could also just pick some number, either absolute or relative to point size, and go with that.
    • we need to store the stroke information for a given layout object ourselves, inside the object. I would try to store this as a Rc<[Line]>, with coordinates relative the origin of the layout. (we may also want to store color and stroke thickness?)
    • after painting the layout, we iterate the strikethrough lines and paint those overtop.

I'm not sure about any of this; it's just my best guess for how it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
piet-coregraphics issue in the CoreGraphics backend text
Projects
None yet
Development

No branches or pull requests

2 participants