|
|
|
|
|
|
|
|
|
|
public void addFont(Font font) { |
|
|
|
D.assert(font != null); |
|
|
|
D.assert(font.dynamic, $"adding font which is not dynamic is not allowed {font.name}"); |
|
|
|
FontInfo current; |
|
|
|
this._fonts.TryGetValue(font.name, out current); |
|
|
|
D.assert(current == null || current.font == font, $"font with name {font.name} already exists"); |
|
|
|
foreach (var fontName in font.fontNames) { |
|
|
|
this._fonts[fontName] = fontInfo; |
|
|
|
} |
|
|
|
this._fonts[font.name] = fontInfo; |
|
|
|
} |
|
|
|
|
|
|
|
internal FontInfo getOrCreate(string name) { |
|
|
|
|
|
|
osFont.material.mainTexture.hideFlags = HideFlags.DontSave; |
|
|
|
|
|
|
|
var newFont = new FontInfo(osFont); |
|
|
|
foreach (var fontName in osFont.fontNames) { |
|
|
|
this._fonts[fontName] = newFont; |
|
|
|
} |
|
|
|
this._fonts[osFont.name] = newFont; |
|
|
|
|
|
|
|
return newFont; |
|
|
|
} |
|
|
|
|
|
|
entry.onTextureRebuilt(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static class FontExtension |
|
|
|
{ |
|
|
|
public static CharacterInfo MustGetCharacterInfo(this Font font, char ch, int fontSize, UnityEngine.FontStyle fontStyle) |
|
|
|
{ |
|
|
|
CharacterInfo info; |
|
|
|
bool success = font.GetCharacterInfo(ch, out info, fontSize, fontStyle); |
|
|
|
D.assert(success, $"fail to get character info for character '{ch}' (code{(int)ch}) from font: ${font.name}"); |
|
|
|
return info; |
|
|
|
} |
|
|
|
} |
|
|
|
} |