Skip to content

Commit

Permalink
#20
Browse files Browse the repository at this point in the history
  • Loading branch information
Christophe Peugnet committed Dec 17, 2024
1 parent 24b5cf8 commit 42ea076
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
27 changes: 14 additions & 13 deletions BlazorCaptcha/BlazorCaptcha.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net7.0; net8.0; net9.0</TargetFrameworks>
<!--<TargetFramework>net9.0</TargetFramework>-->
<Copyright>Copyright 2020-2024</Copyright>
<PackageProjectUrl>https://github.com/tossnet/Blazor-Captcha</PackageProjectUrl>
<RepositoryUrl>https://github.com/tossnet/Blazor-Captcha</RepositoryUrl>
Expand All @@ -12,7 +13,7 @@
<PackageReleaseNotes>Update nuget packages</PackageReleaseNotes>
<PackageIcon>icon.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
<AssemblyVersion>1.6.0.0</AssemblyVersion>
<FileVersion>1.6.0.0</FileVersion>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
Expand Down Expand Up @@ -46,28 +47,28 @@
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="7.0.20" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="7.0.20" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.2.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.11" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.2.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.0" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.1.2" />
<PackageReference Include="SkiaSharp" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.118.0-preview.2.3" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="3.118.0-preview.2.3" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 4 additions & 6 deletions BlazorCaptcha/Captcha.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,26 @@ private void Initialization()
paint.IsAntialias = true;
//paint.TextAlign = SKTextAlign.Left;


SKRect rect = new();
float width = font.MeasureText(l.Value, out rect);
float width = font.GetGlyphWidths(l.Value, out SKRect[] bounds)[0];

float textWidth = width;
var y = (Height - rect.Height);
var y = (Height - bounds[0].Height);

canvas.Save();

canvas.RotateDegrees(l.Angle, x, y);
canvas.DrawText(l.Value, x, y, font, paint);

// Draw red rectangle to debug :
//var y2 = GetNewY(x, y, rect.Width, l.Angle);
//var y2 = GetNewY(x, y, bounds[0].Width, l.Angle);
//var paint1 = new SKPaint
//{
// TextSize = 64.0f,
// IsAntialias = true,
// Color = new SKColor(255, 0, 0),
// Style = SKPaintStyle.Stroke
//};
//canvas.DrawRect(rect.Left + x, y2 + rect.Top, rect.Width, rect.Height, paint1);
//canvas.DrawRect(bounds[0].Left + x, y2 + bounds[0].Top, bounds[0].Width, bounds[0].Height, paint1);

canvas.Restore();

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ For client-side and server-side Blazor - add script section to _Host.cshtml (hea

## <a name="ReleaseNotes"></a>Release Notes

<details open="open"><summary>Version 1.7.1</summary>

>- https://github.com/tossnet/Blazor-Captcha/issues/20#issuecomment-2549029344
</details>

<details open="open"><summary>Version 1.6.0</summary>
<details><summary>Version 1.6.0</summary>

>- issue #12
</details>
Expand Down
2 changes: 1 addition & 1 deletion Samples/BlazorServer/BlazorCaptchaTest/Pages/Form.razor
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="form-group row">
<label class=" col-sm-2 row"></label>
<div class="col-sm-4">
<Captcha @bind-CaptchaWord="@Captcha" CharNumber="@CaptchaLetters" />
<Captcha @bind-CaptchaWord="@Captcha" CharNumber="@CaptchaLetters" Height="80" Width="260" />
</div>
</div>
<div class="form-group row">
Expand Down

0 comments on commit 42ea076

Please sign in to comment.