Text wrapping does not work properly for accented characters
Describe the bug
Text wrapping does not properly work for accented characters like ěščřžýáíé.
To Reproduce
- Open sample app for Xamarin.Forms
- Select Text tab
- Enter: ščěěščž čšřžščřž čšřžščř čšřžščř čšřžščř čšřžščř čšřžščř
- Resize the window. Notice the line breaks anywhere within the "words"
Expected behavior
Words with accented characters should not be broken between lines.
Environment (please complete the following information):
- Platform: CSharpMath.SkiaSharp (in general, not just XF)
- Package Version or Commit: latest
- Device: Windows
@prepare Probably a bug of Typography.TextBreak.
Confirmed a bug of Typography.TextBreak.
This Typography bug was fixed,
see => https://github.com/LayoutFarm/Typography/commit/f350e2268ab2236d07d58a49647cf1e60a6764c4

@prepare Thanks a lot!
Still need to fix this for diacritics via LaTeX commands instead of Unicode, i.e. a\r aa should be one group.
That's what happen when I try to show chinese text (appear squares), is this relate to this issue?
You should provide your own font like in #142.
@BenjaNapo See https://github.com/verybadcat/CSharpMath/issues/20.
@BenjaNapo See #20.
I wrote in the constructor of App.cs:
CSharpMath.Settings.GlobalTypefaces = new Typography.OpenFont.OpenFontReader().Read(File.Open("Cabin-Regular.ttf", FileMode.Open));
but it says that GlobalTypefaces is an onlyread attribute
For GlobalTypefaces, you call Add.
For GlobalTypefaces, you call
Add.
App.xaml
<OnPlatform x:Key="Regular" x:TypeArguments="x:String">
<On Platform="Android" Value="Cabin-Regular.ttf#Cabin" />
<On Platform="iOS" Value="Cabin-Regular" />
</OnPlatform>
App.cs
public App()
{
InitializeComponent();
[... various initialization ...]
object s = new object();
Resources.TryGetValue("Regular", out s);
CSharpMath.Settings.GlobalTypefaces.Add(new Typography.OpenFont.OpenFontReader().Read(s as Stream));
}
Sorry but I never imported Font from code, where did I go wrong?
Are you trying to override the font? The default is AddSupplement. For overrides, use AddOverride.
Are you trying to override the font? The default is
AddSupplement. For overrides, useAddOverride.
Changed with:
object s = new object();
Resources.TryGetValue("Regular", out s);
Typeface t = new Typography.OpenFont.OpenFontReader().Read(s as Stream);
CSharpMath.Settings.GlobalTypefaces.AddOverride(t);
But 3rd line throws ArgumentNullException, I think that the problem is in reading font file in this way
The null means that s is probably not a Stream. Please check.
public async void LoadFont() {
using (var stream = await FileSystem.OpenAppPackageFileAsync("Helvetica-Bold.otf"))
{
Typeface t = new Typography.OpenFont.OpenFontReader().Read(stream as Stream);
CSharpMath.Settings.GlobalTypefaces.AddOverride(t);
}
}
Now it loads the font from the stream but crash on the 4th line (Typeface t = ...) throwing this exception:
System.NotSupportedException: 'Specified method is not supported.'
Try following https://github.com/verybadcat/CSharpMath#sourcelink-for-ci-packages and debug into the source of Typography.
@BenjaNapo Or you can upload a zipped file containing your file and let me investigate what changes are needed from Typography's side.
This bug's fix depends on a decision on updating Typography in LayoutFarm/Typography#192. The fix for
Still need to fix this for diacritics via LaTeX commands instead of Unicode, i.e.
a\r aashould be one group.
is scheduled after #143 and #58.
https://drive.google.com/file/d/1zlvyQ2XXvb0fQJ8k-otYZ4hiR_8L3H-d/view?usp=sharing
Here you are, with this you could note all the issues that I had 'til now (text alignment, change font and height of textview)
Thanks for all the help ^^ Hope this will contribute with the evolution of the library
@BenjaNapo #144 should fix "text alignment" and "height of textview".
This leaves "change font" as to-do.
Thanks for all the help ^^ Hope this will contribute with the evolution of the library
Thank you for taking the time to report problems too!