summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-05-18 12:01:49 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-05-18 12:01:49 +0000
commit9c48ea8482540a02be180daddb0b12752fb90daf (patch)
tree155a2b5a149930ff9cc843d4358b5319f5cdf89d /canvas
parent2652c7dda9b52db25cc06f2c99a91a853072520c (diff)
CWS-TOOLING: integrate CWS cairocanvastext01
2009-05-12 07:10:00 +0200 mox r271795 : Rename ::GetLayoutData() to ::GetSysTextLayoutData() to avoid build breakage in sc module. 2009-05-11 23:40:57 +0200 mox r271794 : merge fixes (again). These files should have been removed by the rebase. 2009-05-11 20:17:44 +0200 mox r271791 : fix build breakage on UNX 2009-05-11 16:53:15 +0200 mox r271779 : Documentation fix 2009-05-11 16:49:16 +0200 mox r271778 : merge fixes 2009-05-11 14:10:36 +0200 mox r271769 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@271427 (milestone: DEV300:m47) 2009-05-11 10:55:11 +0200 mox r271760 : merge fixes 2009-05-11 10:49:44 +0200 mox r271759 : manual merge to DEV300_m47 2009-05-11 10:42:11 +0200 mox r271758 : merge fixes 2009-05-11 10:29:16 +0200 mox r271757 : Manual merge to DEV300_m47 2009-05-11 10:21:13 +0200 mox r271756 : manual merge to DEV300_m47 2009-05-11 10:10:29 +0200 mox r271755 : manual merge to DEV300_m47 2009-05-11 10:01:33 +0200 mox r271754 : Manual merge to DEV300_m47 2009-05-11 09:59:30 +0200 mox r271753 : manual merge to DEV300_m47 2009-05-11 09:57:33 +0200 mox r271752 : merge fixes 2009-05-11 09:56:05 +0200 mox r271751 : merge fixes 2009-05-11 09:53:26 +0200 mox r271749 : Manual merge to DEV300_m47 2009-05-11 09:49:34 +0200 mox r271748 : manual merge to DEV300_m47 2009-05-11 09:43:20 +0200 mox r271747 : manual merge to DEV300_m47 2009-05-11 09:30:10 +0200 mox r271745 : Manual merge to DEV300_m47 2009-05-11 09:28:59 +0200 mox r271744 : manual merge to DEV300_m47 2009-05-11 09:24:49 +0200 mox r271743 : Fix to merge 2009-05-11 09:21:55 +0200 mox r271742 : Manual merge to DEV300_m47 2009-05-11 09:18:13 +0200 mox r271741 : merge fixes 2009-05-11 09:00:50 +0200 mox r271739 : Manual merge to DEV300_m47 2009-05-09 13:26:10 +0200 mox r271734 : cleanup 2009-05-09 13:17:22 +0200 mox r271733 : WNT build fixes 2009-05-09 09:23:59 +0200 mox r271732 : Implement proper cross-platform font width calculation Implement faux bold support 2009-02-21 19:47:08 +0100 mox r268339 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@267171 (milestone: DEV300:m41) 2009-01-19 21:51:21 +0100 mox r266530 : Fix compilation on win32 2009-01-19 21:37:20 +0100 mox r266529 : Fix typo 2009-01-19 21:35:28 +0100 mox r266528 : Better debug 2009-01-19 21:13:30 +0100 mox r266527 : Win32 fixes for proper text rendering 2009-01-19 21:12:56 +0100 mox r266526 : Win32 fixes for proper text rendering 2008-12-27 13:04:05 +0100 mox r265814 : configure fixes 2008-12-27 11:37:00 +0100 mox r265813 : x86_64 works only with system-cairo 2008-12-26 20:02:32 +0100 mox r265809 : Use the fix for 64bit builds 2008-12-25 16:58:11 +0100 mox r265802 : Fix build breaker on WNT 2008-12-24 23:04:58 +0100 mox r265801 : Unbreak build after rebase. 2008-12-23 18:52:32 +0100 mox r265790 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@265758 (milestone: DEV300:m38) 2008-12-23 18:23:09 +0100 mox r265789 : Fix the fix 2008-12-23 18:21:27 +0100 mox r265788 : Fix OS2 stuff 2008-12-11 19:50:40 +0100 mox r265354 : Fix build breaker on Mac 2008-12-09 22:00:53 +0100 mox r265139 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@264807 (milestone: DEV300:m37) 2008-12-08 23:02:32 +0100 thb r265052 : Removed outdated parts from readme 2008-12-08 22:26:54 +0100 mox r265051 : cleanup 2008-12-07 19:55:31 +0100 mox r264967 : Fix for non-intel processors. 2008-12-07 19:47:11 +0100 mox r264963 : sysdata fixes 2008-12-07 19:23:27 +0100 mox r264959 : Sysdata fixes 2008-12-07 19:01:48 +0100 mox r264958 : Fix sysdata usage 2008-12-07 11:41:33 +0100 mox r264951 : sysdata fixes 2008-12-07 11:38:32 +0100 mox r264950 : sysdata fixes 2008-12-06 23:15:06 +0100 mox r264947 : Try to fix error: __sync_val_compare_and_swap_4 2008-12-06 23:09:30 +0100 mox r264945 : Revert unnecessary change. 2008-12-06 23:04:40 +0100 mox r264944 : Use pre/postx from tools module. 2008-12-06 22:49:08 +0100 mox r264943 : Use proper pre/post includes. 2008-12-06 22:48:03 +0100 mox r264942 : Use pre/postx from tools module. 2008-12-06 22:24:10 +0100 mox r264941 : Fix build breaker. 2008-12-06 21:55:46 +0100 mox r264940 : Make pre/postx.h properly available 2008-12-06 21:54:23 +0100 mox r264939 : Make pre/postx.h properly available. 2008-12-06 21:43:09 +0100 mox r264938 : Try to fix error: __sync_val_compare_and_swap_4 2008-12-06 21:12:18 +0100 mox r264937 : Remove obsolete pre-built binaries 2008-12-06 21:07:40 +0100 mox r264936 : WNT: do not hardcode pixman version in cairo build 2008-12-06 19:26:44 +0100 mox r264934 : Revert pixman upgrade. 2008-12-06 18:35:14 +0100 mox r264933 : Fix build breaker 2008-12-06 18:31:11 +0100 mox r264932 : Use static pixman lib on unx/32bit to avoid linking problems 2008-12-06 17:22:52 +0100 mox r264930 : Update pixman to 0.13.2 2008-12-06 13:30:41 +0100 mox r264928 : Fix accidentally changed property 2008-12-06 13:09:00 +0100 mox r264927 : Fix accidental prop changes 2008-12-06 12:40:08 +0100 mox r264926 : Fix build breaker on Win32 2008-12-06 12:39:22 +0100 mox r264925 : Fix build breaker on Win32 2008-12-06 12:30:23 +0100 mox r264924 : Fix build breakers on win32 2008-12-06 11:45:33 +0100 mox r264923 : revert. 2008-12-06 11:43:05 +0100 mox r264922 : Try to fix header include problems on WNT 2008-12-06 09:57:35 +0100 mox r264921 : Cleanup accidental props 2008-11-29 14:43:51 +0100 mox r264580 : Move headers around to make all platforms compile 2008-11-29 14:41:59 +0100 mox r264579 : WaE fixes for X11 2008-11-29 13:13:49 +0100 mox r264578 : Fix build breaker on linux 2008-11-29 12:21:03 +0100 mox r264577 : Fix build breaker 2008-11-29 12:13:50 +0100 mox r264576 : Try to fix build breaker 2008-11-28 22:51:27 +0100 mox r264573 : Revert header includes to common style 2008-11-18 18:59:15 +0100 mox r263794 : Fix build breaker. 2008-11-17 20:28:19 +0100 mox r263740 : Revert most configure hacks 2008-11-17 20:12:51 +0100 mox r263739 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@263288 (milestone: DEV300:m35) 2008-11-14 21:22:22 +0100 mox r263698 : ZLIB_FIX define set 2008-11-14 18:48:22 +0100 mox r263694 : hardcode zlib paths 2008-11-14 16:23:07 +0100 mox r263683 : Fix typo 2008-11-13 20:16:13 +0100 mox r263662 : WaE fix 2008-11-13 19:44:29 +0100 mox r263661 : Properly include zlib headers for win32 2008-11-12 20:05:51 +0100 mox r263610 : Add debugging code. 2008-11-10 19:44:35 +0100 mox r263537 : Try to fix build breaker 2008-11-09 22:34:35 +0100 mox r263504 : Remove accidentally added svn:ignore properties. 2008-11-09 22:33:21 +0100 mox r263503 : prop should be actually deleted. 2008-11-09 22:30:06 +0100 mox r263502 : props should be empty. 2008-11-09 22:23:22 +0100 mox r263501 : Try fix props again... 2008-11-09 22:11:26 +0100 mox r263500 : try to fix svn:ignore 2008-11-09 21:30:01 +0100 mox r263499 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@262620 (milestone: DEV300:m34) 2008-11-09 20:30:55 +0100 mox r263498 : add missing cairo patch 2008-11-09 10:56:33 +0100 mox r263494 : Resync cairo module with cws cairosource01 2008-11-01 09:32:19 +0100 mox r262870 : CWS-TOOLING: rebase CWS cairocanvastext01 to trunk@262620 (milestone: DEV300:m34) 2008-10-26 20:55:48 +0100 mox r262663 : Fix build breaker 2008-10-25 13:10:00 +0200 mox r262662 : CWS rebase to m33 2008-10-12 19:47:56 +0200 mox r262170 : Migrate CWS cairocanvastext01 to SVN.
Diffstat (limited to 'canvas')
-rw-r--r--canvas/overview.txt11
-rw-r--r--canvas/source/cairo/cairo_canvashelper_text.cxx12
-rw-r--r--canvas/source/cairo/cairo_quartz_cairo.cxx3
-rw-r--r--canvas/source/cairo/cairo_quartz_cairo.hxx4
-rw-r--r--canvas/source/cairo/cairo_textlayout.cxx302
-rw-r--r--canvas/source/cairo/cairo_textlayout.hxx7
-rw-r--r--canvas/source/cairo/cairo_win32_cairo.cxx37
-rw-r--r--canvas/source/cairo/cairo_win32_cairo.hxx2
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.cxx38
-rw-r--r--canvas/source/cairo/cairo_xlib_cairo.hxx4
-rw-r--r--canvas/source/cairo/makefile.mk10
-rw-r--r--canvas/source/cairo/postx.h81
-rw-r--r--canvas/source/cairo/prex.h86
13 files changed, 352 insertions, 245 deletions
diff --git a/canvas/overview.txt b/canvas/overview.txt
index 0f9ada46dac9..5d508b04bc45 100644
--- a/canvas/overview.txt
+++ b/canvas/overview.txt
@@ -1,13 +1,10 @@
The new OOo Canvas Framework
============================
-The new OpenOffice.org canvas framework is the successor of the
-system GUI and graphics backend VCL. It is planned for the
-OpenOffice.org 2.0 release, and currently ready in a first developer
-version, with X11, Java, and DirectX/GDI+ backends. This means, that
-basic functionality is available, supplying just as much features as
-to provide a VCL-equivalent feature set (except proper BiDi/CTL
-support).
+The new OpenOffice.org canvas framework is the successor of the system
+GUI and graphics backend VCL. Basic functionality is available,
+supplying just as much features as necessary to provide a
+VCL-equivalent feature set (except proper BiDi/CTL support).
For migration purposes, the new canvas and VCL will be shipped with
OpenOffice.org for quite some time, allowing a step-by-step adaptation
diff --git a/canvas/source/cairo/cairo_canvashelper_text.cxx b/canvas/source/cairo/cairo_canvashelper_text.cxx
index a38553055ae0..ac530f5d4632 100644
--- a/canvas/source/cairo/cairo_canvashelper_text.cxx
+++ b/canvas/source/cairo/cairo_canvashelper_text.cxx
@@ -343,10 +343,12 @@ namespace cairocanvas
// TODO(F2): alpha
mpVirtualDevice->SetLayoutMode( nLayoutMode );
- mpVirtualDevice->DrawText( aOutpos,
- text.Text,
- ::canvas::tools::numeric_cast<USHORT>(text.StartPosition),
- ::canvas::tools::numeric_cast<USHORT>(text.Length) );
+
+ OSL_TRACE(":cairocanvas::CanvasHelper::drawText(O,t,f,v,r,d): %s", ::rtl::OUStringToOString( text.Text.copy( text.StartPosition, text.Length ),
+ RTL_TEXTENCODING_UTF8 ).getStr());
+
+ TextLayout* pTextLayout = new TextLayout(text, textDirection, 0, CanvasFont::Reference(dynamic_cast< CanvasFont* >( xFont.get() )), mpSurfaceProvider);
+ pTextLayout->draw( mpSurface, *mpVirtualDevice, aOutpos, viewState, renderState );
}
return uno::Reference< rendering::XCachedPrimitive >(NULL);
@@ -384,7 +386,7 @@ namespace cairocanvas
return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary
// TODO(F2): What about the offset scalings?
- pTextLayout->draw( *mpVirtualDevice, aOutpos, viewState, renderState );
+ pTextLayout->draw( mpSurface, *mpVirtualDevice, aOutpos, viewState, renderState );
}
}
else
diff --git a/canvas/source/cairo/cairo_quartz_cairo.cxx b/canvas/source/cairo/cairo_quartz_cairo.cxx
index 2575c206f294..a3c6c9bba255 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.cxx
+++ b/canvas/source/cairo/cairo_quartz_cairo.cxx
@@ -37,6 +37,9 @@
************************************************************************/
#include <osl/diagnose.h>
+#include <vcl/sysdata.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/virdev.hxx>
#include "cairo_cairo.hxx"
diff --git a/canvas/source/cairo/cairo_quartz_cairo.hxx b/canvas/source/cairo/cairo_quartz_cairo.hxx
index 31659bbf79f5..fe748d26640a 100644
--- a/canvas/source/cairo/cairo_quartz_cairo.hxx
+++ b/canvas/source/cairo/cairo_quartz_cairo.hxx
@@ -38,10 +38,6 @@
#include <cairo-quartz.h>
#include "postmac.h"
-#include <vcl/sysdata.hxx>
-#include <vcl/bitmap.hxx>
-#include <vcl/virdev.hxx>
-
namespace cairo {
class QuartzSurface : public Surface
diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 5078289a9c40..f822749cab20 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -31,6 +31,8 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_canvas.hxx"
+#include <math.h>
+
#include <canvas/debug.hxx>
#include <canvas/verbosetrace.hxx>
#include <tools/diagnose_ex.h>
@@ -38,6 +40,13 @@
#include <vcl/metric.hxx>
#include <vcl/virdev.hxx>
+#ifdef WNT
+#include <tools/prewin.h>
+#include <windows.h>
+#include <tools/postwin.h>
+#endif
+#include <vcl/sysdata.hxx>
+
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/numeric/ftools.hxx>
@@ -46,6 +55,17 @@
#include "cairo_textlayout.hxx"
#include "cairo_spritecanvas.hxx"
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+# include "cairo_quartz_cairo.hxx"
+#elif defined CAIRO_HAS_WIN32_SURFACE
+# include "cairo_win32_cairo.hxx"
+# include <cairo-win32.h>
+#elif defined CAIRO_HAS_XLIB_SURFACE
+# include "cairo_xlib_cairo.hxx"
+# include <cairo-ft.h>
+#else
+# error Native API needed.
+#endif
using namespace ::cairo;
using namespace ::com::sun::star;
@@ -292,6 +312,11 @@ namespace cairocanvas
cairo_set_font_size( pCairo, aFontRequest.CellSize );
}
+ /** TextLayout:draw
+ *
+ * This function uses the "toy" api of the cairo library
+ *
+ **/
bool TextLayout::draw( Cairo* pCairo )
{
::osl::MutexGuard aGuard( m_aMutex );
@@ -310,6 +335,248 @@ namespace cairocanvas
return true;
}
+
+ /**
+ * TextLayout::isCairoRenderable
+ *
+ * Features currenly not supported by Cairo (VCL rendering is used as fallback):
+ * - vertical glyphs
+ *
+ * @return true, if text/font can be rendered with cairo
+ **/
+ bool TextLayout::isCairoRenderable(SystemFontData aSysFontData) const
+ {
+#if defined UNX && !defined QUARTZ
+ // is font usable?
+ if (!aSysFontData.nFontId) return false;
+#endif
+
+ // vertical glyph rendering is not supported in cairo for now
+ if (aSysFontData.bVerticalCharacterType) {
+ OSL_TRACE(":cairocanvas::TextLayout::isCairoRenderable(): ***************** VERTICAL CHARACTER STYLE!!! ****************");
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * TextLayout::draw
+ *
+ * Cairo-based text rendering. Draw text directly on the cairo surface with cairo fonts.
+ * Avoid using VCL VirtualDevices for that, bypassing VCL DrawText functions, when possible
+ *
+ * Note: some text effects are not rendered due to lacking generic canvas or cairo canvas
+ * implementation. See issues 92657, 92658, 92659, 92660, 97529
+ *
+ * @return true, if successful
+ **/
+ bool TextLayout::draw( SurfaceSharedPtr& pSurface,
+ OutputDevice& rOutDev,
+ const Point& rOutpos,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState ) const
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ SystemTextLayoutData aSysLayoutData;
+#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
+ LOGFONTW logfont;
+#endif
+ setupLayoutMode( rOutDev, mnTextDirection );
+
+ // TODO(P2): cache that
+ ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
+
+ if( maLogicalAdvancements.getLength() )
+ {
+ setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState );
+
+ // TODO(F3): ensure correct length and termination for DX
+ // array (last entry _must_ contain the overall width)
+ }
+
+ aSysLayoutData = rOutDev.GetSysTextLayoutData(rOutpos, maText.Text,
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.Length),
+ maLogicalAdvancements.getLength() ? aOffsets.get() : NULL);
+
+ // The ::GetSysTextLayoutData(), i.e. layouting of text to glyphs can change the font being used.
+ // The fallback checks need to be done after final font is known.
+ if (!isCairoRenderable(aSysLayoutData.aSysFontData)) // VCL FALLBACKS
+ {
+ OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): VCL FALLBACK %s%s%s%s - %s",
+ maLogicalAdvancements.getLength() ? "ADV " : "",
+ aSysLayoutData.aSysFontData.bAntialias ? "AA " : "",
+ aSysLayoutData.aSysFontData.bFakeBold ? "FB " : "",
+ aSysLayoutData.aSysFontData.bFakeItalic ? "FI " : "",
+ ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ),
+ RTL_TEXTENCODING_UTF8 ).getStr());
+
+ if (maLogicalAdvancements.getLength()) // VCL FALLBACK - with glyph advances
+ {
+ rOutDev.DrawTextArray( rOutpos, maText.Text, aOffsets.get(),
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
+ return true;
+ }
+ else // VCL FALLBACK - without advances
+ {
+ rOutDev.DrawText( rOutpos, maText.Text,
+ ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
+ ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
+ return true;
+ }
+ }
+
+ if (aSysLayoutData.rGlyphData.empty()) return false; //??? false?
+
+ /**
+ * Setup platform independent glyph vector into cairo-based glyphs vector.
+ **/
+
+ // setup glyphs
+ std::vector<cairo_glyph_t> cairo_glyphs;
+ cairo_glyphs.reserve( 256 );
+
+ for( int nStart = 0; nStart < (int) aSysLayoutData.rGlyphData.size(); nStart++ )
+ {
+ cairo_glyph_t aGlyph;
+ SystemGlyphData systemGlyph = aSysLayoutData.rGlyphData.at(nStart);
+ aGlyph.index = systemGlyph.index;
+#ifdef CAIRO_HAS_WIN32_SURFACE
+ // Cairo requires standard glyph indexes (ETO_GLYPH_INDEX), while vcl/win/* uses ucs4 chars.
+ // Convert to standard indexes
+ aGlyph.index = cairo::ucs4toindex((unsigned int) aGlyph.index, aSysLayoutData.aSysFontData.hFont);
+#endif
+ aGlyph.x = systemGlyph.x;
+ aGlyph.y = systemGlyph.y;
+ cairo_glyphs.push_back(aGlyph);
+ }
+
+ if (cairo_glyphs.empty()) return true; //true or false??
+
+ /**
+ * Setup font
+ **/
+ cairo_font_face_t* font_face = NULL;
+
+#ifdef CAIRO_HAS_QUARTZ_SURFACE
+ // TODO: use cairo_quartz_font_face_create_for_cgfont(cgFont)
+ // when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
+ font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) aSysLayoutData.aSysFontData.aATSUFontID);
+
+#elif defined CAIRO_HAS_WIN32_SURFACE
+ #if (OSL_DEBUG_LEVEL > 1)
+ GetObjectW( aSysLayoutData.aSysFontData.hFont, sizeof(logfont), &logfont );
+ #endif
+ // Note: cairo library uses logfont fallbacks when lfEscapement, lfOrientation and lfWidth are not zero.
+ // VCL always has non-zero value for lfWidth
+ font_face = cairo_win32_font_face_create_for_hfont(aSysLayoutData.aSysFontData.hFont);
+
+#elif defined CAIRO_HAS_XLIB_SURFACE
+ font_face = cairo_ft_font_face_create_for_ft_face((FT_Face)aSysLayoutData.aSysFontData.nFontId,
+ aSysLayoutData.aSysFontData.nFontFlags);
+#else
+# error Native API needed.
+#endif
+
+ CairoSharedPtr pSCairo = pSurface->getCairo();
+
+ cairo_set_font_face( pSCairo.get(), font_face);
+
+ // create default font options. cairo_get_font_options() does not retrieve the surface defaults,
+ // only what has been set before with cairo_set_font_options()
+ cairo_font_options_t* options = cairo_font_options_create();
+ if (aSysLayoutData.aSysFontData.bAntialias) {
+ // CAIRO_ANTIALIAS_GRAY provides more similar result to VCL Canvas,
+ // so we're not using CAIRO_ANTIALIAS_SUBPIXEL
+ cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
+ }
+ cairo_set_font_options( pSCairo.get(), options);
+
+ // Font color
+ Color mTextColor = rOutDev.GetTextColor();
+ cairo_set_source_rgb(pSCairo.get(),
+ mTextColor.GetRed()/255.0,
+ mTextColor.GetGreen()/255.0,
+ mTextColor.GetBlue()/255.0);
+
+ // Font rotation and scaling
+ cairo_matrix_t m;
+ Font aFont = rOutDev.GetFont();
+ FontMetric aMetric( rOutDev.GetFontMetric(aFont) );
+ long nWidth = 0;
+
+ // width calculation is deep magic and platform/font dependant.
+ // width == 0 means no scaling, and usually width == height means the same.
+ // Other values mean horizontal scaling (narrow or stretching)
+ // see issue #101566
+
+ //proper scale calculation across platforms
+ if (aFont.GetWidth() == 0) {
+ nWidth = aFont.GetHeight();
+ } else {
+ // any scaling needs to be relative to the platform-dependent definition
+ // of width of the font
+ nWidth = aFont.GetHeight() * aFont.GetWidth() / aMetric.GetWidth();
+ }
+
+ cairo_matrix_init_identity(&m);
+
+ if (aSysLayoutData.orientation) cairo_matrix_rotate(&m, (3600 - aSysLayoutData.orientation) * M_PI / 1800.0);
+
+ cairo_matrix_scale(&m, nWidth, aFont.GetHeight());
+
+ //faux italics
+ if (aSysLayoutData.aSysFontData.bFakeItalic) m.xy = -m.xx * 0x6000L / 0x10000L;
+
+ cairo_set_font_matrix(pSCairo.get(), &m);
+
+ OSL_TRACE("\r\n:cairocanvas::TextLayout::draw(S,O,p,v,r): Size:(%d,%d), W:%d->%d, Pos (%d,%d), G(%d,%d,%d) %s%s%s%s || Name:%s - %s",
+ aFont.GetWidth(),
+ aFont.GetHeight(),
+ aMetric.GetWidth(),
+ nWidth,
+ (int) rOutpos.X(),
+ (int) rOutpos.Y(),
+ cairo_glyphs[0].index, cairo_glyphs[1].index, cairo_glyphs[2].index,
+ maLogicalAdvancements.getLength() ? "ADV " : "",
+ aSysLayoutData.aSysFontData.bAntialias ? "AA " : "",
+ aSysLayoutData.aSysFontData.bFakeBold ? "FB " : "",
+ aSysLayoutData.aSysFontData.bFakeItalic ? "FI " : "",
+#if (defined CAIRO_HAS_WIN32_SURFACE) && (OSL_DEBUG_LEVEL > 1)
+ ::rtl::OUStringToOString( reinterpret_cast<const sal_Unicode*> (logfont.lfFaceName), RTL_TEXTENCODING_UTF8 ).getStr(),
+#else
+ ::rtl::OUStringToOString( aFont.GetName(), RTL_TEXTENCODING_UTF8 ).getStr(),
+#endif
+ ::rtl::OUStringToOString( maText.Text.copy( maText.StartPosition, maText.Length ),
+ RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+
+ cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
+
+ //faux bold
+ if (aSysLayoutData.aSysFontData.bFakeBold) {
+ double bold_dx = 0.5 * sqrt( 0.7 * aFont.GetHeight() );
+ int total_steps = 2 * ((int) (bold_dx + 0.5));
+
+ // loop to draw the text for every half pixel of displacement
+ for (int nSteps = 0; nSteps < total_steps; nSteps++) {
+ for(int nGlyphIdx = 0; nGlyphIdx < (int) cairo_glyphs.size(); nGlyphIdx++) {
+ cairo_glyphs[nGlyphIdx].x += bold_dx * nSteps / total_steps;
+ }
+ cairo_show_glyphs(pSCairo.get(), &cairo_glyphs[0], cairo_glyphs.size());
+ }
+ OSL_TRACE(":cairocanvas::TextLayout::draw(S,O,p,v,r): FAKEBOLD - dx:%d", (int) bold_dx);
+ }
+
+ cairo_restore( pSCairo.get() );
+ cairo_font_face_destroy(font_face);
+ return true;
+ }
+
+
namespace
{
class OffsetTransformer
@@ -363,41 +630,6 @@ namespace cairocanvas
OffsetTransformer( aMatrix ) );
}
- bool TextLayout::draw( OutputDevice& rOutDev,
- const Point& rOutpos,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState ) const
- {
- ::osl::MutexGuard aGuard( m_aMutex );
-
- setupLayoutMode( rOutDev, mnTextDirection );
-
- if( maLogicalAdvancements.getLength() )
- {
- // TODO(P2): cache that
- ::boost::scoped_array< sal_Int32 > aOffsets(new sal_Int32[maLogicalAdvancements.getLength()]);
- setupTextOffsets( aOffsets.get(), maLogicalAdvancements, viewState, renderState );
-
- // TODO(F3): ensure correct length and termination for DX
- // array (last entry _must_ contain the overall width)
-
- rOutDev.DrawTextArray( rOutpos,
- maText.Text,
- aOffsets.get(),
- ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
- ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
- }
- else
- {
- rOutDev.DrawText( rOutpos,
- maText.Text,
- ::canvas::tools::numeric_cast<USHORT>(maText.StartPosition),
- ::canvas::tools::numeric_cast<USHORT>(maText.Length) );
- }
-
- return true;
- }
-
#define SERVICE_NAME "com.sun.star.rendering.TextLayout"
#define IMPLEMENTATION_NAME "CairoCanvas::TextLayout"
diff --git a/canvas/source/cairo/cairo_textlayout.hxx b/canvas/source/cairo/cairo_textlayout.hxx
index fb98c434615d..9dbc004d551a 100644
--- a/canvas/source/cairo/cairo_textlayout.hxx
+++ b/canvas/source/cairo/cairo_textlayout.hxx
@@ -93,10 +93,12 @@ namespace cairocanvas
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
bool draw( ::cairo::Cairo* pCairo );
- bool draw( OutputDevice& rOutDev,
+ bool draw( SurfaceSharedPtr& pSurface,
+ OutputDevice& rOutDev,
const Point& rOutpos,
const ::com::sun::star::rendering::ViewState& viewState,
const ::com::sun::star::rendering::RenderState& renderState ) const;
+
void setupTextOffsets( sal_Int32* outputOffsets,
const ::com::sun::star::uno::Sequence< double >& inputOffsets,
const ::com::sun::star::rendering::ViewState& viewState,
@@ -112,7 +114,8 @@ namespace cairocanvas
SurfaceProviderRef mpRefDevice;
sal_Int8 mnTextDirection;
- void useFont( ::cairo::Cairo* pCairo );
+ void useFont( ::cairo::Cairo* pCairo );
+ bool isCairoRenderable(SystemFontData aSysFontData) const;
};
}
diff --git a/canvas/source/cairo/cairo_win32_cairo.cxx b/canvas/source/cairo/cairo_win32_cairo.cxx
index 56edf089b4cb..b679d5fdbf12 100644
--- a/canvas/source/cairo/cairo_win32_cairo.cxx
+++ b/canvas/source/cairo/cairo_win32_cairo.cxx
@@ -284,6 +284,43 @@ namespace cairo
return SurfaceSharedPtr();
}
+
+ /**
+ * cairo::ucs4toindex: Convert ucs4 char to glyph index
+ * @param ucs4 an ucs4 char
+ * @param hfont current font
+ *
+ * @return true if successful
+ **/
+ unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont)
+ {
+ wchar_t unicode[2];
+ WORD glyph_index;
+ HDC hdc = NULL;
+ int i = 0;
+
+ hdc = CreateCompatibleDC (NULL);
+
+ if (!hdc) return 0;
+ if (!SetGraphicsMode (hdc, GM_ADVANCED)) {
+ DeleteDC (hdc);
+ return 0;
+ }
+
+ SelectObject (hdc, hfont);
+ SetMapMode (hdc, MM_TEXT);
+
+ unicode[0] = ucs4;
+ unicode[1] = 0;
+ if (GetGlyphIndicesW (hdc, unicode, 1, &glyph_index, 0) == GDI_ERROR) {
+ glyph_index = 0;
+ }
+
+ DeleteDC (hdc);
+ return glyph_index;
+ }
+
+
} // namespace cairo
#endif // CAIRO_HAS_WIN32_SURFACE
diff --git a/canvas/source/cairo/cairo_win32_cairo.hxx b/canvas/source/cairo/cairo_win32_cairo.hxx
index 2cacd1019ebc..3ecb04608355 100644
--- a/canvas/source/cairo/cairo_win32_cairo.hxx
+++ b/canvas/source/cairo/cairo_win32_cairo.hxx
@@ -66,6 +66,8 @@ namespace cairo {
int getDepth() const;
};
+
+ unsigned long ucs4toindex(unsigned int ucs4, HFONT hfont);
}
#endif
diff --git a/canvas/source/cairo/cairo_xlib_cairo.cxx b/canvas/source/cairo/cairo_xlib_cairo.cxx
index 0dba5c2b44ce..65f0faae659e 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.cxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.cxx
@@ -31,10 +31,10 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_canvas.hxx"
-#include <prex.h>
+#include <tools/prex.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xlib.h>
-#include <postx.h>
+#include <tools/postx.h>
#include "cairo_xlib_cairo.hxx"
@@ -71,23 +71,23 @@ namespace cairo
pRenderFormat(NULL)
{}
- X11SysData::X11SysData( const SystemGraphicsData* pSysDat ) :
- pDisplay(pSysDat->pDisplay),
- hDrawable(pSysDat->hDrawable),
- pVisual(pSysDat->pVisual),
- nScreen(pSysDat->nScreen),
- nDepth(pSysDat->nDepth),
- aColormap(pSysDat->aColormap),
- pRenderFormat(pSysDat->pRenderFormat)
+ X11SysData::X11SysData( const SystemGraphicsData& pSysDat ) :
+ pDisplay(pSysDat.pDisplay),
+ hDrawable(pSysDat.hDrawable),
+ pVisual(pSysDat.pVisual),
+ nScreen(pSysDat.nScreen),
+ nDepth(pSysDat.nDepth),
+ aColormap(pSysDat.aColormap),
+ pRenderFormat(pSysDat.pRenderFormat)
{}
- X11SysData::X11SysData( const SystemEnvData* pSysDat ) :
- pDisplay(pSysDat->pDisplay),
- hDrawable(pSysDat->aWindow),
- pVisual(pSysDat->pVisual),
- nScreen(pSysDat->nScreen),
- nDepth(pSysDat->nDepth),
- aColormap(pSysDat->aColormap),
+ X11SysData::X11SysData( const SystemEnvData& pSysDat ) :
+ pDisplay(pSysDat.pDisplay),
+ hDrawable(pSysDat.aWindow),
+ pVisual(pSysDat.pVisual),
+ nScreen(pSysDat.nScreen),
+ nDepth(pSysDat.nDepth),
+ aColormap(pSysDat.aColormap),
pRenderFormat(NULL)
{}
@@ -315,12 +315,12 @@ namespace cairo
if( !pSysData )
return X11SysData();
else
- return X11SysData(pSysData);
+ return X11SysData(*pSysData);
}
static X11SysData getSysData( const VirtualDevice& rVirDev )
{
- return X11SysData( &rVirDev.GetSystemGfxData() );
+ return X11SysData( rVirDev.GetSystemGfxData() );
}
SurfaceSharedPtr createSurface( const OutputDevice& rRefDevice,
diff --git a/canvas/source/cairo/cairo_xlib_cairo.hxx b/canvas/source/cairo/cairo_xlib_cairo.hxx
index 83bbfd0abfb6..eb5206f8b4eb 100644
--- a/canvas/source/cairo/cairo_xlib_cairo.hxx
+++ b/canvas/source/cairo/cairo_xlib_cairo.hxx
@@ -42,8 +42,8 @@ namespace cairo {
struct X11SysData
{
X11SysData();
- explicit X11SysData( const SystemGraphicsData* );
- explicit X11SysData( const SystemEnvData* );
+ explicit X11SysData( const SystemGraphicsData& );
+ explicit X11SysData( const SystemEnvData& );
void* pDisplay; // the relevant display connection
long hDrawable; // a drawable
diff --git a/canvas/source/cairo/makefile.mk b/canvas/source/cairo/makefile.mk
index 0466b1d07723..bd54254abf7e 100644
--- a/canvas/source/cairo/makefile.mk
+++ b/canvas/source/cairo/makefile.mk
@@ -99,12 +99,14 @@ SHL1STDLIBS+= -lcairo
SLOFILES+= $(SLO)$/cairo_quartz_cairo.obj
OBJCXXFLAGS=-x objective-c++ -fobjc-exceptions
CFLAGSCXX+=$(OBJCXXFLAGS)
-SHL1STDLIBS+= -lpixman-1
-.ELSE
+.ELSE # "$(GUIBASE)"=="aqua"
+
# Xlib
SLOFILES+= $(SLO)$/cairo_xlib_cairo.obj
-SHL1STDLIBS+= -lfontconfig $(FREETYPELIB) -lX11 -lXrender
-.ENDIF
+SHL1STDLIBS+= -lfontconfig -lX11 -lXrender -lpixman-1 $(FREETYPE_LIBS)
+CFLAGS+=$(FREETYPE_CFLAGS)
+
+.ENDIF # "$(GUIBASE)"=="aqua"
.ELSE # "$(GUI)"=="UNX"
diff --git a/canvas/source/cairo/postx.h b/canvas/source/cairo/postx.h
deleted file mode 100644
index ca8f610f78ec..000000000000
--- a/canvas/source/cairo/postx.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*************************************************************************
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: postx.h,v $
- *
- * $Revision: 1.4 $
- *
- * last change: $Author: kz $ $Date: 2008-06-30 12:59:14 $
- *
- * The Contents of this file are made available subject to
- * the terms of GNU Lesser General Public License Version 2.1.
- *
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2005 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- ************************************************************************/
-
-#ifndef _POSTX_H
-#define _POSTX_H
-
-#if defined __cplusplus
-}
-#endif
-
-/* X-Types */
-#undef Window
-#undef BYTE
-#undef INT8
-#undef INT64
-#undef BOOL
-#undef Font
-#undef Cursor
-#undef String
-#undef KeyCode
-#undef Region
-#undef Icon
-#undef Time
-#undef Boolean
-
-#undef Min
-#undef Max
-#undef DestroyAll
-#undef Success
-
-#undef Printer
-/* #undef FontInfo */
-#undef Orientation
-
-#undef GetToken
-#undef ReleaseToken
-#undef InitializeToken
-#undef NextRequest
-
-#ifdef KeyPress
-#if KeyPress != 2
-Error KeyPress must be Equal 2
-#endif
-#undef KeyPress
-#endif
-#define XLIB_KeyPress 2
-
-#endif
-
diff --git a/canvas/source/cairo/prex.h b/canvas/source/cairo/prex.h
deleted file mode 100644
index 6f1289fe9e5e..000000000000
--- a/canvas/source/cairo/prex.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*************************************************************************
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: prex.h,v $
- *
- * $Revision: 1.4 $
- *
- * last change: $Author: kz $ $Date: 2008-06-30 12:58:44 $
- *
- * The Contents of this file are made available subject to
- * the terms of GNU Lesser General Public License Version 2.1.
- *
- *
- * GNU Lesser General Public License Version 2.1
- * =============================================
- * Copyright 2005 by Sun Microsystems, Inc.
- * 901 San Antonio Road, Palo Alto, CA 94303, USA
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1, as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- ************************************************************************/
-
-#ifndef _PREX_H
-#define _PREX_H
-
-#define Window XLIB_Window
-#define BYTE XLIB_BYTE
-#define INT8 XLIB_INT8
-#define INT64 XLIB_INT64
-#define BOOL XLIB_BOOL
-#define Font XLIB_Font
-#define Cursor XLIB_Cursor
-#define String XLIB_String
-#define KeyCode XLIB_KeyCode
-#define Region XLIB_Region
-#define Icon XLIB_Icon
-#define Time XLIB_Time
-#define Region XLIB_Region
-#define Boolean XLIB_Boolean
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-#if defined(LINUX) || defined(FREEBSD) || defined(MACOSX) // should really check for xfree86 or for X11R6.1 and higher
-#define __XKeyboardExtension__ 1
-#else
-#define __XKeyboardExtension__ 0
-#endif
-
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/StringDefs.h>
-#include <X11/extensions/Xrender.h>
-#if __XKeyboardExtension__
-#include <X11/XKBlib.h>
-#endif
-typedef unsigned long Pixel;
-
-#undef DestroyAll
-#define DestroyAll XLIB_DestroyAll
-#define XLIB_DestroyAll 0
-#undef String
-#define String XLIB_String
-
-#undef KeyCode
-#define KeyCode XLIB_KeyCode //undef in intrinsics
-
-#define __Ol_OlXlibExt_h__
-
-#endif
-