Why the font is smaller in the IDLgrBuffer ? [message #65337] |
Fri, 27 February 2009 07:50  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
I've a simple question...
I've an IDLgrView with some IDLgrTexts using a certain IDLgrFont and I
convert all of that to an IDLgrImage using an IDLgrBuffer.
The Buffer has the same dimensions of the View and I use the Draw and
Read methods.
On the result, the font of all texts is modified and smaller than the
original.
Why ?
How can I do to preserve the same font size ?
Thanks,
Bernat
|
|
|
|
|
Re: Why the font is smaller in the IDLgrBuffer ? [message #65417 is a reply to message #65337] |
Fri, 27 February 2009 13:05  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
bernat wrote:
> Hi Rick,
>
> I wrote a small routine to aproximate the font size in the buffer to
> the original font size.
> It's a crazy solution. See below...
>
> With your idea all results more easy.
> The only thing to do is set the RESOLUTION property on the
> IDLgrBuffer. Like that:
> resolution=[1d/!D.X_PX_CM,1d/!D.Y_PX_CM]
> oBuffer->SetProperty, RESOLUTION=resolution)
>
> The problem is that !D.XY_PX_CM only returns the approximate number of
> pixels per centimeter in the X and Y directions so the font size
> changes a little bit beacause the resolution is not exact.
>
> There is another way to get the DPI ?
>
> Thanks,
>
> Bernat
>
> ;----------------------------------------------------------- -------------------------
>
> PRO TEST_BUFFER_FONT, font_size, dimensions, $ ;;input
> final_font_size ;;output
>
> tt=SYSTIME(/SEC)
>
> oView=OBJ_NEW('IDlgrView', VIEWPLANE_RECT=[0,0,dimensions
> [0],dimensions[1]])
> oModel=OBJ_NEW('IDLgrModel')
> oModel->SetProperty, /DEPTH_WRITE_DISABLE
> oView->Add, oModel
>
> buff_font=OBJ_NEW('IDLgrFont', 'Helvetica', SIZE=font_size, THICK=2)
> buff_text=OBJ_NEW('IDLgrText', STRING='null text', FONT=buff_font,
> RECOMPUTE_DIMENSIONS=2)
> oModel->Add, buff_text
>
> oBuffer=OBJ_NEW('IDLgrBuffer', DIMENSIONS=dimensions)
> oBuffer->Draw, oView
>
> buff_text_dim=oBuffer->GetTextDimensions(buff_text)
>
> count=1.
> WHILE buff_text_dim[1] LT font_size DO BEGIN
> buff_font->SetProperty, SIZE=font_size+count
> oBuffer->Draw, oView
> buff_text_dim=oBuffer->GetTextDimensions(buff_text)
> count=count+1.
> ENDWHILE
>
> PRINT, 'Font size / size after buffer ', font_size, buff_text_dim[1]
>
> final_font_size=font_size+count
>
> OBJ_DESTROY, [oView, oModel, oBuffer, buff_font, buff_text]
>
> PRINT, 'TEST_BUFER_FONT TIME ', SYSTIME(/SEC)-tt
> END
Try:
IDL> minfo = obj_new('IDLsysMonitorInfo')
IDL> print, minfo->getResolutions()
0.026458333 0.026478617
0.026458333 0.026478617
IDL> obj_destroy, minfo
Mike
--
www.michaelgalloy.com
Associate Research Scientist
Tech-X Corporation
|
|
|
Re: Why the font is smaller in the IDLgrBuffer ? [message #65419 is a reply to message #65337] |
Fri, 27 February 2009 12:41  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Hi Rick,
I wrote a small routine to aproximate the font size in the buffer to
the original font size.
It's a crazy solution. See below...
With your idea all results more easy.
The only thing to do is set the RESOLUTION property on the
IDLgrBuffer. Like that:
resolution=[1d/!D.X_PX_CM,1d/!D.Y_PX_CM]
oBuffer->SetProperty, RESOLUTION=resolution)
The problem is that !D.XY_PX_CM only returns the approximate number of
pixels per centimeter in the X and Y directions so the font size
changes a little bit beacause the resolution is not exact.
There is another way to get the DPI ?
Thanks,
Bernat
;----------------------------------------------------------- -------------------------
PRO TEST_BUFFER_FONT, font_size, dimensions, $ ;;input
final_font_size ;;output
tt=SYSTIME(/SEC)
oView=OBJ_NEW('IDlgrView', VIEWPLANE_RECT=[0,0,dimensions
[0],dimensions[1]])
oModel=OBJ_NEW('IDLgrModel')
oModel->SetProperty, /DEPTH_WRITE_DISABLE
oView->Add, oModel
buff_font=OBJ_NEW('IDLgrFont', 'Helvetica', SIZE=font_size, THICK=2)
buff_text=OBJ_NEW('IDLgrText', STRING='null text', FONT=buff_font,
RECOMPUTE_DIMENSIONS=2)
oModel->Add, buff_text
oBuffer=OBJ_NEW('IDLgrBuffer', DIMENSIONS=dimensions)
oBuffer->Draw, oView
buff_text_dim=oBuffer->GetTextDimensions(buff_text)
count=1.
WHILE buff_text_dim[1] LT font_size DO BEGIN
buff_font->SetProperty, SIZE=font_size+count
oBuffer->Draw, oView
buff_text_dim=oBuffer->GetTextDimensions(buff_text)
count=count+1.
ENDWHILE
PRINT, 'Font size / size after buffer ', font_size, buff_text_dim[1]
final_font_size=font_size+count
OBJ_DESTROY, [oView, oModel, oBuffer, buff_font, buff_text]
PRINT, 'TEST_BUFER_FONT TIME ', SYSTIME(/SEC)-tt
END
|
|
|