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

Support alignment-baseline and dominant-baseline #247

Open
anton-shchyrov opened this issue Feb 5, 2022 · 3 comments
Open

Support alignment-baseline and dominant-baseline #247

anton-shchyrov opened this issue Feb 5, 2022 · 3 comments

Comments

@anton-shchyrov
Copy link

The library unsupported vertical alignment text

SVG

<?xml version='1.0' encoding='utf-8'?>
<svg height='40' width='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'>
  <rect x="0" y="0" width="40" height="40" fill="white" stroke="black"/>
  <path d="M 0 20 H 40" stroke="black"/>
  <path d="M 20 0 V 40" stroke="black"/>
  <text x='20' y='20' text-anchor='middle'
    alignment-baseline='middle' dominant-baseline='middle'
    font-size='14'>Test</text>
</svg>

The resulting picture

Library picture

Picture in browser

Browser picture

@BigBadaboom BigBadaboom changed the title Text vertical alignment Support alignment-baseline and dominant baseline Feb 6, 2022
@BigBadaboom BigBadaboom changed the title Support alignment-baseline and dominant baseline Support alignment-baseline and dominant-baseline Feb 6, 2022
@BigBadaboom
Copy link
Owner

I'm not sure that this is going to be possible. I don't think the current Android APIs provide a way to control the typeface baseline table..

@anton-shchyrov
Copy link
Author

Maybe support only three values: hanging, middle, baseline? And do it in the same way as an text-anchor

if (anchor != Style.TextAnchor.Start) {
   float  textWidth = calculateTextWidth(obj);
   if (anchor == Style.TextAnchor.Middle) {
      x -= (textWidth / 2);
   } else {
      x -= textWidth;  // 'End' (right justify)
   }
}

@BigBadaboom
Copy link
Owner

Yes. Some values could be emulated/approximated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants