ogre font的load与使用方式

来源:互联网 发布:java 线程 通信 编辑:程序博客网 时间:2024/05/14 18:41

今天遇到一个问题 文字在textArea中显示不出来,后来发现是font没有load成功的原因,后来总算解决了,总结font的load方式有2中

 

1   直接创建,并设置属性

 

Ogre::FontPtr tempFont=Ogre::FontManager::getSingleton().create("StarWars2","General");
  tempFont ->setSource("solo5.ttf"); 
  tempFont ->setType(Ogre::FT_TRUETYPE);// type 有两种 一种truetype 另外一种是图片格式 这里以truetype为例
  tempFont ->setTrueTypeSize(18);
  tempFont ->setTrueTypeResolution(96);
  //tempFont ->addCodePointRange(Ogre::Font::CodePointRange(19968,40869));//好像对应的是汉字?
  tempFont ->addCodePointRange(Ogre::Font::CodePointRange(33,255));//设置显示的范围
  tempFont ->load();

 

2 通过font的定义文件加载

 

  Ogre::FontPtr tempFont2=Ogre::FontManager::getSingleton().getByName("StarWars");
  tempFont2 ->load();

 

  starwars是在sample.fontdef中定义的,之前我一直试bluehighway-10不成功后来发现, bluehighway-10的文件后缀是font 而不是fondef。

   似乎必须是fontdef才能正确load。

 

fond的使用很简单,load成功之后采用类似 textArea->setFontName("StarWars2") 即可。

贴张图得瑟一下,虽然是hello world