示例#1
0
 //------------------------------------------------------------------------
 void font_engine_freetype_base::flip_y(bool f)
 { 
     m_flip_y = f; 
     if(m_cur_face)
     {
         update_signature();
     }
 }
示例#2
0
 //------------------------------------------------------------------------
 void font_engine_freetype_base::transform(const trans_affine& affine)
 {
     m_affine = affine;
     if(m_cur_face)
     {
         update_signature();
     }
 }
示例#3
0
 //------------------------------------------------------------------------
 void font_engine_freetype_base::hinting(bool h)
 { 
     m_hinting = h; 
     if(m_cur_face)
     {
         update_signature();
     }
 }
示例#4
0
Packet::Packet(int ingress_port, packet_id_t id, packet_id_t copy_id,
	       int ingress_length, PacketBuffer &&buffer)
  : ingress_port(ingress_port), packet_id(id), copy_id(copy_id),
    ingress_length(ingress_length), buffer(std::move(buffer)) {
  assert(phv_pool);
  update_signature();
  set_ingress_ts();
  phv = phv_pool->get();
}
示例#5
0
 //------------------------------------------------------------------------
 bool font_engine_freetype_base::char_map(FT_Encoding char_map)
 {
     if(m_cur_face)
     {
         m_last_error = FT_Select_Charmap(m_cur_face, m_char_map);
         if(m_last_error == 0)
         {
             update_signature();
             return true;
         }
     }
     return false;
 }
示例#6
0
Packet::Packet(size_t cxt_id, int ingress_port, packet_id_t id,
               copy_id_t copy_id, int ingress_length, PacketBuffer &&buffer,
               PHVSourceIface *phv_source)
    : cxt_id(cxt_id), ingress_port(ingress_port), packet_id(id),
      copy_id(copy_id), ingress_length(ingress_length),
      buffer(std::move(buffer)), phv_source(phv_source) {
  assert(phv_source);
  update_signature();
  set_ingress_ts();
  phv = phv_source->get(cxt_id);
  phv->set_packet_id(packet_id, copy_id);
  DEBUGGER_PACKET_IN(PacketId::make(packet_id, copy_id), ingress_port);
}
示例#7
0
 //------------------------------------------------------------------------
 void font_engine_freetype_base::update_char_size()
 {
     if(m_cur_face)
     {
         if(m_resolution)
         {
             FT_Set_Char_Size(m_cur_face, 
                              m_width,       // char_width in 1/64th of points
                              m_height,      // char_height in 1/64th of points
                              m_resolution,  // horizontal device resolution 
                              m_resolution); // vertical device resolution 
         }
         else
         {
             FT_Set_Pixel_Sizes(m_cur_face,    
                                m_width >> 6,    // pixel_width
                                m_height >> 6);  // pixel_height
         }
         update_signature();
     }
 }
示例#8
0
    //------------------------------------------------------------------------
    bool font_engine_freetype_base::load_font(const char* font_name, 
                                              unsigned face_index,
                                              glyph_rendering ren_type,
                                              const char* font_mem, 
                                              const long font_mem_size)
    {
        bool ret = false;

        if(m_library_initialized)
        {
            m_last_error = 0;

            int idx = find_face(font_name);
            if(idx >= 0)
            {
                m_cur_face = m_faces[idx];
                m_name     = m_face_names[idx];
            }
            else
            {
                if(m_num_faces >= m_max_faces)
                {
                    delete [] m_face_names[0];
                    FT_Done_Face(m_faces[0]);
                    memcpy(m_faces, 
                           m_faces + 1, 
                           (m_max_faces - 1) * sizeof(FT_Face));
                    memcpy(m_face_names, 
                           m_face_names + 1, 
                           (m_max_faces - 1) * sizeof(char*));
                    m_num_faces = m_max_faces - 1;
                }

                if (font_mem && font_mem_size)
                {
                    m_last_error = FT_New_Memory_Face(m_library, 
                                                      (const FT_Byte*)font_mem, 
                                                      font_mem_size, 
                                                      face_index, 
                                                      &m_faces[m_num_faces]);
                }
                else
                {
                    m_last_error = FT_New_Face(m_library,
                                               font_name,
                                               face_index,
                                               &m_faces[m_num_faces]);
                }

                if(m_last_error == 0)
                {
                    m_face_names[m_num_faces] = new char [strlen(font_name) + 1];
                    strcpy(m_face_names[m_num_faces], font_name);
                    m_cur_face = m_faces[m_num_faces];
                    m_name     = m_face_names[m_num_faces];
                    ++m_num_faces;
                }
                else
                {
                    m_face_names[m_num_faces] = 0;
                    m_cur_face = 0;
                    m_name = 0;
                }
            }


            if(m_last_error == 0)
            {
                ret = true;
                
                switch(ren_type)
                {
                case glyph_ren_native_mono:
                    m_glyph_rendering = glyph_ren_native_mono;
                    break;

                case glyph_ren_native_gray8:
                    m_glyph_rendering = glyph_ren_native_gray8;
                    break;

                case glyph_ren_outline:
                    if(FT_IS_SCALABLE(m_cur_face))
                    {
                        m_glyph_rendering = glyph_ren_outline;
                    }
                    else
                    {
                        m_glyph_rendering = glyph_ren_native_gray8;
                    }
                    break;

                case glyph_ren_agg_mono:
                    if(FT_IS_SCALABLE(m_cur_face))
                    {
                        m_glyph_rendering = glyph_ren_agg_mono;
                    }
                    else
                    {
                        m_glyph_rendering = glyph_ren_native_mono;
                    }
                    break;

                case glyph_ren_agg_gray8:
                    if(FT_IS_SCALABLE(m_cur_face))
                    {
                        m_glyph_rendering = glyph_ren_agg_gray8;
                    }
                    else
                    {
                        m_glyph_rendering = glyph_ren_native_gray8;
                    }
                    break;
                }
                update_signature();
            }
        }

        return ret;
    }