Exemplo n.º 1
0
        private static void bitmapCharacterImpl(int font, char cin)
        {
            BitmapFontRec fontinfo = getBitmapFont(font);
            int           c        = (int)cin & 0xffff;

            if (c < fontinfo.first | c >= fontinfo.first + fontinfo.num_chars)
            {
                return;
            }
            BitmapCharRec ch = fontinfo.ch[c - fontinfo.first];

            if ((ch != null))
            {
                GL.Bitmap(ch.width, ch.height, ch.xorig, ch.yorig, ch.advance, 0, ch.bitmap);
            }
        }
Exemplo n.º 2
0
        private static BitmapFontRec getBitmapFont(int font)
        {
            BitmapFontRec rec = bitmapFonts[font];

            if ((rec == null))
            {
                switch (font)
                {
                case BITMAP_9_BY_15:
                    rec = GLUTBitmap9x15.glutBitmap9By15;
                    break;

                case BITMAP_8_BY_13:
                    rec = GLUTBitmap8x13.glutBitmap8By13;
                    break;

                case BITMAP_TIMES_ROMAN_10:
                    rec = GLUTBitmapTimesRoman10.glutBitmapTimesRoman10;
                    break;

                case BITMAP_TIMES_ROMAN_24:
                    rec = GLUTBitmapTimesRoman24.glutBitmapTimesRoman24;
                    break;

                case BITMAP_HELVETICA_10:
                    rec = GLUTBitmapHelvetica10.glutBitmapHelvetica10;
                    break;

                case BITMAP_HELVETICA_12:
                    rec = GLUTBitmapHelvetica12.glutBitmapHelvetica12;
                    break;

                case BITMAP_HELVETICA_18:
                    rec = GLUTBitmapHelvetica18.glutBitmapHelvetica18;
                    break;

                default:
                    throw new Exception("Unknown bitmap font number :" + font);
                }
                bitmapFonts[font] = rec;
            }
            return(rec);
        }
Exemplo n.º 3
0
        public static int BitmapLength(int font, string s)
        {
            BitmapFontRec fontinfo = getBitmapFont(font);
            float         length   = 0;
            int           len      = s.Length;

            for (int pos = 0; pos <= len - 1; pos++)
            {
                int c = (int)s.ToCharArray(pos, 1)[0] & 0xffff;
                if ((c >= fontinfo.first & c < fontinfo.first + fontinfo.num_chars))
                {
                    BitmapCharRec ch = fontinfo.ch[c - fontinfo.first];
                    if ((ch != null))
                    {
                        length += ch.advance;
                    }
                }
            }
            return((int)length);
        }