diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a11806..27716d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,9 @@ endif() if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter") + if(CMAKE_CXX_COMPILER_ID STREQUAL Clang) + set(WARNING_FLAGS "${WARNING_FLAGS} -Wfloat-conversion") + endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${WARNING_FLAGS}") endif() diff --git a/src/glhelper.cpp b/src/glhelper.cpp index 08564b7..e08aa07 100644 --- a/src/glhelper.cpp +++ b/src/glhelper.cpp @@ -713,7 +713,7 @@ double ssglStrWidth(const std::string &str, double h) { LoadVectorFont(); - int width = 0; + double width = 0; for(char32_t codepoint : ReadUTF8(str)) { width += BuiltinVectorFont.GetGlyph(codepoint).advanceWidth; } @@ -728,11 +728,11 @@ static Vector PixelAlign(Vector v) { return v; } -static int DrawCharacter(const VectorFont::Glyph &glyph, Vector t, Vector o, Vector u, Vector v, - double scale, ssglLineFn *fn, void *fndata, bool gridFit) { - int advanceWidth = glyph.advanceWidth; +static double DrawCharacter(const VectorFont::Glyph &glyph, Vector t, Vector o, Vector u, Vector v, + double scale, ssglLineFn *fn, void *fndata, bool gridFit) { + double advanceWidth = glyph.advanceWidth; - int actualWidth, offsetX; + double actualWidth, offsetX; if(gridFit) { o.x += glyph.leftSideBearing; offsetX = glyph.leftSideBearing; diff --git a/src/mouse.cpp b/src/mouse.cpp index d013d4e..a77e1e0 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -1294,7 +1294,7 @@ void GraphicsWindow::MouseLeftDoubleClick(double mx, double my) { hStyle hs = c->disp.style; if(hs.v == 0) hs.v = Style::CONSTRAINT; ShowGraphicsEditControl((int)p2.x, (int)p2.y, - ssglStrFontSize(Style::TextHeight(hs)) * scale, + (int)(ssglStrFontSize(Style::TextHeight(hs)) * scale), editMinWidthChar, editValue); } } diff --git a/src/platform/gtkmain.cpp b/src/platform/gtkmain.cpp index dd4cef3..97659f7 100644 --- a/src/platform/gtkmain.cpp +++ b/src/platform/gtkmain.cpp @@ -637,11 +637,11 @@ protected: private: int _w, _h; - void ij_to_xy(int i, int j, int &x, int &y) { + void ij_to_xy(double i, double j, int &x, int &y) { // Convert to xy (vs. ij) style coordinates, // with (0, 0) at center - x = i - _w / 2; - y = _h / 2 - j; + x = (int)i - _w / 2; + y = _h / 2 - (int)j; } }; @@ -1376,7 +1376,7 @@ protected: } virtual void on_scrollbar_value_changed() { - SS.TW.ScrollbarEvent(_scrollbar.get_adjustment()->get_value()); + SS.TW.ScrollbarEvent((int)_scrollbar.get_adjustment()->get_value()); } virtual void on_editing_done(Glib::ustring value) { diff --git a/src/resource.cpp b/src/resource.cpp index a271da9..808a7d5 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -88,7 +88,7 @@ static Pixmap ReadPNGIntoPixmap(png_struct *png_ptr, png_info *info_ptr) { Pixmap pixmap = {}; pixmap.width = png_get_image_width(png_ptr, info_ptr); pixmap.height = png_get_image_height(png_ptr, info_ptr); - pixmap.hasAlpha = png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA; + pixmap.hasAlpha = (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA) != 0; size_t stride = pixmap.width * pixmap.GetBytesPerPixel(); if(stride % 4 != 0) stride += 4 - stride % 4;