September 28, 2020, 02:20:29 AM

Author Topic: How can i use greek font?  (Read 315 times)

Offline george

  • Jr. Member
  • **
  • Posts: 10
How can i use greek font?
« on: August 30, 2020, 08:56:50 AM »
Hello guys , i want to write Greek texts in max2d , but i don't know how .I want to create a text game .Thanks for you time .

e.g.

Graphics 600,600

Repeat

   Cls
   DrawText ("Γεια σου κόσμε , πάτησε το πλήκτρο 'esc' για να βγεις ",300,300) ' it shows only the 'esc' the Greek texts are invisible.
   Flip
   
Until KeyHit(key_escape)

Offline GfK

  • Full Member
  • ***
  • Posts: 145
Re: How can i use greek font?
« Reply #1 on: August 30, 2020, 10:41:39 AM »
You need to use a font that includes Greek glyphs.  Most don't.
Intel I9-9900K 3.6-5.0GHz | GeForce RTX2070 8GB | 32GB RAM | 500GB NVMe M.2 SSD | 1TB HDD | Windows 10 x64.
MSI Apache Pro | I7-7700HQ | GeForce GTX1060 3GB | 8GB RAM | 128GB SSD | 1TB HDD | Windows 10 x64.

Offline george

  • Jr. Member
  • **
  • Posts: 10
Re: How can i use greek font?
« Reply #2 on: August 30, 2020, 11:42:44 AM »
Is there any example for how can i do this ?

Offline Derron

  • Hero Member
  • *****
  • Posts: 3180
Re: How can i use greek font?
« Reply #3 on: August 30, 2020, 11:51:28 AM »
local font:TImagefont = LoadImageFont("myfont.ttf")
SetImagefont(font)

From then on it used this font until another one is set.

https://blitzmax.org/docs/en/api/brl/brl.max2d/#function-loadimagefonttimagefont-urlobjectsizestylesmoothfont-
https://blitzmax.org/docs/en/api/brl/brl.max2d/#function-setimagefont-fonttimagefont-


bye
Ron

Offline george

  • Jr. Member
  • **
  • Posts: 10
Re: How can i use greek font?
« Reply #4 on: August 30, 2020, 03:05:41 PM »
I found a .tff here http://www.fontsaddict.com/font/korinthus-italic.html

Graphics 600,600
Local font:TImagefont = LoadImageFont("KORINTHI.ttf",2,style=SMOOTHFONT)
SetImageFont(font)
Repeat

   Cls
   DrawText ("Γεια σου κόσμε , πάτησε το πλήκτρο 'esc' για να βγεις ",300,300)
   Flip
   
Until KeyHit(key_escape)


When i am building it , i'm taking an error" compile error identifier 'style' not found ."

Offline george

  • Jr. Member
  • **
  • Posts: 10
Re: How can i use greek font?
« Reply #5 on: August 30, 2020, 03:07:30 PM »
Ok , it's works, but without tones  . For some reason i need to write greeklish  to works  . Thanks for help  .

Graphics 600,600
Local font:TImagefont = LoadImageFont("KORINTHI.ttf",20,SMOOTHFONT )

Repeat

   Cls
   SetImageFont(font)
   DrawText ("Geia sou kosme , pathse to plhktro ",10,300)
   SetImageFont(Null)
   DrawText("esc",330,310)
   SetImageFont(font)
   DrawText("gia na  bgeiq ",360,300)
   Flip
   
Until KeyHit(key_escape)

Offline Derron

  • Hero Member
  • *****
  • Posts: 3180
Re: How can i use greek font?
« Reply #6 on: August 30, 2020, 04:35:00 PM »
Code: BlitzMax
  1. SuperStrict
  2.  
  3. Graphics 600,600
  4. Local txtFile:String = LoadText("utf8::text.txt")
  5. local txtRaw:String = "Γεια σου κόσμε , πάτησε το πλήκτρο 'esc' για να βγεις"
  6.  
  7. Local font1:TImagefont = LoadImageFont("KORINTHI.TTF",22, ITALICFONT)
  8. 'fonts https://fonts2u.com/attikau.font
  9. Local font2:TImagefont = LoadImageFont("AttikaU.ttf",22, ITALICFONT)
  10.  
  11. SetBlend AlphaBlend
  12. Repeat
  13.  
  14.    Cls
  15.  
  16.         'korinthi
  17.    SetImageFont(font1)
  18.    DrawText ("ASCI Hello World",10,50)
  19.    DrawText (txtRaw,10,100)
  20.    DrawText (txtFile,10,150)
  21.    DrawText (Chr(69)+Chr(70)+Chr(71)+Chr(72),10,200)
  22.    
  23.    DrawLine (0, 300, graphicsWidth(), 300)
  24.  
  25.         'attika unicode
  26.    SetImageFont(font2)
  27.    DrawText ("ASCI Hello World",10,350)
  28.    DrawText (txtRaw,10,400)
  29.    DrawText (txtFile,10,450)
  30.    DrawText (Chr(69)+Chr(70)+Chr(71)+Chr(72),10,500)
  31.  
  32.    Flip
  33.    
  34. Until KeyHit(key_escape)
  35.  
  36.  

Your font does display characters - but maybe for greek code page encoding, not unicode. ISO-8859-7 ... maybe.


So I used a font which contains the unicode characters.


result:



As you see, the one line which adds "normal character codes" (Chr(69), Chr(70) etc - E ...F ...G ...H) does display something in the one line in "Greek" ... but in the unicode font, EFGH stay EFGH while the "greek" stuff can still be used.


So in other words: your font draws "A,B,C ..." as something "greek" and your text could be displayed as "latin". Just imagine having a font which draws a "laughing emoticon" instead of "A" ... if you wrote then "AAA" in your editor (using your latin alphabet) and render it with "your font" you will get ... laughing emoticons.
Remember Windows "wingdings.ttf" or "symbols.fnt" ? They do this.

But if you really wrote "unicode" then you would not write "A" but ... some unique char code. And your greek text is doing this - hence you need a unicode font.



bye
Ron

Offline george

  • Jr. Member
  • **
  • Posts: 10
Re: How can i use greek font?
« Reply #7 on: August 30, 2020, 04:59:17 PM »
 :) Thank you very much Derron , This is really very interesting . I will study it .

Offline makis

  • Jr. Member
  • **
  • Posts: 13
Re: How can i use greek font?
« Reply #8 on: August 30, 2020, 06:01:25 PM »
George are you Greek?

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2780
  • elgol 2021
Re: How can i use greek font?
« Reply #9 on: August 30, 2020, 07:45:55 PM »
Yammas!
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Catalina, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry Pi Zero and pi 4

Offline george

  • Jr. Member
  • **
  • Posts: 10
Re: How can i use greek font?
« Reply #10 on: August 31, 2020, 04:18:49 PM »
Yes makis i am , are you too ? Steve Elliott  Yammas!  ;D

Offline makis

  • Jr. Member
  • **
  • Posts: 13
Re: How can i use greek font?
« Reply #11 on: August 31, 2020, 05:12:36 PM »
Where r u from?

Offline GfK

  • Full Member
  • ***
  • Posts: 145
Re: How can i use greek font?
« Reply #12 on: September 01, 2020, 11:11:36 AM »
I've got through entire holidays in the Greek islands and the Greek end of Cyprus, using only 'yamas'!
Intel I9-9900K 3.6-5.0GHz | GeForce RTX2070 8GB | 32GB RAM | 500GB NVMe M.2 SSD | 1TB HDD | Windows 10 x64.
MSI Apache Pro | I7-7700HQ | GeForce GTX1060 3GB | 8GB RAM | 128GB SSD | 1TB HDD | Windows 10 x64.

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 2780
  • elgol 2021
Re: How can i use greek font?
« Reply #13 on: September 01, 2020, 11:33:45 AM »
lol we go to Greece every year (apart from this year for obvious reasons).  It would be great to speak proper sentences in Greek but the language seems soo difficult to learn!
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
MacOS Catalina, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB
Linux Mint 19.3, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb)
Raspberry Pi Zero and pi 4

Offline GfK

  • Full Member
  • ***
  • Posts: 145
Re: How can i use greek font?
« Reply #14 on: September 01, 2020, 12:16:05 PM »
It's all Greek, to me. :D
Intel I9-9900K 3.6-5.0GHz | GeForce RTX2070 8GB | 32GB RAM | 500GB NVMe M.2 SSD | 1TB HDD | Windows 10 x64.
MSI Apache Pro | I7-7700HQ | GeForce GTX1060 3GB | 8GB RAM | 128GB SSD | 1TB HDD | Windows 10 x64.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal