- compilazione a x32.
Ancora da risolvere il linkage a dwrite.dll.
This commit is contained in:
Daniele Bariletti
2023-10-13 11:13:31 +02:00
parent 23e133be72
commit b0b3afc3fc
3 changed files with 342 additions and 15 deletions
+2 -2
View File
@@ -22,7 +22,7 @@
<ProjectGuid>{1356641D-0B22-4123-B519-A69EE5CDC7F8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>opennurbs_public</RootNamespace>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.20348.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -160,7 +160,7 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<OpenMPSupport>true</OpenMPSupport>
<WarningLevel>Level3</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalOptions>-Wc++11-narrowing %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>-Wunknown-pragmas %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
+310 -3
View File
@@ -471,24 +471,47 @@ void ON_Font::DumpWindowsDWriteFont(
HRESULT hr;
// Family name
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFamily> pIDWriteFontFamily = nullptr;
#else
CComPtr<IDWriteFontFamily> pIDWriteFontFamily = nullptr;
#endif
hr = dwrite_font->GetFontFamily(&pIDWriteFontFamily);
if ((SUCCEEDED(hr)) && nullptr != pIDWriteFontFamily)
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
#endif
hr = pIDWriteFontFamily->GetFamilyNames(&familyNames);
if (SUCCEEDED(hr))
{
#if defined(WIN64)
Internal_PrintLocalizedNames(L"Family name", preferedLocale, familyNames.Get(), text_log);
#else
Internal_PrintLocalizedNames(L"Family name", preferedLocale, familyNames, text_log);
#endif
}
}
// Face name
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#endif
hr = dwrite_font->GetFaceNames(&faceNames);
if (SUCCEEDED(hr))
{
#if defined(WIN64)
Internal_PrintLocalizedNames(L"Face name", preferedLocale, faceNames.Get(), text_log);
#else
Internal_PrintLocalizedNames(L"Face name", preferedLocale, faceNames, text_log);
#endif
}
const DWRITE_FONT_WEIGHT dwrite_weight = dwrite_font->GetWeight();
const ON_wString weightString = Internal_DWRITE_FONT_WEIGHT_ToString(dwrite_weight);
text_log.Print("Weight = %ls\n", static_cast<const wchar_t*>(weightString));
@@ -563,10 +586,22 @@ void ON_Font::DumpWindowsDWriteFont(
for (size_t i = 0; i < info_strings_count; i++)
{
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> fontNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> fontNames = nullptr;
#endif
hr = dwrite_font->GetInformationalStrings(info_strings[i].m_id,&fontNames,&exists);
if (SUCCEEDED(hr) && exists)
{
#if defined(WIN64)
Internal_PrintLocalizedNames(info_strings[i].m_description, preferedLocale, fontNames.Get(), text_log);
#else
Internal_PrintLocalizedNames(info_strings[i].m_description, preferedLocale, fontNames, text_log);
#endif
}
}
const ON_wString postscriptName = ON_Font::PostScriptNameFromWindowsDWriteFont(dwrite_font, preferedLocale);
@@ -665,14 +700,26 @@ const ON_wString ON_Font::PostScriptNameFromWindowsDWriteFont(
if (nullptr == dwrite_font)
break;
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> postscriptNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> postscriptNames = nullptr;
#endif
HRESULT hr = dwrite_font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_NAME, &postscriptNames, &exists);
if (FAILED(hr))
break;
ON_wString loc_PostScriptName;
ON_wString en_PostScriptName;
if (exists)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, postscriptNames.Get(), loc_PostScriptName, en_PostScriptName);
#else
Internal_GetLocalizeStrings(preferedLocale, postscriptNames, loc_PostScriptName, en_PostScriptName);
#endif
}
// This was wrong.
// Bahnschrift is an OpenType variable font and all faces of variable fonts
@@ -748,14 +795,25 @@ static const ON_wString Internal_InfoStringFromWindowsDWriteFont(
if (nullptr == dwrite_font)
break;
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> info_string = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> info_string = nullptr;
#endif
HRESULT hr = dwrite_font->GetInformationalStrings(info_string_id, &info_string, &exists);
if (FAILED(hr))
break;
ON_wString loc_description;
ON_wString en_description;
if (exists)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, info_string.Get(), loc_description, en_description);
#else
Internal_GetLocalizeStrings(preferedLocale, info_string, loc_description, en_description);
#endif
}
return loc_description.IsNotEmpty() ? loc_description : en_description;
}
@@ -1209,12 +1267,22 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
HRESULT hr;
// Get the system font collection.
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontCollection> dwriteFontCollection = nullptr;
#else
CComPtr<IDWriteFontCollection> dwriteFontCollection = nullptr;
#endif
hr = dwriteFactory->GetSystemFontCollection(&dwriteFontCollection);
if (FAILED(hr))
break;
#if defined(WIN64)
if (nullptr == dwriteFontCollection || nullptr == dwriteFontCollection.Get())
break;
#else
if (nullptr == dwriteFontCollection || nullptr == dwriteFontCollection)
break;
#endif
const UINT32 familyCount = dwriteFontCollection->GetFontFamilyCount();
if (familyCount < 1)
break;
@@ -1238,29 +1306,56 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
for (UINT32 familyIndex = 0; familyIndex < familyCount; ++familyIndex)
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFamily> dwriteFontFamily = nullptr;
#else
CComPtr<IDWriteFontFamily> dwriteFontFamily = nullptr;
#endif
hr = dwriteFontCollection->GetFontFamily(familyIndex, &dwriteFontFamily);
if (FAILED(hr))
continue;
#if defined(WIN64)
if (nullptr == dwriteFontFamily || nullptr == dwriteFontFamily.Get())
continue;
#else
if (nullptr == dwriteFontFamily || nullptr == dwriteFontFamily)
continue;
#endif
// Family name
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
#endif
hr = dwriteFontFamily->GetFamilyNames(&familyNames);
ON_wString loc_family_name;
ON_wString en_family_name;
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, familyNames.Get(), loc_family_name, en_family_name);
#else
Internal_GetLocalizeStrings(preferedLocale, familyNames, loc_family_name, en_family_name);
#endif
const UINT32 fontCount = dwriteFontFamily->GetFontCount();
for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++)
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFont> dwriteFont = nullptr;
#else
CComPtr<IDWriteFont> dwriteFont = nullptr;
#endif
hr = dwriteFontFamily->GetFont(fontIndex, &dwriteFont);
if (FAILED(hr))
continue;
#if defined(WIN64)
if (nullptr == dwriteFont || nullptr == dwriteFont.Get())
continue;
#else
if (nullptr == dwriteFont || nullptr == dwriteFont)
continue;
#endif
ON_WindowsDWriteFontInformation fi;
fi.m_prefered_locale = preferedLocale;
@@ -1287,11 +1382,20 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
}
// Face name
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#endif
hr = dwriteFont->GetFaceNames(&faceNames);
if (SUCCEEDED(hr))
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, faceNames.Get(), fi.m_loc_face_name, fi.m_en_face_name);
#else
Internal_GetLocalizeStrings(preferedLocale, faceNames, fi.m_loc_face_name, fi.m_en_face_name);
#endif
}
fi.m_weight = dwriteFont->GetWeight();
@@ -1301,35 +1405,68 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
// Full name
exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> fullNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> fullNames = nullptr;
#endif
hr = dwriteFont->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_FULL_NAME, &fullNames, &exists);
if (SUCCEEDED(hr) && exists)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, fullNames.Get(), fi.m_loc_full_name, fi.m_en_full_name );
#else
Internal_GetLocalizeStrings(preferedLocale, fullNames, fi.m_loc_full_name, fi.m_en_full_name );
#endif
}
// PostScript name
#if defined(WIN64)
fi.m_loc_postscript_name = ON_Font::PostScriptNameFromWindowsDWriteFont(dwriteFont.Get(), preferedLocale);
fi.m_en_postscript_name = ON_Font::PostScriptNameFromWindowsDWriteFont(dwriteFont.Get(), englishLocale);
#else
fi.m_loc_postscript_name = ON_Font::PostScriptNameFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_postscript_name = ON_Font::PostScriptNameFromWindowsDWriteFont(dwriteFont, englishLocale);
#endif
// GDI family name
exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> gdiFamilyNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> gdiFamilyNames = nullptr;
#endif
hr = dwriteFont->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &gdiFamilyNames, &exists);
if (SUCCEEDED(hr) && exists)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, gdiFamilyNames.Get(), fi.m_loc_gdi_family_name, fi.m_en_gdi_family_name);
#else
Internal_GetLocalizeStrings(preferedLocale, gdiFamilyNames, fi.m_loc_gdi_family_name, fi.m_en_gdi_family_name);
#endif
}
// GDI sub-family name
exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> gdiSubfamilyNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> gdiSubfamilyNames = nullptr;
#endif
hr = dwriteFont->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_WIN32_SUBFAMILY_NAMES, &gdiSubfamilyNames, &exists);
if (SUCCEEDED(hr) && exists)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, gdiSubfamilyNames.Get(), fi.m_loc_gdi_subfamily_name, fi.m_en_gdi_subfamily_name);
#else
Internal_GetLocalizeStrings(preferedLocale, gdiSubfamilyNames, fi.m_loc_gdi_subfamily_name, fi.m_en_gdi_subfamily_name);
#endif
}
#if defined(WIN64)
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_WEIGHT_STRETCH_STYLE_FAMILY_NAME, ... )
fi.m_en_weight_stretch_style_model_name = ON_Font::WeightStretchStyleModelFamilyNameFromWindowsDWriteFont(dwriteFont.Get(), preferedLocale);
fi.m_en_weight_stretch_style_model_name = ON_Font::WeightStretchStyleModelFamilyNameFromWindowsDWriteFont(dwriteFont.Get(), preferedLocale);
@@ -1381,11 +1518,69 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME, ... )
fi.m_loc_field_20_postscript_cid = ON_Font::Field_20_PostScriptCIDNameFromWindowsDWriteFont(dwriteFont.Get(), preferedLocale);
fi.m_en_field_20_postscript_cid = ON_Font::Field_20_PostScriptCIDNameFromWindowsDWriteFont(dwriteFont.Get(), englishLocale);
#else
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_WEIGHT_STRETCH_STYLE_FAMILY_NAME, ... )
fi.m_en_weight_stretch_style_model_name = ON_Font::WeightStretchStyleModelFamilyNameFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_weight_stretch_style_model_name = ON_Font::WeightStretchStyleModelFamilyNameFromWindowsDWriteFont(dwriteFont, preferedLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_COPYRIGHT_NOTICE, ... )
fi.m_loc_field_0_copyright = ON_Font::Field_0_CopyrightFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_0_copyright = ON_Font::Field_0_CopyrightFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, ... )
fi.m_loc_field_5_version = ON_Font::Field_5_VersionFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_5_version = ON_Font::Field_5_VersionFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_TRADEMARK, ... )
fi.m_loc_field_7_trademark = ON_Font::Field_7_TrademarkFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_7_trademark = ON_Font::Field_7_TrademarkFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_MANUFACTURER, ... )
fi.m_loc_field_8_manufacturer = ON_Font::Field_8_ManufacturerFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_8_manufacturer = ON_Font::Field_8_ManufacturerFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_DESIGNER, ... )
fi.m_loc_field_9_designer = ON_Font::Field_9_DesignerFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_9_designer = ON_Font::Field_9_DesignerFromWindowsDWriteFont(dwriteFont, englishLocale);
// Field 10 Description
// Opennurbs searches the description saved in field 10 of the name table
// for the strings "Engraving - single stroke" / "Engraving - double stroke" / "Engraving"
// to identify fonts that are desgned for engraving (and which tend to render poorly when
// used to dispaly text devices like screens, monitors, and printers).
// The SLF (single line fonts) are examples of fonts that have Engraving in field 10.
fi.m_loc_field_10_description = ON_Font::Field_10_DescriptionFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_10_description = ON_Font::Field_10_DescriptionFromWindowsDWriteFont(dwriteFont, englishLocale);
fi.m_loc_field_11_vendor_URL = ON_Font::Field_11_VendorURLFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_11_vendor_URL = ON_Font::Field_11_VendorURLFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_DESIGNER_URL, ... )
fi.m_loc_field_12_designer_URL = ON_Font::Field_12_DesignerURLFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_12_designer_URL = ON_Font::Field_12_DesignerURLFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_LICENSE_DESCRIPTION, ... )
fi.m_loc_field_13_license = ON_Font::Field_13_LicenseFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_13_license = ON_Font::Field_13_LicenseFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_LICENSE_INFO_URL, ... )
fi.m_loc_field_14_license_URL = ON_Font::Field_14_LicenseURLFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_14_license_URL = ON_Font::Field_14_LicenseURLFromWindowsDWriteFont(dwriteFont, englishLocale);
// from IDWriteFont.GetInformationalStrings( DWRITE_INFORMATIONAL_STRING_POSTSCRIPT_CID_NAME, ... )
fi.m_loc_field_20_postscript_cid = ON_Font::Field_20_PostScriptCIDNameFromWindowsDWriteFont(dwriteFont, preferedLocale);
fi.m_en_field_20_postscript_cid = ON_Font::Field_20_PostScriptCIDNameFromWindowsDWriteFont(dwriteFont, englishLocale);
#endif
BOOL isSystemFont = false;
LOGFONTW logfont;
memset(&logfont, 0, sizeof(logfont));
#if defined(WIN64)
hr = dwriteGdiInterop->ConvertFontToLOGFONT(dwriteFont.Get(), &logfont, &isSystemFont);
#else
hr = dwriteGdiInterop->ConvertFontToLOGFONT(dwriteFont, &logfont, &isSystemFont);
#endif
if (SUCCEEDED(hr) && 0 != logfont.lfFaceName[0])
{
logfont.lfHeight = 0;
@@ -1423,13 +1618,22 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
////ON_ERROR("Empty LOGFONT lfFaceName");
continue;
}
#if defined(WIN64)
fi.m_font_metrics = ON_FontMetrics::CreateFromDWriteFont(dwriteFont.Get());
#else
fi.m_font_metrics = ON_FontMetrics::CreateFromDWriteFont(dwriteFont);
#endif
for (;;)
{
IDWriteFont1* dwriteFont1 = nullptr;
#if defined(WIN64)
hr = dwriteFont.Get()->QueryInterface(__uuidof(IDWriteFont1), (void**)&dwriteFont1);
#else
hr = dwriteFont->QueryInterface(__uuidof(IDWriteFont1), (void**)&dwriteFont1);
#endif
if (FAILED(hr))
break; // On some versions of Windows 7, IDWriteFont1 is not available
if (nullptr == dwriteFont1)
@@ -1472,17 +1676,31 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
for (;;)
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#else
CComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#endif
hr = dwriteFont->CreateFontFace(&dwriteFontFace);
if (FAILED(hr))
break;
#if defined(WIN64)
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace.Get())
break;
#else
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace)
break;
#endif
UINT32 codepoints[] = {ON_wString::Space, 'H', 'I', 'x'};
UINT32 codepointCount = ((UINT32)sizeof(codepoints) / sizeof(codepoints[0]));
UINT16 glyphIndices[sizeof(codepoints) / sizeof(codepoints[0])] = {};
#if defined(WIN64)
hr = dwriteFontFace.Get()->GetGlyphIndices(codepoints, codepointCount, glyphIndices);
#else
hr = dwriteFontFace->GetGlyphIndices(codepoints, codepointCount, glyphIndices) ;
#endif
if (FAILED(hr))
break;
@@ -1494,7 +1712,11 @@ unsigned int ON_Font::GetInstalledWindowsDWriteFonts(
DWRITE_GLYPH_METRICS glyphMetric;
memset(&glyphMetric, 0, sizeof(glyphMetric));
BOOL isSideways = false;
#if defined(WIN64)
hr = dwriteFontFace.Get()->GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetric, isSideways);
#else
hr = dwriteFontFace->GetDesignGlyphMetrics(&glyphIndex, 1, &glyphMetric, isSideways);
#endif
if (FAILED(hr))
break;
ON_FontGlyph glyph_box;
@@ -1822,13 +2044,23 @@ bool ON_WindowsDWriteGetGlyphOutline(
memset(&dwriteFontMetrics, 0, sizeof(dwriteFontMetrics));
dwriteFont->GetMetrics(&dwriteFontMetrics);
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#else
CComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#endif
HRESULT hr = dwriteFont->CreateFontFace(&dwriteFontFace);
if (FAILED(hr))
return false;
#if defined(WIN64)
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace.Get())
return false;
#else
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace)
return false;
#endif
ON_OutlineAccumulator accumulator;
accumulator.BeginGlyphOutline(
@@ -1903,12 +2135,21 @@ bool ON_WindowsDWriteGetGlyphMetrics(
if ( dwriteGlyphIndex <= 0 || dwriteGlyphIndex > 0xFFFF )
return false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#else
CComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#endif
HRESULT hr = dwriteFont->CreateFontFace(&dwriteFontFace);
if (FAILED(hr))
return false;
#if defined(WIN64)
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace.Get())
return false;
#else
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace)
return false;
#endif
const UINT32 glyphCount = 1;
const BOOL isSideways = 0;
@@ -1986,17 +2227,33 @@ unsigned int ON_WindowsDWriteGetGlyphMetrics(
if (glyph_index > 0)
break;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#else
CComPtr<IDWriteFontFace> dwriteFontFace = nullptr;
#endif
HRESULT hr = dwriteFont->CreateFontFace(&dwriteFontFace);
if (FAILED(hr))
break;
#if defined(WIN64)
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace.Get())
break;
#else
if (nullptr == dwriteFontFace || nullptr == dwriteFontFace)
break;
#endif
const UINT32 codepoints[] = {glyph->CodePoint(), 0 };
const UINT32 codepointCount = 1;
UINT16 glyphIndices[sizeof(codepoints) / sizeof(codepoints[0])] = {};
#if defined(WIN64)
hr = dwriteFontFace.Get()->GetGlyphIndices(codepoints, codepointCount, glyphIndices);
#else
hr = dwriteFontFace->GetGlyphIndices(codepoints, codepointCount, glyphIndices);
#endif
if (FAILED(hr))
break;
@@ -2101,11 +2358,19 @@ bool ON_Font::SetFromWindowsDWriteFont(
// LOGFONT lfFaceName
{
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> gdiLogfontNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> gdiLogfontNames = nullptr;
#endif
hr = dwrite_font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &gdiLogfontNames, &exists);
if (SUCCEEDED(hr) && exists && nullptr != gdiLogfontNames)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, gdiLogfontNames.Get(), m_loc_windows_logfont_name, m_en_windows_logfont_name);
#else
Internal_GetLocalizeStrings(preferedLocale, gdiLogfontNames, m_loc_windows_logfont_name, m_en_windows_logfont_name);
#endif
}
for(;;)
@@ -2145,8 +2410,13 @@ bool ON_Font::SetFromWindowsDWriteFont(
// Family name
for (;;)
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteFontFamily> pIDWriteFontFamily = nullptr;
#else
CComPtr<IDWriteFontFamily> pIDWriteFontFamily = nullptr;
#endif
hr = dwrite_font->GetFontFamily(&pIDWriteFontFamily);
#if defined(WIN64)
if ((SUCCEEDED(hr)) && nullptr != pIDWriteFontFamily && nullptr != pIDWriteFontFamily.Get())
{
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
@@ -2156,18 +2426,38 @@ bool ON_Font::SetFromWindowsDWriteFont(
Internal_GetLocalizeStrings(preferedLocale, familyNames.Get(), m_loc_family_name, m_en_family_name);
}
}
#else
if ((SUCCEEDED(hr)) && nullptr != pIDWriteFontFamily && nullptr != pIDWriteFontFamily)
{
CComPtr<IDWriteLocalizedStrings> familyNames = nullptr;
hr = pIDWriteFontFamily->GetFamilyNames(&familyNames);
if (SUCCEEDED(hr))
{
Internal_GetLocalizeStrings(preferedLocale, familyNames, m_loc_family_name, m_en_family_name);
}
}
#endif
if (m_loc_family_name.IsNotEmpty() && m_en_family_name.IsNotEmpty())
break;
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> preferedFamilyNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> preferedFamilyNames = nullptr;
#endif
hr = dwrite_font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_PREFERRED_FAMILY_NAMES, &preferedFamilyNames, &exists);
if (SUCCEEDED(hr) && exists && nullptr != preferedFamilyNames)
{
ON_wString locName;
ON_wString enName;
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, preferedFamilyNames.Get(), locName, enName);
#else
Internal_GetLocalizeStrings(preferedLocale, preferedFamilyNames, locName, enName);
#endif
if (m_loc_family_name.IsEmpty())
m_loc_family_name = locName;
if ( m_en_family_name.IsEmpty())
@@ -2181,11 +2471,20 @@ bool ON_Font::SetFromWindowsDWriteFont(
// Face name
{
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> faceNames = nullptr;
#endif
hr = dwrite_font->GetFaceNames(&faceNames);
if (SUCCEEDED(hr) && nullptr != faceNames)
{
#if defined(WIN64)
Internal_GetLocalizeStrings(preferedLocale, faceNames.Get(), m_loc_face_name, m_en_face_name);
#else
Internal_GetLocalizeStrings(preferedLocale, faceNames, m_loc_face_name, m_en_face_name);
#endif
}
}
@@ -2300,12 +2599,20 @@ static bool Internal_GetDWriteFamilyName(
{
// iterate possible family names finding the best one to return.
BOOL exists = false;
#if defined(WIN64)
Microsoft::WRL::ComPtr<IDWriteLocalizedStrings> localizedFamilynames = nullptr;
#else
CComPtr<IDWriteLocalizedStrings> localizedFamilynames = nullptr;
#endif
HRESULT hr = const_cast<IDWriteFont*>(dwrite_font)->GetInformationalStrings(name_id[i], &localizedFamilynames, &exists);
if (FAILED(hr))
break;
#if defined(WIN64)
IDWriteLocalizedStrings* familyNames = localizedFamilynames.Get();
#else
IDWriteLocalizedStrings* familyNames = localizedFamilynames;
#endif
if (nullptr == familyNames)
continue;
+24 -4
View File
@@ -25,14 +25,34 @@ Warning C4263 ..: member function does not override any base class virtual membe
Warning C4263 ..: member function does not override any base class virtual member function ... C:\Program Files (x86)\Windows Kits\8.1\Include\um\dwrite_2.h ...
*/
#pragma ON_PRAGMA_WARNING_DISABLE_MSC( 4263 4264 4265 )
#include <dwrite.h>
//#include <dwrite_2.h>
//#include <wrl.h>
#if !defined(WIN64) // quindi definito WIN32
//#include <dwrite.h>
//#include "C:\EgtDev\Extern\dwrite.h"
//#include "C:\EgtDev\Extern\dwrite_1.h"
//#include "C:\EgtDev\Extern\dwrite_2.h"
#include "C:\EgtDev\Extern\opennurbs\dwrite\Include\dwrite.h"
#include "C:\EgtDev\Extern\opennurbs\dwrite\Include\dwrite_1.h"
#include "C:\EgtDev\Extern\opennurbs\dwrite\Include\dwrite_2.h"
//#include "C:\EgtDev\Extern\opennurbs\add\wrl.h"
#include <atlbase.h> // smart pointers disponibili per Windows Xp CComPtr<>
#else //#if defined( WIN64)
#include <dwrite_2.h>
#include <wrl.h> // smart pointers da Windows 8.1 in avanti Miscrosoft::WRL::ComPtr<>
#endif
#include <d2d1.h>
//#include <wrl\implements.h>
//#include <wrl\implements.h> // questo era già commentato
#if defined(WIN64)
#pragma comment(lib, "Dwrite.lib")
#else
//#pragma comment(lib, "C:\\EgtDev\\Extern\\opennurbs\\dwrite\\Lib\\dwriteR32.lib")
#pragma comment(lib, "C:\\EgtDev\\Extern\\dwrite.lib")
#endif
#if defined(WIN32) && defined(WIN64)
#undef WIN32
#endif