This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

grlib and cyrillic



Hi all! I need help with grlib and cyrillic(russian) chars.

I use latest grlib version.

I'l generate font as desribed in post http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/57929/496871.aspx#496871

my native codepage is CODEPAGE_WIN1251 so my code looks like:

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>

#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_hibernate.h"

#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"

#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "driverlib/timer.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/fpu.h"
#include "grlib/grlib.h"

#include "./buttons.h"
#include "hardware/ili9341/fonts/fonts.h"
#include "hardware/ili9341/ili9341.h"
//#include "hardware/ili9325/ili9325.h"
//#include "hardware/SPI/SPI.h"

tCodePointMap g_psCodePointMap_language[] =
{
{ CODEPAGE_WIN1251, CODEPAGE_UNICODE, GrMapWIN1251_Unicode }, };

#define NUM_CODEPOINT_MAPS (sizeof(g_psCodePointMap_language) / sizeof(tCodePointMap))

tGrLibDefaults g_sGrLibDefaultlanguage =
{ GrDefaultStringRenderer, g_psCodePointMap_language, CODEPAGE_WIN1251,
		NUM_CODEPOINT_MAPS, 0 };

int main(void)
{
	SysCtlClockSet(
			SYSCTL_USE_PLL | SYSCTL_SYSDIV_2_5 | SYSCTL_XTAL_16MHZ
					| SYSCTL_OSC_MAIN);
	FPULazyStackingEnable();

	InitDisplay();

	tContext g_sContext;
	GrContextInit(&g_sContext, &g_sILI9341);

	GrLibInit(&g_sGrLibDefaultlanguage);

	tRectangle sRect;
	sRect.i16XMin = 0;
	sRect.i16YMin = 0;
	sRect.i16XMax = 239;
	sRect.i16YMax = 319;
	GrContextForegroundSet(&g_sContext, ClrDarkBlue);
	GrRectFill(&g_sContext, &sRect);

	GrContextForegroundSet(&g_sContext, ClrWhite);
	GrRectDraw(&g_sContext, &sRect);

//    GrStringCodepageSet(&g_sContext, CODEPAGE_UTF_8);
	GrContextFontSet(&g_sContext, g_psFontWArial24pt);
	GrStringDraw(&g_sContext, "hello привет!", -1, 50, 50, 0);

	while (1)
	{
	}
}



but it doesnt work :(

  • There are a couple of things that could be going wrong here but I can't tell which it is based on the information you've provided. Either the font you are using (g_psFontWArial24pt) doesn't contain the Cyrillic characters (normally, a dot is shown if a character can't be found in the font) or the text you are passing to GrStringDraw is being encoded using something other than Windows 1251 codepage.

    Given the number of dots that I see on your screen, I suspect you are actually encoding the text using UTF-8 (you are trying to show 6 characters but I see something like 12 dots. UTF-8 will use 12 bytes to encode the 6 Cyrillic characters so that's a hint). Either make sure that your editor is actually using Windows 1251 or change all 1251 references to UTF_8 and see if this helps (I see you seem to have tried that already. Did you also change g_psCodepointMap_language too? It doesn't have a UTF-8 entry so using GrStringCodepageSet to UTF-8 won't work properly because the system won't be able to map UTF-8 text to the UNICODE index in the font).