Robmaister / SharpFont

Cross-platform FreeType bindings for .NET - Need maintainer
Other
294 stars 107 forks source link

Fixed StrfName's String property returning unicode strings of wrong length #123

Closed rlokc closed 6 years ago

rlokc commented 6 years ago

StrfName's String property uses Marshal.PtrToStringUni to cast the recieved string to a C# string, passing it the string_len from the StrfName structure of FreeType. According to FreeType's documentation, string_len represents the length of string in bytes, while PtrToStringUni's len parameter recieves number of Unicode characters to copy, each being 2 bytes. This results in StrfName's Strings being longer than they really are.

Tested this change on some Windows embedded fonts in Win7, and the fields now get fetched correctly.

Robmaister commented 6 years ago

Awesome, thanks!