MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / show

Function show

internal/cbm/pdf/pdf_text.c:372–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372static void show(pdf_interp_t *it, const pdf_gs_t *gs, double *tm, const pdf_val_t *str) {
373 pdf_font_t *font = gs->font;
374 if (!font) {
375 return;
376 }
377 pdf_doc_t *d = it->d;
378 pdf_out_t *out = &it->out;
379 if (str->n > it->gcap) {
380 size_t ncap = str->n * 2;
381 pdf_glyph_out_t *g =
382 (pdf_glyph_out_t *)cbm_realloc(CBM_MEM_CLASS_EXTRACT, it->gbuf, ncap * sizeof(*g));
383 if (!g) {
384 d->nomem = true;
385 return;
386 }
387 it->gbuf = g;
388 it->gcap = ncap;
389 }
390 size_t ng = 0;
391 pdf_font_decode(d, font, str->s, str->n, it->gbuf, &ng);
392 double fs = gs->fs;
393 double tc = gs->tc;
394 double tw = gs->tw;
395 double th = gs->th;
396 double rise = gs->rise;
397 const double *ctm = gs->ctm;
398 double m[6];
399 mat_mul(tm, ctm, m);
400 double a = m[0];
401 double b = m[1];
402 double size = fabs(fs) * py_hypot(m[2], m[3]) * pdf_font_em(font);
403 double nrm = py_hypot(a, b);
404 double dx = 1.0;
405 double dy = 0.0;
406 if (nrm > 0) {
407 dx = a / nrm;
408 dy = b / nrm;
409 }
410 if (th < 0) {
411 dx = -dx;
412 dy = -dy;
413 }
414 double e = tm[4];
415 double f = tm[5];
416 double ta = tm[0];
417 double tb = tm[1];
418 for (size_t i = 0; i < ng; i++) {
419 const pdf_glyph_out_t *g = &it->gbuf[i];
420 double adv = (g->width * fs + tc + (g->space ? tw : 0.0)) * th;
421 out->glyphs++;
422 const char *u = g->utf8;
423 if (!u) {
424 out->unmapped++;
425 u = "\xEF\xBF\xBD";
426 }
427 if (u[0]) {
428 /* the glyph's origin (0, rise) in text space, in device space */
429 double ux = rise * tm[2] + e;

Callers 1

runFunction · 0.70

Calls 6

cbm_reallocFunction · 0.85
pdf_font_decodeFunction · 0.85
mat_mulFunction · 0.85
py_hypotFunction · 0.85
pdf_font_emFunction · 0.85
emitFunction · 0.70

Tested by

no test coverage detected