Пример #1
0
void ON_Font::Defaults()
{
  m_font_name.Empty();
  m_font_weight = 0;
  m_font_italic = false;
  m_linefeed_ratio = m_default_linefeed_ratio;
  m_font_index = -1;
  memset(&m_font_id,0,sizeof(m_font_id));
  memset( &m_facename, 0, sizeof( m_facename));
  m_I_height = 0;
#if defined(ON_OS_WINDOWS_GDI)
  memset(&m_logfont,0,sizeof(m_logfont));
  m_logfont.lfHeight = normal_font_height;
  m_logfont.lfCharSet = default_charset;
#endif
  SetFontFaceName(L"Arial");
  SetFontWeight(normal_weight);
}
Пример #2
0
void ON_Font::SetBold( bool bBold )
{
  SetFontWeight( bBold ? bold_weight : normal_weight);
}
Пример #3
0
ON_BOOL32 ON_Font::Read(
       ON_BinaryArchive& file // restore definition from binary archive
     )
{
  Defaults();
  m_font_index = -1;
  int major_version = 0;
  int minor_version = 0;
  bool rc = file.Read3dmChunkVersion(&major_version,&minor_version);
  if ( rc && major_version == 1 ) 
  {
    int i;
    for(;;)
    {
      rc = file.ReadInt( &m_font_index );
      if  (!rc) break;
      rc = file.ReadString( m_font_name );
      if  (!rc) break;

      {
        // 18 October 2002 Dale Lear:
        //   Lowell, wchar_t has different sizes on different OSs.
        //   When writing a wchar_t string, you should use one
        //   of the WriteString functions.  This function must continue
        //   to use ReadShort(64,...) so old files will remain valid.
        unsigned short sh[64];
        rc = file.ReadShort(64, sh);
        if (!rc) break;

        wchar_t facename[65];
        for ( i = 0; i < 64; i++ )
        {
          facename[i] = sh[i];
        }
        facename[64] = 0;
        SetFontFaceName(facename);
      }

      if( minor_version >= 1 )
      {
        rc = file.ReadInt( &i );
        if (!rc) break;
        SetFontWeight(i);

        rc = file.ReadInt( &i);
        if (!rc) break;
        SetIsItalic(i?true:false);

        rc = file.ReadDouble( &m_linefeed_ratio );
        if (!rc) break;

        if ( minor_version >= 2 )
        {
          rc = file.ReadUuid( m_font_id );
          if (!rc) break;
        }
        //if ( minor_version >= 3 )
        //{
        //  rc = file.ReadInt( &i);
        //  if (!rc) break;
        //  SetUnderlined(i?true:false);
        //}
      }

      break;
    }
  }
  else
  {
    ON_ERROR("ON_Font::Read - get newer version of opennurbs");
    rc = false;
  }

  return rc;
}