public CCFontFNT(string fntFilePath, CCVector2 imageOffset = default(CCVector2)) { Configuration = CCBMFontConfiguration.FontConfigurationWithFile(fntFilePath); _imageOffset = imageOffset; if (Configuration != null) { IsFontConfigValid = true; } }
private static CCBMFontConfiguration FNTConfigLoadFile(string file) { CCBMFontConfiguration pRet; if (!fontConfigurations.TryGetValue(file, out pRet)) { pRet = CCBMFontConfiguration.FontConfigurationWithFile(file); fontConfigurations.Add(file, pRet); } return(pRet); }
/// <summary> /// Constructor to create a Bitmap Font configuration object from a file path within the /// Content directory /// </summary> /// <param name="fntFilePath">Path to the configuration file</param> /// <param name="imageOffset">Image Offset</param> public CCFontFNT(string fntFilePath, CCVector2?imageOffset = null) { Configuration = CCBMFontConfiguration.FontConfigurationWithFile(fntFilePath); this.imageOffset = CCVector2.Zero; if (imageOffset.HasValue) { this.imageOffset = imageOffset.Value; } if (Configuration != null) { IsFontConfigValid = true; } }
protected void InitBMFont(string theString, string fntFile, CCSize dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCPoint imageOffset, CCTexture2D texture) { Debug.Assert(FontConfiguration == null, "re-init is no longer supported"); Debug.Assert((theString == null && fntFile == null) || (theString != null && fntFile != null), "Invalid params for CCLabelBMFont"); if (!String.IsNullOrEmpty(fntFile)) { try { FontAtlas = CCFontAtlasCache.GetFontAtlasFNT(fntFile, imageOffset); } catch {} if (FontAtlas == null) { CCLog.Log("Bitmap Font CCLabel: Impossible to create font. Please check file: '{0}'", fntFile); return; } } AnchorPoint = CCPoint.AnchorMiddle; FontConfiguration = CCBMFontConfiguration.FontConfigurationWithFile(fntFile); currentLabelType = CCLabelType.BitMapFont; if (String.IsNullOrEmpty(theString)) { theString = String.Empty; } // Initialize the TextureAtlas along with children. var capacity = theString.Length; BlendFunc = CCBlendFunc.AlphaBlend; if (capacity == 0) { capacity = defaultSpriteBatchCapacity; } UpdateBlendFunc(); // no lazy alloc in this node Children = new CCRawList <CCNode>(capacity); Descendants = new CCRawList <CCSprite>(capacity); this.labelDimensions = dimensions; horzAlignment = hAlignment; vertAlignment = vAlignment; IsOpacityCascaded = true; ContentSize = CCSize.Zero; IsColorModifiedByOpacity = TextureAtlas.Texture.HasPremultipliedAlpha; AnchorPoint = CCPoint.AnchorMiddle; ImageOffset = imageOffset; Text = theString; }