diff --git a/TSDocxToPdf.tsf b/TSDocxToPdf.tsf index 10c5e99..7e03e33 100644 --- a/TSDocxToPdf.tsf +++ b/TSDocxToPdf.tsf @@ -122,7 +122,7 @@ begin elements := sect_ware.Elements(); for _,element in elements do begin - // if _ = 31 then break; + // if _ = 8 then break; // if _ = 3 then // println("_ = {}, xml_file_ = {}", _, xml_file_); if element.LocalName = "p" then {self.}TransformP(text_point_, element, w, lb); @@ -208,15 +208,13 @@ end; function TSDocxToPdf.InitSymbol(); begin symbol_ := array( - "": "※", - "": "■", - "": "●", - "": "◆", - - "": "●", - "": "■", - "": "●", - + "": chr(118), + "": chr(110), + "": chr(108), + "": chr(117), + "": chr(108), + "o": chr(109), + "": chr(110), ); end; diff --git a/range/Advanced/TSPdfParagraphRange.tsf b/range/Advanced/TSPdfParagraphRange.tsf index a905386..943ff85 100644 --- a/range/Advanced/TSPdfParagraphRange.tsf +++ b/range/Advanced/TSPdfParagraphRange.tsf @@ -498,10 +498,15 @@ begin a_word := text[pos : pos+num-1]; word := utf8ToAnsi(a_word); if num <> 1 and word = "?" then - word := utf8ToAnsi(docx_to_pdf_.GetSymbol(a_word)); - pos += num; - font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii; - font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B, rpr.I); + begin + word := docx_to_pdf_.GetSymbol(a_word); + if ifnil(word) then word := "u"; + font_obj := docx_to_pdf_.Font.GetSymbolFont(); + end + else begin + font_name := rpr.RFonts.EastAsia ? rpr.RFonts.EastAsia : rpr.RFonts.Ascii; + font_obj := docx_to_pdf_.Font.GetCNSFont(font_name, rpr.B, rpr.I); + end if not rpr.Sz.Val then rpr.Sz.Val := rpr.SzCs.Val ? rpr.SzCs.Val : docx_to_pdf_.Font.GetDefaultSz(); page_.PdfPage.SetFontAndSize(font_obj, rpr.Sz.Val); word_width := page_.PdfPage.TextWidth(word); @@ -512,6 +517,7 @@ begin text_range.Width := word_width; range_array_[length(range_array_)] := text_range; if ifarray(bookmark_array_[link]) then bookmark_array_[link] union= array(text_range); + pos += num; end end; diff --git a/ware/TSFontWare.tsf b/ware/TSFontWare.tsf index d9c036d..8cab086 100644 --- a/ware/TSFontWare.tsf +++ b/ware/TSFontWare.tsf @@ -1,18 +1,19 @@ type TSFontWare = class public function Create(pdf: PdfFile); - function GetFontByText(text: string; name: string; bold: boolean; italic: boolean); - function GetAsciiFont(name: string; bold: boolean; italic: boolean); - function GetCNSFont(name: string; bold: boolean; italic: boolean); + function GetFontByText(text: string; name: string; bold: boolean; italic: boolean): PdfFont; + function GetAsciiFont(name: string; bold: boolean; italic: boolean): PdfFont; + function GetCNSFont(name: string; bold: boolean; italic: boolean): PdfFont; + function GetSymbolFont(): PdfFont; function UseExternalFont(); function SetSubstitutionRules(source: string; target: string); function SetDefaultSz(value: real); - function GetDefaultSz(); + function GetDefaultSz(): real; private - function GetExternalFont(name:string; bold: boolean; italic: boolean); - function GetBuiltInCNSFont(name:string; bold: boolean; italic: boolean); - function GetBuiltInAsciiFont(name:string; bold: boolean; italic: boolean); + function GetExternalFont(name:string; bold: boolean; italic: boolean): PdfFont; + function GetBuiltInCNSFont(name:string; bold: boolean; italic: boolean): PdfFont; + function GetBuiltInAsciiFont(name:string; bold: boolean; italic: boolean): PdfFont; private [weakref]pdf_: PdfFile; @@ -71,7 +72,7 @@ begin return font; end; -function TSFontWare.GetFontByText(text: string; name: string; bold: boolean; italic: boolean); +function TSFontWare.GetFontByText(text: string; name: string; bold: boolean; italic: boolean): PdfFont; begin len := length(text); if len > 1 then @@ -80,12 +81,12 @@ begin return {self.}GetAsciiFont(name, bold, italic); end; -function TSFontWare.GetCNSFont(name: string; bold: boolean; italic: boolean); +function TSFontWare.GetCNSFont(name: string; bold: boolean; italic: boolean): PdfFont; begin return use_built_in_font_ ? {self.}GetBuiltInCNSFont(name, bold, italic) : {self.}GetExternalFont(name, bold, italic); end; -function TSFontWare.GetBuiltInCNSFont(name: string; bold: boolean; italic: boolean); +function TSFontWare.GetBuiltInCNSFont(name: string; bold: boolean; italic: boolean): PdfFont; begin font_name := substitution_rules_[name]; if ifnil(font_name) then font_name := "SimSun"; @@ -95,16 +96,15 @@ begin font_name += ",Bold"; else if italic then font_name += ",Italic"; - font := pdf_.GetFont(font_name, "GBK-EUC-H"); - return font; + return pdf_.GetFont(font_name, "GBK-EUC-H"); end; -function TSFontWare.GetAsciiFont(name: string; bold: boolean; italic: boolean); +function TSFontWare.GetAsciiFont(name: string; bold: boolean; italic: boolean): PdfFont; begin return use_built_in_font_ ? {self.}GetBuiltInAsciiFont(name, bold, italic) : {self.}GetExternalFont(name, bold, italic); end; -function TSFontWare.GetBuiltInAsciiFont(name:string; bold: boolean; italic: boolean); +function TSFontWare.GetBuiltInAsciiFont(name:string; bold: boolean; italic: boolean): PdfFont; begin font_name := substitution_rules_[name]; if ifnil(font_name) then font_name := "Times-Roman"; @@ -126,11 +126,15 @@ begin else if italic then font_name += "Times-Italic"; end - font := pdf_.GetFont(font_name, ""); - return font; + return pdf_.GetFont(font_name, ""); end; function TSFontWare.SetSubstitutionRules(source: string; target: string); begin substitution_rules_[source] := target; end; + +function TSFontWare.GetSymbolFont(): PdfFont; +begin + return pdf_.GetFont("ZapfDingbats", ""); +end;