You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by mes51 December 11, 2024
Hi.
I'm trying vertical layout by looking at the #327 Pull Request.
When I tried it, it seemed that the layout of some characters was off (the characters were not centered like in the pull request, and punctuation marks and long vowels were also significantly misaligned).
I tried several fonts (Windows standard fonts such as MS UI Gothic, Meiryo, YaHei, and fonts installed from Google Fonts and Adobe Fonts), but it seemed that the misalignment occurred with all of them.
Are there any other settings that need to be specified in addition to specifying Vertical* for LayoutMode when layout vertically? Or is there another problem?
In the sample, it is rendered using SixLabors.ImageSharp.Drawing, but in the end, I plan to use the glyph path rather than the rendered image.
Windows 11 Home 23H2
.NET 8
SixLabors.Fonts v2.0.6
(SixLabors.ImageSharp.Drawing v2.1.4)
Without punctuation:
With punctuation (At first glance, the “う”, "こ", “も”, “し” and "日" appear to be centered, but this is only because the punctuation marks is misaligned.)
As a reference, I have attached a layout in Photoshop.
Steps to Reproduce
usingSixLabors.Fonts;usingSixLabors.ImageSharp;usingSixLabors.ImageSharp.Drawing.Processing;usingSixLabors.ImageSharp.PixelFormats;usingSixLabors.ImageSharp.Processing;usingSystem.Numerics;conststringWithoutPunctuation="あいうえお「こんにちはー」もしもし ABCDEFG 日本語";conststringWithPunctuation="あいうえお、「こんにちはー」。もしもし。ABCDEFG 日本語";voidCreateTextImage(stringtext,stringfilePath){//using var fs = new System.IO.FileStream("NotoSerifJP-Medium.ttf", FileMode.Open);//var fontCollection = new FontCollection();//var fontFamily = fontCollection.Add(fs);varfontFamily=SystemFonts.Get("Yu Gothic");varfont=fontFamily.CreateFont(30.0F);vartextOption=newRichTextOptions(font){LayoutMode=LayoutMode.VerticalRightLeft,Origin=newVector2(10.0F,10.0F)};varbounds=TextMeasurer.MeasureBounds(text,textOption);varimage=newImage<Bgra32>((int)Math.Ceiling(bounds.Width+Math.Abs(bounds.Left)*2.0F),(int)Math.Ceiling(bounds.Height+Math.Abs(bounds.Top)*2.0F),newBgra32(255,255,255));image.Mutate(x =>{x.DrawText(textOption,text,Color.Black);// draw bounding boxx.DrawPolygon(Pens.Solid(Color.Blue),newPointF(bounds.Left,bounds.Top),newPointF(bounds.Right,bounds.Top),newPointF(bounds.Right,bounds.Bottom),newPointF(bounds.Left,bounds.Bottom));// draw center linevarcenterX=bounds.Left+bounds.Width*0.5F;x.DrawLine(Pens.Solid(Color.Red),newPointF(centerX,bounds.Top),newPointF(centerX,bounds.Bottom));});image.SaveAsPng(filePath);}CreateTextImage(WithoutPunctuation,"without_punctuation.png");CreateTextImage(WithPunctuation,"with_punctuation.png");
```</div>
The text was updated successfully, but these errors were encountered:
@mes51 I've made some progress here. I was making some incorrect assumptions plus not taking into considertation glyph substitutions for the vert, vrt2, and vrtr tags.
The only thing left to do is to adjust the baseline for rotated fonts (I originally didn't adjust because System.Drawing doesn't but browsers do so I'll use that approach) and add some tests. (not sure how to test yet)
Discussed in #428
Originally posted by mes51 December 11, 2024
Hi.
I'm trying vertical layout by looking at the #327 Pull Request.
When I tried it, it seemed that the layout of some characters was off (the characters were not centered like in the pull request, and punctuation marks and long vowels were also significantly misaligned).
I tried several fonts (Windows standard fonts such as MS UI Gothic, Meiryo, YaHei, and fonts installed from Google Fonts and Adobe Fonts), but it seemed that the misalignment occurred with all of them.
Are there any other settings that need to be specified in addition to specifying
Vertical*
forLayoutMode
when layout vertically? Or is there another problem?In the sample, it is rendered using
SixLabors.ImageSharp.Drawing
, but in the end, I plan to use the glyph path rather than the rendered image.Windows 11 Home 23H2
.NET 8
SixLabors.Fonts v2.0.6
(SixLabors.ImageSharp.Drawing v2.1.4)
Without punctuation:
With punctuation (At first glance, the “う”, "こ", “も”, “し” and "日" appear to be centered, but this is only because the punctuation marks is misaligned.)
As a reference, I have attached a layout in Photoshop.
Steps to Reproduce
The text was updated successfully, but these errors were encountered: