expo / google-fonts

Use any of the 1000+ fonts (and their variants) from fonts.google.com in your Expo app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UseFonts throws an error in Mac BigSur

poustchi opened this issue · comments

commented

UseFonts throws the following error on BigSur but its ok on Catalina

FontStatus: [Error: Unexpected status line: Y�] false


import * as React from "react";
import { View, Text, StyleSheet } from "react-native";
import AppLoading from "expo-app-loading";

import {
  useFonts,
  Roboto_100Thin,
  Roboto_100Thin_Italic,
  Roboto_300Light,
  Roboto_300Light_Italic,
  Roboto_400Regular,
  Roboto_400Regular_Italic,
  Roboto_500Medium,
  Roboto_500Medium_Italic,
  Roboto_700Bold,
  Roboto_700Bold_Italic,
  Roboto_900Black,
  Roboto_900Black_Italic,
} from "@expo-google-fonts/roboto";

export default function App() {
  let [loaded, error] = useFonts({
    Roboto_100Thin,
    Roboto_100Thin_Italic,
    Roboto_300Light,
    Roboto_300Light_Italic,
    Roboto_400Regular,
    Roboto_400Regular_Italic,
    Roboto_500Medium,
    Roboto_500Medium_Italic,
    Roboto_700Bold,
    Roboto_700Bold_Italic,
    Roboto_900Black,
    Roboto_900Black_Italic,
  });

  if (!loaded) {
    return <AppLoading />;
  }

  console.log("FontStatus:", error, loaded);

  return (
    <View>

      <Text style={{ fontFamily: "Roboto_100Thin", fontSize: 30 }}>
        ABCDEFGHIabcdefghi
      </Text>
      
    </View>
  );
}

I've run into a similar issue. However, I'm not using expo-google-fonts and instead I've had the issues with local assets I'm loading via expo-fonts.
I've even just create a new app using the " tabs (TypeScript) - several example screens and tabs using react-navigation and TypeScript" template which includes space-mono. However, running the app gives me

Unexpected status line: 0+%#'77'7''73''77b`�3X

                                              X3�`�3X

                                                     X3P�3X2-4-2X3��3X2-��-2X3
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:103:50 in promiseMethodWrapper
at node_modules/@unimodules/react-native-adapter/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-file-system/build/FileSystem.js:105:17 in downloadAsync
at node_modules/expo-file-system/build/FileSystem.js:101:7 in downloadAsync
at node_modules/expo-asset/build/PlatformUtils.js:49:25 in _downloadAsyncManagedEnv

fontFamily "space-mono" is not a system font and has not been loaded through Font.loadAsync.

I'm using a M1 Macbook running Big Sur. Again, this issue seem to be with expo-font which expo-google-fonts calls.

Same issue here, someone fixed?

UseFonts throws the following error on BigSur but its ok on Catalina

FontStatus: [Error: Unexpected status line: Y�] false


import * as React from "react";
import { View, Text, StyleSheet } from "react-native";
import AppLoading from "expo-app-loading";

import {
  useFonts,
  Roboto_100Thin,
  Roboto_100Thin_Italic,
  Roboto_300Light,
  Roboto_300Light_Italic,
  Roboto_400Regular,
  Roboto_400Regular_Italic,
  Roboto_500Medium,
  Roboto_500Medium_Italic,
  Roboto_700Bold,
  Roboto_700Bold_Italic,
  Roboto_900Black,
  Roboto_900Black_Italic,
} from "@expo-google-fonts/roboto";

export default function App() {
  let [loaded] = useFonts({
    Roboto_100Thin,
    Roboto_100Thin_Italic,
    Roboto_300Light,
    Roboto_300Light_Italic,
    Roboto_400Regular,
    Roboto_400Regular_Italic,
    Roboto_500Medium,
    Roboto_500Medium_Italic,
    Roboto_700Bold,
    Roboto_700Bold_Italic,
    Roboto_900Black,
    Roboto_900Black_Italic,
  });

  if (!loaded) {
    return <AppLoading />;
  }

  console.log("FontStatus:", loaded);

  return (
    <View>

      <Text style={{ fontFamily: "Roboto_100Thin", fontSize: 30 }}>
        ABCDEFGHIabcdefghi
      </Text>
      
    </View>
  );
}

have you tried to remove the error variable from useFonts() method? Idk if that was your intention but maybe isn't the right way to catch an error, just loaded can handle the thing for ya, returning boolean values!