繁体   English   中英

Bangla 字体未显示在 ubuntu .net6 中

[英]Bangla Font is not showing in ubuntu .net6

在 windows 处,字体显示完美,但在 ubuntu 处显示为方框。 我已经附上了 pdf。

  1. Windows 一视窗

  2. Ubuntu 一Linux

我将 iTextSharp 用于 PDF 并且地址本身就是图像。

这是代码

 if (!string.IsNullOrEmpty(shippingAddressData.Address1))
                    {
                        if (String.IsNullOrEmpty(shippingAddressData.Address2))
                        {
                            var customercityStateZipCountry = await FormatAddressTextAsync(shippingAddressData);
                            shippingAddress1 = shippingAddress1 + indent + "Address: " + shippingAddressData.Address1 + customercityStateZipCountry;
                        }
                        var customerAddress1Split = Split(shippingAddress1, 43);
                        int i = 0;
                        foreach (var customerAddress1BreakDown in customerAddress1Split)
                        {
                            if (i == 0)
                            {
                                var customerAddress1InBitMap = ConvertToBitMapDefault(customerAddress1BreakDown, 22f);
                                Image customerAddress1InImage = Image.GetInstance(customerAddress1InBitMap, System.Drawing.Imaging.ImageFormat.Jpeg);

                                shippingAddressPDF.AddCell(customerAddress1InImage);


                            }
                            else
                            {
                                var secondLine = indent + customerAddress1BreakDown;
                                var customerAddress1InBitMap = ConvertToBitMapDefault(secondLine, 22f);
                                Image customerAddress1InImage = Image.GetInstance(customerAddress1InBitMap, System.Drawing.Imaging.ImageFormat.Jpeg);

                                shippingAddressPDF.AddCell(customerAddress1InImage);
                            }
                            i++;
                        }
                    }

支撑方式

public System.Drawing.Bitmap ConvertToBitMapDefault(string Text, float fontSize = 22f, int widthPoint = 0)
        {
            //string familyName = _fileProvider.Combine(_fileProvider.MapPath("~/App_Data/Pdf/"), "ARIALUNI.ttf");
            //Path.Combine(CommonHelper.MapPath("~/App_Data/Pdf/"), "ARIALUNI.ttf");
            string familyName = _fileProvider.Combine(_fileProvider.MapPath("~/App_Data/Pdf/"), _pdfSettings.FontFileName);

            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(850, 40, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            bitmap.SetResolution(500f, 200f);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage((System.Drawing.Image)bitmap);
            graphics.Clear(System.Drawing.Color.White);
            graphics.DrawString(Text ?? "", new System.Drawing.Font(familyName, fontSize, System.Drawing.FontStyle.Regular), System.Drawing.SystemBrushes.InfoText,
                (System.Drawing.PointF)new System.Drawing.Point(widthPoint, 3));

            return bitmap;
        }

请使用System.Web.HttpUtility.UrlEncode对代码中的字符进行编码,如下所示。 它对我有用,它应该对你有用。

string Address1= shippingAddressData.Address1;
Address1 = System.Web.HttpUtility.UrlEncode(Address1, System.Text.Encoding.UTF8)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM