pdffontspdf-generationfont-style

PDF how define only one character front bold


I develop in php function that create simple pdf. I have text:

Lorem ipsum dolor sit amet.

But I want what character i always be bold.

How can I do this? (maybe in /Differences).

--edit--

%PDF-1.4
(..skipping...)
/F1 9 Tf
0 g 
BT
157 830 Td
(Lorem ) Tj
ET
/F2 9 Tf
0 g
BT
187 830 Td
(i) Tj
ET
/F1 9 Tf
0 g
BT
190 830 Td
(psum) Tj
ET
(..skipping...)
8 0 obj 
<</Type /Font /Encoding /WinAnsiEncoding /Subtype /Type1 /BaseFont /Helvetica >>
endobj
9 0 obj 
<</Type /Font /Encoding /WinAnsiEncoding /Subtype /Type1 /BaseFont /Helvetica-Bold >>
endobj

Solution

  • AFAIK the way you do it (switch between two fonts, regular and bold) is the only way. Except that you don't need to create new text block for each piece of text, just change the font in the current text block as needed:

    BT
     0 g 
     /F1 9 Tf
     157 830 Td
     (Lorem ) Tj
     /F2 9 Tf
     187 830 Td
     (i) Tj
     /F1 9 Tf
     190 830 Td
     (psum) Tj
    ET
    

    The glyph's visual appearance is coded in "font program" and /Differences can't be used to reference to different font.

    If the only character you ever need to show in bold is i then I would consider creating special font where the i is bold, but if you need to output text in such a styled way for any character then it is not practical...