--- /dev/null
+Description: Use system flatbuffers
+Author: Anton Gladky <gladk@debian.org>
+Last-Update: 2021-01-12
+
+Index: solvespace/CMakeLists.txt
+===================================================================
+--- solvespace.orig/CMakeLists.txt
++++ solvespace/CMakeLists.txt
+@@ -181,13 +181,6 @@ endif()
+ message(STATUS "Using in-tree libdxfrw")
+ add_subdirectory(extlib/libdxfrw)
+
+-message(STATUS "Using in-tree flatbuffers")
+-set(FLATBUFFERS_BUILD_FLATLIB ON CACHE BOOL "")
+-set(FLATBUFFERS_BUILD_FLATC ON CACHE BOOL "")
+-set(FLATBUFFERS_BUILD_FLATHASH OFF CACHE BOOL "")
+-set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "")
+-add_subdirectory(extlib/flatbuffers EXCLUDE_FROM_ALL)
+-
+ message(STATUS "Using in-tree q3d")
+ add_subdirectory(extlib/q3d)
+ set(Q3D_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/q3d)
+Index: solvespace/extlib/q3d/CMakeLists.txt
+===================================================================
+--- solvespace.orig/extlib/q3d/CMakeLists.txt
++++ solvespace/extlib/q3d/CMakeLists.txt
+@@ -6,18 +6,8 @@ set(Q3D_HEADER_DIR ${CMAKE_CURRENT_BINAR
+ set(Q3D_SCHEMA ${CMAKE_CURRENT_SOURCE_DIR}/q3d_object.fbs)
+ set(Q3D_HEADER ${Q3D_HEADER_DIR}/q3d_object_generated.h)
+
+-if(NOT FLATC)
+- # If not specified explicitly, use flatc from an adjacent flatbuffers
+- # CMake project.
+ add_custom_command(
+ OUTPUT ${Q3D_HEADER}
+- COMMAND $<TARGET_FILE:flatc> --cpp --no-includes -o ${Q3D_HEADER_DIR}
+- ${Q3D_SCHEMA}
+- DEPENDS flatc)
+-else()
+- add_custom_command(
+- OUTPUT ${Q3D_HEADER}
+- COMMAND ${FLATC} --cpp --no-includes -o ${Q3D_HEADER_DIR} ${Q3D_SCHEMA})
+-endif()
++ COMMAND flatc --cpp --no-includes -o ${Q3D_HEADER_DIR} ${Q3D_SCHEMA})
+
+ add_custom_target(q3d_header DEPENDS ${Q3D_HEADER})
+++ /dev/null
-Description: Use system packaged unifont
-Author: Anton Gladky <gladk@debian.org>
-Last-Update: 2016-08-15
-
-Index: solvespace/src/CMakeLists.txt
-===================================================================
---- solvespace.orig/src/CMakeLists.txt
-+++ solvespace/src/CMakeLists.txt
-@@ -101,10 +101,10 @@ add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h
- COMMAND $<TARGET_FILE:unifont2c>
- ${CMAKE_CURRENT_BINARY_DIR}/generated/bitmapfont.table.h
-- ${CMAKE_CURRENT_SOURCE_DIR}/fonts/unifont-8.0.01.hex.gz
-+ /usr/share/unifont/unifont.hex
- ${chars}
- DEPENDS unifont2c
-- ${CMAKE_CURRENT_SOURCE_DIR}/fonts/unifont-8.0.01.hex.gz
-+ /usr/share/unifont/unifont.hex
- ${chars}
- VERBATIM)
-
-Index: solvespace/tools/unifont2c.cpp
-===================================================================
---- solvespace.orig/tools/unifont2c.cpp
-+++ solvespace/tools/unifont2c.cpp
-@@ -118,17 +118,17 @@ int main(int argc, char** argv) {
- properties[codepoint].exists = true;
- }
-
-- gzFile unifont = gzopen(argv[2], "rb");
-+ FILE *unifont = fopen(argv[2], "rb");
- if(!unifont)
- die("unifont fopen failed");
-
- while(1) {
- char buf[100];
-- if(!gzgets(unifont, buf, sizeof(buf))){
-- if(gzeof(unifont)) {
-+ if(!fgets(buf, sizeof(buf), unifont)){
-+ if(feof(unifont)) {
- break;
- } else {
-- die("unifont gzgets failed");
-+ die("unifont gets failed");
- }
- }
-
-@@ -164,7 +164,7 @@ int main(int argc, char** argv) {
- properties[codepoint].isWide = isWide;
- }
-
-- gzclose(unifont);
-+ fclose(unifont);
-
- FILE *source = fopen(argv[1], "wt");
- if(!source)
+++ /dev/null
-Description: Fix FTBFS with glibc 2.25
- Replace CHAR_WIDTH by CHAR_W_SOLVESPACE
-Author: Anton Gladky <gladk@debian.org>
-Bug-Debian: https://bugs.debian.org/882167
-Fixed-Upstream: https://github.com/solvespace/solvespace/commit/7eb6574f90310f9eb294e483b0ec9ed976a66e8e
-Last-Update: 2017-11-21
-
---- solvespace-2.3+repack1.orig/src/textwin.cpp
-+++ solvespace-2.3+repack1/src/textwin.cpp
-@@ -85,7 +85,7 @@ void TextWindow::ShowEditControl(int col
- editControl.halfRow = halfRow;
- editControl.col = col;
-
-- int x = LEFT_MARGIN + CHAR_WIDTH*col;
-+ int x = LEFT_MARGIN + CHAR_W_SOLVESPACE*col;
- int y = (halfRow - SS.TW.scrollPos)*(LINE_HEIGHT/2);
-
- ShowTextEditControl(x, y + 18, str);
-@@ -447,7 +447,7 @@ void TextWindow::DrawOrHitTestIcons(int
- double ox = oldMousePos.x, oy = oldMousePos.y - LINE_HEIGHT;
- ox += 3;
- oy -= 3;
-- int tw = (str.length() + 1)*(CHAR_WIDTH - 1);
-+ int tw = (str.length() + 1)*(CHAR_W_SOLVESPACE - 1);
- ox = min(ox, (double) (width - 25) - tw);
- oy = max(oy, 5.0);
-
-@@ -583,7 +583,7 @@ bool TextWindow::DrawOrHitTestColorPicke
- int width, height;
- GetTextWindowSize(&width, &height);
-
-- int px = LEFT_MARGIN + CHAR_WIDTH*editControl.col;
-+ int px = LEFT_MARGIN + CHAR_W_SOLVESPACE*editControl.col;
- int py = (editControl.halfRow - SS.TW.scrollPos)*(LINE_HEIGHT/2);
-
- py += LINE_HEIGHT + 5;
-@@ -842,8 +842,8 @@ void TextWindow::Paint(void) {
- if(ltop < (scrollPos-1)) continue;
- if(ltop > scrollPos+halfRows) break;
-
-- for(c = 0; c < min((width/CHAR_WIDTH)+1, (int) MAX_COLS); c++) {
-- int x = LEFT_MARGIN + c*CHAR_WIDTH;
-+ for(c = 0; c < min((width/CHAR_W_SOLVESPACE)+1, (int) MAX_COLS); c++) {
-+ int x = LEFT_MARGIN + c*CHAR_W_SOLVESPACE;
- int y = (ltop-scrollPos)*(LINE_HEIGHT/2) + 4;
-
- int fg = meta[r][c].fg;
-@@ -866,7 +866,7 @@ void TextWindow::Paint(void) {
- // Move the quad down a bit, so that the descenders
- // still have the correct background.
- y += adj;
-- ssglAxisAlignedQuad(x, x + CHAR_WIDTH, y, y + bh, false);
-+ ssglAxisAlignedQuad(x, x + CHAR_W_SOLVESPACE, y, y + bh, false);
- y -= adj;
- }
- } else if(a == 1) {
-@@ -912,8 +912,8 @@ void TextWindow::Paint(void) {
- glLineWidth(1);
- glBegin(GL_LINES);
- int yp = y + CHAR_HEIGHT;
-- glVertex2d(LEFT_MARGIN + cs*CHAR_WIDTH, yp);
-- glVertex2d(LEFT_MARGIN + cf*CHAR_WIDTH, yp);
-+ glVertex2d(LEFT_MARGIN + cs*CHAR_W_SOLVESPACE, yp);
-+ glVertex2d(LEFT_MARGIN + cf*CHAR_W_SOLVESPACE, yp);
- glEnd();
-
- glEnable(GL_TEXTURE_2D);
-@@ -979,7 +979,7 @@ void TextWindow::MouseEvent(bool leftCli
- hoveredCol = 0;
-
- // Find the corresponding character in the text buffer
-- int c = (int)((x - LEFT_MARGIN) / CHAR_WIDTH);
-+ int c = (int)((x - LEFT_MARGIN) / CHAR_W_SOLVESPACE);
- int hh = (LINE_HEIGHT)/2;
- y += scrollPos*hh;
- int r;
---- solvespace-2.3+repack1.orig/src/toolbar.cpp
-+++ solvespace-2.3+repack1/src/toolbar.cpp
-@@ -218,7 +218,7 @@ bool GraphicsWindow::ToolbarDrawOrHitTes
- }
- }
-
-- int tw = str.length() * (SS.TW.CHAR_WIDTH - 1) + 10,
-+ int tw = str.length() * (SS.TW.CHAR_W_SOLVESPACE - 1) + 10,
- th = SS.TW.LINE_HEIGHT + 2;
-
- double ox = toolbarMouseX + 3, oy = toolbarMouseY + 3;
---- solvespace-2.3+repack1.orig/src/ui.h
-+++ solvespace-2.3+repack1/src/ui.h
-@@ -27,7 +27,7 @@ public:
- float fgColorTable[256*3];
-
- enum {
-- CHAR_WIDTH = 9,
-+ CHAR_W_SOLVESPACE = 9,
- CHAR_HEIGHT = 16,
- LINE_HEIGHT = 20,
- LEFT_MARGIN = 6,
---- solvespace-2.3+repack1.orig/src/win32/w32main.cpp
-+++ solvespace-2.3+repack1/src/win32/w32main.cpp
-@@ -138,7 +138,7 @@ void SolveSpace::DoMessageBox(const char
- RECT r;
- GetWindowRect(GraphicsWnd, &r);
- const char *title = error ? "SolveSpace - Error" : "SolveSpace - Message";
-- int width = cols*SS.TW.CHAR_WIDTH + 20,
-+ int width = cols*SS.TW.CHAR_W_SOLVESPACE + 20,
- height = rows*SS.TW.LINE_HEIGHT + 60;
- MessageWidth = width;
- MessageHeight = height;
-@@ -546,7 +546,7 @@ LRESULT CALLBACK TextWndProc(HWND hwnd,
- r->top += extra;
- break;
- }
-- int tooNarrow = (SS.TW.MIN_COLS*SS.TW.CHAR_WIDTH) -
-+ int tooNarrow = (SS.TW.MIN_COLS*SS.TW.CHAR_W_SOLVESPACE) -
- (r->right - r->left);
- if(tooNarrow >= 0) {
- switch(wParam) {
-@@ -1367,7 +1367,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
- InitCommonControls();
-
- // A monospaced font
-- FixedFont = CreateFontW(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_WIDTH, 0, 0,
-+ FixedFont = CreateFontW(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_W_SOLVESPACE, 0, 0,
- FW_REGULAR, false,
- false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, FF_DONTCARE, L"Lucida Console");