Merge pull request #1472 from nixbody/cffi-unicode-fixes

UNICODE fixes (clipboard, window title, file dialogs, paths, font glyphs, ...)
This commit is contained in:
tobil4sk
2024-07-07 23:10:43 +01:00
committed by GitHub
3 changed files with 116 additions and 107 deletions

View File

@@ -188,10 +188,11 @@ class Font
public function getGlyphs(characters:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^`'\"/\\&*()[]{}<>|:;_-+=?,. "):Array<Glyph>
{
#if (lime_cffi && !macro)
var glyphs:Dynamic = NativeCFFI.lime_font_get_glyph_indices(src, characters);
// lime_font_get_glyph_indices returns Array<Int>
// cast it to Array<Glyph> instead (Glyph is an abstract)
return cast glyphs;
#if hl
return [for (index in NativeCFFI.lime_font_get_glyph_indices(src, characters)) new Glyph(index)];
#else
return NativeCFFI.lime_font_get_glyph_indices(src, characters);
#end
#else
return null;
#end

View File

@@ -113,10 +113,7 @@ class FileDialog
#if (!macro && lime_cffi)
#if hl
var bytes = NativeCFFI.lime_file_dialog_open_file(title, filter, defaultPath);
if (bytes != null)
{
path = @:privateAccess String.fromUTF8(cast bytes);
}
path = bytes != null ? @:privateAccess String.fromUTF8(cast bytes) : null;
#else
path = NativeCFFI.lime_file_dialog_open_file(title, filter, defaultPath);
#end
@@ -157,10 +154,7 @@ class FileDialog
#if (!macro && lime_cffi)
#if hl
var bytes = NativeCFFI.lime_file_dialog_open_directory(title, filter, defaultPath);
if (bytes != null)
{
path = @:privateAccess String.fromUTF8(cast bytes);
}
path = bytes != null ? @:privateAccess String.fromUTF8(cast bytes) : null;
#else
path = NativeCFFI.lime_file_dialog_open_directory(title, filter, defaultPath);
#end
@@ -331,7 +325,7 @@ class FileDialog
#if (!macro && lime_cffi)
#if hl
var bytes = NativeCFFI.lime_file_dialog_save_file(title, filter, defaultPath);
path = @:privateAccess String.fromUTF8(cast bytes);
path = bytes != null ? @:privateAccess String.fromUTF8(cast bytes) : null;
#else
path = NativeCFFI.lime_file_dialog_save_file(title, filter, defaultPath);
#end