Exemple #1
0
        public bool PrepareGlyph(int glyph_code)
        {
            m_GlyphIndex   = (int)ANT.ANT_Get_Char_Index(m_CurrentFace, glyph_code);
            m_ANTLastError = ANT.ANT_Load_Glyph(m_CurrentFace, m_GlyphIndex,
                                                m_Hinting ? ANT_LOAD.ANT_LOAD_DEFAULT : ANT_LOAD.ANT_LOAD_NO_HINTING);

            if (m_ANTLastError == ANT_Error.ANT_Err_Ok)
            {
                m_AdvanceX = ANT.ANT_int26p6_to_double(m_CurrentFace.glyph.advance.x);
                m_AdvanceY = ANT.ANT_int26p6_to_double(m_CurrentFace.glyph.advance.y);

                switch (m_GlyphRenderType)
                {
                case GlyphRenderType.Mono:
                case GlyphRenderType.Gray8:

                    m_ANTLastError = ANT.ANT_Render_Glyph(m_CurrentFace.glyph,
                                                          m_GlyphRenderType == GlyphRenderType.Mono ?
                                                          ANT_Render_Mode.ANT_RENDER_MODE_MONO : ANT_Render_Mode.ANT_RENDER_MODE_NORMAL);

                    if (m_ANTLastError == ANT_Error.ANT_Err_Ok)
                    {
                        m_CurrentBitmap = ANTExt.ToBitmap(m_CurrentFace.glyph.bitmap, m_FlipY);
                        if (m_CurrentBitmap != null)
                        {
                            m_Bounds.Left   = m_CurrentFace.glyph.bitmap_left;
                            m_Bounds.Top    = m_CurrentFace.glyph.bitmap_top;
                            m_Bounds.Right  = m_CurrentBitmap.PixelWidth + 1;
                            m_Bounds.Bottom = m_CurrentBitmap.PixelHeight + 1;
                        }
                    }
                    else
                    {
                        m_Bounds = new Rect(0, 0, m_AdvanceX, m_AdvanceY);
                    }

                    m_GlyphDataType = m_GlyphRenderType == GlyphRenderType.Mono ?
                                      GlyphDataType.Mono : GlyphDataType.Gray8;

                    return(true);

                case GlyphRenderType.Outline:

                    m_CurrentGeometry = ANTExt.ANT_Outline_ToGeometry(m_CurrentFace.glyph.outline,
                                                                      m_FlipY,
                                                                      m_Matrix);
                    if (m_CurrentGeometry != null)
                    {
                        m_Bounds = m_CurrentGeometry.Bounds;
                        //m_Bounds.BoundFloorCeiling();

                        m_GlyphDataType = GlyphDataType.Outline;

                        m_Matrix.Transform(ref m_AdvanceX, ref m_AdvanceY);

                        return(true);
                    }

                    m_Bounds = Rect.Empty;

                    break;
                }
            }

            return(false);
        }