On Thu Sep 4 20:04:15 2025 +0000, Nikolay Sivov wrote:
We could make it work without such extra marker. One way would be to always allocate entries array of pointers for a new font set object, and copy existing arrays to it, addrefing entries. Another way is to add another layer with `"struct dwrite_fontset_entries { refcount; struct dwrite_fontset_entry **entries; entry_count };"` This way you'd create such structure once and can referencing it easily without copies. There are two different cases:
- collection -> get_fontset. That gets you a complete set every time,
but different instance of dwrite outer object implementing IDWriteFontSet;
- fontset -> getmatchingfonts. That produces a subset, so you would
create a new "struct dwrite_fontset_entries" if matching count does not equal full set count. If it's a smaller subset you'll have to go trough a loop to addref entries. But in collection -> GetFontSet() case you only need to allocate "struct fontset", set a pointer to "struct dwrite_fontset_entries *", and addref just fontset_entries, no need to loop. Let me know what you think, or if something is unclear.
Ah thanks, that makes sense. There's a new version up that takes the approach of giving each font set its own array that's a copy of the collection's (and caching a copy on the collection the first time a font set is made). That seemed far simpler to me than another level of indirection with its own refcount, though the lack of copying with that approach is appealing. Let me know what you think and if you'd prefer the other direction.