react-native-htmlview icon indicating copy to clipboard operation
react-native-htmlview copied to clipboard

Can we customized font

Open possathornwitt opened this issue 6 years ago • 3 comments

In my html style, my p tag is using 'sukhumvit' font-family. I'm wondering how to show the text in that custom font.

I do have .otf in asset folder. Thank you in advance!

possathornwitt avatar Mar 30 '19 16:03 possathornwitt

You can follow this guide, and after just add the fontFamily to the tags you want, e.g.:

import HTMLView from "react-native-htmlview";

const YourComponent = () => <HTMLView stylesheet={styles} />

const styles = StyleSheet.create({
  // Make sure to add all tags you want to customize
  h1: {
    fontFamily: "YourCustomFontFamilyName"
  },
  h2: {
    fontFamily: "YourCustomFontFamilyName"
  },
  p: {
    fontFamily: "YourCustomFontFamilyName"
  }
});

manfromanotherland avatar Aug 06 '19 16:08 manfromanotherland

@edmundojr how to set font for all text tags, i dont want to set manually to h1, h2, h3,...

huy-lv avatar Aug 31 '20 11:08 huy-lv

@huy-lv I haven't used this in a while, so not sure if there's a way to do for all the text tags at once.

manfromanotherland avatar Aug 31 '20 11:08 manfromanotherland