[email protected] 7 年之前
父節點
當前提交
94ac73c771

+ 6 - 6
examples/HelloFreeType/data/fonts/example.fe

@@ -90,21 +90,21 @@ text:SHOP
  2,075C67FF,0,075C67FF,1,2,00,.3516,FF,.375,0,1,0,1
  2,075C67FF,0,075C67FF,1,2,00,.3516,FF,.375,0,1,0,1
 *3,11,0,6,6,811,198,0,0,0,0,0,0,0,0,
 *3,11,0,6,6,811,198,0,0,0,0,0,0,0,0,
  2,030320FF,0,030320FF,1,2,00,.2969,FF,.5508,0,1,0,1
  2,030320FF,0,030320FF,1,2,00,.2969,FF,.5508,0,1,0,1
-*3,12,0,2,3,14,346,0,0,0,0,0,0,0,0,
+*3,12,0,2,3,21,338,0,0,0,0,0,0,0,0,
  2,000000FF,0,000000FF,1,2,00,.0977,FF,.1387,0,1,0,1
  2,000000FF,0,000000FF,1,2,00,.0977,FF,.1387,0,1,0,1
 *3,13,0,2,3,180,353,0,0,0,0,0,0,0,0,
 *3,13,0,2,3,180,353,0,0,0,0,0,0,0,0,
- 2,9C4986FF,.3945,251D5CFF,1,2,00,0,FF,0,.0096,1,18.9799,.9615
+ 2,9C4986FF,.3945,251D5CFF,1,1,FF,.332,.0096,1,18.9799,.9615
 *3,14,0,2,3,21,550,0,0,0,0,0,0,0,0,
 *3,14,0,2,3,21,550,0,0,0,0,0,0,0,0,
  2,000000FF,0,000000FF,1,2,00,.043,FF,.0645,0,1,0,1
  2,000000FF,0,000000FF,1,2,00,.043,FF,.0645,0,1,0,1
 *3,15,0,2,3,210,573,0,0,0,0,0,0,0,0,
 *3,15,0,2,3,210,573,0,0,0,0,0,0,0,0,
- 2,A964ACFF,.3945,4E5DBCFF,1,2,00,0,FF,0,.0096,1,18.9799,.9615
+ 2,A964ACFF,.3945,4E5DBCFF,1,1,FF,.0742,.0096,1,18.9799,.9615
 *5,17,0,0,0,708,14,0,0,0,0,0,0,0,0,
 *5,17,0,0,0,708,14,0,0,0,0,0,0,0,0,
 *3,19,0,2,3,374,394,0,0,0,0,0,0,0,0,
 *3,19,0,2,3,374,394,0,0,0,0,0,0,0,0,
  2,000000FF,0,000000FF,1,2,00,.043,FF,.0645,0,1,0,1
  2,000000FF,0,000000FF,1,2,00,.043,FF,.0645,0,1,0,1
 *3,18,0,5,10,554,397,0,0,0,0,0,0,0,0,
 *3,18,0,5,10,554,397,0,0,0,0,0,0,0,0,
- 3,040545FF,.8516,20659FFF,.9688,2E87D3FF,.9941,2,00,0,FF,0,-.0018,1,18.9795,1.0099
-*3,20,0,6,10,590,594,0,0,0,0,0,0,0,0,
- 2,0C0035FF,0,0C0035FF,1,2,00,0,FF,0,0,1,0,1
+ 3,040545FF,.8516,20659FFF,.9688,2E87D3FF,.9941,1,FF,.1211,-.0018,1,18.9795,1.0099
+*3,20,0,6,10,545,600,0,0,0,0,0,0,0,0,
+ 2,0C0035FF,0,0C0035FF,1,2,00,0,FF,.0312,0,1,0,1
 @edges
 @edges
 *7,2,0
 *7,2,0
 *13,2,1
 *13,2,1

+ 1 - 0
examples/HelloFreeType/src/FontEffects.cpp

@@ -65,6 +65,7 @@ namespace oxfe
 
 
         p.gl->offset_x = res.x;
         p.gl->offset_x = res.x;
         p.gl->offset_y = -res.y;
         p.gl->offset_y = -res.y;
+        p.gl->advance_x = (int)(p.gl->advance_x * node->effect->distance);
 
 
         fe_image_free(&res.image);
         fe_image_free(&res.image);
     }
     }

+ 29 - 60
examples/HelloFreeType/src/example.cpp

@@ -1,7 +1,8 @@
 #include "oxygine-framework.h"
 #include "oxygine-framework.h"
 #include <functional>
 #include <functional>
 #include "ResFontFT.h"
 #include "ResFontFT.h"
-
+#include "FontEffects.h"
+#include "fe/fe.h"
 using namespace oxygine;
 using namespace oxygine;
 
 
 //it is our resources
 //it is our resources
@@ -9,11 +10,12 @@ using namespace oxygine;
 //It is important on mobile devices with limited memory and you would load/unload them
 //It is important on mobile devices with limited memory and you would load/unload them
 Resources gameResources;
 Resources gameResources;
 
 
-enum TextMode
-{
-    tm_no_shadow = 0,
-    tm_shadow = 1,
-    tm_shadow2 = 2,
+
+fe_bundle *bundle = 0;
+
+enum {
+    EFFECT_A = 1,
+    EFFECT_B
 };
 };
 
 
 class MainActor: public Actor
 class MainActor: public Actor
@@ -65,23 +67,22 @@ public:
 
 
         //initialize text style
         //initialize text style
         TextStyle style;
         TextStyle style;
-#if OXYGINE_VERSION > 3
+
         style.font = gameResources.getResFont("main");
         style.font = gameResources.getResFont("main");
         style.fontSize = 80;
         style.fontSize = 80;
-#else
-        style.font = gameResources.getResFont("main")->getFont(0, 40);
-#endif
-        style.color = Color::Crimson;
+
+        //style.color = Color::Crimson;
         style.vAlign = TextStyle::VALIGN_MIDDLE;
         style.vAlign = TextStyle::VALIGN_MIDDLE;
         style.hAlign = TextStyle::HALIGN_MIDDLE;
         style.hAlign = TextStyle::HALIGN_MIDDLE;
         style.baselineScale = 0.7f;
         style.baselineScale = 0.7f;
 
 
         //apply our custom option
         //apply our custom option
-        style.options = tm_shadow;
+        style.options = EFFECT_A;
 
 
         text->setStyle(style);
         text->setStyle(style);
         text->setHtmlText("Hello\n <div opt='2'>World!</div>");
         text->setHtmlText("Hello\n <div opt='2'>World!</div>");
 
 
+
         _text = text;
         _text = text;
     }
     }
 
 
@@ -145,63 +146,29 @@ typedef oxygine::intrusive_ptr<MainActor> spMainActor;
 
 
 void example_preinit() {}
 void example_preinit() {}
 
 
-void myShadowsFilter(ResFontFT::postProcessData& data)
-{
-    Image& destIm = *data.dest;
-    ImageData& src = *data.src;
-
-    ImageData rc;
-
-
-    Image tempImage;
-    tempImage.init(src.w, src.h, TF_R8G8B8A8);
-
-    rc = tempImage.lock();
-    operations::blitPremultiply(src, rc);
-
-    src = rc;
-
-    if (data.opt == tm_no_shadow)
-    {
-        //if shadows disabled
-        destIm.swap(tempImage);
-        return;
-    }
-
-
-    const int xoffset = 4;
-    const int yoffset = 3;
-
-    //initialize destination Image with increased size
-    destIm.init(src.w + xoffset, src.h + yoffset, TF_R8G8B8A8);
-    //clear it
-    destIm.fillZero();
-
-
-    //copy black image as shadow
-    rc = destIm.lock(Rect(xoffset, yoffset, src.w, src.h));
-
-    Color shadowColor = data.opt == tm_shadow ? Color(0, 0, 0, 255) : Color(255, 0, 0, 255);
-    operations::blitColored(src, rc, shadowColor);
-
-    //copy original image
-    operations::op_blend_one_invSrcAlpha op;
-    rc = destIm.lock(Rect(0, 0, src.w, src.h));
-    operations::applyOperation(op, src, rc);
-}
-
 //called from entry_point.cpp
 //called from entry_point.cpp
 void example_init()
 void example_init()
 {
 {
     ResFontFT::initLibrary();
     ResFontFT::initLibrary();
-
-    //use it for adding shadows
-    ResFontFT::setGlyphPostProcessor(myShadowsFilter);
+    
+    oxfe::init();
 
 
     //load xml file with resources definition
     //load xml file with resources definition
     gameResources.loadXML("res.xml");
     gameResources.loadXML("res.xml");
 
 
 
 
+    file::buffer buf;
+    file::read("fonts/example.fe", buf);
+    bundle = fe_bundle_load(buf.getData(), buf.getSize());
+
+    fe_effect *effect;
+
+    effect = fe_bundle_get_effect_by_name(bundle, "beta");
+    oxfe::out_nodes[EFFECT_A] = fe_effect_find_node_by_type(effect, fe_node_type_out);
+
+    effect = fe_bundle_get_effect_by_name(bundle, "kappa");
+    oxfe::out_nodes[EFFECT_B] = fe_effect_find_node_by_type(effect, fe_node_type_out);
+
     //lets create our client code simple actor
     //lets create our client code simple actor
     //spMainActor was defined above as smart intrusive pointer (read more: http://www.boost.org/doc/libs/1_57_0/libs/smart_ptr/intrusive_ptr.html)
     //spMainActor was defined above as smart intrusive pointer (read more: http://www.boost.org/doc/libs/1_57_0/libs/smart_ptr/intrusive_ptr.html)
     spMainActor actor = new MainActor;
     spMainActor actor = new MainActor;
@@ -219,6 +186,8 @@ void example_update()
 //called each frame from entry_point.cpp
 //called each frame from entry_point.cpp
 void example_destroy()
 void example_destroy()
 {
 {
+    fe_bundle_free(bundle);
+
     //free previously loaded resources
     //free previously loaded resources
     gameResources.free();
     gameResources.free();
     ResFontFT::freeLibrary();
     ResFontFT::freeLibrary();

+ 1 - 1
font-effects-lib

@@ -1 +1 @@
-Subproject commit 58ddf9ef802264aed02981410c7cab1b458cf5d5
+Subproject commit 1abbf0ffd3afcbe083e59a56ad85bcff7331903b