27
26
# include "config.h"
34
#include "libnr/n-art-bpath.h"
35
#include "libnr/nr-point-matrix-ops.h"
36
#include "libnr/nr-rect.h"
37
#include "libnr/nr-matrix.h"
38
#include "libnr/nr-matrix-fns.h"
39
#include "libnr/nr-path.h"
40
#include "libnr/nr-pixblock.h"
41
#include "display/canvas-bpath.h"
33
#include <2geom/pathvector.h>
34
#include <2geom/rect.h>
35
#include <2geom/bezier-curve.h>
36
#include <2geom/hvlinesegment.h>
37
#include "helper/geom.h"
38
#include "helper/geom-curves.h"
39
//#include "display/canvas-bpath.h"
42
40
#include "sp-item.h"
45
#include "gtk/gtkdialog.h"
46
#include "gtk/gtkbox.h"
47
#include "gtk/gtkstock.h"
43
//#include "gtk/gtkdialog.h"
44
//#include "gtk/gtkbox.h"
45
//#include "gtk/gtkstock.h"
49
#include "glibmm/i18n.h"
47
//#include "glibmm/i18n.h"
49
//#include "document.h"
53
#include "sp-paint-server.h"
54
#include "inkscape_version.h"
56
#include "FontFactory.h"
57
#include "libnrtype/font-instance.h"
58
#include "libnrtype/font-style-to-pos.h"
51
//#include "sp-paint-server.h"
52
#include "inkscape-version.h"
54
//#include "libnrtype/FontFactory.h"
55
//#include "libnrtype/font-instance.h"
56
//#include "libnrtype/font-style-to-pos.h"
58
#define WIN32_LEAN_AND_MEAN
61
62
#include "emf-win32-print.h"
63
64
#include "unit-constants.h"
65
#include "extension/extension.h"
66
//#include "extension/extension.h"
66
67
#include "extension/system.h"
67
68
#include "extension/print.h"
73
#define WIN32_LEAN_AND_MEAN
76
74
namespace Inkscape {
77
75
namespace Extension {
165
165
HDC hScreenDC = GetDC( NULL );
167
167
// Get the physical characteristics of the reference DC
168
float PixelsX = (float) GetDeviceCaps( hScreenDC, HORZRES );
169
float PixelsY = (float) GetDeviceCaps( hScreenDC, VERTRES );
170
float MMX = (float) GetDeviceCaps( hScreenDC, HORZSIZE );
171
float MMY = (float) GetDeviceCaps( hScreenDC, VERTSIZE );
168
int PixelsX = GetDeviceCaps( hScreenDC, HORZRES );
169
int PixelsY = GetDeviceCaps( hScreenDC, VERTRES );
170
int MMX = GetDeviceCaps( hScreenDC, HORZSIZE );
171
int MMY = GetDeviceCaps( hScreenDC, VERTSIZE );
174
ZeroMemory(buff, sizeof(buff));
175
snprintf(buff, sizeof(buff)-1, "Inkscape %s (%s)", Inkscape::version_string, __DATE__);
176
INT len = strlen(buff);
177
CHAR *p1 = strrchr(ansi_uri, '\\');
178
CHAR *p2 = strrchr(ansi_uri, '/');
179
CHAR *p = MAX(p1, p2);
184
snprintf(buff+len+1, sizeof(buff)-len-2, "%s", p);
173
186
// Create the Metafile
174
if (PrintWin32::is_os_wide())
175
hdc = CreateEnhMetaFileW( hScreenDC, unicode_uri, &rc, NULL );
177
hdc = CreateEnhMetaFileA( hScreenDC, ansi_uri, &rc, NULL );
187
if (PrintWin32::is_os_wide()) {
189
ZeroMemory(wbuff, sizeof(wbuff));
190
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, buff, sizeof(buff)/sizeof(buff[0]), wbuff, sizeof(wbuff)/sizeof(wbuff[0]));
191
hdc = CreateEnhMetaFileW( hScreenDC, unicode_uri, &rc, wbuff );
194
hdc = CreateEnhMetaFileA( hScreenDC, ansi_uri, &rc, buff );
179
197
// Release the reference DC
180
198
ReleaseDC( NULL, hScreenDC );
191
209
SetMapMode( hdc, MM_ANISOTROPIC );
193
211
// Set the Windows extent
194
SetWindowExtEx( hdc, (int) (dwInchesX*dwDPI), (int) (dwInchesY*dwDPI), NULL );
212
int windowextX = (int) ceil(dwInchesX*dwDPI);
213
int windowextY = (int) ceil(dwInchesY*dwDPI);
214
SetWindowExtEx( hdc, windowextX, windowextY, NULL );
196
216
// Set the viewport extent to reflect
197
217
// dwInchesX" x dwInchesY" in device units
198
SetViewportExtEx( hdc,
199
(int) ((float) dwInchesX*25.4f*PixelsX/MMX),
200
(int) ((float) dwInchesY*25.4f*PixelsY/MMY),
218
int viewportextX = (int)((float)dwInchesX*25.4f*(float)PixelsX/(float)MMX);
219
int viewportextY = (int)((float)dwInchesY*25.4f*(float)PixelsY/(float)MMY);
220
SetViewportExtEx( hdc, viewportextX, viewportextY, NULL );
223
snprintf(buff, sizeof(buff)-1, "Screen=%dx%dpx, %dx%dmm", PixelsX, PixelsY, MMX, MMY);
224
GdiComment(hdc, strlen(buff), (BYTE*) buff);
226
snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * MM_PER_IN, dwInchesY * MM_PER_IN);
227
GdiComment(hdc, strlen(buff), (BYTE*) buff);
203
230
SetRect( &rc, 0, 0, (int) ceil(dwInchesX*dwDPI), (int) ceil(dwInchesY*dwDPI) );
205
232
g_free(local_fn);
206
233
g_free(unicode_fn);
235
m_tr_stack.push( Geom::Scale(1, -1) * Geom::Translate(0, sp_document_height(doc)));
213
PrintEmfWin32::finish (Inkscape::Extension::Print *mod)
242
PrintEmfWin32::finish (Inkscape::Extension::Print * /*mod*/)
215
244
if (!hdc) return 0;
412
445
PrintEmfWin32::flush_fill()
415
print_bpath(fill_path, &fill_transform, &fill_pbox);
447
if (!fill_pathv.empty()) {
448
stroke_and_fill = false;
450
print_pathv(fill_pathv, fill_transform);
425
PrintEmfWin32::copy_bpath(const NArtBpath *bp)
427
NArtBpath *tmp = (NArtBpath *) bp;
430
while (tmp->code != NR_END) {
435
tmp = new NArtBpath[num];
445
PrintEmfWin32::cmp_bpath(const NArtBpath *bp1, const NArtBpath *bp2)
451
while (bp1->code != NR_END && bp2->code != NR_END) {
452
if (bp1->code != bp2->code) {
456
if ( fabs(bp1->x1 - bp2->x1) > 0.00000001 ||
457
fabs(bp1->y1 - bp2->y1) > 0.00000001 ||
458
fabs(bp1->x2 - bp2->x2) > 0.00000001 ||
459
fabs(bp1->y2 - bp2->y2) > 0.00000001 ||
460
fabs(bp1->x3 - bp2->x3) > 0.00000001 ||
461
fabs(bp1->y3 - bp2->y3) > 0.00000001 )
470
return bp1->code != NR_END || bp2->code != NR_END;
474
PrintEmfWin32::bind(Inkscape::Extension::Print *mod, NRMatrix const *transform, float opacity)
476
text_transform = *transform;
481
PrintEmfWin32::release(Inkscape::Extension::Print *mod)
487
PrintEmfWin32::fill(Inkscape::Extension::Print *mod,
488
NRBPath const *bpath, NRMatrix const *transform, SPStyle const *style,
489
NRRect const *pbox, NRRect const *dbox, NRRect const *bbox)
460
PrintEmfWin32::bind(Inkscape::Extension::Print * /*mod*/, Geom::Matrix const *transform, float /*opacity*/)
462
Geom::Matrix tr = *transform;
464
if (m_tr_stack.size()) {
465
Geom::Matrix tr_top = m_tr_stack.top();
466
m_tr_stack.push(tr * tr_top);
475
PrintEmfWin32::release(Inkscape::Extension::Print * /*mod*/)
482
PrintEmfWin32::fill(Inkscape::Extension::Print * /*mod*/,
483
Geom::PathVector const &pathv, Geom::Matrix const * /*transform*/, SPStyle const *style,
484
NRRect const * /*pbox*/, NRRect const * /*dbox*/, NRRect const * /*bbox*/)
491
486
if (!hdc) return 0;
488
Geom::Matrix tf = m_tr_stack.top();
493
490
flush_fill(); // flush any pending fills
495
492
if (style->fill.isColor()) {
551
PrintEmfWin32::print_simple_shape(Geom::PathVector const &pathv, const Geom::Matrix &transform)
553
Geom::PathVector pv = pathv_to_linear_and_cubic_beziers( pathv * transform );
560
for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
565
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit)
569
if ( is_straight_curve(*cit) ) {
572
else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit)) {
582
POINT *lpPoints = new POINT[moves + lines + curves*3];
586
* For all Subpaths in the <path>
588
for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
593
Geom::Point p0 = pit->initialPoint();
595
p0[X] = (p0[X] * IN_PER_PX * dwDPI);
596
p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
598
LONG const x0 = (LONG) round(p0[X]);
599
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
606
* For all segments in the subpath
608
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit)
610
if ( is_straight_curve(*cit) )
612
//Geom::Point p0 = cit->initialPoint();
613
Geom::Point p1 = cit->finalPoint();
615
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
616
p1[X] = (p1[X] * IN_PER_PX * dwDPI);
617
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
618
p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
620
//LONG const x0 = (LONG) round(p0[X]);
621
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
622
LONG const x1 = (LONG) round(p1[X]);
623
LONG const y1 = (LONG) round(rc.bottom-p1[Y]);
629
else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit))
631
std::vector<Geom::Point> points = cubic->points();
632
//Geom::Point p0 = points[0];
633
Geom::Point p1 = points[1];
634
Geom::Point p2 = points[2];
635
Geom::Point p3 = points[3];
637
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
638
p1[X] = (p1[X] * IN_PER_PX * dwDPI);
639
p2[X] = (p2[X] * IN_PER_PX * dwDPI);
640
p3[X] = (p3[X] * IN_PER_PX * dwDPI);
641
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
642
p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
643
p2[Y] = (p2[Y] * IN_PER_PX * dwDPI);
644
p3[Y] = (p3[Y] * IN_PER_PX * dwDPI);
646
//LONG const x0 = (LONG) round(p0[X]);
647
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
648
LONG const x1 = (LONG) round(p1[X]);
649
LONG const y1 = (LONG) round(rc.bottom-p1[Y]);
650
LONG const x2 = (LONG) round(p2[X]);
651
LONG const y2 = (LONG) round(rc.bottom-p2[Y]);
652
LONG const x3 = (LONG) round(p3[X]);
653
LONG const y3 = (LONG) round(rc.bottom-p3[Y]);
665
lpPoints[i+1].x = x2;
666
lpPoints[i+1].y = y2;
667
lpPoints[i+2].x = x3;
668
lpPoints[i+2].y = y3;
675
bool closed = (lpPoints[0].x == lpPoints[i-1].x) && (lpPoints[0].y == lpPoints[i-1].y);
676
bool polygon = false;
677
bool rectangle = false;
678
bool ellipse = false;
680
if (moves == 1 && moves+lines == nodes && closed) {
683
if (lpPoints[0].x == lpPoints[3].x && lpPoints[1].x == lpPoints[2].x &&
684
lpPoints[0].y == lpPoints[1].y && lpPoints[2].y == lpPoints[3].y)
690
else if (moves == 1 && nodes == 5 && moves+curves == nodes && closed) {
691
if (lpPoints[0].x == lpPoints[1].x && lpPoints[1].x == lpPoints[11].x &&
692
lpPoints[5].x == lpPoints[6].x && lpPoints[6].x == lpPoints[7].x &&
693
lpPoints[2].x == lpPoints[10].x && lpPoints[3].x == lpPoints[9].x && lpPoints[4].x == lpPoints[8].x &&
694
lpPoints[2].y == lpPoints[3].y && lpPoints[3].y == lpPoints[4].y &&
695
lpPoints[8].y == lpPoints[9].y && lpPoints[9].y == lpPoints[10].y &&
696
lpPoints[5].y == lpPoints[1].y && lpPoints[6].y == lpPoints[0].y && lpPoints[7].y == lpPoints[11].y)
702
if (polygon || ellipse) {
705
HBRUSH hbrushTmp = NULL;
706
HBRUSH hbrushOld = NULL;
708
if (!stroke_and_fill) {
710
hpenTmp = (HPEN) GetStockObject(NULL_PEN);
711
hpenOld = (HPEN) SelectObject( hdc, hpenTmp );
713
else { // if (stroke_only)
714
hbrushTmp = (HBRUSH) GetStockObject(NULL_BRUSH);
715
hbrushOld = (HBRUSH) SelectObject( hdc, hbrushTmp );
721
Rectangle( hdc, lpPoints[0].x, lpPoints[0].y, lpPoints[2].x, lpPoints[2].y );
723
Polygon( hdc, lpPoints, nodes );
726
Ellipse( hdc, lpPoints[6].x, lpPoints[3].y, lpPoints[0].x, lpPoints[9].y);
732
SelectObject( hdc, hpenOld );
734
DeleteObject( hpenTmp );
736
SelectObject( hdc, hbrushOld );
738
DeleteObject( hbrushTmp );
551
PrintEmfWin32::print_bpath(const NArtBpath *bp, const NRMatrix *transform, NRRect const *pbox)
747
PrintEmfWin32::print_pathv(Geom::PathVector const &pathv, const Geom::Matrix &transform)
554
NR::Matrix tf = *transform;
749
simple_shape = print_simple_shape(pathv, transform);
754
Geom::PathVector pv = pathv_to_linear_and_cubic_beziers( pathv * transform );
556
756
BeginPath( hdc );
558
while (bp->code != NR_END) {
562
NR::Point p1(bp->c(1) * tf);
563
NR::Point p2(bp->c(2) * tf);
564
NR::Point p3(bp->c(3) * tf);
566
p1[X] = (p1[X] * IN_PER_PX * dwDPI);
567
p2[X] = (p2[X] * IN_PER_PX * dwDPI);
568
p3[X] = (p3[X] * IN_PER_PX * dwDPI);
569
p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
570
p2[Y] = (p2[Y] * IN_PER_PX * dwDPI);
571
p3[Y] = (p3[Y] * IN_PER_PX * dwDPI);
573
LONG const x1 = (LONG) round(p1[X]);
574
LONG const y1 = (LONG) round(rc.bottom-p1[Y]);
575
LONG const x2 = (LONG) round(p2[X]);
576
LONG const y2 = (LONG) round(rc.bottom-p2[Y]);
577
LONG const x3 = (LONG) round(p3[X]);
578
LONG const y3 = (LONG) round(rc.bottom-p3[Y]);
586
MoveToEx( hdc, x3, y3, NULL );
593
MoveToEx( hdc, x3, y3, NULL );
596
LineTo( hdc, x3, y3 );
759
* For all Subpaths in the <path>
761
for (Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
766
Geom::Point p0 = pit->initialPoint();
768
p0[X] = (p0[X] * IN_PER_PX * dwDPI);
769
p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
771
LONG const x0 = (LONG) round(p0[X]);
772
LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
774
MoveToEx( hdc, x0, y0, NULL );
777
* For all segments in the subpath
779
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit)
781
if ( is_straight_curve(*cit) )
783
//Geom::Point p0 = cit->initialPoint();
784
Geom::Point p1 = cit->finalPoint();
786
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
787
p1[X] = (p1[X] * IN_PER_PX * dwDPI);
788
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
789
p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
791
//LONG const x0 = (LONG) round(p0[X]);
792
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
793
LONG const x1 = (LONG) round(p1[X]);
794
LONG const y1 = (LONG) round(rc.bottom-p1[Y]);
796
LineTo( hdc, x1, y1 );
798
else if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*cit))
800
std::vector<Geom::Point> points = cubic->points();
801
//Geom::Point p0 = points[0];
802
Geom::Point p1 = points[1];
803
Geom::Point p2 = points[2];
804
Geom::Point p3 = points[3];
806
//p0[X] = (p0[X] * IN_PER_PX * dwDPI);
807
p1[X] = (p1[X] * IN_PER_PX * dwDPI);
808
p2[X] = (p2[X] * IN_PER_PX * dwDPI);
809
p3[X] = (p3[X] * IN_PER_PX * dwDPI);
810
//p0[Y] = (p0[Y] * IN_PER_PX * dwDPI);
811
p1[Y] = (p1[Y] * IN_PER_PX * dwDPI);
812
p2[Y] = (p2[Y] * IN_PER_PX * dwDPI);
813
p3[Y] = (p3[Y] * IN_PER_PX * dwDPI);
815
//LONG const x0 = (LONG) round(p0[X]);
816
//LONG const y0 = (LONG) round(rc.bottom-p0[Y]);
817
LONG const x1 = (LONG) round(p1[X]);
818
LONG const y1 = (LONG) round(rc.bottom-p1[Y]);
819
LONG const x2 = (LONG) round(p2[X]);
820
LONG const y2 = (LONG) round(rc.bottom-p2[Y]);
821
LONG const x3 = (LONG) round(p3[X]);
822
LONG const y3 = (LONG) round(rc.bottom-p3[Y]);
658
884
lf->lfEscapement = 0;
659
885
lf->lfOrientation = 0;
661
style->font_weight.value == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
662
style->font_weight.value == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
663
style->font_weight.value == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
664
style->font_weight.value == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
665
style->font_weight.value == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
666
style->font_weight.value == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
667
style->font_weight.value == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
668
style->font_weight.value == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
669
style->font_weight.value == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
670
style->font_weight.value == SP_CSS_FONT_WEIGHT_NORMAL ? FW_NORMAL :
671
style->font_weight.value == SP_CSS_FONT_WEIGHT_BOLD ? FW_BOLD :
672
style->font_weight.value == SP_CSS_FONT_WEIGHT_LIGHTER ? FW_EXTRALIGHT :
673
style->font_weight.value == SP_CSS_FONT_WEIGHT_BOLDER ? FW_EXTRABOLD :
887
style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
888
style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
889
style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
890
style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
891
style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
892
style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
893
style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
894
style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
895
style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
675
lf->lfItalic = (style->font_style.value == SP_CSS_FONT_STYLE_ITALIC);
897
lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC);
676
898
lf->lfUnderline = style->text_decoration.underline;
677
899
lf->lfStrikeOut = style->text_decoration.line_through;
678
900
lf->lfCharSet = DEFAULT_CHARSET;
698
920
lf->lfEscapement = 0;
699
921
lf->lfOrientation = 0;
701
style->font_weight.value == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
702
style->font_weight.value == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
703
style->font_weight.value == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
704
style->font_weight.value == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
705
style->font_weight.value == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
706
style->font_weight.value == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
707
style->font_weight.value == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
708
style->font_weight.value == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
709
style->font_weight.value == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
710
style->font_weight.value == SP_CSS_FONT_WEIGHT_NORMAL ? FW_NORMAL :
711
style->font_weight.value == SP_CSS_FONT_WEIGHT_BOLD ? FW_BOLD :
712
style->font_weight.value == SP_CSS_FONT_WEIGHT_LIGHTER ? FW_EXTRALIGHT :
713
style->font_weight.value == SP_CSS_FONT_WEIGHT_BOLDER ? FW_EXTRABOLD :
923
style->font_weight.computed == SP_CSS_FONT_WEIGHT_100 ? FW_THIN :
924
style->font_weight.computed == SP_CSS_FONT_WEIGHT_200 ? FW_EXTRALIGHT :
925
style->font_weight.computed == SP_CSS_FONT_WEIGHT_300 ? FW_LIGHT :
926
style->font_weight.computed == SP_CSS_FONT_WEIGHT_400 ? FW_NORMAL :
927
style->font_weight.computed == SP_CSS_FONT_WEIGHT_500 ? FW_MEDIUM :
928
style->font_weight.computed == SP_CSS_FONT_WEIGHT_600 ? FW_SEMIBOLD :
929
style->font_weight.computed == SP_CSS_FONT_WEIGHT_700 ? FW_BOLD :
930
style->font_weight.computed == SP_CSS_FONT_WEIGHT_800 ? FW_EXTRABOLD :
931
style->font_weight.computed == SP_CSS_FONT_WEIGHT_900 ? FW_HEAVY :
715
lf->lfItalic = (style->font_style.value == SP_CSS_FONT_STYLE_ITALIC);
933
lf->lfItalic = (style->font_style.computed == SP_CSS_FONT_STYLE_ITALIC);
716
934
lf->lfUnderline = style->text_decoration.underline;
717
935
lf->lfStrikeOut = style->text_decoration.line_through;
718
936
lf->lfCharSet = DEFAULT_CHARSET;
732
950
HFONT hfontOld = (HFONT) SelectObject(hdc, hfont);
735
953
sp_color_get_rgb_floatv( &style->fill.value.color, rgb );
736
954
SetTextColor(hdc, RGB(255*rgb[0], 255*rgb[1], 255*rgb[2]));
739
style->text_align.value == SP_CSS_TEXT_ALIGN_RIGHT ? TA_RIGHT :
740
style->text_align.value == SP_CSS_TEXT_ALIGN_CENTER ? TA_CENTER : TA_LEFT;
741
SetTextAlign(hdc, TA_BASELINE | align);
743
p = p * text_transform;
744
p[NR::X] = (p[NR::X] * IN_PER_PX * dwDPI);
745
p[NR::Y] = (p[NR::Y] * IN_PER_PX * dwDPI);
957
// - (x,y) coordinates received by this filter are those of the point where the text
958
// actually starts, and already takes into account the text object's alignment;
959
// - for this reason, the EMF text alignment must always be TA_BASELINE|TA_LEFT.
960
SetTextAlign(hdc, TA_BASELINE | TA_LEFT);
962
// Transparent text background
963
SetBkMode(hdc, TRANSPARENT);
965
Geom::Matrix tf = m_tr_stack.top();
968
p[Geom::X] = (p[Geom::X] * IN_PER_PX * dwDPI);
969
p[Geom::Y] = (p[Geom::Y] * IN_PER_PX * dwDPI);
971
LONG const xpos = (LONG) round(p[Geom::X]);
972
LONG const ypos = (LONG) round(rc.bottom-p[Geom::Y]);
747
974
if (PrintWin32::is_os_wide()) {
748
975
gunichar2 *unicode_text = g_utf8_to_utf16( text, -1, NULL, NULL, NULL );
749
TextOutW(hdc, p[NR::X], p[NR::Y], (WCHAR*)unicode_text, wcslen((wchar_t*)unicode_text));
976
TextOutW(hdc, xpos, ypos, (WCHAR*)unicode_text, wcslen((wchar_t*)unicode_text));
752
TextOutA(hdc, p[NR::X], p[NR::Y], (CHAR*)text, strlen((char*)text));
979
TextOutA(hdc, xpos, ypos, (CHAR*)text, strlen((char*)text));
755
982
SelectObject(hdc, hfontOld);
756
983
DeleteObject(hfont);