Difference between revisions of "Cyrillic"

From uGFX Wiki
Jump to: navigation, search
(Step 2: Convert the font)
Line 22: Line 22:
 
  |A font usually provides you with a lot more characters than what you're going to need. The Character filter helps you to exclude the not needed ones, such as special characters etc. [http://en.wikipedia.org/wiki/Basic_multilingual_plane#Basic_Multilingual_Plane This table] will help you to find out what character range will match your needs.
 
  |A font usually provides you with a lot more characters than what you're going to need. The Character filter helps you to exclude the not needed ones, such as special characters etc. [http://en.wikipedia.org/wiki/Basic_multilingual_plane#Basic_Multilingual_Plane This table] will help you to find out what character range will match your needs.
 
For cyrillic fonts, you may want to choose the option "custom range" and set it to '''400''' to '''4ff'''.
 
For cyrillic fonts, you may want to choose the option "custom range" and set it to '''400''' to '''4ff'''.
 +
|}
 
After applying all these settings, simply click on the Get .c File button. Please do only hit this button once. It may take up to one minute to convert a font. A download of a .c file will be provided after the converting is finished.
 
After applying all these settings, simply click on the Get .c File button. Please do only hit this button once. It may take up to one minute to convert a font. A download of a .c file will be provided after the converting is finished.
 
 
  
 
== Step 3: Implement the font ==
 
== Step 3: Implement the font ==

Revision as of 01:02, 3 July 2014

µGFX is currently not shipped with any built-in cyrillic fonts. However, it's very easy to add one yourself. The following guide will lead you through the process.

Step 1: Acquire a font

There are literally thousands of free-to-use cyrillic fonts you can get on the internet. This website is just one example of many. You can use any font that you'll get in a *.tff format.

Step 2: Convert the font

The next step is to convert the font into a format that can be understood by the µGFX decoder. This can be done very easily using our online converter. Once you have uploaded the font, you can set several options:

Option Description
Font size Choose the size in which you'd like to have your font. The size is the height in pixels.
Anti-Aliasing Enable or disable font anti-aliasing.
Output Format Choose wether you want your font RLE encoded or as a raw bitmap. Where RLE will reduce the size of the resulting font drastically, it will take up some more to render it.
Character filter A font usually provides you with a lot more characters than what you're going to need. The Character filter helps you to exclude the not needed ones, such as special characters etc. This table will help you to find out what character range will match your needs.

For cyrillic fonts, you may want to choose the option "custom range" and set it to 400 to 4ff.

After applying all these settings, simply click on the Get .c File button. Please do only hit this button once. It may take up to one minute to convert a font. A download of a .c file will be provided after the converting is finished.

Step 3: Implement the font

Place the downloaded c file inside your project directory and name it userfonts.h. In your gfxconf.h, enable the following settings:

  1. define GDISP_NEED_TEXT TRUE
  2. define GDISP_NEED_UTF8 TRUE
  3. define GDISP_NEED_ANTIALIAS TRUE // if wanted
  4. define GDISP_NEED_TEXT_KERNING TRUE // if wanted
  5. define GDISP_INCLUDE_USER_FONTS TRUE


Step 4: Use the font

To successfully display a unicode font, you have to set your editors encoding to UTF-8. You can now open and use the font as any other by using gdispOpenFont():

font_t myfont = gdispOpenFont("The name of the font 12"); Where the given argument is the name of the font. If you don't know it, you can find it in your userfonts.h file at the very bottom. It's the first member of the mf_rlefont_s struct.