From afa4cb6d40e13f22edc678a0bc52fee1f0dade55 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 16 Nov 2020 21:51:24 +1000
Subject: Fix build


diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1f259e..a5b56d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -421,7 +421,7 @@ include(CMakeLists_Dependencies.cmake)
 ##############################################################################################################
 ########## Include Setup                                                                            ##########
 
-TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+#TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
 
 CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H)
 if(HAVE_DLFCN_H)
diff --git a/scribus/scpaths.cpp b/scribus/scpaths.cpp
index 7d5b424..66995bf 100644
--- a/scribus/scpaths.cpp
+++ b/scribus/scpaths.cpp
@@ -322,6 +322,15 @@ QStringList ScPaths::spellDirs() const
 	d.setPath(linuxLocalPath);
 	if (d.exists())
 		spellDirs.append(linuxLocalPath);
+#elif defined(Q_OS_HAIKU)
+	QString haikuSystemHunspellPath("/system/data/hunspell/");
+	QString haikuUserHunspellPath("/boot/home/config/non-packaged/data/hunspell/");
+	d.setPath(haikuSystemHunspellPath);
+	if (d.exists())
+		spellDirs.append(haikuSystemHunspellPath);
+	d.setPath(haikuUserHunspellPath);
+	if (d.exists())
+		spellDirs.append(haikuUserHunspellPath);
 #endif
 	return spellDirs;
 }
@@ -388,6 +397,19 @@ QStringList ScPaths::hyphDirs() const
 	d.setPath(linuxLocalPath);
 	if (d.exists())
 		hyphDirs.append(linuxLocalPath);
+#elif defined(Q_OS_HAIKU)
+	QString haikuSystemHyphenPath("/system/data/hyphen/");
+	QString haikuSystemHunspellPath("/system/data/hunspell/");
+	QString haikuUserHunspellPath("/boot/home/config/non-packaged/data/hunspell/");
+	d.setPath(haikuSystemHyphenPath);
+	if (d.exists())
+		hyphDirs.append(haikuSystemHyphenPath);
+	d.setPath(haikuSystemHunspellPath);
+	if (d.exists())
+		hyphDirs.append(haikuSystemHunspellPath);
+	d.setPath(haikuUserHunspellPath);
+	if (d.exists())
+		hyphDirs.append(haikuUserHunspellPath);
 #endif
 	return hyphDirs;
 }
@@ -411,6 +433,9 @@ QStringList ScPaths::systemFontDirs()
 	if (d.exists())
 		fontDirs.append(roamingFontDir);
 	fontDirs.append(windowsSpecialDir(CSIDL_FONTS));
+#elif defined(Q_OS_HAIKU)
+	fontDirs.append("/system/data/fonts/ttfonts");
+	fontDirs.append("/boot/home/config/non-packaged/data/fonts");
 #endif
 	return fontDirs;
 }
diff --git a/scribus/third_party/pgf/PGFplatform.h b/scribus/third_party/pgf/PGFplatform.h
index 55a5828..f421582 100644
--- a/scribus/third_party/pgf/PGFplatform.h
+++ b/scribus/third_party/pgf/PGFplatform.h
@@ -529,7 +529,7 @@ __inline OSError FileWrite(HANDLE hFile, int *count, void *buffPtr) {
 }
 
 __inline OSError GetFPos(HANDLE hFile, UINT64 *pos) {
-	#ifdef __APPLE__
+	#if defined(__APPLE__) || defined(__HAIKU__)
 		off_t ret;
 		if ((ret = lseek(hFile, 0, SEEK_CUR)) == -1) {
 			return errno;
@@ -549,7 +549,7 @@ __inline OSError GetFPos(HANDLE hFile, UINT64 *pos) {
 }
 
 __inline OSError SetFPos(HANDLE hFile, int posMode, INT64 posOff) {
-	#ifdef __APPLE__
+	#if defined(__APPLE__) || defined(__HAIKU__)
 		if ((lseek(hFile, (off_t)posOff, posMode)) == -1) {
 			return errno;
 		} else {
diff --git a/scribus/util_debug.cpp b/scribus/util_debug.cpp
index 6f19200..d3a8c61 100644
--- a/scribus/util_debug.cpp
+++ b/scribus/util_debug.cpp
@@ -53,7 +53,7 @@ void tDebug(const QString& message)
  */
 void printBacktrace ( int nFrames )
 {
-#if !defined(_WIN32) && !defined(Q_OS_MAC) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_FREEBSD)
+#if !defined(_WIN32) && !defined(Q_OS_MAC) && !defined(Q_OS_OPENBSD) && !defined(Q_OS_FREEBSD) && !defined(Q_OS_HAIKU)
 	void ** trace = new void*[nFrames + 1];
 	char **messages = ( char ** ) nullptr;
 	int i, trace_size = 0;
-- 
2.30.2


From 27b2024b2f783d09c103059924852838eff45407 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 8 Jan 2021 22:00:46 +1000
Subject: Fix for app font


diff --git a/scribus/main_nix.cpp b/scribus/main_nix.cpp
index e50217e..a20ab3c 100644
--- a/scribus/main_nix.cpp
+++ b/scribus/main_nix.cpp
@@ -64,8 +64,9 @@ int main(int argc, char *argv[])
 int mainApp(int argc, char **argv)
 {
 	emergencyActivated = false;
-
+#ifndef Q_OS_HAIKU
 	ScribusQApp::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
 	ScribusQApp app(argc, argv);
 	initCrashHandler();
 	app.parseCommandLine();
diff --git a/scribus/prefsmanager.cpp b/scribus/prefsmanager.cpp
index e6fe249..98b672e 100644
--- a/scribus/prefsmanager.cpp
+++ b/scribus/prefsmanager.cpp
@@ -2783,9 +2783,11 @@ bool PrefsManager::readPref(const QString& filePath)
 		else
 			appPrefs.uiPrefs.style.clear();
 	}
+#ifndef Q_OS_HAIKU
 	QFont apf = qApp->font();
 	apf.setPointSize(appPrefs.uiPrefs.applicationFontSize);
 	qApp->setFont(apf);
+#endif
 	return true;
 }
 
diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index dca5b13..3a2e2bd 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -6484,12 +6484,14 @@ void ScribusMainWindow::slotPrefsOrg()
 		ScQApp->changeIconSet(newIconSet);
 
 	int newUIFontSize = m_prefsManager.guiFontSize();
+#ifndef Q_OS_HAIKU
 	if (oldPrefs.uiPrefs.applicationFontSize != newUIFontSize)
 	{
 		QFont apf = qApp->font();
 		apf.setPointSize(newUIFontSize);
 		qApp->setFont(apf);
 	}
+#endif
 	emit UpdateRequest(reqDefFontListUpdate);
 	if (m_prefsManager.appPrefs.uiPrefs.useTabs)
 	{
-- 
2.30.2


From 4ad3b247e814bb8fddcf56508ac00ce1bdfd6fa0 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 22 Nov 2021 20:40:09 +0100
Subject: Prefer the shared libpython3


diff --git a/CMakeLists_Dependencies.cmake b/CMakeLists_Dependencies.cmake
index 0a660bf..281fc33 100644
--- a/CMakeLists_Dependencies.cmake
+++ b/CMakeLists_Dependencies.cmake
@@ -160,6 +160,7 @@ endif()
 #<< PYTHON
 if (NOT WANT_PYTHON_2X)
 	message("Python 3.x Selected")
+	set (Python3_USE_STATIC_LIBS FALSE)
 	find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
 	if (Python3_Development_FOUND)
 		message("Python 3.x Library Found OK (Version ${Python3_VERSION})")
-- 
2.30.2


From 06f52ede0e7b7c5b226791b16e499f185f19fd48 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Fri, 25 Feb 2022 20:42:38 +0100
Subject: fix uint32_t type for x86


diff --git a/scribus/imagedataloaders/scimgdataloader_tiff.cpp b/scribus/imagedataloaders/scimgdataloader_tiff.cpp
index 1073051..0a8e539 100644
--- a/scribus/imagedataloaders/scimgdataloader_tiff.cpp
+++ b/scribus/imagedataloaders/scimgdataloader_tiff.cpp
@@ -52,7 +52,7 @@ void ScImgDataLoader_TIFF::loadEmbeddedProfile(const QString& fn, int /*page*/)
 	if (!tif)
 		return;
 
-	uint32_t EmbedLen = 0;
+	uint32 EmbedLen = 0;
 	void*  EmbedBuffer;
 	if (TIFFGetField(tif, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer))
 	{
@@ -289,26 +289,26 @@ bool ScImgDataLoader_TIFF::getImageData(TIFF* tif, RawImage *image, uint widtht,
 
 	if (TIFFIsTiled(tif))
 	{
-		uint32_t columns, rows;
-		uint32_t *tile_buf;
-		uint32_t xt, yt;
+		uint32 columns, rows;
+		uint32 *tile_buf;
+		uint32 xt, yt;
 		TIFFGetField(tif, TIFFTAG_TILEWIDTH,  &columns);
 		TIFFGetField(tif, TIFFTAG_TILELENGTH, &rows);
-		tile_buf = (uint32_t*) _TIFFmalloc(columns * rows * sizeof(uint32_t));
+		tile_buf = (uint32*) _TIFFmalloc(columns * rows * sizeof(uint32));
 		if (tile_buf == nullptr)
 		{
 			TIFFClose(tif);
 			return false;
 		}
-		uint32_t tileW = columns, tileH = rows;
-		for (yt = 0; yt < (uint32_t) image->height(); yt += rows)
+		uint32 tileW = columns, tileH = rows;
+		for (yt = 0; yt < (uint32) image->height(); yt += rows)
 		{
 			if (yt > (uint) image->height())
 				break;
 			if (image->height() - yt < rows)
 				tileH = image->height() - yt;
 			tileW = columns;
-			uint32_t yi;
+			uint32 yi;
 			int chans = image->channels();
 			for (xt = 0; xt < (uint) image->width(); xt += columns)
 			{
@@ -325,7 +325,7 @@ bool ScImgDataLoader_TIFF::getImageData(TIFF* tif, RawImage *image, uint widtht,
 	{
 		int chans = image->channels();
 		tsize_t bytesperrow = TIFFScanlineSize(tif);
-		uint32_t *bits = (uint32_t *) _TIFFmalloc(bytesperrow);
+		uint32 *bits = (uint32 *) _TIFFmalloc(bytesperrow);
 		if (bits)
 		{
 			for (unsigned int y = 0; y < heightt; y++)
@@ -351,7 +351,7 @@ bool ScImgDataLoader_TIFF::getImageData(TIFF* tif, RawImage *image, uint widtht,
 
 bool ScImgDataLoader_TIFF::getImageData_RGBA(TIFF* tif, RawImage *image, uint widtht, uint heightt, uint size, const SampleFormatInfo& sampleInfo)
 {
-	uint32_t* bits = (uint32_t *) _TIFFmalloc(size * sizeof(uint32_t));
+	uint32* bits = (uint32 *) _TIFFmalloc(size * sizeof(uint32));
 	if (!bits)
 		return false;
 
@@ -733,7 +733,7 @@ bool ScImgDataLoader_TIFF::loadPicture(const QString& fn, int page, int res, boo
 	m_imageInfoRecord.exifInfo.artist = QString(artist);
 	m_imageInfoRecord.exifInfo.thumbnail = QImage();
 	m_imageInfoRecord.exifDataValid = true;
-	uint32_t EmbedLen = 0;
+	uint32 EmbedLen = 0;
 	void*  EmbedBuffer;
 	if (TIFFGetField(tif, TIFFTAG_ICCPROFILE, &EmbedLen, &EmbedBuffer))
 	{
-- 
2.30.2

