[email protected] 7 years ago
parent
commit
8ad561b994

+ 1 - 1
.gitmodules

@@ -1,3 +1,3 @@
 [submodule "font-effects-lib"]
 	path = font-effects-lib
-	url = https://github.com/frankinshtein/font-effects-lib
+[email protected]:frankinshtein/font-effects-lib.git

+ 172 - 0
examples/HelloFreeType/data/fonts/example.fe

@@ -0,0 +1,172 @@
+FEF2
+#sigma
+size:100
+distance:1.05
+@nodes
+*1,1,0,0,0,10,10,0,0,0,0,0,0,0,0,
+*50,2,0,0,0,579,21,0,0,0,0,1,0,0,0,
+*3,4,0,4,4,144,166,0,0,0,0,0,0,0,0,
+ 3,000000FF,0,FFFFFFFF,.7031,FF8787FF,1,1,FF,0,.5286,.8489,33.7156,1.6017
+*3,3,0,0,0,145,10,0,0,0,0,0,0,0,0,
+ 2,FF0000FF,.3691,00FF89FF,1,1,FF,0,0,1,0,1
+*10,5,0,0,0,148,345,1.75,0,0,0,0,0,0,0,
+*6,6,0,0,0,360,258,10,0,0,0,0,0,0,0,
+*5,7,0,0,0,355,63,0,0,0,0,0,0,0,0,
+*3,8,0,0,0,533,247,0,0,0,0,0,0,0,0,
+ 2,01B4FFFF,0,000000FF,1,2,00,.4707,FF,.5273,0,1,0,1
+@edges
+*7,2,1
+*8,2,4
+*1,4,3
+*1,3,3
+*1,5,3
+*7,6,2
+*3,7,1
+*5,7,2
+*4,7,4
+*6,8,2
+#mu
+size:100
+distance:1
+text:Abcdefg
+@nodes
+*1,1,0,0,0,10,10,0,0,0,0,0,0,0,0,
+*50,2,0,0,0,416,7,0,0,0,0,0,0,0,0,
+*6,3,0,0,0,110,165,10,0,0,0,0,0,0,0,
+*3,4,0,0,0,311,238,0,0,0,0,0,0,0,0,
+ 1,7600B3FF,1,3,00,.4297,FF,.4629,00,.5859,0,1,0,1
+@edges
+*4,2,2
+*1,2,3
+*1,3,2
+*3,4,2
+#pi
+size:100
+distance:.75
+font:../test..
+back:../test..
+text:Effect!
+@nodes
+*1,1,0,0,0,12,90,0,0,0,0,0,0,0,0,
+*50,2,0,0,0,764,130,0,0,0,0,1,0,0,0,
+*3,4,0,4,4,202,162,0,0,0,0,0,0,0,0,
+ 3,000000FF,0,FFFFFFFF,.6289,000000FF,1,1,FF,0,0,1,0,1
+*3,3,0,0,0,231,11,0,0,0,0,0,0,0,0,
+ 2,FF0000FF,.3691,00FF89FF,1,1,FF,0,0,1,0,1
+*6,6,0,0,0,339,336,10,0,0,0,0,0,0,0,
+*3,7,0,0,0,574,325,0,0,0,0,0,0,0,0,
+ 3,1E2289FF,0,323693FF,.9551,FFFFFFFF,1,2,00,.4727,FF,.5234,0,1,0,1
+*5,8,0,0,0,436,89,0,0,0,0,0,0,0,0,
+@edges
+*8,2,1
+*7,2,4
+*1,4,3
+*1,3,3
+*8,6,2
+*6,7,3
+*3,8,1
+*4,8,3
+#kappa
+size:100
+distance:1.2
+font:../Fonts/BigshotOne.ttf
+text:SHOP
+@nodes
+*1,1,0,0,0,10,10,0,0,0,0,0,0,0,0,
+*50,2,0,0,0,889,506,0,0,0,0,1,0,0,0,
+*3,3,0,2,2,528,7,0,0,0,0,0,0,0,0,
+ 8,F79F00FF,0,FBC51FFF,.2246,F14B6CFF,.5508,EB3071FF,.6094,2E2763FF,.6602,276AA0FF,.7754,23B2E8FF,.8789,23C3F9FF,1,1,FF,0,0,1,31,1.3333
+*3,4,0,0,0,186,12,0,0,0,0,0,0,0,0,
+ 2,FDF9EFFF,0,F07F91FF,1,2,FF,0,00,.6562,.4997,.8662,51.5714,1.6657
+*6,5,0,0,0,8,130,30,0,0,0,0,0,0,0,
+*3,6,0,0,0,367,5,0,0,0,0,0,0,0,0,
+ 2,000000FF,0,000000FF,1,2,00,.459,FF,.4902,0,1,0,1
+*3,8,0,2,3,381,202,0,0,0,0,0,0,0,0,
+ 2,075C67FF,0,075C67FF,1,2,00,.4316,FF,.4551,0,1,0,1
+*3,10,0,2,3,526,200,0,0,0,0,0,0,0,0,
+ 2,2FB7B1FF,.002,2DD1CAFF,1,2,00,.377,FF,.4023,0,1,0,1
+*5,7,0,0,0,872,14,0,0,0,0,0,0,0,0,
+*3,9,0,2,3,666,200,0,0,0,0,0,0,0,0,
+ 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,
+ 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,
+ 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,
+ 2,9C4986FF,.3945,251D5CFF,1,2,00,0,FF,0,.0096,1,18.9799,.9615
+*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
+*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
+*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,
+ 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,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
+@edges
+*7,2,0
+*13,2,1
+*18,2,2
+*15,2,3
+*20,2,4
+*6,3,0
+*1,4,0
+*1,5,0
+*5,6,0
+*5,8,0
+*5,10,0
+*17,7,0
+*8,7,1
+*10,7,2
+*9,7,3
+*11,7,4
+*5,9,0
+*5,11,0
+*5,12,0
+*12,13,0
+*5,14,0
+*14,15,0
+*4,17,0
+*3,17,1
+*5,19,0
+*19,18,1
+*5,20,0
+#beta
+size:100
+distance:1.1
+font:../Fonts/Merienda-Bold.ttf
+text:Exclusive Deal!
+@nodes
+*1,1,0,0,0,10,10,0,0,0,0,0,0,0,0,
+*3,2,0,0,0,192,8,0,0,0,0,0,0,0,0,
+ 5,FFE4AAFF,0,FFF5B0FF,.1758,FFFEC0FF,.5176,FFF49CFF,.5215,FFDC6DFF,1,1,FF,0,.0125,.9999,19.9859,1.2499
+*50,3,0,0,0,769,347,0,0,0,0,1,0,0,0,
+*3,4,0,0,0,223,189,0,0,0,0,0,0,0,0,
+ 2,8F4506FF,0,8F4506FF,1,2,00,.4473,FF,.4844,0,1,0,1
+*6,5,0,0,0,13,204,10,0,0,0,0,0,0,0,
+*3,6,0,0,3,227,362,0,0,0,0,0,0,0,0,
+ 2,471806FF,0,471806FF,1,2,00,.3555,FF,.375,0,1,0,1
+*5,7,0,0,0,512,303,0,0,0,0,0,0,0,0,
+*3,11,0,0,5,211,541,0,0,0,0,0,0,0,0,
+ 2,8F4506FF,0,8F4506FF,1,2,00,.3574,FF,.3828,0,1,0,1
+*10,9,0,0,0,435,28,1,0,0,0,0,0,0,0,
+*3,13,0,0,0,661,128,0,0,0,0,0,0,0,0,
+ 2,FFFBDAFF,.4199,FFE4AAFF,1,1,FF,0,.0125,.9999,19.9859,1.2499
+*10,14,0,0,0,472,64,1,0,0,0,0,0,0,0,
+@edges
+*1,2,0
+*2,3,0
+*13,3,1
+*7,3,4
+*5,4,0
+*1,5,1
+*5,6,0
+*4,7,0
+*6,7,1
+*11,7,2
+*5,11,0
+*2,9,0
+*14,13,0
+*9,14,1

+ 6 - 2
examples/HelloFreeType/proj.cmake/CMakeLists.txt

@@ -10,10 +10,14 @@ add_subdirectory(../../../../oxygine-freetype/ oxygine-freetype)
 include_directories(${OXYGINE_FREETYPE_INCLUDE_DIRS})
 link_directories(${OXYGINE_FREETYPE_LIBRARY_DIRS})
 
+
+add_subdirectory(../../../font-effects-lib/ font-effects-lib)
+include_directories(../../../font-effects-lib/include)
+
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OXYGINE_CXX_FLAGS} ${OXYGINE_FREETYPE_CXX_FLAGS}")
 
-add_executable(HelloFreeType ../src/main.cpp ../src/example.cpp  ../src/example.h )
-target_link_libraries(HelloFreeType ${OXYGINE_CORE_LIBS} ${OXYGINE_FREETYPE_LIBS} oxygine-freetype)
+add_executable(HelloFreeType ../src/main.cpp ../src/example.cpp  ../src/example.h ../src/FontEffects.h ../src/FontEffects.cpp)
+target_link_libraries(HelloFreeType ${OXYGINE_CORE_LIBS} ${OXYGINE_FREETYPE_LIBS} oxygine-freetype font-effects)
 
 
 

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

@@ -0,0 +1,77 @@
+#include "FontEffects.h"
+#include "ResFontFT.h"
+#include "fe/fe.h"
+#include "ox/Font.hpp"
+#include "ox/Image.hpp"
+
+void* _fe_alloc(size_t size)
+{
+    return malloc(size);
+}
+
+void _fe_free(void *ptr)
+{
+    free(ptr);
+}
+
+namespace oxfe
+{
+    fe_node* out_nodes[32];
+    using namespace oxygine;
+
+    void glyphProcessor(ResFontFT::postProcessData &p)
+    {
+        if (!p.opt)
+        {
+            ftGenDefault(p);
+            return;
+        }
+
+        fe_node *node = out_nodes[p.opt];
+        if (!node)
+        {
+            ftGenDefault(p);
+            return;
+        }
+
+        fe_im im;
+        fe_im res;
+
+        int sz = p.font->getSize();
+        im.x = p.gl->offset_x;
+        im.y = -p.gl->offset_y;
+
+        im.image.bytespp = p.src->bytespp;
+        im.image.data = p.src->data;
+        im.image.pitch = p.src->pitch;
+        im.image.w = p.src->w;
+        im.image.h = p.src->h;
+        im.image.format = FE_IMG_A8;
+        im.image.free = 0;
+
+        fe_node_apply2(p.font->getSize(), &im, node, &res);
+
+        Image& dest = *p.dest;
+
+        ImageData src;
+        src.data = res.image.data;
+        src.bytespp = res.image.bytespp;
+        src.w = res.image.w;
+        src.h = res.image.h;
+        src.format = TF_R8G8B8A8;
+        src.pitch = res.image.pitch;
+
+        dest.init(src);
+
+        p.gl->offset_x = res.x;
+        p.gl->offset_y = -res.y;
+
+        fe_image_free(&res.image);
+    }
+
+
+    void init() 
+    {
+        ResFontFT::setGlyphPostProcessor(glyphProcessor);
+    }
+}

+ 7 - 0
examples/HelloFreeType/src/FontEffects.h

@@ -0,0 +1,7 @@
+#pragma once
+#include "fe/fe.h"
+namespace oxfe
+{
+    extern fe_node* out_nodes[32];
+    void init();
+}

+ 1 - 1
font-effects-lib

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