Skip to content

Crash in SharpFont when trying to read the horizontal header of a TrueType font #161

@wldevries

Description

@wldevries

Crash in Face when trying to read the horizontal header of a TrueType font.

var library = new Library();
Face face = new Face(library, "c:/windows/fonts/arial.ttf");
face.GetSfntTable(SfntTag.HorizontalHeader);

This results in the following error:

System.TypeLoadException: Cannot marshal field 'Reserved' of type 'SharpFont.TrueType.lnternal.HoriHeaderRec': This type can only be marshaled in restricted ways.
at System.Runtime.lnteropServices.Marshal.PtrToStructureHelper(lntPtr ptr, Object structure, Boolean allowValueClasses)
at System.Runtime.lnteropServices.Marshal.PtrToStructure(lntPtr ptr, Type structureType)
at SharpFont.PlnvokeHelper.PtrToStructure[T](lntPtr reference)
at SharpFont.TrueType.HoriHeader.set_Reference(lntPtr value)
at SharpFont.TrueType.HoriHeader..ctor(lntPtr reference)
at SharpFont.Face.GetSfntTable(SfntTag tag)

I'm trying to get to get access to the LineGap of a font which seems to be present only in the vertical and horizontal headers. The vertical header loads fine.

The SpaceWizards.SharpFont package combined with SharpFont.Dependencies loads the horizontal header just fine. Robmaister/SharpFont#140

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions