CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, CFX_ByteString& csNameTag)
{
    csNameTag = "";
    FX_BYTE charSet = CPDF_InterForm::GetNativeCharSet();
    CFX_SubstFont* pSubst;
    CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument);
    if (pFont != NULL) {
        pSubst = (CFX_SubstFont*)pFont->GetSubstFont();
        if (pSubst != NULL && pSubst->m_Charset == (int)charSet) {
            FindInterFormFont(pFormDict, pFont, csNameTag);
            return pFont;
        }
    }
    return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
예제 #2
0
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
                                  CPDF_Document* pDocument,
                                  CFX_ByteString& csNameTag) {
  csNameTag.clear();
  uint8_t charSet = CPDF_InterForm::GetNativeCharSet();
  CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument);
  if (pFont) {
    CFX_SubstFont* pSubst = pFont->GetSubstFont();
    if (pSubst && pSubst->m_Charset == (int)charSet) {
      FindInterFormFont(pFormDict, pFont, csNameTag);
      return pFont;
    }
  }
  return GetNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
}
예제 #3
0
CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
                                               CFX_ByteString& sFontAlias,
                                               int32_t nCharset) {
  if (!pResDict)
    return NULL;

  CPDF_Document* pDocument = GetDocument();
  ASSERT(pDocument != NULL);

  CPDF_Dictionary* pFonts = pResDict->GetDict("Font");
  if (pFonts == NULL)
    return NULL;

  CPDF_Font* pFind = NULL;

  FX_POSITION pos = pFonts->GetStartPos();
  while (pos) {
    CPDF_Object* pObj = NULL;
    CFX_ByteString csKey;
    pObj = pFonts->GetNextElement(pos, csKey);
    if (pObj == NULL)
      continue;

    CPDF_Object* pDirect = pObj->GetDirect();
    if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY)
      continue;

    CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
    if (pElement->GetString("Type") != "Font")
      continue;

    CPDF_Font* pFont = pDocument->LoadFont(pElement);
    if (pFont == NULL)
      continue;
    const CFX_SubstFont* pSubst = pFont->GetSubstFont();
    if (pSubst == NULL)
      continue;
    if (pSubst->m_Charset == nCharset) {
      sFontAlias = csKey;
      pFind = pFont;
    }
  }
  return pFind;
}
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, CPDF_Document* pDocument, FX_BYTE charSet, CFX_ByteString& csNameTag)
{
    if (pFormDict == NULL) {
        return NULL;
    }
    CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
    if (pDR == NULL) {
        return NULL;
    }
    CPDF_Dictionary* pFonts = pDR->GetDict("Font");
    if (pFonts == NULL) {
        return NULL;
    }
    FX_POSITION pos = pFonts->GetStartPos();
    while (pos) {
        CPDF_Object* pObj = NULL;
        CFX_ByteString csKey;
        pObj = pFonts->GetNextElement(pos, csKey);
        if (pObj == NULL) {
            continue;
        }
        CPDF_Object* pDirect = pObj->GetDirect();
        if (pDirect == NULL || pDirect->GetType() != PDFOBJ_DICTIONARY) {
            continue;
        }
        CPDF_Dictionary* pElement = (CPDF_Dictionary*)pDirect;
        if (pElement->GetString("Type") != "Font") {
            continue;
        }
        CPDF_Font* pFind = pDocument->LoadFont(pElement);
        if (pFind == NULL) {
            continue;
        }
        CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
        if (pSubst == NULL) {
            continue;
        }
        if (pSubst->m_Charset == (int)charSet) {
            csNameTag = csKey;
            return pFind;
        }
    }
    return NULL;
}
예제 #5
0
CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict,
                                  CPDF_Document* pDocument,
                                  uint8_t charSet,
                                  CFX_ByteString& csNameTag) {
  if (!pFormDict) {
    return NULL;
  }
  CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
  if (!pDR) {
    return NULL;
  }
  CPDF_Dictionary* pFonts = pDR->GetDict("Font");
  if (!pFonts) {
    return NULL;
  }
  for (const auto& it : *pFonts) {
    const CFX_ByteString& csKey = it.first;
    CPDF_Object* pObj = it.second;
    if (!pObj) {
      continue;
    }
    CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
    if (!pElement)
      continue;
    if (pElement->GetString("Type") != "Font")
      continue;
    CPDF_Font* pFind = pDocument->LoadFont(pElement);
    if (!pFind) {
      continue;
    }
    CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
    if (!pSubst) {
      continue;
    }
    if (pSubst->m_Charset == (int)charSet) {
      csNameTag = csKey;
      return pFind;
    }
  }
  return NULL;
}
예제 #6
0
CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict,
                                               CFX_ByteString& sFontAlias,
                                               int32_t nCharset) {
  if (!pResDict)
    return nullptr;

  CPDF_Dictionary* pFonts = pResDict->GetDictBy("Font");
  if (!pFonts)
    return nullptr;

  CPDF_Document* pDocument = GetDocument();
  CPDF_Font* pFind = nullptr;
  for (const auto& it : *pFonts) {
    const CFX_ByteString& csKey = it.first;
    CPDF_Object* pObj = it.second;
    if (!pObj)
      continue;

    CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
    if (!pElement)
      continue;
    if (pElement->GetStringBy("Type") != "Font")
      continue;

    CPDF_Font* pFont = pDocument->LoadFont(pElement);
    if (!pFont)
      continue;
    const CFX_SubstFont* pSubst = pFont->GetSubstFont();
    if (!pSubst)
      continue;
    if (pSubst->m_Charset == nCharset) {
      sFontAlias = csKey;
      pFind = pFont;
    }
  }
  return pFind;
}
예제 #7
0
FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, const CFX_AffineMatrix* pObj2Device, CFX_PathData* pClippingPath)
{
    if(textobj->m_nChars == 0) {
        return TRUE;
    }
    int text_render_mode = textobj->m_TextState.GetObject()->m_TextMode;
    if (text_render_mode == 3) {
        return TRUE;
    }
    CPDF_Font* pFont = textobj->m_TextState.GetFont();
    if (pFont->GetFontType() == PDFFONT_TYPE3) {
        return ProcessType3Text(textobj, pObj2Device);
    }
    FX_BOOL bFill = FALSE, bStroke = FALSE, bClip = FALSE;
    if (pClippingPath) {
        bClip = TRUE;
    } else {
        switch (text_render_mode) {
            case 0:
            case 4:
                bFill = TRUE;
                break;
            case 1:
            case 5:
                if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
                    bFill = TRUE;
                } else {
                    bStroke = TRUE;
                }
                break;
            case 2:
            case 6:
                if (pFont->GetFace() == NULL && !(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
                    bFill = TRUE;
                } else {
                    bFill = bStroke = TRUE;
                }
                break;
            case 3:
            case 7:
                return TRUE;
            default:
                bFill = TRUE;
        }
    }
    FX_ARGB stroke_argb = 0, fill_argb = 0;
    FX_BOOL bPattern = FALSE;
    if (bStroke) {
        if (textobj->m_ColorState.GetStrokeColor()->IsPattern()) {
            bPattern = TRUE;
        } else {
            stroke_argb = GetStrokeArgb(textobj);
        }
    }
    if (bFill) {
        if (textobj->m_ColorState.GetFillColor()->IsPattern()) {
            bPattern = TRUE;
        } else {
            fill_argb = GetFillArgb(textobj);
        }
    }
    CFX_AffineMatrix text_matrix;
    textobj->GetTextMatrix(&text_matrix);
    if(IsAvailableMatrix(text_matrix) == FALSE) {
        return TRUE;
    }
    FX_FLOAT font_size = textobj->m_TextState.GetFontSize();
    if (bPattern) {
        DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_matrix, bFill, bStroke);
        return TRUE;
    }
#if defined(_FPDFAPI_MINI_)
    if (bFill) {
        bStroke = FALSE;
    }
    if (bStroke) {
        if (font_size * text_matrix.GetXUnit() * pObj2Device->GetXUnit() < 6) {
            bStroke = FALSE;
        }
    }
#endif
    if (bClip || bStroke) {
        const CFX_AffineMatrix* pDeviceMatrix = pObj2Device;
        CFX_AffineMatrix device_matrix;
        if (bStroke) {
            const FX_FLOAT* pCTM = textobj->m_TextState.GetObject()->m_CTM;
            if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) {
                CFX_AffineMatrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0);
                text_matrix.ConcatInverse(ctm);
                device_matrix.Copy(ctm);
                device_matrix.Concat(*pObj2Device);
                pDeviceMatrix = &device_matrix;
            }
        }
        int flag = 0;
        if (bStroke && bFill) {
            flag |= FX_FILL_STROKE;
            flag |= FX_STROKE_TEXT_MODE;
        }
#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_)
        const CPDF_GeneralStateData* pGeneralData = ((CPDF_PageObject*)textobj)->m_GeneralState;
        if (pGeneralData && pGeneralData->m_StrokeAdjust) {
            flag |= FX_STROKE_ADJUST;
        }
#endif
        if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) {
            flag |= FXFILL_NOPATHSMOOTH;
        }
        return CPDF_TextRenderer::DrawTextPath(m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos, pFont, font_size,
                                               &text_matrix, pDeviceMatrix, textobj->m_GraphState, fill_argb, stroke_argb, pClippingPath, flag);
    }
    text_matrix.Concat(*pObj2Device);
    return CPDF_TextRenderer::DrawNormalText(m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos, pFont, font_size,
            &text_matrix, fill_argb, &m_Options);
}