Text() and non english characters

Archives Forums/Blitz3D Bug Reports/Text() and non english characters

Mr.Waterlily(Posted 2007) [#1]
Hi,

I was playing a little with the Text() command and discovered something wierd.
If I create a boundary on the right side with Viewport, and use a loaded font(Arial), and the textstring includes non-english characters, the clipping doesn´t quite work properly.
Sometimes it can´t print non-complete letters.

Is this a known bug? Or did I just "get lucky"? ;)


I posted this in the Programming forum first but it should probably be located here instead.

Use the left and right arrows to see the "disappearing letter" bug.
Graphics 350,180,32,2
SetBuffer BackBuffer()
font=LoadFont("Arial",14,False,False,False)
SetFont font
tx=40
Repeat
	If KeyHit(203) Then tx=tx-5	;left
	If KeyHit(205) Then tx=tx+5	;Right
	Viewport 44,36,205,40
	Color 0,0,200
	Rect 44,36,205,40,1
	Color 255,255,255
	Text tx,40,"Alittetextstringthatcontainssomeletterthatiså;äandöandalsosomeüandÅagainandafterthatsomstandardenlishcharacters"
	Text tx,52,"Alittetextstringthatcontainssomeletterthatisonlystandartenglishlettagainandafterthatsomstandardenlishcharacters"
	Viewport 0,0,GraphicsWidth(),GraphicsHeight()
	Flip
Until KeyHit(1)
FreeFont font
End


Is there anything that can be done about this? And still be able to use the Text command?


Bobysait(Posted 2012) [#2]
Got a problem with the text function on a similar (but different) behavior, I think the bug come from the same problem (in the bb internal sources)

when we create an image with stringwidth(txt$) as width, then we draw the text (txt$) inside, the last letter(s) are not drawn if the string contains some special caracters (but the rule seems really strange, because it only happens when the string contains some special chars and is terminated with a special chars)




for this problem, I had to make a little tweak to fix the code


whatever, I really can't point on what is going wrong here, so I came to the conclusion :

[b]there is a bug in the Text command

Last edited 2012


_PJ_(Posted 2012) [#3]
Am I missing something here?
I don't quite see what the bug is...

both programs (Bobysait's & Mr. Waterlily's) seem to work fine.


Yasha(Posted 2012) [#4]
I was under the impression that Text didn't work reliably with any non-ASCII characters, and that you have to use something like FastText for that.

I'm pretty sure B3D strings don't actually support Unicode (for a start, if they did half of what I use them for wouldn't work), so any results where they get printed correctly will probably be errors luckily working out the "right" way.


_PJ_(Posted 2012) [#5]
I think the 'problem' is not with Text, but when using commands such as Mid or Chr etc. on strings with UTF or Unicode encoding, you are specifying a single character. Blitz interprets the result as a single byte, even if it identifies the correct 'position' in a string, the value itself is still only recognised as (n And 255)


Bobysait(Posted 2012) [#6]
nope, the truth is ... somewhere else.



same code as above, exept it doesn't use the "chr" command. Same result.

Last edited 2012