Beispiel #1
0
    // Start is called before the first frame update
    void Start()
    {
        PxPre.Berny.TTF.Loader loader = new PxPre.Berny.TTF.Loader();
        //this.typeface = loader.ReadTTF("Assets\\Testing\\Nerko\\NerkoOne-Regular.ttf");
        // this.typeface = loader.ReadTTF("Assets\\Testing\\BattalionCommander\\Battalion Commander.otf");
        //this.typeface = loader.ReadTTF("C:\\Users\\Reavenk\\Desktop\\GILSANUB.TTF");
        this.typeface = loader.ReadTTF("C:\\Users\\Reavenk\\Desktop\\AGENCYB.TTF");


        this.curveDocument = new Document();

        //BShape shapeRect = this.curveDocument.AddRectangle(Vector2.zero, new Vector2(1.0f, 1.0f));

        //foreach(BLoop bl in shapeRect.loops)
        //{
        //    foreach (BNode bn in bl.nodes)
        //        bn.Round();
        //}

        this.curveDocument.FlushDirty();

        //Vector2 pos = Vector2.zero;
        //for(int i = 4; i < this.typeface.glyphs.Count; ++i)
        //{
        //    Debug.Log("Preparing index " + i.ToString());
        //    BShape shape =
        //        PxPre.Berny.Text.GenerateGlyph(
        //            this.typeface.glyphs[i],
        //            this.curveDocument.GetFirstLayer(),
        //            //pos,
        //            new Vector2((1.0f - this.typeface.glyphs[i].advance) * 0.5f, 0.2f),
        //            1.0f);
        //
        //    //PxPre.Berny.Text.BridgeGlyph(shape);
        //    shape.FlushDirty();
        //    pos.x += this.typeface.glyphs[i].advance;
        //
        //    break;
        //
        //    //break;
        //}
    }
Beispiel #2
0
        /// <summary>
        /// Given a string and a typeface, create the vector shapes for them.
        /// </summary>
        /// <param name="l">The layer to create the glyph shapes in.</param>
        /// <param name="offset">The location where the glyphs will be created. Represents the
        /// baseline position for the start of the string.</param>
        /// <param name="font">The font to create.</param>
        /// <param name="scale">A multiplier scale on the created geometry.</param>
        /// <param name="strToGen">The string to generate.</param>
        /// <returns>A 1-1 mapping between the string chars and the generated shapes. For missing glyphs, the entry will
        /// either be an empty glyph or null.</returns>
        public static List <BShape> GenerateString(
            Layer l,
            Vector2 offset,
            Font.Typeface font,
            float scale,
            string strToGen)
        {
            Vector2       pos = offset;
            List <BShape> ret = new List <BShape>();

            const float normLineHeight = 1.0f;

            // For each shape, generate the geometry.
            for (int i = 0; i < strToGen.Length; ++i)
            {
                char       c = strToGen[i];
                Font.Glyph g;

                if (c == '\n')
                {
                    pos.x  = offset.x;
                    pos.y += 1.0f * scale * normLineHeight;
                    ret.Add(null);
                    continue;
                }

                if (font.glyphLookup.TryGetValue(c, out g) == false)
                {
                    ret.Add(null);
                    continue;
                }

                BShape glyphShape = GenerateGlyph(g, l, pos, scale);
                ret.Add(glyphShape);

                pos.x += g.advance * scale;
            }

            return(ret);
        }
Beispiel #3
0
        public static List <BShape> CreateText(Font.Typeface typeface, Vector2 startPos, float scale, Layer layer, string str)
        {
            List <BShape> lst = new List <BShape>();

            return(lst);
        }