Exemplo n.º 1
0
        public Tuple <double, double, double> MeasureFontGlyph(uint gid)
        {
            var hadv = FtFace.GetAdvance(gid, LoadFlags.NoScale | LoadFlags.IgnoreTransform);
            var vadv = FtFace.GetAdvance(gid, LoadFlags.NoScale | LoadFlags.IgnoreTransform | LoadFlags.VerticalLayout);

            return(new Tuple <double, double, double>(hadv.Value / (float)FtFace.UnitsPerEM, vadv.Value / (float)FtFace.UnitsPerEM, FtFace.Ascender / (float)FtFace.UnitsPerEM));
        }
Exemplo n.º 2
0
        internal Rect BoundGlyph(uint glyphIndex, StyleSimulations style)
        {
            var recip = 1 / (float)FtFace.UnitsPerEM;
            //var strength = 0.02f;
            var trm = AdjustGlyphWidth(glyphIndex);
            var m   = new FTMatrix((int)trm.M11 * 65536, (int)trm.M21 * 65536, (int)trm.M12 * 65536, (int)trm.M22 * 65536);
            var v   = new FTVector(Fixed16Dot16.FromDouble(trm.OffsetX * 65536), Fixed16Dot16.FromDouble(trm.OffsetY * 65536));

            FtFace.SetCharSize(Fixed26Dot6.FromInt32(FtFace.UnitsPerEM), Fixed26Dot6.FromInt32(FtFace.UnitsPerEM), 72, 72);
            FtFace.SetTransform(m, v);
            FtFace.LoadGlyph(glyphIndex, LoadFlags.NoBitmap | LoadFlags.NoHinting, LoadTarget.Normal);

            /*if (style == StyleSimulations.BoldSimulation)
             * {
             *  FtFace.Glyph.Outline.Embolden(Fixed26Dot6.FromDouble(strength * FtFace.UnitsPerEM));
             *  FtFace.Glyph.Outline.Translate((int) (-strength * 0.5 * FtFace.UnitsPerEM), (int) (-strength * 0.5 * FtFace.UnitsPerEM));
             * }*/
            var box  = FtFace.Glyph.GetGlyph().GetCBox(GlyphBBoxMode.Pixels);
            var rect = new Rect(new Point(box.Left * recip, box.Top * recip), new Point(box.Right * recip, box.Bottom * recip));

            if (rect.IsEmpty)
            {
                rect = new Rect(new Point(trm.OffsetX, trm.OffsetY), new Point(trm.OffsetX, trm.OffsetY));
            }

            return(rect);
        }
Exemplo n.º 3
0
        public uint EncodeFontChar(uint code)
        {
            var gid = FtFace.GetCharIndex(code);

            if (gid == 0 && FtFace.CharMap != null && FtFace.CharMap.PlatformId == PlatformId.Microsoft && FtFace.CharMap.EncodingId == 0)
            {
                gid = FtFace.GetCharIndex(0xF000 | code);
            }
            return(gid);
        }
Exemplo n.º 4
0
 protected override void DisposeCore()
 {
     FtFace?.Dispose();
 }