Can't write Unicode text with FreeType fonts
Original Reporter info from Mantis: ddemarco
-
Reporter name: Diego De Marco
Original Reporter info from Mantis: ddemarco
- Reporter name: Diego De Marco
Description:
TFontManager as declared in freetype.pp is unable to handle Unicode or UTF-8 encoded characters. This is because method MakeString counts the individual single-byte characters, and therefore prints all characters above $7f incorrectly.
Steps to reproduce:
Create a TFpmemoryImage, a FreeTypeFont, and use them to print any text containing characters above $80 (either UTF-8 encoded, or using a UnicodeString). The printed text will look incorrect.
Additional information:
From freetype.pp, lines 582 and following:
CurFont := GetFont(FontID);
if (Angle = 0) or // no angle asked, or can't work with angles (not scalable)
((CurFont.Font^.face_flags and FT_FACE_FLAG_SCALABLE)=0) then
result := MakeString (FontID, Text, Size)
else
begin
InitMakeString (FontID, Size);
c := length(text); <------ Not really. This would be valid
only if Text was a UnicodeString.
I believe the text should first be converted to a UnicodeString, and then use each character in the Unicode String to obtain the respective glyph.
Mantis conversion info:
- Mantis ID: 24448
- OS: Ubuntu
- OS Build: 12.10
- Platform: Linux
- Version: 2.6.2
- Fixed in version: 3.1.1
- Fixed in revision: 36402 (#0fe12f20)
- Target version: 3.0.4