Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How i can see Greek text?  (Read 9299 times)

0 Members and 1 Guest are viewing this topic.

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« on: February 13, 2010, 09:07:23 am »
Hello. In code i have Greek language, arial have Greeks, but i can not see the real text.
How i can do that?
Thank's
Jim

Code: [Select]
   if (!MyFont.LoadFromFile("arial.ttf", 50))
        return EXIT_FAILURE;
// Create a graphical string
    sf::String Hello;
    Hello.SetText("Hello !\n γεια χαρά?");
    Hello.SetFont(MyFont);
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    Hello.SetRotation(15.f);
    Hello.SetSize(50.f);

Lokk

  • Full Member
  • ***
  • Posts: 228
    • View Profile
    • http://betadineproject.wordpress.com/
How i can see Greek text?
« Reply #1 on: February 13, 2010, 10:46:23 am »
Code: [Select]
Hello.SetText(L"Hello !\n γεια χαρά?"); ?

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #2 on: February 15, 2010, 12:20:15 pm »
Sorry, it dont works.

compiller says
.... converting to execution character set: Illegal byte sequence|
||=== Build finished: 1 errors, 0 warnings ===|

CodeBlocks, win XP, MinGW.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How i can see Greek text?
« Reply #3 on: February 15, 2010, 02:03:45 pm »
You should never write string literals other than ASCII into your code, the different encodings involved are very hard to control and always create a lot of troubles.
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #4 on: February 15, 2010, 07:34:14 pm »
Ok only ASCII chars in code. But if someone want's to have unicode text into the code how can it does that?
One method is to open a unicode file, convert strings in wstrings and final works with it.
But if want to have embending wstrings, without open an external file, what it does?  :?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How i can see Greek text?
« Reply #5 on: February 15, 2010, 07:58:21 pm »
You can have wide strings literals
Code: [Select]
std::wstring str = L"blah";
But it still depends on the encoding used by your code editor, and how your platform implements wchar_t.

The safest way is to use the unicode escape sequence to type codepoints directly (never remember the syntax, sorry -- something like "\u0015") but it's not very convenient.
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #6 on: February 15, 2010, 09:32:10 pm »
Thank's for reply. I am trying some methods, like resources, in utf enconding.
Jim

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #7 on: February 16, 2010, 02:56:45 pm »
I am trying this code. All characters are ok from \x21 until \xfe. But from \xff and more nothing. For example the \x3c2 character is as the \xc2.
I use SFML 1.5, how it can fix it?

Code: [Select]
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("arial.ttf", 50))
        return EXIT_FAILURE;
    sf::String Hello;
    std::string asd="123 Γεια χαρά, όλα καλά";
    std::wstring asd1=L"456 Γεια χαρά, όλα καλά";
    Hello.SetText("\xf1\xf2...\xfe\xff");
    Hello.SetFont(MyFont);
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    //Hello.SetRotation(15.f);
    Hello.SetSize(50.f);
    sf::Event Event;
    while (App.IsOpened())
    {
        while (App.GetEvent(Event))
        {
            if (Event.Type == sf::Event::Closed)
                App.Close();
            if (Event.Type == sf::Event::KeyPressed)
            {
                if (Event.Key.Code == sf::Key::Escape)
                {
                    App.Close();
                }
                if (Event.Key.Code == sf::Key::F1)
                {
                    sf::Image Screen = App.Capture();
                    Screen.SaveToFile("screenshot.jpg");
                }
            }
        }
        App.Clear(sf::Color(200, 0, 0));
       App.Draw(Hello);
        App.Display();
    }
    return EXIT_SUCCESS;
}

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #8 on: February 18, 2010, 07:37:09 am »
Maybe must implement my own chars in library, with SFML1.5, but in SFML 2.0 there is not sutch restriction. I have not try get.

src\SFML\Graphics\Font.cpp
----------------------------------

Code: [Select]
Uint32 Font::ourDefaultCharset[] =
{
    // Printable characters in ASCII range
    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
    0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
    0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E,

    // Printable characters in extended ASCII range
    0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0x2A, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
    0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
    0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
    0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
    0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
    0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE,

    // To make it a valid string
    0x00
};

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How i can see Greek text?
« Reply #9 on: February 18, 2010, 07:56:59 am »
Yes, in SFML 1 there is a limited character set, and it must contain all the glyphs that you draw.
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #10 on: February 19, 2010, 12:10:38 pm »
Compiling sfml2 take these libraries. The *.a put in C:\Program Files\CodeBlocks\MinGW\lib\ directory, and the *.dll to source project path, and in C:\Program Files\CodeBlocks\MinGW\include\ i put SFML directory.

Quote
libsfml-audio-d.a,libsfml-audio-s-d.a,libsfml-audio-s.a,libsfml-audio.a,libsfml-graphics-d.a,libsfml-graphics-s-d.a,libsfml-g,aphics-s.a,libsfml-graphics.a,libsfml-main-d.a,libsfml-network-d.a,libsfml-network-s-d.a,libsfml-network-s.a,libsfml-netwo,k.a,libsfml-system-d.a,libsfml-system-d.dll.a,libsfml-system-s-d.a,libsfml-system-s.a,libsfml-system.a,libsfml-window-d.a,l,bsfml-window-s-d.a,libsfml-window-s.a,libsfml-window.a
sfml-audio-d.dll,sfml-audio.dll,sfml-graphics-d.dll,sfml-graphics,dll,sfml-network-d.dll,sfml-network.dll,sfml-system-d.dll,sfml-system.dll,sfml-window-d.dll,sfml-window.dll


Linker options i have

Quote
-lsfml-graphics
-lsfml-window
-lsfml-system
-lsfml-audio


and defines SFML_DYNAMIC macro.

Runing the sample ...

Code: [Select]
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}


all are ok...

But in the next paradigm

Code: [Select]
int main()
{
// Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
// Load a font from a file
    sf::Font MyFont;
    if (!MyFont.LoadFromFile("arial.ttf", 50))
        return EXIT_FAILURE;
// Create a graphical string
    sf::String Hello;
    std::string asd="123 Γεια χαρά, όλα καλά";
    std::wstring asd1=L"456 Γεια χαρά, όλα καλά";
    Hello.SetText("\xf1\xf2...\xfe\xff  \x3c2");


compiller says in LoadFromFile....



Quote
C:\TMP\15\main.cpp||In function `int main()':|
C:\TMP\15\main.cpp|19|error: no matching function for call to `sf::Font::LoadFromFile(const char[10], int)'|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\SFML\Graphics\Font.hpp|92|note: candidates are: bool sf::Font::LoadFromFile(const std::string&)|
C:\TMP\15\main.cpp|25|error: 'class sf::String' has no member named 'SetText'|
C:\TMP\15\main.cpp|25|warning: hex escape sequence out of range|
C:\TMP\15\main.cpp|26|error: 'class sf::String' has no member named 'SetFont'|
C:\TMP\15\main.cpp|27|error: 'class sf::String' has no member named 'SetColor'|
C:\TMP\15\main.cpp|28|error: 'class sf::String' has no member named 'SetPosition'|
C:\TMP\15\main.cpp|30|error: 'class sf::String' has no member named 'SetSize'|
C:\TMP\15\main.cpp|52|error: 'class sf::RenderWindow' has no member named 'Capture'|
C:\TMP\15\main.cpp|59|error: no matching function for call to `sf::RenderWindow::Draw(sf::String&)'|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\SFML\Graphics\RenderTarget.hpp|70|note: candidates are: void sf::RenderTarget::Draw(const sf::Drawable&)|
C:\Program Files\CodeBlocks\MinGW\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\include\SFML\Graphics\RenderTarget.hpp|79|note:                 void sf::RenderTarget::Draw(const sf::Drawable&, const sf::Shader&)|
||=== Build finished: 8 errors, 1 warnings ===|

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How i can see Greek text?
« Reply #11 on: February 19, 2010, 12:11:53 pm »
A lot of things have changed in SFML 2 (and are not documented yet, except in my messages on the General forum).

sf::String is now sf::Text, and SetText is now SetString ;)
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #12 on: February 19, 2010, 12:13:45 pm »
Thank's
Ok. we waiting next docoumentation.
Jim

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How i can see Greek text?
« Reply #13 on: February 19, 2010, 12:24:59 pm »
Quote
Ok. we waiting next docoumentation.

It won't happen before a long time ;)
Laurent Gomila - SFML developer

dkaip

  • Newbie
  • *
  • Posts: 32
    • View Profile
How i can see Greek text?
« Reply #14 on: March 08, 2010, 06:53:28 pm »
Trying to see character \x271F  of my font, i compile SFML1.5, i imlement default char set with extension bellow...
Code: [Select]

Uint32 Font::ourDefaultCharset[] =
{
    // Printable characters in ASCII range
    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, ....
..........................

// extension
0x2710, 0x2711,

..................


Using these libraries nothing happent. I can not see the 0x2710 character, only the x34, that is 4 i can see...
Code: [Select]

    sf::Font A;
    if (!A.LoadFromFile("i2.ttf"))
        return EXIT_FAILURE;
    sf::String Text("\x271F \x34 ", A, 50);// the 4 i can see it ...




Any suggestion?

 

anything