@@ -1248,7 +1248,7 @@ MainWindow::DialogProcResult CALLBACK MainWindow::OnDragAndDrop(HWND hwnd, UINT
12481248 DragFinish (hDrop);
12491249
12501250 if (hr == HRESULT_FROM_WIN32 (ERROR_BAD_FORMAT))
1251- ShowMessageAndAppendLog (u" Unknown file format '%s', 0x%08X" , fileName.c_str (), hr);
1251+ ShowMessageAndAppendLog (u" Unknown file format '%s' (TextLayoutSamplerSettings, txt, ttf, otf, tte, ttc, otc) , 0x%08X" , fileName.c_str (), hr);
12521252 else if (FAILED (hr))
12531253 ShowMessageAndAppendLog (u" Failed to load file '%s', 0x%08X" , fileName.c_str (), hr);
12541254
@@ -1268,6 +1268,11 @@ std::vector<uint32_t> MainWindow::GetSelectedDrawableObjectIndices()
12681268 selectedIndices.resize (drawableObjects_.size ());
12691269 std::iota (selectedIndices.begin (), selectedIndices.end (), 0 );
12701270 }
1271+ else // Validate the indices, just in case the UI somehow became out of sync.
1272+ {
1273+ auto const drawableObjectsTotal = drawableObjects_.size ();
1274+ selectedIndices.erase (std::remove_if (selectedIndices.begin (), selectedIndices.end (), [=](auto i) {return i >= drawableObjectsTotal; }), selectedIndices.end ());
1275+ }
12711276
12721277 return selectedIndices;
12731278}
@@ -1484,9 +1489,6 @@ HRESULT MainWindow::UpdateDrawableObjectsFromFontFamilyNameProperties(FontFamily
14841489
14851490 for (auto drawableObjectIndex : selectedDrawableObjectIndices)
14861491 {
1487- if (drawableObjectIndex >= drawableObjectsTotal)
1488- continue ;
1489-
14901492 auto & drawableObject = drawableObjects_[drawableObjectIndex];
14911493 DrawableObjectFunction function = drawableObject.GetValue (DrawableObjectAttributeFunction, DrawableObjectFunctionNop);
14921494 bool isGdiOrGdiPlusFunction = DrawableObject::IsGdiOrGdiPlusFunction (function);
@@ -2112,9 +2114,6 @@ HRESULT MainWindow::AutofitDrawableObjects(bool useMaximumWidth, bool useMaximum
21122114 // The first pass gets the sizes of all the objects.
21132115 for (auto drawableObjectIndex : drawableObjectIndices)
21142116 {
2115- if (drawableObjectIndex >= drawableObjectsTotal)
2116- continue ;
2117-
21182117 auto & drawableObject = drawableObjects_[drawableObjectIndex];
21192118
21202119 D2D_RECT_F layoutBounds, contentBounds;
@@ -2132,9 +2131,6 @@ HRESULT MainWindow::AutofitDrawableObjects(bool useMaximumWidth, bool useMaximum
21322131 // The second pass updates them, considering whether to maximize them to the largest object found.
21332132 for (auto drawableObjectIndex : drawableObjectIndices)
21342133 {
2135- if (drawableObjectIndex >= drawableObjectsTotal)
2136- continue ;
2137-
21382134 auto & drawableObject = drawableObjects_[drawableObjectIndex];
21392135 D2D_SIZE_F& size = sizes[drawableObjectIndex];
21402136 if (size.width > 0 && size.height > 0 )
@@ -2159,6 +2155,33 @@ HRESULT MainWindow::AutofitDrawableObjects(bool useMaximumWidth, bool useMaximum
21592155}
21602156
21612157
2158+ HRESULT MainWindow::SetNoLineWrapOnDrawableObjects ()
2159+ {
2160+ // Reduce all selected drawable objects to 1x1, and set no wrapping.
2161+ std::vector<uint32_t > drawableObjectIndices = GetSelectedDrawableObjectIndices ();
2162+ for (auto drawableObjectIndex : drawableObjectIndices)
2163+ {
2164+ auto & drawableObject = drawableObjects_[drawableObjectIndex];
2165+ drawableObject.Set (DrawableObjectAttributeLineWrappingMode, LineWrappingModeNone);
2166+ drawableObject.Set (DrawableObjectAttributeWidth, 1 );
2167+ drawableObject.Set (DrawableObjectAttributeHeight, 1 );
2168+ drawableObject.Update ();
2169+ }
2170+
2171+ DeferUpdateUi (
2172+ NeededUiUpdateDrawableObjectsListView |
2173+ NeededUiUpdateAttributesListView |
2174+ NeededUiUpdateAttributeValuesListView |
2175+ NeededUiUpdateAttributeValuesEdit |
2176+ NeededUiUpdateAttributeValuesSlider |
2177+ NeededUiUpdateDrawableObjectsCanvas |
2178+ NeededUiUpdateTextEdit
2179+ );
2180+
2181+ return S_OK;
2182+ }
2183+
2184+
21622185HRESULT MainWindow::StoreDrawableObjectsSettings ()
21632186{
21642187 std::u16string filePath;
@@ -2184,11 +2207,11 @@ HRESULT MainWindow::StoreDrawableObjectsSettings()
21842207 }
21852208 if (hr == HRESULT_FROM_WIN32 (ERROR_BAD_FORMAT)) // Consolidate this repeated error message.
21862209 {
2187- ShowMessageAndAppendLog (u" Unknown file format '%s', 0x%08X" , filePath.c_str (), hr);
2210+ ShowMessageAndAppendLog (u" Unknown sampler settings file format '%s', 0x%08X" , filePath.c_str (), hr);
21882211 }
21892212 else if (FAILED (hr))
21902213 {
2191- ShowMessageAndAppendLog (u" Failed to save to file '%s', 0x%08X" , filePath.c_str (), hr);
2214+ ShowMessageAndAppendLog (u" Failed to save to sampler settings file '%s', 0x%08X" , filePath.c_str (), hr);
21922215 }
21932216
21942217 return hr;
@@ -2983,8 +3006,9 @@ void MainWindow::OnAssortedActions(HWND anchorControl)
29833006 {IdcGetAllColorFontCharacters, u" Get all color font characters" },
29843007 {IdcCopyAllFontCharacters, u" Copy all font characters to clipboard" },
29853008 {0 , u" -" },
2986- { IdcAutofitDrawableObjects, u" Autofit drawable objects" },
3009+ {IdcAutofitDrawableObjects, u" Autofit drawable objects" },
29873010 {IdcAutofitDrawableObjectsUniformly, u" Autofit drawable objects uniformly" },
3011+ {IdcSetNoLineWrapOnDrawableObjects, u" Reduce drawable objects size with no wrap" }
29883012 };
29893013
29903014 int menuId = TrackPopupMenu (make_array_ref (items, countof (items)), anchorControl, hwnd_);
@@ -2999,6 +3023,7 @@ void MainWindow::OnAssortedActions(HWND anchorControl)
29993023 case IdcExportGlyphImageData: ExportFontGlyphData (); break ;
30003024 case IdcAutofitDrawableObjects: AutofitDrawableObjects (/* useMaximumWidth*/ false , /* useMaximumHeight*/ false ); break ;
30013025 case IdcAutofitDrawableObjectsUniformly: AutofitDrawableObjects (/* useMaximumWidth*/ true , /* useMaximumHeight*/ true ); break ;
3026+ case IdcSetNoLineWrapOnDrawableObjects: SetNoLineWrapOnDrawableObjects (); break ;
30023027 }
30033028}
30043029
0 commit comments