void U_EMREXTCREATEFONTINDIRECTW_draw(const char *contents, FILE *out, drawingStates *states) { FLAG_PARTIAL; if (states->verbose) { U_EMREXTCREATEFONTINDIRECTW_print(contents, states); } PU_EMREXTCREATEFONTINDIRECTW pEmr = (PU_EMREXTCREATEFONTINDIRECTW)(contents); uint16_t index = pEmr->ihFont; returnOutOfOTIndex(index); if (states->objectTable[index].font_name != NULL) { free(states->objectTable[index].font_name); states->objectTable[index].font_name = NULL; } if (states->objectTable[index].font_family != NULL) { free(states->objectTable[index].font_family); states->objectTable[index].font_family = NULL; } U_LOGFONT logfont; if (pEmr->emr.nSize == sizeof(U_EMREXTCREATEFONTINDIRECTW)) { // holds logfont_panose U_LOGFONT_PANOSE lfp = pEmr->elfw; logfont = pEmr->elfw.elfLogFont; char *fullname = U_Utf16leToUtf8(lfp.elfFullName, U_LF_FULLFACESIZE, NULL); states->objectTable[index].font_name = fullname; } else { // holds logfont logfont = *(PU_LOGFONT) & (pEmr->elfw); } char *family = U_Utf16leToUtf8(logfont.lfFaceName, U_LF_FACESIZE, NULL); states->objectTable[index].font_width = abs(logfont.lfWidth); states->objectTable[index].font_height = abs(logfont.lfHeight); states->objectTable[index].font_weight = logfont.lfWeight; states->objectTable[index].font_italic = logfont.lfItalic; states->objectTable[index].font_underline = logfont.lfUnderline; states->objectTable[index].font_strikeout = logfont.lfStrikeOut; states->objectTable[index].font_escapement = (logfont.lfEscapement % 3600); states->objectTable[index].font_orientation = (logfont.lfOrientation % 3600); states->objectTable[index].font_family = family; states->objectTable[index].font_set = true; states->objectTable[index].text_charset = logfont.lfCharSet; }
void U_EMRHEADER_draw(const char *contents, FILE *out, drawingStates *states) { FLAG_PARTIAL; if (states->verbose) { U_EMRHEADER_print(contents, states); } char *string; int p1len; PU_EMRHEADER pEmr = (PU_EMRHEADER)(contents); if (pEmr->offDescription) { returnOutOfEmf((uint16_t *)((char *)(intptr_t)pEmr + (intptr_t)pEmr->offDescription) + 2 * (intptr_t)pEmr->nDescription); string = U_Utf16leToUtf8((uint16_t *)((char *)pEmr + pEmr->offDescription), pEmr->nDescription, NULL); free(string); p1len = 2 + 2 * wchar16len((uint16_t *)((char *)pEmr + pEmr->offDescription)); returnOutOfEmf((uint16_t *)((char *)(intptr_t)pEmr + (intptr_t)pEmr->offDescription + (intptr_t)p1len) + 2 * (intptr_t)pEmr->nDescription); string = U_Utf16leToUtf8( (uint16_t *)((char *)pEmr + pEmr->offDescription + p1len), pEmr->nDescription, NULL); free(string); } // object table allocation // allocate one more to directly use object indexes (starts at 1 and not 0) states->objectTable = calloc(pEmr->nHandles + 1, sizeof(emfGraphObject)); states->objectTableSize = pEmr->nHandles; double ratioXY = (double)(pEmr->rclBounds.right - pEmr->rclBounds.left) / (double)(pEmr->rclBounds.bottom - pEmr->rclBounds.top); if ((states->imgHeight != 0) && (states->imgWidth != 0)) { double tmpWidth = states->imgHeight * ratioXY; double tmpHeight = states->imgWidth / ratioXY; if (tmpWidth > states->imgWidth) { states->imgHeight = tmpHeight; } else { states->imgWidth = tmpWidth; } } else if (states->imgHeight != 0) { states->imgWidth = states->imgHeight * ratioXY; } else if (states->imgWidth != 0) { states->imgHeight = states->imgWidth / ratioXY; } else { states->imgWidth = (double)abs(pEmr->rclBounds.right - pEmr->rclBounds.left); states->imgHeight = (double)abs(pEmr->rclBounds.bottom - pEmr->rclBounds.top); } // set scaling for original resolution // states->scaling = 1; states->scaling = states->imgWidth / (double)abs(pEmr->rclBounds.right - pEmr->rclBounds.left); // remember reference point of the output DC states->RefX = (double)pEmr->rclBounds.left; states->RefY = (double)pEmr->rclBounds.top; states->pxPerMm = (double)pEmr->szlDevice.cx / (double)pEmr->szlMillimeters.cx; if (states->svgDelimiter) { fprintf( out, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); fprintf(out, "<%ssvg version=\"1.1\" ", states->nameSpaceString); fprintf(out, "xmlns=\"http://www.w3.org/2000/svg\" "); fprintf(out, "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "); if ((states->nameSpace != NULL) && (strlen(states->nameSpace) != 0)) { fprintf(out, "xmlns:%s=\"http://www.w3.org/2000/svg\" ", states->nameSpace); } fprintf(out, "width=\"%.4f\" height=\"%.4f\">\n", states->imgWidth, states->imgHeight); } fprintf(out, "<%sg transform=\"translate(%.4f, %.4f)\">\n", states->nameSpaceString, -1.0 * states->RefX * states->scaling, -1.0 * states->RefY * states->scaling); }