Hi Alban,

I added the code to your driver. I shortly explain what I did and what 
needs to be done.

At line 245 I added three tables and 4 functions. All code is between 
#if 0/#endif so it should still compile.

1. The lookup tables are needed to set the font - the index is returned 
by some PLplot function. Replace the wxWidgets codes with corresponding 
QT codes.
2. ProcessString - this is the main function. It sets the font, 
calculates rotation and sheer and calls PSDrawText twice - the first 
time to calculate the text width and height, the second time to do the 
actual drawing. You need to do some changes here (marked with $$) - also 
the positioning, rotating and sheer need to be done.
3. PSDrawText - this is a generic function, where no changes are required.
4. PSSetFont - set the font. This is specific to your driver.
5. PSDrawTextToDC - determine text width and height and/or draw text 
depending on variable drawText. This is specific to your driver.

At line 781 I added the code to call the function ProcessString - PLplot 
does this via plD_esc_xxx. Just uncomment it (maybe change function 
name) after you finished your changes.

At line 881 I added the code necessary to enable the text processing. 
Just uncomment it.

I actually don't know where this functions should go in your case, since 
I don't fully understand the qt device structure. The following 
variables also need to be added to some class:

  /* font variables */
  static const int max_string_length=500;
  wxFont* m_font;
  bool underlined;
  double fontSize;
  double fontScale;
  wxCoord textWidth, textHeight, textDescent, textLeading;
  double yOffset;
  PLINT posX, posY;
  PLFLT rotation, cos_rot, sin_rot;
  PLFLT shear, cos_shear, sin_shear;
  PLFLT stride;

They must be accessible by all 4 functions.

I actually did a mistake in copying the code from the wxWidgets DC 
backend, since shearing is neglected there. Look at the function 
wxPLDevGC::ProcessString( PLStream* pls, EscText* args ) in 
wxwidgets_gc.cpp to get an idea how this works. I use an affine matrix 
there to do the transformation (rotation, shear, x,y-positioning).

I hope this framework is good enough for you to add the text processing 
capability to the qt driver in a short time. If you have any questions 
don't hesitate to ask.

Best Regards,
Werner Smekal

Alban Rochel wrote:
> Hi Werner,
>
> Werner Smekal wrote:
>   
>> Hi Alban,
>>
>>     
>>> "Another issue I have noticed for the Qt devices is they all seem to 
>>> use the
>>> Hershey fonts. Do you have any present plans to use the powerful Qt font
>>> and text layout facilities (e.g. for Complex text layout languages like
>>> Arabic, Hebrew, Hindi, Thai, etc.) to render text?"
>>> No, we don't, simply because the required effort was not worth it in
>>> QSAS. They don't look that bad on the Qt driver as it does antialiasing.
>>>  Maybe in a future development, but we have many other priorities on 
>>> QSAS!
>>>       
>> This is actually quite "easy". Looking at the psttf and cairo code I 
>> wrote some abstracted functions, since I actually use 3 different 
>> backends for the wxWidgets driver, all with it's own font handling code. 
>> It's more or less including one function and providing another function 
>> which does the actual "font rendering". I can add part of this code to 
>> the qt driver and write some comments where code is then missing, which 
>> is then to be filled out by you. As long qt knows unicode (100% sure) 
>> and knows how to rotate and shear fonts (quite sure) this should be one 
>> hour of work (and a day of debugging ;). If you don't object I'll try that.
>>     
>
> Well, if you have the courage to do that, I have no objection of course 
> and I will try to complete your work. Thanks! Feel free to contact me if 
> anything is unclear in my code.
>
>   
>> Regards,
>> Werner
>>     
>
> Alban
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Plplot-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>   


-- 
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria
DVR-Nr: 0005886

email: [email protected]
web:   http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office)
       +43-(0)1-58801-13469 (laboratory)
fax:   +43-(0)1-58801-13499


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to