Skip to content

Commit

Permalink
Fixed SfntName.String issues. Ref #96
Browse files Browse the repository at this point in the history
  • Loading branch information
Robmaister committed Dec 7, 2016
1 parent 07a8e76 commit 3a5b821
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Source/SharpFontShared/TrueType/SfntName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,43 @@ public ushort NameId
}
}

/// <summary>
/// This property returns <see cref="StringPtr"/> interpreted as UTF-16.
/// </summary>
public string String
{
get
{
//TODO it may be possible to consolidate all of these properties
//if the strings follow some sane structure. Otherwise, leave
//them or add more overloads for common encodings like UTF-8.
return Marshal.PtrToStringUni(rec.@string, (int)rec.string_len);
}
}

/// <summary>
/// This property returns <see cref="StringPtr"/> interpreted as ANSI.
/// </summary>
public string StringAnsi
{
get
{
return Marshal.PtrToStringAnsi(rec.@string, (int)rec.string_len);
}
}

/// <summary><para>
/// Gets the ‘name’ string. Note that its format differs depending on the (platform,encoding) pair. It can be a
/// Pascal String, a UTF-16 one, etc.
/// </para><para>
/// Generally speaking, the string is not zero-terminated. Please refer to the TrueType specification for
/// details.
/// </para></summary>
public string String
public IntPtr StringPtr
{
get
{
//TODO look at TrueType specs, interpret string based on platform, encoding pair.
//return string.Empty;
return Marshal.PtrToStringUni(rec.@string, (int)rec.string_len);
return rec.@string;
}
}

Expand Down

0 comments on commit 3a5b821

Please sign in to comment.