Skip to content

Having trouble installing libraqm #8232

Closed
@HectorsitoXD

Description

@HectorsitoXD

What did you do?

I am trying to install libraqm. I'm using Replit and I managed to install pillow, but when I try to use kern or liga as font features i am prompted an "Unable to use features without libraqm" error, so I tried to install it using "pip install libraqm" but that didn't work. I know very little about python and programming in general, so please be specific with me.

What did you expect to happen?

I expect the libraqm lib to be installed with no problem but it turned out to be more complex than a command in the shell.

What actually happened?

~/$ pip install libraqm
ERROR: Could not find a version that satisfies the requirement libraqm (from versions: none)
ERROR: No matching distribution found for libraqm

What are your OS, Python and Pillow versions?

  • OS: Replit
  • Python: I think Python 3
  • Pillow: I assume I installed the last Pillow version
Please paste here the output of running:

python3 -m PIL.report
or
python3 -m PIL --report

Or the output of the following Python code:

from PIL import report
# or
from PIL import features
features.pilinfo(supported_formats=False)

image

code goes here

import discord
from discord import app_commands
from discord.ext import commands
from PIL import Image, ImageDraw, ImageFont

token = '(token)'
bot = commands.Bot(command_prefix = ".", intents = discord.Intents.all())

from PIL import features
print (features.check('raqm'))

@bot.event
async def on_ready():
  print("Hello wolrd!")
  try:
    synced = await bot.tree.sync()
    print(f"Synced {len(synced)} command(s)")
  except Exception as e:
    print(e)

@bot.tree.command(name = "type", description = "Send an image of your text in BA")
@app_commands.describe(text = "Text to send")
@app_commands.allowed_installs(guilds=True, users=True)
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)

async def type(interaction: discord.Interaction, text: str):
  image = Image.new('RGBA', (1, 1), (0, 0, 0, 0))
  draw = ImageDraw.Draw(image)
  font = ImageFont.truetype("font.ttf", 50)

  x = int(draw.textlength(text, font=font, font_size=50, features=None))

  lines = 0
  if x > 500:
    list = text.split()
    print(list)
    chunk = ""
    new = ""
    lenghts = []
    c = -1
    for i in list:
      c += 1
      chunk = chunk + i
      print(chunk)
      x = int(draw.textlength(chunk, font=font, font_size=50, features=None))
      print(x)
      if x > 500:
        lenghts.append(x)
        print(lenghts)
        new = new + chunk + "\n"
        print(new)
        chunk = ""
        print(list.index(i))
        print(len(list))
        if c != len(list) - 1:
          lines = lines + 1
      else:
        chunk = chunk + " "
    new = new + chunk
    text = new
    lenghts.append(x)
    x = max(lenghts)
  print(lines)
  image = image.resize((x,50+44*lines))
  draw = ImageDraw.Draw(image)
  draw.multiline_text((0,0), text, (255,255,255), font=font, features=None)
  image.save("text.png")

  await interaction.response.send_message(
    file = discord.File("text.png")
    )

bot.run(token)

The code runs perfect as it is, but when I change features=None to features="kern" or features="liga" it prompts this error:
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions