Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5956099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:12:29+00:00 2026-05-22T18:12:29+00:00

I write a python script in order to generate a SVG file. This SVG

  • 0

I write a python script in order to generate a SVG file. This SVG file uses a web font ( imported from google webfonts via CSS ) to render my texts nicely. Everything is fine except I need to know the size (in pixel) of a sentence before putting it in my SVG file.

As I started learning python few days ago, I don’t know if this kind of stuff is possible. Google helped me to find the existence of the ImageFont python module (from the Python Imaging Library) but it seems ImageFont needs to load font file from a local path in order to compute character size.

Is there any chance a way to compute character size on a web font exists ?

Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:12:30+00:00Added an answer on May 22, 2026 at 6:12 pm

    You can achieve it on the client side with javascript and the SVG DOM.

    First step : create a text element and compute its length with the getComputedTextLength() method ( http://www.w3.org/TR/SVG11/text.html#InterfaceSVGTextContentElement )

    <text id="foo" xml:space="preserve">foo </text>
    

    Then compute the path length with the getTotalLength() method ( http://www.w3.org/TR/SVG11/paths.html#InterfaceSVGPathElement )

    And you can compute how many times you can put your text before it is truncated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a python script that packages our software. This script needs
I am trying to replace/modify a part of string in a python file from
I have a Python script I recently wrote that I call using the command
I would like to write some scripts in python that do some automated changes
I'm attempting to write a Python C extension that reads packed binary data (it
I've been wondering about how hard it would be to write some Python code
I need some help calculating Pi. I am trying to write a python program
Using PyObjC , you can use Python to write Cocoa applications for OS X.
I want to write a function in Python that returns different fixed values based
I am trying to write my first real python function that does something real.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.