diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Editor.cxx | 11 | ||||
| -rw-r--r-- | src/Style.cxx | 5 | ||||
| -rw-r--r-- | src/ViewStyle.cxx | 6 | 
3 files changed, 14 insertions, 8 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index f7ad2f735..a606671dd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -853,7 +853,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart,  			} else {  				rcSegment.left = ll.positions[startseg] + xStart;  				rcSegment.right = ll.positions[i + 1] + xStart; -				// Only try do draw if really visible - enhances performance by not calling environment to  +				// Only try to draw if really visible - enhances performance by not calling environment to   				// draw strings that are completely past the right side of the window.  				if (rcSegment.left <= rcLine.right) {  					surface->DrawText(rcSegment, textFont, @@ -1236,20 +1236,27 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {  				PRectangle rcNumber = rcLine;  				rcNumber.right = rcNumber.left + lineNumberWidth;  				// Right justify -				rcNumber.left += lineNumberWidth -  +				rcNumber.left -=    					surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));  				surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,  				                  ypos + vsPrint.maxAscent, number, strlen(number),  				                  vsPrint.styles[STYLE_LINENUMBER].fore.allocated,   						  vsPrint.styles[STYLE_LINENUMBER].back.allocated);  			} + +			// When printing, the hdc and hdcTarget may be the same, so +			// changing the state of surfaceMeasure may change the underlying +			// state of surface. Therefore, any cached state is discarded before  +			// using each surface.  			// Copy this line and its styles from the document into local arrays  			// and determine the x position at which each character starts. +			surfaceMeasure->FlushCachedState();  			LineLayout ll;  			LayoutLine(line, surfaceMeasure, vsPrint, ll);  			// Draw the line +			surface->FlushCachedState();  			DrawLine(surface, vsPrint, line, xStart, rcLine, ll);  			ypos += vsPrint.lineHeight; diff --git a/src/Style.cxx b/src/Style.cxx index 120fd6e95..75dc6eb93 100644 --- a/src/Style.cxx +++ b/src/Style.cxx @@ -25,17 +25,14 @@ Style::~Style() {  Style &Style::operator=(const Style &source) {  	if (this == &source)  		return *this; -	// Crash: -	*(char *)0 = 1;  	Clear(Colour(0,0,0), Colour(0xff,0xff,0xff), -	        Platform::DefaultFontSize(), 0, +	        0, 0,  		false, false, false);  	fore.desired = source.fore.desired;  	back.desired = source.back.desired;  	bold = source.bold;  	italic = source.italic;  	size = source.size; -	fontName = source.fontName;  	eolFilled = source.eolFilled;  	return *this;  } diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index 976593de3..d5c36981b 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -53,6 +53,8 @@ ViewStyle::ViewStyle(const ViewStyle &source) {  	Init();  	for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {  		styles[sty] = source.styles[sty]; +		// Can't just copy fontname as its lifetime is relative to its owning ViewStyle +		styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);  	}  	for (int mrk=0;mrk<=MARKER_MAX;mrk++) {  		markers[mrk] = source.markers[mrk]; @@ -166,9 +168,9 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {  void ViewStyle::Refresh(Surface &surface) {  	selbar.desired = Platform::Chrome();  	selbarlight.desired = Platform::ChromeHighlight(); -	maxAscent = 1; -	maxDescent = 1;  	styles[STYLE_DEFAULT].Realise(surface, zoomLevel); +	maxAscent = styles[STYLE_DEFAULT].ascent; +	maxDescent = styles[STYLE_DEFAULT].descent;  	for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {  		if (i != STYLE_DEFAULT) {  			styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]); | 
