google-fonts icon indicating copy to clipboard operation
google-fonts copied to clipboard

UseFonts throws an error in Mac BigSur

Open poustchi opened this issue 3 years ago • 3 comments

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>
  );
}

poustchi avatar Jul 06 '21 02:07 poustchi

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.

guess-burger avatar Aug 08 '21 14:08 guess-burger

Same issue here, someone fixed?

JordaoViktor avatar Oct 13 '21 23:10 JordaoViktor

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!

herbertfuchs avatar Jun 01 '22 19:06 herbertfuchs