Subject: Changing Font/Brush/Style in Text
Date: 2011-07-20 20:22:17
From: Brian Geiman
Source: changing-font-brush-style-text
----------------------------------------------------------------------

Hello,

I am currently laying a paragraph down with DrawString using a Rectangle so that the text wraps at the right margin of the page.

I need to know if there is a way to change font / brush / style in the middle of the paragraph with a single DrawString call. I can not place the text down 1 piece / line at a time, since the text contains variable information of different lengths that may change where words wrap, etc..


Ex: (bold and itatlic text in the middle of the paragraph)

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nunc et libero neque. Donec rhoncus vulputate purus,
eget gravida turpis consectetur a. Mauris eu dolor turpis.
In hac habitasse platea dictumst.


Ex: (red text was variable and longer for this record causing words to wrap at a different location)

Lorem ipsum dolor sit amet, egestas non dui gravida
adipiscing elit. Nunc et libero neque. Donec rhoncus
vulputate purus, eget gravida turpis consectetur a.
Mauris eu dolor turpis. In hac habitasse platea dictumst.


This is an example of what I am kind of looking for:

page.Graphics.DrawString(
                    "Lorem ipsum dolor sit amet, <Color=Red>consectetur<Color=Black> adipiscing elit. Nunc et libero neque. <Style=Bold>Donec rhoncus<Style=Regular> vulputate purus, eget <Style=Italics,Underline>gravida turpis consectetur<Style=Regular> a. Mauris eu dolor turpis. In hac habitasse platea dictumst. ",
                    new PdfStandardFont(PdfFontFamily.TimesRoman, 12),
                    PdfBrushes.Black,
                    new RectangleF(0, 0 , 500, 500),
                    format
                    );

--
Thanks,

Brian Geiman
RR Donnelley
---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index