private static void DrawCardText( Rectangle rectangle, Cursor topCursor, Cursor bottomCursor, PdfCanvas canvas, string cardName, PdfFont font, CardSuperType cardSuperType) { const float textPadding = 2f; const float textHeight = 12f; const float maxFontSize = 10f; var textRectangleHeight = topCursor.GetCurrent() - bottomCursor.GetCurrent() - textPadding * 2; var textFontSize = TextSharpHelpers.GetFontSize(canvas, cardName, textRectangleHeight, font, maxFontSize); var fontWeight = GetMainTextFontWeight(cardSuperType); var fontColor = GetMainTextFontColor(cardSuperType); var textWidthOffset = 8 + (maxFontSize - textFontSize) * .35f; var textRectangle = new Rectangle( rectangle.GetLeft() + textWidthOffset, bottomCursor.GetCurrent() + textPadding, textHeight, topCursor.GetCurrent() - (bottomCursor.GetCurrent() + 2 * textPadding)); DrawText(canvas, cardName, textRectangle, -2.5f, 0f, font, fontColor, textFontSize, fontWeight); }
private static FontWeight GetMainTextFontWeight(CardSuperType superType) { var hasBlackBackground = superType.Card_type_image == "night.png"; return(hasBlackBackground ? FontWeight.Bold : FontWeight.Regular); }
private static Color GetMainTextFontColor(CardSuperType superType) { var hasBlackBackground = superType.Card_type_image == "night.png"; return(hasBlackBackground ? ColorConstants.WHITE : ColorConstants.BLACK); }
private static void DrawBackgroundImage(CardSuperType superType, Rectangle rectangle, PdfContentByte canvas, Cursor topCursor, Cursor bottomCursor) { var imageNameTokens = superType.Card_type_image.Split('.'); var imagePath = GetCurrentPath + $@"Dominion\{imageNameTokens[0]}_nc.{imageNameTokens[1]}"; var image = DrawImage(rectangle, canvas, imagePath, true, true); bottomCursor.AdvanceCursor(image.AbsoluteY); topCursor.AdvanceCursor(bottomCursor.GetCurrent() + image.ScaledHeight); }
private static void DrawBackgroundImage( CardSuperType superType, Rectangle rectangle, PdfCanvas canvas) { var imageNameTokens = superType.Card_type_image.Split('.'); var imagePath = Path.Combine(CurrentPath, "Dominion", $"{imageNameTokens[0]}.{imageNameTokens[1]}"); DrawImage(rectangle, canvas, imagePath, true, true); }
private static Font GetMainTextFont(BaseFont baseFont, float fontSize, CardSuperType superType) { var hasBlackBackground = superType.Card_type_image == "night.png"; var fontColor = hasBlackBackground ? BaseColor.WHITE : BaseColor.BLACK; var fontStyle = hasBlackBackground ? Font.BOLD : Font.NORMAL; var font = new Font(baseFont, fontSize, fontStyle, fontColor); return(font); }
private static void DrawCardText(Rectangle rectangle, Cursor topCursor, Cursor bottomCursor, PdfContentByte canvas, string cardName, BaseFont baseFont, CardSuperType cardSuperType) { const float textPadding = 2f; const float textHeight = 12f; const float maxFontSize = 10f; var textRectangleHeight = topCursor.GetCurrent() - bottomCursor.GetCurrent() - textPadding * 2; var textFontSize = TextSharpHelpers.GetFontSize(canvas, cardName, textRectangleHeight, baseFont, maxFontSize, Element.ALIGN_LEFT, Font.NORMAL); var font = GetMainTextFont(baseFont, textFontSize, cardSuperType); var textWidthOffset = 8 + (maxFontSize - font.Size) * .35f; var textRectangle = new Rectangle( rectangle.Left + textWidthOffset, bottomCursor.GetCurrent() + textPadding, rectangle.Left + textWidthOffset + textHeight, topCursor.GetCurrent() - textPadding); DrawText(canvas, cardName, textRectangle, 0, 0, font); }