@ expo- google- fonts/ google- sans- 代码
此软件包允许您使用 谷歌桑斯码 字体家族从 谷歌字体 在你的博览会应用.
谷歌桑斯码

此字体家族包含 12个样式。 。 。 .
GoogleSansCode_300LightGoogleSansCode_400RegularGoogleSansCode_500MediumGoogleSansCode_600SemiBoldGoogleSansCode_700BoldGoogleSansCode_800ExtraBoldGoogleSansCode_300Light_ItalicGoogleSansCode_400Regular_ItalicGoogleSansCode_500Medium_ItalicGoogleSansCode_600SemiBold_ItalicGoogleSansCode_700Bold_ItalicGoogleSansCode_800ExtraBold_Italic
使用量
从您的 Expo 项目的根目录中的 shell 中运行此命令, 以便将字体家族包添加到您的工程中
npx expo install @expo-google-fonts/google-sans-code expo-font
现在将这样的代码添加到您的工程中
import { Text, View } from "react-native";
import { useFonts } from '@expo-google-fonts/google-sans-code/useFonts';
import { GoogleSansCode_300Light } from '@expo-google-fonts/google-sans-code/300Light';
import { GoogleSansCode_400Regular } from '@expo-google-fonts/google-sans-code/400Regular';
import { GoogleSansCode_500Medium } from '@expo-google-fonts/google-sans-code/500Medium';
import { GoogleSansCode_600SemiBold } from '@expo-google-fonts/google-sans-code/600SemiBold';
import { GoogleSansCode_700Bold } from '@expo-google-fonts/google-sans-code/700Bold';
import { GoogleSansCode_800ExtraBold } from '@expo-google-fonts/google-sans-code/800ExtraBold';
import { GoogleSansCode_300Light_Italic } from '@expo-google-fonts/google-sans-code/300Light_Italic';
import { GoogleSansCode_400Regular_Italic } from '@expo-google-fonts/google-sans-code/400Regular_Italic';
import { GoogleSansCode_500Medium_Italic } from '@expo-google-fonts/google-sans-code/500Medium_Italic';
import { GoogleSansCode_600SemiBold_Italic } from '@expo-google-fonts/google-sans-code/600SemiBold_Italic';
import { GoogleSansCode_700Bold_Italic } from '@expo-google-fonts/google-sans-code/700Bold_Italic';
import { GoogleSansCode_800ExtraBold_Italic } from '@expo-google-fonts/google-sans-code/800ExtraBold_Italic';
export default () => {
let [fontsLoaded] = useFonts({
GoogleSansCode_300Light,
GoogleSansCode_400Regular,
GoogleSansCode_500Medium,
GoogleSansCode_600SemiBold,
GoogleSansCode_700Bold,
GoogleSansCode_800ExtraBold,
GoogleSansCode_300Light_Italic,
GoogleSansCode_400Regular_Italic,
GoogleSansCode_500Medium_Italic,
GoogleSansCode_600SemiBold_Italic,
GoogleSansCode_700Bold_Italic,
GoogleSansCode_800ExtraBold_Italic
});
let fontSize = 24;
let paddingVertical = 6;
if (!fontsLoaded) {
return null;
} else {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_300Light"
}}>
Google Sans Code Light
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_400Regular"
}}>
Google Sans Code Regular
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_500Medium"
}}>
Google Sans Code Medium
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_600SemiBold"
}}>
Google Sans Code Semi Bold
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_700Bold"
}}>
Google Sans Code Bold
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_800ExtraBold"
}}>
Google Sans Code Extra Bold
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_300Light_Italic"
}}>
Google Sans Code Light Italic
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_400Regular_Italic"
}}>
Google Sans Code Italic
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_500Medium_Italic"
}}>
Google Sans Code Medium Italic
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_600SemiBold_Italic"
}}>
Google Sans Code Semi Bold Italic
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_700Bold_Italic"
}}>
Google Sans Code Bold Italic
</Text>
<Text style={{
fontSize,
paddingVertical,
// Note the quoting of the value for `fontFamily` here; it expects a string!
fontFamily: "GoogleSansCode_800ExtraBold_Italic"
}}>
Google Sans Code Extra Bold Italic
</Text>
</View>
);
}
};
QQ 画廊
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
开发期间的使用
如果您尝试了许多不同的字体, 您可以尝试使用 @expo-google-fonts/dev 软件包。 。 。 .
您可以导入 任意 任何 Expo Google 字体包的字体样式。 它会在运行时将字体加载到网络上,而不是将资产作为文件添加到您的项目中,因此您的应用程序在启动时可能需要更长的时间才能实现交互,但是在任意风格的游戏中极方便.
许可证
这个 @expo-google-fonts/google-sans-code 软件包及其代码在麻省理工学院许可下发布.
Google字体目录中的所有字体都是免费和开源的.
检查 谷歌字体上的 Google Sans 代码页面 该字体家族的特定许可证.
您可以在您的产品和项目中自由使用这些字体 -- -- 打印或数字、商业或其他。 然而,不能自行销售字体. 这不是法律建议,请考虑咨询律师 并查看所有细节的完整许可证.
链接
- 谷歌字体上的 Google Sans 代码
- 谷歌字体
- Npm 上的这个软件包
- GitHub 上的这个软件包
- GitHub 上的博览会 Google 字体项目
@expo-google-fonts/dev开发软件包
捐款
贡献是非常受欢迎的! 这个整个目录,包括您现在所读的内容,都是由代码生成的. 请不直接提交公关文件,而是向 生成器 换句话说.











