I did a proof-of-concept online implementation of a traditional card game. To avoid having to actually draw pictures of the cards I used the corresponding Unicode characters (eg. U+1F0A1
相关问题
- UrlEncodeUnicode and browser navigation errors
- how to Enumerate local fonts in silverlight 4
- Scaling png font down
- GD error while try load font
- Unicode issue with makemessages --all Django 1.6.2
相关文章
- Why is `'↊'.isnumeric()` false?
- How to display unicode in SVG?
- UnicodeEncodeError when saving ImageField containi
- Loading custom font using JavaFX 8 and css
- Generating .afm from .ttf [closed]
- Vue Cli 3 Local fonts not loading
- Why is TextView showing the unicode right arrow (\
- C++ (Standard) Exceptions and Unicode
Yes, there is. This is how it works.
Creating the font
To avoid using giant fonts just to support a few special characters, you can create your own fonts with tools like the Icomoon App.
The Icomoon App allows you to do each of the following :
I used the Icomoon App to create the Emoji emoticon font as well as for creating custom icon fonts on a per project basis.
Using the font
To include an icon font in your CSS, you can include the following code :
To use an icon in your HTML, you can do each of the following :
If you want to opt for method 7, you'll need some additional CSS code. This CSS code would look like this :
Icon fonts like Iconic, Font Awesome or Glyphicons typically all use method 7. This, to avoid you having to copy-paste special characters from a cheat sheet or being forced to use HTML entities.
It is, however, a method that has several downsides. First of all, it requires support for the
:before
CSS selector and the use of an escape sequence for UNICODE characters. Neither IE6-7 nor certain versions of Webkit provide this support.Another downside is that you have to use a seperate HTML tag for each icon, with each tag corresponding to one character from the icon font. Displaying several icons within HTML tag is not possible with method 7, unlike with other methods.
Other methods have their own downsides, though. Methods 1, 3 and 5 require you to copy-paste the character from a cheat sheet or use means to put the character itself within your code. Your code editor may not be capable of displaying the character or it may display a different character from the one in your icon font if the icon font uses a non-standard mapping that character.
Methods 1, 3 and 5 also require that your browser uses the proper encoding to display the correct character. For UNICODE characters, this isn't as obvious as it is for ASCII characters. This should, however, be ensured by adding the meta-tag
<meta charset="utf-8" />
somewhere in thehead
of your HTML-document.Methods 2, 4 and 6 do not require you to copy-paste the character, however it makes your code less readable by humans and makes any changes to the code more prone to human error. Also, as you will need to look up the HTML-entity code for each of the icons you want to use or you'll need to memorize them. While the same obviously applies to the classes used in method 7 as well, those classes are much easier to memorize than an HTML entity code.
You can try to adapt the dejavu build script used to create dejavu-lgc. That, or edit it in fontforge directly.