|
|
|
|
|
|
using Unity.UIWidgets.foundation; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
namespace Unity.UIWidgets.ui |
|
|
|
{ |
|
|
|
public class FontInfo |
|
|
|
{ |
|
|
|
namespace Unity.UIWidgets.ui { |
|
|
|
internal class FontInfo { |
|
|
|
public FontInfo(Font font) |
|
|
|
{ |
|
|
|
public FontInfo(Font font) { |
|
|
|
public int textureVersion |
|
|
|
{ |
|
|
|
public int textureVersion { |
|
|
|
public void onTextureRebuilt() |
|
|
|
{ |
|
|
|
public void onTextureRebuilt() { |
|
|
|
public class FontManager |
|
|
|
{ |
|
|
|
public class FontManager { |
|
|
|
private FontManager() |
|
|
|
{ |
|
|
|
private FontManager() { |
|
|
|
public FontInfo getOrCreate(string[] names) |
|
|
|
{ |
|
|
|
_fonts = _fonts.FindAll((info) => info.font != null); // filter out destoryed fonts
|
|
|
|
var founded = _fonts.Find((info) => |
|
|
|
( (names == info.font.fontNames || (names != null && |
|
|
|
names.SequenceEqual(info.font.fontNames))))); |
|
|
|
if (founded != null) |
|
|
|
{ |
|
|
|
public bool addFont(Font font) { |
|
|
|
var entry = _fonts.Find(f => f.font == font); |
|
|
|
if (entry != null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
D.assert(font != null); |
|
|
|
font.hideFlags = HideFlags.DontSave & ~HideFlags.DontSaveInBuild; |
|
|
|
|
|
|
|
var fontInfo = new FontInfo(font); |
|
|
|
_fonts.Add(fontInfo); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
internal FontInfo getOrCreate(string[] names) { |
|
|
|
_fonts = _fonts.FindAll(info => info.font != null); // filter out destroyed fonts
|
|
|
|
var founded = _fonts.Find(info => |
|
|
|
names == info.font.fontNames || |
|
|
|
names != null && names.SequenceEqual(info.font.fontNames)); |
|
|
|
if (founded != null) { |
|
|
|
if (names.SequenceEqual(new string[] {"Material Icons"})) |
|
|
|
{ |
|
|
|
var font = Resources.Load<Font>("MaterialIcons-Regular"); |
|
|
|
D.assert(font != null); |
|
|
|
var fontInfo = new FontInfo(font); |
|
|
|
_fonts.Add(fontInfo); |
|
|
|
return fontInfo; |
|
|
|
} |
|
|
|
var osFont = Font.CreateDynamicFontFromOSFont(names, defaultFontSize); |
|
|
|
osFont.hideFlags = HideFlags.DontSave; |
|
|
|
osFont.material.hideFlags = HideFlags.DontSave; |
|
|
|
osFont.material.mainTexture.hideFlags = HideFlags.DontSave; |
|
|
|
var newFont = new FontInfo(Font.CreateDynamicFontFromOSFont(names, defaultFontSize)); |
|
|
|
var newFont = new FontInfo(osFont); |
|
|
|
public FontInfo getOrCreate(string name) |
|
|
|
{ |
|
|
|
internal FontInfo getOrCreate(string name) { |
|
|
|
private void onFontTextureRebuilt(Font font) |
|
|
|
{ |
|
|
|
var id = font.GetInstanceID(); |
|
|
|
var entry = _fonts.Find((f) => f.font != null && f.font.GetInstanceID() == id); |
|
|
|
if (entry != null) |
|
|
|
{ |
|
|
|
private void onFontTextureRebuilt(Font font) { |
|
|
|
var entry = _fonts.Find(f => f.font == font); |
|
|
|
if (entry != null) { |
|
|
|
entry.onTextureRebuilt(); |
|
|
|
} |
|
|
|
} |