Special Characters in Cocos2D-X CCLabelTTF - special-characters

Hi I want to create CCLabelTTF with a string that contains special characters here is some example
CCLabelTTF* pLabelDuracion = CCLabelTTF::create("Duración de Periodo", "Arial", 20,CCSize(),kCCTextAlignmentLeft);
or
CCLabelTTF* pLabelPsswd = CCLabelTTF::create("Contraseña", "Arial", 20,CCSize(),kCCTextAlignmentLeft);
Please show me how to display this characters in my app ("ñ","´",etc)
I'm coding in visual studio 2010

change your cpp file encoding to UTF in visual studio

Related

Unicode for hindi printing on Zebra ZDR series printer

I am trying to print Unicode (for Hindi printing) using ZPL on Zebra printer ZDR500R. I am sending unicode file through 'Send file' in 'Tools' properties of Zebra printer. I have used various fonts like 'NT20WGL4.FNT', 'NK20WGL4.FNT', 'MONOBD15.FNT', H24.FNT', 'H12.FNT' etc. But none of them worked to print Hindi.
I am using following code for printing.
----------------------------------------------
^XA
^LH100,150
^CWT,E:MONOBD1524.FNT
^CFT,30,30
^CI28
^FT0,0^FH^FDTesting 1 2 3^FS
^FT0,50^FH^FD_905_924_93E_930_93F^FS
^FT0,100^B3^FDAAA001^FS
^XZ
-------------------------------------------
Here 905, 924, 93E, 930, 93F are unicode for hindi characters.
Plz help , how can i print Hindi characters of Unicode? Which Zebra font (.FNT) should i use?
Thanks & Regards.
The fonts you mentioned may not have the Hindi characters in them. Convert a TrueType font that has them (e.g., Mangal) to a Zebra FNT. The Zebra setup utility should be able to convert a TTF to an FNT for you.
Mangal comes with Windows. If you're not running Windows, you can find free Devanagari fonts lots of places online.

How to display Unicode string in with Lua in Cocos Code Ide

I'm using Cocos Code IDE to create a simple project with Lua.
main.lua was saved in UTF-8 Without BOM and contains the following snippet:
local label1 = cc.Label:createWithTTF("長い","fonts/Marker Felt.ttf",32);
local label2 = cc.Label:createWithTTF("LONG","fonts/Marker Felt.ttf",32);
local label3 = cc.Label:createWithTTF("rất dài","fonts/Marker Felt.ttf",32);
label1 was an Japanese string which was rendered correctly, as was label2 which was an ANSI string. however, label3 wasn't rendered correctly. In fact, it was rendered like "rt dài".
I had tried to use other Unicode fonts which clearly has that character. Still, I couldn't get those character rendered correctly. What have I done wrong?
I have the same issue, and i have solved.
I figure out that, the font file Marker Felt.tff include in cocos project is not unicode version. So after a while, i have found the unicode version of Marker Felt font in my Mac PC in: System/Library/Fonts/MarkerFelt.ttc
MarkerFelt Unicode Image

Issue in displaying Unicoded native language characters through MFC in Windows XP

I'm trying to display Unicode Bengali, a native language of India through a MFC application as below:
CFont *m_pFontSmallBN = new CFont();
m_pFontSmallBN->CreateFont(34,0,0,0,600,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,
_T("Ekushey Lalsalu")); //"Ekushey Lalsalu" is the Bengali Font name here.
CStatic m_msg_bn;
m_msg_bn.SetFont(m_pFontSmallBN,TRUE);
m_msg_bn.SetWindowText(_T("TEXT IN NATIVE LANGUAGE")); //TEXT is typed with the Font
While I'm running the app in Windows vista it can display the text perfectly; but in Windows XP it cannot display unicode characters properly. Compound alphabets (framed with multiple unicode characters) of the bengali language are being displayed as separate characters. I ensured that both Windows Vista and XP have the Font installed and character set of my MFC project setting is Unicode.
Could anybody please help me to find out the issue in Windows XP environment ?
Choosing a font in Windows is tricky. You'd expect the font name to take precedence over all other font characteristics, but that's not always the case. To be sure you're getting the proper font you should make sure all the parameters to CreateFont match the font you want. This article, though old, details the font mapping process: Windows Font Mapping.
Here's a small program that puts up a font selection dialog and dumps the parameters that you can pass to CreateFont to guarantee that you're getting the font you want.
#include <Windows.h>
#include <stdio.h>
int wmain(int argc, wchar_t* argv[])
{
LOGFONT lf = {};
CHOOSEFONT cf = {sizeof(CHOOSEFONT)};
cf.lpLogFont = &lf;
cf.Flags = CF_BOTH | CF_FORCEFONTEXIST;
if (ChooseFont(&cf))
{
wprintf(L"%d,%d,%d,%d,%d,", lf.lfHeight, lf.lfWidth, lf.lfEscapement, lf.lfOrientation, lf.lfWeight);
wprintf(L"%d,%d,%d,%d,%d,", lf.lfItalic, lf.lfUnderline, lf.lfStrikeOut, lf.lfCharSet, lf.lfOutPrecision);
wprintf(L"%d,%d,%d,", lf.lfClipPrecision, lf.lfQuality, lf.lfPitchAndFamily);
wprintf(L"_T(\"%s\")\n", lf.lfFaceName);
}
return 0;
}
#Mark I could not add my comment using "add a comment" link; therefore, I'm adding it here. Even in XP environment the program displays same values for the Font properties. Another thing is that using notepad of the same system, I see the same improper display. It can display bengali font but display is improper for compound alphabet (consonant conjunct or consonant attached with a diacritic form of a vowel) of bengali language. This is probably due to XP doesn't have in-built support for complex text for native scripts like bengali by default. Windows from Vista and onward have this complex text support enabled by default; therefore just installing a native unicode font enables us to view native script properly.

Displaying 'special' characters from other encodings in UILabel or similar

I'd like to be able to simulate a terminal on my iPhone to play games like Nethack using the primitive graphics I enjoyed on a real DEC terminal. Nethack allows selection of DECgraphics for vt-compatible terminals or IBMGraphics for codepage 437 support.
I know that these special graphics characters are generated by strings sent to the terminal (vt100.net has a huge amount of information including the terminal manuals and test programs). I can receive and interpret those strings but I need to be able to reproduce and display those characters in a UIView.
It looks like kCFStringEncodingMacVT100 and kCFStringEncodingDOSLatinUS are the keys to the puzzle. Here's a bit of partial code showing what I tried to do to get "special characters" glyphs onto a UILabel:
UInt8 c = some value...
NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingMacVT100);
NSData *charData = [NSData dataWithBytes:&c length:1];
NSString *charString = [[NSString alloc] initWithData:charData encoding:stringEncoding];
label.font = [UIFont fontWithName:#"Courier New" size:20.f];
label.text = charString;
I tried values of c from 0 to 255. I can display characters from space to '~' with all the expected stuff in between using this code but there are no corners or other line characters at all. When there is no character to display, charString is nil.
Now I'm pretty sure the Courier New TTF has these characters - on my Mac I can play Nethack with the terminal font set to Courier New and I can set DECgraphics and the display is OK.
So the questions are:
what's wrong with the code above?
what freely available monospaced truetype fonts are there supporting the DEC special characters and/or codepage 437?
how can you test a TTF once you have it to be sure those glyphs are there?
how can you display these glyphs in a UILabel or similar?
(I don't want to use any of the graphical tilesets available, I don't like them. I know there are at least two Nethacks available for free already but none have the straightforward keyboard interface I want, I find the popup a window for everything approach really slow and frustrating. I know it's not an easy project. And I might want to to Angband one day.)
Most (all?) of the glyphs in CP437 have corresponding code points in the Unicode standard, as detailed on this Wikipedia article.
For example, to display a club, you can do the following. It works with the default UILabel font:
UniChar club = 0x2663;
NSString *clubString = [NSString stringWithCharacters:&club length:1];
[label setText:clubString];

How to draw Thai text to PDF file by using libharu library

i am using free pdf library libharu to generate PDF file,
but i have a encoding problem, i can not draw Thai lanugage text on PDF file,
all the text shows "???.."
Somebody know how to fix it?
Thanks
I have succeeded in rendering hieroglyphic texts (not Thai, but Chinese and Japanese) using libharu. First of all, I used Unicode mode, please refer to HPDF_UseUTFEncodings() function documentation.
For C language, here is a sequence of libharu API calls needed to overcome your trouble:
HPDF_UseUTFEncodings(docHandle);
HPDF_SetCurrentEncoder(docHandle, "UTF-8");
Here docHandle is a valid HPDF_Doc object.
Next part is proper work with UTF fonts:
const char * libFontName = HPDF_LoadTTFontFromFile(docHandle, fontFileName.c_str(), font_embed::EmbedFonts);
HPDF_Font font = HPDF_GetFont(docHandle, libFontName, "UTF-8");
After these calls you may render unicode texts containing Thai characters. Also note about embedding flag (3rd param of LoadTTFontFromFile) - your PDF file may be unreadable due to external font references. If you are not crazy with output PDF size, you may just embed fonts.
I've tested couple of Thai .ttf fonts found in Google and they were rendered OK. Also (it may be important, but I'm not sure) I'm using fork of libharu https://github.com/kdeforche/libharu which is now merged into master branch.
When you write text to the PDF, use the correct font and encoding. In the libharu documentation you have all the possibilities: https://github.com/libharu/libharu/wiki/Fonts
In your case, you must use the ISO8859-11 Thai, TIS 620-2569 character set
An example (in spanish):
HPDF_Font fontEn = HPDF_GetFont(pdf, "Helvetica-Bold", "ISO8859-2");
HPDF_Page_TextOut(page1, 50.00, 750.00, [#"Código para correcta codificación en libharu" cStringUsingEncoding:NSISOLatin1StringEncoding]);