From 7510007dac7dbed6e2206e81e68c5bbe6dccb9f5 Mon Sep 17 00:00:00 2001 From: gaurav12devloper Date: Thu, 19 Oct 2023 17:18:23 +0530 Subject: [PATCH] fixed bug for space between two character --- Ascii.h | 4 ++++ Fonts/Boomer/boomer.h | 10 ++++++++++ Fonts/SevenStar/sevenstar.h | 10 ++++++++++ Fonts/Straight/straight.h | 10 ++++++++++ Fonts/banner/banner.h | 11 +++++++++++ Fonts/carlos/carlos.h | 10 ++++++++++ Fonts/fonts.h | 7 +++++++ Fonts/starwar/starwar.h | 10 ++++++++++ example.cpp | 4 ++-- 9 files changed, 74 insertions(+), 2 deletions(-) diff --git a/Ascii.h b/Ascii.h index 77b4dbf5..9b3a7c66 100644 --- a/Ascii.h +++ b/Ascii.h @@ -206,6 +206,10 @@ namespace ascii else if (c == '9') character = font->nine(); + //for space + else if (c == ' ') + character = font->space(); + font->pushChar(character); } font->printvector(); diff --git a/Fonts/Boomer/boomer.h b/Fonts/Boomer/boomer.h index 9133e261..f63027a0 100644 --- a/Fonts/Boomer/boomer.h +++ b/Fonts/Boomer/boomer.h @@ -793,5 +793,15 @@ class Boomer : public Fonts character[3][0] = character[5][0] = '\\'; return character; } + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + + return character; + } }; #endif diff --git a/Fonts/SevenStar/sevenstar.h b/Fonts/SevenStar/sevenstar.h index 252ebd1d..e6b80cb4 100644 --- a/Fonts/SevenStar/sevenstar.h +++ b/Fonts/SevenStar/sevenstar.h @@ -2461,5 +2461,15 @@ class SevenStar : public Fonts } return character; } + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + + return character; + } }; #endif \ No newline at end of file diff --git a/Fonts/Straight/straight.h b/Fonts/Straight/straight.h index e849b947..31fb08e5 100644 --- a/Fonts/Straight/straight.h +++ b/Fonts/Straight/straight.h @@ -721,6 +721,16 @@ class Straight : public Fonts character[2][3] = '/'; character[1][3] = '\\'; + return character; + } + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + return character; } }; diff --git a/Fonts/banner/banner.h b/Fonts/banner/banner.h index 87d6f04a..24cffb09 100644 --- a/Fonts/banner/banner.h +++ b/Fonts/banner/banner.h @@ -693,5 +693,16 @@ class Banner : public Fonts } */ + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + + return character; + } + }; #endif diff --git a/Fonts/carlos/carlos.h b/Fonts/carlos/carlos.h index 7bc7b009..ac349cd4 100644 --- a/Fonts/carlos/carlos.h +++ b/Fonts/carlos/carlos.h @@ -1012,5 +1012,15 @@ class Carlos : public Fonts } */ + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + + return character; + } }; #endif diff --git a/Fonts/fonts.h b/Fonts/fonts.h index 295be997..8ffb9ad3 100644 --- a/Fonts/fonts.h +++ b/Fonts/fonts.h @@ -83,6 +83,13 @@ class Fonts } /********************************adding virtual functions********************************/ + // Virtual functions for space + virtual char **space() + { + std::cout << "space not overridden?" << std::endl; + return nullptr; + } + // Virtual functions for lowercase letters virtual char **a() { diff --git a/Fonts/starwar/starwar.h b/Fonts/starwar/starwar.h index 0dd91a70..9dfe4d14 100644 --- a/Fonts/starwar/starwar.h +++ b/Fonts/starwar/starwar.h @@ -805,5 +805,15 @@ class Starwar : public Fonts character[2][0] = character[2][6] = character[3][6] = '|'; return character; } + + // for space + char **space() + { + char **character = getCharGrid(1,1); + + character[0][0] = ' '; + + return character; + } }; #endif diff --git a/example.cpp b/example.cpp index 9f7d59fe..1e258e5e 100644 --- a/example.cpp +++ b/example.cpp @@ -5,7 +5,7 @@ using namespace ascii; int main() { - Ascii a = Ascii(starwar); - a.print("K"); + Ascii a = Ascii(carlos); + a.print("G A"); return 0; } \ No newline at end of file