Copy link to clipboard
Copied
Hi,
I'm trying to make a plugin using visual C++ (VS 2019) on Win10x64 machine. The idea is (or was) to be able to bold all numbers in the text. I thought this could be done by altering some of the PDFontMetrics members, since some change (ie PDFontMetricsP->stemV) between bold and normal text.
The code shows I'm just taking the PDFontMetrics and reapplying them:
PDEFont pdeFont = PDETextGetFont((PDEText)pdeElement, kPDETextRun, i);
CosObj cosObj;
PDEFontGetCosObj(pdeFont, &cosObj);
PDFont pf = PDFontFromCosObj(cosObj);
PDFontMetricsP metricsP = (PDFontMetricsP)calloc(sizeof(PDFontMetrics),1);//if not used, usually end up with null pointer
ASSize_t sizeMetrics = sizeof(PDFontMetrics);
PDFontGetMetrics(pf, metricsP, sizeMetrics);
PDFontSetMetrics(pf, metricsP, sizeMetrics);
And this is what it does to the pdf, which originally was TimesNewRoman:
I would've expected no change to the font using the PDFontSetMetrics(), so either I've messed up; for example without the calloc, metricsP would end up usually as a null pointer. I'm no expert in C++, so do not know why calloc is needed, or if I'm using it correctly. Otherwise, an Adobe bug?
I'm not holding my breath, there seem to be no examples/samples, or even hits, when searching for PDFontMetrics, but if anyone could point me in the right direction (no pun intended), I will be very surprised and very happy.
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now