27#include <wx/filename.h>
28#include <wx/mstream.h>
29#include <wx/zstream.h>
30#include <wx/wfstream.h>
31#include <wx/datstrm.h>
32#include <wx/tokenzr.h>
45#include <fmt/format.h>
46#include <fmt/chrono.h>
47#include <fmt/ranges.h>
58#define GLM_ENABLE_EXPERIMENTAL
60#include <glm/gtx/euler_angles.hpp>
72 bool is_ascii7 =
true;
74 for(
size_t ii = 0; ii < aText.Len(); ii++ )
76 if( aText[ii] >= 0x7F )
87 for(
unsigned ii = 0; ii < aText.Len(); ii++ )
89 unsigned int code = aText[ii];
112 for(
size_t ii = 0; ii < aText.Len(); ii++ )
114 unsigned int code = aText[ii];
115 result += fmt::format(
"{:04X}", code);
127 std::string buf = fmt::format(
"{:g}", aValue );
131 if( buf.find(
'e' ) != std::string::npos || buf.find(
'E' ) != std::string::npos )
132 buf = fmt::format(
"{:.10f}", aValue );
134 if( buf.find(
'.' ) != std::string::npos )
137 while( buf.size() > 1 && buf.back() ==
'0' )
141 if( !buf.empty() && buf.back() ==
'.' )
156 result.reserve( aBytes.size() * 4 + 2 );
159 for(
unsigned char byte : aBytes )
161 if(
byte ==
'(' ||
byte ==
')' ||
byte ==
'\\' )
164 result.push_back(
static_cast<char>(
byte ) );
166 else if( byte < 32 || byte > 126 )
168 fmt::format_to( std::back_inserter(
result ),
"\\{:03o}",
byte );
172 result.push_back(
static_cast<char>(
byte ) );
224 wxASSERT_MSG( aWidth > 0,
"Plotter called to set negative pen width" );
241 r = ( r * a ) + ( 1 - a );
242 g = ( g * a ) + ( 1 - a );
243 b = ( b * a ) + ( 1 - a );
246 fmt::println(
m_workFile,
"{} {} {} rg {} {} {} RG",
271 fmt::println(
m_workFile,
"[{} {} {} {}] 0 d",
279 fmt::println(
m_workFile,
"[{} {} {} {} {} {}] 0 d",
303 if( aCornerRadius > 0 )
315 if( size.
x == 0 && size.
y == 0 )
327 std::vector<VECTOR2I> cornerList;
329 cornerList.emplace_back( p1.
x, p1.
y );
330 cornerList.emplace_back( p2.
x, p1.
y );
331 cornerList.emplace_back( p2.
x, p2.
y );
332 cornerList.emplace_back( p1.
x, p2.
y );
333 cornerList.emplace_back( p1.
x, p1.
y );
335 PlotPoly( cornerList, fill, width,
nullptr );
348 paintOp = width > 0 ?
'B' :
'f';
350 fmt::println(
m_workFile,
"{} {} {} {} re {}",
384 double magic =
radius * 0.551784;
389 "{} {} {} {} {} {} c "
390 "{} {} {} {} {} {} c "
391 "{} {} {} {} {} {} c "
392 "{} {} {} {} {} {} c {}",
416 const EDA_ANGLE& aAngle,
double aRadius )
418 std::vector<VECTOR2D>
path;
425 EDA_ANGLE endAngle = startAngle - aAngle;
430 if( startAngle > endAngle )
431 std::swap( startAngle, endAngle );
434 start.
x =
KiROUND( aCenter.
x + aRadius * ( -startAngle ).Cos() );
435 start.
y =
KiROUND( aCenter.
y + aRadius * ( -startAngle ).Sin() );
440 end.x =
KiROUND( aCenter.
x + aRadius * ( -ii ).Cos() );
441 end.y =
KiROUND( aCenter.
y + aRadius * ( -ii ).Sin() );
445 end.x =
KiROUND( aCenter.
x + aRadius * ( -endAngle ).Cos() );
446 end.y =
KiROUND( aCenter.
y + aRadius * ( -endAngle ).Sin() );
466 std::vector<VECTOR2D>
path =
arcPath( aCenter, aStartAngle, aAngle, aRadius );
468 if(
path.size() >= 2 )
473 for(
int ii = 1; ii < (int)
path.size(); ++ii )
500 if( aCornerList.size() <= 1 )
511 for(
unsigned ii = 1; ii < aCornerList.size(); ii++ )
520 else if( aWidth == 0 )
531 std::set<size_t> handledArcs;
532 std::vector<VECTOR2D>
path;
538 size_t arcIndex = aLineChain.
ArcIndex( ii );
540 if( !handledArcs.contains( arcIndex ) )
542 handledArcs.insert( arcIndex );
547 for(
const VECTOR2D& pt : std::ranges::reverse_view( arc_path ) )
548 path.emplace_back( pt );
559 if(
path.size() <= 1 )
565 for(
int ii = 1; ii < (int)
path.size(); ++ii )
574 else if( aWidth == 0 )
604 plume ==
'D' ?
'l' :
'm' );
615 VECTOR2I pix_size( aImage.GetWidth(), aImage.GetHeight() );
618 VECTOR2D drawsize( aScaleFactor * pix_size.
x, aScaleFactor * pix_size.
y );
621 VECTOR2I start( aPos.
x - drawsize.
x / 2, aPos.
y + drawsize.
y / 2 );
625 auto findHandleForImage =
626 [&](
const wxImage& aCurrImage ) ->
int
630 if(
image.IsSameAs( aCurrImage ) )
633 if(
image.GetWidth() != aCurrImage.GetWidth() )
636 if(
image.GetHeight() != aCurrImage.GetHeight() )
639 if(
image.GetType() != aCurrImage.GetType() )
642 if(
image.HasAlpha() != aCurrImage.HasAlpha() )
645 if(
image.HasMask() != aCurrImage.HasMask()
646 ||
image.GetMaskRed() != aCurrImage.GetMaskRed()
647 ||
image.GetMaskGreen() != aCurrImage.GetMaskGreen()
648 ||
image.GetMaskBlue() != aCurrImage.GetMaskBlue() )
653 int pixCount =
image.GetWidth() *
image.GetHeight();
655 if( memcmp(
image.GetData(), aCurrImage.GetData(), pixCount * 3 ) != 0 )
658 if(
image.HasAlpha() && memcmp(
image.GetAlpha(), aCurrImage.GetAlpha(), pixCount ) != 0 )
667 int imgHandle = findHandleForImage( aImage );
669 if( imgHandle == -1 )
685 fmt::println(
m_workFile,
"q {} 0 0 {} {} {} cm",
691 fmt::println(
m_workFile,
"/Im{} Do", imgHandle );
738 "<< /Length {} 0 R >>\nstream\n",
744 "<< /Length {} 0 R /Filter /FlateDecode >>\nstream\n",
770 unsigned char *inbuf =
new unsigned char[stream_len];
772 int rc = fread( inbuf, 1, stream_len,
m_workFile );
773 wxASSERT( rc == stream_len );
785 out_count = stream_len;
791 wxMemoryOutputStream memos(
nullptr, std::max( 2000l, stream_len ) ) ;
801 wxZlibOutputStream zos( memos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
803 zos.Write( inbuf, stream_len );
806 wxStreamBuffer* sb = memos.GetOutputStreamBuffer();
808 out_count = sb->Tell();
809 fwrite( sb->GetBufferStart(), 1, out_count,
m_outputFile );
824 const wxString& aParentPageNumber,
const wxString& aParentPageName )
830 m_pageName = aPageName.IsEmpty() ? wxString::Format(
_(
"Page %s" ),
832 : wxString::Format(
_(
"%s (Page %s)" ),
837 : wxString::Format(
_(
"%s (Page %s)" ),
860 "{} 0 0 {} 0 0 cm 1 J 1 j 0 0 0 rg 0 0 0 RG {} w",
868void WriteImageStream(
const wxImage& aImage, wxDataOutputStream& aOut, wxColor bg,
bool colorMode )
870 int w = aImage.GetWidth();
871 int h = aImage.GetHeight();
873 for(
int y = 0; y < h; y++ )
875 for(
int x = 0; x < w; x++ )
877 unsigned char r = aImage.GetRed( x, y ) & 0xFF;
878 unsigned char g = aImage.GetGreen( x, y ) & 0xFF;
879 unsigned char b = aImage.GetBlue( x, y ) & 0xFF;
881 if( aImage.HasMask() )
883 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen() && b == aImage.GetMaskBlue() )
900 unsigned char grey =
KiROUND( r * 0.2126 + g * 0.7152 + b * 0.0722 );
911 int w = aImage.GetWidth();
912 int h = aImage.GetHeight();
914 if( aImage.HasMask() )
916 for(
int y = 0; y < h; y++ )
918 for(
int x = 0; x < w; x++ )
920 unsigned char a = 255;
921 unsigned char r = aImage.GetRed( x, y );
922 unsigned char g = aImage.GetGreen( x, y );
923 unsigned char b = aImage.GetBlue( x, y );
925 if( r == aImage.GetMaskRed() && g == aImage.GetMaskGreen() && b == aImage.GetMaskBlue() )
932 else if( aImage.HasAlpha() )
935 aOut.Write8( aImage.GetAlpha(), size );
954 const double PTsPERMIL = 0.072;
957 auto iuToPdfUserSpace =
970 retval.
x = ( psPaperSize.
x - pos.
x );
979 std::vector<int> annotHandles;
985 const BOX2I& box = linkPair.first;
986 const wxString& url = linkPair.second;
993 userSpaceBox.
SetEnd( topRight );
1002 const BOX2I& box = menuPair.first;
1003 const std::vector<wxString>& urls = menuPair.second;
1010 userSpaceBox.
SetEnd( topRight );
1017 int annot3DHandle = -1;
1022 annotHandles.push_back( annot3DHandle );
1026 int annotArrayHandle = -1;
1029 if( annotHandles.size() > 0 )
1032 bool isFirst =
true;
1036 for(
int handle : annotHandles )
1059 " /ProcSet [/PDF /Text /ImageC /ImageB]\n"
1061 " /XObject {} 0 R >>\n"
1062 "/MediaBox [0 0 {} {}]\n",
1072 if( annotHandles.size() > 0 )
1073 fmt::print(
m_outputFile,
"/Annots {} 0 R", annotArrayHandle );
1086 "/Rect [0 0 {} {}]\n"
1087 "/NM (3D Annotation)\n"
1090 "/3DA<</A/PO/D/PC/TB true/NP true>>\n"
1111 std::stack<OUTLINE_NODE*> nodes;
1114 while( !nodes.empty() )
1128 nodes.push( child );
1140 for(
const std::pair<BOX2I, wxString>& bookmarkPair : groupVector )
1142 const BOX2I& box = bookmarkPair.first;
1143 const wxString& ref = bookmarkPair.second;
1148 actionHandle =
emitGoToAction( pageHandle, bottomLeft, topRight );
1153 std::sort( groupOutlineNode->
children.begin(), groupOutlineNode->
children.end(),
1156 return a->title < b->title;
1169 return StartPlot( aPageNumber, wxEmptyString );
1202 fmt::print(
m_outputFile,
"%PDF-1.5\n%\200\201\202\203\n" );
1229 "<</S /GoTo /D [{} 0 R /FitR {} {} {} {}]\n"
1239 return actionHandle;
1249 "<</S /GoTo /D [{} 0 R /Fit]\n"
1255 return actionHandle;
1262 int prevHandle = -1;
1263 int nextHandle = -1;
1265 for( std::vector<OUTLINE_NODE*>::iterator it = node->
children.begin(); it != node->
children.end(); it++ )
1267 if( it >= node->
children.end() - 1 )
1270 nextHandle = ( *( it + 1 ) )->entryHandle;
1274 prevHandle = ( *it )->entryHandle;
1278 if( parentHandle != -1 )
1290 fmt::println(
m_outputFile,
"/Next {} 0 R", nextNode );
1293 fmt::println(
m_outputFile,
"/Prev {} 0 R", prevNode );
1297 int32_t count = -1 *
static_cast<int32_t
>( node->
children.size() );
1313 const wxString& aTitle )
1334 "<< /Type /Outlines\n"
1374 if( !glyph.m_stream.empty() )
1375 fmt::print(
m_workFile,
"{}\n", glyph.m_stream );
1378 glyph.m_charProcHandle = charProcHandle;
1385 fmt::println(
m_outputFile,
" /{} {} 0 R", glyph.m_name, glyph.m_charProcHandle );
1400 double fontMatrixScale = 1.0 / subset.
UnitsPerEm();
1408 "<<\n/Type /Font\n/Subtype /Type3\n/Name {}\n/FontBBox [ {} {} {} {} ]\n",
1415 "/FontMatrix [ {} 0 0 {} 0 0 ]\n/CharProcs {} 0 R\n",
1420 "/Encoding << /Type /Encoding /Differences {} >>\n",
1423 "/FirstChar {}\n/LastChar {}\n/Widths {}\n",
1428 "/ToUnicode {} 0 R\n/Resources << /ProcSet [/PDF /Text] >>\n>>\n",
1443 if( !subsetPtr || !subsetPtr->HasGlyphs() )
1446 const std::vector<uint8_t>& fontData = subsetPtr->FontFileData();
1448 if( fontData.empty() )
1452 subsetPtr->SetFontFileHandle( fontFileHandle );
1454 if( !fontData.empty() )
1455 fwrite( fontData.data(), fontData.size(), 1,
m_workFile );
1459 std::string cidMap = subsetPtr->BuildCIDToGIDStream();
1461 subsetPtr->SetCIDMapHandle( cidMapHandle );
1463 if( !cidMap.empty() )
1464 fwrite( cidMap.data(), cidMap.size(), 1,
m_workFile );
1468 std::string toUnicode = subsetPtr->BuildToUnicodeCMap();
1470 subsetPtr->SetToUnicodeHandle( toUnicodeHandle );
1472 if( !toUnicode.empty() )
1478 subsetPtr->SetFontDescriptorHandle( descriptorHandle );
1481 "<<\n/Type /FontDescriptor\n/FontName /{}\n/Flags {}\n/ItalicAngle {}\n/Ascent {}\n/Descent {}\n"
1482 "/CapHeight {}\n/StemV {}\n/FontBBox [ {} {} {} {} ]\n/FontFile2 {} 0 R\n>>\n",
1483 subsetPtr->BaseFontName(),
1494 subsetPtr->FontFileHandle() );
1498 subsetPtr->SetCIDFontHandle( cidFontHandle );
1500 std::string widths = subsetPtr->BuildWidthsArray();
1503 "<<\n/Type /Font\n/Subtype /CIDFontType2\n/BaseFont /{}\n"
1504 "/CIDSystemInfo << /Registry (Adobe) /Ordering (Identity) /Supplement 0 >>\n"
1505 "/FontDescriptor {} 0 R\n/W {}\n/CIDToGIDMap {} 0 R\n>>\n",
1506 subsetPtr->BaseFontName(),
1507 subsetPtr->FontDescriptorHandle(),
1509 subsetPtr->CIDMapHandle() );
1513 subsetPtr->SetFontHandle( fontHandle );
1516 "<<\n/Type /Font\n/Subtype /Type0\n/BaseFont /{}\n/Encoding /Identity-H\n"
1517 "/DescendantFonts [ {} 0 R ]\n/ToUnicode {} 0 R\n>>\n",
1518 subsetPtr->BaseFontName(),
1519 subsetPtr->CIDFontHandle(),
1520 subsetPtr->ToUnicodeHandle() );
1538 if( subsetPtr && subsetPtr->FontHandle() >= 0 )
1539 fmt::println(
m_outputFile,
" {} {} 0 R", subsetPtr->ResourceName(), subsetPtr->FontHandle() );
1562 fmt::print(
m_outputFile,
" /Im{} {} 0 R\n", imgHandle, imgHandle );
1582 "/BitsPerComponent 8\n"
1586 "/Filter /FlateDecode\n"
1593 if( smaskHandle != -1 )
1594 fmt::println(
m_outputFile,
"/SMask {} 0 R", smaskHandle );
1602 wxFFileOutputStream ffos( outputFFile );
1603 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1604 wxDataOutputStream dos( zos );
1610 long imgStreamSize = ftell(
m_outputFile ) - imgStreamStart;
1619 if( smaskHandle != -1 )
1629 "/BitsPerComponent 8\n"
1630 "/ColorSpace /DeviceGray\n"
1634 "/Filter /FlateDecode\n"
1645 wxFFileOutputStream ffos( outputFFile );
1646 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
1647 wxDataOutputStream dos( zos );
1652 long smaskStreamSize = ftell(
m_outputFile ) - smaskStreamStart;
1658 fmt::println(
m_outputFile,
"{}", (
unsigned) smaskStreamSize );
1662 outputFFile.Detach();
1667 BOX2D box = linkPair.first;
1668 wxString url = linkPair.second;
1676 "/Rect [{} {} {} {}]\n"
1677 "/Border [16 16 0]\n",
1683 wxString pageNumber;
1684 bool pageFound =
false;
1693 "/Dest [{} 0 R /FitB]\n"
1706 "/A << /Type /Action /S /NOP >>\n"
1716 "/A << /Type /Action /S /URI /URI {} >>\n"
1726 const BOX2D& box = menuPair.first;
1727 const std::vector<wxString>& urls = menuPair.second;
1728 wxString js = wxT(
"ShM([\n" );
1730 for(
const wxString& url : urls )
1732 if( url.StartsWith(
"!" ) )
1734 wxString
property = url.AfterFirst(
'!' );
1736 if( property.Find(
"http:" ) >= 0 )
1738 wxString href =
property.substr( property.Find(
"http:" ) );
1746 else if( property.Find(
"https:" ) >= 0 )
1748 wxString href =
property.substr( property.Find(
"https:" ) );
1756 else if( property.Find(
"file:" ) >= 0 )
1758 wxString href =
property.substr( property.Find(
"file:" ) );
1764 wxString displayText =
property.substr( 0, property.Find(
"file:" ) ) + href;
1772 int eqPos =
property.Find( wxS(
" = " ) );
1774 bool converted =
false;
1776 if( eqPos != wxNOT_FOUND )
1778 href =
property.Mid( eqPos + 3 );
1783 if( href.StartsWith( wxS(
"/" ) ) || href.StartsWith( wxS(
"${" ) )
1784 || ( href.Length() >= 2 && wxIsalpha( href[0] ) && href[1] ==
':' )
1785 || href.StartsWith( wxS(
"\\\\" ) ) )
1787 if( !href.StartsWith( wxS(
"/" ) ) )
1789 href.Replace( wxS(
"\\" ), wxS(
"/" ) );
1791 if( href.StartsWith( wxS(
"//" ) ) )
1792 href = wxS(
"file:" ) + href;
1794 href = wxS(
"file:///" ) + href;
1798 href = wxS(
"file://" ) + href;
1817 else if( url.StartsWith(
"#" ) )
1819 wxString pageNumber = url.AfterFirst(
'#' );
1825 wxString menuText = wxString::Format(
_(
"Show Page %s" ), pageNumber );
1827 js += wxString::Format( wxT(
"[\"%s\", \"#%d\"],\n" ),
1829 static_cast<int>( ii ) );
1836 wxString href = url;
1842 if( !href.StartsWith( wxS(
"http:" ) ) && !href.StartsWith( wxS(
"https:" ) )
1843 && !href.StartsWith( wxS(
"file:" ) ) )
1845 if( href.StartsWith( wxS(
"/" ) ) || href.StartsWith( wxS(
"${" ) ) )
1847 href = wxS(
"file://" ) + href;
1849 else if( href.Length() >= 2 && wxIsalpha( href[0] ) && href[1] ==
':' )
1851 href.Replace( wxS(
"\\" ), wxS(
"/" ) );
1852 href = wxS(
"file:///" ) + href;
1854 else if( href.StartsWith( wxS(
"\\\\" ) ) )
1856 href.Replace( wxS(
"\\" ), wxS(
"/" ) );
1857 href = wxS(
"file:" ) + href;
1861 if( href.StartsWith( wxS(
"file:" ) ) )
1864 if( href.StartsWith( wxS(
"http:" ) ) || href.StartsWith( wxS(
"https:" ) )
1865 || href.StartsWith( wxS(
"file:" ) ) )
1867 wxString menuText = wxString::Format(
_(
"Open %s" ), href );
1883 "/Rect [{} {} {} {}]\n"
1884 "/Border [16 16 0]\n",
1891 "/A << /Type /Action /S /JavaScript /JS {} >>\n"
1902function ShM(aEntries) {
1904 for (var i = 0; i < aEntries.length; ++i) {
1906 cName: aEntries[i][0],
1907 cReturn: aEntries[i].length > 1 ? aEntries[i][1] : ''
1911 var cChoice = app.popUpMenuEx.apply(app, aParams);
1912 if (cChoice == null || cChoice == '') return;
1914 if (cChoice.substring(0, 1) == '#') {
1915 this.pageNum = parseInt(cChoice.slice(1));
1919 // Fallback: some viewers return cName instead of cReturn
1921 if (url.substring(0, 4) != 'http' && url.substring(0, 4) != 'file') {
1922 var idx = url.indexOf('http');
1923 if (idx < 0) idx = url.indexOf('file:');
1924 if (idx >= 0) url = url.substring(idx);
1928 if (url.substring(0, 8) == 'file:///') app.openDoc(url.substring(7));
1929 else if (url.substring(0, 7) == 'file://') app.openDoc('//' + url.substring(7));
1930 else app.launchURL(url);
1937 " [ (JSInit) << /Type /Action /S /JavaScript /JS {} >> ]\n"
1979 std::time_t time = std::time(
nullptr );
1981#if defined( _WIN32 ) || defined( _MSC_VER )
1982 localtime_s( &tm, &time );
1984 localtime_r( &time, &tm );
1986 std::string dt = fmt::format(
"D:{:%Y:%m:%d:%H:%M:%S}", tm );
1997 "/Producer (KiCad PDF)\n"
1998 "/CreationDate ({})\n"
2013 int outlineHandle = -1;
2021 if( outlineHandle > 0 )
2028 "/PageMode /UseOutlines\n"
2029 "/Outlines {} 0 R\n"
2031 "/PageLayout /SinglePage\n"
2044 "/PageMode /UseNone\n"
2045 "/PageLayout /SinglePage\n"
2059 "0000000000 65535 f \n",
2062 for(
unsigned i = 1; i <
m_xrefTable.size(); i++ )
2068 "<< /Size {} /Root {} 0 R /Info {} 0 R >>\n"
2086 const wxString& aText,
2094 bool aMultilineAllowed,
2100 if( aSize.
x == 0 || aSize.
y == 0 )
2103 wxString
text( aText );
2105 if(
text.Contains( wxS(
"@{" ) ) )
2118 bool textMirrored = aSize.
x < 0;
2126 std::unique_ptr<MARKUP::NODE> markupTree( markupParser.
Parse() );
2130 wxLogTrace(
tracePdfPlotter,
"PDF_PLOTTER::Text: Markup parsing failed, falling back to plain text." );
2132 wxStringTokenizer str_tok(
text,
" ", wxTOKEN_RET_DELIMS );
2135 while( str_tok.HasMoreTokens() )
2137 wxString word = str_tok.GetNextToken();
2138 pos =
renderWord( word, pos, t_size, aOrient, textMirrored, aWidth, aBold, aItalic, aFont,
2139 aFontMetrics, aV_justify, 0 );
2168 std::vector<OVERBAR_INFO> overbars;
2169 renderMarkupNode( markupTree.get(), pos, t_size, aOrient, textMirrored, aWidth, aBold, aItalic, aFont,
2170 aFontMetrics, aV_justify, 0, overbars );
2178 const EDA_ANGLE& aOrient,
bool aTextMirrored,
int aWidth,
bool aBold,
bool aItalic,
2182 if( wxGetEnv(
"KICAD_DEBUG_SYN_STYLE",
nullptr ) )
2189 styleFlags = (int) face->style_flags;
2192 wxLogTrace(
tracePdfPlotter,
"renderWord enter word='%s' bold=%d italic=%d textStyle=%u styleFlags=%d",
2193 TO_UTF8( aWord ), (
int) aBold, (
int) aItalic, (
unsigned) aTextStyle, styleFlags );
2216 auto cursorAdvanceX = [&](
const wxString& aText )
2223 if( aWord == wxT(
" " ) )
2225 VECTOR2I spaceBox( cursorAdvanceX( wxT(
" " ) ), 0 );
2230 VECTOR2I rotatedSpaceBox = spaceBox;
2232 return aPosition + rotatedSpaceBox;
2237 if( aWord.Contains( wxT(
'\t' ) ) )
2239 constexpr double TAB_WIDTH = 4 * 0.6;
2244 for( wxUniChar c : aWord )
2248 if( !segment.IsEmpty() )
2250 pos =
renderWord( segment, pos, aSize, aOrient, aTextMirrored, aWidth, aBold, aItalic,
2251 aFont, aFontMetrics, aV_justify, aTextStyle );
2255 int tabWidth =
KiROUND( aSize.
x * TAB_WIDTH );
2256 int currentIntrusion = ( pos.
x - aPosition.
x ) % tabWidth;
2257 VECTOR2I tabAdvance( tabWidth - currentIntrusion, 0 );
2271 if( !segment.IsEmpty() )
2273 pos =
renderWord( segment, pos, aSize, aOrient, aTextMirrored, aWidth, aBold, aItalic,
2274 aFont, aFontMetrics, aV_justify, aTextStyle );
2281 double ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f;
2282 double wideningFactor, heightFactor;
2286 &ctm_a, &ctm_b, &ctm_c, &ctm_d, &ctm_e, &ctm_f, &heightFactor );
2288 VECTOR2I bbox( cursorAdvanceX( aWord ), 0 );
2294 VECTOR2I nextPos = aPosition + bbox;
2301 double factor = aFont->
IsOutline() ? 0.050 : 0.030;
2302 VECTOR2I offset( 0,
static_cast<int>( std::lround( aSize.
y * factor ) ) );
2313 offset.
y =
static_cast<int>( std::lround( aSize.
y * 0.01 ) );
2323 std::vector<PDF_OUTLINE_FONT_RUN> outlineRuns;
2333 if( !outlineRuns.empty() )
2336 double baseline_factor = 0.17;
2337 double alignment_multiplier = 1.0;
2340 alignment_multiplier = 2.0;
2342 alignment_multiplier = 4.0;
2345 double baseline_adjustment = font_size_dev.
y * baseline_factor * alignment_multiplier;
2347 double adjusted_ctm_e = ctm_e;
2348 double adjusted_ctm_f = ctm_f;
2351 double cos_angle = cos( angle_rad );
2352 double sin_angle = sin( angle_rad );
2354 adjusted_ctm_e = ctm_e - baseline_adjustment * sin_angle;
2355 adjusted_ctm_f = ctm_f + baseline_adjustment * cos_angle;
2357 double adj_c = ctm_c;
2358 double adj_d = ctm_d;
2361 bool syntheticItalicApplied =
false;
2362 double appliedTilt = 0.0;
2363 double syn_c = adj_c;
2364 double syn_d = adj_d;
2365 double syn_a = ctm_a;
2366 double syn_b = ctm_b;
2369 if( std::getenv(
"KICAD_FORCE_SYN_ITALIC" ) )
2373 bool fontIsItalic = aFont->
IsItalic();
2374 bool fontIsBold = aFont->
IsBold();
2382 bool forceSynItalic =
false;
2383 double overrideTilt = 0.0;
2385 if(
const char* envForce = std::getenv(
"KICAD_FORCE_SYN_ITALIC" ) )
2387 if( *envForce !=
'\0' && *envForce !=
'0' )
2388 forceSynItalic =
true;
2391 if(
const char* envTilt = std::getenv(
"KICAD_SYN_ITALIC_TILT" ) )
2393 std::string tiltStr( envTilt );
2397 if( tiltStr.find(
"deg" ) != std::string::npos )
2399 double deg = std::stod( tiltStr );
2400 overrideTilt = tan( deg *
M_PI / 180.0 );
2404 overrideTilt = std::stod( tiltStr );
2415 "Outline path word='%s' runs=%zu wantItalic=%d fontIsItalic=%d fontIsFakeItalic=%d wantBold=%d fontIsBold=%d fontIsFakeBold=%d forceSyn=%d",
2416 TO_UTF8( aWord ), outlineRuns.size(), (
int) wantItalic, (
int) fontIsItalic,
2417 (
int) fontIsFakeItalic, (
int) wantBold, (
int) fontIsBold, (
int) fontIsFakeBold,
2418 (
int) forceSynItalic );
2424 bool realItalicFace = fontIsItalic && !fontIsFakeItalic;
2426 if( wantItalic && ( forceSynItalic || !realItalicFace ) )
2437 double tilt = ( overrideTilt != 0.0 ) ? overrideTilt :
ITALIC_TILT;
2439 if( wideningFactor < 0 )
2442 syn_c = adj_c + tilt * syn_a;
2443 syn_d = adj_d + tilt * syn_b;
2445 syntheticItalicApplied =
true;
2447 wxLogTrace(
tracePdfPlotter,
"Synthetic italic shear applied: tilt=%f a=%f b=%f c->%f d->%f",
2448 tilt, syn_a, syn_b, syn_c, syn_d );
2451 if( wantBold && !fontIsBold )
2458 if( syntheticItalicApplied )
2461 fmt::print(
m_workFile,
"% syn-italic tilt={} a={} b={} c={} d={}\n",
2462 appliedTilt, syn_a, syn_b, syn_c, syn_d );
2465 fmt::print(
m_workFile,
"q {:f} {:f} {:f} {:f} {:f} {:f} cm BT {} Tr {} Tz ",
2466 syn_a, syn_b, syn_c, syn_d, adjusted_ctm_e, adjusted_ctm_f,
2478 static_cast<unsigned char>( ( glyph.
cid >> 8 ) & 0xFF ),
2479 static_cast<unsigned char>( glyph.
cid & 0xFF ) );
2495 wxLogTrace(
tracePdfPlotter,
"Stroke path word='%s' wantItalic=%d aItalic=%d aBold=%d",
2498 std::vector<PDF_STROKE_FONT_RUN> runs;
2504 double fontSize = dev_size.
y;
2506 double adj_c = ctm_c;
2507 double adj_d = ctm_d;
2513 if( wideningFactor < 0 )
2516 adj_c -= ctm_a * tilt;
2517 adj_d -= ctm_b * tilt;
2530 double deltaDev = 0.0;
2532 switch( aV_justify )
2535 deltaDev = yOffsetEm * fontSize - 3.0 * thicknessDev;
2539 deltaDev = ( yOffsetEm - 0.085 ) * fontSize - 1.5 * thicknessDev;
2543 deltaDev = ( yOffsetEm - 0.17 ) * fontSize;
2555 const double adj_ctm_e = ctm_e - deltaDev * adj_c;
2556 const double adj_ctm_f = ctm_f - deltaDev * adj_d;
2558 fmt::print(
m_workFile,
"q {:f} {:f} {:f} {:f} {:f} {:f} cm BT {} Tr {} Tz ",
2559 ctm_a, ctm_b, adj_c, adj_d, adj_ctm_e, adj_ctm_f,
2566 run.m_subset->ResourceName(),
2582 bool aTextMirrored,
int aWidth,
bool aBaseBold,
bool aBaseItalic,
2585 std::vector<OVERBAR_INFO>& aOverbars )
2590 return nextPosition;
2594 bool drawOverbar =
false;
2597 if( !aNode->is_root() )
2603 currentSize =
VECTOR2I( aBaseSize.
x * 0.5, aBaseSize.
y * 0.6 );
2609 currentSize =
VECTOR2I( aBaseSize.
x * 0.5, aBaseSize.
y * 0.6 );
2619 if( aNode->has_content() )
2624 wxStringTokenizer str_tok( nodeText,
" ", wxTOKEN_RET_DELIMS );
2626 while( str_tok.HasMoreTokens() )
2628 wxString word = str_tok.GetNextToken();
2629 nextPosition =
renderWord( word, nextPosition, currentSize, aOrient, aTextMirrored, aWidth,
2632 aFont, aFontMetrics, aV_justify, currentStyle );
2638 for(
const std::unique_ptr<MARKUP::NODE>& child : aNode->children )
2642 nextPosition =
renderMarkupNode( child.get(), nextPosition, currentSize, aOrient, aTextMirrored, aWidth,
2643 aBaseBold, aBaseItalic, aFont, aFontMetrics, aV_justify, currentStyle,
2650 aOverbars.push_back( { startPos, endPos, currentSize, aFont->
IsOutline(), aV_justify } );
2654 return nextPosition;
2664 VECTOR2D dir( overbar.endPos.x - overbar.startPos.x, overbar.endPos.y - overbar.startPos.y );
2666 double len = hypot( dir.
x, dir.
y );
2688 if( overbar.isOutline )
2689 barOffset += overbar.fontSize.y * 0.16;
2691 barOffset += overbar.fontSize.y * 0.32;
2696 double alignMult = 1.0;
2698 switch( overbar.vAlign )
2702 default: alignMult = 1.0;
break;
2705 if( alignMult > 1.0 )
2708 double baseline_factor = 0.17;
2709 barOffset += ( alignMult - 1.0 ) * ( baseline_factor * overbar.fontSize.y );
2713 double barTrim = overbar.fontSize.x * 0.1;
2716 VECTOR2D startPt( overbar.startPos.x, overbar.startPos.y );
2717 VECTOR2D endPt( overbar.endPos.x, overbar.endPos.y );
2721 VECTOR2D offVec( -barOffset * nrm.
x, -barOffset * nrm.
y );
2723 startPt.
x += dir.
x * barTrim + offVec.
x;
2724 startPt.
y += dir.
y * barTrim + offVec.
y;
2725 endPt.
x -= dir.
x * barTrim - offVec.
x;
2726 endPt.
y -= dir.
y * barTrim - offVec.
y;
2740 const wxString& aText,
2749 if( size.
x == 0 || size.
y == 0 )
2757 aFont, aFontMetrics, aData );
2776 m_bookmarksInPage[aGroupName].push_back( std::make_pair( aLocation, aSymbolReference ) );
2782 std::map<float, int> m_fovMap;
2783 std::vector<int> m_viewHandles;
2788 wxASSERT( view.m_cameraMatrix.size() == 12 );
2791 if( !m_fovMap.contains( view.m_fov ) )
2794 m_fovMap[view.m_fov] = fovHandle;
2808 fovHandle = m_fovMap[view.m_fov];
2820 "/C2W [{:f} {:f} {:f} {:f} {:f} {:f} {:f} {:f} {:f} {:f} {:f} {:f}]\n"
2827 "/C [1.000000 1.000000 1.000000]>>\n"
2830 "/Type /3DLightingScheme\n"
2833 view.m_name, view.m_name, view.m_cameraMatrix[0],
2834 view.m_cameraMatrix[1],
2835 view.m_cameraMatrix[2], view.m_cameraMatrix[3], view.m_cameraMatrix[4],
2836 view.m_cameraMatrix[5], view.m_cameraMatrix[6], view.m_cameraMatrix[7],
2837 view.m_cameraMatrix[8], view.m_cameraMatrix[9], view.m_cameraMatrix[10],
2838 view.m_cameraMatrix[11],
2839 view.m_cameraCenter,
2844 m_viewHandles.push_back( viewHandle );
2860 for(
int viewHandle : m_viewHandles )
2867 "/Filter /FlateDecode\n"
2878 size_t model_stored_size = 0;
2881 wxFFileOutputStream ffos( outputFFile );
2882 wxZlibOutputStream zos( ffos, wxZ_BEST_COMPRESSION, wxZLIB_ZLIB );
2884 wxFFileInputStream fileStream( aSourcePath );
2886 if( !fileStream.IsOk() )
2887 wxLogError(
_(
"Failed to open 3D model file: %s" ), aSourcePath );
2889 zos.Write( fileStream );
2894 model_stored_size -= imgStreamStart;
2900 fmt::println(
m_outputFile,
"{}", (
unsigned) model_stored_size );
2903 outputFFile.Detach();
2908 float aCameraDistance,
2910 float aPitchDegrees,
2911 float aRollDegrees )
2913 float yRadians = glm::radians( aYawDegrees );
2914 float xRadians = glm::radians( aPitchDegrees );
2915 float zRadians = glm::radians( aRollDegrees );
2918 glm::mat4 rotationMatrix = glm::eulerAngleYXZ( yRadians, xRadians, zRadians );
2922 glm::vec4 cameraOffset = glm::vec4( 0.0f, 0.0f, aCameraDistance, 1.0f );
2925 cameraOffset = rotationMatrix * cameraOffset;
2928 glm::vec3 cameraPosition = glm::vec3(aTargetPosition.
x, aTargetPosition.
y, aTargetPosition.
z)
2929 - glm::vec3( cameraOffset );
2931 std::vector<float>
result( 12 );
2935 for(
int col = 0; col < 3; ++col )
2937 for(
int row = 0; row < 3; ++row )
2939 result[
index++] =
static_cast<float>( rotationMatrix[col][row] );
2944 result[9] =
static_cast<float>( cameraPosition.x );
2945 result[10] =
static_cast<float>( cameraPosition.y );
2946 result[11] =
static_cast<float>( cameraPosition.z );
void WriteImageSMaskStream(const wxImage &aImage, wxDataOutputStream &aOut)
void WriteImageStream(const wxImage &aImage, wxDataOutputStream &aOut, wxColor bg, bool colorMode)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr const Vec & GetPosition() const
constexpr const Vec GetEnd() const
constexpr void SetOrigin(const Vec &pos)
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr void SetEnd(coord_type x, coord_type y)
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
static bool IsGotoPageHref(const wxString &aHref, wxString *aDestination=nullptr)
Check if aHref is a valid internal hyperlink.
High-level wrapper for evaluating mathematical and string expressions in wxString format.
wxString Evaluate(const wxString &aInput)
Main evaluation function - processes input string and evaluates all} expressions.
FONT is an abstract base class for both outline and stroke fonts.
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
virtual bool IsStroke() const
virtual bool IsItalic() const
virtual bool IsBold() const
virtual bool IsOutline() const
VECTOR2I StringBoundaryLimits(const wxString &aText, const VECTOR2I &aSize, int aThickness, bool aBold, bool aItalic, const METRICS &aFontMetrics) const
Compute the boundary limits of aText (the bounding box of all shapes).
virtual VECTOR2I GetTextAsGlyphs(BOX2I *aBBox, std::vector< std::unique_ptr< GLYPH > > *aGlyphs, const wxString &aText, const VECTOR2I &aSize, const VECTOR2I &aPosition, const EDA_ANGLE &aAngle, bool aMirror, const VECTOR2I &aOrigin, TEXT_STYLE_FLAGS aTextStyle) const =0
Convert text string to an array of GLYPHs.
double GetOverbarVerticalPosition(double aGlyphHeight) const
Compute the vertical position of an overbar.
Class OUTLINE_FONT implements outline font drawing.
A color representation with 4 components: red, green, blue, alpha.
std::unique_ptr< NODE > Parse()
std::vector< int > m_pageHandles
Handles to the page objects.
FILE * m_workFile
Temporary file to construct the stream before zipping.
wxString m_parentPageName
virtual void ClosePage()
Close the current page in the PDF document (and emit its compressed stream).
void emitOutlineNode(OUTLINE_NODE *aNode, int aParentHandle, int aNextNode, int aPrevNode)
Emits a outline item object and recurses into any children.
std::map< int, wxImage > m_imageHandles
int emitOutline()
Starts emitting the outline object.
virtual bool EndPlot() override
int startPdfObject(int aHandle=-1)
Open a new PDF object and returns the handle if the parameter is -1.
virtual void PlotPoly(const std::vector< VECTOR2I > &aCornerList, FILL_T aFill, int aWidth=USE_DEFAULT_LINE_WIDTH, void *aData=nullptr) override
Polygon plotting for PDF.
virtual void Circle(const VECTOR2I &pos, int diametre, FILL_T fill, int width) override
Circle drawing for PDF.
virtual void SetCurrentLineWidth(int width, void *aData=nullptr) override
Pen width setting for PDF.
int m_streamLengthHandle
Handle to the deferred stream length.
void PlotImage(const wxImage &aImage, const VECTOR2I &aPos, double aScaleFactor) override
PDF images are handles as inline, not XObject streams...
int m_jsNamesHandle
Handle for Names dictionary with JS.
virtual void SetDash(int aLineWidth, LINE_STYLE aLineStyle) override
PDF supports dashed lines.
void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs) override
Create a clickable hyperlink menu with a rectangular click area.
virtual bool OpenFile(const wxString &aFullFilename) override
Open or create the plot file aFullFilename.
std::string encodeDoubleForPlotter(double aValue) const
Convert a double to a PDF-compatible numeric token (no exponent notation).
int m_fontResDictHandle
Font resource dictionary.
virtual void emitSetRGBColor(double r, double g, double b, double a) override
PDF supports colors fully.
std::map< int, std::pair< BOX2D, wxString > > m_hyperlinkHandles
Handles for all the hyperlink objects that will be deferred.
int m_pageTreeHandle
Handle to the root of the page tree object.
virtual void Text(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
Draw text with the plotter.
int emitGoToAction(int aPageHandle, const VECTOR2I &aBottomLeft, const VECTOR2I &aTopRight)
Emit an action object that instructs a goto coordinates on a page.
void closePdfStream()
Finish the current PDF stream (writes the deferred length, too).
void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString) override
Create a bookmark to a symbol.
std::vector< long > m_xrefTable
The PDF xref offset table.
void endPlotEmitResources()
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0) override
Rectangles in PDF.
int startPdfStream(int aHandle=-1)
Start a PDF stream (for the page).
VECTOR2I renderMarkupNode(const MARKUP::NODE *aNode, const VECTOR2I &aPosition, const VECTOR2I &aBaseSize, const EDA_ANGLE &aOrient, bool aTextMirrored, int aWidth, bool aBaseBold, bool aBaseItalic, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, enum GR_TEXT_V_ALIGN_T aV_justify, TEXT_STYLE_FLAGS aTextStyle, std::vector< OVERBAR_INFO > &aOverbars)
Recursively render markup nodes with appropriate styling.
virtual void Arc(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius, FILL_T aFill, int aWidth) override
The PDF engine can't directly plot arcs so we use polygonization.
void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL) override
Create a clickable hyperlink with a rectangular click area.
virtual void PenTo(const VECTOR2I &pos, char plume) override
Moveto/lineto primitive, moves the 'pen' to the specified direction.
std::map< wxString, std::vector< std::pair< BOX2I, wxString > > > m_bookmarksInPage
virtual bool StartPlot(const wxString &aPageNumber) override
The PDF engine supports multiple pages; the first one is opened 'for free' the following are to be cl...
virtual void StartPage(const wxString &aPageNumber, const wxString &aPageName=wxEmptyString, const wxString &aParentPageNumber=wxEmptyString, const wxString &aParentPageName=wxEmptyString)
Start a new page in the PDF document.
std::unique_ptr< PDF_OUTLINE_FONT_MANAGER > m_outlineFontManager
OUTLINE_NODE * addOutlineNode(OUTLINE_NODE *aParent, int aActionHandle, const wxString &aTitle)
Add a new outline node entry.
int m_imgResDictHandle
Image resource dictionary.
std::string encodeStringForPlotter(const wxString &aUnicode) override
convert a wxString unicode string to a char string compatible with the accepted string PDF format (co...
std::unique_ptr< PDF_STROKE_FONT_MANAGER > m_strokeFontManager
void Plot3DModel(const wxString &aSourcePath, const std::vector< PDF_3D_VIEW > &a3DViews)
std::vector< wxString > m_pageNumbers
List of user-space page numbers for resolving internal hyperlinks.
int allocPdfObject()
Allocate a new handle in the table of the PDF object.
VECTOR2I renderWord(const wxString &aWord, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aOrient, bool aTextMirrored, int aWidth, bool aBold, bool aItalic, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, enum GR_TEXT_V_ALIGN_T aV_justify, TEXT_STYLE_FLAGS aTextStyle)
Render a single word with the given style parameters.
std::string encodeByteString(const std::string &aBytes)
void drawOverbars(const std::vector< OVERBAR_INFO > &aOverbars, const EDA_ANGLE &aOrient, const KIFONT::METRICS &aFontMetrics)
Draw overbar lines above text.
virtual void SetViewport(const VECTOR2I &aOffset, double aIusPerDecimil, double aScale, bool aMirror) override
PDF can have multiple pages, so SetPageSettings can be called with the outputFile open (but not insid...
std::map< int, std::pair< BOX2D, std::vector< wxString > > > m_hyperlinkMenuHandles
int m_pageStreamHandle
Handle of the page content object.
virtual void PlotText(const VECTOR2I &aPos, const COLOR4D &aColor, const wxString &aText, const TEXT_ATTRIBUTES &aAttributes, KIFONT::FONT *aFont, const KIFONT::METRICS &aFontMetrics, void *aData=nullptr) override
static std::vector< float > CreateC2WMatrixFromAngles(const VECTOR3D &aTargetPosition, float aCameraDistance, float aYawDegrees, float aPitchDegrees, float aRollDegrees)
Generates the camera to world matrix for use with a 3D View.
std::vector< std::pair< BOX2I, wxString > > m_hyperlinksInPage
List of loaded hyperlinks in current page.
std::unique_ptr< OUTLINE_NODE > m_outlineRoot
Root outline node.
std::vector< std::pair< BOX2I, std::vector< wxString > > > m_hyperlinkMenusInPage
void closePdfObject()
Close the current PDF object.
int m_totalOutlineNodes
Total number of outline nodes.
std::vector< VECTOR2D > arcPath(const VECTOR2D &aCenter, const EDA_ANGLE &aStartAngle, const EDA_ANGLE &aAngle, double aRadius)
const std::string & ResourceName() const
std::string BuildDifferencesArray() const
double FontBBoxMaxY() const
double FontBBoxMinY() const
double UnitsPerEm() const
double FontBBoxMinX() const
void SetToUnicodeHandle(int aHandle)
int CharProcsHandle() const
std::string BuildWidthsArray() const
double FontBBoxMaxX() const
void SetFontHandle(int aHandle)
int ToUnicodeHandle() const
void SetCharProcsHandle(int aHandle)
std::string BuildToUnicodeCMap() const
std::vector< GLYPH > & Glyphs()
double GetDotMarkLenIU(int aLineWidth) const
double GetDashGapLenIU(int aLineWidth) const
const PROJECT * m_project
bool m_mirrorIsHorizontal
static const int USE_DEFAULT_LINE_WIDTH
void MoveTo(const VECTOR2I &pos)
void FinishTo(const VECTOR2I &pos)
virtual VECTOR2D userToDeviceCoordinates(const VECTOR2I &aCoordinate)
Modify coordinates according to the orientation, scale factor, and offsets trace.
virtual VECTOR2D userToDeviceSize(const VECTOR2I &size)
Modify size according to the plotter scale factors (VECTOR2I version, returns a VECTOR2D).
double m_plotScale
Plot scale - chosen by the user (even implicitly with 'fit in a4')
FILE * m_outputFile
Output file.
void LineTo(const VECTOR2I &pos)
static const int DO_NOT_SET_LINE_WIDTH
RENDER_SETTINGS * m_renderSettings
virtual int GetCurrentLineWidth() const
double GetDashMarkLenIU(int aLineWidth) const
virtual void SetColor(const COLOR4D &color) override
The SetColor implementation is split with the subclasses: the PSLIKE computes the rgb values,...
double plotScaleAdjX
Fine user scale adjust ( = 1.0 if no correction)
void computeTextParameters(const VECTOR2I &aPos, const wxString &aText, const EDA_ANGLE &aOrient, const VECTOR2I &aSize, bool aMirror, enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify, int aWidth, bool aItalic, bool aBold, double *wideningFactor, double *ctm_a, double *ctm_b, double *ctm_c, double *ctm_d, double *ctm_e, double *ctm_f, double *heightFactor)
This is the core for postscript/PDF text alignment.
EDA_ANGLE GetCentralAngle() const
Get the "central angle" of the arc - this is the angle at the point of the "pie slice".
EDA_ANGLE GetStartAngle() const
const VECTOR2I & GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
SEG Segment(int aIndex) const
Return a copy of the aIndex-th segment in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
bool IsArcSegment(size_t aSegment) const
const SHAPE_LINE_CHAIN Outline() const
void SetRadius(int aRadius)
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
std::string substr(size_t pos=0, size_t len=npos) const
const wxString ResolveUriByEnvVars(const wxString &aUri, const PROJECT *aProject)
Replace any environment and/or text variables in URIs.
static constexpr EDA_ANGLE ANGLE_0
@ FILLED_SHAPE
Fill with object color.
unsigned int TEXT_STYLE_FLAGS
static constexpr double ITALIC_TILT
Tilt factor for italic style (this is the scaling factor on dY relative coordinates to give a tilted ...
double m_PDFStrokeFontYOffset
Vertical offset factor applied to stroke font glyph coordinates (in EM units) after Y inversion to co...
const wxChar *const tracePdfPlotter
Flag to enable PDF plotter debug tracing.
void ignore_unused(const T &)
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Plotting engines similar to ps (PostScript, Gerber, svg)
wxString NormalizeFileUri(const wxString &aFileUri)
Normalize file path aFileUri to URI convention.
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
LINE_STYLE
Dashed line types.
bool isSuperscript() const
wxString asWxString() const
wxString title
Title of outline node.
std::vector< OUTLINE_NODE * > children
Ordered list of children.
int entryHandle
Allocated handle for this outline entry.
OUTLINE_NODE * AddChild(int aActionHandle, const wxString &aTitle, int aEntryHandle)
int actionHandle
Handle to action.
wxString result
Test unit parsing edge cases and error handling.
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_INDETERMINATE
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
VECTOR3< double > VECTOR3D