public void OutputText(int x, int y, int flag, int x1, int y1, int x2, int y2, string text)
{
MetaFont font = state.CurrentFont;
float refX = state.TransformX(x);
float refY = state.TransformY(y);
float angle = state.TransformAngle(font.Angle);
float sin = (float)Math.Sin(angle);
float cos = (float)Math.Cos(angle);
float fontSize = font.GetFontSize(state);
BaseFont bf = font.Font;
int align = state.TextAlign;
float textWidth = bf.GetWidthPoint(text, fontSize);
float tx = 0;
float ty = 0;
float descender = bf.GetFontDescriptor(BaseFont.DESCENT, fontSize);
float ury = bf.GetFontDescriptor(BaseFont.BBOXURY, fontSize);
cb.SaveState();
cb.ConcatCTM(cos, sin, -sin, cos, refX, refY);
if ((align & MetaState.TA_CENTER) == MetaState.TA_CENTER)
tx = -textWidth / 2;
else if ((align & MetaState.TA_RIGHT) == MetaState.TA_RIGHT)
tx = -textWidth;
if ((align & MetaState.TA_BASELINE) == MetaState.TA_BASELINE)
ty = 0;
else if ((align & MetaState.TA_BOTTOM) == MetaState.TA_BOTTOM)
ty = -descender;
else
ty = -ury;
BaseColor textColor;
if (state.BackgroundMode == MetaState.OPAQUE) {
textColor = state.CurrentBackgroundColor;
cb.SetColorFill(textColor);
cb.Rectangle(tx, ty + descender, textWidth, ury - descender);
cb.Fill();
}
textColor = state.CurrentTextColor;
cb.SetColorFill(textColor);
cb.BeginText();
cb.SetFontAndSize(bf, fontSize);
cb.SetTextMatrix(tx, ty);
cb.ShowText(text);
cb.EndText();
if (font.IsUnderline()) {
cb.Rectangle(tx, ty - fontSize / 4, textWidth, fontSize / 15);
cb.Fill();
}
if (font.IsStrikeout()) {
cb.Rectangle(tx, ty + fontSize / 3, textWidth, fontSize / 15);
cb.Fill();
}
cb.RestoreState();
}