/// <summary> /// Set font for all menu entries /// </summary> /// <param name="fontKey"></param> public void SetMenuEntryFont(FontId fontId) { foreach (MenuEntry entry in MenuEntries) { entry.Entry_Id = fontId; } }
public Texture GetGlyphTexture(FontId font, char charactor) { Texture result = null; FontFace fontface = new FontFace(); var key = (font.Id << 32 | charactor); if (!charactorMap.TryGetValue(key, out result)) { if (fontMap.TryGetValue(font.Id, out fontface)) { if (fontface.IsLoaded) { var glyph = fontface.Font.LoadGlyph(charactor); charactorMap[key] = result = CreateGlyphTexture(glyph); } } else { LoadFontFace(font); } } return(result); }
private async Task LoadFontFace(FontId font) { var fontFace = await loader.LoadFont(font); fontMap[font.Id] = new FontFace { Font = fontFace, IsLoaded = true }; }
public static FontOptions GetFont(FontId fontId) { foreach (FontOptions fontOption in config.fontOptions) { if (fontOption.fontId == fontId) { return(fontOption); } } return(null); }
/// <summary> /// Get a SpriteFont object /// </summary> /// <param name="fontName"></param> /// <returns></returns> public static SpriteFont GetSpriteFont(FontId fontId) { ICutlassFont font = GetFont(fontId); if (font != null) { return(font.Font); } else { return(null); } }
public TextSprite( string text, FontId font = default(FontId), float fontSize = 12, Vector2 position = default(Vector2), Color? color = null) { this.Text = text; this.Font = font; this.FontSize = fontSize; this.Position = position; this.Color = color ?? Color.White; }
/// <summary> /// Remove a font. /// </summary> /// <param name="fontId"></param> public static void RemoveFont(FontId fontId) { ICutlassFont fontToRemove; _Fonts.TryGetValue(fontId, out fontToRemove); if (fontToRemove != null) { if (_Initialized) { fontToRemove.UnloadContent(); } _Fonts.Remove(fontId); } }
private GameObject CreateText(string txt, FontId fontId, float size, Vector3 newPosition, TextAnchor newAchor) { // A custom method that creates a gameobject based on the fontPrefab and write the string in it FontOptions fontOptions = UFE.GetFont(fontId); if (fontOptions.fontPrefab == null) { Debug.LogError("Font prefab not found! Make sure you have all font prefabs set in the Global Editor"); } GameObject guiTextGO = (GameObject)Instantiate(fontOptions.fontPrefab, newPosition, Quaternion.identity); guiTextGO.guiText.anchor = newAchor; guiTextGO.guiText.text = txt; guiTextGO.transform.localScale *= size; return(guiTextGO); }
public override int GetHashCode() { unchecked { int hash = 11; hash = hash * 17 + FormatId?.GetHashCode() ?? 0; hash = hash * 17 + FontId?.GetHashCode() ?? 0; hash = hash * 17 + FillId?.GetHashCode() ?? 0; hash = hash * 17 + BorderId?.GetHashCode() ?? 0; hash = hash * 17 + NumberFormatId?.GetHashCode() ?? 0; hash = hash * 17 + HasPivotButton?.GetHashCode() ?? 0; hash = hash * 17 + HasQuotePrefix?.GetHashCode() ?? 0; hash = hash * 17 + Alignment?.GetHashCode() ?? 0; hash = hash * 17 + Protection?.GetHashCode() ?? 0; return(hash); } }
/// <summary> /// Get a SpriteFont, or return the default font if not found. /// </summary> /// <param name="fontName"></param> /// <returns></returns> public static SpriteFont GetSpriteFontOrDefault(FontId fontId) { return(GetSpriteFont(fontId) ?? DefaultFont); }
/// <summary> /// Get a font /// </summary> /// <param name="textureId"></param> /// <returns></returns> public static ICutlassFont GetFont(FontId fontId) { return(_Fonts.ElementAtOrDefault(fontId).Value); }
private GameObject CreateText(string txt, FontId fontId, float size, Vector3 newPosition, TextAnchor newAchor) { // A custom method that creates a gameobject based on the fontPrefab and write the string in it FontOptions fontOptions = UFE.GetFont(fontId); if (fontOptions.fontPrefab == null) Debug.LogError("Font prefab not found! Make sure you have all font prefabs set in the Global Editor"); GameObject guiTextGO = (GameObject)Instantiate(fontOptions.fontPrefab, newPosition, Quaternion.identity); guiTextGO.guiText.anchor = newAchor; guiTextGO.guiText.alignment = TextAlignment.Center; guiTextGO.guiText.text = txt; guiTextGO.transform.localScale *= size; return guiTextGO; }
public static Font GetFont(FontId lookupKey) { return(SeparatorResourceManager.GetInstance().LookupFont(lookupKey)); }
private Font LookupFont(FontId fontId) { return(theSeparatorFonts[(int)fontId]); }