Hi there. I'm a new in the sourceforge, and do not know how to send a
patch. So I just created a new post.
Joxy LookAndFeel do not draw UTF-8 strings properly as QString(char
chars) constructor creates a new
string from ANCII charset. To create QString from UTF-8 charset use
QString::fromUtf8(char utf8)
instead. Here is a fixed joxy_utils_JoxyGraphics.cpp file:
/** * This file is a part of the Joxy Look and Feel for Java Swing. */#include"joxy_utils_JoxyGraphics.h"#include<QtGui/QApplication>#include<QtGui/qcolor.h>#include<QtGui/qimage.h>#include<QtGui/qpainter.h>#include<QtCore/qstring.h>intargc=0;char**argv=NULL;QApplicationa(argc,argv);jmethodIDmid;JNIEXPORTvoidJNICALLJava_joxy_utils_JoxyGraphics_initializeNative(JNIEnv*env,jclasscl){jclasscls=env->FindClass("java/awt/image/BufferedImage");if(cls==NULL){printf("Couldn't find class BufferedImage\n");return;}mid=env->GetMethodID(cls,"setRGB","(III)V");if(mid==NULL){printf("Couldn't find method setRGB(int)\n");return;}}JNIEXPORTvoidJNICALLJava_joxy_utils_JoxyGraphics_drawStringNative(JNIEnv*env,jclasscl,jstringstr,jobjectimage,jintwidth,jintheight,jstringfontname,jintfontsize,jintstyle,jintcolor){QImageqimage(width,height,QImage::Format_ARGB32);QColorqcolor=QColor::fromRgb(color);qcolor.setAlpha(0);qimage.fill(qcolor);QPainterpainter(&qimage);painter.setPen(QColor::fromRgb(color));constchar*cfontname=env->GetStringUTFChars(fontname,JNI_FALSE);boolitalic=(style>=2);boolbold=(style%2==1);painter.setFont(QFont(cfontname,fontsize,(bold?75:50),italic));constchar*cstr=env->GetStringUTFChars(str,JNI_FALSE);painter.drawText(0,0,width+10,height,Qt::AlignLeft,QString::fromUtf8(cstr));env->ReleaseStringUTFChars(str,cfontname);env->ReleaseStringUTFChars(str,cstr);// TODO do this with the int[] version, so the for-loop is unnecessaryfor(inti=0;i<width;i++){for(intj=0;j<height;j++){intpixel=qimage.pixel(i,j);// if it is transparent, it is useless to copy it...if(pixel!=0){env->CallVoidMethod(image,mid,i,j,pixel);}}}}
Kind regards,
Votaily
Last edit: Thom Castermans 2012-09-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As you can see I edited your post, so that the code is better readable :)
Thanks a bunch for your patch! I will test this tomorrow and add it to the unstable version of Joxy if it works, but I guess you are a more experienced C-programmer than both Willem and I are, so there will probably be no problem. Of course, if it works, I will add your name to the file, because you deserve some credit. Can I just use "Vitaliy" or "Votaily" with a link to your SourceForge profile?
Kind regards,
Thom
Last edit: Thom Castermans 2012-09-10
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It was intended that every logged-in user is able to file bug reports, but it seems we set the permissions incorrectly for the bug tracker.
Could you please verify that you are now also able to send reports?
Thanks!
Willem
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there. I'm a new in the sourceforge, and do not know how to send a
patch. So I just created a new post.
Joxy LookAndFeel do not draw UTF-8 strings properly as QString(char
chars) constructor creates a new
string from ANCII charset. To create QString from UTF-8 charset use
QString::fromUtf8(char utf8)
instead. Here is a fixed joxy_utils_JoxyGraphics.cpp file:
Kind regards,
Votaily
Last edit: Thom Castermans 2012-09-10
Hi Vitaliy,
As you can see I edited your post, so that the code is better readable :)
Thanks a bunch for your patch! I will test this tomorrow and add it to the unstable version of Joxy if it works, but I guess you are a more experienced C-programmer than both Willem and I are, so there will probably be no problem. Of course, if it works, I will add your name to the file, because you deserve some credit. Can I just use "Vitaliy" or "Votaily" with a link to your SourceForge profile?
Kind regards,
Thom
Last edit: Thom Castermans 2012-09-10
First of all, sorry for the delay.
I compiled the new file in, and indeed it works perfectly. So we will commit it and the fix will appear in Joxy 0.1.1 :-)
(Side note: We also don't know how people are supposed to send in patches on SourceForge, we are new here too... But this method works fine I think.)
Again, thank you very much for your help!
Willem
Willem: the bugtracker can be used as a patch tracker too.
Anyway, it would be great if the users can also report bugs in the bugtracker, because in my opinion tracking bugs using discussion is not very handy.
Hello Lukas,
It was intended that every logged-in user is able to file bug reports, but it seems we set the permissions incorrectly for the bug tracker.
Could you please verify that you are now also able to send reports?
Thanks!
Willem
Thank you Willem,
I can confirm there's now an option to create a new ticket. I haven't tried to report one though.