* Advanced text bug introduced earlier is fixed 4.x-dev

Wed, 21 Jul 2021 10:39:37 +0300

author
cemkalyoncu
date
Wed, 21 Jul 2021 10:39:37 +0300
branch
4.x-dev
changeset 1725
ebbf2e5bfb34
parent 1724
f5aa57571f69
child 1726
4915f53e1995

* Advanced text bug introduced earlier is fixed

Source/Gorgon/Graphics/AdvancedPrinter.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Graphics/AdvancedPrinterImpl.h file | annotate | diff | comparison | revisions
Source/Gorgon/ImageProcessing/Kernel.cpp file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/Graphics/AdvancedPrinter.cpp	Tue Jul 20 09:36:01 2021 +0300
+++ b/Source/Gorgon/Graphics/AdvancedPrinter.cpp	Wed Jul 21 10:39:37 2021 +0300
@@ -53,7 +53,7 @@
             ) {
                 if(g != 0xffff) {
                     auto p = location + (Geometry::Point)renderer.GetSize(g) + renderer.GetOffset(g);
-                    p.Y += renderer.GetBaseLine();
+                    p.Y += (int)renderer.GetBaseLine();
 
                     if(p.X > sz.Width)
                         sz.Width = p.X;
--- a/Source/Gorgon/Graphics/AdvancedPrinterImpl.h	Tue Jul 20 09:36:01 2021 +0300
+++ b/Source/Gorgon/Graphics/AdvancedPrinterImpl.h	Wed Jul 21 10:39:37 2021 +0300
@@ -158,8 +158,8 @@
             if(baseline != renderer->GetBaseLine())
                 prev = 0; //font size changed, do not use kerning
 
-            height = renderer->GetLineGap();
-            baseline = renderer->GetBaseLine();
+            height = (int)renderer->GetLineGap();
+            baseline = (int)renderer->GetBaseLine();
             em = renderer->GetEMSize();
             lineth = std::max(1, (int)std::round(renderer->GetLineThickness()));
 
@@ -433,7 +433,7 @@
             {
                 auto ind = readindex(it, end, p, curindex);
 
-                for(int i = openregions.size()-1; i>=0; i--) {
+                for(int i = (int)openregions.size()-1; i>=0; i--) {
                     if(openregions[i].ID == ind && openregions[i].finishat == -1) {
                         openregions[i].finishat = (int)acc.size();
                         break;
@@ -549,7 +549,7 @@
             {
                 baselineoffset = -0.3f;
 
-                auto height = renderer->GetBaseLine() * 0.3f;
+                auto height = (int)std::round(renderer->GetBaseLine() * 0.3f);
                 if(height > extralineheight)
                     extralineheight = height;
 
@@ -559,7 +559,7 @@
             {
                 baselineoffset = 0.4f;
 
-                auto offset = renderer->GetBaseLine() * 0.4f;
+                auto offset = (int)std::round(renderer->GetBaseLine() * 0.4f);
                 if(offset > extralineoffset)
                     extralineoffset = offset;
 
@@ -608,7 +608,7 @@
             case 0x86:
             {
                 RGBAf curbgcol = color(printer->GetColor());
-                curbgcol.A *= 0.2;
+                curbgcol.A *= 0.2f;
 
                 auto curim = selimg;
                 if(selbg.set) {
@@ -756,7 +756,7 @@
                 break;
             }
 
-            int lineh = linespacing(maxh, printer->GetLineSpacing() * (maxh + extralineoffset + extralineheight));
+            int lineh = linespacing(maxh, int(printer->GetLineSpacing() * (maxh + extralineoffset + extralineheight)));
 
             //selection handling
             for(auto &s : selections) {
@@ -929,7 +929,7 @@
                 cur.X = acc.back().location.X + acc.back().width;
             }
 
-            ind = acc.size();
+            ind = (int)acc.size();
             newline = ind == 0;
 
             int regionendy = cur.Y + lineh;
@@ -1099,14 +1099,14 @@
 
             //if still doing scripts, readjust exta line height and offset
             if(baselineoffset < 0) {
-                auto height = renderer->GetBaseLine() * -baselineoffset;
+                auto height = int(std::round(renderer->GetBaseLine() * -baselineoffset));
                 if(height > extralineheight)
                     extralineheight = height;
 
                 changeprinter(backup, true);
             }
             else if(baselineoffset > 0) {
-                auto offset = renderer->GetBaseLine() * baselineoffset;
+                auto offset = int(std::round(renderer->GetBaseLine() * baselineoffset));
 
                 if(offset > extralineoffset)
                     extralineoffset = offset;
@@ -1214,14 +1214,14 @@
             }
             else if(internal::isspace(g)) {
                 if(renderer->Exists(g)) {
-                    gw = renderer->GetCursorAdvance(g);
+                    gw = (int)renderer->GetCursorAdvance(g);
                 }
                 else {
                     gw = (int)internal::defaultspace(g, *renderer);
                 }
             }
             else if(g != '\t') {
-                gw = renderer->GetCursorAdvance(g);
+                gw = (int)renderer->GetCursorAdvance(g);
             }
 
             newline = false;
@@ -1405,6 +1405,8 @@
 
         }
 
+        auto l = cur;
+
         if(!acc.empty()) {
             if(!doline(-1)) {
                 done = true;
@@ -1412,7 +1414,7 @@
         }
 
 
-        location = cur;
+        location = l;
         
         if(!done)
             glyphr(*renderer, 0xffff, location, 0.f, std::numeric_limits<long>::max());
--- a/Source/Gorgon/ImageProcessing/Kernel.cpp	Tue Jul 20 09:36:01 2021 +0300
+++ b/Source/Gorgon/ImageProcessing/Kernel.cpp	Wed Jul 21 10:39:37 2021 +0300
@@ -9,11 +9,11 @@
     }
 
     Kernel &Kernel::operator = (const std::initializer_list<std::initializer_list<Float>> &values) {
-        int maxlistsize = values.begin()->size();
+        int maxlistsize = (int)values.begin()->size();
         
         for(auto &list : values) {            
             if(list.size()  > maxlistsize)
-                maxlistsize = list.size();
+                maxlistsize = (int)list.size();
         }
         
         for(auto &list : values) {
@@ -25,7 +25,7 @@
                 kernel.insert(kernel.end(), maxlistsize - list.size(), 0);
         }        
             
-        size.Height = values.size();
+        size.Height = (int)values.size();
         size.Width = maxlistsize;
         
         return *this;
@@ -54,10 +54,10 @@
         
         switch (axis){
             case Axis::X:
-                nkernel = {{1, 0, -1}, {2, 0, -2}, {1, 0, -1}};
+                nkernel = {{1.f, 0.f, -1.f}, {2.f, 0.f, -2.f}, {1.f, 0.f, -1.f}};
                 break;
             case Axis::Y:
-                nkernel = {{1, 2, 1}, {0, 0, 0}, {-1, -2, -1}};
+                nkernel = {{1.f, 2.f, 1.f}, {0.f, 0.f, 0.f}, {-1.f, -2.f, -1.f}};
                 break;
         }
         
@@ -66,21 +66,21 @@
 
 
     Kernel Kernel::Sharpen() {
-        return {{-0.025, -0.1, -0.025}, {-0.1, 1.5, -0.1}, {-0.025, -0.1, -0.025}};
+        return {{-0.025f, -0.1f, -0.025f}, {-0.1f, 1.5f, -0.1f}, {-0.025f, -0.1f, -0.025f}};
     }  
 
     Kernel Kernel::BoxFilter(int kernelsize) {
         Kernel nkernel;
         
         nkernel.Resize({kernelsize, kernelsize});
-        nkernel.createboxfilter(1.0 /(kernelsize * kernelsize), 1.0 / (kernelsize * kernelsize));
+        nkernel.createboxfilter(1.0f /(kernelsize * kernelsize), 1.0f / (kernelsize * kernelsize));
         
         return nkernel;
     }
     
     Kernel Kernel::CircularFilter(float kernelsize) {
         Kernel nkernel;
-        int size = std::ceil(kernelsize);
+        int size = (int)std::ceil(kernelsize);
         nkernel.Resize({size, size});
         nkernel.createcircularfilter(0, 255);
         return nkernel;
@@ -90,7 +90,7 @@
         Kernel nkernel;
         
         nkernel.Resize({kernelsize, kernelsize});
-        nkernel.createboxfilter(kernelsize * kernelsize -1, -1);
+        nkernel.createboxfilter(float(kernelsize * kernelsize - 1), -1.f);
         
         return nkernel;
     }

mercurial