FCLT#63646 Graphics 2022 FCLT#69128 Fontawesome iconen kunnen gebruiken als Graphics symbolen
svn path=/Slnkdwf/trunk/; revision=53563
This commit is contained in:
@@ -71,6 +71,7 @@ interface IWhipFile : IDispatch{
|
||||
[id(29), helpstring("method SymbolOrigin")] HRESULT SymbolOrigin([in] BSTR symbolName, [in] DOUBLE dwgX, [in] DOUBLE dwgY);
|
||||
[propget, id(30), helpstring("property minMergeDistance")] HRESULT minMergeDistance([out, retval] DOUBLE* pVal);
|
||||
[propput, id(30), helpstring("property minMergeDistance")] HRESULT minMergeDistance([in] DOUBLE newVal);
|
||||
[id(31), helpstring("method SetSymbolFont")] HRESULT SetSymbolFont([in] BSTR FontName, [in, defaultvalue(1000)] DOUBLE FontHeight);
|
||||
};
|
||||
[
|
||||
object,
|
||||
|
||||
@@ -34,7 +34,8 @@ WT_Result CSLNKSymbolImpl::serialize (WT_File & file, WT_Units & units,
|
||||
CSLNKSymbolDefinition *symbdef,
|
||||
WT_Integer32 &node_num,
|
||||
double hintScale,
|
||||
BOOL forFind, double scale)
|
||||
BOOL forFind, double scale,
|
||||
int ttfdescent)
|
||||
{
|
||||
ATLASSERT(symbdef != NULL);
|
||||
|
||||
@@ -147,13 +148,13 @@ WT_Result CSLNKSymbolImpl::serialize (WT_File & file, WT_Units & units,
|
||||
// Het roteren en verschalen gebeurt via WT_Transform SymbolTrans
|
||||
// Een gewijzigde rotatie of schaal maakt dat we een (Font) moeten wegschrijven naar de DWF
|
||||
// De toolkit snapt echter niet goed dat het nodig is bij gewijzigde Transform, daarom hieronder expliciet
|
||||
file.desired_rendition().font().height() = 1000; // Zorg dat FONT_HEIGHT_BIT gezet raakt
|
||||
file.desired_rendition().font().height() = file.desired_rendition().font().height(); // Zorg dat FONT_HEIGHT_BIT gezet raakt
|
||||
file.desired_rendition().font().rotation() = 0; // Zorg dat FONT_ROTATION_BIT gezet raakt
|
||||
file.desired_rendition().font().serialize(file);
|
||||
|
||||
//https://stackoverflow.com/questions/32781414/what-is-the-baseline-font-height-of-fontawesome-font
|
||||
// Waarom moet ik hier 125 gebruiken? Omdat dat in de svg descent (64) / units-per-em (512) is!
|
||||
WT_Text my_text(WT_Logical_Point(0, 125), this->m_unicode);
|
||||
WT_Text my_text(WT_Logical_Point(0, -ttfdescent), this->m_unicode);
|
||||
// het font is in CWhipFile::GenerateSymbols al goed gezet
|
||||
my_text.serialize(file);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ public:
|
||||
CSLNKSymbolDefinition *symbdef,
|
||||
WT_Integer32 &node_num,
|
||||
double hintScale, BOOL forFind,
|
||||
double scale);
|
||||
double scale,
|
||||
int ttfdescent = 0);
|
||||
WT_Result calculateBoundary (myWT_File *wtFile);
|
||||
|
||||
~CSLNKSymbolImpl(void);
|
||||
|
||||
@@ -77,6 +77,8 @@ CWhipFile::CWhipFile()
|
||||
m_FontName.set("Arial");
|
||||
m_FontHeight = 400.0;
|
||||
m_FontHeightSymbols = 200.0;
|
||||
m_SymbolFontName.set("Font Awesome 5 Pro Regular");
|
||||
m_SymbolFontHeight = 1000.0;
|
||||
|
||||
m_reContouren.Parse(".*", FALSE);
|
||||
m_reLabels.Parse(".*", FALSE);
|
||||
@@ -1016,7 +1018,7 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file)
|
||||
for (size_t i=0; i<m_SLNKSymbols.GetCount(); i++)
|
||||
{
|
||||
CSLNKSymbolImpl *symbol= m_SLNKSymbols[i];
|
||||
if (symbol->m_unicode.length()) // die doen we allemaal tegelijk
|
||||
if (symbol->m_unicode.length()) // die doen we in de tweede slag allemaal tegelijk
|
||||
continue;
|
||||
|
||||
if (symbol->m_symbolName == "" || !m_SLNKSymbolDefinitions.Lookup(symbol->m_symbolName))
|
||||
@@ -1036,13 +1038,13 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file)
|
||||
//
|
||||
// nu de unicode symbolen
|
||||
//
|
||||
tempFontDC myDC("Font Awesome 5 Pro Regular"); // TODO
|
||||
TEXTMETRIC tm;
|
||||
int delta = 0; // zo ver moet het karakter nog omhoog om het precies in het midden aan te grijpen
|
||||
if (GetTextMetrics(myDC, &tm) != 0)
|
||||
{
|
||||
delta = MulDiv(tm.tmDescent, FONT_SIZER, tm.tmHeight + 250); // waarom is die 250 nodig om 125 te krijgen? Nu nog hardcoded in SLNKSymbolImpl.cpp
|
||||
}
|
||||
tempFontDC myDC(m_SymbolFontName);
|
||||
//TEXTMETRIC tm;
|
||||
int ttfdescent = 0; // zo ver moet het karakter nog omhoog om het precies in het midden aan te grijpen
|
||||
//if (GetTextMetrics(myDC, &tm) != 0)
|
||||
//{
|
||||
// ttfdescent = MulDiv(tm.tmDescent, FONT_SIZER, tm.tmHeight + 250); // waarom is die 250 nodig om 125 te krijgen? Nu nog hardcoded in SLNKSymbolImpl.cpp
|
||||
//}
|
||||
int size = ::GetOutlineTextMetricsW(myDC, 0, NULL); // alleen voor TrueType!
|
||||
if (size != 0)
|
||||
{
|
||||
@@ -1052,18 +1054,14 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file)
|
||||
UINT status = GetOutlineTextMetricsW(myDC, size, otm);
|
||||
WD_Assert(status != 0);
|
||||
|
||||
delta = otm->otmDescent;
|
||||
|
||||
// if (status != 0)
|
||||
// logfont.lfHeight = otm->otmEMSquare;
|
||||
ttfdescent = otm->otmDescent;
|
||||
|
||||
delete[] otm;
|
||||
}
|
||||
|
||||
WT_Font myfont;
|
||||
int fontheight = 1000; // 1000 sluit aan bij onze ingebouwde symbolen
|
||||
myfont.font_name().set("Font Awesome 5 Pro Regular");
|
||||
myfont.height() = fontheight; // echte komt nog wel
|
||||
myfont.font_name().set(m_SymbolFontName);
|
||||
myfont.height() = myRound(m_SymbolFontHeight); // 1000 sluit aan bij onze ingebouwde symbolen
|
||||
myfont.rotation() = 0;
|
||||
myfont.width_scale() = 0;
|
||||
myfont.flags() = 0;
|
||||
@@ -1079,7 +1077,7 @@ bool CWhipFile::GenerateSymbols(myWT_File &my_file)
|
||||
comment(my_file, s);
|
||||
symbol->serialize(my_file, m_contunits, m_SLNKSymbolDefinitions[symbol->m_symbolName],
|
||||
m_next_node_num,
|
||||
m_hintScale, m_forFind, scale);
|
||||
m_hintScale, m_forFind, scale, ttfdescent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1408,6 +1406,14 @@ STDMETHODIMP CWhipFile::SetLabelPosition(BYTE p_LabelPos)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CWhipFile::SetSymbolFont(BSTR FontName, DOUBLE FontHeight /* = 1000 */)
|
||||
{
|
||||
m_SymbolFontName.set(FontName);
|
||||
m_SymbolFontHeight = FontHeight;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal)
|
||||
{
|
||||
CString name(symbolName);
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
STDMETHOD(SaveAs2)(BSTR WhipPath, VARIANT_BOOL ascii);
|
||||
STDMETHOD(HighlightUnrecognized)();
|
||||
STDMETHOD(SetLabelFont)(BSTR FontName, DOUBLE FontHeight, DOUBLE FontHeightSymbols);
|
||||
STDMETHOD(SetSymbolFont)(BSTR FontName, DOUBLE FontHeight);
|
||||
STDMETHOD(SetLabelPosition)(BYTE LabelPos);
|
||||
STDMETHOD(get_AddSymbol)(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal);
|
||||
STDMETHOD(DefineSymbol)(BSTR symbolName, VARIANT EPlotStream, ISLNKContour** pContour);
|
||||
@@ -82,8 +83,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
WT_String m_FontName;
|
||||
double m_FontHeight, m_FontHeightSymbols;
|
||||
WT_String m_FontName, m_SymbolFontName;
|
||||
double m_FontHeight, m_FontHeightSymbols, m_SymbolFontHeight;
|
||||
|
||||
CComQIPtr<IEPlotSection> m_iEPlotSection; // Om scope levend te houden
|
||||
CComQIPtr<IBoundingBox> m_dwgLimits;
|
||||
|
||||
Reference in New Issue
Block a user