PsPrint( " findfont\n" );
- double size = (double) m_font.GetPointSize();
+ float size = float(m_font.GetPointSize());
+ size = size * GetFontPointSizeAdjustment(DPI);
wxString buffer;
- buffer.Printf( "%f scalefont setfont\n", size * DEV2PS * m_scaleX );
+ buffer.Printf( "%f scalefont setfont\n", size * m_scaleX );
buffer.Replace( ",", "." );
PsPrint( buffer );
}
if (!fontToUse) fontToUse = &m_font;
- wxCHECK_RET( fontToUse, wxT("GetTextExtent: no font defined") );
+ const float fontSize =
+ fontToUse->GetPointSize() * GetFontPointSizeAdjustment(72.0);
if (string.empty())
{
* Produces accurate results for mono-spaced font
* such as Courier (aka wxMODERN) */
- int height = 12;
- if (fontToUse)
- {
- height = fontToUse->GetPointSize();
- }
if ( x )
- *x = strlen (strbuf) * height * 72 / 120;
+ *x = strlen (strbuf) * fontSize * 72.0 / 120.0;
if ( y )
- *y = (wxCoord) (height * 1.32); /* allow for descender */
+ *y = (wxCoord) (fontSize * 1.32); /* allow for descender */
if (descent) *descent = 0;
if (externalLeading) *externalLeading = 0;
#else
// VS: dirty, but is there any better solution?
double *pt;
pt = (double*) &m_underlinePosition;
- *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f;
+ *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontSize)) / 1000.0f;
pt = (double*) &m_underlineThickness;
- *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f;
+ *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontSize)) / 1000.0f;
}
/ string. they are given in 1/1000 of the size! */
long sum=0;
- wxCoord height=Size; /* by default */
+ float height=fontSize; /* by default */
unsigned char *p;
for(p=(unsigned char *)wxMBSTRINGCAST strbuf; *p; p++)
{
}
double widthSum = sum;
- widthSum *= Size;
+ widthSum *= fontSize;
widthSum /= 1000.0F;
/* add descender to height (it is usually a negative value) */
if ( x )
*x = (wxCoord)widthSum;
if ( y )
- *y = height;
+ *y = (wxCoord)height;
/* return other parameters */
if (descent)
{
if(lastDescender!=INT_MIN)
{
- *descent = (wxCoord)(((-lastDescender)/1000.0F) * Size); /* MATTHEW: forgot scale */
+ *descent = (wxCoord)(((-lastDescender)/1000.0F) * fontSize); /* MATTHEW: forgot scale */
}
else
{
}
}
- int w,h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
#if 0
if ( m_backgroundMode == wxSOLID )
{
gs_libGnomePrint->gnome_print_pango_layout( m_gpc, m_layout );
+ int w,h;
+ pango_layout_get_pixel_size( m_layout, &w, &h );
+
gs_libGnomePrint->gnome_print_grestore( m_gpc );
if (underlined)
pango_layout_set_attributes(m_layout, NULL);
}
- CalcBoundingBox (x + w, y + h);
+ CalcBoundingBox(x, y);
+ CalcBoundingBox(x + w, y + h);
}
void wxGnomePrinterDCImpl::Clear()
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
+ float size = pango_font_description_get_size( m_fontdesc );
+ size = size * GetFontPointSizeAdjustment(72.0);
+ pango_font_description_set_size( m_fontdesc, (gint)size );
+
pango_layout_set_font_description( m_layout, m_fontdesc );
}
}
const wxCharBuffer dataUTF8 = string.utf8_str();
#endif
- PangoFontDescription *desc = (theFont) ? theFont->GetNativeFontInfo()->description : m_fontdesc;
-
- gint oldSize = pango_font_description_get_size( desc );
- double size = oldSize;
- size = size * m_scaleY;
- pango_font_description_set_size( desc, (gint)size );
+ gint oldSize;
+ if ( theFont )
+ {
+ // scale the font and apply it
+ PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
+ float size = pango_font_description_get_size(desc);
+ size = size * GetFontPointSizeAdjustment(72.0);
+ pango_font_description_set_size(desc, (gint)size);
- // apply scaled font
- pango_layout_set_font_description( m_layout, desc );
+ pango_layout_set_font_description(m_layout, desc);
+ }
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
- int w, h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
-
-
- if (width)
- *width = (wxCoord)(w / m_scaleX);
- if (height)
- *height = (wxCoord)(h / m_scaleY);
+ int h;
+ pango_layout_get_pixel_size( m_layout, width, &h );
+ if ( height )
+ *height = h;
if (descent)
{
*descent = h - PANGO_PIXELS(baseline);
}
- // reset unscaled size
- pango_font_description_set_size( desc, oldSize );
+ if ( theFont )
+ {
+ // restore font and reset font's size back
+ pango_layout_set_font_description(m_layout, m_fontdesc);
- // reset unscaled font
- pango_layout_set_font_description( m_layout, m_fontdesc );
+ PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
+ pango_font_description_set_size(desc, oldSize);
+ }
}
void wxGnomePrinterDCImpl::DoGetSize(int* width, int* height) const
}
}
- int w,h;
-
- // Scale font description.
- gint oldSize = pango_font_description_get_size( m_fontdesc );
- double size = oldSize;
- size = size * m_scaleX;
- pango_font_description_set_size( m_fontdesc, (gint)size );
-
- // Actually apply scaled font.
- pango_layout_set_font_description( m_layout, m_fontdesc );
-
- pango_layout_get_pixel_size( m_layout, &w, &h );
-
- if ( m_backgroundMode == wxBRUSHSTYLE_SOLID )
- {
- unsigned char red = m_textBackgroundColour.Red();
- unsigned char blue = m_textBackgroundColour.Blue();
- unsigned char green = m_textBackgroundColour.Green();
- unsigned char alpha = m_textBackgroundColour.Alpha();
-
- double redPS = (double)(red) / 255.0;
- double bluePS = (double)(blue) / 255.0;
- double greenPS = (double)(green) / 255.0;
- double alphaPS = (double)(alpha) / 255.0;
-
- cairo_save(m_cairo);
- cairo_translate(m_cairo, xx, yy);
- cairo_set_source_rgba( m_cairo, redPS, greenPS, bluePS, alphaPS );
- cairo_rotate(m_cairo,angle*DEG2RAD);
- cairo_rectangle(m_cairo, 0, 0, w, h); // still in cairo units
- cairo_fill(m_cairo);
- cairo_restore(m_cairo);
- }
-
// Draw layout.
cairo_move_to (m_cairo, xx, yy);
if (fabs(angle) > 0.00001)
cairo_rotate( m_cairo, angle*DEG2RAD );
+ cairo_scale(m_cairo, m_scaleX, m_scaleY);
+
+ int w,h;
+ pango_layout_get_pixel_size( m_layout, &w, &h );
+
+ if ( m_backgroundMode == wxBRUSHSTYLE_SOLID )
+ {
+ unsigned char red = m_textBackgroundColour.Red();
+ unsigned char blue = m_textBackgroundColour.Blue();
+ unsigned char green = m_textBackgroundColour.Green();
+ unsigned char alpha = m_textBackgroundColour.Alpha();
+
+ double redPS = (double)(red) / 255.0;
+ double bluePS = (double)(blue) / 255.0;
+ double greenPS = (double)(green) / 255.0;
+ double alphaPS = (double)(alpha) / 255.0;
+
+ cairo_save(m_cairo);
+ cairo_set_source_rgba( m_cairo, redPS, greenPS, bluePS, alphaPS );
+ cairo_rectangle(m_cairo, 0, 0, w, h); // still in cairo units
+ cairo_fill(m_cairo);
+ cairo_restore(m_cairo);
+ }
+
pango_cairo_update_layout (m_cairo, m_layout);
pango_cairo_show_layout (m_cairo, m_layout);
pango_layout_set_attributes(m_layout, NULL);
}
- // Reset unscaled size.
- pango_font_description_set_size( m_fontdesc, oldSize );
-
- // Actually apply unscaled font.
- pango_layout_set_font_description( m_layout, m_fontdesc );
-
// Back to device units:
CalcBoundingBox (x, y);
CalcBoundingBox (x + w, y + h);
m_fontdesc = pango_font_description_copy( m_font.GetNativeFontInfo()->description );
+ float size = pango_font_description_get_size( m_fontdesc );
+ size = size * GetFontPointSizeAdjustment(72.0);
+ pango_font_description_set_size( m_fontdesc, (gint)size );
+
pango_layout_set_font_description( m_layout, m_fontdesc );
}
}
return;
}
+ cairo_save( m_cairo );
+ cairo_scale(m_cairo, m_scaleX, m_scaleY);
+
// Set layout's text
const wxUTF8Buf dataUTF8 = string.utf8_str();
- PangoFontDescription *desc = m_fontdesc;
- if (theFont) desc = theFont->GetNativeFontInfo()->description;
-
- gint oldSize = pango_font_description_get_size( desc );
- double size = oldSize;
- size = size * m_scaleY;
- pango_font_description_set_size( desc, (gint)size );
+ gint oldSize;
+ if ( theFont )
+ {
+ // scale the font and apply it
+ PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
+ float size = pango_font_description_get_size(desc);
+ size = size * GetFontPointSizeAdjustment(72.0);
+ pango_font_description_set_size(desc, (gint)size);
- // apply scaled font
- pango_layout_set_font_description( m_layout, desc );
+ pango_layout_set_font_description(m_layout, desc);
+ }
pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) );
- int w, h;
- pango_layout_get_pixel_size( m_layout, &w, &h );
-
- if (width)
- *width = wxRound( (double)w / m_scaleX * m_PS2DEV );
- if (height)
- *height = wxRound( (double)h / m_scaleY * m_PS2DEV );
+ int h;
+ pango_layout_get_pixel_size( m_layout, width, &h );
+ if ( height )
+ *height = h;
if (descent)
{
PangoLayoutIter *iter = pango_layout_get_iter(m_layout);
int baseline = pango_layout_iter_get_baseline(iter);
pango_layout_iter_free(iter);
- *descent = wxRound( (h - PANGO_PIXELS(baseline)) * m_PS2DEV );
+ *descent = h - PANGO_PIXELS(baseline);
}
- // Reset unscaled size.
- pango_font_description_set_size( desc, oldSize );
+ if ( theFont )
+ {
+ // restore font and reset font's size back
+ pango_layout_set_font_description(m_layout, m_fontdesc);
+
+ PangoFontDescription *desc = theFont->GetNativeFontInfo()->description;
+ pango_font_description_set_size(desc, oldSize);
+ }
- // Reset unscaled font.
- pango_layout_set_font_description( m_layout, m_fontdesc );
+ cairo_restore( m_cairo );
}
void wxGtkPrinterDCImpl::DoGetSize(int* width, int* height) const