FX_FLOAT CPDF_VariableText::GetAutoFontSize() {
  int32_t nTotal = sizeof(gFontSizeSteps) / sizeof(uint8_t);
  if (IsMultiLine())
    nTotal /= 4;
  if (nTotal <= 0)
    return 0;
  if (GetPlateWidth() <= 0)
    return 0;

  int32_t nLeft = 0;
  int32_t nRight = nTotal - 1;
  int32_t nMid = nTotal / 2;
  while (nLeft <= nRight) {
    if (IsBigger(gFontSizeSteps[nMid])) {
      nRight = nMid - 1;
      nMid = (nLeft + nRight) / 2;
      continue;
    } else {
      nLeft = nMid + 1;
      nMid = (nLeft + nRight) / 2;
      continue;
    }
  }
  return (FX_FLOAT)gFontSizeSteps[nMid];
}
bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const {
  CFX_SizeF szTotal;
  for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
    if (CSection* pSection = m_SectionArray.GetAt(s)) {
      CFX_SizeF size = pSection->GetSectionSize(fFontSize);
      szTotal.x = std::max(size.x, szTotal.x);
      szTotal.y += size.y;
      if (IsFloatBigger(szTotal.x, GetPlateWidth()) ||
          IsFloatBigger(szTotal.y, GetPlateHeight())) {
        return true;
      }
    }
  }
  return false;
}
Exemplo n.º 3
0
CFX_SizeF CPDF_VariableText::GetPlateSize() const {
  return CFX_SizeF(GetPlateWidth(), GetPlateHeight());
}