expo / vector-icons

https://icons.expo.fyi
MIT License
671 stars 116 forks source link

Creating icon set for Remix Icon #313

Closed Code-Victor closed 3 months ago

Code-Victor commented 3 months ago

Issue with RemixIcon Displaying Numbers Instead of Icons

I'm trying to use RemixIcon with Expo Vector Icons, but I'm encountering an issue where only numbers are displayed instead of the icons.

Here's the code I'm using:

import createIconSet from "@expo/vector-icons/createIconSet";
import remixiconGlyphMap from "@/assets/icons/remixicon.glyphmap.json";

export const RemixIcon = createIconSet(
  remixiconGlyphMap,
  "remixicon",
  "@/assets/icons/remixicon.ttf"
);

In my component, I have:

<RemixIcon
  name={focused ? "calendar-schedule-fill" : "calendar-schedule-line"}
  color={color}
  size={24}
  aria-labelledby="order-tab-label"
/>

However, all I see is the number instead of the icon: Issue Screenshot

I suspect the font isn't loaded correctly, but the documentation doesn't provide guidance on this. I tried loading the font globally with the following code:

const [fontsLoaded, fontsError] = useFonts({
  // other fonts ...
  remixicon: require("@/assets/icons/remixicon.ttf"),
});

Despite this, it still doesn't work. Any help would be greatly appreciated.

Code-Victor commented 3 months ago

Here's my remixicon.glypmap.json file. https://gist.github.com/Code-Victor/52a61086d3a16404dbe42c87a25be746

Looking forward to a response

Code-Victor commented 3 months ago

I've found a solution. It's in two folds. First, my glyphmap wasn't generated correctly. It should have values of numbers and not strings. Secondly, my code needed a bit of modification:

import createIconSet from "@expo/vector-icons/createIconSet";
import remixiconGlyphMap from "@/assets/icons/remixicon.glyphmap.json";

const expoAssetId = require("@/assets/icons/remixicon.ttf");
export const RemixIcon = createIconSet(
  remixiconGlyphMap,
  "remixicon",
  expoAssetId
);

Thanks