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.

Regression: Font properties aren't applied when changed

See original GitHub issue

When font properties such as fontSize are changed, the new value is not applied to the image. Note that if another non-font property is changed, such as fill the new font properties are applied.

This effects version 6.3 and newer, but worked correctly in 6.2.2. Therefore, running this example on snack shows the expected behavior, since expo still uses 6.2.2:

// @flow

import React, { PureComponent } from "react";
import { View, Button } from "react-native";
import Svg, { Text } from "react-native-svg";

export default class extends PureComponent<
  {},
  { fontSize: number, fill: string }
> {
  state = {
    fontSize: 20,
    fill: "red"
  };

  _toggleFontSize = () => {
    this.setState(({ fontSize }) => ({
      fontSize: fontSize === 20 ? 40 : 20
    }));
  };

  _toggleFontSizeAndFill = () => {
    this.setState(({ fontSize, fill }) => ({
      fontSize: fontSize === 20 ? 40 : 20,
      fill: fill === "red" ? "blue" : "red"
    }));
  };

  render() {
    return (
      <View>
        <Svg
          style={{ backgroundColor: "rgb(230, 230, 230)" }}
          width={400}
          height={200}
        >
          <Text
            x={0}
            y={100}
            fill={this.state.fill}
            fontSize={this.state.fontSize}
          >
            Some example text
          </Text>
        </Svg>

        <View>
          <Button onPress={this._toggleFontSize} title="Toggle Font Size" />
          <Button
            onPress={this._toggleFontSizeAndFill}
            title="Toggle Font Size & Fill"
          />
        </View>
      </View>
    );
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
msandcommented, Aug 26, 2018

It’s part of this PR https://github.com/react-native-community/react-native-svg/pull/757 It’s in my fork in the NativeAnimationExperiment branch. As I haven’t merged the PR it’s not visible in any branch of this repo yet. Good to know it works! 👍

0reactions
msandcommented, Sep 15, 2018

I’ve release the fixes, latest version now is v7.0.1 This can probably closed now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regression: Font properties aren't applied when changed #760
When font properties such as fontSize are changed, the new value is not applied to the image. Note that if another non-font property...
Read more >
454340 - [Regression]: Selected font color is not retained after ...
Issue 454340: [Regression]: Selected font color is not retained after user selects font color and applies alignment/bullet.
Read more >
html - Font family does not change in the output - Stack Overflow
There is no change at all in h1, that I had applied it to. Following is my HTML code: <h1 align="center" class="login ...
Read more >
5.3 - The Multiple Linear Regression Model | STAT 462
If the null hypothesis above were the case, then a change in the value of x_{1} would not change y, so y and...
Read more >
Change Font in Comments (Writer 4.1.04) - Ask LibreOffice
Crunchbang 11, v3.5.7.2: It is only possible to set the bold/italic/underline attribute in a comment but not Font name or Font size. Set...
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