From c61b928517b28526ed19907c0f1633f25e16eb13 Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 15 May 2019 01:55:16 +0000 Subject: [PATCH] CairoCanvas: Fix cairocanvas example and add note for windows git-svn-id: trunk@61228 - --- .gitattributes | 1 + components/cairocanvas/example/cairoprog.lpi | 19 ++++--- components/cairocanvas/example/cairoprog.lpr | 17 +++++- components/cairocanvas/example/readme.txt | 58 ++++++++++++++++++++ 4 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 components/cairocanvas/example/readme.txt diff --git a/.gitattributes b/.gitattributes index 3903eda749..34911fd7f7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -561,6 +561,7 @@ components/cairocanvas/cairographics.pas svneol=native#text/plain components/cairocanvas/cairoprinter.pas svneol=native#text/pascal components/cairocanvas/example/cairoprog.lpi svneol=native#text/plain components/cairocanvas/example/cairoprog.lpr svneol=native#text/pascal +components/cairocanvas/example/readme.txt svneol=native#text/plain components/cairocanvas/tests/24217/project1.lpi svneol=native#text/plain components/cairocanvas/tests/24217/project1.lpr svneol=native#text/pascal components/cairocanvas/tests/24217/unit1.lfm svneol=native#text/plain diff --git a/components/cairocanvas/example/cairoprog.lpi b/components/cairocanvas/example/cairoprog.lpi index 873050e5c6..3ff7e507a4 100644 --- a/components/cairocanvas/example/cairoprog.lpi +++ b/components/cairocanvas/example/cairoprog.lpi @@ -1,14 +1,14 @@ - + + - <UseAppBundle Value="False"/> <ResourceType Value="res"/> @@ -16,9 +16,6 @@ <i18n> <EnableI18N LFM="False"/> </i18n> - <VersionInfo> - <StringTable ProductVersion=""/> - </VersionInfo> <MacroValues Count="1"> <Macro1 Name="LCLWidgetType" Value="nogui"/> </MacroValues> @@ -32,9 +29,10 @@ <Version Value="2"/> </PublishOptions> <RunParams> - <local> - <FormatVersion Value="1"/> - </local> + <FormatVersion Value="2"/> + <Modes Count="1"> + <Mode0 Name="default"/> + </Modes> </RunParams> <RequiredPackages Count="1"> <Item1> @@ -57,6 +55,11 @@ <IncludeFiles Value="$(ProjOutDir)"/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf2"/> + </Debugging> + </Linking> </CompilerOptions> <Debugging> <Exceptions Count="3"> diff --git a/components/cairocanvas/example/cairoprog.lpr b/components/cairocanvas/example/cairoprog.lpr index edf8e6ab83..319b29d2c4 100644 --- a/components/cairocanvas/example/cairoprog.lpr +++ b/components/cairocanvas/example/cairoprog.lpr @@ -10,25 +10,36 @@ var // This could also be TCairoSvgCanvas, TCairoPngCanvas or TCairoPsCanvas begin PrinterCanvas := TCairoPdfCanvas.Create; try - PrinterCanvas.OutputFileName := 'CairoCanvas.pdf'; - PrinterCanvas.Ellipse(20, 20, 170, 120); //PrinterCanvas.XDPI := 75; // These have valid default values. //PrinterCanvas.YDPI := 75; //PrinterCanvas.PaperWidth := 250; //PrinterCanvas.PaperHeight := 500; + PrinterCanvas.BeginDoc; + PrinterCanvas.OutputFileName := 'CairoCanvas.pdf'; + PrinterCanvas.Ellipse(10, 20, 160, 120); + + // Font properties must be set, does not work otherwise. + {$IFDEF MSWindows} + PrinterCanvas.Font.Name := 'Arial Unicode MS'; + {$ELSE} PrinterCanvas.Font.Name := 'Arial'; // Font properties must be set, does not work otherwise. + {$ENDIF} PrinterCanvas.Font.Height := 24; + + PrinterCanvas.TextOut(50, 60, 'Page 1'); PrinterCanvas.TextOut(50, 150, 'abcdefghijklmnopqrstuvwxyzåäö'); PrinterCanvas.TextOut(50, 220, 'ฉันหิวแล้ว'); PrinterCanvas.TextOut(50, 290, 'К нам в око́шко застучи́т'); PrinterCanvas.TextOut(50, 360, 'لا أتَكَلّمُ الْعَرَبيّة'); PrinterCanvas.NewPage; - PrinterCanvas.TextOut(50, 80, 'Page 2'); + PrinterCanvas.Ellipse(10, 20, 160, 120); + PrinterCanvas.TextOut(50, 60, 'Page 2'); PrinterCanvas.TextOut(50, 150, 'Finnish: wxyzåäö1234567890'); PrinterCanvas.TextOut(50, 220, 'Thai: ฉันหิวแล้ว'); PrinterCanvas.TextOut(50, 290, 'Russian: К нам в око́шко застучи́т'); PrinterCanvas.TextOut(50, 360, 'Arabic: لا أتَكَلّمُ الْعَرَبيّة'); WriteLn('Written file ' + PrinterCanvas.OutputFileName); + PrinterCanvas.EndDoc; finally PrinterCanvas.Free; end; diff --git a/components/cairocanvas/example/readme.txt b/components/cairocanvas/example/readme.txt new file mode 100644 index 0000000000..0cf2e676f5 --- /dev/null +++ b/components/cairocanvas/example/readme.txt @@ -0,0 +1,58 @@ +Notes for this example targeting 32 bits Windows: + +This cairocanvas example require the Cairo Graphics and Pango libraries. + +There are instructions for downloading precompiled binaries for windows +in the web page: https://www.cairographics.org/download/ + +In this example the binaries for The Glade/GTK+ for Windows Toolkit will be used, +Because they are available as a single GTK+ setup file that install only the +most basic runtime libraries needed to run GTK+ applications, including cairo +applications. + +Probably more rencent files can be obtained from the official GTK+ for windows +web page, but that would require installing either MSYS2 or vcpkg, which is +overkill for the purpose of this example. At the time of this writing +(14-may-2019), the glade binaries are still available in the following +link: http://gladewin32.sourceforge.net/ + +Where the next version is selected: + +" +(2008 Apr 20 02:58 HKT) Updated cairo, freetype, glade, libglade to their latest stable release: + +Gtk+ 2.12.9 Runtime Environment Revision 2 (7,206) +" + +This is a setup program that installs some old GTK files in some user chosen directory, but +that for purposes of this example it should be fine. There are instructions for installing this +files globaly in a shared location, but for purposes of this example we choose to make a +local copy of the needed files. + +From the installed 'bin' directory copy the following dll files into the current directory: + +libpango-1.0-0.dll +libpangocairo-1.0-0.dll +libpangoft2-1.0-0.dll +libpangowin32-1.0-0.dll +pango-basic-fc.dll +pango-basic-win32.dll +libcairo-2.dll +libfreetype-6.dll +intl.dll +libglib-2.0-0.dll +libgmodule-2.0-0.dll +libgobject-2.0-0.dll +libxml2.dll +libpng12.dll +libfontconfig-1.dll +zlib1.dll +iconv.dll + +From the installed root directory, copy the following directories: + +etc\ +lib\ + +Probably not everything inside the 'etc' or 'lib' directories is needed, but being +less than 1 MB it should not matter too much.