CairoCanvas: Fix cairocanvas example and add note for windows

git-svn-id: trunk@61228 -
This commit is contained in:
jesus 2019-05-15 01:55:16 +00:00
parent 0348f7bc9a
commit c61b928517
4 changed files with 84 additions and 11 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<Version Value="12"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="cairoprog"/>
<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">

View File

@ -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;

View File

@ -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.