コード例 #1
0
ファイル: font.cpp プロジェクト: Andrettin/Wyrmgus
/**
**  Get a font
**
**  @param ident  Font identifier
**
**  @return       The font
*/
/* static */ CFont *CFont::Get(const std::string &ident)
{
	std::map<std::string, CFont *>::iterator it = Fonts.find(ident);
	if (it == Fonts.end()) {
		DebugPrint("font not found: %s\n" _C_ ident.c_str());
		return nullptr;
	}
	CFont *font = it->second;
	if (font == nullptr) {
		DebugPrint("font not found: %s\n" _C_ ident.c_str());
		return nullptr;
	}
	return font;
}
コード例 #2
0
ファイル: Font.cpp プロジェクト: anshpat2826/NME
Font *Font::Create(TextFormat &inFormat,double inScale,GlyphRotation inRotation,bool inNative,bool inInitRef)
{
   FontInfo info(inFormat,inScale,inRotation,inNative);

   Font *font = 0;
   FontMap::iterator fit = sgFontMap.find(info);
   if (fit!=sgFontMap.end())
   {
      font = fit->second;
      if (inInitRef)
         font->IncRef();
      return font;
   }


   FontFace *face = 0;
   
   AutoGCRoot *bytes = 0;
   FontBytesMap::iterator fbit = sgRegisteredFonts.find(WideToUTF8(inFormat.font).c_str());
   if (fbit!=sgRegisteredFonts.end())
   {
      bytes = fbit->second;
   }
   
   if (bytes != NULL)
	  face = FontFace::CreateFreeType(inFormat,inScale,bytes);

   if (!face)
      face = FontFace::CreateCFFIFont(inFormat,inScale);

   if (!face && inNative)
      face = FontFace::CreateNative(inFormat,inScale);

   if (!face)
      face = FontFace::CreateFreeType(inFormat,inScale,NULL);
  
   if (!face && !inNative)
      face = FontFace::CreateNative(inFormat,inScale);
 
   if (!face)
        return 0;

   font =  new Font(face,info.height,inRotation,inInitRef);
   // Store for Ron ...
   font->IncRef();
   sgFontMap[info] = font;
   return font;
}
コード例 #3
0
ファイル: Font.cpp プロジェクト: deltaluca/Haxe-NME--fork-
Font *Font::Create(TextFormat &inFormat,double inScale,GlyphRotation inRotation,bool inNative,bool inInitRef)
{
   FontInfo info(inFormat,inScale,inRotation,inNative);

   Font *font = 0;
   FontMap::iterator fit = sgFontMap.find(info);
   if (fit!=sgFontMap.end())
   {
      font = fit->second;
      if (inInitRef)
         font->IncRef();
      return font;
   }


   FontFace *face = 0;

   if (inNative)
      face = FontFace::CreateNative(inFormat,inScale);
   
   #ifndef IPHONE
   if (!face)
      face = FontFace::CreateFreeType(inFormat,inScale);
   #endif
  
   if (!face && !inNative)
      face = FontFace::CreateNative(inFormat,inScale);
 
   if (!face)
        return 0;

   font =  new Font(face,info.height,inRotation,inInitRef);
   // Store for Ron ...
   font->IncRef();
   sgFontMap[info] = font;
   return font;
}
コード例 #4
0
ファイル: Font.cpp プロジェクト: massiveinteractive/lime
Font *Font::Create(TextFormat &inFormat,double inScale,bool inNative,bool inInitRef)
{
   FontInfo info(inFormat,inScale,inNative);

   Font *font = 0;
   FontMap::iterator fit = sgFontMap.find(info);
   if (fit!=sgFontMap.end())
   {
      font = fit->second;
      if (inInitRef)
         font->IncRef();
      return font;
   }


   FontFace *face = 0;
   
   AutoGCRoot *bytes = 0;
   FontBytesMap::iterator fbit = sgRegisteredFonts.find(WideToUTF8(inFormat.font).c_str());
   if (fbit!=sgRegisteredFonts.end())
   {
      bytes = fbit->second;
   }
   
   if (bytes != NULL)
	  face = FontFace::CreateFreeType(inFormat,inScale,bytes);

   if (!face)
      face = FontFace::CreateCFFIFont(inFormat,inScale);

   if (!face && inNative)
      face = FontFace::CreateNative(inFormat,inScale);

   if (!face)
      face = FontFace::CreateFreeType(inFormat,inScale,NULL);
  
   if (!face && !inNative)
      face = FontFace::CreateNative(inFormat,inScale);
 
   if (!face)
        return 0;

   font =  new Font(face,info.height,inInitRef);
   // Store for Ron ...
   font->IncRef();
   sgFontMap[info] = font;

   // Clear out any old fonts
   for (FontMap::iterator fit = sgFontMap.begin(); fit!=sgFontMap.end();)
   {
      if (fit->second->GetRefCount()==1)
      {
         fit->second->DecRef();
         FontMap::iterator next = fit;
         next++;
         sgFontMap.erase(fit);
         fit = next;
      }
      else
         ++fit;
   }
   
   return font;
}