• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision39129de3df99e718fa1570ca9b3a6debe9b206af (tree)
Time2021-10-12 21:05:10
AuthorFojtik
CommiterFojtik

Log Message

Emit correctly centered text in images.

Change Summary

Incremental Difference

diff -r d2cb05133333 -r 39129de3df99 trunk/sources.cc/images/ras_img.cc
--- a/trunk/sources.cc/images/ras_img.cc Mon Oct 11 23:46:58 2021 +0200
+++ b/trunk/sources.cc/images/ras_img.cc Tue Oct 12 14:05:10 2021 +0200
@@ -34,6 +34,7 @@
3434
3535 #include "matrix.h"
3636 #include "imgsupp.h"
37+#include "struct.h"
3738
3839 #if SupportJPG>=4 || SupportJPG==2
3940 Raster2DAbstract *LoadFragmentJPG(FILE *F);
diff -r d2cb05133333 -r 39129de3df99 trunk/sources.cc/images/vecimage.cc
--- a/trunk/sources.cc/images/vecimage.cc Mon Oct 11 23:46:58 2021 +0200
+++ b/trunk/sources.cc/images/vecimage.cc Tue Oct 12 14:05:10 2021 +0200
@@ -1117,6 +1117,7 @@
11171117 TextObjects = 0;
11181118 FontOrientation = 0;
11191119 RotCenterX = RotCenterY = 0;
1120+ TextAllign = 0;
11201121 }
11211122
11221123
@@ -1142,7 +1143,7 @@
11421143 /// Append show only when needed. The intent is not to emit "() show". Too much empty
11431144 /// strings only bloat image. Of course that "(\()" is a string containing one character.
11441145 /// @param[in,out] str String that needs either cleanup or adding \show.
1145-void AppendShow(string &str)
1146+void AppendShow(string &str, unsigned char HorizontalPos)
11461147 {
11471148 int len = length(str);
11481149 if(len==0) return;
@@ -1158,6 +1159,11 @@
11581159 }
11591160 }
11601161 }
1162+ if((HorizontalPos & 6) == 6)
1163+ {
1164+ str += "\ndup stringwidth pop -2 div"
1165+ "\n0 rmoveto";
1166+ }
11611167 str += "\nshow";
11621168 }
11631169
@@ -1196,7 +1202,7 @@
11961202 FixPsAccent(Text[i]->contents,"\\\"{","(\\310)"); // umlaut
11971203 FixPsAccent2(Text[i]->contents,"\\accent39","( \\47)"); //insert space before apostrophe \\47
11981204
1199- if(i>0) AppendShow(str);
1205+ if(i>0) AppendShow(str,TextAllign);
12001206
12011207 if(PSS!=NULL)
12021208 {
@@ -1261,7 +1267,7 @@
12611267 }
12621268 }
12631269 }
1264- AppendShow(str);
1270+ AppendShow(str,TextAllign);
12651271 if(TextRotated)
12661272 {
12671273 str += "\ngrestore";
@@ -1342,7 +1348,7 @@
13421348 pTobj->contents = contents;
13431349
13441350 pTobj->size = PSS.FontSize;
1345- //pTobj->Weight = Weight;
1351+ //pTobj->Weight = Weight;
13461352 memcpy(&pTobj->TextColor,&PSS.TextColor,sizeof(RGB_Record));
13471353 }
13481354
diff -r d2cb05133333 -r 39129de3df99 trunk/sources.cc/images/vecimage.h
--- a/trunk/sources.cc/images/vecimage.h Mon Oct 11 23:46:58 2021 +0200
+++ b/trunk/sources.cc/images/vecimage.h Tue Oct 12 14:05:10 2021 +0200
@@ -346,6 +346,7 @@
346346 float PosX, PosY; ///< Tex start point.
347347 float FontOrientation; ///< Font rotation [deg]
348348 float RotCenterX, RotCenterY;
349+ BYTE TextAllign;
349350
350351 TextContainer();
351352 virtual ~TextContainer();
diff -r d2cb05133333 -r 39129de3df99 trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Mon Oct 11 23:46:58 2021 +0200
+++ b/trunk/sources.cc/pass1wmf.cc Tue Oct 12 14:05:10 2021 +0200
@@ -2,7 +2,7 @@
22 * program: wp2latex *
33 * function: Convert WordPerfect files into LaTeX. *
44 * modul: pass1wmf.cc *
5- * description: Opens Windows MetaFile. *
5+ * description: Opens Windows MetaFile and Enhanced Windows Metafile *
66 * licency: GPL *
77 ******************************************************************************/
88 // See https://en.wikipedia.org/wiki/Windows_Metafile
@@ -348,7 +348,7 @@
348348 void parse_ExtTextOut(VectorList &VectList);
349349 void parse_Rectangle(VectorList &VectList);
350350 void parse_SelectObject(void);
351- void parse_SetTextAllign(void);
351+ void parse_SetTextAlign(void);
352352 void parse_SetBkColor(void);
353353 void parse_SetMapMode(void);
354354 void parse_SetTextColor(void);
@@ -1141,13 +1141,13 @@
11411141 }
11421142
11431143
1144-void TconvertedPass1_WMF::parse_SetTextAllign(void)
1144+void TconvertedPass1_WMF::parse_SetTextAlign(void)
11451145 {
11461146 #ifdef DEBUG
1147- fprintf(log,"\n#TconvertedPass1_WMF::parse_SetTextAllign() ");fflush(log);
1147+ fprintf(log,"\n#TconvertedPass1_WMF::parse_SetTextAlign() ");fflush(log);
11481148 #endif
11491149 WORD TextAlignmentMode;
1150-static const char ObjName[] = "!SetTextAllign";
1150+static const char ObjName[] = "!SetTextAlign";
11511151
11521152 if(!CheckWmfRecSz(1))
11531153 {
@@ -1189,6 +1189,7 @@
11891189 TextContainer *pTextCont = new TextContainer;
11901190 pTextCont->PosX = 0;
11911191 pTextCont->PosY = 0;
1192+ pTextCont->TextAllign = PSS.TextAllign;
11921193 pTextCont->FontOrientation = PSS.FontOrientation10 / 10.0f;
11931194 LineLen = CurLineLen = 0;
11941195 XStart = StringLen & 1;
@@ -1233,7 +1234,7 @@
12331234 }
12341235 }
12351236 if(CurLineLen>LineLen) LineLen=CurLineLen;
1236- if(XStart>0) // Word allignment.
1237+ if(XStart>0) // Word alignment.
12371238 fseek(wpd,1,SEEK_CUR);
12381239
12391240 SWORD YStart;
@@ -1279,12 +1280,24 @@
12791280 Rd_word(wpd, &TextLen);
12801281 Rd_word(wpd, &fuOptions);
12811282
1283+ const float Scale = GetScale2PSU((TMapMode)MapMode);
12821284 int MaxTextLen = 2*(WmfRec.Size - 4);
12831285 if(fuOptions & 0x0004) // ETO_CLIPPED Rectangle provided
1284- {
1285- fseek(wpd, 8, SEEK_CUR); //TODO: dopsat!
1286+ {
1287+ fseek(wpd,8,SEEK_CUR);
12861288 MaxTextLen -= 8;
12871289 }
1290+#ifdef _DEBUG
1291+/*
1292+ else
1293+ {
1294+ const float sz = mm2PSu(PSS.FontSize)/2;
1295+ VectorRectangle *pVectRec = new VectorRectangle(Scale*y_pos-sz, Scale*y_pos+sz, Scale*x_pos-sz, Scale*x_pos+sz);
1296+ pVectRec->AttribFromPSS(PSS);
1297+ VectList.AddObject(pVectRec);
1298+ }
1299+*/
1300+#endif
12881301
12891302 if(MaxTextLen < TextLen)
12901303 {
@@ -1296,11 +1309,11 @@
12961309 TextLen = MaxTextLen;
12971310 }
12981311
1299- const float Scale = GetScale2PSU((TMapMode)MapMode);
13001312 TextContainer *pTextCont = new TextContainer;
13011313 pTextCont->PosX = Scale*x_pos;
13021314 pTextCont->PosY = Scale*y_pos;
13031315 pTextCont->FontOrientation = PSS.FontOrientation10 / 10.0f;
1316+ pTextCont->TextAllign = PSS.TextAllign;
13041317
13051318 LineLen = CurLineLen = 0;
13061319 if(log!=NULL) fputc(' ',log);
@@ -1322,6 +1335,7 @@
13221335 pTextCont->PosX = Scale*x_pos;
13231336 pTextCont->PosY = CurPosY;
13241337 pTextCont->FontOrientation = PSS.FontOrientation10 / 10.0f;
1338+ pTextCont->TextAllign = PSS.TextAllign;
13251339 }
13261340 }
13271341 else CurLineLen++;
@@ -1340,14 +1354,22 @@
13401354 pTextCont->AddText((char)c,PSS);
13411355 }
13421356 }
1357+
1358+ if(CurLineLen>LineLen) LineLen=CurLineLen;
1359+
13431360 if(pTextCont->isEmpty())
13441361 delete pTextCont;
1345- else
1362+ else
1363+ {
1364+ if((PSS.TextAllign & 6) == 6) // TA_CENTER
1365+ {
1366+ x_pos -= LineLen*mm2PSu(PSS.FontSizeW) / 2;
1367+ }
13461368 VectList.AddObject(pTextCont);
1369+ }
13471370 pTextCont=NULL;
13481371
1349- //if(VectList.isEmpty()) goto TEXT_OUT_FAIL;
1350- if(CurLineLen>LineLen) LineLen=CurLineLen;
1372+ //if(VectList.isEmpty()) goto TEXT_OUT_FAIL;
13511373
13521374 UpdateBBox(bbx, 0, x_pos, y_pos+0.1*mm2PSu(PSS.FontSize), // Extend down reserved space for character.
13531375 LineLen*mm2PSu(PSS.FontSizeW), -1.1*mm2PSu(PSS.FontSize));
@@ -1480,7 +1502,7 @@
14801502 case 0x012B: strcpy(ObjType,"!PaintRegion"); break;
14811503 case 0x012C: strcpy(ObjType,"!SelectClipRegion"); break;
14821504 case 0x012D: parse_SelectObject(); break;
1483- case 0x012E: parse_SetTextAllign(); break;
1505+ case 0x012E: parse_SetTextAlign(); break;
14841506
14851507 case 0x0139: strcpy(ObjType,"!ResizePalette"); break;
14861508
diff -r d2cb05133333 -r 39129de3df99 trunk/sources.cc/wp2latex.h
--- a/trunk/sources.cc/wp2latex.h Mon Oct 11 23:46:58 2021 +0200
+++ b/trunk/sources.cc/wp2latex.h Tue Oct 12 14:05:10 2021 +0200
@@ -18,7 +18,7 @@
1818 #define LineLength 80 /* Split lines after more than LineLength charcters */
1919
2020 #define VersionWP2L "3.pre101"
21-#define VersionDate "11 Oct 2021" /* day (space) month (space) full year */
21+#define VersionDate "12 Oct 2021" /* day (space) month (space) full year */
2222
2323 #ifndef false
2424 #define false 0
@@ -393,9 +393,10 @@
393393 #ifdef __cplusplus
394394 extern "C" {
395395 #endif
396- void InitGettext(const char *GtxtDomain);
396+ void InitGettext(const char *GtxtDomain);
397397 void CheckGettext(const char *PROG_NAME, const char *GtxtDomain);
398398 //char *gettext__ (const char *__msgid);
399+ void FixConsole2UTF8(void);
399400 #ifdef __cplusplus
400401 }
401402 #endif
Show on old repository browser