Ver Fonte

Forget the hash. Just use the string. Hide the details in the property accessors.

Jay Sistar há 9 anos atrás
pai
commit
76ec792683
2 ficheiros alterados com 9 adições e 15 exclusões
  1. 7 13
      Source/Atomic/UI/UIWidget.cpp
  2. 2 2
      Source/Atomic/UI/UIWidget.h

+ 7 - 13
Source/Atomic/UI/UIWidget.cpp

@@ -437,23 +437,17 @@ void UIWidget::SetFontId(const String& fontId)
     widget_->SetFontDescription(fd);
 }
 
-void UIWidget::SetFontIdHash(unsigned fontIdHash)
+String UIWidget::GetFontId()
 {
     if (!widget_)
-        return;
+        return "";
 
     tb::TBFontDescription fd(widget_->GetFontDescription());
-    fd.SetID(fontIdHash);
-    widget_->SetFontDescription(fd);
-}
-
-unsigned UIWidget::GetFontIdHash()
-{
-    if (!widget_)
-        return 0;
-
-    tb::TBFontDescription fd(widget_->GetFontDescription());
-    return fd.GetID();
+    if (!g_font_manager->HasFontFace(fd))
+    {
+        return "";
+    }
+    return g_font_manager->GetFontInfo(fd.GetID())->GetName();
 }
 
 void UIWidget::SetFontSize(int size)

+ 2 - 2
Source/Atomic/UI/UIWidget.h

@@ -24,6 +24,7 @@
 
 #include <ThirdParty/TurboBadger/tb_widgets.h>
 #include <ThirdParty/TurboBadger/tb_widgets_common.h>
+#include <ThirdParty/TurboBadger/tb_font_renderer.h>
 
 #include "../Core/Object.h"
 
@@ -275,8 +276,7 @@ class UIWidget : public Object, public tb::TBWidgetDelegate
 
     // Font Description
     void SetFontId(const String& fontId);
-    void SetFontIdHash(unsigned fontIdHash);
-    unsigned GetFontIdHash();
+    String GetFontId();
     void SetFontSize(int size);
     int GetFontSize();