diff --git a/.gitignore b/.gitignore
index 3dfcc77..f5f8a5c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ build/
 .mypy_cache/
 .pytest_cache/
 _build/
+.vscode/
diff --git a/.travis.yml b/.travis.yml
index b9261b5..5c8bfa4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ python:
   - "3.4"
   - "3.5"
   - "3.6"
-  - "3.7-dev"
+  - "nightly"
 
 install:
   - pip install --upgrade pipenv
diff --git a/README.md b/README.md
index 73ff3ec..7d2daa6 100644
--- a/README.md
+++ b/README.md
@@ -69,5 +69,6 @@ Ported by [@frostming](https://github.com/frostming), under GPLv2 license. See [
 
 ## Changelog
 
-- **v0.3.0** Supports Python 2.7
-- **v0.2.0** Initial commit and testing
+- **v0.3.1** Fix a bug that the background doesn't span the full width.
+- **v0.3.0** Supports Python 2.7.
+- **v0.2.0** Initial commit and testing.
diff --git a/cfonts/__version__.py b/cfonts/__version__.py
index 98f0094..f19df34 100644
--- a/cfonts/__version__.py
+++ b/cfonts/__version__.py
@@ -6,4 +6,4 @@
     :license: GNU GPLv2
     :author: Frost Ming<mianghong@gmail.com>
 """
-__version__ = '0.3.0'
+__version__ = '0.3.1'
diff --git a/cfonts/core.py b/cfonts/core.py
index 43d70ac..ffd6d61 100644
--- a/cfonts/core.py
+++ b/cfonts/core.py
@@ -280,14 +280,20 @@ def render(
 
         output = align_text(output, line_length, font_face.lines, align, size)
 
-    write = "\n".join(output)
-    if font_face.colors <= 1:
-        write = colorize(write, font_face.colors, colors)
     if space:
-        write = "\n\n{}\n\n".format(write)
+        # Blank lines at the beginning and end
+        output = [""] * 2 + output + [""] * 2
     if background != BGCOLORS.transparent:
+        # Fill whitespaces to the full width.
+        # See https://github.com/frostming/python-cfonts/issues/3
+        output = [(line + " " * (size[0] - len(_strip_color(line)))) for line in output]
         bg_color = "bg" + background
-        write = ansi_styles[bg_color][0] + "\n" + write + ansi_styles[bg_color][1]
+        if output:
+            output[0] = ansi_styles[bg_color][0] + output[0]
+            output[-1] += ansi_styles[bg_color][1]
+    write = "\n".join(output)
+    if font_face.colors <= 1:
+        write = colorize(write, font_face.colors, colors)
 
     return write
 
@@ -302,3 +308,8 @@ def say(text, **options):
     write = render(text, **options)
     if write:
         click.echo(write)
+
+
+def _strip_color(text):
+    REGEX = re.compile(r'\x1b\[\d+?m')
+    return REGEX.sub('', text)

Background colour doesn't span entire line
While kicking the tires, I noticed that my output differed from the tutorial:

![image](https://user-images.githubusercontent.com/3307295/42124988-0220ea0a-7c6e-11e8-922a-e551d5c023b7.png)

I also tried outside of `ipython` from the CLI without any improvement.

- Terminal editor: kitty
- Shell: `zsh`
- `TERM=screen-256color`

Please let me know if there's any other information you need.

Really nice package, thanks for sharing!

PS: Also tried konsole terminal emulator with the same result.
diff --git a/tests/test_render.py b/tests/test_render.py
index 7f6906d..1154d40 100644
--- a/tests/test_render.py
+++ b/tests/test_render.py
@@ -12,7 +12,7 @@ def test_render_console():
 
 def test_render_console_with_color():
     text = render("text", font="console", colors=["red"], size=(100, 10))
-    assert text == "\n\n\x1b[31mtext\x1b[39m\n\n"
+    assert text == "\x1b[31m\n\ntext\n\n\x1b[39m"
 
 
 def test_render_invalid_input():
@@ -166,12 +166,12 @@ def test_render_remove_space():
 
 
 def test_render_background():
-    assert render("text", background="red", size=(100, 10)) == (
-        "\x1b[41m\n\n\n"
-        " ████████╗ ███████╗ ██╗  ██╗ ████████╗ \n"
-        " ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ \n"
-        "    ██║    █████╗    ╚███╔╝     ██║    \n"
-        "    ██║    ██╔══╝    ██╔██╗     ██║    \n"
-        "    ██║    ███████╗ ██╔╝ ██╗    ██║    \n"
-        "    ╚═╝    ╚══════╝ ╚═╝  ╚═╝    ╚═╝    \n\n\x1b[49m"
-    )
+    assert render("text", background="red", size=(50, 10)) == (
+        "\x1b[41m{0}\n{0}\n"
+        " ████████╗ ███████╗ ██╗  ██╗ ████████╗ {1}\n"
+        " ╚══██╔══╝ ██╔════╝ ╚██╗██╔╝ ╚══██╔══╝ {1}\n"
+        "    ██║    █████╗    ╚███╔╝     ██║    {1}\n"
+        "    ██║    ██╔══╝    ██╔██╗     ██║    {1}\n"
+        "    ██║    ███████╗ ██╔╝ ██╗    ██║    {1}\n"
+        "    ╚═╝    ╚══════╝ ╚═╝  ╚═╝    ╚═╝    {1}\n{0}\n{0}\x1b[49m"
+    ).format(" " * 50, " " * 11)

pip install -e .[dev]
parse_log_pytest
pytest
pytest
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
click==8.1.8
colorama==0.4.6
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
-e git+https://github.com/frostming/python-cfonts.git@689ea448083092139fbecc4f7e7406e19843badb#egg=python_cfonts
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work

name: python-cfonts
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - click==8.1.8
      - colorama==0.4.6
prefix: /opt/conda/envs/python-cfonts

tests/test_render.py::test_render_console_with_color tests/test_render.py::test_render_background
tests/test_render.py::test_render_console tests/test_render.py::test_render_invalid_input tests/test_render.py::test_render_block_font tests/test_render.py::test_render_letter_spacing tests/test_render.py::test_render_center_block_font tests/test_render.py::test_render_right_block_font tests/test_render.py::test_render_break_new_line tests/test_render.py::test_render_add_line_break tests/test_render.py::test_render_add_line_height tests/test_render.py::test_render_ignore_non_supported tests/test_render.py::test_render_remove_space
cfonts/core.py .gitignore .travis.yml README.md cfonts/__version__.py
cfonts/core.py .gitignore .travis.yml README.md cfonts/__version__.py