Get the unicode icon value from a custom font

独自空忆成欢 提交于 2019-12-18 04:17:22

问题


I need to write a CSS for an icon font build using the site flaticon. I develop using a MAC with 10.10 and can't find any way to retrieve a single character Unicode value that I need to insert inside my CSS

.font-icon-pencil:before {
    content: "\e038";
}

How can I read the contents of a font file, to get the icon codes within that custom-made font?


回答1:


On MacOS Sierra I'm able to get a unicode value of icon in Font Book (default app).

  1. Install the font.
  2. Open the user installed font in Font Book.
  3. Move the mouse on the desired icon. You should get a title saying unicode value on hover.




回答2:


Edited answer (April 29th, 2015)

@al404it commented: "I know how to write the CSS part. I don't know how to get, from a customized font, the corresponding code to use in content: "xxxxx";"


Answer

Option 1)
Font Viewer, OR similar font viewer software
This is the easiest option.

  1. Install the FontViewer software
  2. Get the font's icon codes from the character map
  3. Use any online code converter, like Rishida Unicode Code Converter, to get the escaped CSS code

If this doesn't work for you...

Option 2)
Use the icomoon app

  1. Sign up AND create a new project
  2. In that project, import your font files (Top left button called "+ Import Icons")
  3. Under Fonts (Bottom right option), you'll see the list of all your icons and respective codes.

This should work for sure.


Original answer

@font-face {
    font-family: icons;
    src: url(MyFont.ttf); /* Replace with thatever your font file is */
}
.font-icon-pencil:before {
    font-family: icons, sans-serif;;
    content: "\e038";
}



回答3:


https://fontdrop.info : Very useful website where you can see all the unicode coed at once




回答4:


This question is pretty old, but I think I have, the article you needed in that time:

https://css-tricks.com/snippets/css/using-font-face/

Good luck :)



来源:https://stackoverflow.com/questions/27247145/get-the-unicode-icon-value-from-a-custom-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!