Hi,

I would like very much to have the font size on qscintilla to accept real 
numbers (with 0.1 precision) instead of just integers. Looking on the source 
code, it is clear that the foundation is already ready and there are things to 
change.

I went ahead and did the small changes (and tested) and it works.

Are there any reasons to use integer point size instead of the floating one? (I 
understand that some platforms may not cope with floating point and as so may 
be rounded on them)

Best regards,
André
--- ./Qt4Qt5/qsciscintilla.cpp.orig	2014-03-14 11:12:58.000000000 -0300
+++ ./Qt4Qt5/qsciscintilla.cpp	2014-05-27 11:14:18.544454469 -0300
@@ -44,6 +44,7 @@
 #include "Qsci/qscilexer.h"
 #include "Qsci/qscistyle.h"
 #include "Qsci/qscistyledtext.h"
+#include "Qsci/qsciscintillabase.h"
 
 
 // Make sure these match the values in Scintilla.h.  We don't #include that
@@ -3281,7 +3281,7 @@
 void QsciScintilla::setStylesFont(const QFont &f, int style)
 {
     SendScintilla(SCI_STYLESETFONT, style, f.family().toLatin1().data());
-    SendScintilla(SCI_STYLESETSIZE, style, f.pointSize());
+    SendScintilla(SCI_STYLESETSIZEFRACTIONAL, style, long (f.pointSizeF() * QsciScintillaBase::SC_FONT_SIZE_MULTIPLIER));
 
     // Pass the Qt weight via the back door.
     SendScintilla(SCI_STYLESETWEIGHT, style, -f.weight());
--- ./Qt4Qt5/PlatQt.cpp.orig	2014-03-14 11:12:58.000000000 -0300
+++ ./Qt4Qt5/PlatQt.cpp	2014-05-27 10:42:55.036001565 -0300
@@ -129,7 +129,7 @@
     else
     {
         f->setFamily(fp.faceName);
-        f->setPointSize(fp.size);
+        f->setPointSizeF(fp.size);
 
         // See if the Qt weight has been passed via the back door.   Otherwise
         // map Scintilla weights to Qt weights ensuring that the SC_WEIGHT_*
@@ -991,6 +991,11 @@
     return QApplication::font().pointSize();
 }
 
+qreal Platform::DefaultFontSizeF()
+{
+    return QApplication::font().pointSizeF();
+}
+
 unsigned int Platform::DoubleClickTime()
 {
     return QApplication::doubleClickInterval();
--- ./Qt4Qt5/qscilexer.cpp.orig	2014-03-14 11:12:58.000000000 -0300
+++ ./Qt4Qt5/qscilexer.cpp	2014-05-27 10:58:10.123561397 -0300
@@ -416,7 +416,7 @@
             QFont f;
 
             f.setFamily(fdesc[0]);
-            f.setPointSize(fdesc[1].toInt());
+            f.setPointSizeF(fdesc[1].toDouble());
             f.setBold(fdesc[2].toInt());
             f.setItalic(fdesc[3].toInt());
             f.setUnderline(fdesc[4].toInt());
@@ -482,7 +482,7 @@
         QFont f;
 
         f.setFamily(fdesc[0]);
-        f.setPointSize(fdesc[1].toInt());
+        f.setPointSizeF(fdesc[1].toDouble());
         f.setBold(fdesc[2].toInt());
         f.setItalic(fdesc[3].toInt());
         f.setUnderline(fdesc[4].toInt());
@@ -541,7 +541,7 @@
 
         fdesc.clear();
         fdesc += f.family();
-        fdesc += fmt.arg(f.pointSize());
+        fdesc += fmt.arg(f.pointSizeF());
 
         // The casts are for Borland.
         fdesc += fmt.arg((int)f.bold());
@@ -579,7 +579,7 @@
     // Write the default font
     fdesc.clear();
     fdesc += defFont.family();
-    fdesc += fmt.arg(defFont.pointSize());
+    fdesc += fmt.arg(defFont.pointSizeF());
 
     // The casts are for Borland.
     fdesc += fmt.arg((int)defFont.bold());
--- ./Qt4Qt5/qscistyle.cpp.orig	2014-03-14 11:12:58.000000000 -0300
+++ ./Qt4Qt5/qscistyle.cpp	2014-05-27 11:19:16.396730804 -0300
@@ -98,8 +98,8 @@
             style_paper);
     sci->SendScintilla(QsciScintillaBase::SCI_STYLESETFONT, style_nr,
             style_font.family().toLatin1().data());
-    sci->SendScintilla(QsciScintillaBase::SCI_STYLESETSIZE, style_nr,
-            style_font.pointSize());
+    sci->SendScintilla(QsciScintillaBase::SCI_STYLESETSIZEFRACTIONAL, style_nr,
+            long (style_font.pointSizeF() * QsciScintillaBase::SC_FONT_SIZE_MULTIPLIER));
 
     // Pass the Qt weight via the back door.
     sci->SendScintilla(QsciScintillaBase::SCI_STYLESETWEIGHT, style_nr,
--- ./include/Platform.h.orig	2013-11-04 12:56:48.000000000 -0200
+++ ./include/Platform.h	2014-05-27 10:49:09.103325080 -0300
@@ -477,6 +477,7 @@
 	static ColourDesired ChromeHighlight();
 	static const char *DefaultFont();
 	static int DefaultFontSize();
+	static qreal DefaultFontSizeF();
 	static unsigned int DoubleClickTime();
 	static bool MouseButtonBounce();
 	static void DebugDisplay(const char *s);
_______________________________________________
QScintilla mailing list
[email protected]
http://www.riverbankcomputing.com/mailman/listinfo/qscintilla

Reply via email to