Why does the font change when adding SVG to pdf?

Currently I am using iText7 version 8.0.4 to replace jpg files into svg files.
enter image description here
I replaced the jpg image with the svg image but the problem is that the font in my 2nd screenshot is wrong, the font I used in the svg file is “Lucida Console” but when I replace the svg file it changes to the font. “Time New Roman”. When the svg file is saved on my computer it still displays correctly, it’s just the wrong font when I add it to the pdf

This’s my .net code:

public bool ReplaceImageWithSvg(string inputPdf, string outputPdf)
{
    try
    {
        using (PdfReader pdfReader = new PdfReader(inputPdf))
        using (PdfWriter pdfWriter = new PdfWriter(outputPdf))
        using (PdfDocument pdfDocument = new PdfDocument(pdfReader, pdfWriter))
        {
            int numPages = pdfDocument.GetNumberOfPages();
            string tempPath = System.IO.Path.GetTempPath();

            for (int pageNum = 1; pageNum <= numPages; pageNum++)
            {
                PdfPage page = pdfDocument.GetPage(pageNum);

                IList<PdfAnnotation> annotations = new List<PdfAnnotation>(page.GetAnnotations());

                foreach (PdfAnnotation annotation in annotations)
                {
                    if (annotation.GetSubtype().Equals(PdfName.Link))
                    {
                        PdfLinkAnnotation linkAnnotation = (PdfLinkAnnotation)annotation;

                        // Check if the link annotation is associated with an image
                        PdfArray rect = linkAnnotation.GetRectangle();
                        if (rect != null && rect.Size() == 4)
                        {
                            var tempSvgFile = System.IO.Path.Combine(tempPath, Guid.NewGuid().ToString() + ".svg");
                            var imageUrl = ExtractURL(linkAnnotation.GetAction().ToString());

                            var svgContent = FetchSvgImageAsync(imageUrl);

                            var imageStream = ModifySvgFontAttributes(svgContent, _newFontFamily, _increaseFontSizeBy, _increaseFontWeight, _newStrokeWidth);

                            SaveSvgToFile(imageStream, tempSvgFile);

                            ReplaceImageWithSvg(page, rect, tempSvgFile);

                            page.RemoveAnnotation(linkAnnotation);

                            if (File.Exists(tempSvgFile))
                            {
                                File.Delete(tempSvgFile);
                            }
                        }
                    }
                }
            }
        }

        return true;
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error replacing image with SVG: {ex.Message}");
        return false;
    }
}

private void ReplaceImageWithSvg(PdfPage page, PdfArray rect, string svgImagePath)
{
    try
    {
        // Extract position and dimensions of the existing image
        float x = rect.GetAsNumber(0).FloatValue();
        float y = rect.GetAsNumber(1).FloatValue();
        // Added on to get rid of the border
        float width = rect.GetAsNumber(2).FloatValue() - x + _border;
        float height = rect.GetAsNumber(3).FloatValue() - y + _border;


        // Convert the SVG image to PdfFormXObject
        PdfDocument pdfDoc = page.GetDocument();
        using (Stream svgStream = File.OpenRead(svgImagePath))
        {
            PdfFormXObject svgObject = SvgConverter.ConvertToXObject(svgStream, pdfDoc);

            // Get the content stream of the page
            PdfCanvas canvas = new PdfCanvas(page);
            // Set fill color to white(or match the page background)
            canvas.SetFillColorGray(1.0f); // White color
            // Cover the area with a rectangle
            canvas.Rectangle(x, y, width, height);
            canvas.Fill();

            // Calculate the scale to fit the SVG in the specified rectangle
            // Assumes the SVG's aspect ratio matches the target rectangle.
            float scaleX = width / svgObject.GetWidth();
            float scaleY = height / svgObject.GetHeight();

            // Create transformation matrix for scaling and then translating the image
            float[] matrix = new float[] { scaleX, 0, 0, scaleY, x, y };

            // Add the SVG Form XObject to the canvas with transformation
            canvas.AddXObjectWithTransformationMatrix(svgObject, matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error replacing image with SVG: {ex.Message}");
    }
}

private string ModifySvgFontAttributes(string svgContent, string newFontFamily, string fontSizeIncrease, int fontWeightIncrease, string strokeWidth)
{
    XDocument svgDoc = XDocument.Parse(svgContent);

    // Update font-family
    var elementsWithFontFamily = svgDoc.Descendants().Where(e => e.Attribute("font-family") != null);
    foreach (var elem in elementsWithFontFamily)
    {
        elem.SetAttributeValue("font-family", newFontFamily);
    }

    return svgDoc.ToString();
}

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật