summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormiklosh <miklosh@users.sourceforge.net>2007-08-17 12:36:23 +0000
committermiklosh <miklosh@users.sourceforge.net>2007-08-17 12:36:23 +0000
commit8d53cd4a26ae7b31ccedaa5468b9b8d1a4762cd0 (patch)
tree1fde701ae48a6732ded83d99470aa4adc3b5b5a1 /src
parentOptimized text output by not repeating glyph coordinates when they are identical (diff)
downloadinkscape-8d53cd4a26ae7b31ccedaa5468b9b8d1a4762cd0.tar.gz
inkscape-8d53cd4a26ae7b31ccedaa5468b9b8d1a4762cd0.zip
Moved the code for updating the text matrix to where it belongs
(bzr r3493)
Diffstat (limited to 'src')
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp1
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp52
2 files changed, 27 insertions, 26 deletions
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index d27d4dab4..9233361b2 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -2065,6 +2065,7 @@ void PdfParser::opSetWordSpacing(Object args[], int numArgs) {
void PdfParser::opSetHorizScaling(Object args[], int numArgs) {
state->setHorizScaling(args[0].getNum());
+ builder->updateTextMatrix(state);
fontChanged = gTrue;
}
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 28da78d09..14f9c6102 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -853,6 +853,7 @@ void SvgBuilder::updateFont(GfxState *state) {
TRACE(("updateFont()\n"));
_need_font_update = false;
+ updateTextMatrix(state); // Ensure that we have a text matrix built
if (_font_style) {
//sp_repr_css_attr_unref(_font_style);
@@ -982,23 +983,13 @@ void SvgBuilder::updateFont(GfxState *state) {
// Font size
Inkscape::CSSOStringStream os_font_size;
- double *text_matrix = state->getTextMat();
- double w_scale = sqrt( text_matrix[0] * text_matrix[0] + text_matrix[2] * text_matrix[2] );
- double h_scale = sqrt( text_matrix[1] * text_matrix[1] + text_matrix[3] * text_matrix[3] );
- double max_scale;
- if ( w_scale > h_scale ) {
- max_scale = w_scale;
- } else {
- max_scale = h_scale;
- }
- double css_font_size = max_scale * state->getFontSize();
+ double css_font_size = _font_scaling * state->getFontSize();
if ( font->getType() == fontType3 ) {
double *font_matrix = font->getFontMatrix();
if ( font_matrix[0] != 0.0 ) {
css_font_size *= font_matrix[3] / font_matrix[0];
}
}
-
os_font_size << css_font_size;
sp_repr_css_set_property(_font_style, "font-size", os_font_size.str().c_str());
@@ -1009,20 +1000,6 @@ void SvgBuilder::updateFont(GfxState *state) {
sp_repr_css_set_property(_font_style, "writing-mode", "tb");
}
- // Calculate new text matrix
- NR::Matrix new_text_matrix(text_matrix[0] * state->getHorizScaling(),
- text_matrix[1] * state->getHorizScaling(),
- -text_matrix[2], -text_matrix[3],
- 0.0, 0.0);
-
- if ( fabs( max_scale - 1.0 ) > EPSILON ) {
- // Cancel out scaling by font size in text matrix
- for ( int i = 0 ; i < 4 ; i++ ) {
- new_text_matrix[i] /= max_scale;
- }
- }
- _text_matrix = new_text_matrix;
- _font_scaling = max_scale;
_current_font = font;
_invalidated_style = true;
}
@@ -1052,7 +1029,30 @@ void SvgBuilder::updateTextPosition(double tx, double ty) {
*/
void SvgBuilder::updateTextMatrix(GfxState *state) {
_flushText();
- updateFont(state); // Update text matrix
+ // Update text matrix
+ double *text_matrix = state->getTextMat();
+ double w_scale = sqrt( text_matrix[0] * text_matrix[0] + text_matrix[2] * text_matrix[2] );
+ double h_scale = sqrt( text_matrix[1] * text_matrix[1] + text_matrix[3] * text_matrix[3] );
+ double max_scale;
+ if ( w_scale > h_scale ) {
+ max_scale = w_scale;
+ } else {
+ max_scale = h_scale;
+ }
+ // Calculate new text matrix
+ NR::Matrix new_text_matrix(text_matrix[0] * state->getHorizScaling(),
+ text_matrix[1] * state->getHorizScaling(),
+ -text_matrix[2], -text_matrix[3],
+ 0.0, 0.0);
+
+ if ( fabs( max_scale - 1.0 ) > EPSILON ) {
+ // Cancel out scaling by font size in text matrix
+ for ( int i = 0 ; i < 4 ; i++ ) {
+ new_text_matrix[i] /= max_scale;
+ }
+ }
+ _text_matrix = new_text_matrix;
+ _font_scaling = max_scale;
}
/**