Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom font family is not working in WebAssembly #15683

Closed
amirhoseinadlfar opened this issue May 10, 2024 · 7 comments
Closed

Custom font family is not working in WebAssembly #15683

amirhoseinadlfar opened this issue May 10, 2024 · 7 comments

Comments

@amirhoseinadlfar
Copy link

Describe the bug

in desktop :
image
in WebAssembly:
image

Is there any arabic/persian support for WebAssembly?

To Reproduce

code :
im using Avalonia.Markup.Declarative

protected override object Build()
{
    return new StackPanel()
        .Orientation(Orientation.Vertical)
        .Children(
            new TextBlock()
                .Text("نام کاربری"),
            new TextBox(),

            new TextBlock()
                .Text("رمزعبور"),
            new TextBox(),

            new TextBlock()
                .Text("تکرار رمزعبور"),
            new TextBox()
        );
}

font style :

    Styles.Add(new Style()
        .Selector(selector => selector.Is<TemplatedControl>())
        .Setter(TemplatedControl.FontFamilyProperty, new FontFamily("Nahid")));

font resource loading :

    //avares://AvaloniaClient/Assets/Fonts/Nahid.ttf
    FontFamily nahidFontFamily = new FontFamily(Assets.Fonts.NahidPath);

    Resources.Add("Nahid", nahidFontFamily);

Expected behavior

No response

Avalonia version

11.0.10

OS

WebAssembly

Additional context

font family is https://github.com/rastikerdar/nahid-font

@amirhoseinadlfar amirhoseinadlfar changed the title custom font family do not working in WebAssembly Custom font family do not working in WebAssembly May 10, 2024
@amirhoseinadlfar
Copy link
Author

without any font:
image
image
also, with default font, some characters like 'م' are not rendering correctly.

@amirhoseinadlfar amirhoseinadlfar changed the title Custom font family do not working in WebAssembly Custom font family is not working in WebAssembly May 10, 2024
@timunie
Copy link
Contributor

timunie commented May 12, 2024

can you try 11.1 beta? Please mind the breaking changes for browser when you do so (mentioned in 11.1 beta1 thread)

@amirhoseinadlfar
Copy link
Author

amirhoseinadlfar commented May 16, 2024

can you try 11.1 beta? Please mind the breaking changes for browser when you do so (mentioned in 11.1 beta1 thread)

for some reason its do not recognize Avalonia.Browser namespace after updating to 11.1.0-beta1 and 11.1.0-beta2. I'm not sure if its a bug or I am missing something, its working fine on 11.0.10

csproj :

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
    <WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <WasmExtraFilesToDeploy Include="AppBundle\**" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Avalonia.Browser" Version="11.1.0-beta1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\AvaloniaClient\AvaloniaClient.csproj" />
  </ItemGroup>
</Project>

Error :
The type or namespace name 'Browser' does not exist in the namespace 'Avalonia' (are you missing an assembly reference?) AvaloniaClient.Browser
'AppBuilder' does not contain a definition for 'StartBrowserAppAsync' and no accessible extension method 'StartBrowserAppAsync' accepting a first argument of type 'AppBuilder' could be found (are you missing a using directive or an assembly reference?)
so I'm referenced it manually and move staticwebassets to my project AppBundle with Copy Always option.


  <ItemGroup>
    <Reference Include="Avalonia.Browser">
      <HintPath>C:\Users\{USER}\.nuget\packages\avalonia.browser\11.1.0-beta1\lib\net8.0-browser1.0\Avalonia.Browser.dll</HintPath>
    </Reference>
  </ItemGroup>

and for some reason when I'm start project with debug, visual studio do open browser but do not redirect browser to localhost:5000 and after sometime its give me error and close the browser so I'm have to do all my troubleshooting again. so I'm changed to Start Without Debugging and its also has some wired problems like not finding content inside _framework folder so I'm have to copy paste content manually every time, the project do not include Avalonia.Skia and I'm added it in nuget to browser project. and now I'm have this error which I'm have no idea what is about and I'm really did not expect project to run
image

@amirhoseinadlfar
Copy link
Author

can you try 11.1 beta? Please mind the breaking changes for browser when you do so (mentioned in 11.1 beta1 thread)

but at least problem with character 'م' is fixed in desktop app

@jp2masa
Copy link
Contributor

jp2masa commented May 16, 2024

and for some reason when I'm start project with debug, visual studio do open browser but do not redirect browser to localhost:5000 and after sometime its give me error and close the browser so I'm have to do all my troubleshooting again.

That's probably #14570.

@timunie
Copy link
Contributor

timunie commented May 17, 2024

please also see here for 11.1-beta testing: #14821

@amirhoseinadlfar
Copy link
Author

problem fixed.
the path of //avares://AvaloniaClient/Assets/Fonts/Nahid.ttf was wrong and changed to //avares://AvaloniaClient/Assets/Fonts#Nahid and now font can be load correctly.
it was falling back to default font instead of using nahid font so its must be the default font bug and its looks fine right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants