summaryrefslogtreecommitdiff
path: root/src/corelib/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/render')
-rw-r--r--src/corelib/render/software/Agg2D.pas5
-rw-r--r--src/corelib/render/software/agg-demos/extrafpc.cfg21
-rw-r--r--src/corelib/render/software/agg_2D.pas60
-rw-r--r--src/corelib/render/software/agg_blur.pas2
-rw-r--r--src/corelib/render/software/agg_platform_gdi.inc13
5 files changed, 83 insertions, 18 deletions
diff --git a/src/corelib/render/software/Agg2D.pas b/src/corelib/render/software/Agg2D.pas
index 229294d2..b77b9ce9 100644
--- a/src/corelib/render/software/Agg2D.pas
+++ b/src/corelib/render/software/Agg2D.pas
@@ -2653,9 +2653,10 @@ procedure TAgg2D.Font(
italic : boolean = false;
cache : TAggFontCacheType = AGG_VectorFontCache;
angle : double = 0.0 );
+{$IFDEF AGG2D_USE_WINFONTS}
var
b : int;
-
+{$ENDIF}
begin
m_textAngle :=angle;
m_fontHeight :=height;
@@ -3559,7 +3560,7 @@ procedure TAgg2D.DoSetFontRes(fntres: TfpgFontResourceBase);
{$IFDEF WINDOWS}
begin
{$IFDEF AGG2D_USE_FREETYPE }
- Font('c:\WINNT\Fonts\arial.ttf', 10);
+ Font(GetWindowsFontDir + 'arial.ttf', 10);
{$ENDIF }
{$IFDEF AGG2D_USE_WINFONTS}
Font('Arial', 13);
diff --git a/src/corelib/render/software/agg-demos/extrafpc.cfg b/src/corelib/render/software/agg-demos/extrafpc.cfg
new file mode 100644
index 00000000..94482a02
--- /dev/null
+++ b/src/corelib/render/software/agg-demos/extrafpc.cfg
@@ -0,0 +1,21 @@
+-FUunits
+-Fu../
+-Fu../ctrl/
+#IFDEF UNIX
+ -Fu../platform/linux/
+#ENDIF
+#IFDEF WINDOWS
+ -Fu../platform/win/
+ -WG
+#ENDIF
+#IFDEF Carbon
+ -Fu../platform/mac/
+#ENDIF
+-Fu../svg/
+-Fu../util/
+-Fi../
+-Xs
+-XX
+-CX
+-Mdelphi
+
diff --git a/src/corelib/render/software/agg_2D.pas b/src/corelib/render/software/agg_2D.pas
index 45d88e44..0fcbc3d9 100644
--- a/src/corelib/render/software/agg_2D.pas
+++ b/src/corelib/render/software/agg_2D.pas
@@ -414,9 +414,9 @@ type
opt : ViewportOption = XMidYMid );
// Basic Shapes
- procedure line (x1 ,y1 ,x2 ,y2 : double );
+ procedure line (const x1 ,y1 ,x2 ,y2 : double; AFixAlignment: boolean = false );
procedure triangle (x1 ,y1 ,x2 ,y2 ,x3 ,y3 : double );
- procedure rectangle(x1 ,y1 ,x2 ,y2 : double );
+ procedure rectangle(const x1 ,y1 ,x2 ,y2 : double; AFixAlignment: boolean = false);
procedure roundedRect(x1 ,y1 ,x2 ,y2 ,r : double ); overload;
procedure roundedRect(x1 ,y1 ,x2 ,y2 ,rx ,ry : double ); overload;
@@ -443,7 +443,7 @@ type
fileName : char_ptr; height : double;
bold : boolean = false;
italic : boolean = false;
- ch : FontCacheType = RasterFontCache;
+ ch : FontCacheType = VectorFontCache;
angle : double = 0.0 );
function fontHeight : double;
@@ -1876,13 +1876,25 @@ begin
end;
{ LINE }
-procedure Agg2D.line(x1 ,y1 ,x2 ,y2 : double );
+procedure Agg2D.line(const x1, y1, x2, y2: double; AFixAlignment: boolean = false);
+var
+ lx1, ly1, lx2, ly2: double;
begin
m_path.remove_all;
- addLine (x1 ,y1 ,x2 ,y2 );
- drawPath(StrokeOnly );
+ lx1 := x1;
+ ly1 := y1;
+ lx2 := x2;
+ ly2 := y2;
+ if AFixAlignment then
+ begin
+ AlignPoint(@lx1, @ly1);
+ AlignPoint(@lx2, @ly2);
+ end;
+
+ addLine(lx1, ly1, lx2, ly2);
+ drawPath(StrokeOnly);
end;
{ TRIANGLE }
@@ -1899,13 +1911,27 @@ begin
end;
{ RECTANGLE }
-procedure Agg2D.rectangle(x1 ,y1 ,x2 ,y2 : double );
+procedure Agg2D.rectangle(const x1 ,y1 ,x2 ,y2 : double; AFixAlignment: boolean);
+var
+ lx1, ly1, lx2, ly2: double;
begin
m_path.remove_all;
- m_path.move_to(x1 ,y1 );
- m_path.line_to(x2 ,y1 );
- m_path.line_to(x2 ,y2 );
- m_path.line_to(x1 ,y2 );
+
+ lx1 := x1;
+ ly1 := y1;
+ lx2 := x2;
+ ly2 := y2;
+
+ if AFixAlignment then
+ begin
+ AlignPoint(@lx1, @ly1);
+ AlignPoint(@lx2, @ly2);
+ end;
+
+ m_path.move_to(lx1 ,ly1 );
+ m_path.line_to(lx2 ,ly1 );
+ m_path.line_to(lx2 ,ly2 );
+ m_path.line_to(lx1 ,ly2 );
m_path.close_polygon;
drawPath(FillAndStroke );
@@ -2102,7 +2128,7 @@ procedure Agg2D.font(
fileName : char_ptr; height : double;
bold : boolean = false;
italic : boolean = false;
- ch : FontCacheType = RasterFontCache;
+ ch : FontCacheType = VectorFontCache;
angle : double = 0.0 );
var
b : int;
@@ -2121,10 +2147,11 @@ begin
m_fontEngine.hinting_(m_textHints );
if ch = VectorFontCache then
- m_fontEngine.height_(height )
+ {$NOTE We need to fix this. Translating from font pt to pixels is inaccurate. This is just a temp fix for now. }
+ m_fontEngine.height_(height * 1.3333 ) // 9pt = ~12px so that is a ratio of 1.3333
else
m_fontEngine.height_(worldToScreen(height ) );
-{$ENDIF }
+{$ENDIF}
{$IFDEF AGG2D_USE_WINFONTS}
m_fontEngine.hinting_(m_textHints );
@@ -2167,7 +2194,9 @@ end;
procedure Agg2D.textHints(hints : boolean );
begin
m_textHints:=hints;
-
+ {$IFNDEF AGG2D_NO_FONT}
+ m_fontEngine.hinting_(m_textHints );
+ {$ENDIF}
end;
{ TEXTWIDTH }
@@ -2350,6 +2379,7 @@ end;
procedure Agg2D.resetPath;
begin
m_path.remove_all;
+ m_path.move_to(0 ,0 );
end;
diff --git a/src/corelib/render/software/agg_blur.pas b/src/corelib/render/software/agg_blur.pas
index 5ddda2bc..78e6df72 100644
--- a/src/corelib/render/software/agg_blur.pas
+++ b/src/corelib/render/software/agg_blur.pas
@@ -25,7 +25,7 @@
// http://incubator.quasimondo.com/processing/fast_blur_deluxe.php
// (search phrase "Stackblur: Fast But Goodlooking").
// The major improvement is that there's no more division table
-// that was very expensive to create for large blur radii. Insted,
+// that was very expensive to create for large blur radii. Instead,
// for 8-bit per channel and radius not exceeding 254 the division is
// replaced by multiplication and shift.
//
diff --git a/src/corelib/render/software/agg_platform_gdi.inc b/src/corelib/render/software/agg_platform_gdi.inc
index 88d3b586..c61d068f 100644
--- a/src/corelib/render/software/agg_platform_gdi.inc
+++ b/src/corelib/render/software/agg_platform_gdi.inc
@@ -21,6 +21,19 @@ type
// to get access to protected methods (seeing that FPC doesn't support Friend-classes)
TImageHack = class(TfpgImage);
+function GetWindowsFontDir: string;
+var
+ lWinFontPath: array[0..MAX_PATH] of WideChar;
+ lPasWinFontPath: string;
+ i: Integer;
+begin
+ // Find for example C:\Windows\Fonts or C:\WINNT\Fonts
+ Windows.GetWindowsDirectoryW(@lWinFontPath[0], MAX_PATH);
+ lPasWinFontPath := lWinFontPath;
+ lPasWinFontPath := IncludeTrailingPathDelimiter(lPasWinFontPath) + 'Fonts' + PathDelim;
+ Result := lPasWinFontPath;
+end;
+
procedure TAgg2D.DoPutBufferToScreen(x, y, w, h: TfpgCoord);
var
srcdc: HDC;