Beispiel #1
0
        public void Shape(Buffer buffer, IReadOnlyList <Feature> features, IReadOnlyList <string> shapers)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            var featuresPtr = features == null || features.Count == 0 ? IntPtr.Zero : StructureArrayToPtr(features);
            var shapersPtr  = shapers == null || shapers.Count == 0 ? IntPtr.Zero : StructureArrayToPtr(shapers);

            HarfBuzzApi.hb_shape_full(
                Handle,
                buffer.Handle,
                featuresPtr,
                featuresPtr != IntPtr.Zero ? features.Count : 0,
                shapersPtr);

            if (featuresPtr != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(featuresPtr);
            }

            if (shapersPtr != IntPtr.Zero)
            {
                Marshal.FreeCoTaskMem(shapersPtr);
            }
        }
Beispiel #2
0
        public unsafe ReadOnlySpan <byte> AsSpan()
        {
            uint length;
            var  dataPtr = HarfBuzzApi.hb_blob_get_data(Handle, &length);

            return(new ReadOnlySpan <byte> (dataPtr, (int)length));
        }
 public bool TryGetPosition(OpenTypeMetricsTag metricsTag, out int position)
 {
     fixed(int *p = &position)
     {
         return(HarfBuzzApi.hb_ot_metrics_get_position(font.Handle, metricsTag, p));
     }
 }
Beispiel #4
0
        public unsafe Stream AsStream()
        {
            uint length;
            var  dataPtr = HarfBuzzApi.hb_blob_get_data(Handle, &length);

            return(new UnmanagedMemoryStream((byte *)dataPtr, length));
        }
Beispiel #5
0
 protected override void DisposeHandler()
 {
     if (Handle != IntPtr.Zero)
     {
         HarfBuzzApi.hb_unicode_funcs_destroy(Handle);
     }
 }
Beispiel #6
0
 public bool TryGetNominalGlyph(uint unicode, out uint glyph)
 {
     fixed(uint *g = &glyph)
     {
         return(HarfBuzzApi.hb_font_get_nominal_glyph(Handle, unicode, g));
     }
 }
Beispiel #7
0
 public bool TryGetGlyphExtents(uint glyph, out GlyphExtents extents)
 {
     fixed(GlyphExtents *e = &extents)
     {
         return(HarfBuzzApi.hb_font_get_glyph_extents(Handle, glyph, e));
     }
 }
Beispiel #8
0
 public bool TryCompose(uint a, uint b, out uint ab)
 {
     fixed(uint *abPtr = &ab)
     {
         return(HarfBuzzApi.hb_unicode_compose(Handle, a, b, abPtr));
     }
 }
Beispiel #9
0
 public bool TryGetGlyph(uint unicode, uint variationSelector, out uint glyph)
 {
     fixed(uint *g = &glyph)
     {
         return(HarfBuzzApi.hb_font_get_glyph(Handle, unicode, variationSelector, g));
     }
 }
Beispiel #10
0
        public FontExtents GetFontExtentsForDirection(Direction direction)
        {
            FontExtents extents;

            HarfBuzzApi.hb_font_get_extents_for_direction(Handle, direction, &extents);
            return(extents);
        }
Beispiel #11
0
 protected override void DisposeHandler()
 {
     if (Handle != IntPtr.Zero)
     {
         HarfBuzzApi.hb_font_destroy(Handle);
     }
 }
Beispiel #12
0
 public bool TryGetGlyphFromName(string name, out uint glyph)
 {
     fixed(uint *g = &glyph)
     {
         return(HarfBuzzApi.hb_font_get_glyph_from_name(Handle, name, name.Length, g));
     }
 }
Beispiel #13
0
 public bool TryGetVerticalFontExtents(out FontExtents extents)
 {
     fixed(FontExtents *e = &extents)
     {
         return(HarfBuzzApi.hb_font_get_v_extents(Handle, e));
     }
 }
Beispiel #14
0
 public Stream AsStream()
 {
     unsafe {
         var dataPtr = HarfBuzzApi.hb_blob_get_data(Handle, out var length);
         return(new UnmanagedMemoryStream(dataPtr, length));
     }
 }
Beispiel #15
0
 public bool TryGetVariationGlyph(uint unicode, out uint glyph)
 {
     fixed(uint *g = &glyph)
     {
         return(HarfBuzzApi.hb_font_get_variation_glyph(Handle, unicode, 0, g));
     }
 }
Beispiel #16
0
 public ReadOnlySpan <byte> AsSpan()
 {
     unsafe {
         var dataPtr = HarfBuzzApi.hb_blob_get_data(Handle, out var length);
         return(new ReadOnlySpan <byte> (dataPtr, length));
     }
 }
Beispiel #17
0
 public bool TryGetGlyphFromString(string s, out uint glyph)
 {
     fixed(uint *g = &glyph)
     {
         return(HarfBuzzApi.hb_font_glyph_from_string(Handle, s, -1, g));
     }
 }
Beispiel #18
0
 public void GetGlyphAdvanceForDirection(uint glyph, Direction direction, out int x, out int y)
 {
     fixed(int *xPtr = &x)
     fixed(int *yPtr = &y)
     {
         HarfBuzzApi.hb_font_get_glyph_advance_for_direction(Handle, glyph, direction, xPtr, yPtr);
     }
 }
Beispiel #19
0
        public void SetVerticalFontExtentsDelegate(FontExtentsDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_font_v_extents_func(Handle, DelegateProxies.FontExtentsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #20
0
 public bool TryDecompose(uint ab, out uint a, out uint b)
 {
     fixed(uint *aPtr = &a)
     fixed(uint *bPtr = &b)
     {
         return(HarfBuzzApi.hb_unicode_decompose(Handle, ab, aPtr, bPtr));
     }
 }
Beispiel #21
0
        public void SetHorizontalGlyphAdvanceDelegate(GlyphAdvanceDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_glyph_h_advance_func(Handle, DelegateProxies.GlyphAdvanceProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #22
0
        public void SetVariationGlyphDelegate(VariationGlyphDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_variation_glyph_func(Handle, DelegateProxies.VariationGlyphProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #23
0
        public void SetNominalGlyphsDelegate(NominalGlyphsDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_nominal_glyphs_func(Handle, DelegateProxies.NominalGlyphsProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #24
0
 public bool TryGetGlyphContourPointForOrigin(uint glyph, uint pointIndex, Direction direction, out int x, out int y)
 {
     fixed(int *xPtr = &x)
     fixed(int *yPtr = &y)
     {
         return(HarfBuzzApi.hb_font_get_glyph_contour_point_for_origin(Handle, glyph, pointIndex, direction, xPtr, yPtr));
     }
 }
Beispiel #25
0
 public bool TryGetVerticalGlyphOrigin(uint glyph, out int xOrigin, out int yOrigin)
 {
     fixed(int *x = &xOrigin)
     fixed(int *y = &yOrigin)
     {
         return(HarfBuzzApi.hb_font_get_glyph_v_origin(Handle, glyph, x, y));
     }
 }
Beispiel #26
0
        public void SetGlyphContourPointDelegate(GlyphContourPointDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_glyph_contour_point_func(Handle, DelegateProxies.GlyphContourPointProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #27
0
 public void GetScale(out int xScale, out int yScale)
 {
     fixed(int *x = &xScale)
     fixed(int *y = &yScale)
     {
         HarfBuzzApi.hb_font_get_scale(Handle, x, y);
     }
 }
Beispiel #28
0
 public bool TryGetGlyphContourPoint(uint glyph, uint pointIndex, out int x, out int y)
 {
     fixed(int *xPtr = &x)
     fixed(int *yPtr = &y)
     {
         return(HarfBuzzApi.hb_font_get_glyph_contour_point(Handle, glyph, pointIndex, xPtr, yPtr));
     }
 }
Beispiel #29
0
        public void SetVerticalGlyphOriginDelegate(GlyphOriginDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_glyph_v_origin_func(Handle, DelegateProxies.GlyphOriginProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }
Beispiel #30
0
        public void SetGlyphFromNameDelegate(GlyphFromNameDelegate del, ReleaseDelegate destroy)
        {
            VerifyParameters(del);

            var ctx = DelegateProxies.CreateMulti(del, destroy);

            HarfBuzzApi.hb_font_funcs_set_glyph_from_name_func(Handle, DelegateProxies.GlyphFromNameProxy, ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
        }