question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Text TSpan dy behaves differently on Android and iOS

See original GitHub issue

Notice the relative size difference between the text and the <Rect/> on iOS and Android:

screen shot 2017-06-19 at 12 13 03 am
import React from 'react';
import { View } from 'react-native';
import Svg, { Rect, Text, TSpan } from "react-native-svg";

export default class App extends React.Component {
  render() {
    return (
      <View>
      <Svg
          height="160"
          width="200"
      >
          <Rect fill="blue" x="0" y="25" width="5" height="42" />
          <Text y="20" dx="5 5">
              <TSpan x="10" >tspan line 1</TSpan>
              <TSpan x="10" dy="15">tspan line 2</TSpan>
              <TSpan x="10" dx="10" dy="15">tspan line 3</TSpan>
          </Text>
      </Svg>
      </View>
    );
  }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:48

github_iconTop GitHub Comments

3reactions
msandcommented, Jun 21, 2017

@chrisbolin I have letter-spacing and kerning implemented now as well (even chrome doesn’t support the kerning attribute in svg yet). I’ve removed all magical constant and other strange things.

It is now possible to make it render similar output in both chrome and react-native in android, but native sometimes needs different font-size, letter-spacing, and start-offset values, seemingly depending on the length of the path referenced in the href attribute of the textpath element.

Except for that, it now seems at least possible to get essentially pixel perfect results for text, tspan and textpath, merely requiring scaling of some values for the native rendering.

1reaction
msandcommented, Aug 16, 2017

@chrisbolin @gpeal @OzoTek There is now a new version and pull request, with some of the fixes from android ported to ios: https://github.com/react-native-community/react-native-svg/pull/430

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text TSpan dy behaves differently on Android and iOS #377
It is now possible to make it render similar output in both chrome and react-native in android, but native sometimes needs different font-size,...
Read more >
<tspan> - SVG: Scalable Vector Graphics - MDN Web Docs
The SVG <tspan> element defines a subtext within a <text> element ... dy. Shifts the text position vertically from a previous text element....
Read more >
Duplication of SVG text-paths on iOS/Safari - Stack Overflow
Here the text is duplicated below the paths. See the image below for what I mean by "duplicated". Any idea on why Safari...
Read more >
Exporting Diagram with custom Shape shows text outside the ...
When exporting Diagram with a custom shape in iOS (iPad v.15) the text inside that custom shape is not placed inside the shape....
Read more >
Safari Technology Preview Release Notes - Apple Developer
Many of the new Safari 16 features are now available in Safari Technology Preview 147: Live Text. Select and interact with text in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found