@@ -590,12 +590,11 @@ namespace netxs::gui
590
590
}
591
591
};
592
592
593
- IDWriteFactory2* factory2; // fonts: DWrite factory.
594
- IDWriteFontCollection* fontlist; // fonts: System font collection.
595
- IDWriteTextAnalyzer2* analyzer; // fonts: Glyph indicies reader.
596
- std::thread bgworker; // fonts: Background thread .
593
+ ComPtr< IDWriteFactory2> factory2; // fonts: DWrite factory.
594
+ ComPtr< IDWriteFontCollection> fontlist; // fonts: System font collection.
595
+ ComPtr< IDWriteTextAnalyzer2> analyzer; // fonts: Glyph indicies reader.
596
+ std::future< void > bgworker; // fonts: Background fallback reindex .
597
597
wide oslocale; // fonts: User locale.
598
- flag complete; // fonts: Fallback index is ready.
599
598
shaper fontshaper{ *this }; // fonts: .
600
599
601
600
static ui16 msscript (ui32 code) // fonts: ISO<->MS script map.
@@ -715,7 +714,7 @@ namespace netxs::gui
715
714
};
716
715
for (auto & f : fallback) if ((f.color || f.fixed ) && hittest (f.fontface [0 ].face_inst )) return f;
717
716
for (auto & f : fallback) if ((!f.color && !f.fixed ) && hittest (f.fontface [0 ].face_inst )) return f;
718
- complete. wait (faux );
717
+ if (bgworker. valid ()) bgworker. get ( );
719
718
auto try_font = [&](auto i, bool test)
720
719
{
721
720
auto hit = faux;
@@ -766,12 +765,11 @@ namespace netxs::gui
766
765
}
767
766
768
767
fonts (std::list<text>& family_names, si32 cell_height)
769
- : factory2{ (IDWriteFactory2*)[]{ auto f = (IUnknown*)nullptr ; ::DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), &f); return f; }() },
770
- fontlist{ [&]{ auto c = (IDWriteFontCollection*)nullptr ; factory2->GetSystemFontCollection (&c, TRUE ); return c; }() },
771
- analyzer{ [&]{ auto a = (IDWriteTextAnalyzer2*)nullptr ; factory2->CreateTextAnalyzer ((IDWriteTextAnalyzer**)&a); return a; }() },
772
- oslocale (LOCALE_NAME_MAX_LENGTH, ' \0 ' ),
773
- complete{ faux }
768
+ : oslocale(LOCALE_NAME_MAX_LENGTH, ' \0 ' )
774
769
{
770
+ ::DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)factory2.GetAddressOf());
771
+ factory2->GetSystemFontCollection (fontlist.GetAddressOf (), TRUE );
772
+ factory2->CreateTextAnalyzer ((IDWriteTextAnalyzer**)analyzer.GetAddressOf ());
775
773
fontstat.resize (fontlist ? fontlist->GetFontFamilyCount () : 0 );
776
774
if (!fontlist || !analyzer)
777
775
{
@@ -786,7 +784,7 @@ namespace netxs::gui
786
784
log (" %%Using default locale 'en-US'." , prompt::gui);
787
785
}
788
786
oslocale.shrink_to_fit ();
789
- bgworker = std::thread{ [&]
787
+ bgworker = std::async (std::launch::async, [&]
790
788
{
791
789
for (auto i = 0u ; i < fontstat.size (); i++)
792
790
{
@@ -837,10 +835,8 @@ namespace netxs::gui
837
835
}
838
836
sort ();
839
837
// for (auto f : fontstat) log("id=", utf::to_hex(f.s), " i= ", f.i, " n=", f.n);
840
- complete.exchange (true );
841
- complete.notify_all ();
842
838
log (" %%Font fallback index initialized." , prompt::gui);
843
- }} ;
839
+ }) ;
844
840
if (fallback.empty ())
845
841
{
846
842
auto default_font = std::list{ " Courier New" s };
@@ -854,13 +850,6 @@ namespace netxs::gui
854
850
}
855
851
set_cellsz (cell_height);
856
852
}
857
- ~fonts ()
858
- {
859
- if (bgworker.joinable ()) bgworker.join ();
860
- if (analyzer) analyzer->Release ();
861
- if (fontlist) fontlist->Release ();
862
- if (factory2) factory2->Release ();
863
- }
864
853
};
865
854
866
855
#else
@@ -892,7 +881,7 @@ namespace netxs::gui
892
881
bool is_monochromatic;
893
882
void rasterize_layer_pack (auto & /* glyf_masks*/ , auto & /* buffer_pool*/ )
894
883
{
895
- using irgb = netxs::irgb<fp32>;
884
+ // using irgb = netxs::irgb<fp32>;
896
885
// ...
897
886
}
898
887
void rasterize_single_layer (auto & /* glyph_mask*/ , fp2d /* base_line*/ )
@@ -914,7 +903,10 @@ namespace netxs::gui
914
903
}
915
904
auto take_glyph_run (bool monochromatic, bool aamode, bool is_rtl, twod base_line, fp32 em_height, bool is_box_drawing)
916
905
{
917
- auto t = monochromatic || aamode || is_rtl || base_line || em_height || is_box_drawing;
906
+ if (monochromatic || aamode || is_rtl || base_line || em_height || is_box_drawing)
907
+ {
908
+ // ...
909
+ }
918
910
return gr{};
919
911
}
920
912
};
@@ -1190,7 +1182,6 @@ namespace netxs::gui
1190
1182
if (alpha == 255 ) dst = { 0 .f , 0 .f , 0 .f , 256 .f + 255 .f };
1191
1183
else if (alpha != 0 )
1192
1184
{
1193
- static constexpr auto kk = (si32)netxs::saturate_cast<byte>(- 256 .f );
1194
1185
auto fgc_alpha = (si32)netxs::saturate_cast<byte>(dst.a - 256 .f );
1195
1186
dst.a = dst.a + (-(si32)dst.a + 256 + alpha + (255 - alpha) * fgc_alpha / 255 );
1196
1187
}
0 commit comments