0

我已经安装了许多字体..并且一切正常,但不是 NOTO-Fonts。我创建了一个简单的代码,向您展示问题。Licorice-Regular 和 GeoAcadNusxNormal 在 iOS 和 android 上显示得非常好。但 NOTO-Fonts 仅显示为标准字体。我以相同的方式安装了所有字体。所有字体都在 Android 和 Xcode 的正确文件夹中。我可以很好地在 Xcode 中看到正确的 NOTO-Fonts 符号。

const App = () => {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "white"
      }}>
      <Text>Hello, world!</Text>
      <Text style={{ fontFamily: 'Licorice-Regular', fontSize: 40 }}>
        Google-Font fine on ios and android (Simulator and real device)
      </Text>
      <Text style={{ fontFamily: 'GeoAcadNusxNormal', fontSize: 40 }}>
        Custom-Font fine on ios and android
      </Text>
      <Text style={{ fontFamily: 'NotoSansGeorgian-Medium' }}>
        NOTO-Font doesn't work. Is shown as standart Font, but not georgian.
      </Text>
      <Text style={{ fontFamily: 'NotoSansTamil-Regular' }}>
        NOTO-Font doesn't work. Is shown as standart Font, but not Tamil.
      </Text>
    </View>
  )
}

我的 react-native.config.js 看起来像这样:

module.exports = {
    project: {
        ios: {},
        android: {},
    },
    assets: ['./src/assets/fonts/'],
};

这是我的 package.json

{
  "name": "Test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "17.0.2",
    "react-localization": "^1.0.17",
    "react-native": "0.66.4",
    "react-native-mmkv": "^1.5.4",
    "react-native-reanimated": "^2.3.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  }
}
4

1 回答 1

0

我找到了一个解决方案:

当我在代码中使用“a”时使用 GeoAcadNusxNormal-custom-font。并且“ა”显示在应用程序显示屏上。这对我来说很好。但是使用 NOTO-Fonts wenn 我使用“a”,我在显示屏上看到“a”并且我很恼火,正如你在上面看到的那样。嗯,现在我在我的电脑上安装了格鲁吉亚字体,在我的代码中我现在尝试了格鲁吉亚字体“ა” 取而代之的是“a”和应用程序显示现在显示正确的格鲁吉亚ა。

我不确定,如果我做得很好,但现在可以了。在新设备上,Georgian 字体也在 Noto-Georgian-font 中正确显示。

<Text style={{ fontFamily: 'NotoSansGeorgian-Regular', fontSize: 40 }}>ზტლწოაჯ&lt;/Text>

问候!

于 2022-01-04T16:50:44.220 回答