Fonts created for different documents should be independent. In other case you cannot do anything usable with them when using multiple threads.
Code:
``` c++
PdfMemDocument doc0;
PdfFont *font0 = doc0.CreateFont("Helvetica");
font0->SetFontSize(10);
PdfMemDocument doc1;
PdfFont *font1 = doc1.CreateFont("Helvetica");
font1->SetFontSize(20);
printf("font0 size %g\n", font0->GetFontSize());
printf("font1 size %g\n", font1->GetFontSize());
```
Output:
```
font0 size 20
font1 size 20
```
What I would expect (or what happens when is font for example "Arial"):
```
font0 size 10
font1 size 20
```
Fonts font0 and font1 are different objects but they share same m_pMetrics
(in case of base 14 fonts) which is used for font size and other font
settings. This is because PODOFO_Base14FontDef_FindBuiltinData is returning
mutable pointer to static global array PODOFO_BUILTIN_FONTS.
This is here probably from beginning.
I am sending patch. Hopefully I did not forget something.
PODOFO_Base14FontDef_FindBuiltinData is now returning newly allocated
metrics object copy constructed from PODOFO_BUILTIN_FONTS[i]. I deleted
destructor of PdfFontTypeBase14 so metrics object is properly deleted with
font. I also changed PODOFO_BUILTIN_FONTS to const for sure that there is
nothing else that changes it.
patch.diff
Description: Binary data
_______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
